]> sourceware.org Git - automake.git/commitdiff
* lib/ansi2knr.c: New version.
authorTom Tromey <tromey@redhat.com>
Sun, 20 May 2001 05:59:43 +0000 (05:59 +0000)
committerTom Tromey <tromey@redhat.com>
Sun, 20 May 2001 05:59:43 +0000 (05:59 +0000)
* Makefile.am (FETCHFILES): Added ansi2knr.c.
(fetch): Likewise.

ChangeLog
Makefile.am
Makefile.in
lib/ansi2knr.c

index 7f7e2d23ec0fadf7a66a84a779fc90f226485599..6bc795581c82a4dcb915ae87d25d555e1652c4cc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-05-20  Tom Tromey  <tromey@redhat.com>
+
+       * lib/ansi2knr.c: New version.
+
+       * Makefile.am (FETCHFILES): Added ansi2knr.c.
+       (fetch): Likewise.
+
 2001-05-19  Tom Tromey  <tromey@redhat.com>
 
        * config.guess, config.sub: New versions from FSF.
index a48578696be309b11455a4d19d2dfe78c460ddc6..1a3a08a3b89d0e193c3bc0cb6820cafff111292f 100644 (file)
@@ -143,7 +143,8 @@ WGET = wget
 
 ## Files that we fetch and which we compare against.
 ## FIXME should be a lot more here
-FETCHFILES = config.guess config.sub
+## Sadly we can't fetch ansi2knr.1 from the same location :-(
+FETCHFILES = config.guess config.sub ansi2knr.c
 
 ## Fetch the latest versions of files we care about.
 fetch:
@@ -152,7 +153,8 @@ fetch:
 ## If a get fails then that is a problem.
        (cd Fetchdir && \
        $(WGET) ftp://ftp.gnu.org/gnu/config/config.guess; \
-       $(WGET) ftp://ftp.gnu.org/gnu/config/config.sub)
+       $(WGET) ftp://ftp.gnu.org/gnu/config/config.sub; \
+       $(WGET) ftp://ftp.cs.wisc.edu/ghost/ansi2knr.c)
 ## Don't exit after test because we want to give as many errors as
 ## possible.
        @stat=0; for file in $(FETCHFILES); do \
index bbafb9ec41ef4d2c5323c31e389232d216f7dca0..8732b859180785bb154dfed022d15c710577868f 100644 (file)
@@ -88,7 +88,7 @@ EXTRA_DIST = ChangeLog.1996 ChangeLog.1998
 
 WGET = wget
 
-FETCHFILES = config.guess config.sub
+FETCHFILES = config.guess config.sub ansi2knr.c
 EXEEXT =
 OBJEXT = o
 subdir = .
@@ -202,7 +202,8 @@ DVIPS = dvips
 
 uninstall-info-am:
        $(PRE_UNINSTALL)
-       @if $(SHELL) -c 'install-info --version 2>&1 | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
+       @if (install-info --version && \
+            install-info --version | fgrep -i -v debian) >/dev/null 2>&1; then \
          list='$(INFO_DEPS)'; \
          for file in $$list; do \
            echo " install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$$file"; \
@@ -495,7 +496,8 @@ install-info-am: $(INFO_DEPS)
          done; \
        done
        @$(POST_INSTALL)
-       @if $(SHELL) -c 'install-info --version 2>&1 | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
+       @if (install-info --version && \
+            install-info --version | fgrep -i -v debian) >/dev/null 2>&1; then \
          list='$(INFO_DEPS)'; \
          for file in $$list; do \
            echo " install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$$file";\
@@ -637,9 +639,10 @@ fetch:
        mkdir Fetchdir
        (cd Fetchdir && \
        $(WGET) ftp://ftp.gnu.org/gnu/config/config.guess; \
-       $(WGET) ftp://ftp.gnu.org/gnu/config/config.sub)
+       $(WGET) ftp://ftp.gnu.org/gnu/config/config.sub; \
+       $(WGET) ftp://ftp.cs.wisc.edu/ghost/ansi2knr.c)
        @stat=0; for file in $(FETCHFILES); do \
-         if diff $(srcdir)/$$file Fetchdir/$$file > /dev/null 2>&1; then :; \
+         if diff $(srcdir)/lib/$$file Fetchdir/$$file > /dev/null 2>&1; then :; \
          else \
            stat=1; \
            echo "install Fetchdir/$$file into srcdir and commit"; \
index ed5ba195d1bc1c57586f75bdde0100db9515027a..1b32b068ab0bd0a760dea1b3d751193aba805547 100644 (file)
@@ -1,6 +1,6 @@
-/* Copyright (C) 1989, 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved. */
+/* Copyright (C) 1989, 2000 Aladdin Enterprises.  All rights reserved. */
 
-/*$Id: ansi2knr.c $*/
+/*$Id: ansi2knr.c,v 1.3 2000/04/13 03:41:48 lpd Exp $*/
 /* Convert ANSI C function definitions to K&R ("traditional C") syntax */
 
 /*
@@ -37,21 +37,21 @@ program under the GPL.
  * There are no error messages.
  *
  * ansi2knr recognizes function definitions by seeing a non-keyword
- * identifier at the left margin, followed by a left parenthesis,
- * with a right parenthesis as the last character on the line,
- * and with a left brace as the first token on the following line
- * (ignoring possible intervening comments), except that a line
+ * identifier at the left margin, followed by a left parenthesis, with a
+ * right parenthesis as the last character on the line, and with a left
+ * brace as the first token on the following line (ignoring possible
+ * intervening comments and/or preprocessor directives), except that a line
  * consisting of only
  *     identifier1(identifier2)
  * will not be considered a function definition unless identifier2 is
  * 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 following constructs will confuse it:
+ * 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, comments, and preprocessor directives, except that
+ * the function name must be the first thing on the line.  The following
+ * constructs will confuse it:
  *     - Any other construct that starts at the left margin and
  *         follows the above syntax (such as a macro or function call).
  *     - Some macros that tinker with the syntax of function headers.
@@ -61,6 +61,27 @@ program under the GPL.
  * 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 2000-04-12 backs out Eggert's changes because of bugs:
+       - concatlits didn't declare the type of its bufend argument;
+       - concatlits didn't't recognize when it was inside a comment;
+       - scanstring could scan backward past the beginning of the string; when
+       - the check for \ + newline in scanstring was unnecessary.
+
+       2000-03-05  Paul Eggert  <eggert@twinsun.com>
+
+       Add support for concatenated string literals.
+       * ansi2knr.c (concatlits): New decl.
+       (main): Invoke concatlits to concatenate string literals.
+       (scanstring): Handle backslash-newline correctly.  Work with
+       character constants.  Fix bug when scanning backwards through
+       backslash-quote.  Check for unterminated strings.
+       (convert1): Parse character constants, too.
+       (appendline, concatlits): New functions.
+       * ansi2knr.1: Document this.
+
+       lpd 1999-08-17 added code to allow preprocessor directives
+               wherever comments are allowed
        lpd 1999-04-12 added minor fixes from Pavel Roskin
                <pavel_roskin@geocities.com> for clean compilation with
                gcc -W -Wall
@@ -196,6 +217,8 @@ program under the GPL.
 #define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_')
 
 /* Forward references */
+char *ppdirforward();
+char *ppdirbackward();
 char *skipspace();
 char *scanstring();
 int writeblanks();
@@ -298,7 +321,7 @@ f:                  if ( line >= buf + (bufsize - 1) ) /* overflow check */
                          goto wl;
                        if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL )
                          goto wl;
-                       switch ( *skipspace(more, 1) )
+                       switch ( *skipspace(ppdirforward(more), 1) )
                          {
                          case '{':
                            /* Definitely a function header. */
@@ -349,32 +372,70 @@ wl:                       fputs(buf, out);
        return 0;
 }
 
-/* Skip over whitespace and comments, in either direction. */
+/*
+ * Skip forward or backward over one or more preprocessor directives.
+ */
+char *
+ppdirforward(p)
+    char *p;
+{
+    for (; *p == '#'; ++p) {
+       for (; *p != '\r' && *p != '\n'; ++p)
+           if (*p == 0)
+               return p;
+       if (*p == '\r' && p[1] == '\n')
+           ++p;
+    }
+    return p;
+}
+char *
+ppdirbackward(p, limit)
+    char *p;
+    char *limit;
+{
+    char *np = p;
+
+    for (;; p = --np) {
+       if (*np == '\n' && np[-1] == '\r')
+           --np;
+       for (; np > limit && np[-1] != '\r' && np[-1] != '\n'; --np)
+           if (np[-1] == 0)
+               return np;
+       if (*np != '#')
+           return p;
+    }
+}
+
+/*
+ * Skip over whitespace, comments, and preprocessor directives,
+ * in either direction.
+ */
 char *
 skipspace(p, dir)
-    register char *p;
-    register int dir;                  /* 1 for forward, -1 for backward */
-{      for ( ; ; )
-          {    while ( is_space(*p) )
-                 p += dir;
-               if ( !(*p == '/' && p[dir] == '*') )
-                 break;
-               p += dir;  p += dir;
-               while ( !(*p == '*' && p[dir] == '/') )
-                  {    if ( *p == 0 )
-                         return p;     /* multi-line comment?? */
-                       p += dir;
-                  }
-               p += dir;  p += dir;
-          }
-       return p;
+    char *p;
+    int dir;                   /* 1 for forward, -1 for backward */
+{
+    for ( ; ; ) {
+       while ( is_space(*p) )
+           p += dir;
+       if ( !(*p == '/' && p[dir] == '*') )
+           break;
+       p += dir;  p += dir;
+       while ( !(*p == '*' && p[dir] == '/') ) {
+           if ( *p == 0 )
+               return p;       /* multi-line comment?? */
+           p += dir;
+       }
+       p += dir;  p += dir;
+    }
+    return p;
 }
 
 /* Scan over a quoted string, in either direction. */
 char *
 scanstring(p, dir)
-    register char *p;
-    register int dir;
+    char *p;
+    int dir;
 {
     for (p += dir; ; p += dir)
        if (*p == '"' && p[-dir] != '\\')
@@ -412,14 +473,14 @@ writeblanks(start, end)
 int
 test1(buf)
     char *buf;
-{      register char *p = buf;
+{      char *p = buf;
        char *bend;
        char *endfn;
        int contin;
 
        if ( !isidfirstchar(*p) )
          return 0;             /* no name at left margin */
-       bend = skipspace(buf + strlen(buf) - 1, -1);
+       bend = skipspace(ppdirbackward(buf + strlen(buf) - 1, buf), -1);
        switch ( *bend )
           {
           case ';': contin = 0 /*2*/; break;
@@ -498,7 +559,7 @@ convert1(buf, out, header, convert_varargs)
     int header;                        /* Boolean */
     int convert_varargs;       /* Boolean */
 {      char *endfn;
-       register char *p;
+       char *p;
        /*
         * The breaks table contains pointers to the beginning and end
         * of each argument.
This page took 0.042253 seconds and 5 git commands to generate.