diff options
author | Zack Weinberg <zack@wolery.cumb.org> | 2000-01-19 21:41:04 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-01-19 21:41:04 +0000 |
commit | 5c0d5b94d1952d982318d3fa4ae2b2bace4178ca (patch) | |
tree | 071d4198056ed723a6710483d992b94bb6261350 /gcc/fixinc/fixtests.c | |
parent | 5170877a059f586a13fe0fea6bb466fddb1a0f28 (diff) | |
download | gcc-5c0d5b94d1952d982318d3fa4ae2b2bace4178ca.zip gcc-5c0d5b94d1952d982318d3fa4ae2b2bace4178ca.tar.gz gcc-5c0d5b94d1952d982318d3fa4ae2b2bace4178ca.tar.bz2 |
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
Diffstat (limited to 'gcc/fixinc/fixtests.c')
-rw-r--r-- | gcc/fixinc/fixtests.c | 100 |
1 files changed, 42 insertions, 58 deletions
diff --git a/gcc/fixinc/fixtests.c b/gcc/fixinc/fixtests.c index 941b1ee..22fea35 100644 --- a/gcc/fixinc/fixtests.c +++ b/gcc/fixinc/fixtests.c @@ -153,9 +153,9 @@ TEST_FOR_FIX_PROC_HEAD( else_endif_label_test ) static regex_t label_re; char ch; - tCC* pz_next = (char*)NULL; + tCC* pz_next; + tCC* all_text = text; regmatch_t match[2]; - t_bool file_is_cxx = is_cxx_header( fname, text ); /* This routine may be run many times within a single execution. @@ -170,20 +170,14 @@ TEST_FOR_FIX_PROC_HEAD( else_endif_label_test ) for (;;) /* entire file */ { - /* - See if we need to advance to the next candidate directive - If the scanning pointer passes over the end of the directive, - then the directive is inside a comment */ - if (pz_next < text) - { - if (regexec (&label_re, text, 2, match, 0) != 0) - break; - pz_next = text + match[0].rm_eo; - } - - /* - IF the scan pointer has not reached the directive end, ... */ - if (pz_next > text) + /* Find the next else or endif in the file. */ + if (regexec (&label_re, text, 2, match, 0) != 0) + break; + pz_next = text + match[0].rm_eo; + + /* Scan from where we are up to that position, to make sure + we didn't find something in a string or comment. */ + while (pz_next > text) { /* Advance the scanning pointer. If we are at the start @@ -209,34 +203,23 @@ TEST_FOR_FIX_PROC_HEAD( else_endif_label_test ) case '\'': text = skip_quote( ch, text ); break; - } /* switch (ch) */ - continue; - } /* if (still shy of directive end) */ + } + } + if (pz_next < text) + continue; - /* - The scanning pointer (text) has reached the end of the current - directive under test, then check for bogons here */ - for (;;) /* bogon check */ + /* We're at the end of a real directive. Check for bogons here. */ + for (;;) { char ch = *(pz_next++); - if (isspace (ch)) - { - if (ch == '\n') - { - /* - It is clean. No bogons on this directive */ - text = pz_next; - pz_next = (char*)NULL; /* force a new regex search */ - break; - } - continue; - } + switch (ch) + { + case '\n': + /* It is clean. No bogons on this directive. */ + goto next_directive; - switch (ch) - { case '\\': - /* - Skip escaped newlines. Otherwise, we have a bogon */ + /* Skip escaped newlines. Otherwise, we have a bogon. */ if (*pz_next != '\n') return APPLY_FIX; @@ -244,47 +227,48 @@ TEST_FOR_FIX_PROC_HEAD( else_endif_label_test ) break; case '/': - /* - Skip comments. Otherwise, we have a bogon */ - switch (*pz_next) - { - case '/': - /* IF we found a "//" in a C header, THEN fix it. */ - if (! file_is_cxx) + /* Skip comments. Otherwise, we have a bogon */ + switch (*pz_next) + { + case '/': + /* // in a C header is a bogon. */ + if (! is_cxx_header( fname, all_text )) return APPLY_FIX; - /* C++ header. Skip to newline and continue. */ + /* C++ comment is allowed in a C++ header. + Skip to newline and continue. */ pz_next = strchr( pz_next+1, '\n' ); if (pz_next == (char*)NULL) return SKIP_FIX; pz_next++; - break; + goto next_directive; - case '*': + case '*': /* A comment for either C++ or C. Skip over it. */ pz_next = strstr( pz_next+1, "*/" ); if (pz_next == (char*)NULL) return SKIP_FIX; pz_next += 2; - break; + break; - default: - /* a '/' followed by other junk. */ - return APPLY_FIX; - } - break; /* a C or C++ comment */ + default: + return APPLY_FIX; + } + break; default: - /* - GOTTA BE A BOGON */ - return APPLY_FIX; + if (!isspace (ch)) + return APPLY_FIX; } /* switch (ch) */ } /* for (bogon check loop) */ + next_directive:; + text = pz_next; } /* for (entire file) loop */ return SKIP_FIX; } + /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = test for fix selector |