Drop strbuf's 'eof' marker, and make read_line a first class citizen.
read_line is now strbuf_getline, and is a first class citizen, it returns 0 when reading a line worked, EOF else. The ->eof marker was used non-locally by fast-import.c, mimic the same behaviour using a static int in "read_next_command", that now returns -1 on EOF, and avoids to call strbuf_getline when it's in EOF state. Also no longer automagically strbuf_release the buffer, it's counter intuitive and breaks fast-import in a very subtle way. Note: being at EOF implies that command_buf.len == 0. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
8b6087fb25
commit
e6c019d0b0
5
strbuf.h
5
strbuf.h
@ -44,11 +44,10 @@
|
||||
struct strbuf {
|
||||
size_t alloc;
|
||||
size_t len;
|
||||
int eof;
|
||||
char *buf;
|
||||
};
|
||||
|
||||
#define STRBUF_INIT { 0, 0, 0, NULL }
|
||||
#define STRBUF_INIT { 0, 0, NULL }
|
||||
|
||||
/*----- strbuf life cycle -----*/
|
||||
extern void strbuf_init(struct strbuf *, size_t);
|
||||
@ -101,6 +100,6 @@ extern size_t strbuf_fread(struct strbuf *, size_t, FILE *);
|
||||
/* XXX: if read fails, any partial read is undone */
|
||||
extern ssize_t strbuf_read(struct strbuf *, int fd, size_t hint);
|
||||
|
||||
extern void read_line(struct strbuf *, FILE *, int);
|
||||
extern int strbuf_getline(struct strbuf *, FILE *, int);
|
||||
|
||||
#endif /* STRBUF_H */
|
||||
|
||||
Reference in New Issue
Block a user