aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/fcallfmt.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-02-11 16:58:23 +0000
committerrsc <devnull@localhost>2005-02-11 16:58:23 +0000
commitb589fce2fbf05ae18a6f015240f87ce2a163521f (patch)
tree872dbf6e2c6f7be43971b6097f8bb15379e1379e /src/lib9/fcallfmt.c
parent26a5fd572556f6d875c18fff8e83ed5eed6cf8fa (diff)
downloadplan9port-b589fce2fbf05ae18a6f015240f87ce2a163521f.tar.gz
plan9port-b589fce2fbf05ae18a6f015240f87ce2a163521f.tar.bz2
plan9port-b589fce2fbf05ae18a6f015240f87ce2a163521f.zip
hard code list of plan 9 services in case they are not in /etc/services
Diffstat (limited to 'src/lib9/fcallfmt.c')
-rw-r--r--src/lib9/fcallfmt.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/lib9/fcallfmt.c b/src/lib9/fcallfmt.c
index 592316fe..88a5ecc4 100644
--- a/src/lib9/fcallfmt.c
+++ b/src/lib9/fcallfmt.c
@@ -216,15 +216,26 @@ dumpsome(char *ans, char *e, char *buf, long count)
if(count > DUMPL)
count = DUMPL;
for(i=0; i<count && printable; i++)
- if((buf[i]<32 && buf[i] !='\n' && buf[i] !='\t') || (uchar)buf[i]>127)
+ if((buf[i]!=0 && buf[i]<32) || (uchar)buf[i]>127)
printable = 0;
p = ans;
*p++ = '\'';
if(printable){
- if(count > e-p-2)
- count = e-p-2;
- memmove(p, buf, count);
- p += count;
+ if(2*count > e-p-2)
+ count = (e-p-2)/2;
+ for(i=0; i<count; i++){
+ if(buf[i] == 0){
+ *p++ = '\\';
+ *p++ = '0';
+ }else if(buf[i] == '\t'){
+ *p++ = '\\';
+ *p++ = 't';
+ }else if(buf[i] == '\n'){
+ *p++ = '\\';
+ *p++ = 'n';
+ }else
+ *p++ = buf[i];
+ }
}else{
if(2*count > e-p-2)
count = (e-p-2)/2;
@@ -237,5 +248,6 @@ dumpsome(char *ans, char *e, char *buf, long count)
}
*p++ = '\'';
*p = 0;
+ assert(p < e);
return p - ans;
}