From: Bruce Korb Date: Fri, 12 May 2000 16:35:21 +0000 (+0000) Subject: buglet & relaxed rules X-Git-Tag: prereleases/libstdc++-2.92~6468 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a92fa6087356629b7810c7e8368645b394aba980;p=thirdparty%2Fgcc.git buglet & relaxed rules From-SVN: r33877 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d5ff1679f754..bf19c4496722 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -41,6 +41,10 @@ (LABEL_NUSES, LABEL_REFS): Likewise. * unroll.c (copy_loop_body): Don't copy NOTE_INSN_DELETED_LABEL. +2000-05-12 Bruce Korb + + * fixinc/fixfixes.c(format_write): buglet & relaxed rules + 2000-05-12 Zack Weinberg * fixinc/fixfixes.c (IO_use_fix, IO_defn_fix, CTRL_use_fix, diff --git a/gcc/fixinc/fixfixes.c b/gcc/fixinc/fixfixes.c index 1dfa5a7ce28a..90b8fd814abe 100644 --- a/gcc/fixinc/fixfixes.c +++ b/gcc/fixinc/fixfixes.c @@ -127,32 +127,54 @@ format_write (format, text, av) tCC* text; regmatch_t av[]; { - tCC *p, *str; int c; - size_t len; - - for (p = 0; *p; p++) { - c = *p; - if (c != '%') { - putchar(c); - continue; - } - - c = *++p; - if (c == '%') { - putchar(c); - continue; - } else if (c < '0' || c > '9') { - abort(); - } - - c -= '0'; - str = text + av[c].rm_so; - len = av[c].rm_eo - av[c].rm_so; - fwrite(str, len, 1, stdout); + + while ((c = (unsigned)*(format++)) != NUL) { + + if (c != '%') { + putchar(c); + continue; + } + + c = (unsigned)*(format++); + + /* + * IF the character following a '%' is not a digit, + * THEN we will always emit a '%' and we may or may + * not emit the following character. We will end on + * a NUL and we will emit only one of a pair of '%'. + */ + if (! isdigit( c )) { + putchar( '%' ); + switch (c) { + case NUL: + return; + case '%': + break; + default: + putchar(c); + } + } + + /* + * Emit the matched subexpression numbered 'c'. + * IF, of course, there was such a match... + */ + else { + regmatch_t* pRM = av + (c - (unsigned)'0'); + size_t len; + + if (pRM->rm_so < 0) + continue; + + len = pRM->rm_eo - pRM->rm_so; + if (len > 0) + fwrite(text + pRM->rm_so, len, 1, stdout); + } } } + FIX_PROC_HEAD( format_fix ) { tSCC zBad[] = "fixincl error: `%s' needs %s c_fix_arg\n";