-/* Read bytes from FP into buffer BUF of size SIZE. Return the
- number of bytes read. Remove '\r' from input, treating \r\n
- and isolated \r as \n. */
-
-static size_t
-no_cr_read (FILE *fp, char *buf, size_t size)
-{
- size_t s = fread (buf, 1, size, fp);
- if (s)
- {
- char *w = memchr (buf, '\r', s);
- if (w)
- {
- char const *r = ++w;
- char const *lim = buf + s;
-
- for (;;)
- {
- /* Found an '\r'. Treat it like '\n', but ignore any
- '\n' that immediately follows. */
- w[-1] = '\n';
- if (r == lim)
- {
- int ch = getc (fp);
- if (ch != '\n' && ungetc (ch, fp) != ch)
- break;
- }
- else if (*r == '\n')
- r++;
-
- /* Copy until the next '\r'. */
- do
- {
- if (r == lim)
- return w - buf;
- }
- while ((*w++ = *r++) != '\r');
- }
-
- return w - buf;
- }
- }
-
- return s;
-}
-
-
-/* Extend *LOC to account for token TOKEN of size SIZE. */
-
-static void
-extend_location (location_t *loc, char const *token, int size)
-{
- int line = loc->last_line;
- int column = loc->last_column;
- char const *p0 = token;
- char const *p = token;
- char const *lim = token + size;
-
- for (p = token; p < lim; p++)
- switch (*p)
- {
- case '\r':
- /* \r shouldn't survive no_cr_read. */
- abort ();
-
- case '\n':
- line++;
- column = 1;
- p0 = p + 1;
- break;
-
- case '\t':
- column += mbsnwidth (p0, p - p0, 0);
- column += 8 - ((column - 1) & 7);
- p0 = p + 1;
- break;
- }
-
- loc->last_line = line;
- loc->last_column = column + mbsnwidth (p0, p - p0, 0);
-}
-
-
-/* Report an unexpected end of file at LOC. A token or comment began
- with TOKEN_START, but an end of file was encountered and the
- expected TOKEN_END was missing. */
-
-static void
-unexpected_end_of_file (location_t loc,
- char const *token_start, char const *token_end)
-{
- complain_at (loc, _("unexpected end of file in `%s ... %s'"),
- token_start, token_end);
-}
-
-
-
-/* STRING_OBSTACK -- Used to store all the characters that we need to