/* 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,
* and with a left brace as the first token on the following line
* (ignoring possible intervening comments).
* It will recognize a multi-line header provided that no intervening
* line ends with a left or right brace or a semicolon.
* These algorithms ignore whitespace and comments, except that
* the function name must be the first thing on the line.
* The following constructs will confuse it:
* - Any other construct that starts at the left margin and
* follows the above syntax (such as a macro or function call).
* - Some macros that tinker with the syntax of the function header.
*/
/*
* The original and principal author of ansi2knr is L. Peter Deutsch
* <ghost@aladdin.com>. Other authors are noted in the change history
* that follows (in reverse chronological order):
lpd 96-01-21 added code to cope with not HAVE_CONFIG_H and with
compilers that don't understand void, as suggested by
Tom Lane
lpd 96-01-15 changed to require that the first non-comment token
on the line following a function header be a left brace,
to reduce sensitivity to macros, as suggested by Tom Lane
<tgl@sss.pgh.pa.us>
lpd 95-06-22 removed #ifndefs whose sole purpose was to define
undefined preprocessor symbols as 0; changed all #ifdefs
for configuration symbols to #ifs
lpd 95-04-05 changed copyright notice to make it clear that
including ansi2knr in a program does not bring the entire
program under the GPL
lpd 94-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 94-10-10 removed CONFIG_BROKETS conditional
lpd 94-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 89-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, *out;
#define bufsize 5000 /* arbitrary size */
char *buf;
char *line;
char *more;
/*
* In previous versions, ansi2knr recognized a --varargs switch.
* If this switch was supplied, ansi2knr would attempt to convert
* 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);
}
}
if (argc < 2 || argc > 3)
{
printf("Usage: ansi2knr input_file [output_file]\n");
exit(1);
}
in = fopen(argv[1], "r");
if ( in == NULL )
{
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;
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(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;
}
i
没有合适的资源?快使用搜索试试~ 我知道了~
automake-1.2.tar.gz
需积分: 5 0 下载量 72 浏览量
2024-01-30
00:34:07
上传
评论
收藏 281KB GZ 举报
温馨提示
共219个文件
test:124个
am:39个
m4:21个
Automake 是一个广泛使用的工具,它是 GNU 自动化构建系统的一部分,用于生成符合 GNU 标准的 Makefile 文件。这种工具对于简化和标准化复杂软件构建过程非常有用,尤其是在处理跨平台兼容性时。开发者和系统管理员可以下载这个文件,解压并编译其源代码,从而在他们的系统上安装或升级 Automake。使用 Automake,开发者可以更轻松地创建复杂的、跨平台的构建脚本,特别是当与 Autoconf 和 Libtool 等其他 GNU 构建工具结合使用时。Automake 的目标是减少手动编写 Makefile 的需要,自动化构建过程,并确保构建脚本的一致性和可移植性。
资源推荐
资源详情
资源评论
收起资源包目录
automake-1.2.tar.gz (219个子文件)
ansi2knr.1 1KB
acinstall 886B
texinfos.am 7KB
Makefile.am 4KB
subdirs.am 3KB
scripts.am 2KB
depend.am 2KB
header-vars.am 2KB
libs.am 2KB
program.am 2KB
progs.am 2KB
Makefile.am 2KB
dejagnu.am 2KB
texi-vers.am 2KB
ltlib.am 2KB
lisp.am 1KB
clean.am 1KB
data.am 1KB
remake-hdr.am 1KB
tags.am 1KB
header.am 1KB
kr-extra.am 1KB
tags-clean.am 1KB
remake.am 1KB
libtool.am 1KB
progs-clean.am 1KB
depend2.am 1KB
compile.am 1024B
dist-vars.am 1000B
ltlib-clean.am 984B
libs-clean.am 984B
ltlibrary.am 979B
library.am 976B
footer.am 958B
comp-vars.am 923B
lisp-clean.am 918B
clean-hdr.am 903B
clean-kr.am 896B
data-clean.am 871B
mans-vars.am 828B
Makefile.am 391B
AUTHORS 171B
ansi2knr.c 14KB
ChangeLog 137KB
ChangeLog 11KB
configure 37KB
COPYING 18KB
defs 1KB
elisp-comp 2KB
config.guess 21KB
automake.in 159KB
Makefile.in 18KB
aclocal.in 9KB
Makefile.in 6KB
Makefile.in 5KB
configure.in 617B
automake.info 2KB
automake.info-1 48KB
automake.info-2 46KB
INSTALL 8KB
install-sh 5KB
aclocal.m4 3KB
ccstdc.m4 2KB
strtod.m4 2KB
mktime.m4 2KB
regex.m4 1KB
init.m4 1KB
lispdir.m4 1KB
header.m4 856B
winsz.m4 850B
sanity.m4 842B
cygwin.m4 717B
missing.m4 697B
maintainer.m4 637B
dmalloc.m4 581B
protos.m4 557B
install.m4 486B
error.m4 425B
obstack.m4 406B
termios.m4 358B
ptrdiff.m4 325B
cond.m4 162B
mdate-sh 3KB
missing 5KB
mkinstalldirs 732B
NEWS 5KB
README 1KB
stamp-vti 60B
config.sub 19KB
depend2.test 2KB
installsh.test 766B
empty.test 685B
exsource.test 638B
depend.test 611B
man.test 607B
confsub.test 600B
subdir2.test 563B
vtexi.test 551B
extra.test 523B
ldadd.test 519B
共 219 条
- 1
- 2
- 3
资源评论
程序员Chino的日记
- 粉丝: 2936
- 资源: 4万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 3-1same.cbp
- tudou-android-release (2).apk
- 三维重建-基于NeRF实现的稳定+实时3D说话人脸生成-附项目源码-优质项目实战.zip
- oracle-10g-32bit.zip
- com.aesq.zb_v1.0.35_danji100.com.apk
- 760996331259605建立门派1.360.apk
- 下面提供一些C语言的入门示例代码,并附有注释,以帮助理解每个部分的功能 1. Hello World程序 #include
- 下面提供一些C语言的入门示例代码,并附有注释,以帮助理解每个部分的功能 1. Hello World程序 #include
- 下面提供一些C语言的入门示例代码,并附有注释,以帮助理解每个部分的功能 1. Hello World程序 #include
- C语言是一种广泛使用的计算机编程语言,它是许多其他编程语言的基础 以下是一些C语言入门的例子和代码,适合初学者学习和实践
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功