a2a915
? patch
a2a915
? lib/isc/lex.c.rh490837
a2a915
Index: lib/isc/lex.c
a2a915
===================================================================
a2a915
RCS file: /var/snap/bind9/lib/isc/lex.c,v
a2a915
retrieving revision 1.86
a2a915
diff -p -u -r1.86 lex.c
a2a915
--- lib/isc/lex.c	17 Sep 2007 09:56:29 -0000	1.86
a2a915
+++ lib/isc/lex.c	6 Apr 2009 13:24:15 -0000
a2a915
@@ -425,17 +425,14 @@ isc_lex_gettoken(isc_lex_t *lex, unsigne
a2a915
 			if (source->is_file) {
a2a915
 				stream = source->input;
a2a915
 
a2a915
-#if defined(HAVE_FLOCKFILE) && defined(HAVE_GETCUNLOCKED)
a2a915
-				c = getc_unlocked(stream);
a2a915
-#else
a2a915
-				c = getc(stream);
a2a915
-#endif
a2a915
-				if (c == EOF) {
a2a915
-					if (ferror(stream)) {
a2a915
-						source->result = ISC_R_IOERROR;
a2a915
-						result = source->result;
a2a915
+				result = isc_stdio_fgetc(stream, &c);
a2a915
+
a2a915
+				if (result != ISC_R_SUCCESS) {
a2a915
+					if (result != ISC_R_EOF) {
a2a915
+						source->result = result;
a2a915
 						goto done;
a2a915
 					}
a2a915
+
a2a915
 					source->at_eof = ISC_TRUE;
a2a915
 				}
a2a915
 			} else {
a2a915
Index: lib/isc/include/isc/stdio.h
a2a915
===================================================================
a2a915
RCS file: /var/snap/bind9/lib/isc/include/isc/stdio.h,v
a2a915
retrieving revision 1.13
a2a915
diff -p -u -r1.13 stdio.h
a2a915
--- lib/isc/include/isc/stdio.h	19 Jun 2007 23:47:18 -0000	1.13
a2a915
+++ lib/isc/include/isc/stdio.h	6 Apr 2009 13:24:15 -0000
a2a915
@@ -72,6 +72,9 @@ isc_stdio_sync(FILE *f);
a2a915
  * direct counterpart in the stdio library.
a2a915
  */
a2a915
 
a2a915
+isc_result_t
a2a915
+isc_stdio_fgetc(FILE *f, int *ret);
a2a915
+
a2a915
 ISC_LANG_ENDDECLS
a2a915
 
a2a915
 #endif /* ISC_STDIO_H */
a2a915
Index: lib/isc/unix/errno2result.c
a2a915
===================================================================
a2a915
RCS file: /var/snap/bind9/lib/isc/unix/errno2result.c,v
a2a915
retrieving revision 1.17
a2a915
diff -p -u -r1.17 errno2result.c
a2a915
--- lib/isc/unix/errno2result.c	19 Jun 2007 23:47:18 -0000	1.17
a2a915
+++ lib/isc/unix/errno2result.c	6 Apr 2009 13:24:15 -0000
a2a915
@@ -43,6 +43,7 @@ isc__errno2result(int posixerrno) {
a2a915
 	case EINVAL:		/* XXX sometimes this is not for files */
a2a915
 	case ENAMETOOLONG:
a2a915
 	case EBADF:
a2a915
+	case EISDIR:
a2a915
 		return (ISC_R_INVALIDFILE);
a2a915
 	case ENOENT:
a2a915
 		return (ISC_R_FILENOTFOUND);
a2a915
Index: lib/isc/unix/stdio.c
a2a915
===================================================================
a2a915
RCS file: /var/snap/bind9/lib/isc/unix/stdio.c,v
a2a915
retrieving revision 1.8
a2a915
diff -p -u -r1.8 stdio.c
a2a915
--- lib/isc/unix/stdio.c	19 Jun 2007 23:47:18 -0000	1.8
a2a915
+++ lib/isc/unix/stdio.c	6 Apr 2009 13:24:15 -0000
a2a915
@@ -115,3 +115,22 @@ isc_stdio_sync(FILE *f) {
a2a915
 		return (isc__errno2result(errno));
a2a915
 }
a2a915
 
a2a915
+isc_result_t
a2a915
+isc_stdio_fgetc(FILE *f, int *ret) {
a2a915
+	int r;
a2a915
+	isc_result_t result = ISC_R_SUCCESS;
a2a915
+
a2a915
+#if defined(HAVE_FLOCKFILE) && defined(HAVE_GETCUNLOCKED)
a2a915
+	r = fgetc_unlocked(f);
a2a915
+#else
a2a915
+	r = fgets(f);
a2a915
+#endif
a2a915
+
a2a915
+	if (r == EOF)
a2a915
+		result = ferror(f) ? isc__errno2result(errno) : ISC_R_EOF;
a2a915
+
a2a915
+	*ret = r;
a2a915
+
a2a915
+	return result;
a2a915
+}
a2a915
+