Browse Source

Plan 9 from Bell Labs 2003-09-09

David du Colombier 20 years ago
parent
commit
f01c337464
6 changed files with 84 additions and 5 deletions
  1. 5 4
      dist/replica/plan9.db
  2. 7 0
      dist/replica/plan9.log
  3. 2 0
      sys/games/lib/fortunes
  4. 31 0
      sys/man/1/cb
  5. 38 1
      sys/src/cmd/cb/cb.c
  6. 1 0
      sys/src/cmd/cb/cb.h

+ 5 - 4
dist/replica/plan9.db

@@ -171,7 +171,7 @@
 386/bin/cal - 775 sys sys 1056364226 66698
 386/bin/calendar - 775 sys sys 1056364227 78213
 386/bin/cat - 775 sys sys 1039758550 37944
-386/bin/cb - 775 sys sys 1062860430 75704
+386/bin/cb - 775 sys sys 1063039635 76159
 386/bin/cdfs - 775 sys sys 1056364228 163188
 386/bin/cfs - 775 sys sys 1056364229 129790
 386/bin/chgrp - 775 sys sys 1056364229 58515
@@ -3263,7 +3263,7 @@ sys/doc/venti/venti.pdf - 755 sys sys 1020384352 139090
 sys/doc/venti/venti.ps - 664 sys sys 1019852320 2012620
 sys/games - 20000000775 sys sys 952648872 0
 sys/games/lib - 20000000775 sys sys 952648879 0
-sys/games/lib/fortunes - 664 sys sys 1060359152 244377
+sys/games/lib/fortunes - 664 sys sys 1063072455 244492
 sys/include - 20000000775 sys sys 1016902416 0
 sys/include/9p.h - 664 sys sys 1044836327 4309
 sys/include/String.h - 664 sys sys 1055701304 1291
@@ -4497,6 +4497,7 @@ sys/man/1/bundle - 664 sys sys 944959672 986
 sys/man/1/cal - 664 sys sys 944959673 849
 sys/man/1/calendar - 664 sys sys 1032058542 1144
 sys/man/1/cat - 664 sys sys 1022048090 1335
+sys/man/1/cb - 664 sys sys 1063025841 890
 sys/man/1/chgrp - 664 sys sys 944959673 710
 sys/man/1/chmod - 664 sys sys 944959673 1276
 sys/man/1/cleanname - 664 sys sys 944959674 580
@@ -6930,8 +6931,8 @@ sys/src/cmd/cal.c - 664 sys sys 944961619 4206
 sys/src/cmd/calendar.c - 664 sys sys 1034213625 3571
 sys/src/cmd/cat.c - 664 sys sys 1014926693 532
 sys/src/cmd/cb - 20000000775 sys sys 1062860425 0
-sys/src/cmd/cb/cb.c - 664 sys sys 1062860425 17924
-sys/src/cmd/cb/cb.h - 664 sys sys 1062860425 3382
+sys/src/cmd/cb/cb.c - 664 sys sys 1063039630 18439
+sys/src/cmd/cb/cb.h - 664 sys sys 1063023989 3404
 sys/src/cmd/cb/cbtype.c - 664 sys sys 1062860425 674
 sys/src/cmd/cb/cbtype.h - 664 sys sys 1062860425 794
 sys/src/cmd/cb/mkfile - 664 sys sys 1062860425 172

+ 7 - 0
dist/replica/plan9.log

@@ -13135,3 +13135,10 @@
 1062860489 4 a sys/src/cmd/cb/cbtype.c - 664 sys sys 1062860425 674
 1062860489 5 a sys/src/cmd/cb/cbtype.h - 664 sys sys 1062860425 794
 1062860489 6 a sys/src/cmd/cb/mkfile - 664 sys sys 1062860425 172
+1063024217 0 c 386/bin/cb - 775 sys sys 1063023996 76152
+1063024217 1 c sys/src/cmd/cb/cb.c - 664 sys sys 1063023990 18425
+1063024217 2 c sys/src/cmd/cb/cb.h - 664 sys sys 1063023989 3404
+1063026018 0 a sys/man/1/cb - 664 sys sys 1063025841 890
+1063040436 0 c 386/bin/cb - 775 sys sys 1063039635 76159
+1063040436 1 c sys/src/cmd/cb/cb.c - 664 sys sys 1063039630 18439
+1063072862 0 c sys/games/lib/fortunes - 664 sys sys 1063072455 244492

+ 2 - 0
sys/games/lib/fortunes

@@ -3975,3 +3975,5 @@ Sense of terminal's easiness and functional file server!
 Practically noiseless and impossible to explode. - ad for the 1897 Oldsmobile
 info: Terminal type `dumb' is not smart enough to run Info.
  k=k; /* To suppress warning */
+debug1: Miscellaneous failure
+That doesn't make sense to me.  But then, you are very small.  Perhaps you're right.

+ 31 - 0
sys/man/1/cb

@@ -0,0 +1,31 @@
+.TH CB 1
+.SH NAME
+.I cb 
+\- C program beautifier
+.SH SYNOPSIS
+\fBcb\fR [\fB-s\fR] [\fB-j\fR] [\fB-l\fR \fIleng\fR] [\fIfile\fR ...]
+.SH DESCRIPTION
+\fBCb\fR reads syntactically correct C programs from
+from its input or the given files, and writes them to its stdout
+with a more visualy pleasing spacing and indentation. \fBCb\fR
+understands no C++ syntax bar newline terminated comments;
+and by default all user new-lines are preserved in the output.
+.PP
+\fBCb\fR accepts the following options.
+.TP 
+.B -s
+Write the code in the style of Kernighan and
+Ritchie found in The C Programming Language.
+.TP
+.B -j
+Put split lines back together.
+.TP 
+.B -l leng
+Split lines that are longer than \fIleng\fR.
+.SH SOURCE
+.B /sys/src/cmd/cb
+.SH NOTES
+The format of structure initializations is unchanged by \fBcb\fR.
+.br
+Punctuation that is hidden in preprocessing directives
+causes indentation errors.

+ 38 - 1
sys/src/cmd/cb/cb.c

@@ -484,7 +484,15 @@ work(void){
 			OUTK;
 			continue;
 		case '/':
-			if ((cc = getch()) != '*'){
+			if ((cc = getch()) == '/') {
+				putch(c,NO);
+				putch(cc,NO);
+				cpp_comment(YES);
+				OUT;
+				lastlook = 0;
+				continue;
+			}
+			else if (cc != '*') {
 				unget(cc);
 				gotop(c);
 				continue;
@@ -736,6 +744,13 @@ getnl(void){
 			ch = getch();
 			gotcmt=1;
 		}
+		else if (ch == '/') {
+			putch('/',NO);
+			putch('/',NO);
+			cpp_comment(NO);
+			ch = getch();
+			gotcmt = 1;
+		}
 		else {
 			if(inswitch)*(++lastplace) = ch;
 			else {
@@ -871,6 +886,28 @@ gotstar:
 	}
 	return(hitnl);
 }
+int
+cpp_comment(int ok)
+{
+	int ch;
+	int hitnl;
+
+	hitnl = 0;
+	while ((ch = getch()) != -1) {
+		if (ch == '\n') {
+			if (ok && !hitnl)
+				outs(clev->tabs);
+			else
+				outs(0);
+			lbegin = 1;
+			count = 0;
+			hitnl = 1;
+			break;
+		}
+		putch(ch, NO);
+	}
+	return hitnl;
+}
 void
 putspace(char ch, int ok)
 {

+ 1 - 0
sys/src/cmd/cb/cb.h

@@ -169,3 +169,4 @@ void copy(char *);
 void clearif(struct indent *);
 char puttmp(char, int);
 void error(char *);
+int cpp_comment(int);