Path: utzoo!yunexus!spectrix!clewis From: clewis@spectrix.UUCP (Chris R. Lewis) Newsgroups: comp.unix.questions Subject: Re: I need to create ANSI C function prototypes. Message-ID: <445@spectrix.UUCP> Date: 12 Feb 88 22:47:22 GMT Article-I.D.: spectrix.445 Posted: Fri Feb 12 17:47:22 1988 References: <201@fxgrp.UUCP> <2273@cognos.UUCP> Reply-To: clewis@spectrix.UUCP (Chris R. Lewis) Organization: Spectrix Microsystems Inc., Toronto, Ontario, Canada Lines: 38 In article <2273@cognos.UUCP> brianc@cognos.UUCP (Brian Campbell) writes: >In article <201@fxgrp.UUCP> fxgrp!ljz@ames.arpa (Lloyd Zusman) writes: >! I'm looking for a program that will take old-fashioned C code and >! produce ANSI C function prototypes. >! ... >! This program would produce something similar to the following: >! >! char *foo(char *a, int b, int c); This is probably not to hard to do with awk. Swallow a whole function definition until the leading brace and then rewrite it. With YACC (this will probably work much better): find a yacc grammar for C. In the parameter declaration portion, insert actions to reformat the text and spit it out. Don't emit anything else. >I tried to do this once before. I failed. I wanted to have lint >create a lint-library for each source file, but lint libraries are not >particularly readable (they're not textual). An easy hack: Take the lint shell file. Make a copy. Modify it so that it saves the output of the "lint1" pass. Delete the lint2 pass. Run it on the sources you want to have lint libraries for. Viola! The stuff you saved is the lint library. Only one idiosyncrasy: if any of the library routines have lint errors, you'll see these lint errors on every invocation lint you use these new lint libraries on. And, I expect that the libraries would be bigger than they could be. Or, use my first suggestion, except that you'll have to emit the function declaration in the order it comes in (rather than make it look like ANSI) plus replace the body with: { return(); } -- Chris Lewis, Spectrix Microsystems Inc, UUCP: {uunet!mnetor, utcsri!utzoo, lsuc, yunexus}!spectrix!clewis Phone: (416)-474-1955