2018-10-19 15:52:10 +00:00
|
|
|
diff --git a/lib/isc/include/isc/stdio.h b/lib/isc/include/isc/stdio.h
|
|
|
|
index 1f44b5a..a3625f9 100644
|
|
|
|
--- a/lib/isc/include/isc/stdio.h
|
|
|
|
+++ b/lib/isc/include/isc/stdio.h
|
|
|
|
@@ -69,6 +69,9 @@ isc_stdio_sync(FILE *f);
|
|
|
|
* direct counterpart in the stdio library.
|
|
|
|
*/
|
|
|
|
|
|
|
|
+isc_result_t
|
|
|
|
+isc_stdio_fgetc(FILE *f, int *ret);
|
|
|
|
+
|
|
|
|
ISC_LANG_ENDDECLS
|
|
|
|
|
|
|
|
#endif /* ISC_STDIO_H */
|
|
|
|
diff --git a/lib/isc/lex.c b/lib/isc/lex.c
|
2019-04-09 18:15:24 +00:00
|
|
|
index ca5fe6d..b0152eb 100644
|
2018-10-19 15:52:10 +00:00
|
|
|
--- a/lib/isc/lex.c
|
|
|
|
+++ b/lib/isc/lex.c
|
2019-04-09 18:15:24 +00:00
|
|
|
@@ -433,15 +433,11 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
|
2009-04-24 15:29:06 +00:00
|
|
|
if (source->is_file) {
|
|
|
|
stream = source->input;
|
|
|
|
|
2019-04-09 18:15:24 +00:00
|
|
|
-#if defined(HAVE_FLOCKFILE) && defined(HAVE_GETC_UNLOCKED)
|
2009-04-24 15:29:06 +00:00
|
|
|
- c = getc_unlocked(stream);
|
|
|
|
-#else
|
|
|
|
- c = getc(stream);
|
|
|
|
-#endif
|
|
|
|
- if (c == EOF) {
|
|
|
|
- if (ferror(stream)) {
|
|
|
|
- source->result = ISC_R_IOERROR;
|
|
|
|
- result = source->result;
|
|
|
|
+ result = isc_stdio_fgetc(stream, &c);
|
|
|
|
+
|
|
|
|
+ if (result != ISC_R_SUCCESS) {
|
|
|
|
+ if (result != ISC_R_EOF) {
|
|
|
|
+ source->result = result;
|
|
|
|
goto done;
|
|
|
|
}
|
2018-10-19 15:52:10 +00:00
|
|
|
source->at_eof = true;
|
|
|
|
diff --git a/lib/isc/unix/errno2result.c b/lib/isc/unix/errno2result.c
|
2019-04-09 18:15:24 +00:00
|
|
|
index d72d56f..4287ff3 100644
|
2018-10-19 15:52:10 +00:00
|
|
|
--- a/lib/isc/unix/errno2result.c
|
|
|
|
+++ b/lib/isc/unix/errno2result.c
|
2019-04-09 18:15:24 +00:00
|
|
|
@@ -42,6 +42,7 @@ isc___errno2result(int posixerrno, bool dolog,
|
2009-04-24 15:29:06 +00:00
|
|
|
case EINVAL: /* XXX sometimes this is not for files */
|
|
|
|
case ENAMETOOLONG:
|
|
|
|
case EBADF:
|
|
|
|
+ case EISDIR:
|
|
|
|
return (ISC_R_INVALIDFILE);
|
|
|
|
case ENOENT:
|
|
|
|
return (ISC_R_FILENOTFOUND);
|
2018-10-19 15:52:10 +00:00
|
|
|
diff --git a/lib/isc/unix/stdio.c b/lib/isc/unix/stdio.c
|
2019-04-09 18:15:24 +00:00
|
|
|
index d2b1dda..79630b2 100644
|
2018-10-19 15:52:10 +00:00
|
|
|
--- a/lib/isc/unix/stdio.c
|
|
|
|
+++ b/lib/isc/unix/stdio.c
|
2019-04-09 18:15:24 +00:00
|
|
|
@@ -141,3 +141,22 @@ isc_stdio_sync(FILE *f) {
|
2009-04-24 15:29:06 +00:00
|
|
|
return (isc__errno2result(errno));
|
|
|
|
}
|
|
|
|
|
|
|
|
+isc_result_t
|
|
|
|
+isc_stdio_fgetc(FILE *f, int *ret) {
|
|
|
|
+ int r;
|
|
|
|
+ isc_result_t result = ISC_R_SUCCESS;
|
|
|
|
+
|
|
|
|
+#if defined(HAVE_FLOCKFILE) && defined(HAVE_GETCUNLOCKED)
|
|
|
|
+ r = fgetc_unlocked(f);
|
|
|
|
+#else
|
2019-04-09 18:15:24 +00:00
|
|
|
+ r = fgetc(f);
|
2009-04-24 15:29:06 +00:00
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ if (r == EOF)
|
|
|
|
+ result = ferror(f) ? isc__errno2result(errno) : ISC_R_EOF;
|
|
|
|
+
|
|
|
|
+ *ret = r;
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+}
|
|
|
|
+
|