summaryrefslogtreecommitdiffstats
path: root/gcc/fixinc/fixtests.c
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2000-01-19 21:41:04 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2000-01-19 21:41:04 +0000
commitada96dc208b8e1f35994c2f01fece1896b350e0c (patch)
tree071d4198056ed723a6710483d992b94bb6261350 /gcc/fixinc/fixtests.c
parent92102682fde6dae8dd65745c63b4b02732e3161d (diff)
downloadppe42-gcc-ada96dc208b8e1f35994c2f01fece1896b350e0c.tar.gz
ppe42-gcc-ada96dc208b8e1f35994c2f01fece1896b350e0c.zip
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31512 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fixinc/fixtests.c')
-rw-r--r--gcc/fixinc/fixtests.c100
1 files changed, 42 insertions, 58 deletions
diff --git a/gcc/fixinc/fixtests.c b/gcc/fixinc/fixtests.c
index 941b1ee1815..22fea350fd2 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
OpenPOWER on IntegriCloud