]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
new files from elsewhere
authorTom Tromey <tromey@redhat.com>
Sat, 22 Mar 1997 05:40:13 +0000 (05:40 +0000)
committerTom Tromey <tromey@redhat.com>
Sat, 22 Mar 1997 05:40:13 +0000 (05:40 +0000)
12 files changed:
ChangeLog
NEWS
ansi2knr.1
ansi2knr.c
automake.texi
lib/am/progs.am
lib/am/scripts.am
lib/ansi2knr.1
lib/ansi2knr.c
m4/mktime.m4
progs.am
scripts.am

index eec4c3d36fc094ab9cfd5875e2c9cfaccef3483a..d4fb1c840102d1e7d3cea2a935afb232d54c6ddc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Fri Mar 21 10:22:51 1997  Tom Tromey  <tromey@cygnus.com>
+
+       * ansi2knr.c, ansi2knr.1: New versions from L. Peter Deutsch.
+
+       * scripts.am: Add @EXEEXT@ to installed scripts.
+
+Wed Jan 22 20:12:31 1997  Jim Meyering  <meyering@na-net.ornl.gov>
+
+       * m4/mktime.m4 (AM_FUNC_MKTIME): Run tests for each of a few values
+       for the TZ environment variable.  Andre Novaes Cunha provided the
+       hairy TZ setting that exercized the Solaris tzset bug.
+
+1997-01-22  Paul Eggert  <eggert@twinsun.com>
+
+       * m4/mktime.m4: (AM_FUNC_MKTIME): Fix bug in mktime test -- don't
+       test now, test a couple of thousand times.
+
 Thu Mar 20 00:16:54 1997  Tom Tromey  <tromey@cygnus.com>
 
        * automake.in (handle_programs): Remove CYGWIN lines unless
diff --git a/NEWS b/NEWS
index 2de4a21d541ee294509a31ed084cc90cb9ac9bf0..a070ac4379bf30db666ebd95e4a0277a37716f64 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ New in 1.1m:
 * Automake will now generate rules to regenerate aclocal.m4, if appropriate
 * Now uses `AM_' macro names everywhere
 * ansi2knr option can have directory prefix (eg `../lib/ansi2knr')
+  ansi2knr now works correctly on K&R sources
 * Better C++, yacc, lex support
 * Will compute _DEPENDENCIES variables automatically if not supplied
 * Will interpolate $(...) and ${...} when examining contents of a variable
index 434ce8f042436aaabe216835dbc51d82e8195504..f9ee5a631c2ee870819fefe6c1c701eb426d1508 100644 (file)
@@ -1,19 +1,36 @@
-.TH ANSI2KNR 1 "31 December 1990" 
+.TH ANSI2KNR 1 "19 Jan 1996"
 .SH NAME
 ansi2knr \- convert ANSI C to Kernighan & Ritchie C
 .SH SYNOPSIS
 .I ansi2knr
-input_file output_file
+[--varargs] input_file [output_file]
 .SH DESCRIPTION
 If no output_file is supplied, output goes to stdout.
 .br
 There are no error messages.
 .sp
 .I ansi2knr
-recognizes functions 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.  It will recognize a multi-line header if the last character on each line but the last is a left parenthesis or comma.  These algorithms ignore whitespace and comments, except that the function name must be the first thing on the line.
+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).  It 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.
 .sp
 The following constructs will confuse it:
 .br
-     - Any other construct that starts at the left margin and follows the above syntax (such as a macro or function call).
+     - Any other construct that starts at the left margin and follows the
+above syntax (such as a macro or function call).
 .br
-     - Macros that tinker with the syntax of the function header.
+     - Some macros that tinker with the syntax of the function header.
+.sp
+The --varargs switch is obsolete, and is recognized only for
+backwards compatibility.  The present version of
+.I ansi2knr
+will always attempt to convert a ... argument to va_alist and va_dcl.
+.SH AUTHOR
+L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and
+continues to maintain the current version; most of the code in the current
+version is his work.  ansi2knr also includes contributions by Francois
+Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>.
index 22e68e1c83f32095721c639376e838263bf4a0ca..64a4578a2fa63d92463a77c2107f397d3ebdd03c 100644 (file)
@@ -1,5 +1,3 @@
-/* Copyright (C) 1989, 1991, 1993, 1994, 1995 Aladdin Enterprises. All rights reserved. */
-
 /* ansi2knr.c */
 /* Convert ANSI C function definitions to K&R ("traditional C") syntax */
 
@@ -34,22 +32,33 @@ program under the GPL.
  *
  * 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.
- * It will recognize a multi-line header provided that the last character
- * of the last line of the header is a right parenthesis,
- * and no intervening line ends with a left or right brace or a semicolon.
+ * 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).
+ * It 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:
  *     - Any other construct that starts at the left margin and
  *         follows the above syntax (such as a macro or function call).
- *     - Macros that tinker with the syntax of the function header.
+ *     - Some macros that tinker with the syntax of the function header.
  */
 
 /*
  * 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 96-01-21 added code to cope with not HAVE_CONFIG_H and with
+               compilers that don't understand void, as suggested by
+               Tom Lane
+       lpd 96-01-15 changed to require that the first non-comment token
+               on the line following a function header be a left brace,
+               to reduce sensitivity to macros, as suggested by Tom Lane
+               <tgl@sss.pgh.pa.us>
+       lpd 95-06-22 removed #ifndefs whose sole purpose was to define
+               undefined preprocessor symbols as 0; changed all #ifdefs
+               for configuration symbols to #ifs
        lpd 95-04-05 changed copyright notice to make it clear that
                including ansi2knr in a program does not bring the entire
                program under the GPL
@@ -67,16 +76,16 @@ program under the GPL.
  */
 
 /* Most of the conditionals here are to make ansi2knr work with */
-/* the GNU configure machinery. */
+/* or without the GNU configure machinery. */
 
-#ifdef HAVE_CONFIG_H
+#if HAVE_CONFIG_H
 # include <config.h>
 #endif
 
 #include <stdio.h>
 #include <ctype.h>
 
-#ifdef HAVE_CONFIG_H
+#if HAVE_CONFIG_H
 
 /*
    For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h).
@@ -91,40 +100,49 @@ program under the GPL.
 
 #else /* not HAVE_CONFIG_H */
 
-/*
-   Without AC_CONFIG_HEADER, merely use <string.h> as in the original
-   Ghostscript distribution.  This loses on older BSD systems.
- */
+/* Otherwise do it the hard way */
 
-# include <string.h>
+# ifdef BSD
+#  include <strings.h>
+# else
+#  ifdef VMS
+    extern int strlen(), strncmp();
+#  else
+#   include <string.h>
+#  endif
+# endif
 
 #endif /* not HAVE_CONFIG_H */
 
-#ifdef STDC_HEADERS
+#if STDC_HEADERS
 # include <stdlib.h>
 #else
 /*
    malloc and free should be declared in stdlib.h,
    but if you've got a K&R compiler, they probably aren't.
  */
-char *malloc();
-void free();
+# ifdef MSDOS
+#  include <malloc.h>
+# else
+#  ifdef VMS
+     extern char *malloc();
+     extern void free();
+#  else
+     extern char *malloc();
+     extern int free();
+#  endif
+# endif
+
 #endif
 
 /*
  * The ctype macros don't always handle 8-bit characters correctly.
  * Compensate for this here.
  */
-#ifndef STDC_HEADERS
-#  define STDC_HEADERS 0
-#endif
 #ifdef isascii
 #  undef HAVE_ISASCII          /* just in case */
 #  define HAVE_ISASCII 1
 #else
-#  ifndef HAVE_ISASCII
-#    define HAVE_ISASCII 0
-#  endif
 #endif
 #if STDC_HEADERS || !HAVE_ISASCII
 #  define is_ascii(c) 1
@@ -142,7 +160,7 @@ void free();
 
 /* Forward references */
 char *skipspace();
-void writeblanks();
+int writeblanks();
 int test1();
 int convert1();
 
@@ -155,6 +173,7 @@ main(argc, argv)
 #define bufsize 5000                   /* arbitrary size */
        char *buf;
        char *line;
+       char *more;
        /*
         * In previous versions, ansi2knr recognized a --varargs switch.
         * If this switch was supplied, ansi2knr would attempt to convert
@@ -200,26 +219,53 @@ main(argc, argv)
        buf = malloc(bufsize);
        line = buf;
        while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
-          {    switch ( test1(buf) )
+          {
+test:          line += strlen(line);
+               switch ( test1(buf) )
                   {
                case 2:                 /* a function header */
                        convert1(buf, out, 1, convert_varargs);
                        break;
                case 1:                 /* a function */
-                       convert1(buf, out, 0, convert_varargs);
+                       /* Check for a { at the start of the next line. */
+                       more = ++line;
+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) )
+                         {
+                         case '{':
+                           /* Definitely a function header. */
+                           convert1(buf, out, 0, convert_varargs);
+                           fputs(more, out);
+                           break;
+                         case 0:
+                           /* The next line was blank or a comment: */
+                           /* keep scanning for a non-comment. */
+                           line += strlen(line);
+                           goto f;
+                         default:
+                           /* buf isn't a function header, but */
+                           /* more might be. */
+                           fputs(buf, out);
+                           strcpy(buf, more);
+                           line = buf;
+                           goto test;
+                         }
                        break;
                case -1:                /* maybe the start of a function */
-                       line = buf + strlen(buf);
                        if ( line != buf + (bufsize - 1) ) /* overflow check */
-                               continue;
+                         continue;
                        /* falls through */
                default:                /* not a function */
-                       fputs(buf, out);
+wl:                    fputs(buf, out);
                        break;
                   }
                line = buf;
           }
-       if ( line != buf ) fputs(buf, out);
+       if ( line != buf )
+         fputs(buf, out);
        free(buf);
        fclose(out);
        fclose(in);
@@ -232,11 +278,14 @@ 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;
+          {    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?? */
+                  {    if ( *p == 0 )
+                         return p;     /* multi-line comment?? */
                        p += dir;
                   }
                p += dir;  p += dir;
@@ -248,13 +297,15 @@ skipspace(p, dir)
  * Write blanks over part of a string.
  * Don't overwrite end-of-line characters.
  */
-void
+int
 writeblanks(start, end)
     char *start;
     char *end;
 {      char *p;
        for ( p = start; p < end; p++ )
-         if ( *p != '\r' && *p != '\n' ) *p = ' ';
+         if ( *p != '\r' && *p != '\n' )
+           *p = ' ';
+       return 0;
 }
 
 /*
@@ -277,25 +328,27 @@ test1(buf)
        char *bend;
        char *endfn;
        int contin;
+
        if ( !isidfirstchar(*p) )
-               return 0;               /* no name at left margin */
+         return 0;             /* no name at left margin */
        bend = skipspace(buf + strlen(buf) - 1, -1);
        switch ( *bend )
           {
-       case ';': contin = 0 /*2*/; break;
-       case ')': contin = 1; break;
-       case '{': return 0;             /* not a function */
-       case '}': return 0;             /* not a function */
-       default: contin = -1;
+          case ';': contin = 0 /*2*/; break;
+          case ')': contin = 1; break;
+          case '{': return 0;          /* not a function */
+          case '}': return 0;          /* not a function */
+          default: contin = -1;
           }
-       while ( isidchar(*p) ) p++;
+       while ( isidchar(*p) )
+         p++;
        endfn = p;
        p = skipspace(p, 1);
        if ( *p++ != '(' )
-               return 0;               /* not a function */
+         return 0;             /* not a function */
        p = skipspace(p, 1);
        if ( *p == ')' )
-               return 0;               /* no parameters */
+         return 0;             /* no parameters */
        /* Check that the apparent function name isn't a keyword. */
        /* We only need to check for keywords that could be followed */
        /* by a left parenthesis (which, unfortunately, is most of them). */
@@ -309,9 +362,10 @@ test1(buf)
                char **key = words;
                char *kp;
                int len = endfn - buf;
+
                while ( (kp = *key) != 0 )
                   {    if ( strlen(kp) == len && !strncmp(kp, buf, len) )
-                               return 0;       /* name is a keyword */
+                         return 0;     /* name is a keyword */
                        key++;
                   }
           }
@@ -327,15 +381,21 @@ convert1(buf, out, header, convert_varargs)
     int convert_varargs;       /* Boolean */
 {      char *endfn;
        register char *p;
+       /*
+        * The breaks table contains pointers to the beginning and end
+        * of each argument.
+        */
        char **breaks;
        unsigned num_breaks = 2;        /* for testing */
        char **btop;
        char **bp;
        char **ap;
        char *vararg = 0;
+
        /* Pre-ANSI implementations don't agree on whether strchr */
        /* is called strchr or index, so we open-code it here. */
-       for ( endfn = buf; *(endfn++) != '('; ) ;
+       for ( endfn = buf; *(endfn++) != '('; )
+         ;
 top:   p = endfn;
        breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
        if ( breaks == 0 )
@@ -352,6 +412,7 @@ top:        p = endfn;
                char *lp = NULL;
                char *rp;
                char *end = NULL;
+
                if ( bp >= btop )
                   {    /* Filled up break table. */
                        /* Allocate a bigger one and start over. */
@@ -364,21 +425,21 @@ top:      p = endfn;
                for ( ; end == NULL; p++ )
                   {    switch(*p)
                           {
-                       case ',':
+                          case ',':
                                if ( !level ) end = p;
                                break;
-                       case '(':
+                          case '(':
                                if ( !level ) lp = p;
                                level++;
                                break;
-                       case ')':
+                          case ')':
                                if ( --level < 0 ) end = p;
                                else rp = p;
                                break;
-                       case '/':
+                          case '/':
                                p = skipspace(p, 1) - 1;
                                break;
-                       default:
+                          default:
                                ;
                           }
                   }
@@ -393,26 +454,27 @@ top:      p = endfn;
                   {    p = skipspace(p - 1, -1);
                        switch ( *p )
                           {
-                       case ']':       /* skip array dimension(s) */
-                       case ')':       /* skip procedure args OR name */
+                          case ']':    /* skip array dimension(s) */
+                          case ')':    /* skip procedure args OR name */
                           {    int level = 1;
                                while ( level )
                                 switch ( *--p )
                                   {
-                               case ']': case ')': level++; break;
-                               case '[': case '(': level--; break;
-                               case '/': p = skipspace(p, -1) + 1; break;
-                               default: ;
+                                  case ']': case ')': level++; break;
+                                  case '[': case '(': level--; break;
+                                  case '/': p = skipspace(p, -1) + 1; break;
+                                  default: ;
                                   }
                           }
                                if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
                                   {    /* We found the name being declared */
                                        while ( !isidfirstchar(*p) )
-                                               p = skipspace(p, 1) + 1;
+                                         p = skipspace(p, 1) + 1;
                                        goto found;
                                   }
                                break;
-                       default: goto found;
+                          default:
+                               goto found;
                           }
                   }
 found:         if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
index 7355fa05e555528ad42eb632a1b5ef444870fb9d..7b854b3c6b2eaed53ddc52dcc2a56cf281aef989 100644 (file)
@@ -424,12 +424,9 @@ Here is the @file{configure.in} from GNU Hello:
 @example
 dnl Process this file with autoconf to produce a configure script.
 AC_INIT(src/hello.c)
-AC_PREREQ(2.12)
 AM_INIT_AUTOMAKE(hello, 1.3.11)
 AM_CONFIG_HEADER(config.h)
 
-AC_ARG_PROGRAM
-
 dnl Set of available languages.
 ALL_LINGUAS="de fr es ko nl no pl pt sl sv"
 
@@ -1468,8 +1465,7 @@ files into K&R C, which is then compiled.
 
 The @code{ansi2knr} program is simple-minded.  It assumes the source
 code will be formatted in a particular way; see the @code{ansi2knr} man
-page for details.  Running @code{ansi2knr} on K&R C source will result
-in compilation errors.
+page for details.
 
 De-ANSI-fication support requires the source files @file{ansi2knr.c} and
 @file{ansi2knr.1} to be in the same package as the ANSI C source; these
index 3d255ef5db3216d570be3a31399b9c7da1d9f5c4..68689e8d0cadeb2c9a512c53a4feb58a8d8e6077 100644 (file)
@@ -27,7 +27,7 @@ install-@DIR@PROGRAMS: $(@DIR@_PROGRAMS)
 ## Note that we explicitly set the libtool mode.  This avoids any
 ## lossage if the install program doesn't have a name that libtool
 ## expects.
-           echo " @LIBTOOL --mode=install@ $(INSTALL_PROGRAM) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`"; \
+           echo " @LIBTOOL --mode=install@ $(INSTALL_PROGRAM) $$p@EXEEXT@ $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@"; \
            @LIBTOOL --mode=install@ $(INSTALL_PROGRAM) $$p@EXEEXT@ $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@; \
          else :; fi; \
        done
index 6700f4462f1933c1ee241899c7fd70ca1c693647..9ca60ff26a2d43cb5d3a2afe85c5e75b55fad329 100644 (file)
@@ -22,11 +22,11 @@ install-@DIR@SCRIPTS: $(@DIR@_SCRIPTS)
 ## a syntax error in sh.
        @list="$(@DIR@_SCRIPTS)"; for p in $$list; do \
          if test -f $$p; then \
-           echo " $(INSTALL_SCRIPT) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`"; \
-           $(INSTALL_SCRIPT) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`; \
+           echo " $(INSTALL_SCRIPT) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@"; \
+           $(INSTALL_SCRIPT) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@; \
          else if test -f $(srcdir)/$$p; then \
-           echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`"; \
-           $(INSTALL_SCRIPT) $(srcdir)/$$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`; \
+           echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@"; \
+           $(INSTALL_SCRIPT) $(srcdir)/$$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@; \
          else :; fi; fi; \
        done
 
index 434ce8f042436aaabe216835dbc51d82e8195504..f9ee5a631c2ee870819fefe6c1c701eb426d1508 100644 (file)
@@ -1,19 +1,36 @@
-.TH ANSI2KNR 1 "31 December 1990" 
+.TH ANSI2KNR 1 "19 Jan 1996"
 .SH NAME
 ansi2knr \- convert ANSI C to Kernighan & Ritchie C
 .SH SYNOPSIS
 .I ansi2knr
-input_file output_file
+[--varargs] input_file [output_file]
 .SH DESCRIPTION
 If no output_file is supplied, output goes to stdout.
 .br
 There are no error messages.
 .sp
 .I ansi2knr
-recognizes functions 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.  It will recognize a multi-line header if the last character on each line but the last is a left parenthesis or comma.  These algorithms ignore whitespace and comments, except that the function name must be the first thing on the line.
+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).  It 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.
 .sp
 The following constructs will confuse it:
 .br
-     - Any other construct that starts at the left margin and follows the above syntax (such as a macro or function call).
+     - Any other construct that starts at the left margin and follows the
+above syntax (such as a macro or function call).
 .br
-     - Macros that tinker with the syntax of the function header.
+     - Some macros that tinker with the syntax of the function header.
+.sp
+The --varargs switch is obsolete, and is recognized only for
+backwards compatibility.  The present version of
+.I ansi2knr
+will always attempt to convert a ... argument to va_alist and va_dcl.
+.SH AUTHOR
+L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and
+continues to maintain the current version; most of the code in the current
+version is his work.  ansi2knr also includes contributions by Francois
+Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>.
index 22e68e1c83f32095721c639376e838263bf4a0ca..64a4578a2fa63d92463a77c2107f397d3ebdd03c 100644 (file)
@@ -1,5 +1,3 @@
-/* Copyright (C) 1989, 1991, 1993, 1994, 1995 Aladdin Enterprises. All rights reserved. */
-
 /* ansi2knr.c */
 /* Convert ANSI C function definitions to K&R ("traditional C") syntax */
 
@@ -34,22 +32,33 @@ program under the GPL.
  *
  * 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.
- * It will recognize a multi-line header provided that the last character
- * of the last line of the header is a right parenthesis,
- * and no intervening line ends with a left or right brace or a semicolon.
+ * 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).
+ * It 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:
  *     - Any other construct that starts at the left margin and
  *         follows the above syntax (such as a macro or function call).
- *     - Macros that tinker with the syntax of the function header.
+ *     - Some macros that tinker with the syntax of the function header.
  */
 
 /*
  * 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 96-01-21 added code to cope with not HAVE_CONFIG_H and with
+               compilers that don't understand void, as suggested by
+               Tom Lane
+       lpd 96-01-15 changed to require that the first non-comment token
+               on the line following a function header be a left brace,
+               to reduce sensitivity to macros, as suggested by Tom Lane
+               <tgl@sss.pgh.pa.us>
+       lpd 95-06-22 removed #ifndefs whose sole purpose was to define
+               undefined preprocessor symbols as 0; changed all #ifdefs
+               for configuration symbols to #ifs
        lpd 95-04-05 changed copyright notice to make it clear that
                including ansi2knr in a program does not bring the entire
                program under the GPL
@@ -67,16 +76,16 @@ program under the GPL.
  */
 
 /* Most of the conditionals here are to make ansi2knr work with */
-/* the GNU configure machinery. */
+/* or without the GNU configure machinery. */
 
-#ifdef HAVE_CONFIG_H
+#if HAVE_CONFIG_H
 # include <config.h>
 #endif
 
 #include <stdio.h>
 #include <ctype.h>
 
-#ifdef HAVE_CONFIG_H
+#if HAVE_CONFIG_H
 
 /*
    For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h).
@@ -91,40 +100,49 @@ program under the GPL.
 
 #else /* not HAVE_CONFIG_H */
 
-/*
-   Without AC_CONFIG_HEADER, merely use <string.h> as in the original
-   Ghostscript distribution.  This loses on older BSD systems.
- */
+/* Otherwise do it the hard way */
 
-# include <string.h>
+# ifdef BSD
+#  include <strings.h>
+# else
+#  ifdef VMS
+    extern int strlen(), strncmp();
+#  else
+#   include <string.h>
+#  endif
+# endif
 
 #endif /* not HAVE_CONFIG_H */
 
-#ifdef STDC_HEADERS
+#if STDC_HEADERS
 # include <stdlib.h>
 #else
 /*
    malloc and free should be declared in stdlib.h,
    but if you've got a K&R compiler, they probably aren't.
  */
-char *malloc();
-void free();
+# ifdef MSDOS
+#  include <malloc.h>
+# else
+#  ifdef VMS
+     extern char *malloc();
+     extern void free();
+#  else
+     extern char *malloc();
+     extern int free();
+#  endif
+# endif
+
 #endif
 
 /*
  * The ctype macros don't always handle 8-bit characters correctly.
  * Compensate for this here.
  */
-#ifndef STDC_HEADERS
-#  define STDC_HEADERS 0
-#endif
 #ifdef isascii
 #  undef HAVE_ISASCII          /* just in case */
 #  define HAVE_ISASCII 1
 #else
-#  ifndef HAVE_ISASCII
-#    define HAVE_ISASCII 0
-#  endif
 #endif
 #if STDC_HEADERS || !HAVE_ISASCII
 #  define is_ascii(c) 1
@@ -142,7 +160,7 @@ void free();
 
 /* Forward references */
 char *skipspace();
-void writeblanks();
+int writeblanks();
 int test1();
 int convert1();
 
@@ -155,6 +173,7 @@ main(argc, argv)
 #define bufsize 5000                   /* arbitrary size */
        char *buf;
        char *line;
+       char *more;
        /*
         * In previous versions, ansi2knr recognized a --varargs switch.
         * If this switch was supplied, ansi2knr would attempt to convert
@@ -200,26 +219,53 @@ main(argc, argv)
        buf = malloc(bufsize);
        line = buf;
        while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
-          {    switch ( test1(buf) )
+          {
+test:          line += strlen(line);
+               switch ( test1(buf) )
                   {
                case 2:                 /* a function header */
                        convert1(buf, out, 1, convert_varargs);
                        break;
                case 1:                 /* a function */
-                       convert1(buf, out, 0, convert_varargs);
+                       /* Check for a { at the start of the next line. */
+                       more = ++line;
+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) )
+                         {
+                         case '{':
+                           /* Definitely a function header. */
+                           convert1(buf, out, 0, convert_varargs);
+                           fputs(more, out);
+                           break;
+                         case 0:
+                           /* The next line was blank or a comment: */
+                           /* keep scanning for a non-comment. */
+                           line += strlen(line);
+                           goto f;
+                         default:
+                           /* buf isn't a function header, but */
+                           /* more might be. */
+                           fputs(buf, out);
+                           strcpy(buf, more);
+                           line = buf;
+                           goto test;
+                         }
                        break;
                case -1:                /* maybe the start of a function */
-                       line = buf + strlen(buf);
                        if ( line != buf + (bufsize - 1) ) /* overflow check */
-                               continue;
+                         continue;
                        /* falls through */
                default:                /* not a function */
-                       fputs(buf, out);
+wl:                    fputs(buf, out);
                        break;
                   }
                line = buf;
           }
-       if ( line != buf ) fputs(buf, out);
+       if ( line != buf )
+         fputs(buf, out);
        free(buf);
        fclose(out);
        fclose(in);
@@ -232,11 +278,14 @@ 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;
+          {    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?? */
+                  {    if ( *p == 0 )
+                         return p;     /* multi-line comment?? */
                        p += dir;
                   }
                p += dir;  p += dir;
@@ -248,13 +297,15 @@ skipspace(p, dir)
  * Write blanks over part of a string.
  * Don't overwrite end-of-line characters.
  */
-void
+int
 writeblanks(start, end)
     char *start;
     char *end;
 {      char *p;
        for ( p = start; p < end; p++ )
-         if ( *p != '\r' && *p != '\n' ) *p = ' ';
+         if ( *p != '\r' && *p != '\n' )
+           *p = ' ';
+       return 0;
 }
 
 /*
@@ -277,25 +328,27 @@ test1(buf)
        char *bend;
        char *endfn;
        int contin;
+
        if ( !isidfirstchar(*p) )
-               return 0;               /* no name at left margin */
+         return 0;             /* no name at left margin */
        bend = skipspace(buf + strlen(buf) - 1, -1);
        switch ( *bend )
           {
-       case ';': contin = 0 /*2*/; break;
-       case ')': contin = 1; break;
-       case '{': return 0;             /* not a function */
-       case '}': return 0;             /* not a function */
-       default: contin = -1;
+          case ';': contin = 0 /*2*/; break;
+          case ')': contin = 1; break;
+          case '{': return 0;          /* not a function */
+          case '}': return 0;          /* not a function */
+          default: contin = -1;
           }
-       while ( isidchar(*p) ) p++;
+       while ( isidchar(*p) )
+         p++;
        endfn = p;
        p = skipspace(p, 1);
        if ( *p++ != '(' )
-               return 0;               /* not a function */
+         return 0;             /* not a function */
        p = skipspace(p, 1);
        if ( *p == ')' )
-               return 0;               /* no parameters */
+         return 0;             /* no parameters */
        /* Check that the apparent function name isn't a keyword. */
        /* We only need to check for keywords that could be followed */
        /* by a left parenthesis (which, unfortunately, is most of them). */
@@ -309,9 +362,10 @@ test1(buf)
                char **key = words;
                char *kp;
                int len = endfn - buf;
+
                while ( (kp = *key) != 0 )
                   {    if ( strlen(kp) == len && !strncmp(kp, buf, len) )
-                               return 0;       /* name is a keyword */
+                         return 0;     /* name is a keyword */
                        key++;
                   }
           }
@@ -327,15 +381,21 @@ convert1(buf, out, header, convert_varargs)
     int convert_varargs;       /* Boolean */
 {      char *endfn;
        register char *p;
+       /*
+        * The breaks table contains pointers to the beginning and end
+        * of each argument.
+        */
        char **breaks;
        unsigned num_breaks = 2;        /* for testing */
        char **btop;
        char **bp;
        char **ap;
        char *vararg = 0;
+
        /* Pre-ANSI implementations don't agree on whether strchr */
        /* is called strchr or index, so we open-code it here. */
-       for ( endfn = buf; *(endfn++) != '('; ) ;
+       for ( endfn = buf; *(endfn++) != '('; )
+         ;
 top:   p = endfn;
        breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
        if ( breaks == 0 )
@@ -352,6 +412,7 @@ top:        p = endfn;
                char *lp = NULL;
                char *rp;
                char *end = NULL;
+
                if ( bp >= btop )
                   {    /* Filled up break table. */
                        /* Allocate a bigger one and start over. */
@@ -364,21 +425,21 @@ top:      p = endfn;
                for ( ; end == NULL; p++ )
                   {    switch(*p)
                           {
-                       case ',':
+                          case ',':
                                if ( !level ) end = p;
                                break;
-                       case '(':
+                          case '(':
                                if ( !level ) lp = p;
                                level++;
                                break;
-                       case ')':
+                          case ')':
                                if ( --level < 0 ) end = p;
                                else rp = p;
                                break;
-                       case '/':
+                          case '/':
                                p = skipspace(p, 1) - 1;
                                break;
-                       default:
+                          default:
                                ;
                           }
                   }
@@ -393,26 +454,27 @@ top:      p = endfn;
                   {    p = skipspace(p - 1, -1);
                        switch ( *p )
                           {
-                       case ']':       /* skip array dimension(s) */
-                       case ')':       /* skip procedure args OR name */
+                          case ']':    /* skip array dimension(s) */
+                          case ')':    /* skip procedure args OR name */
                           {    int level = 1;
                                while ( level )
                                 switch ( *--p )
                                   {
-                               case ']': case ')': level++; break;
-                               case '[': case '(': level--; break;
-                               case '/': p = skipspace(p, -1) + 1; break;
-                               default: ;
+                                  case ']': case ')': level++; break;
+                                  case '[': case '(': level--; break;
+                                  case '/': p = skipspace(p, -1) + 1; break;
+                                  default: ;
                                   }
                           }
                                if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
                                   {    /* We found the name being declared */
                                        while ( !isidfirstchar(*p) )
-                                               p = skipspace(p, 1) + 1;
+                                         p = skipspace(p, 1) + 1;
                                        goto found;
                                   }
                                break;
-                       default: goto found;
+                          default:
+                               goto found;
                           }
                   }
 found:         if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
index 3f03b1e0c4a72ce6d366c320f5ef136bd0c2360c..4be030aa141e4763b83ac34739e75668d8f9e1b1 100644 (file)
@@ -1,3 +1,5 @@
+#serial 2
+
 dnl From Jim Meyering.
 dnl FIXME: this should migrate into libit.
 
@@ -5,7 +7,10 @@ AC_DEFUN(AM_FUNC_MKTIME,
 [AC_REQUIRE([AC_HEADER_TIME])dnl
  AC_CHECK_HEADERS(sys/time.h)
  AC_CACHE_CHECK([for working mktime], am_cv_func_working_mktime,
-  [AC_TRY_RUN([/* Test program from Tony Leneis (tony@plaza.ds.adp.com).  */
+  [AC_TRY_RUN(
+changequote(<<, >>)dnl
+<</* Test program from Paul Eggert (eggert@twinsun.com)
+   and Tony Leneis (tony@plaza.ds.adp.com).  */
 #if TIME_WITH_SYS_TIME
 # include <sys/time.h>
 # include <time.h>
@@ -16,14 +21,50 @@ AC_DEFUN(AM_FUNC_MKTIME,
 #  include <time.h>
 # endif
 #endif
+
+static time_t time_t_max;
+
+/* Values we'll use to set the TZ environment variable.  */
+static const char *const tz_strings[] = {
+  NULL, "GMT0", "JST-9", "EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
+};
+#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
+
+static void
+mktime_test (now)
+     time_t now;
+{
+  if (mktime (localtime (&now)) != now)
+    exit (1);
+  now = time_t_max - now;
+  if (mktime (localtime (&now)) != now)
+    exit (1);
+}
+
 int
 main ()
 {
-  time_t today = time (0);
-  struct tm *local = localtime (&today);
-  exit (mktime (local) != today);
+  time_t t, delta;
+  int i;
+
+  for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
+    continue;
+  time_t_max--;
+  delta = time_t_max / 997; /* a suitable prime number */
+  for (i = 0; i < N_STRINGS; i++)
+    {
+      if (tz_strings[i])
+       putenv (tz_strings[i]);
+
+      for (t = 0; t <= time_t_max - delta; t += delta)
+       mktime_test (t);
+      mktime_test ((time_t) 60 * 60);
+      mktime_test ((time_t) 60 * 60 * 24);
+    }
+  exit (0);
 }
-             ],
+             >>,
+changequote([, ])dnl
             am_cv_func_working_mktime=yes, am_cv_func_working_mktime=no,
             dnl When crosscompiling, assume mktime is missing or broken.
             am_cv_func_working_mktime=no)
index 3d255ef5db3216d570be3a31399b9c7da1d9f5c4..68689e8d0cadeb2c9a512c53a4feb58a8d8e6077 100644 (file)
--- a/progs.am
+++ b/progs.am
@@ -27,7 +27,7 @@ install-@DIR@PROGRAMS: $(@DIR@_PROGRAMS)
 ## Note that we explicitly set the libtool mode.  This avoids any
 ## lossage if the install program doesn't have a name that libtool
 ## expects.
-           echo " @LIBTOOL --mode=install@ $(INSTALL_PROGRAM) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`"; \
+           echo " @LIBTOOL --mode=install@ $(INSTALL_PROGRAM) $$p@EXEEXT@ $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@"; \
            @LIBTOOL --mode=install@ $(INSTALL_PROGRAM) $$p@EXEEXT@ $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@; \
          else :; fi; \
        done
index 6700f4462f1933c1ee241899c7fd70ca1c693647..9ca60ff26a2d43cb5d3a2afe85c5e75b55fad329 100644 (file)
@@ -22,11 +22,11 @@ install-@DIR@SCRIPTS: $(@DIR@_SCRIPTS)
 ## a syntax error in sh.
        @list="$(@DIR@_SCRIPTS)"; for p in $$list; do \
          if test -f $$p; then \
-           echo " $(INSTALL_SCRIPT) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`"; \
-           $(INSTALL_SCRIPT) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`; \
+           echo " $(INSTALL_SCRIPT) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@"; \
+           $(INSTALL_SCRIPT) $$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@; \
          else if test -f $(srcdir)/$$p; then \
-           echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`"; \
-           $(INSTALL_SCRIPT) $(srcdir)/$$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`; \
+           echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@"; \
+           $(INSTALL_SCRIPT) $(srcdir)/$$p $(@DIR@dir)/`echo $$p|sed '$(transform)'`@EXEEXT@; \
          else :; fi; fi; \
        done