summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-06-25 17:05:56 +0000
committerJim Meyering <jim@meyering.net>1997-06-25 17:05:56 +0000
commitf657d65570c7389f9c60e2ff9d850206e5ce3b57 (patch)
treec894d57bde8fe8ecc5cd43d86d548144834639a9
parent9bcfe15afebe3a8be6fd7f2417b34abc22ea9d17 (diff)
downloadcoreutils-f657d65570c7389f9c60e2ff9d850206e5ce3b57.tar.gz
update from automake-1.2SH-UTILS-1_16a
-rw-r--r--src/ansi2knr.127
-rw-r--r--src/ansi2knr.c36
2 files changed, 42 insertions, 21 deletions
diff --git a/src/ansi2knr.1 b/src/ansi2knr.1
index 434ce8f04..f9ee5a631 100644
--- a/src/ansi2knr.1
+++ b/src/ansi2knr.1
@@ -1,19 +1,36 @@
-.TH ANSI2KNR 1 "31 December 1990"
+.TH ANSI2KNR 1 "19 Jan 1996"
.SH NAME
ansi2knr \- convert ANSI C to Kernighan & Ritchie C
.SH SYNOPSIS
.I ansi2knr
-input_file output_file
+[--varargs] input_file [output_file]
.SH DESCRIPTION
If no output_file is supplied, output goes to stdout.
.br
There are no error messages.
.sp
.I ansi2knr
-recognizes functions by seeing a non-keyword identifier at the left margin, followed by a left parenthesis, with a right parenthesis as the last character on the line. It will recognize a multi-line header if the last character on each line but the last is a left parenthesis or comma. These algorithms ignore whitespace and comments, except that the function name must be the first thing on the line.
+recognizes function definitions by seeing a non-keyword identifier at the left
+margin, followed by a left parenthesis, with a right parenthesis as the last
+character on the line, and with a left brace as the first token on the
+following line (ignoring possible intervening comments). It will recognize a
+multi-line header provided that no intervening line ends with a left or right
+brace or a semicolon. These algorithms ignore whitespace and comments, except
+that the function name must be the first thing on the line.
.sp
The following constructs will confuse it:
.br
- - Any other construct that starts at the left margin and follows the above syntax (such as a macro or function call).
+ - Any other construct that starts at the left margin and follows the
+above syntax (such as a macro or function call).
.br
- - Macros that tinker with the syntax of the function header.
+ - Some macros that tinker with the syntax of the function header.
+.sp
+The --varargs switch is obsolete, and is recognized only for
+backwards compatibility. The present version of
+.I ansi2knr
+will always attempt to convert a ... argument to va_alist and va_dcl.
+.SH AUTHOR
+L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and
+continues to maintain the current version; most of the code in the current
+version is his work. ansi2knr also includes contributions by Francois
+Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>.
diff --git a/src/ansi2knr.c b/src/ansi2knr.c
index 8731f6ddd..c6ee83309 100644
--- a/src/ansi2knr.c
+++ b/src/ansi2knr.c
@@ -140,14 +140,14 @@ program under the GPL.
* Compensate for this here.
*/
#ifdef isascii
-# undef HAVE_ISASCII /* just in case */
-# define HAVE_ISASCII 1
+# undef HAVE_ISASCII /* just in case */
+# define HAVE_ISASCII 1
#else
#endif
#if STDC_HEADERS || !HAVE_ISASCII
-# define is_ascii(c) 1
+# define is_ascii(c) 1
#else
-# define is_ascii(c) isascii(c)
+# define is_ascii(c) isascii(c)
#endif
#define is_space(c) (is_ascii(c) && isspace(c))
@@ -195,26 +195,30 @@ main(argc, argv)
exit(1);
}
}
- switch ( argc )
+ if (argc < 2 || argc > 3)
{
- 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]);
+ {
+ fprintf(stderr, "Cannot open input file %s\n", argv[1]);
exit(1);
}
+ if (argc == 3)
+ {
+ out = fopen(argv[2], "w");
+ if ( out == NULL )
+ {
+ fprintf(stderr, "Cannot open output file %s\n", argv[2]);
+ exit(1);
+ }
+ }
+ else
+ {
+ out = stdout;
+ }
fprintf(out, "#line 1 \"%s\"\n", argv[1]);
buf = malloc(bufsize);
line = buf;