Browse Source

Plan 9 from Bell Labs 2010-01-23

David du Colombier 14 years ago
parent
commit
a395606dcb
6 changed files with 67 additions and 48 deletions
  1. 2 1
      sys/doc/ape.ms
  2. 49 41
      sys/doc/ape.ps
  3. 2 2
      sys/doc/mkdirlist
  4. 1 2
      sys/include/ape/stdio.h
  5. 2 2
      sys/src/ape/lib/ap/plan9/profile.c
  6. 11 0
      sys/src/cmd/page/view.c

+ 2 - 1
sys/doc/ape.ms

@@ -428,7 +428,8 @@ actually stored in the target string.
 string was too small.)
 C99 requires them to instead return the number of bytes,
 excluding terminating NUL,
-that would have been written into the target string if it were infinitely large,
+that would have been written into the target string if it were infinitely large
+or a negative value if an `encoding error' occurs,
 so old programs compiled under C99 rules will be prone to overrunning
 their buffers.
 This extension is a way for the programmer to declare that he or she understands

+ 49 - 41
sys/doc/ape.ps

@@ -5543,47 +5543,55 @@ mark
 (if) 4872 840 w
 (it) 4974 840 w
 (were) 970 960 w
-(infinitely) 1244 960 w
-(large,) 1711 960 w
-(so) 2031 960 w
-(old) 2188 960 w
-(programs) 2386 960 w
-(compiled) 2898 960 w
-(under) 3388 960 w
-(C99) 3717 960 w
-(rules) 3957 960 w
-(will) 4241 960 w
-(be) 4450 960 w
-(prone) 4614 960 w
-(to) 4942 960 w
-(overrunning) 970 1080 w
-(their) 1602 1080 w
-(buffers.) 1869 1080 w
-(This) 2322 1080 w
-(extension) 2569 1080 w
-(is) 3085 1080 w
-(a) 3206 1080 w
-(way) 3302 1080 w
-(for) 3527 1080 w
-(the) 3707 1080 w
-(programmer) 3903 1080 w
-(to) 4550 1080 w
-(declare) 4689 1080 w
-(that) 970 1200 w
-(he) 1194 1200 w
-(or) 1346 1200 w
-(she) 1482 1200 w
-(understands) 1685 1200 w
-(the) 2322 1200 w
-(situation) 2511 1200 w
-(and) 2968 1200 w
-(has) 3182 1200 w
-(adjusted) 3384 1200 w
-(the) 3835 1200 w
-(code) 4024 1200 w
-(being) 4289 1200 w
-(compiled) 4595 1200 w
-(to compensate.) 970 1320 w
+(infinitely) 1243 960 w
+(large) 1708 960 w
+(or) 1994 960 w
+(a) 2139 960 w
+(negative) 2237 960 w
+(value) 2689 960 w
+(if) 2987 960 w
+(an) 3097 960 w
+10 /LucidaSansUnicode20 f
+(\030) 3258 960 w
+10 /LucidaSansUnicode00 f
+(encoding) 3290 960 w
+(error) 3780 960 w
+10 /LucidaSansUnicode20 f
+(\031) 4020 960 w
+10 /LucidaSansUnicode00 f
+(occurs,) 4096 960 w
+(so) 4489 960 w
+(old) 4645 960 w
+(pro\255) 4842 960 w
+(grams) 970 1080 w
+(compiled) 1315 1080 w
+(under) 1803 1080 w
+(C99) 2130 1080 w
+(rules) 2368 1080 w
+(will) 2650 1080 w
+(be) 2857 1080 w
+(prone) 3018 1080 w
+(to) 3343 1080 w
+(overrunning) 3483 1080 w
+(their) 4115 1080 w
+(buffers.) 4382 1080 w
+(This) 4835 1080 w
+(extension) 970 1200 w
+(is) 1487 1200 w
+(a) 1609 1200 w
+(way) 1706 1200 w
+(for) 1932 1200 w
+(the) 2113 1200 w
+(programmer) 2310 1200 w
+(to) 2958 1200 w
+(declare) 3098 1200 w
+(that) 3491 1200 w
+(he) 3724 1200 w
+(or) 3884 1200 w
+(she) 4028 1200 w
+(understands) 4239 1200 w
+(the) 4885 1200 w
+(situation and has adjusted the code being compiled to compensate.) 970 1320 w
 10 /LucidaSans-Demi f
 (Common Problems) 720 1560 w
 10 /LucidaSansUnicode00 f

+ 2 - 2
sys/doc/mkdirlist

@@ -1,5 +1,5 @@
 #!/bin/rc
-
+# mkdirlist
 for(i in $*)
 	if(~ $i */*)
-		echo $i
+		basename -d $i

+ 1 - 2
sys/include/ape/stdio.h

@@ -88,8 +88,7 @@ extern int fscanf(FILE *, const char *, ...);
 extern int printf(const char *, ...);
 extern int scanf(const char *, ...);
 extern int sprintf(char *, const char *, ...);
-#define _C99_SNPRINTF_EXTENSION
-#ifdef _C99_SNPRINTF_EXTENSION		/* user knows about c99 treachery */
+#ifdef _C99_SNPRINTF_EXTENSION /* user knows about c99 out-of-bounds returns */
 extern int snprintf(char *, size_t, const char *, ...);
 extern int vsnprintf(char *, size_t, const char *, va_list);
 #else

+ 2 - 2
sys/src/ape/lib/ap/plan9/profile.c

@@ -143,8 +143,8 @@ err(char *fmt, ...)
 	va_start(arg, fmt);
 	/*
 	 * C99 now requires *snprintf to return the number of characters
-	 * that *would* have been emitted, had there been room for them.
-	 * Arrgh!
+	 * that *would* have been emitted, had there been room for them,
+	 * or a negative value on an `encoding error'.  Arrgh!
 	 */
 	vsnprintf(buf, sizeof buf, fmt, arg);
 	va_end(arg);

+ 11 - 0
sys/src/cmd/page/view.c

@@ -220,6 +220,15 @@ showdata(Plumbmsg *msg)
 	return s && strcmp(s, "showdata")==0;
 }
 
+static int
+plumbquit(Plumbmsg *msg)
+{
+	char *s;
+
+	s = plumblookup(msg->attr, "action");
+	return s && strcmp(s, "quit")==0;
+}
+
 /* correspond to entries in miditems[] below,
  * changing one means you need to change
  */
@@ -666,6 +675,8 @@ viewer(Document *dd)
 				plumbfree(pm);
 				break;
 			}
+			if(plumbquit(pm))
+				exits(nil);
 			if(showdata(pm)) {
 				s = estrdup("/tmp/pageplumbXXXXXXX");
 				fd = opentemp(s);