summaryrefslogtreecommitdiff
path: root/strbuf.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-01-13 18:32:23 -0800
committerJunio C Hamano <gitster@pobox.com>2016-01-15 10:23:57 -0800
commit1a0c8dfd89475d6bb09ddee8c019cf0ae5b3bdc2 (patch)
treefea2d4a8ae1b60e90034f2bc3e40ce09978c5a6c /strbuf.h
parenta392f57daf7dc5e72ab3ada7802eddc000fa3081 (diff)
downloadgit-1a0c8dfd89475d6bb09ddee8c019cf0ae5b3bdc2.tar.gz
strbuf: give strbuf_getline() to the "most text friendly" variantjc/strbuf-getline
Now there is no direct caller to strbuf_getline(), we can demote it to file-scope static that is private to strbuf.c and rename it to strbuf_getdelim(). Rename strbuf_getline_crlf(), which is designed to be the most "text friendly" variant, and allow it to take over this simplest name, strbuf_getline(), so we can add more uses of it without having to type _crlf over and over again in the coming steps. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.h')
-rw-r--r--strbuf.h22
1 files changed, 10 insertions, 12 deletions
diff --git a/strbuf.h b/strbuf.h
index e56ec77e2b..970c24ab43 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 *);
@@ -379,19 +379,14 @@ extern ssize_t strbuf_read_file(struct strbuf *sb, const char *path, size_t hint
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'`.
+ * Read a line from a FILE *, overwriting the existing contents of
+ * the strbuf. The strbuf_getline*() family of functions share
+ * this signature, but have different line termination conventions.
+ *
* 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);
-
-/**
- * The strbuf_getline*() family of functions share this signature, but
- * have different line termination conventions.
- */
typedef int (*strbuf_getline_fn)(struct strbuf *, FILE *);
/* Uses LF as the line terminator */
@@ -403,8 +398,11 @@ extern int strbuf_getline_nul(struct strbuf *sb, FILE *fp);
/*
* Similar to strbuf_getline_lf(), but additionally treats a CR that
* comes immediately before the LF as part of the terminator.
+ * This is the most friendly version to be used to read "text" files
+ * that can come from platforms whose native text format is CRLF
+ * terminated.
*/
-extern int strbuf_getline_crlf(struct strbuf *, FILE *);
+extern int strbuf_getline(struct strbuf *, FILE *);
/**