summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e75316d)
raw | patch | inline | side by side (parent: e75316d)
author | Jonathan Nieder <jrnieder@gmail.com> | |
Mon, 11 Oct 2010 02:51:21 +0000 (21:51 -0500) | ||
committer | Jonathan Nieder <jrnieder@gmail.com> | |
Mon, 7 Mar 2011 07:32:51 +0000 (01:32 -0600) |
The line_buffer library silently flags input errors until
buffer_deinit time; unfortunately, by that point usually errno is
invalid. Expose the error flag so callers can check for and
report errors early for easy debugging.
some_error_prone_operation(...);
if (buffer_ferror(buf))
return error("input error: %s", strerror(errno));
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
buffer_deinit time; unfortunately, by that point usually errno is
invalid. Expose the error flag so callers can check for and
report errors early for easy debugging.
some_error_prone_operation(...);
if (buffer_ferror(buf))
return error("input error: %s", strerror(errno));
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
vcs-svn/line_buffer.c | patch | blob | history | |
vcs-svn/line_buffer.h | patch | blob | history |
diff --git a/vcs-svn/line_buffer.c b/vcs-svn/line_buffer.c
index aedf105b70586f2ef7567547426bb6622799b067..eb8a6a7f7b67fb56f28f42e39b92736f91b0af85 100644 (file)
--- a/vcs-svn/line_buffer.c
+++ b/vcs-svn/line_buffer.c
return pos;
}
+int buffer_ferror(struct line_buffer *buf)
+{
+ return ferror(buf->infile);
+}
+
int buffer_read_char(struct line_buffer *buf)
{
return fgetc(buf->infile);
diff --git a/vcs-svn/line_buffer.h b/vcs-svn/line_buffer.h
index 96ce966a229110e6775cd33ee01a93d5f133404e..3c9629e09d3442acb1216754cdc4721ffba89c1b 100644 (file)
--- a/vcs-svn/line_buffer.h
+++ b/vcs-svn/line_buffer.h
FILE *buffer_tmpfile_rewind(struct line_buffer *buf); /* prepare to write. */
long buffer_tmpfile_prepare_to_read(struct line_buffer *buf);
+int buffer_ferror(struct line_buffer *buf);
char *buffer_read_line(struct line_buffer *buf);
char *buffer_read_string(struct line_buffer *buf, uint32_t len);
int buffer_read_char(struct line_buffer *buf);