+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
* 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
-.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>.
-/* 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 */
*
* 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
*/
/* 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).
#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
/* Forward references */
char *skipspace();
-void writeblanks();
+int writeblanks();
int test1();
int convert1();
#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
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);
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;
* 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;
}
/*
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). */
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++;
}
}
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 )
char *lp = NULL;
char *rp;
char *end = NULL;
+
if ( bp >= btop )
{ /* Filled up break table. */
/* Allocate a bigger one and start over. */
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:
;
}
}
{ 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] == '.' )
@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"
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
## 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
## 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
-.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>.
-/* 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 */
*
* 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
*/
/* 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).
#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
/* Forward references */
char *skipspace();
-void writeblanks();
+int writeblanks();
int test1();
int convert1();
#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
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);
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;
* 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;
}
/*
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). */
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++;
}
}
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 )
char *lp = NULL;
char *rp;
char *end = NULL;
+
if ( bp >= btop )
{ /* Filled up break table. */
/* Allocate a bigger one and start over. */
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:
;
}
}
{ 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] == '.' )
+#serial 2
+
dnl From Jim Meyering.
dnl FIXME: this should migrate into libit.
[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>
# 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)
## 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
## 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