diff options
author | Denis Vlasenko | 2008-03-26 20:04:27 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-03-26 20:04:27 +0000 |
commit | 8ee649a02e97e9d4e770a8138ba94c0f3ddd8055 (patch) | |
tree | cf13ce448542a36595264ad53397a0633ffedcc8 /libbb | |
parent | ce7eb4443cc90038aabc19a8b7b8f25e4b88892e (diff) | |
download | busybox-8ee649a02e97e9d4e770a8138ba94c0f3ddd8055.zip busybox-8ee649a02e97e9d4e770a8138ba94c0f3ddd8055.tar.gz |
*: more uniform naming: s/xmalloc_getline/xmalloc_fgetline/
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/get_line_from_file.c | 2 | ||||
-rw-r--r-- | libbb/lineedit.c | 2 | ||||
-rw-r--r-- | libbb/read.c | 11 |
3 files changed, 8 insertions, 7 deletions
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c index ac4d14b..b88872d 100644 --- a/libbb/get_line_from_file.c +++ b/libbb/get_line_from_file.c @@ -57,7 +57,7 @@ char *xmalloc_fgets(FILE *file) } /* Get line. Remove trailing \n */ -char *xmalloc_getline(FILE *file) +char *xmalloc_fgetline(FILE *file) { int i; char *c = bb_get_chunk_from_file(file, &i); diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 5d65665..4ba61c1 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -969,7 +969,7 @@ static void load_history(const char *fromfile) } for (hi = 0; hi < MAX_HISTORY;) { - char *hl = xmalloc_getline(fp); + char *hl = xmalloc_fgetline(fp); int l; if (!hl) diff --git a/libbb/read.c b/libbb/read.c index 9c025e3..1d31fb0 100644 --- a/libbb/read.c +++ b/libbb/read.c @@ -141,7 +141,7 @@ char *reads(int fd, char *buffer, size_t size) off_t offset; *p++ = '\0'; // avoid incorrect (unsigned) widening - offset = (off_t)(p-buffer) - (off_t)size; + offset = (off_t)(p - buffer) - (off_t)size; // set fd position right after '\n' if (offset && lseek(fd, offset, SEEK_CUR) == (off_t)-1) return NULL; @@ -149,8 +149,8 @@ char *reads(int fd, char *buffer, size_t size) return buffer; } -// Read one line a-la fgets. Reads byte-by-byte. -// Useful when it is important to not read ahead. +// Reads one line a-la fgets (but doesn't save terminating '\n'). +// Reads byte-by-byte. Useful when it is important to not read ahead. // Bytes are appended to pfx (which must be malloced, or NULL). char *xmalloc_reads(int fd, char *buf, size_t *maxsz_p) { @@ -178,9 +178,10 @@ char *xmalloc_reads(int fd, char *buf, size_t *maxsz_p) break; p++; } - *p++ = '\0'; + *p = '\0'; if (maxsz_p) - *maxsz_p = p - buf - 1; + *maxsz_p = p - buf; + p++; return xrealloc(buf, p - buf); } |