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