/* Copyright (C) 1989, 1997, 1998 Aladdin Enterprises. All rights reserved. */
/*$Id: 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,
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), except that a line
* consisting of only
* identifier1(identifier2)
* will not be considered a function definition unless identifier2 is
* the word "void". 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 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).
* - 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 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
<ceder@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
<tgl@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 <pinard@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 <pinard@iro.umontreal.ca>;
properly erase prototype args in function parameters,
contributed by Jim Avera <jima@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
/*
* 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 *skipspace();
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;
#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;
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, "Unrecognized switch: %s\n", argv[1]);
fprintf(stderr, usage);
exit(1);
}
switch ( argc )
{
default:
fprintf(stderr, usage);
exit(0);
case 3:
out = fopen(argv[2], "w");
if ( out == NULL ) {
fprintf(stderr, "Cannot open output file %s\n", argv[2]);
exit(1);
}
/* falls through */
case 2:
in = fopen(argv[1], "r");
if ( in == NULL ) {
fprintf(stderr, "Cannot open input file %s\n", argv[1]);
exit(1);
}
if ( filename == 0 )
filename = argv[1];
/* falls through */
case 1:
break;
}
if ( filename )
fprintf(out, "#line 1 \"%s\"\n", filename);
没有合适的资源?快使用搜索试试~ 我知道了~
automake-1.4-p1.tar.gz
需积分: 5 0 下载量 39 浏览量
2024-01-30
00:34:09
上传
评论
收藏 358KB GZ 举报
温馨提示
Automake 是一个广泛使用的工具,它是 GNU 自动化构建系统的一部分,用于生成符合 GNU 标准的 Makefile 文件。这种工具对于简化和标准化复杂软件构建过程非常有用,尤其是在处理跨平台兼容性时。开发者和系统管理员可以下载这个文件,解压并编译其源代码,从而在他们的系统上安装或升级 Automake。使用 Automake,开发者可以更轻松地创建复杂的、跨平台的构建脚本,特别是当与 Autoconf 和 Libtool 等其他 GNU 构建工具结合使用时。Automake 的目标是减少手动编写 Makefile 的需要,自动化构建过程,并确保构建脚本的一致性和可移植性。
资源推荐
资源详情
资源评论
收起资源包目录
automake-1.4-p1.tar.gz (294个子文件)
ansi2knr.1 1KB
acinstall 886B
texinfos.am 9KB
Makefile.am 5KB
subdirs.am 3KB
depend2.am 3KB
Makefile.am 3KB
mans.am 2KB
scripts.am 2KB
header-vars.am 2KB
libs.am 2KB
remake-hdr.am 2KB
tags.am 2KB
dejagnu.am 2KB
progs.am 2KB
ltlib.am 2KB
lisp.am 2KB
texi-vers.am 2KB
multilib.am 2KB
data.am 1KB
header.am 1KB
clean.am 1KB
depend.am 1KB
java.am 1KB
libtool.am 1KB
compile.am 1KB
kr-extra.am 1KB
program.am 1KB
tags-clean.am 1KB
remake.am 1KB
dist-vars.am 1000B
ltlib-clean.am 985B
progs-clean.am 985B
libs-clean.am 985B
ltlibrary.am 979B
library.am 977B
footer.am 958B
comp-vars.am 929B
java-clean.am 924B
lisp-clean.am 919B
clean-hdr.am 904B
clean-kr.am 897B
data-clean.am 871B
mans-vars.am 828B
Makefile.am 386B
AUTHORS 171B
ansi2knr.c 16KB
ChangeLog 189KB
ChangeLog 20KB
configure 37KB
COPYING 18KB
defs 1KB
elisp-comp 2KB
config.guess 38KB
automake.in 192KB
Makefile.in 20KB
aclocal.in 10KB
Makefile.in 7KB
Makefile.in 5KB
configure.in 620B
automake.info 3KB
automake.info-1 49KB
automake.info-2 48KB
automake.info-3 32KB
INSTALL 8KB
install-sh 5KB
mktime.m4 4KB
aclocal.m4 3KB
ccstdc.m4 3KB
strtod.m4 2KB
regex.m4 1KB
sanity.m4 1KB
multi.m4 1KB
lispdir.m4 1KB
init.m4 1KB
winsz.m4 911B
header.m4 856B
missing.m4 697B
maintainer.m4 652B
dmalloc.m4 651B
protos.m4 630B
obstack.m4 443B
error.m4 425B
ptrdiff.m4 365B
termios.m4 358B
lex.m4 351B
cond.m4 162B
mdate-sh 3KB
missing 6KB
mkinstalldirs 722B
NEWS 7KB
README 1KB
stamp-vti 68B
config.sub 27KB
depend2.test 2KB
flibs.test 1KB
fonly.test 1KB
colon3.test 962B
ansi3.test 831B
depend3.test 792B
共 294 条
- 1
- 2
- 3
资源评论
程序员Chino的日记
- 粉丝: 3644
- 资源: 5万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功