* lib/ansi2knr.1, lib/ansi2knr.c: Deleted. * lib/Makefile.am (dist_pkgvdata_DATA): Do not list them anymore. * lib/am/ansi2knr.am: Delete. * lib/am/Makefile.am (dist_am_DATA): Do not list it anymore. * lib/Automake/Variable.pm (%_am_macro_for_var): Remove entries for `ANSI2KNR' and `U'. * m4/depout.m4 (_AM_OUTPUT_DEPENDENCY_COMMANDS): Don't care anymore about possible definition of the `$U' variable. * automake.in (@common_files): Drop `ansi2knr.1' and `ansi2knr.c'. (struct): Remove scalar field `ansi'. All callers adjusted. (&lang_c_finish, %de_ansi_files): Remove, they're not required anymore. All callers adjusted. ($get_object_extension_was_run): Fix typo in comment. (&get_object_extension): Drop code dealing with de-ansification; it's basically a no-op now, but is required to properly initialize `$get_object_extension_was_run' variable. (&handle_languages, &handle_compile, &lang_c_rewrite): Drop code dealing with de-ansification. --- ChangeLog | 24 ++ automake.in | 246 +--------------- lib/Automake/Variable.pm | 2 - lib/Makefile.am | 7 +- lib/Makefile.in | 14 +- lib/am/Makefile.am | 3 +- lib/am/Makefile.in | 3 +- lib/am/ansi2knr.am | 77 ----- lib/ansi2knr.1 | 36 --- lib/ansi2knr.c | 739 ---------------------------------------------- m4/depout.m4 | 4 +- 11 files changed, 45 insertions(+), 1110 deletions(-) delete mode 100644 lib/am/ansi2knr.am delete mode 100644 lib/ansi2knr.1 delete mode 100644 lib/ansi2knr.c
diff --git a/ChangeLog b/ChangeLog index 0ea7ddf..1542bc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,29 @@ 2011-08-28 Stefano Lattarini <stefano.lattar...@gmail.com> + ansi: remove dead code/files for automatic de-ANSI-fication support + * lib/ansi2knr.1, lib/ansi2knr.c: Deleted. + * lib/Makefile.am (dist_pkgvdata_DATA): Do not list them anymore. + * lib/am/ansi2knr.am: Delete. + * lib/am/Makefile.am (dist_am_DATA): Do not list it anymore. + * lib/Automake/Variable.pm (%_am_macro_for_var): Remove entries for + `ANSI2KNR' and `U'. + * m4/depout.m4 (_AM_OUTPUT_DEPENDENCY_COMMANDS): Don't care anymore + about possible definition of the `$U' variable. + * automake.in (@common_files): Drop `ansi2knr.1' and `ansi2knr.c'. + (struct): Remove scalar field `ansi'. + All callers adjusted. + (&lang_c_finish, %de_ansi_files): Remove, they're not required + anymore. + All callers adjusted. + ($get_object_extension_was_run): Fix typo in comment. + (&get_object_extension): Drop code dealing with de-ansification; + it's basically a no-op now, but is required to properly initialize + `$get_object_extension_was_run' variable. + (&handle_languages, &handle_compile, &lang_c_rewrite): Drop code + dealing with de-ansification. + +2011-08-28 Stefano Lattarini <stefano.lattar...@gmail.com> + ansi: reject attempts to use automatic de-ANSI-fication support * tests/protos.m4 (AM_C_PROTOTYPES): Error out whenever called. * lib/Automake/Options.pm (_process_option_list ): Error out diff --git a/automake.in b/automake.in index 517eea9..0aac1a3 100644 --- a/automake.in +++ b/automake.in @@ -53,7 +53,6 @@ struct (# Short name of the language (c, f77...). # List of configure variables which must be defined. 'config_vars' => '@', - 'ansi' => "\$", # `pure' is `1' or `'. A `pure' language is one where, if # all the files in a directory are of that language, then we # do not require the C compiler or any code to call it. @@ -233,7 +232,7 @@ my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh); my @common_files = (qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO - ansi2knr.1 ansi2knr.c ar-lib compile config.guess config.rpath + ar-lib compile config.guess config.rpath config.sub depcomp elisp-comp install-sh libversion.in mdate-sh missing mkinstalldirs py-compile texinfo.tex ylwrap), @libtool_files, @libtool_sometimes); @@ -568,12 +567,6 @@ my @dist_targets; my %known_programs; my %known_libraries; -# Keys in this hash are the basenames of files which must depend on -# ansi2knr. Values are either the empty string, or the directory in -# which the ANSI source file appears; the directory must have a -# trailing `/'. -my %de_ansi_files; - # This keeps track of which extensions we've seen (that we care # about). my %extension_seen; @@ -598,7 +591,7 @@ my %linkers_used; my $need_link; # Was get_object_extension run? -# FIXME: This is a hack. a better switch should be found. +# FIXME: This is a hack; a better switch should be found. my $get_object_extension_was_run; # Record each file processed by make_paragraphs. @@ -699,8 +692,6 @@ sub initialize_per_input () %known_programs = (); %known_libraries= (); - %de_ansi_files = (); - %extension_seen = (); %language_scratch = (); @@ -725,7 +716,6 @@ sub initialize_per_input () register_language ('name' => 'c', 'Name' => 'C', 'config_vars' => ['CC'], - 'ansi' => 1, 'autodep' => '', 'flags' => ['CFLAGS', 'CPPFLAGS'], 'ccer' => 'CC', @@ -737,8 +727,7 @@ register_language ('name' => 'c', 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', 'compile_flag' => '-c', 'libtool_tag' => 'CC', - 'extensions' => ['.c'], - '_finish' => \&lang_c_finish); + 'extensions' => ['.c']); # C++. register_language ('name' => 'cxx', @@ -895,10 +884,7 @@ register_language ('name' => 'asm', 'compiler' => 'CCASCOMPILE', 'compile_flag' => '-c', 'output_flag' => '-o', - 'extensions' => ['.s'], - - # With assembly we still use the C linker. - '_finish' => \&lang_c_finish); + 'extensions' => ['.s']); # Preprocessed Assembler. register_language ('name' => 'cppasm', @@ -912,10 +898,7 @@ register_language ('name' => 'cppasm', 'compiler' => 'CPPASCOMPILE', 'compile_flag' => '-c', 'output_flag' => '-o', - 'extensions' => ['.S', '.sx'], - - # With assembly we still use the C linker. - '_finish' => \&lang_c_finish); + 'extensions' => ['.S', '.sx']); # Fortran 77 register_language ('name' => 'f77', @@ -1286,18 +1269,12 @@ sub shadow_unconditionally ($$) # get_object_extension ($EXTENSION) # --------------------------------- -# Prefix $EXTENSION with $U if ansi2knr is in use. +# FIXME: this is only used so that `$get_object_extension_was_run' gets +# properly defined. We should refactor to get rid of such an hack. sub get_object_extension ($) { - my ($extension) = @_; - - # Check for automatic de-ANSI-fication. - $extension = '$U' . $extension - if option 'ansi2knr'; - $get_object_extension_was_run = 1; - - return $extension; + return $_[0]; } # check_user_variables (@LIST) @@ -1524,97 +1501,6 @@ sub handle_languages unless $depbase eq ''; $depbase .= '$(DEPDIR)/' . basename ($obj); - # Support for deansified files in subdirectories is ugly - # enough to deserve an explanation. - # - # A Note about normal ansi2knr processing first. On - # - # AUTOMAKE_OPTIONS = ansi2knr - # bin_PROGRAMS = foo - # foo_SOURCES = foo.c - # - # we generate rules similar to: - # - # foo: foo$U.o; link ... - # foo$U.o: foo$U.c; compile ... - # foo_.c: foo.c; ansi2knr ... - # - # this is fairly compact, and will call ansi2knr depending - # on the value of $U (`' or `_'). - # - # It's harder with subdir sources. On - # - # AUTOMAKE_OPTIONS = ansi2knr - # bin_PROGRAMS = foo - # foo_SOURCES = sub/foo.c - # - # we have to create foo_.c in the current directory. - # (Unless the user asks 'subdir-objects'.) This is important - # in case the same file (`foo.c') is compiled from other - # directories with different cpp options: foo_.c would - # be preprocessed for only one set of options if it were - # put in the subdirectory. - # - # Because foo$U.o must be built from either foo_.c or - # sub/foo.c we can't be as concise as in the first example. - # Instead we output - # - # foo: foo$U.o; link ... - # foo_.o: foo_.c; compile ... - # foo.o: sub/foo.c; compile ... - # foo_.c: foo.c; ansi2knr ... - # - # This is why we'll now transform $rule_file twice - # if we detect this case. - # A first time we output the compile rule with `$U' - # replaced by `_' and the source directory removed, - # and another time we simply remove `$U'. - # - # Note that at this point $source (as computed by - # &handle_single_transform) is `sub/foo$U.c'. - # This can be confusing: it can be used as-is when - # subdir-objects is set, otherwise you have to know - # it really means `foo_.c' or `sub/foo.c'. - my $objdir = dirname ($obj); - my $srcdir = dirname ($source); - if ($lang->ansi && $obj =~ /\$U/) - { - prog_error "`$obj' contains \$U, but `$source' doesn't" - if $source !~ /\$U/; - - (my $source_ = $source) =~ s/\$U/_/g; - # Output an additional rule if _.c and .c are not in - # the same directory. (_.c is always in $objdir.) - if ($objdir ne $srcdir) - { - (my $obj_ = $obj) =~ s/\$U/_/g; - (my $depbase_ = $depbase) =~ s/\$U/_/g; - $source_ = basename ($source_); - - $output_rules .= - file_contents ($rule_file, - new Automake::Location, - %transform, - GENERIC => 0, - - DEPBASE => $depbase_, - BASE => $obj_, - SOURCE => $source_, - SOURCEFLAG => $sourceflags{$srcext} || '', - OBJ => "$obj_$myext", - OBJOBJ => "$obj_.obj", - LTOBJ => "$obj_.lo", - - COMPILE => $obj_compile, - LTCOMPILE => $obj_ltcompile, - -o => $output_flag, - %file_transform); - $obj =~ s/\$U//g; - $depbase =~ s/\$U//g; - $source =~ s/\$U//g; - } - } - $output_rules .= file_contents ($rule_file, new Automake::Location, @@ -1770,7 +1656,7 @@ sub check_libobjs_sources # $VAR is the name of the variable that the source filenames come from # $TOPPARENT is the name of the _SOURCES variable which is being processed # $DERIVED is the name of resulting executable or library -# $OBJ is the object extension (e.g., `$U.lo') +# $OBJ is the object extension (e.g., `.lo') # $FILE the source file to transform # %TRANSFORM contains extras arguments to pass to file_contents # when producing explicit rules @@ -1782,7 +1668,6 @@ sub handle_single_transform ($$$$$%) my @files = ($_file); my @result = (); my $nonansi_obj = $obj; - $nonansi_obj =~ s/\$U//g; # Turn sources into objects. We use a while loop like this # because we might add to @files in the loop. @@ -1873,10 +1758,6 @@ sub handle_single_transform ($$$$$%) $this_obj_ext = $source_extension; $derived_source = 1; } - elsif ($lang->ansi) - { - $this_obj_ext = $obj; - } else { $this_obj_ext = $nonansi_obj; @@ -1968,12 +1849,6 @@ sub handle_single_transform ($$$$$%) $full_ansi = $base . $extension; } - if ($lang->ansi && option 'ansi2knr') - { - $full_ansi =~ s/$KNOWN_EXTENSIONS_PATTERN$/\$U$&/; - $obj_sans_ext .= '$U'; - } - my @specifics = ($full_ansi, $obj_sans_ext, # Only use $this_obj_ext in the derived # source case because in the other case we @@ -2573,38 +2448,6 @@ sub handle_compile () 'DISTRMS' => join ("\n", @dist_rms))); $output_vars .= $vars; $output_rules .= "$coms$rules"; - - # Check for automatic de-ANSI-fication. - if (option 'ansi2knr') - { - my ($ansi2knr_filename, $ansi2knr_where) = @{option 'ansi2knr'}; - my $ansi2knr_dir = ''; - - require_variables ($ansi2knr_where, "option `ansi2knr' is used", - TRUE, "ANSI2KNR", "U"); - - # topdir is where ansi2knr should be. - if ($ansi2knr_filename eq 'ansi2knr') - { - # Only require ansi2knr files if they should appear in - # this directory. - require_file ($ansi2knr_where, FOREIGN, - 'ansi2knr.c', 'ansi2knr.1'); - - # ansi2knr needs to be built before subdirs, so unshift it - # rather then pushing it. - unshift (@all, '$(ANSI2KNR)'); - } - else - { - $ansi2knr_dir = dirname ($ansi2knr_filename); - } - - $output_rules .= &file_contents ('ansi2knr', - new Automake::Location, - 'ANSI2KNR-DIR' => $ansi2knr_dir); - - } } # handle_libtool () @@ -5770,12 +5613,6 @@ sub lang_c_rewrite { my ($directory, $base, $ext, $nonansi_obj, $have_per_exec_flags, $var) = @_; - if (option 'ansi2knr' && $base =~ /_$/) - { - # FIXME: include line number in error. - err_am "C source file `$base.c' would be deleted by ansi2knr rules"; - } - my $r = LANG_PROCESS; if (option 'subdir-objects') { @@ -5793,16 +5630,6 @@ sub lang_c_rewrite uniq_part => 'AM_PROG_CC_C_O subdir') unless $seen_cc_c_o || $nonansi_obj eq '.lo'; } - - # In this case we already have the directory information, so - # don't add it again. - $de_ansi_files{$base} = ''; - } - else - { - $de_ansi_files{$base} = (($directory eq '.' || $directory eq '') - ? '' - : "$directory/"); } if (! $seen_cc_c_o @@ -5947,59 +5774,6 @@ sub lang_java_rewrite # language, etc. A finish function is only called if a source file of # the appropriate type has been seen. -sub lang_c_finish -{ - # Push all libobjs files onto de_ansi_files. We actually only - # push files which exist in the current directory, and which are - # genuine source files. - foreach my $file (keys %libsources) - { - if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file") - { - $de_ansi_files{$1} = '' - } - } - - if (option 'ansi2knr' && keys %de_ansi_files) - { - # Make all _.c files depend on their corresponding .c files. - my @objects; - foreach my $base (sort keys %de_ansi_files) - { - # Each _.c file must depend on ansi2knr; otherwise it - # might be used in a parallel build before it is built. - # We need to support files in the srcdir and in the build - # dir (because these files might be auto-generated. But - # we can't use $< -- some makes only define $< during a - # suffix rule. - my $ansfile = $de_ansi_files{$base} . $base . '.c'; - $output_rules .= ($base . "_.c: $ansfile \$(ANSI2KNR)\n\t" - . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) ' - . '`if test -f $(srcdir)/' . $ansfile - . '; then echo $(srcdir)/' . $ansfile - . '; else echo ' . $ansfile . '; fi` ' - . "| sed 's/^# \\([0-9]\\)/#line \\1/' " - . '| $(ANSI2KNR) > $@' - # If ansi2knr fails then we shouldn't - # create the _.c file - . " || rm -f \$\@\n"); - push (@objects, $base . '_.$(OBJEXT)'); - push (@objects, $base . '_.lo') - if var ('LIBTOOL'); - - # Explicitly clean the _.c files if they are in a - # subdirectory. (In the current directory they get erased - # by a `rm -f *_.c' rule.) - $clean_files{$base . '_.c'} = MOSTLY_CLEAN - if dirname ($base) ne '.'; - } - - # Make all _.o (and _.lo) files depend on ansi2knr. - # Use a sneaky little hack to make it print nicely. - &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)'); - } -} - sub lang_vala_finish_target ($$) { my ($self, $name) = @_; @@ -6309,8 +6083,6 @@ sub register_language (%) my (%option) = @_; # Set the defaults. - $option{'ansi'} = 0 - unless defined $option{'ansi'}; $option{'autodep'} = 'no' unless defined $option{'autodep'}; $option{'linker'} = '' diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm index 24d8be0..cd57877 100644 --- a/lib/Automake/Variable.pm +++ b/lib/Automake/Variable.pm @@ -156,7 +156,6 @@ my %_gen_varname_n = (); # Macros accessible via aclocal. my %_am_macro_for_var = ( - ANSI2KNR => 'AM_C_PROTOTYPES', CCAS => 'AM_PROG_AS', CCASFLAGS => 'AM_PROG_AS', EMACS => 'AM_PATH_LISPDIR', @@ -169,7 +168,6 @@ my %_am_macro_for_var = pyexecdir => 'AM_PATH_PYTHON', PYTHON => 'AM_PATH_PYTHON', pythondir => 'AM_PATH_PYTHON', - U => 'AM_C_PROTOTYPES', ); # Macros shipped with Autoconf. diff --git a/lib/Makefile.am b/lib/Makefile.am index 5bdc02e..f5e91c0 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2,8 +2,8 @@ ## Makefile for Automake lib. -# Copyright (C) 2001, 2003, 2004, 2009, 2010 Free Software Foundation, -# Inc. +# Copyright (C) 2001, 2003, 2004, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,8 +20,7 @@ SUBDIRS = Automake am -dist_pkgvdata_DATA = COPYING INSTALL texinfo.tex ansi2knr.c ansi2knr.1 \ - config-ml.in +dist_pkgvdata_DATA = COPYING INSTALL texinfo.tex config-ml.in ## These must all be executable when installed. However, if we use ## _SCRIPTS, then the program transform will be applied, which is not diff --git a/lib/Makefile.in b/lib/Makefile.in index 91e9bae..54de126 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -15,8 +15,8 @@ @SET_MAKE@ -# Copyright (C) 2001, 2003, 2004, 2009, 2010 Free Software Foundation, -# Inc. +# Copyright (C) 2001, 2003, 2004, 2009, 2010, 2011 Free Software +# Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -52,9 +52,9 @@ build_triplet = @build@ subdir = lib DIST_COMMON = $(dist_pkgvdata_DATA) $(dist_script_DATA) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in COPYING INSTALL \ - ansi2knr.1 ansi2knr.c ar-lib compile config.guess config.sub \ - depcomp elisp-comp install-sh mdate-sh missing mkinstalldirs \ - py-compile texinfo.tex ylwrap + ar-lib compile config.guess config.sub depcomp elisp-comp \ + install-sh mdate-sh missing mkinstalldirs py-compile \ + texinfo.tex ylwrap ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/amversion.m4 \ $(top_srcdir)/m4/auxdir.m4 $(top_srcdir)/m4/init.m4 \ @@ -236,9 +236,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = Automake am -dist_pkgvdata_DATA = COPYING INSTALL texinfo.tex ansi2knr.c ansi2knr.1 \ - config-ml.in - +dist_pkgvdata_DATA = COPYING INSTALL texinfo.tex config-ml.in scriptdir = $(pkgvdatadir) dist_script_DATA = config.guess config.sub install-sh mdate-sh missing \ mkinstalldirs elisp-comp ylwrap acinstall depcomp compile py-compile \ diff --git a/lib/am/Makefile.am b/lib/am/Makefile.am index a255f70..037a4ae 100644 --- a/lib/am/Makefile.am +++ b/lib/am/Makefile.am @@ -3,7 +3,7 @@ ## Makefile for Automake lib/am. # Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2003, 2004, 2008, -# 2009 Free Software Foundation, Inc. +# 2009, 2011 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,7 +21,6 @@ amdir = $(pkgvdatadir)/am dist_am_DATA = \ -ansi2knr.am \ check.am \ check2.am \ clean-hdr.am \ diff --git a/lib/am/Makefile.in b/lib/am/Makefile.in index 674d4bf..f31c27f 100644 --- a/lib/am/Makefile.in +++ b/lib/am/Makefile.in @@ -16,7 +16,7 @@ @SET_MAKE@ # Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001, 2003, 2004, 2008, -# 2009 Free Software Foundation, Inc. +# 2009, 2011 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -194,7 +194,6 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ amdir = $(pkgvdatadir)/am dist_am_DATA = \ -ansi2knr.am \ check.am \ check2.am \ clean-hdr.am \ diff --git a/lib/am/ansi2knr.am b/lib/am/ansi2knr.am deleted file mode 100644 index c4e1990..0000000 --- a/lib/am/ansi2knr.am +++ /dev/null @@ -1,77 +0,0 @@ -## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996, 1997, 2001, 2003, 2008, 2009 -## Free Software Foundation, Inc. - -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2, or (at your option) -## any later version. - -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. - -## You should have received a copy of the GNU General Public License -## along with this program. If not, see <http://www.gnu.org/licenses/>. - -## %ANSI2KNR-DIR% is the directory where ansi2knr is, `' if -## is the current directory. - - -## ---------- ## -## ansi2knr. ## -## ---------- ## - -if %?ANSI2KNR-DIR% - -ANSI2KNR = %ANSI2KNR-DIR%/ansi2knr -%ANSI2KNR-DIR%/ansi2knr: - $(am__cd) %ANSI2KNR-DIR% && $(MAKE) $(AM_MAKEFLAGS) ./ansi2knr -.MAKE: %ANSI2KNR-DIR%/ansi2knr - -else !%?ANSI2KNR-DIR% - -## Substitution from AM_C_PROTOTYPES. This makes it be built only when -## necessary. -ANSI2KNR = @ANSI2KNR@ -./ansi2knr: ansi2knr.$(OBJEXT) - $(LINK) ansi2knr.$(OBJEXT) $(LIBS) -ansi2knr.$(OBJEXT): $(CONFIG_HEADER) - -endif !%?ANSI2KNR-DIR% - - -## ------------------- ## -## Cleaning ansi2knr. ## -## ------------------- ## - - -if !%?ANSI2KNR-DIR% -.PHONY: clean-krextra - -clean-am: clean-krextra -clean-krextra: -## Why `clean' and not somewhere else? Not `mostlyclean' because -## people usually don't want to recompile this file. And not -## `distclean' because of our informal rule: if `make' built it, then -## `clean' should delete it; if `configure' built it, then `distclean' -## should remove it (and if the maintainer built it, then -## maintainer-clean should remove it). - -rm -f ansi2knr -endif !%?ANSI2KNR-DIR% - - - -## --------------------------------- ## -## Cleaning the output of ansi2knr. ## -## --------------------------------- ## - -.PHONY: mostlyclean-kr - -mostlyclean-am: mostlyclean-kr -mostlyclean-kr: -## Only delete *_.c when ansi2knr is actually in use, so as to avoid -## deleting sources that happen to end in "_" after being truncated on a DOS -## 8.3 filesystem with srcdir==builddir. - -test "$U" = "" || rm -f *_.c diff --git a/lib/ansi2knr.1 b/lib/ansi2knr.1 deleted file mode 100644 index f9ee5a6..0000000 --- a/lib/ansi2knr.1 +++ /dev/null @@ -1,36 +0,0 @@ -.TH ANSI2KNR 1 "19 Jan 1996" -.SH NAME -ansi2knr \- convert ANSI C to Kernighan & Ritchie C -.SH SYNOPSIS -.I ansi2knr -[--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 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). -.br - - 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 <gh...@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 <pin...@iro.umontreal.ca> and Jim Avera <j...@netcom.com>. diff --git a/lib/ansi2knr.c b/lib/ansi2knr.c deleted file mode 100644 index e84c210..0000000 --- a/lib/ansi2knr.c +++ /dev/null @@ -1,739 +0,0 @@ -/* Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved. */ - -/*$Id: ansi2knr.c,v 1.14 2003/09/06 05:36:56 eggert Exp $*/ -/* 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, -or, if there is no file named COPYLEFT, a file named COPYING. 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 [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]] - * --filename provides the file name for the #line directive in the output, - * overriding input_file (if present). - * If no input_file is supplied, input is read from stdin. - * 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, and with a left - * brace as the first token on the following line (ignoring possible - * intervening comments and/or preprocessor directives), except that a line - * consisting of only - * identifier1(identifier2) - * will not be considered a function definition unless identifier2 is - * the word "void", and a line consisting of - * identifier1(identifier2, <<arbitrary>>) - * will not be considered a function definition. - * ansi2knr will recognize a multi-line header provided that no intervening - * line ends with a left or right brace or a semicolon. These algorithms - * ignore whitespace, comments, and preprocessor directives, except that - * the function name must be the first thing on the line. The following - * constructs will confuse it: - * - Any other construct that starts at the left margin and - * follows the above syntax (such as a macro or function call). - * - Some macros that tinker with the syntax of function headers. - */ - -/* - * The original and principal author of ansi2knr is L. Peter Deutsch - * <gh...@aladdin.com>. Other authors are noted in the change history - * that follows (in reverse chronological order): - - lpd 2000-04-12 backs out Eggert's changes because of bugs: - - concatlits didn't declare the type of its bufend argument; - - concatlits didn't recognize when it was inside a comment; - - scanstring could scan backward past the beginning of the string; when - - the check for \ + newline in scanstring was unnecessary. - - 2000-03-05 Paul Eggert <egg...@twinsun.com> - - Add support for concatenated string literals. - * ansi2knr.c (concatlits): New decl. - (main): Invoke concatlits to concatenate string literals. - (scanstring): Handle backslash-newline correctly. Work with - character constants. Fix bug when scanning backwards through - backslash-quote. Check for unterminated strings. - (convert1): Parse character constants, too. - (appendline, concatlits): New functions. - * ansi2knr.1: Document this. - - lpd 1999-08-17 added code to allow preprocessor directives - wherever comments are allowed - lpd 1999-04-12 added minor fixes from Pavel Roskin - <pavel_ros...@geocities.com> for clean compilation with - gcc -W -Wall - lpd 1999-03-22 added hack to recognize lines consisting of - identifier1(identifier2, xxx) as *not* being procedures - lpd 1999-02-03 made indentation of preprocessor commands consistent - lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an - endless loop; quoted strings within an argument list - confused the parser - lpd 1999-01-24 added a check for write errors on the output, - suggested by Jim Meyering <meyer...@ascend.com> - lpd 1998-11-09 added further hack to recognize identifier(void) - as being a procedure - lpd 1998-10-23 added hack to recognize lines consisting of - identifier1(identifier2) as *not* being procedures - lpd 1997-12-08 made input_file optional; only closes input and/or - output file if not stdin or stdout respectively; prints - usage message on stderr rather than stdout; adds - --filename switch (changes suggested by - <ce...@lysator.liu.se>) - lpd 1996-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 1996-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 - <t...@sss.pgh.pa.us> - lpd 1995-06-22 removed #ifndefs whose sole purpose was to define - undefined preprocessor symbols as 0; changed all #ifdefs - for configuration symbols to #ifs - lpd 1995-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 1994-12-18 added conditionals for systems where ctype macros - don't handle 8-bit characters properly, suggested by - Francois Pinard <pin...@iro.umontreal.ca>; - removed --varargs switch (this is now the default) - lpd 1994-10-10 removed CONFIG_BROKETS conditional - lpd 1994-07-16 added some conditionals to help GNU `configure', - suggested by Francois Pinard <pin...@iro.umontreal.ca>; - properly erase prototype args in function parameters, - contributed by Jim Avera <j...@netcom.com>; - correct error in writeblanks (it shouldn't erase EOLs) - lpd 1989-xx-xx original version - */ - -/* Most of the conditionals here are to make ansi2knr work with */ -/* or without the GNU configure machinery. */ - -#if HAVE_CONFIG_H -# include <config.h> -#endif - -#include <stdio.h> -#include <ctype.h> - -#if 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 <string.h> -# else -# include <strings.h> -# endif - -#else /* not HAVE_CONFIG_H */ - -/* Otherwise do it the hard way */ - -# ifdef BSD -# include <strings.h> -# else -# ifdef VMS - extern int strlen(), strncmp(); -# else -# include <string.h> -# endif -# endif - -#endif /* not HAVE_CONFIG_H */ - -#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. - */ -# ifdef MSDOS -# include <malloc.h> -# else -# ifdef VMS - extern char *malloc(); - extern void free(); -# else - extern char *malloc(); - extern int free(); -# endif -# endif - -#endif - -/* Define NULL (for *very* old compilers). */ -#ifndef NULL -# define NULL (0) -#endif - -/* - * The ctype macros don't always handle 8-bit characters correctly. - * Compensate for this here. - */ -#ifdef isascii -# undef HAVE_ISASCII /* just in case */ -# define HAVE_ISASCII 1 -#else -#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 *ppdirforward(); -char *ppdirbackward(); -char *skipspace(); -char *scanstring(); -int writeblanks(); -int test1(); -int convert1(); - -/* The main program */ -int -main(argc, argv) - int argc; - char *argv[]; -{ FILE *in = stdin; - FILE *out = stdout; - char *filename = 0; - char *program_name = argv[0]; - char *output_name = 0; -#define bufsize 5000 /* arbitrary size */ - char *buf; - char *line; - char *more; - char *usage = - "Usage: ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]\n"; - /* - * 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; - int output_error; - - while ( argc > 1 && argv[1][0] == '-' ) { - if ( !strcmp(argv[1], "--varargs") ) { - convert_varargs = 1; - argc--; - argv++; - continue; - } - if ( !strcmp(argv[1], "--filename") && argc > 2 ) { - filename = argv[2]; - argc -= 2; - argv += 2; - continue; - } - fprintf(stderr, "%s: Unrecognized switch: %s\n", program_name, - argv[1]); - fprintf(stderr, usage); - exit(1); - } - switch ( argc ) - { - default: - fprintf(stderr, usage); - exit(0); - case 3: - output_name = argv[2]; - out = fopen(output_name, "w"); - if ( out == NULL ) { - fprintf(stderr, "%s: Cannot open output file %s\n", - program_name, output_name); - exit(1); - } - /* falls through */ - case 2: - in = fopen(argv[1], "r"); - if ( in == NULL ) { - fprintf(stderr, "%s: Cannot open input file %s\n", - program_name, argv[1]); - exit(1); - } - if ( filename == 0 ) - filename = argv[1]; - /* falls through */ - case 1: - break; - } - if ( filename ) - fprintf(out, "#line 1 \"%s\"\n", filename); - buf = malloc(bufsize); - if ( buf == NULL ) - { - fprintf(stderr, "Unable to allocate read buffer!\n"); - exit(1); - } - line = buf; - while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) - { -test: line += strlen(line); - switch ( test1(buf) ) - { - case 2: /* a function header */ - convert1(buf, out, 1, convert_varargs); - break; - case 1: /* a function */ - /* 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(ppdirforward(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 */ - if ( line != buf + (bufsize - 1) ) /* overflow check */ - continue; - /* falls through */ - default: /* not a function */ -wl: fputs(buf, out); - break; - } - line = buf; - } - if ( line != buf ) - fputs(buf, out); - free(buf); - if ( output_name ) { - output_error = ferror(out); - output_error |= fclose(out); - } else { /* out == stdout */ - fflush(out); - output_error = ferror(out); - } - if ( output_error ) { - fprintf(stderr, "%s: error writing to %s\n", program_name, - (output_name ? output_name : "stdout")); - exit(1); - } - if ( in != stdin ) - fclose(in); - return 0; -} - -/* - * Skip forward or backward over one or more preprocessor directives. - */ -char * -ppdirforward(p) - char *p; -{ - for (; *p == '#'; ++p) { - for (; *p != '\r' && *p != '\n'; ++p) - if (*p == 0) - return p; - if (*p == '\r' && p[1] == '\n') - ++p; - } - return p; -} -char * -ppdirbackward(p, limit) - char *p; - char *limit; -{ - char *np = p; - - for (;; p = --np) { - if (*np == '\n' && np[-1] == '\r') - --np; - for (; np > limit && np[-1] != '\r' && np[-1] != '\n'; --np) - if (np[-1] == 0) - return np; - if (*np != '#') - return p; - } -} - -/* - * Skip over whitespace, comments, and preprocessor directives, - * in either direction. - */ -char * -skipspace(p, dir) - char *p; - int dir; /* 1 for forward, -1 for backward */ -{ - for ( ; ; ) { - while ( is_space(*p) ) - p += dir; - if ( !(*p == '/' && p[dir] == '*') ) - break; - p += dir; p += dir; - while ( !(*p == '*' && p[dir] == '/') ) { - if ( *p == 0 ) - return p; /* multi-line comment?? */ - p += dir; - } - p += dir; p += dir; - } - return p; -} - -/* Scan over a quoted string, in either direction. */ -char * -scanstring(p, dir) - char *p; - int dir; -{ - for (p += dir; ; p += dir) - if (*p == '"' && p[-dir] != '\\') - return p + dir; -} - -/* - * Write blanks over part of a string. - * Don't overwrite end-of-line characters. - */ -int -writeblanks(start, end) - char *start; - char *end; -{ char *p; - for ( p = start; p < end; p++ ) - if ( *p != '\r' && *p != '\n' ) - *p = ' '; - return 0; -} - -/* - * 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; -{ char *p = buf; - char *bend; - char *endfn; - int contin; - - if ( !isidfirstchar(*p) ) - return 0; /* no name at left margin */ - bend = skipspace(ppdirbackward(buf + strlen(buf) - 1, buf), -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; - unsigned len = endfn - buf; - - while ( (kp = *key) != 0 ) - { if ( strlen(kp) == len && !strncmp(kp, buf, len) ) - return 0; /* name is a keyword */ - key++; - } - } - { - char *id = p; - int len; - /* - * Check for identifier1(identifier2) and not - * identifier1(void), or identifier1(identifier2, xxxx). - */ - - while ( isidchar(*p) ) - p++; - len = p - id; - p = skipspace(p, 1); - if (*p == ',' || - (*p == ')' && (len != 4 || strncmp(id, "void", 4))) - ) - return 0; /* not a function */ - } - /* - * If the last significant character was a ), we need to count - * parentheses, because it might be part of a formal parameter - * that is a procedure. - */ - if (contin > 0) { - int level = 0; - - for (p = skipspace(buf, 1); *p; p = skipspace(p + 1, 1)) - level += (*p == '(' ? 1 : *p == ')' ? -1 : 0); - if (level > 0) - contin = -1; - } - 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; - 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++) != '('; ) - ; -top: p = endfn; - breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); - if ( breaks == NULL ) - { /* 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 = NULL; - 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 '/': - if (p[1] == '*') - p = skipspace(p, 1) - 1; - break; - case '"': - p = scanstring(p, 1) - 1; - break; - default: - ; - } - } - /* Erase any embedded prototype parameters. */ - if ( lp && rp ) - 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 '/': - if (p > buf && p[-1] == '*') - p = skipspace(p, -1) + 1; - break; - case '"': - p = scanstring(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/m4/depout.m4 b/m4/depout.m4 index 80a3926..3e046cd 100644 --- a/m4/depout.m4 +++ b/m4/depout.m4 @@ -44,15 +44,13 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` -- 1.7.2.3