Now there is no direct caller to strbuf_getline(), so demote it to file-scope static private to strbuf.c implementation and rename it to strbuf_getdelim(). Eventually, we may want to make this short and clean name a synonym to strbuf_getline_crlf(), but not now. Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- strbuf.c | 6 +++--- strbuf.h | 21 +++++++++++---------- transport-helper.c | 3 ++- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/strbuf.c b/strbuf.c index 2ff898c..a8641cb 100644 --- a/strbuf.c +++ b/strbuf.c @@ -501,7 +501,7 @@ int strbuf_getwholeline(struct strbuf *sb, FILE *fp, int term) } #endif -int strbuf_getline(struct strbuf *sb, FILE *fp, int term) +static int strbuf_getdelim(struct strbuf *sb, FILE *fp, int term) { if (strbuf_getwholeline(sb, fp, term)) return EOF; @@ -524,12 +524,12 @@ int strbuf_getline_crlf(struct strbuf *sb, FILE *fp) int strbuf_getline_lf(struct strbuf *sb, FILE *fp) { - return strbuf_getline(sb, fp, '\n'); + return strbuf_getdelim(sb, fp, '\n'); } int strbuf_getline_nul(struct strbuf *sb, FILE *fp) { - return strbuf_getline(sb, fp, '\0'); + return strbuf_getdelim(sb, fp, '\0'); } int strbuf_getwholeline_fd(struct strbuf *sb, int fd, int term) diff --git a/strbuf.h b/strbuf.h index 5501743..ea2a51f 100644 --- a/strbuf.h +++ b/strbuf.h @@ -354,8 +354,8 @@ extern void strbuf_addftime(struct strbuf *sb, const char *fmt, const struct tm * * NOTE: The buffer is rewound if the read fails. If -1 is returned, * `errno` must be consulted, like you would do for `read(3)`. - * `strbuf_read()`, `strbuf_read_file()` and `strbuf_getline()` has the - * same behaviour as well. + * `strbuf_read()`, `strbuf_read_file()` and `strbuf_getline_*()` + * family of functions have the same behaviour as well. */ extern size_t strbuf_fread(struct strbuf *, size_t, FILE *); @@ -380,24 +380,25 @@ extern int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint); /** * Read a line from a FILE *, overwriting the existing contents - * of the strbuf. The second argument specifies the line - * terminator character, typically `'\n'`. + * of the strbuf. There are three public functions with this + * function signature, with different line termination convention. * Reading stops after the terminator or at EOF. The terminator * is removed from the buffer before returning. Returns 0 unless * there was nothing left before EOF, in which case it returns `EOF`. */ -extern int strbuf_getline(struct strbuf *, FILE *, int); - typedef int (*strbuf_getline_fn)(struct strbuf *, FILE *); +/* Uses LF as the line terminator */ extern int strbuf_getline_lf(struct strbuf *sb, FILE *fp); + +/* Uses NUL as the line terminator */ extern int strbuf_getline_nul(struct strbuf *sb, FILE *fp); -/* - * Similar to strbuf_getline(), but uses '\n' as the terminator, - * and additionally treats a '\r' that comes immediately before '\n' - * as part of the terminator. +/** + * Similar to strbuf_getline_lf(), but additionally treats + * a '\r' that comes immediately before '\n' as part of the + * terminator. */ extern int strbuf_getline_crlf(struct strbuf *, FILE *); diff --git a/transport-helper.c b/transport-helper.c index 74eb217..d108336 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -137,7 +137,8 @@ static struct child_process *get_helper(struct transport *transport) data->no_disconnect_req = 0; /* - * Open the output as FILE* so strbuf_getline() can be used. + * Open the output as FILE* so strbuf_getline_*() family of + * functions can be used. * Do this with duped fd because fclose() will close the fd, * and stuff like taking over will require the fd to remain. */ -- 2.7.0-242-gdd583c7 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html