mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-22 07:30:43 +00:00
windows-port iterate
This commit is contained in:
parent
70ba319392
commit
1daee5bac4
5 changed files with 13 additions and 5 deletions
|
|
@ -339,11 +339,13 @@ TEST_JOIN_BUCKET_KEEPER_SRCS = \
|
|||
|
||||
EXPERIMENTAL_READER_SRCS = \
|
||||
lib/mlrutil.c \
|
||||
lib/mlrdatetime.c \
|
||||
lib/mlr_arch.c \
|
||||
lib/mtrand.c \
|
||||
lib/mlrescape.c \
|
||||
lib/mlrregex.c \
|
||||
lib/mlr_globals.c \
|
||||
lib/string_array.c \
|
||||
lib/string_builder.c \
|
||||
input/stdio_byte_reader.c \
|
||||
input/file_reader_mmap.c \
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "lib/mlr_globals.h"
|
||||
#include "lib/mlr_arch.h"
|
||||
#include "lib/mlrutil.h"
|
||||
#include "lib/mlrdatetime.h"
|
||||
#include "input/file_reader_stdio.h"
|
||||
#include "input/file_reader_mmap.h"
|
||||
#include "input/lrec_readers.h"
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ char* mlr_get_cline2(FILE* fp, char irs) {
|
|||
if (p == line)
|
||||
eof = TRUE;
|
||||
*p = 0;
|
||||
p++;
|
||||
break;
|
||||
} else {
|
||||
*(p++) = c;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <string.h>
|
||||
#include "mlr_globals.h"
|
||||
#include "mlr_arch.h"
|
||||
#include "mlrutil.h"
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
int mlr_arch_setenv(const char *name, const char *value) {
|
||||
|
|
@ -35,7 +36,10 @@ char * mlr_arch_strsep(char **pstring, const char *delim) {
|
|||
|
||||
// ----------------------------------------------------------------
|
||||
#ifdef MLR_ON_MSYS2
|
||||
static int mlr_arch_getdelim(char** restrict pline, size_t* restrict plinecap, int delimiter, FILE* restrict stream) {
|
||||
|
||||
// Use powers of two exclusively, to help avoid heap fragmentation
|
||||
#define INITIAL_SIZE 128
|
||||
static int local_getdelim(char** restrict pline, size_t* restrict plinecap, int delimiter, FILE* restrict stream) {
|
||||
size_t linecap = INITIAL_SIZE;
|
||||
char* restrict line = mlr_malloc_or_die(INITIAL_SIZE);
|
||||
char* restrict p = line;
|
||||
|
|
@ -52,6 +56,7 @@ static int mlr_arch_getdelim(char** restrict pline, size_t* restrict plinecap, i
|
|||
c = mlr_arch_getc(stream);
|
||||
if (c == delimiter) {
|
||||
*p = 0;
|
||||
p++;
|
||||
break;
|
||||
} else if (c == EOF) {
|
||||
if (p == line)
|
||||
|
|
@ -67,7 +72,7 @@ static int mlr_arch_getdelim(char** restrict pline, size_t* restrict plinecap, i
|
|||
free(line);
|
||||
*pline = NULL;
|
||||
*plinecap = 0;
|
||||
return 0;
|
||||
return -1;
|
||||
} else {
|
||||
*pline = line;
|
||||
*plinecap = linecap;
|
||||
|
|
@ -81,7 +86,6 @@ ssize_t mlr_arch_getdelim(char** restrict pline, size_t* restrict plinecap, int
|
|||
#ifndef MLR_ON_MSYS2
|
||||
return getdelim(pline, plinecap, delimiter, stream);
|
||||
#else
|
||||
char* retval = mlr_get_cline2(stream, delimiter);
|
||||
return local_getdelim(pline, plinecap, delimiter, stream);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ MSYS2 TO-DO
|
|||
|
||||
! msys2 / pacman -S / etc @ appveyor
|
||||
|
||||
! getdelim
|
||||
~ getdelim
|
||||
|
||||
! strsep
|
||||
~ strsep
|
||||
|
||||
k get_unlocked / getc:
|
||||
k @ mlr_arch.h: ifdef MSYS2 define getc_unlocked(x) getc(x)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue