CB COM'CB DOC9CB MAN*K͞+AAL'+FÎr ͖ 8{ Ăy0w#w#w^#V#*~#fo^#*~#fo^#V#*n^#*n^#V# ~#fo^#& ~#fo!+!#!+!#!+!+}|z{|}|z7||7zZZ)|/g}/o#|͉k|/g}/o#ɯ2qZZk:q|/g}/o#|/g}/o#:q<2qqDM!xxGyO҃)v|͔`i|)Öxڷz/W{/_ѯzW{_=yOxGæ2qZZ͉M|}ȯ|g}o)|/g}/o#z/W{/_!9~#fo! ! ! ! ! ! !9~#A"s!`*"!"!Y">2>2>22!"!"!@"!" ʞ!F#x±~#±!b2r~# "2r+}|~#G:rx"2r+w# +6#!6#2w2x*s!>r<o&F=-` r'~h6!+`W?_!~7z?` :>ª@w#.¶ww#E*>?w#> w#.7:77!a{   `OE!y6$ -7rBo&))T])))!yW%@d&P V$!9DM!%`is#r* w#w* 6#6!%* s#r* 6#6* s#r* s* s* s* w#w* s#r* s#r! ~#foDà ! ^#Vr+sz[ ! ^#Vr+s~#fo`is#r`i~#fon}- `i^#Vr+sn} `i~#fon&5>e¢>>p®>ʋ >nº>ʢ >s>ʭ >t> >v> `i^#Vr+sn} `i~#fon&5>z >z >e >ʅ >## >ʑ >l/ >ʮ >a; > >rG > >bS > >c_ >" >ik >? >sw >\ y * w#w* 6#6* ~#fo|g}os#r| * ~#fo|g}os#r| * ~#fo|g}os#r| * ~#fo|g}os#r| * ~#fo|g}os#r| * ~#fo@|g}os#r| * ~#fo|g}os#r| * ~#fo |g}os#r| à `i^#Vr+s * 6#6* 4 * 4 `i^#Vr+sn&* s#r `i^#Vr+sn&* s#r * 4 à xX * ~#fo|X ! ~#fo|X ! ~#fo~#fon}X ! ~#fo* s#r! ~#fo* s#rD* ~#foڃ * ~#fok !%65!%65!&65!3&65!d&65!&65!&65! '65!C'65!x'65!'65!'65!(65!B(65!d(65!(65!(65!(65!(65!)65!")65!M)65!|)65!)65!)65!)65!*65!C*65!>* ~#fo| * ~#fo~#fo* s#r** ~#fo~#fo[5#| * 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#fo|Š!rÂUnmatched #elser3y!* ~#fo+* s#r* ~#fo k* * s#r* ~#fo~#fo* s#r* ~#fo##~#fo* s#r* ~#fo~#fo* s#r* ~#fo~#fo* s#r* ~#fo~#fo* s* ~#fo)* * ~#fo ~#fos#r!! Ú endif* ~#fo1| * ~#fo| ! Unmatched #endifr3 * ^#Vr+s* s#r!y!* ~#fo|g}o|y!Z/* ~#fo!#Y4* w#wͰ/* ~#fo!Q!U!%s * ~#fo͛5* w#w+g* n&|g}os* ~#fon}ʲ!* ^#Vr+sÐ!* ~#fon}\!g* 6+y!!%* ~#fo* s#r* ^#Vr+sn}\"* ^#Vr+s* ~#fon}H"* ^#Vr+sn}'E"H""* ~#fon}'ʃ"!`"{"Illegal Character Constantr3Ñ"* ^#Vr+sg* ^#Vr+s* ~#fon}"* ~#fon}""* ^#Vr+sâ"* ~#fon}""%* ~#fon}\!#!##Illegal Stringr3+g* n&|g}os+â"* ~#fon}/#* ~#fo#n}*#* ~#fo*œ#* 4* n&|g}os* ^#Vr+szʾ#* ^#Vr+s* ~#fo##s#r#* ~#fo|#%* ~#fon}*G$* ~#fo#n}/G$* ^#Vr+s* ^#Vr+sz9$* 6%* ^#Vr+s* ~#fon} %* n}ʐ$* n&|g}os** s#r+* ~#fon}*$* ~#fon} $* ~#fo*$* ^#Vr+s* n}%* n&|g}os%* ^#Vr+s>#%* ~#fon&$6}N%* ~#fon&U6}ʒ%* ~#fon&$6}~%* ~#fon&U6}ʏ%* ^#Vr+sN%à%* ^#Vr+sg!9~|:Copyright CDI 1981 All Rights Reservedstdincb 10-3-81 CB - a C program Beautifier By Chuck Forsberg, Computer Development Inc 6700 S.W. 105th Beaverton OR 97005 503/646-1599 Send Comments/Bug-reports via RCP/M 503/621-3193 Copyright 1981 Computer Development INC. All rights Reserved. The BDS C relocatable file 'CB.CRL' is hereby placed in the public domain by its author. This file must be linked by the BDS C linker to produce an executable program. This program may not be distributed in any other form without written permission from the above. Usage: cb [-e{ze#labric}] [-pnsMtMv] infile [outfile] where: -e{option} affects editing: l Break line before left brace a Break line after left brace r Break line after right brace b Break line before right brace c Break line at cases i Break line after do,if, etc. # Indenet nested #if...'s z No line breaks or indentented #if..'s e All of the above (`ala Kernighan/Ritchie) -p Output to LST: device -n Number source lines -sM Indentation shift width is 1<=M<=9 (Default 8) -tM Assume Hardware tab width is 1<=M<=9 (Default 8) -v Verbose More v's are more verbose [outfile] write ouput to outfile Can't open %s Output file existsCan't create %s casechardefaultdodoubleelseifexternforfloatifintlongregisterstructswitchshort* ~#fo* s#r+!9DM* ~#fo|,Z/* n&|g}o|J+Ͱ/* ~#fo* ~#foҐ+* ~#fo* ^#Vr+sn&Y4J+!/* ~#fo͛5* n&,* ~#fon&* ~#fo* n&* n&* ~#fo* ~#fo* ~#fo* n&* ~#fo* ~#fo* ~#fo!/* ~#fo͛5!9`i6#6`i~#fo* ~#foڮ,`i~#fo)* ~#fo!O/* ~#fo͛5`i^#Vr+s],!T/* ~#fo͛5* ~#fo|,* ~#fon}g-}0#|E-* n&-!V/65* ~#fo!Y4* ~#fö́6* ~#fo7!>* ^#Vr+s** s#r* ~#fon} ʋ-* ~#fon} œ-* ^#Vr+sg-* n&s* ~#fo)* ~#fo|g}o|-* ~#fo+-* ~#fo* s#r* s* s* ~#fo|-.* w#w* n&|g}o|O.*Z.* ~#fo* s#r* n}ͣʿ.* ~#fo|ͣ.* ~#fo*ͣʿ.* ~#fon} ͝.* ~#fo|ͣ.* ~#fo|ͣ* s#r* s#r* s#r!9 ol%d l%d ob%d =%d {%d (%d [%d #%d nl%d c%d *pos%oLevels: %d EOF* n}j/* ~#fo|ʀ/!*Ã/! * ~#fo!/* ~#fo͛5%4u%c !9DM* ~#fo* ~#fo?`is#r`i~#fo* ~#fo* ~#fo|ͣ! s#r`i~#fo* ~#fo`is#r`i^#Vr+szL0* ~#fo! Y4&0! ^#Vr+szt0* ~#fo! Y4L0!9!9DM** s#r! 6#6! ^#Vr+s!ҋ1* ~#fo7`is#r> 0>0>0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~#fo}?`9!͐##6#6͐͐s#r͐^#Vr+s! ns&!9DM! n&Aͯ9! n&Zͯ!i9DM! ^#Vr+s~#fo! s#r͐! s#r! ^#Vr+sn`is{<`in}%{:!! s#r! ^#Vr+sn`is{.:! j>! s#r! 4! ^#Vr+sn`is`in&>}D:U+;X4;O=;Cʃ;Sʴ;<͐~#fo|+;! ^#Vr+s6-͐͐~#fos#r! ^#Vr+s! 6 C;! 6C;! 6! ~#fo! n&! ^#Vr+s~#fo! =ѯgs#r,͐^#Vr+s͐ >͐0 >͐7s!&a>͐ ͐͐ ͉͐=`is͐ ͐͐ )͐=`in&#&a>!9!9DM`iw#w͐~#fon&U6}ʷ>͐ ?͐^#Vr+snѯg`is#rx>͐þ>!9!9DM! n&͗=|>! n&>! n& 7,2q*&:q):8?=8?=r:qo& !\&!7*@?\!*>7:)~:,"s!"u*|*u?*~#º?"*s*u?#"u*+"ç?7*|DM**0@@><@~# x@ ><$@~+ x$@|}7:,*͒A:*X@}|2q ʉ@@:qwz@! {w#:woʭ@2w&!o @ . &7:O*o`7:)~:,"s!"u*|GoyA$ $(,048<@DHLPTX\`dhlptx| CB(1) C Utilities CB(1) NAME cb - A C program beautifier SYNOPSIS cb [-e] [-fpnsMtMuv] infile [outifle] DESCRIPTION Cb is a C program beautifier. It takes infile and formats it according to the editing rules given with the -e option and places the output in [outfile] according to the options given with the -f option. The following options are interpreted by cb. -e[option] affects editing: l Break line before left brace a Break line after left brace r Break line after right brace b Break line before right brace c Break line at cases i Break line after do, if, etc. # Indent nested #if...'s z No line breaks or indented #if...'s e All of the above -f Output a form feed (FF) at beginning -p Output to CP/M LST: device -n Number source lines -sM Indentation shift width is 1<=M<=9 (Def: 8) -tM Assume hardware tab width is 1<=M<=9 (Def: 8) -u Unbeautify. Compact file by not indenting -v Debug option. More v's are more verbose [outfile] - write output to outfile, otherwise write to the console. FILES cb.crl public domain distribution crl file SEE ALSO B. W. Kernighan and D. M. Ritchie, The C Programming Language A Guide to CP/M Features and Facilities DIAGNOSTICS It will print a list of the valid switches when the arguements are empty or when there is an input error. 1 Printed 1/19/82 1 CB(1) C Utilities CB(1) AUTHOR Chuck Forsberg Computer Devolpment Inc 6700 S.W. 105th Beaverton OR., 97005 1-503-646-1599 BUGS There is no directed i/o in this version. The -e option does not give the formatting that is used in The C Programming Language. ACKNOWLEDGMENTS CP/M is a Trademark of Digitial Research 2 Printed 1/19/82 2 *********************************************************************** The following are fragments from the source to cb.c to help you understand how to use it and what to expect. It was passed through cb before being made into this '.doc' file. This program is independent of the WECO cb and has a number of important differences: 1. My cb doesn't toss cookies. 2. This beautifier doesn't deface pretty comments. 3. Unless told to do so, cb doesn't waste much paper with breaks that aren't absolutely necessary for clarity. This helps CRT users also. 4. Some syntax errors are reported, especially bad strings and mismatched () or {}. 5. Optionally, the SOURCE line number may be listed for each output line. AVAILABILITY: Currently, the only legitimate form of my 'cb' is as a BDS C .CRL file. Of course, this is useful only to those with BDS C licenses (I hope). I will endeavour to make a linkable object of this program available to users of any unrestricted PUBLIC DOMAIN C compiler which has a sufficient subset of C to compile this program. Vendors of C compilers may obtain source to 'cb' by agreeing to provide me a binary license to their C compiler and system (if their own) for each such combination as they wish to make 'cb' available for. Chuck Forsberg 503/621-3406 voice, 621-3193 RCP/M Program beautifiers are especially useful in suggesting where braces have been inadvertently omitted or included. There are some instances of C code which are nearly unreadable (to me) without benefit of this program. /* * cb - A Prettyprinter for C programs * Copyright 1981 Computer Development Inc Beaverton OR * All Rights Reserved * Chuck Forsberg author * * The baroqueness of this program is a reflection of my * preferred "style" of indenting C code. */ #define VERSION "cb 10-3-81\n" unsigned Edit; /* bits indicating editing options selected */ /* * Editing options. "nothing after" really means "nothing * except perhaps a comment." */ #define EBLBR 1 /* nothing before left brace */ #define EALBR 2 /* nothing after left brace */ #define EBRBR 4 /* nothing before right brace */ #define EARBR 8 /* t "tail" or right brace */ #define ECTL 16 /* newline after if, while, for head */ #define ESEMI 32 /* newline after semicolons */ #define ECASE 64 /* labels and cases one per line */ #define ESHARP 128 /* # indent ifdef's et al */ #define EFOOL 1024 /* anyplace where not breaking would be confusing */ #ifdef xxx1 # ifdef xxx2 # ifdef xxx3 # ifdef xxx4 /* test for levels of indentation on #if's */ # endif # endif # endif #endif /* WARNING- BDS C doesn't understand nested conditionals!! */ cp="~|:Copyright CDI 1981 All Rights Reserved"; Edit=EFOOL; Print=Verbose=Number=npats=0; what[0]=0; tabwidth=shiftwidth=8; if(argc<2) goto usage; while (--argc) { cp = *++argv; if(*cp == '-') { while( *++cp) { #ifdef CPM switch(tolower(*cp)) { #else switch(*cp) { #endif case 'e': while(*++cp) { switch(tolower(*cp)) { case 'z': Edit= 0; case 'e': Edit= ~0; case '#': Edit|=ESHARP;break; case 'l': Edit |= EBLBR;break; case 'a': Edit |= EALBR;break; case 'r': Edit |= EARBR;break; case 'b': Edit |= EBRBR;break; case 'c': Edit |= ECASE;break; case 'i': Edit |= ECTL;break; case 's': Edit |= ESEMI;break; default: goto usage; } } cp--; break; case 'p': out=2; Print++; break; case 'n': Number++; break; case 's': shiftwidth= *++cp - '0'; break; case 't': tabwidth= *++cp - '0'; break; case 'v': Verbose++; break; default: goto usage; } } } else if( !npats && argc) { if(argv[0][0]) { npats=argc; patts=argv; } } } if(npats < 1 || npats > 2) { usage: printf(VERSION); printf(" CB - a C program Beautifier\n"); printf("By Chuck Forsberg, Computer Development Inc\n"); printf("6700 S.W. 105th Beaverton OR 97005 503/646-1599\n"); printf("Send Comments/Bug-reports via RCP/M 503/621-3193\n"); printf("Copyright 1981 Computer Development INC. All rights Reserved.\n"); printf("The BDS C relocatable file 'CB.CRL' is hereby placed\n"); printf("in the public domain by its author. This file must be\n"); printf("linked by the BDS C linker to produce an executable\n"); printf("program. This program may not be distributed in any other\n"); printf("form without written permission from the above.\n\n"); printf("Usage: cb [-e{ze#labric}] [-pnsMtMv] infile [outfile]\n"); printf("where:\n -e{option} affects editing:\n"); printf("\t\tl Break line before left brace\n"); printf("\t\ta Break line after left brace\n"); printf("\t\tr Break line after right brace\n"); printf("\t\tb Break line before right brace\n"); printf("\t\tc Break line at cases\n"); printf("\t\ti Break line after do,if, etc.\n"); printf("\t\t# Indenet nested #if...'s\n"); printf("\t\tz No line breaks or indentented #if..'s\n"); printf("\t\te All of the above (`ala Kernighan/Ritchie)\n"); #ifdef CPM printf(" -p Output to LST: device\n"); #endif printf(" -n Number source lines\n"); printf(" -sM Indentation shift width is 1<=M<=9 (Default 8)\n"); printf(" -tM Assume Hardware tab width is 1<=M<=9 (Default 8)\n"); printf(" -v Verbose More v's are more verbose\n"); #ifdef CPM printf(" [outfile] write ouput to outfile\n"); exit(1); } #ifdef CPM if(npats) { pathname=patts[0]; if(fopen( patts[0], fin) == ERROR) { fprintf(stderr, "Can't open %s\n", patts[0]); exit(128); } else in=fin; } if(npats==2) { if(fopen(patts[1], fout) != ERROR) { fprintf(stderr, "Output file exists"); exit(9); } if(fcreat(patts[1], fout)== ERROR) { fprintf(stderr, "Can't create %s\n", patts[1]); exit(128); } else out=fout; } goto qagain; /* * Comments are printed in a particular style. */ /* * If found at the margin, they stay there. */ cagain: case '/': if(*pos == '/' && pos[1] == NATHAN) { if(pos==line) { jamcom++; jamleft |= 1; } if(comments++) nestedc++; pos +=2; } else if(comments==0) break; if(*pos == NATHAN && pos[1] == '/') { pos++; if(--comments == 0) { jamcom= 0; break; } pos++; } if(*pos == 0) { if(jamcom) { jamleft |= 1; pos0= line; } doline(); if( *pos0 == NATHAN && pos0[-1] == ' ' && pos0 > line) --pos0; if(jamcom) jamleft |= 1; } else pos++; goto cagain; #ifdef CPM #undef putc xputc(cha, channel) /* a putch that tabs the printer */ { if(channel==2) { if(cha=='\t') { do putc(040, 2); while( ++column & 07); } else { putc(cha, 2); if(cha > 037) column++; else column=0; } return OK; } else return putc(cha, channel); } #endif  /* * If found at the margin, they stay there.