Article View: gnu.gcc.help
Article #51661protoize unconfused
From: Joey Pruett
Date: Mon, 19 Apr 1993 16:46
Date: Mon, 19 Apr 1993 16:46
45 lines
2541 bytes
2541 bytes
i found out what the problem was. the scanner in protoize is pretty
simple and just looks for a close-paren followed by an open-curly or an
alpha character. this does actually find function definitions, but can
be thrown by constructs like:
if (foo)
bar();
else
(void)printf("Hello");
here, it sees the close-paren on (void) followed by p and thinks it has
a function definition. it backs up to the matching open-paren and see
the function name of "else". this also can happen for the if part of
my example. it sees the close-paren of (foo) followed by b, backs up
and see the function name "if". since this is quite common, the
scanner has a table of keywords so that it will realize when it has
goofed. but, "else" was not in that list.
so, the short story is to add "else" to the list. after thinking a
bit, i realized that "do" could have the same appearance, and a really
twisted looking case (case (int)enum_val:) so i added them as well. i
couldn't think of any other cases where this might pop up, but it might
be worth including all the keywords just to avoid really odd code...
here's the diff:
*** protoize.c.save Mon Dec 21 23:21:04 1992
--- protoize.c Mon Apr 19 09:39:34 1993
***************
*** 3980,3986 ****
{
char *func_name = (char *) alloca (id_length + 1);
static const char * const stmt_keywords[]
! = { "if", "while", "for", "switch", "return", 0 };
const char * const *stmt_keyword;
strncpy (func_name, id_start, id_length);
--- 3980,3986 ----
{
char *func_name = (char *) alloca (id_length + 1);
static const char * const stmt_keywords[]
! = { "if", "else", "do", "while", "for", "switch", "case", "return", 0 };
const char * const *stmt_keyword;
strncpy (func_name, id_start, id_length);
Technical Details
Message-ID:
<1993Apr19.164646.20073@tessi.com>Path:
arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!noc.near.net!uunet!tessi!joeyShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,ac47d6ea15bac6f2,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1993-04-19 09:52:01 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!noc.near.net!uunet!tessi!joey From: joey@tessi.com (Joey Pruett) Subject: protoize unconfused Message-ID: <1993Apr19.164646.20073@tessi.com> Organization: Test Systems Strategies, Inc., Beaverton, Oregon Date: Mon, 19 Apr 1993 16:46:46 GMT Lines: 45