maintainer).
+1999-04-12 Tom Tromey <tromey@cygnus.com>
+
+ * ansi2knr.c: New version from Pavel Roskin (via ansi2knr.c
+ maintainer).
+
1999-04-11 Tom Tromey <tromey@cygnus.com>
* automake.in (handle_dist): Use AMTAR.
try to find a losing compiler and see if it really works.
(actually: hack config.cache and do it)
+* test `make clean' with subdir-objects
+
* Test nodist_SOURCES with lex, yacc, etc.
* Support subdir-objects with fortran
* consisting of only
* identifier1(identifier2)
* will not be considered a function definition unless identifier2 is
- * the word "void". ansi2knr will recognize a multi-line header provided
+ * the word "void", and a line consisting of
+ * identifier1(identifier2, <<arbitrary>>)
+ * will not be considered a function definition.
+ * ansi2knr will recognize a multi-line header provided
* that no intervening line ends with a left or right brace or a semicolon.
* These algorithms ignore whitespace and comments, except that
* the function name must be the first thing on the line.
* The original and principal author of ansi2knr is L. Peter Deutsch
* <ghost@aladdin.com>. Other authors are noted in the change history
* that follows (in reverse chronological order):
+ lpd 1999-04-12 added minor fixes from Pavel Roskin
+ <pavel_roskin@geocities.com> for clean compilation with
+ gcc -W -Wall
+ lpd 1999-03-22 added hack to recognize lines consisting of
+ identifier1(identifier2, xxx) as *not* being procedures
+ lpd 1999-02-03 made indentation of preprocessor commands consistent
lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an
endless loop; quoted strings within an argument list
confused the parser
#endif
+/* Define NULL (for *very* old compilers). */
+#ifndef NULL
+# define NULL (0)
+#endif
+
/*
* The ctype macros don't always handle 8-bit characters correctly.
* Compensate for this here.
*/
#ifdef isascii
-# undef HAVE_ISASCII /* just in case */
-# define HAVE_ISASCII 1
+# undef HAVE_ISASCII /* just in case */
+# define HAVE_ISASCII 1
#else
#endif
#if STDC_HEADERS || !HAVE_ISASCII
-# define is_ascii(c) 1
+# define is_ascii(c) 1
#else
-# define is_ascii(c) isascii(c)
+# define is_ascii(c) isascii(c)
#endif
#define is_space(c) (is_ascii(c) && isspace(c))
if ( filename )
fprintf(out, "#line 1 \"%s\"\n", filename);
buf = malloc(bufsize);
+ if ( buf == NULL )
+ {
+ fprintf(stderr, "Unable to allocate read buffer!\n");
+ exit(1);
+ }
line = buf;
while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
{
};
char **key = words;
char *kp;
- int len = endfn - buf;
+ unsigned len = endfn - buf;
while ( (kp = *key) != 0 )
{ if ( strlen(kp) == len && !strncmp(kp, buf, len) )
int len;
/*
* Check for identifier1(identifier2) and not
- * identifier1(void).
+ * identifier1(void), or identifier1(identifier2, xxxx).
*/
while ( isidchar(*p) )
p++;
len = p - id;
p = skipspace(p, 1);
- if ( *p == ')' && (len != 4 || strncmp(id, "void", 4)) )
+ if (*p == ',' ||
+ (*p == ')' && (len != 4 || strncmp(id, "void", 4)))
+ )
return 0; /* not a function */
}
/*
;
top: p = endfn;
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
- if ( breaks == 0 )
+ if ( breaks == NULL )
{ /* Couldn't allocate break table, give up */
fprintf(stderr, "Unable to allocate break table!\n");
fputs(buf, out);
do
{ int level = 0;
char *lp = NULL;
- char *rp;
+ char *rp = NULL;
char *end = NULL;
if ( bp >= btop )
}
}
/* Erase any embedded prototype parameters. */
- if ( lp )
+ if ( lp && rp )
writeblanks(lp + 1, rp);
p--; /* back up over terminator */
/* Find the name being declared. */
* consisting of only
* identifier1(identifier2)
* will not be considered a function definition unless identifier2 is
- * the word "void". ansi2knr will recognize a multi-line header provided
+ * the word "void", and a line consisting of
+ * identifier1(identifier2, <<arbitrary>>)
+ * will not be considered a function definition.
+ * ansi2knr will recognize a multi-line header provided
* that no intervening line ends with a left or right brace or a semicolon.
* These algorithms ignore whitespace and comments, except that
* the function name must be the first thing on the line.
* The original and principal author of ansi2knr is L. Peter Deutsch
* <ghost@aladdin.com>. Other authors are noted in the change history
* that follows (in reverse chronological order):
+ lpd 1999-04-12 added minor fixes from Pavel Roskin
+ <pavel_roskin@geocities.com> for clean compilation with
+ gcc -W -Wall
+ lpd 1999-03-22 added hack to recognize lines consisting of
+ identifier1(identifier2, xxx) as *not* being procedures
+ lpd 1999-02-03 made indentation of preprocessor commands consistent
lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an
endless loop; quoted strings within an argument list
confused the parser
#endif
+/* Define NULL (for *very* old compilers). */
+#ifndef NULL
+# define NULL (0)
+#endif
+
/*
* The ctype macros don't always handle 8-bit characters correctly.
* Compensate for this here.
*/
#ifdef isascii
-# undef HAVE_ISASCII /* just in case */
-# define HAVE_ISASCII 1
+# undef HAVE_ISASCII /* just in case */
+# define HAVE_ISASCII 1
#else
#endif
#if STDC_HEADERS || !HAVE_ISASCII
-# define is_ascii(c) 1
+# define is_ascii(c) 1
#else
-# define is_ascii(c) isascii(c)
+# define is_ascii(c) isascii(c)
#endif
#define is_space(c) (is_ascii(c) && isspace(c))
if ( filename )
fprintf(out, "#line 1 \"%s\"\n", filename);
buf = malloc(bufsize);
+ if ( buf == NULL )
+ {
+ fprintf(stderr, "Unable to allocate read buffer!\n");
+ exit(1);
+ }
line = buf;
while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
{
};
char **key = words;
char *kp;
- int len = endfn - buf;
+ unsigned len = endfn - buf;
while ( (kp = *key) != 0 )
{ if ( strlen(kp) == len && !strncmp(kp, buf, len) )
int len;
/*
* Check for identifier1(identifier2) and not
- * identifier1(void).
+ * identifier1(void), or identifier1(identifier2, xxxx).
*/
while ( isidchar(*p) )
p++;
len = p - id;
p = skipspace(p, 1);
- if ( *p == ')' && (len != 4 || strncmp(id, "void", 4)) )
+ if (*p == ',' ||
+ (*p == ')' && (len != 4 || strncmp(id, "void", 4)))
+ )
return 0; /* not a function */
}
/*
;
top: p = endfn;
breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
- if ( breaks == 0 )
+ if ( breaks == NULL )
{ /* Couldn't allocate break table, give up */
fprintf(stderr, "Unable to allocate break table!\n");
fputs(buf, out);
do
{ int level = 0;
char *lp = NULL;
- char *rp;
+ char *rp = NULL;
char *end = NULL;
if ( bp >= btop )
}
}
/* Erase any embedded prototype parameters. */
- if ( lp )
+ if ( lp && rp )
writeblanks(lp + 1, rp);
p--; /* back up over terminator */
/* Find the name being declared. */