From: Tom Tromey Date: Wed, 4 Dec 1996 02:04:43 +0000 (+0000) Subject: Fixes from Gord X-Git-Tag: v1.10.2~3307 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38bca416289b2da147cd85d9579464daf01405ca;p=platform%2Fupstream%2Fautomake.git Fixes from Gord --- diff --git a/ChangeLog b/ChangeLog index da6ec9b..5f63f05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,27 @@ +Tue Dec 3 18:58:40 1996 Tom Tromey + + * automake.in (handle_dependencies): Skip C-only lines in + depend2.am when appropriate. + * depend2.am (.deps/%.P): Omit modification of $o if language is + not C. + +Tue Dec 3 11:29:01 1996 Gordon Matzigkeit + + * compile-kr.am: Quote arguments to echo. + + * progs.am: Fix up problems when LIBTOOL is not defined (by + setting shell variable instprog to the installation program). + + * aclocal.in (scan_file): Allow the acinclude.m4 file to override + any other macro files (but still prevent multiple definitions + within acinclude.m4). + Tue Dec 3 10:40:48 1996 Tom Tromey + From Ulrich Drepper: + * automake.in (handle_emacs_lisp): Typo fix. + (scan_configure): Only recognize VERSION after whitespace. + * texinfos.am: install-info requires path to info file. * progs.am: Use @LIBTOOL@, not $(LIBTOOL). @@ -7,6 +29,13 @@ Tue Dec 3 10:40:48 1996 Tom Tromey * automake.in (am_install_var): If -ltlibs passed, substitute @LIBTOOL@. +Mon Dec 2 13:51:11 1996 Gordon Matzigkeit + + * automake.in (get_object_extension): Unshift ansi2knr onto the + all target, so that it builds before any other targets. + [de_ansi_objects]: Delete, since unshifting ansi2knr is an easier + solution. + Mon Dec 2 12:13:27 1996 Tom Tromey * Released 1.1i. diff --git a/NEWS b/NEWS index 42185dc..cc4747e 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -New in 1.1i: +New in 1.1j: * Bug fixes * Better DejaGNU support * Added no-installinfo option diff --git a/aclocal.in b/aclocal.in index 4ba3976..4aa8697 100644 --- a/aclocal.in +++ b/aclocal.in @@ -334,13 +334,17 @@ sub scan_file if (/$ac_defun_rx/) { - if (defined $map{$1}) + if (!defined $map{$1}) + { + $map{$1} = $file; + } + # Allow acinclude.m4 to override other macro files. + elsif ($map{$1} ne 'acinclude.m4' || $file eq 'acinclude.m4') { warn "aclocal: $file: $.: duplicated macro \`$1'\n"; $exit_status = 1; } - print STDERR "Found macro $1 in $file\n" if $verbosity; - $map{$1} = $file; + print STDERR "Found macro $1 in $file: $.\n" if $verbosity; } } close (FILE); diff --git a/ansi2knr.c b/ansi2knr.c index f581c07..22e68e1 100644 --- a/ansi2knr.c +++ b/ansi2knr.c @@ -482,493 +482,3 @@ found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) free((char *)breaks); return 0; } - ---------------1BA817596D5A -Content-Type: text/plain; charset=us-ascii -Content-Transfer-Encoding: 7bit -Content-Disposition: inline; filename="ansi2knr.c" - -/* 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 is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY. No author or distributor accepts responsibility to anyone for the -consequences of using it or for whether it serves any particular purpose or -works at all, unless he says so in writing. Refer to the GNU General Public -License (the "GPL") for full details. - -Everyone is granted permission to copy, modify and redistribute ansi2knr, -but only under the conditions described in the GPL. A copy of this license -is supposed to have been given to you along with ansi2knr so you can know -your rights and responsibilities. It should be in a file named COPYLEFT. -Among other things, the copyright notice and this notice must be preserved -on all copies. - -We explicitly state here what we believe is already implied by the GPL: if -the ansi2knr program is distributed as a separate set of sources and a -separate executable file which are aggregated on a storage medium together -with another program, this in itself does not bring the other program under -the GPL, nor does the mere fact that such a program or the procedures for -constructing it invoke the ansi2knr executable bring any other part of the -program under the GPL. -*/ - -/* - * Usage: - ansi2knr input_file [output_file] - * If no output_file is supplied, output goes to stdout. - * 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. - * 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. - * 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. - */ - -/* - * The original and principal author of ansi2knr is L. Peter Deutsch - * . Other authors are noted in the change history - * that follows (in reverse chronological order): - 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 - lpd 94-12-18 added conditionals for systems where ctype macros - don't handle 8-bit characters properly, suggested by - Francois Pinard ; - removed --varargs switch (this is now the default) - lpd 94-10-10 removed CONFIG_BROKETS conditional - lpd 94-07-16 added some conditionals to help GNU `configure', - suggested by Francois Pinard ; - properly erase prototype args in function parameters, - contributed by Jim Avera ; - correct error in writeblanks (it shouldn't erase EOLs) - lpd 89-xx-xx original version - */ - -/* Most of the conditionals here are to make ansi2knr work with */ -/* the GNU configure machinery. */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#ifdef HAVE_CONFIG_H - -/* - For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). - This will define HAVE_CONFIG_H and so, activate the following lines. - */ - -# if STDC_HEADERS || HAVE_STRING_H -# include -# else -# include -# endif - -#else /* not HAVE_CONFIG_H */ - -/* - Without AC_CONFIG_HEADER, merely use as in the original - Ghostscript distribution. This loses on older BSD systems. - */ - -# include - -#endif /* not HAVE_CONFIG_H */ - -#ifdef STDC_HEADERS -# include -#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(); -#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 -#else -# define is_ascii(c) isascii(c) -#endif - -#define is_space(c) (is_ascii(c) && isspace(c)) -#define is_alpha(c) (is_ascii(c) && isalpha(c)) -#define is_alnum(c) (is_ascii(c) && isalnum(c)) - -/* Scanning macros */ -#define isidchar(ch) (is_alnum(ch) || (ch) == '_') -#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') - -/* Forward references */ -char *skipspace(); -void writeblanks(); -int test1(); -int convert1(); - -/* The main program */ -int -main(argc, argv) - int argc; - char *argv[]; -{ FILE *in, *out; -#define bufsize 5000 /* arbitrary size */ - char *buf; - char *line; - /* - * In previous versions, ansi2knr recognized a --varargs switch. - * If this switch was supplied, ansi2knr would attempt to convert - * a ... argument to va_alist and va_dcl; if this switch was not - * supplied, ansi2knr would simply drop any such arguments. - * Now, ansi2knr always does this conversion, and we only - * check for this switch for backward compatibility. - */ - int convert_varargs = 1; - - if ( argc > 1 && argv[1][0] == '-' ) - { if ( !strcmp(argv[1], "--varargs") ) - { convert_varargs = 1; - argc--; - argv++; - } - else - { fprintf(stderr, "Unrecognized switch: %s\n", argv[1]); - exit(1); - } - } - switch ( argc ) - { - default: - printf("Usage: ansi2knr input_file [output_file]\n"); - exit(0); - case 2: - out = stdout; - break; - case 3: - out = fopen(argv[2], "w"); - if ( out == NULL ) - { fprintf(stderr, "Cannot open output file %s\n", argv[2]); - exit(1); - } - } - in = fopen(argv[1], "r"); - if ( in == NULL ) - { fprintf(stderr, "Cannot open input file %s\n", argv[1]); - exit(1); - } - fprintf(out, "#line 1 \"%s\"\n", argv[1]); - buf = malloc(bufsize); - line = buf; - while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) - { 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); - break; - case -1: /* maybe the start of a function */ - line = buf + strlen(buf); - if ( line != buf + (bufsize - 1) ) /* overflow check */ - continue; - /* falls through */ - default: /* not a function */ - fputs(buf, out); - break; - } - line = buf; - } - if ( line != buf ) fputs(buf, out); - free(buf); - fclose(out); - fclose(in); - return 0; -} - -/* Skip over space and comments, 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; -} - -/* - * Write blanks over part of a string. - * Don't overwrite end-of-line characters. - */ -void -writeblanks(start, end) - char *start; - char *end; -{ char *p; - for ( p = start; p < end; p++ ) - if ( *p != '\r' && *p != '\n' ) *p = ' '; -} - -/* - * Test whether the string in buf is a function definition. - * The string may contain and/or end with a newline. - * Return as follows: - * 0 - definitely not a function definition; - * 1 - definitely a function definition; - * 2 - definitely a function prototype (NOT USED); - * -1 - may be the beginning of a function definition, - * append another line and look again. - * The reason we don't attempt to convert function prototypes is that - * Ghostscript's declaration-generating macros look too much like - * prototypes, and confuse the algorithms. - */ -int -test1(buf) - char *buf; -{ register 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); - 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; - } - while ( isidchar(*p) ) p++; - endfn = p; - p = skipspace(p, 1); - if ( *p++ != '(' ) - return 0; /* not a function */ - p = skipspace(p, 1); - if ( *p == ')' ) - 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). */ - { static char *words[] = - { "asm", "auto", "case", "char", "const", "double", - "extern", "float", "for", "if", "int", "long", - "register", "return", "short", "signed", "sizeof", - "static", "switch", "typedef", "unsigned", - "void", "volatile", "while", 0 - }; - 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 */ - key++; - } - } - return contin; -} - -/* Convert a recognized function definition or header to K&R syntax. */ -int -convert1(buf, out, header, convert_varargs) - char *buf; - FILE *out; - int header; /* Boolean */ - int convert_varargs; /* Boolean */ -{ char *endfn; - register char *p; - 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++) != '('; ) ; -top: p = endfn; - breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); - if ( breaks == 0 ) - { /* Couldn't allocate break table, give up */ - fprintf(stderr, "Unable to allocate break table!\n"); - fputs(buf, out); - return -1; - } - btop = breaks + num_breaks * 2 - 2; - bp = breaks; - /* Parse the argument list */ - do - { int level = 0; - char *lp = NULL; - char *rp; - char *end = NULL; - if ( bp >= btop ) - { /* Filled up break table. */ - /* Allocate a bigger one and start over. */ - free((char *)breaks); - num_breaks <<= 1; - goto top; - } - *bp++ = p; - /* Find the end of the argument */ - for ( ; end == NULL; p++ ) - { switch(*p) - { - case ',': - if ( !level ) end = p; - break; - case '(': - if ( !level ) lp = p; - level++; - break; - case ')': - if ( --level < 0 ) end = p; - else rp = p; - break; - case '/': - p = skipspace(p, 1) - 1; - break; - default: - ; - } - } - /* Erase any embedded prototype parameters. */ - if ( lp ) - writeblanks(lp + 1, rp); - p--; /* back up over terminator */ - /* Find the name being declared. */ - /* This is complicated because of procedure and */ - /* array modifiers. */ - for ( ; ; ) - { p = skipspace(p - 1, -1); - switch ( *p ) - { - 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: ; - } - } - if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) - { /* We found the name being declared */ - while ( !isidfirstchar(*p) ) - p = skipspace(p, 1) + 1; - goto found; - } - break; - default: goto found; - } - } -found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) - { if ( convert_varargs ) - { *bp++ = "va_alist"; - vararg = p-2; - } - else - { p++; - if ( bp == breaks + 1 ) /* sole argument */ - writeblanks(breaks[0], p); - else - writeblanks(bp[-1] - 1, p); - bp--; - } - } - else - { while ( isidchar(*p) ) p--; - *bp++ = p+1; - } - p = end; - } - while ( *p++ == ',' ); - *bp = p; - /* Make a special check for 'void' arglist */ - if ( bp == breaks+2 ) - { p = skipspace(breaks[0], 1); - if ( !strncmp(p, "void", 4) ) - { p = skipspace(p+4, 1); - if ( p == breaks[2] - 1 ) - { bp = breaks; /* yup, pretend arglist is empty */ - writeblanks(breaks[0], p + 1); - } - } - } - /* Put out the function name and left parenthesis. */ - p = buf; - while ( p != endfn ) putc(*p, out), p++; - /* Put out the declaration. */ - if ( header ) - { fputs(");", out); - for ( p = breaks[0]; *p; p++ ) - if ( *p == '\r' || *p == '\n' ) - putc(*p, out); - } - else - { for ( ap = breaks+1; ap < bp; ap += 2 ) - { p = *ap; - while ( isidchar(*p) ) - putc(*p, out), p++; - if ( ap < bp - 1 ) - fputs(", ", out); - } - fputs(") ", out); - /* Put out the argument declarations */ - for ( ap = breaks+2; ap <= bp; ap += 2 ) - (*ap)[-1] = ';'; - if ( vararg != 0 ) - { *vararg = 0; - fputs(breaks[0], out); /* any prior args */ - fputs("va_dcl", out); /* the final arg */ - fputs(bp[0], out); - } - else - fputs(breaks[0], out); - } - free((char *)breaks); - return 0; -} diff --git a/automake.in b/automake.in index 291d8f3..18542d2 100755 --- a/automake.in +++ b/automake.in @@ -660,7 +660,7 @@ sub get_object_extension } push (@suffixes, '._c', '._o'); - push (@suffixes, '._lo') if $seen_libtool; + push (@suffixes, '.l_o') if $seen_libtool; # Only require ansi2knr files if they should appear in # this directory. @@ -673,7 +673,7 @@ sub get_object_extension &push_phony_cleaners ('krextra'); } - &define_variable ('o', ".\@U\@o"); + &define_variable ('o', "\@U\@o"); # Make sure ansi2knr can be found: if no path specified, # specify "./". @@ -688,6 +688,8 @@ sub get_object_extension # Substitution from AM_C_PROTOTYPES. This makes it be # built only when necessary. &define_configure_variable ('ANSI2KNR'); + # ansi2knr needs to be built before subdirs, so unshift it. + unshift (@all, '$(ANSI2KNR)'); } $output_rules .= &file_contents ('compile-kr'); @@ -2155,7 +2157,8 @@ sub handle_dependencies &push_phony_cleaners ('depend'); $output_rules .= &file_contents_with_transform ('s/\@EXT\@/.c/g;' - . 's/\@MKDEP\@/MKDEP/g', + . 's/\@MKDEP\@/MKDEP/g' + . 's/^ONLYC//g', 'depend2'); local ($ext); local ($need_cxx) = 0; @@ -2163,7 +2166,8 @@ sub handle_dependencies { $output_rules .= &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;' - . 's/\@MKDEP\@/CXXMKDEP/g', + . 's/\@MKDEP\@/CXXMKDEP/g' + . 'next if /^ONLYC/;', 'depend2'); $need_cxx = 1; } @@ -3013,7 +3017,7 @@ sub handle_emacs_lisp &define_configure_variable ('EMACS'); $output_rules .= (".el.elc:\n" . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n" - . "\t\EMACS=$(EMACS) $(SHELL) \$(srcdir)/elisp-comp \$<\n"); + . "\tEMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<\n"); push (@suffixes, '.el', '.elc'); # Generate .elc files. @@ -3267,7 +3271,7 @@ sub scan_configure $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/; $seen_package = 1 if /PACKAGE=/; - if (/VERSION=(\S+)/) + if (/\bVERSION=(\S+)/) { $seen_version = 1; $package_version = $1; @@ -4440,13 +4444,10 @@ sub require_file_internal $trailer .= "; error while making link: $!\n"; } } - else + elsif (! system ('cp', $am_dir . '/' . $file, $errfile)) { - if (! system ('cp', $am_dir . '/' . $file, $errfile)) - { - $suppress = 0; - $trailer .= "\n error while making link: $!\n"; - } + $suppress = 0; + $trailer .= "\n error while making link\n"; } } } diff --git a/clean-kr.am b/clean-kr.am index 56a1466..6307d03 100644 --- a/clean-kr.am +++ b/clean-kr.am @@ -16,7 +16,7 @@ ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. mostlyclean-kr: - rm -f *._o *._c _*.c _*.o + rm -f *._o *.l_o *._c _*.c _*.o clean-kr: diff --git a/compile-kr.am b/compile-kr.am index 46c7559..86cecf9 100644 --- a/compile-kr.am +++ b/compile-kr.am @@ -19,12 +19,23 @@ $(ANSI2KNR) $< > $*.tmp && mv $*.tmp $@ ._c._o: - @echo $(COMPILE) -c $< + @echo "$(COMPILE) -c $<" @rm -f _$*.c @ln $< _$*.c && $(COMPILE) -c _$*.c && mv _$*.o $@ && rm _$*.c +._c.l_o: + @echo "$(LIBTOOL) --mode=compile $(COMPILE) -c $<" + @rm -f _$*.c + @ln $< _$*.c && $(LIBTOOL) --mode=compile $(COMPILE) -c _$*.c && mv _$*.lo $@ && rm _$*.c + .c._o: $(ANSI2KNR) $< > $*.tmp && mv $*.tmp $*._c - @echo $(COMPILE) -c $*._c + @echo "$(COMPILE) -c $*._c" @rm -f _$*.c @ln $*._c _$*.c && $(COMPILE) -c _$*.c && mv _$*.o $@ && rm _$*.c + +.c.l_o: + $(ANSI2KNR) $< > $*.tmp && mv $*.tmp $*._c + @echo "$(LIBTOOL) --mode=compile $(COMPILE) -c $*._c" + @rm -f _$*.c + @ln $*._c _$*.c && $(LIBTOOL) --mode=compile $(COMPILE) -c _$*.c && mv _$*.lo $@ && rm _$*.c diff --git a/depend2.am b/depend2.am index dfe0d85..97fe1c9 100644 --- a/depend2.am +++ b/depend2.am @@ -17,11 +17,6 @@ ## 02111-1307, USA. .deps/%.P: $(srcdir)/%@EXT@ @echo "Computing dependencies for $<..." - @$(@MKDEP@) $< > $@-tmp -## FIXME: shouldn't do this for languages other than C. - @if test -n "$o"; then \ - sed 's/\.o:/$$o:/' $@-tmp > $@; \ - rm $@-tmp; \ - else \ - mv $@-tmp $@; \ - fi + @o='o'; \ +ONLYC test -n "$o" && o='$$o'; \ + $(@MKDEP@) $< | sed "s/^\(.*\)\.o:/\1.$$o \1.l$$o:/" > $@ diff --git a/lib/am/depend2.am b/lib/am/depend2.am index dfe0d85..97fe1c9 100644 --- a/lib/am/depend2.am +++ b/lib/am/depend2.am @@ -17,11 +17,6 @@ ## 02111-1307, USA. .deps/%.P: $(srcdir)/%@EXT@ @echo "Computing dependencies for $<..." - @$(@MKDEP@) $< > $@-tmp -## FIXME: shouldn't do this for languages other than C. - @if test -n "$o"; then \ - sed 's/\.o:/$$o:/' $@-tmp > $@; \ - rm $@-tmp; \ - else \ - mv $@-tmp $@; \ - fi + @o='o'; \ +ONLYC test -n "$o" && o='$$o'; \ + $(@MKDEP@) $< | sed "s/^\(.*\)\.o:/\1.$$o \1.l$$o:/" > $@ diff --git a/lib/ansi2knr.c b/lib/ansi2knr.c index f581c07..22e68e1 100644 --- a/lib/ansi2knr.c +++ b/lib/ansi2knr.c @@ -482,493 +482,3 @@ found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) free((char *)breaks); return 0; } - ---------------1BA817596D5A -Content-Type: text/plain; charset=us-ascii -Content-Transfer-Encoding: 7bit -Content-Disposition: inline; filename="ansi2knr.c" - -/* 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 is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY. No author or distributor accepts responsibility to anyone for the -consequences of using it or for whether it serves any particular purpose or -works at all, unless he says so in writing. Refer to the GNU General Public -License (the "GPL") for full details. - -Everyone is granted permission to copy, modify and redistribute ansi2knr, -but only under the conditions described in the GPL. A copy of this license -is supposed to have been given to you along with ansi2knr so you can know -your rights and responsibilities. It should be in a file named COPYLEFT. -Among other things, the copyright notice and this notice must be preserved -on all copies. - -We explicitly state here what we believe is already implied by the GPL: if -the ansi2knr program is distributed as a separate set of sources and a -separate executable file which are aggregated on a storage medium together -with another program, this in itself does not bring the other program under -the GPL, nor does the mere fact that such a program or the procedures for -constructing it invoke the ansi2knr executable bring any other part of the -program under the GPL. -*/ - -/* - * Usage: - ansi2knr input_file [output_file] - * If no output_file is supplied, output goes to stdout. - * 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. - * 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. - * 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. - */ - -/* - * The original and principal author of ansi2knr is L. Peter Deutsch - * . Other authors are noted in the change history - * that follows (in reverse chronological order): - 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 - lpd 94-12-18 added conditionals for systems where ctype macros - don't handle 8-bit characters properly, suggested by - Francois Pinard ; - removed --varargs switch (this is now the default) - lpd 94-10-10 removed CONFIG_BROKETS conditional - lpd 94-07-16 added some conditionals to help GNU `configure', - suggested by Francois Pinard ; - properly erase prototype args in function parameters, - contributed by Jim Avera ; - correct error in writeblanks (it shouldn't erase EOLs) - lpd 89-xx-xx original version - */ - -/* Most of the conditionals here are to make ansi2knr work with */ -/* the GNU configure machinery. */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include - -#ifdef HAVE_CONFIG_H - -/* - For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h). - This will define HAVE_CONFIG_H and so, activate the following lines. - */ - -# if STDC_HEADERS || HAVE_STRING_H -# include -# else -# include -# endif - -#else /* not HAVE_CONFIG_H */ - -/* - Without AC_CONFIG_HEADER, merely use as in the original - Ghostscript distribution. This loses on older BSD systems. - */ - -# include - -#endif /* not HAVE_CONFIG_H */ - -#ifdef STDC_HEADERS -# include -#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(); -#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 -#else -# define is_ascii(c) isascii(c) -#endif - -#define is_space(c) (is_ascii(c) && isspace(c)) -#define is_alpha(c) (is_ascii(c) && isalpha(c)) -#define is_alnum(c) (is_ascii(c) && isalnum(c)) - -/* Scanning macros */ -#define isidchar(ch) (is_alnum(ch) || (ch) == '_') -#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_') - -/* Forward references */ -char *skipspace(); -void writeblanks(); -int test1(); -int convert1(); - -/* The main program */ -int -main(argc, argv) - int argc; - char *argv[]; -{ FILE *in, *out; -#define bufsize 5000 /* arbitrary size */ - char *buf; - char *line; - /* - * In previous versions, ansi2knr recognized a --varargs switch. - * If this switch was supplied, ansi2knr would attempt to convert - * a ... argument to va_alist and va_dcl; if this switch was not - * supplied, ansi2knr would simply drop any such arguments. - * Now, ansi2knr always does this conversion, and we only - * check for this switch for backward compatibility. - */ - int convert_varargs = 1; - - if ( argc > 1 && argv[1][0] == '-' ) - { if ( !strcmp(argv[1], "--varargs") ) - { convert_varargs = 1; - argc--; - argv++; - } - else - { fprintf(stderr, "Unrecognized switch: %s\n", argv[1]); - exit(1); - } - } - switch ( argc ) - { - default: - printf("Usage: ansi2knr input_file [output_file]\n"); - exit(0); - case 2: - out = stdout; - break; - case 3: - out = fopen(argv[2], "w"); - if ( out == NULL ) - { fprintf(stderr, "Cannot open output file %s\n", argv[2]); - exit(1); - } - } - in = fopen(argv[1], "r"); - if ( in == NULL ) - { fprintf(stderr, "Cannot open input file %s\n", argv[1]); - exit(1); - } - fprintf(out, "#line 1 \"%s\"\n", argv[1]); - buf = malloc(bufsize); - line = buf; - while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) - { 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); - break; - case -1: /* maybe the start of a function */ - line = buf + strlen(buf); - if ( line != buf + (bufsize - 1) ) /* overflow check */ - continue; - /* falls through */ - default: /* not a function */ - fputs(buf, out); - break; - } - line = buf; - } - if ( line != buf ) fputs(buf, out); - free(buf); - fclose(out); - fclose(in); - return 0; -} - -/* Skip over space and comments, 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; -} - -/* - * Write blanks over part of a string. - * Don't overwrite end-of-line characters. - */ -void -writeblanks(start, end) - char *start; - char *end; -{ char *p; - for ( p = start; p < end; p++ ) - if ( *p != '\r' && *p != '\n' ) *p = ' '; -} - -/* - * Test whether the string in buf is a function definition. - * The string may contain and/or end with a newline. - * Return as follows: - * 0 - definitely not a function definition; - * 1 - definitely a function definition; - * 2 - definitely a function prototype (NOT USED); - * -1 - may be the beginning of a function definition, - * append another line and look again. - * The reason we don't attempt to convert function prototypes is that - * Ghostscript's declaration-generating macros look too much like - * prototypes, and confuse the algorithms. - */ -int -test1(buf) - char *buf; -{ register 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); - 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; - } - while ( isidchar(*p) ) p++; - endfn = p; - p = skipspace(p, 1); - if ( *p++ != '(' ) - return 0; /* not a function */ - p = skipspace(p, 1); - if ( *p == ')' ) - 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). */ - { static char *words[] = - { "asm", "auto", "case", "char", "const", "double", - "extern", "float", "for", "if", "int", "long", - "register", "return", "short", "signed", "sizeof", - "static", "switch", "typedef", "unsigned", - "void", "volatile", "while", 0 - }; - 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 */ - key++; - } - } - return contin; -} - -/* Convert a recognized function definition or header to K&R syntax. */ -int -convert1(buf, out, header, convert_varargs) - char *buf; - FILE *out; - int header; /* Boolean */ - int convert_varargs; /* Boolean */ -{ char *endfn; - register char *p; - 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++) != '('; ) ; -top: p = endfn; - breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); - if ( breaks == 0 ) - { /* Couldn't allocate break table, give up */ - fprintf(stderr, "Unable to allocate break table!\n"); - fputs(buf, out); - return -1; - } - btop = breaks + num_breaks * 2 - 2; - bp = breaks; - /* Parse the argument list */ - do - { int level = 0; - char *lp = NULL; - char *rp; - char *end = NULL; - if ( bp >= btop ) - { /* Filled up break table. */ - /* Allocate a bigger one and start over. */ - free((char *)breaks); - num_breaks <<= 1; - goto top; - } - *bp++ = p; - /* Find the end of the argument */ - for ( ; end == NULL; p++ ) - { switch(*p) - { - case ',': - if ( !level ) end = p; - break; - case '(': - if ( !level ) lp = p; - level++; - break; - case ')': - if ( --level < 0 ) end = p; - else rp = p; - break; - case '/': - p = skipspace(p, 1) - 1; - break; - default: - ; - } - } - /* Erase any embedded prototype parameters. */ - if ( lp ) - writeblanks(lp + 1, rp); - p--; /* back up over terminator */ - /* Find the name being declared. */ - /* This is complicated because of procedure and */ - /* array modifiers. */ - for ( ; ; ) - { p = skipspace(p - 1, -1); - switch ( *p ) - { - 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: ; - } - } - if ( *p == '(' && *skipspace(p + 1, 1) == '*' ) - { /* We found the name being declared */ - while ( !isidfirstchar(*p) ) - p = skipspace(p, 1) + 1; - goto found; - } - break; - default: goto found; - } - } -found: if ( *p == '.' && p[-1] == '.' && p[-2] == '.' ) - { if ( convert_varargs ) - { *bp++ = "va_alist"; - vararg = p-2; - } - else - { p++; - if ( bp == breaks + 1 ) /* sole argument */ - writeblanks(breaks[0], p); - else - writeblanks(bp[-1] - 1, p); - bp--; - } - } - else - { while ( isidchar(*p) ) p--; - *bp++ = p+1; - } - p = end; - } - while ( *p++ == ',' ); - *bp = p; - /* Make a special check for 'void' arglist */ - if ( bp == breaks+2 ) - { p = skipspace(breaks[0], 1); - if ( !strncmp(p, "void", 4) ) - { p = skipspace(p+4, 1); - if ( p == breaks[2] - 1 ) - { bp = breaks; /* yup, pretend arglist is empty */ - writeblanks(breaks[0], p + 1); - } - } - } - /* Put out the function name and left parenthesis. */ - p = buf; - while ( p != endfn ) putc(*p, out), p++; - /* Put out the declaration. */ - if ( header ) - { fputs(");", out); - for ( p = breaks[0]; *p; p++ ) - if ( *p == '\r' || *p == '\n' ) - putc(*p, out); - } - else - { for ( ap = breaks+1; ap < bp; ap += 2 ) - { p = *ap; - while ( isidchar(*p) ) - putc(*p, out), p++; - if ( ap < bp - 1 ) - fputs(", ", out); - } - fputs(") ", out); - /* Put out the argument declarations */ - for ( ap = breaks+2; ap <= bp; ap += 2 ) - (*ap)[-1] = ';'; - if ( vararg != 0 ) - { *vararg = 0; - fputs(breaks[0], out); /* any prior args */ - fputs("va_dcl", out); /* the final arg */ - fputs(bp[0], out); - } - else - fputs(breaks[0], out); - } - free((char *)breaks); - return 0; -} diff --git a/tests/ChangeLog b/tests/ChangeLog index c6bff3a..86b4ed3 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,13 @@ +Tue Dec 3 11:55:18 1996 Gordon Matzigkeit + + * dup.test, dup2.test: Modified, now that aclocal allows + acinclude.m4 to override any installed macro file. + +Mon Dec 2 22:44:16 1996 Gordon Matzigkeit + + * alllib.test: Removed from distribution, since LIBFILES are no + longer computed. + Sun Nov 24 14:36:00 1996 Tom Tromey * extra2.test: New file. diff --git a/tests/Makefile.am b/tests/Makefile.am index 9cf97c4..922dff7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -13,7 +13,7 @@ yacc.test mkinst2.test texinfo2.test ansi.test depacl.test depacl2.test \ error.test colon.test vtexi2.test tags.test comment.test ansi2.test \ man.test info.test obsolete.test lex.test scripts.test subdir2.test \ exsource.test canon4.test dup.test defun.test cxxlink.test cxxnoc.test \ -order.test libobj2.test interp.test alllib.test block.test libobj3.test \ +order.test libobj2.test interp.test block.test libobj3.test dup2.test \ gnits.test interp2.test colneq.test implicit.test spell.test spell2.test \ confsub.test primary.test primary2.test depend2.test spell3.test \ comment2.test vpath.test symlink.test discover.test acinclude.test req.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index aa9378b..13fd7a4 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -52,7 +52,7 @@ yacc.test mkinst2.test texinfo2.test ansi.test depacl.test depacl2.test \ error.test colon.test vtexi2.test tags.test comment.test ansi2.test \ man.test info.test obsolete.test lex.test scripts.test subdir2.test \ exsource.test canon4.test dup.test defun.test cxxlink.test cxxnoc.test \ -order.test libobj2.test interp.test alllib.test block.test libobj3.test \ +order.test libobj2.test interp.test block.test libobj3.test dup2.test \ gnits.test interp2.test colneq.test implicit.test spell.test spell2.test \ confsub.test primary.test primary2.test depend2.test spell3.test \ comment2.test vpath.test symlink.test discover.test acinclude.test req.test \ diff --git a/tests/alllib.test b/tests/alllib.test deleted file mode 100755 index 2f6425e..0000000 --- a/tests/alllib.test +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/sh - -# Make sure EXTRA_LIBRARIES aren't built by "all". -# Bug from Steve M Robbins. - -. $srcdir/defs || exit 1 - -cat >> configure.in << 'END' -AC_PROG_CC -AC_PROG_RANLIB -END - -cat > Makefile.am << 'END' -lib_LIBRARIES = libV.a -EXTRA_LIBRARIES = libVm.a -END - -$AUTOMAKE || exit 1 - -(grep '^LIBFILES =' Makefile.in | grep libVm) && exit 1 -exit 0 diff --git a/tests/canon4.test b/tests/canon4.test index 6c87424..5ca51e7 100755 --- a/tests/canon4.test +++ b/tests/canon4.test @@ -16,5 +16,5 @@ END $AUTOMAKE || exit 1 -grep '^x-y' Makefile.in && exit 1 +grep '^libx-y.*=' Makefile.in && exit 1 exit 0 diff --git a/tests/dup.test b/tests/dup.test index e873839..ee26cae 100755 --- a/tests/dup.test +++ b/tests/dup.test @@ -5,11 +5,12 @@ . $srcdir/defs || exit 1 cat > configure.in << 'END' -AM_FUNC_STRTOD +pkg_INTERNAL_MACRO END cat > acinclude.m4 << 'END' -AC_DEFUN([AM_FUNC_STRTOD]) +AC_DEFUN([pkg_INTERNAL_MACRO]) +AC_DEFUN([pkg_INTERNAL_MACRO]) END $ACLOCAL && exit 1 diff --git a/tests/dup2.test b/tests/dup2.test new file mode 100755 index 0000000..c012f16 --- /dev/null +++ b/tests/dup2.test @@ -0,0 +1,16 @@ +#! /bin/sh + +# Make sure aclocal only warns about definitions overridden by acinclude.m4. + +. $srcdir/defs || exit 1 + +cat > configure.in << 'END' +AM_FUNC_STRTOD +END + +cat > acinclude.m4 << 'END' +AC_DEFUN([AM_FUNC_STRTOD]) +END + +$ACLOCAL || exit 1 +exit 0