Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site zeppo.UUCP Path: utzoo!linus!decvax!harpo!zeppo!raj From: raj@zeppo.UUCP (Richard A. Johnson) Newsgroups: net.sources Subject: Re: another version of cpr Message-ID: <542@zeppo.UUCP> Date: Thu, 25-Aug-83 21:54:50 EDT Article-I.D.: zeppo.542 Posted: Thu Aug 25 21:54:50 1983 Date-Received: Sat, 27-Aug-83 15:20:11 EDT References: <128@ccieng5.UUCP> Organization: Bell Labs, Whippany Lines: 39 I tried the cpr (C print) program and noticed two problems. First, and mentioned in the manual page, structure declarations are treated like functions (i.e., given extra white space after the '}'). Second, tabs are always converted to exactly 8 spaces (this is annoying if you use tabs to line up columns). I fixed the first problem by looking for a ';' after the '}' (most structure declarations that I have seen end with "};" whereas functions just end with '}'). If there is a ';' there, the '}' is treated like any other character. If not, then it is a function and given extra white space. I fixed the second problem by substituting one space for the tab. Then I add more spaces, if necessary, until the next character position is a tab stop. My fixes to cpr.c follow: 273c273,276 < bp = 1; --- > if( *(l+1) == ';' ) > ++l; > else > bp = 1; 613c616,617 < * of the tab character with 8 (eight) spaces. The function returns --- > * of the tab character with enough spaces to put the next character > * at the next tab stop. The function returns 633,634c637,639 < strcpy(&retstr[count], " "); < count += 7; --- > retstr[count] = ' '; > while (((count + 1) % 8) != 0) > retstr[++count] = ' '; Rich Johnson BTL - Whippany zeppo!raj