diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1994-08-15 19:31:15 -0400 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1994-08-15 19:31:15 -0400 |
commit | 0e7e3fc1a939404aa6e07d0467dc3643e33b9fd2 (patch) | |
tree | acaf8dc69047b83f6f119f67cf134116a47f6ffe | |
parent | b415f25eef56f3f037a1cbdcfe5ceec98138f8a6 (diff) | |
download | gcc-0e7e3fc1a939404aa6e07d0467dc3643e33b9fd2.zip gcc-0e7e3fc1a939404aa6e07d0467dc3643e33b9fd2.tar.gz gcc-0e7e3fc1a939404aa6e07d0467dc3643e33b9fd2.tar.bz2 |
(index0): New function.
(trigraph_pcp): Use index0 instead of index, so that a null byte
doesn't suppress further trigraph preprocessing.
From-SVN: r7934
-rw-r--r-- | gcc/cccp.c | 32 |
1 files changed, 30 insertions, 2 deletions
@@ -2195,6 +2195,33 @@ path_include (path) } } +/* Return the address of the first character in S that equals C. + S is an array of length N, possibly containing '\0's, and followed by '\0'. + Return 0 if there is no such character. Assume that C itself is not '\0'. + If we knew we could use memchr, we could just invoke memchr (S, C, N), + but unfortunately memchr isn't autoconfigured yet. */ + +static U_CHAR * +index0 (s, c, n) + U_CHAR *s; + int c; + int n; +{ + for (;;) { + char *q = index (s, c); + if (q) + return (U_CHAR *) q; + else { + int l = strlen (s); + if (l == n) + return 0; + l++; + s += l; + n -= l; + } + } +} + /* Pre-C-Preprocessor to translate ANSI trigraph idiocy in BUF before main CCCP processing. Name `pcp' is also in honor of the drugs the trigraph designers must have been on. @@ -2208,11 +2235,12 @@ static void trigraph_pcp (buf) FILE_BUF *buf; { - register U_CHAR c, *fptr, *bptr, *sptr; + register U_CHAR c, *fptr, *bptr, *sptr, *lptr; int len; fptr = bptr = sptr = buf->buf; - while ((sptr = (U_CHAR *) index (sptr, '?')) != NULL) { + lptr = fptr + buf->length; + while ((sptr = (U_CHAR *) index0 (sptr, '?', lptr - sptr)) != NULL) { if (*++sptr != '?') continue; switch (*++sptr) { |