Commit e174accc by Richard Stallman

(scan_decls): When reading parameter list,

handle whitespace differently, and keep track of line number.

From-SVN: r5890
parent 13ac10d7
...@@ -32,13 +32,13 @@ int brace_nesting = 0; ...@@ -32,13 +32,13 @@ int brace_nesting = 0;
/* The first extern_C_braces_length elements of extern_C_braces /* The first extern_C_braces_length elements of extern_C_braces
indicate the (brace nesting levels of) left braces that were indicate the (brace nesting levels of) left braces that were
prefixed by extern "C". */ prefixed by extern "C". */
int extern_C_braces_length = 0; int extern_C_braces_length = 0;
char extern_C_braces[20]; char extern_C_braces[20];
#define in_extern_C_brace (extern_C_braces_length>0) #define in_extern_C_brace (extern_C_braces_length>0)
/* True if the function declaration currently being scanned is /* True if the function declaration currently being scanned is
prefixed by extern "C". */ prefixed by extern "C". */
int current_extern_C = 0; int current_extern_C = 0;
static void static void
...@@ -77,7 +77,7 @@ scan_decls (fp) ...@@ -77,7 +77,7 @@ scan_decls (fp)
saw_inline = 0; saw_inline = 0;
if (c == '}') if (c == '}')
{ {
/* pop an 'extern "C"' nesting level, if appropriate */ /* Pop an 'extern "C"' nesting level, if appropriate. */
if (extern_C_braces_length if (extern_C_braces_length
&& extern_C_braces[extern_C_braces_length - 1] == brace_nesting) && extern_C_braces[extern_C_braces_length - 1] == brace_nesting)
extern_C_braces_length--; extern_C_braces_length--;
...@@ -100,11 +100,11 @@ scan_decls (fp) ...@@ -100,11 +100,11 @@ scan_decls (fp)
&& strncmp (buf.base, "__DEFINED_MACRO_", 16) == 0) && strncmp (buf.base, "__DEFINED_MACRO_", 16) == 0)
{ {
/* For certain interesting macro names, fixproto puts /* For certain interesting macro names, fixproto puts
#ifdef FOO #ifdef FOO
__DEFINED_MACRO_FOO __DEFINED_MACRO_FOO
#endif #endif
into the file to be pre-processed. So if we see __DEFINED_MACRO_FOO, into the file to be pre-processed. So if we see __DEFINED_MACRO_FOO,
it means FOO was defined, which we may want to make a note of. */ it means FOO was defined, which we may want to make a note of. */
recognized_macro (buf.base+16); recognized_macro (buf.base+16);
goto new_statement; goto new_statement;
} }
...@@ -134,7 +134,7 @@ scan_decls (fp) ...@@ -134,7 +134,7 @@ scan_decls (fp)
{ {
int followingc = getc (fp); /* char following token in buf */ int followingc = getc (fp); /* char following token in buf */
MAKE_SSTRING_SPACE(&rtype, 1); MAKE_SSTRING_SPACE (&rtype, 1);
*rtype.ptr = 0; *rtype.ptr = 0;
if (c == IDENTIFIER_TOKEN) if (c == IDENTIFIER_TOKEN)
...@@ -143,11 +143,13 @@ scan_decls (fp) ...@@ -143,11 +143,13 @@ scan_decls (fp)
if (nextc == '(') if (nextc == '(')
{ {
int nesting = 1; int nesting = 1;
int func_lineno = source_lineno;
char *args;
arg_list.ptr = arg_list.base; arg_list.ptr = arg_list.base;
c = skip_spaces (fp, ' ');
for (;;) for (;;)
{ {
c = getc (fp);
if (c == '(') if (c == '(')
nesting++; nesting++;
else if (c == ')') else if (c == ')')
...@@ -156,17 +158,23 @@ scan_decls (fp) ...@@ -156,17 +158,23 @@ scan_decls (fp)
if (c == EOF) if (c == EOF)
break; break;
if (c == '\n') if (c == '\n')
c = ' '; {
SSTRING_PUT(&arg_list, c); c = ' ';
c = getc (fp); source_lineno++;
lineno++;
}
SSTRING_PUT (&arg_list, c);
} }
SSTRING_PUT(&arg_list, '\0'); SSTRING_PUT (&arg_list, '\0');
args = arg_list.base;
while (*args == ' ')
args++;
recognized_function (buf.base, recognized_function (buf.base,
saw_inline ? 'I' (saw_inline ? 'I'
: in_extern_C_brace || current_extern_C : in_extern_C_brace || current_extern_C
? 'F' : 'f', ? 'F' : 'f'),
rtype.base, arg_list.base, rtype.base, args,
source_filename.base, source_lineno); source_filename.base, func_lineno);
c = get_token (fp, &buf); c = get_token (fp, &buf);
if (c == '{') if (c == '{')
{ {
...@@ -190,7 +198,7 @@ scan_decls (fp) ...@@ -190,7 +198,7 @@ scan_decls (fp)
goto handle_statement; goto handle_statement;
sstring_append (&rtype, &buf); sstring_append (&rtype, &buf);
if (followingc == ' ' || followingc == '\t' || followingc == '\n') if (followingc == ' ' || followingc == '\t' || followingc == '\n')
SSTRING_PUT(&rtype, ' '); SSTRING_PUT (&rtype, ' ');
c = get_token (fp, &buf); c = get_token (fp, &buf);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment