aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libbb.h3
-rw-r--r--libbb/get_line_from_file.c15
2 files changed, 15 insertions, 3 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 0db1658f4..3a7c2eee9 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -618,7 +618,7 @@ extern char *xmalloc_fgets(FILE *file) FAST_FUNC;
618/* Chops off '\n' from the end, unlike fgets: */ 618/* Chops off '\n' from the end, unlike fgets: */
619extern char *xmalloc_fgetline(FILE *file) FAST_FUNC; 619extern char *xmalloc_fgetline(FILE *file) FAST_FUNC;
620/* Same, but doesn't try to conserve space (may have some slack after the end) */ 620/* Same, but doesn't try to conserve space (may have some slack after the end) */
621extern char *xmalloc_fgetline_fast(FILE *file) FAST_FUNC; 621/* extern char *xmalloc_fgetline_fast(FILE *file) FAST_FUNC; */
622 622
623extern void die_if_ferror(FILE *file, const char *msg) FAST_FUNC; 623extern void die_if_ferror(FILE *file, const char *msg) FAST_FUNC;
624extern void die_if_ferror_stdout(void) FAST_FUNC; 624extern void die_if_ferror_stdout(void) FAST_FUNC;
@@ -1006,6 +1006,7 @@ typedef struct parser_t {
1006} parser_t; 1006} parser_t;
1007extern FILE* config_open(parser_t *parser, const char *filename) FAST_FUNC; 1007extern FILE* config_open(parser_t *parser, const char *filename) FAST_FUNC;
1008#endif 1008#endif
1009/* TODO: add define magic to collapse ntokens/mintokens/comment into one int param */
1009extern char* config_read(parser_t *parser, char **tokens, int ntokens, int mintokens, const char *delims, char comment) FAST_FUNC; 1010extern char* config_read(parser_t *parser, char **tokens, int ntokens, int mintokens, const char *delims, char comment) FAST_FUNC;
1010extern void config_close(parser_t *parser) FAST_FUNC; 1011extern void config_close(parser_t *parser) FAST_FUNC;
1011 1012
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c
index 7b65ced8d..56761f941 100644
--- a/libbb/get_line_from_file.c
+++ b/libbb/get_line_from_file.c
@@ -68,12 +68,24 @@ char* FAST_FUNC xmalloc_fgetline(FILE *file)
68 return c; 68 return c;
69} 69}
70 70
71#if 0
71/* Faster routines (~twice as fast). +170 bytes. Unused as of 2008-07. 72/* Faster routines (~twice as fast). +170 bytes. Unused as of 2008-07.
72 * 73 *
73 * NB: they stop at NUL byte too. 74 * NB: they stop at NUL byte too.
74 * Performance is important here. Think "grep 50gigabyte_file"... 75 * Performance is important here. Think "grep 50gigabyte_file"...
75 * Iironically, grep can't use it because of NUL issue. 76 * Ironically, grep can't use it because of NUL issue.
76 * We sorely need C lib to provide fgets which reports size! 77 * We sorely need C lib to provide fgets which reports size!
78 *
79 * Update:
80 * Actually, uclibc and glibc have it. man getline. It's GNUism,
81 * but very useful one (if it's as fast as this code).
82 * TODO:
83 * - currently, sed and sort use bb_get_chunk_from_file and heavily
84 * depend on its "stop on \n or \0" behavior, and STILL they fail
85 * to handle all cases with embedded NULs correctly. So:
86 * - audit sed and sort; convert them to getline FIRST.
87 * - THEN ditch bb_get_chunk_from_file, replace it with getline.
88 * - provide getline implementation for non-GNU systems.
77 */ 89 */
78 90
79static char* xmalloc_fgets_internal(FILE *file, int *sizep) 91static char* xmalloc_fgets_internal(FILE *file, int *sizep)
@@ -118,7 +130,6 @@ char* FAST_FUNC xmalloc_fgetline_fast(FILE *file)
118 return r; /* not xrealloc(r, sz + 1)! */ 130 return r; /* not xrealloc(r, sz + 1)! */
119} 131}
120 132
121#if 0
122char* FAST_FUNC xmalloc_fgets(FILE *file) 133char* FAST_FUNC xmalloc_fgets(FILE *file)
123{ 134{
124 int sz; 135 int sz;