Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!mordor!sri-spam!sri-unix!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Power proposal for ANSI C Message-ID: <547@cresswell.quintus.UUCP> Date: 18 Jan 88 05:23:39 GMT References: <38384@sun.uucp> <3573@sdcc6.ucsd.EDU> <434@drilex.UUCP> Organization: Quintus Computer Systems, Mountain View, CA Lines: 29 Summary: tip In article <434@drilex.UUCP>, dricej@drilex.UUCP (Craig Jackson) writes: > > a = b/*c; > > My friend spent two days looking for that one... When I've spent more than a few minutes on such a problem I use 'cc -E foo.c | cb' or 'cc -E foo.c | indent' depending on which system I'm on to see exactly what the preprocessor has done with it. This strips out comments too, which is why it's a good dodge for this kind of problem. (Couldn't happen in BCPL...) On UNIX, it's a good idea to have a little script around: #!/bin/sh #NAME badcom #SYNOPSIS badcom foobaz.c #DESCRIPTION Finds (some) suspicious comment lines, namely # lines where /* occurs, is not the first thing # on its line, and hasn't got */ on the same line, # also lines where */ occurs, is not the last # thing on the line, and hasn't got /* on the # same line #OPTIONS none #BUGS Doesn't know about ".." or #if 0 # Misses other kinds of comment error egrep -n -e '[^ \t].*/\*|\*/.*[^ \t]' $1 | \ egrep -v -e '/\*.*\*/' {When entering this script, replace \t by actual TAB characters.}