diff --git a/sys/src/boot/pc/fat.c b/sys/src/boot/pc/fat.c index f27e847e7..35a8f9603 100644 --- a/sys/src/boot/pc/fat.c +++ b/sys/src/boot/pc/fat.c @@ -384,21 +384,21 @@ start(void *sp) drive = ((ushort*)sp)[5] & 0xFF; if(findfat(&fat, drive, 0, 0)){ - print("no fat\r\n"); + print("no fat\n"); halt(); } if(fatwalk(f = &fi, &fat, "plan9.ini")){ - print("no config\r\n"); + print("no config\n"); f = 0; } for(;;){ kern = configure(f, path); f = 0; if(fatwalk(&fi, &fat, kern)){ - print("not found\r\n"); + print("not found\n"); continue; } print(bootkern(&fi)); - print(crnl); + print("\n"); } } diff --git a/sys/src/boot/pc/fns.h b/sys/src/boot/pc/fns.h index c4a46b1fc..760a51250 100644 --- a/sys/src/boot/pc/fns.h +++ b/sys/src/boot/pc/fns.h @@ -1,7 +1,6 @@ /* handy strings in l.s */ extern char origin[]; extern char hex[]; -extern char crnl[]; extern char bootname[]; /* l.s */ diff --git a/sys/src/boot/pc/iso.c b/sys/src/boot/pc/iso.c index d5e083cea..48caadc69 100644 --- a/sys/src/boot/pc/iso.c +++ b/sys/src/boot/pc/iso.c @@ -161,17 +161,17 @@ start(void *sp) close(&ex); if(isowalk(f = &ex, drive, "/cfg/plan9.ini")){ - print("no config\r\n"); + print("no config\n"); f = 0; } for(;;){ kern = configure(f, path); f = 0; if(isowalk(&ex, drive, kern)){ - print("not found\r\n"); + print("not found\n"); continue; } print(bootkern(&ex)); - print(crnl); + print("\n"); } } diff --git a/sys/src/boot/pc/l.s b/sys/src/boot/pc/l.s index 0858288ec..3ba560a6e 100644 --- a/sys/src/boot/pc/l.s +++ b/sys/src/boot/pc/l.s @@ -295,9 +295,6 @@ TEXT bootname(SB), $0 #endif -TEXT crnl(SB), $0 - BYTE $'\r'; BYTE $'\n'; BYTE $0 - TEXT hex(SB), $0 BYTE $'0'; BYTE $'1'; BYTE $'2'; BYTE $'3'; BYTE $'4'; BYTE $'5'; BYTE $'6'; BYTE $'7'; diff --git a/sys/src/boot/pc/pxe.c b/sys/src/boot/pc/pxe.c index 9f6d74b29..07e8c9911 100644 --- a/sys/src/boot/pc/pxe.c +++ b/sys/src/boot/pc/pxe.c @@ -268,7 +268,7 @@ read(void *f, void *data, int len) break; case Tftp_ERROR: print(t->pkt+4); - print(crnl); + print("\n"); default: t->eof = 1; return -1; @@ -336,27 +336,27 @@ start(void *) Tftp t; if(pxeinit()){ - print("pxe init\r\n"); + print("pxe init\n"); halt(); } if(getip(yip, sip, gip, mac)){ - print("bad dhcp\r\n"); + print("bad dhcp\n"); halt(); } memmove(path, "/cfg/pxe/", 9); memmove(path+9, mac, 13); if(tftpopen(f = &t, path, yip, sip, gip)) if(tftpopen(f, "/cfg/pxe/default", yip, sip, gip)){ - print("no config\r\n"); + print("no config\n"); f = 0; } for(;;){ kern = configure(f, path); f = 0; if(tftpopen(&t, kern, yip, sip, gip)){ - print("not found\r\n"); + print("not found\n"); continue; } print(bootkern(&t)); - print(crnl); + print("\n"); } } diff --git a/sys/src/boot/pc/sub.c b/sys/src/boot/pc/sub.c index 25fd37746..2fda72da8 100644 --- a/sys/src/boot/pc/sub.c +++ b/sys/src/boot/pc/sub.c @@ -38,9 +38,11 @@ memcmp(void *src, void *dst, int n) uchar *s = src; int r = 0; - while(n-- > 0) - if(r = (*d++ - *s++)) + while(n-- > 0){ + r = *d++ - *s++; + if(r != 0) break; + } return r; } @@ -50,7 +52,7 @@ strlen(char *s) { char *p = s; - while(*p) + while(*p != '\0') p++; return p - s; @@ -59,18 +61,21 @@ strlen(char *s) char* strchr(char *s, int c) { - for(; *s; s++) + for(; *s != 0; s++) if(*s == c) return s; - return 0; + return nil; } void print(char *s) { - while(*s) + while(*s != 0){ + if(*s == '\n') + putc('\r'); putc(*s++); + } } int @@ -103,10 +108,10 @@ readline(void *f, char buf[64]) p = buf; do{ - if(!f) + if(f == nil) putc('>'); for(;;){ - if(!f){ + if(f == nil){ putc(*p = getc()); if(*p == '\r') putc('\n'); @@ -116,12 +121,12 @@ readline(void *f, char buf[64]) } }else if(read(f, p, 1) <= 0) return 0; - if(strchr(crnl, *p)) + if(strchr("\r\n", *p) != nil) break; - if(p == buf && strchr(white, *p)) + if(p == buf && strchr(white, *p) != nil) continue; /* whitespace on start of line */ if(p >= buf + 64-1){ - if(!f){ + if(f == nil){ putc('\b'); putc(' '); putc('\b'); @@ -171,7 +176,7 @@ getconf(char *s, char *buf) for(e = p+1; e < confend; e++) if(*e == '\n') break; - if(!memcmp(p, s, n)){ + if(memcmp(p, s, n) == 0){ p += n; n = e - p; buf[n] = 0; @@ -179,7 +184,7 @@ getconf(char *s, char *buf) return buf; } } - return 0; + return nil; } static int @@ -194,7 +199,7 @@ delconf(char *s) break; } } - if(!memcmp(p, s, strlen(s))){ + if(memcmp(p, s, strlen(s)) == 0){ memmove(p, e, confend - e); confend -= e - p; *confend = 0; @@ -225,45 +230,37 @@ Clear: inblock = 0; Loop: while(readline(f, line) > 0){ - if(*line == 0 || strchr("#;=", *line)) + if(*line == 0 || strchr("#;=", *line) != nil) continue; if(*line == '['){ - inblock = memcmp("[common]", line, 8); + inblock = memcmp("[common]", line, 8) != 0; continue; } - if(!memcmp("boot", line, 5)){ + if(memcmp("boot", line, 5) == 0){ nowait=1; break; } - if(!memcmp("wait", line, 5)){ + if(memcmp("wait", line, 5) == 0){ nowait=0; continue; } - if(!memcmp("show", line, 5)){ - for(p = BOOTARGS; p < confend; p++){ - if(*p == '\n') - print(crnl); - else - putc(*p); - } + if(memcmp("show", line, 5) == 0){ + print(BOOTARGS); continue; } - if(!memcmp("clear", line, 5)){ - if(line[5] == 0){ - print("ok"); - print(crnl); + if(memcmp("clear", line, 5) == 0){ + if(line[5] == '\0'){ + print("ok\n"); goto Clear; - } else if(line[5] == ' ' && delconf(line+6)){ - print("ok"); - print(crnl); - } + } else if(line[5] == ' ' && delconf(line+6)) + print("ok\n"); continue; } - if(inblock || (p = strchr(line, '=')) == nil) + if(inblock != 0 || (p = strchr(line, '=')) == nil) continue; *p++ = 0; delconf(line); - if(!memcmp("apm", line, 3)){ + if(memcmp("apm", line, 3) == 0){ apmconf('0' - line[3]); continue; } @@ -272,28 +269,25 @@ Loop: memmove(confend, line, n = strlen(line)); confend += n; *confend++ = '='; memmove(confend, p, n = strlen(p)); confend += n; - *confend = 0; - - print(s); print(crnl); - *confend++ = '\n'; *confend = 0; + print(s); } kern = getconf("bootfile=", path); - if(f){ + if(f != nil){ close(f); - f = 0; + f = nil; - if(kern && (nowait==0 || timeout(1000))) + if(kern != nil && (nowait==0 || timeout(1000))) goto Loop; } - if(!kern){ - print("no bootfile\r\n"); + if(kern == nil){ + print("no bootfile\n"); goto Loop; } - while(p = strchr(kern, '!')) + while((p = strchr(kern, '!')) != nil) kern = p+1; return kern; @@ -333,7 +327,7 @@ apmconf(int id) memset(a, 0, 20); apm(id); - if(memcmp(a, "APM", 4)) + if(memcmp(a, "APM", 4) != 0) return; s = confend; @@ -346,10 +340,10 @@ apmconf(int id) addconfx(" di=", 4, *((ushort*)(a+10))); addconfx(" esi=", 8, *((ulong*)(a+16))); - print(s); print(crnl); - *confend++ = '\n'; *confend = 0; + + print(s); } static void @@ -392,11 +386,10 @@ e820conf(void) if(confend == s) return; - *confend = 0; - print(s); print(crnl); - *confend++ = '\n'; *confend = 0; + + print(s); } static ulong @@ -414,7 +407,7 @@ bootkern(void *f) Exec ex; while(a20() < 0) - print("a20 enable failed\r\n"); + print("a20 enable failed\n"); if(readn(f, &ex, sizeof(ex)) != sizeof(ex)) return "bad header"; @@ -448,8 +441,7 @@ bootkern(void *f) close(f); unload(); - print("boot"); - print(crnl); + print("boot\n"); jump(e);