+2003-09-14 Bruno Haible <bruno@clisp.org>
+
+ More reliable checking for read errors.
+ * po-lex.c (mbfile_getc): Diagnose read errors also in the middle of
+ multibyte characters.
+ (lex_getc): Diagnose read errors also right after backslash.
+ * x-rst.c (extract_rst): Diagnose read errors also inside ConstName
+ and immediately after #.
+
2003-09-14 Bruno Haible <bruno@clisp.org>
* write-mo.c: Include fwriterror.h.
* user-email.in: Use 'gettext' instead of @PACKAGE@.
-See ChangeLog.0 for earlier changes.
+See ChangeLog.0 for earlier changes.
\ No newline at end of file
mbf->bufcount = 0;
}
+/* Read the next multibyte character from mbf and put it into mbc.
+ If a read error occurs, errno is set and ferror (mbf->fp) becomes true. */
static void
mbfile_getc (mbchar_t mbc, mbfile_t mbf)
{
if (c == EOF)
{
mbf->eof_seen = true;
+ if (ferror (mbf->fp))
+ goto eof;
if (signal_eilseq)
po_gram_error (_("\
incomplete multibyte sequence at end of file"));
{
/* Read one more byte. */
int c = getc (mbf->fp);
- if (c != EOF)
+ if (c == EOF)
+ {
+ if (ferror (mbf->fp))
+ {
+ mbf->eof_seen = true;
+ goto eof;
+ }
+ }
+ else
{
mbf->buf[1] = (unsigned char) c;
mbf->bufcount++;
if (mb_iseof (mbc))
{
if (ferror (mbf->fp))
- error (EXIT_FAILURE, errno, _("error while reading \"%s\""),
- gram_pos.file_name);
+ {
+ bomb:
+ error (EXIT_FAILURE, errno, _("error while reading \"%s\""),
+ gram_pos.file_name);
+ }
break;
}
mbfile_getc (mbc2, mbf);
+ if (mb_iseof (mbc2))
+ {
+ if (ferror (mbf->fp))
+ goto bomb;
+ break;
+ }
+
if (!mb_iseq (mbc2, '\n'))
{
- if (!mb_iseof (mbc2))
- mbfile_ungetc (mbc2, mbf);
+ mbfile_ungetc (mbc2, mbf);
break;
}
break;
buffer[bufpos++] = c;
c = getc (f);
+ if (c == EOF && ferror (f))
+ goto bomb;
}
buffer[bufpos] = '\0';
location = xstrdup (buffer);
{
int n;
c = getc (f);
+ if (c == EOF && ferror (f))
+ goto bomb;
if (c == EOF || !isdigit (c))
{
error_with_progname = false;
}
if (ferror (f))
- error (EXIT_FAILURE, errno, _("error while reading \"%s\""),
- real_filename);
+ {
+ bomb:
+ error (EXIT_FAILURE, errno, _("error while reading \"%s\""),
+ real_filename);
+ }
}