Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: comp.lang.c Subject: Re: Null source transformer for C Message-ID: <613@hadron.UUCP> Date: Wed, 12-Nov-86 23:40:56 EST Article-I.D.: hadron.613 Posted: Wed Nov 12 23:40:56 1986 Date-Received: Thu, 13-Nov-86 04:00:22 EST References: <5058@brl-smoke.ARPA> <1105@cit-vax.Caltech.Edu> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 26 Summary: An alternative way (for diffs) In article <1105@cit-vax.Caltech.Edu> jon@cit-vax.UUCP (Jon Leech) writes: >In article <5058@brl-smoke.ARPA> jrv@MITRE-BEDFORD.ARPA (James R. Van Zandt) writes: >>Several times I've wanted to make a change to some C source code that >>would be minor, but requires parsing it. Some examples are: > Another example that I badly needed recently is a 'diff'-like program >driven by syntax rather than text; I had two divergent versions of a large >program with differing indentations, preprocessor usage, etc. ... What I did at one point, after a round of 'style wars' had badly trashed some otherwise good pieces of code, was to write into the 'compare' program some language-specific routines that recognised general C and assembler constructs (assuming file.[csh] was right), and transformed the files such that: all white space became a single space (trailing WS stripped); all '{'s and '}'s put on single lines, indented or not semicolons not in strings or comments introduced new lines no blank lines. Terrible format to read, but a common, comparable format. It got the job done, and was lots easier to write than a general parser. Unfortunately, it's on an 800 bpi tape that I can't read right now. But, you should be able to do this at home with some simple equipment [;-)]. Just remember to match "" '' /**/. -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP} jsdy@hadron.COM (not yet domainised)