From 2aeafcb077b3a41d663e577952a2f8fe7f35bbdb Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 17 Jan 1995 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1995-01-17 --- carrera/mem.h | 1 + pc/devfloppy.c | 2 +- pc/devhard.c | 10 +++++----- pc/devi82365.c | 4 ++-- pc/devvga.c | 2 +- pc/kbd.c | 2 +- pc/main.c | 2 +- port/devcons.c | 6 ++++++ port/devsd.c | 4 ++-- port/lib.h | 1 + port/portfns.h | 2 +- 11 files changed, 22 insertions(+), 14 deletions(-) diff --git a/carrera/mem.h b/carrera/mem.h index 722e002aae78ace52d537e9b9a58c4157c7bfb3b..b5fe10fdffbb9ba45fceaa60c3124516f08aadbd 100644 --- a/carrera/mem.h +++ b/carrera/mem.h @@ -166,6 +166,7 @@ #define KSEG2 0xC0000000 #define KSEG3 0xE0000000 #define KSEGM 0xE0000000 /* mask to check which seg */ +#define CACHELINESZ 128 #define PIDXSHFT 12 #define PIDX (0x7< 1){ + if(getfields(params, f, 3, " ") > 1){ for(t = floppytype; t < &floppytype[NTYPES]; t++) if(strcmp(f[1], t->name)==0 && t->dt==dp->dt){ dp->t = t; diff --git a/pc/devhard.c b/pc/devhard.c index e7badace09aad02e4bdaba67a08aaf4ca26bd226..66deedf441450a1ae499571bf391aebebe967c7d 100644 --- a/pc/devhard.c +++ b/pc/devhard.c @@ -880,12 +880,12 @@ hardreplinit(Drive *dp) /* * parse replacement table. */ - n = getfields(buf, line, Nrepl+1, '\n'); + n = getfields(buf, line, Nrepl+1, "\n"); if(strncmp(line[0], REPLMAGIC, sizeof(REPLMAGIC)-1)){ dp->repl.p = 0; } else { for(dp->repl.nrepl = 0, i = 1; i < n; i++, dp->repl.nrepl++){ - if(getfields(line[i], field, 1, ' ') != 1) + if(getfields(line[i], field, 1, " ") != 1) break; dp->repl.blk[dp->repl.nrepl] = strtoul(field[0], 0, 0); if(dp->repl.blk[dp->repl.nrepl] <= 0) @@ -948,14 +948,14 @@ hardpart(Drive *dp) */ hardxfer(dp, pp, Cread, 0, dp->bytes, buf); buf[dp->bytes-1] = 0; - n = getfields(buf, line, Npart+1, '\n'); + n = getfields(buf, line, Npart+1, "\n"); if(n == 0 || strncmp(line[0], PARTMAGIC, sizeof(PARTMAGIC)-1)){ dp->p[0].end--; dp->p[1].start--; dp->p[1].end--; hardxfer(dp, pp, Cread, 0, dp->bytes, buf); buf[dp->bytes-1] = 0; - n = getfields(buf, line, Npart+1, '\n'); + n = getfields(buf, line, Npart+1, "\n"); } /* @@ -964,7 +964,7 @@ hardpart(Drive *dp) if(n && strncmp(line[0], PARTMAGIC, sizeof(PARTMAGIC)-1) == 0){ for(i = 1; i < n; i++){ pp++; - switch(getfields(line[i], field, 3, ' ')) { + switch(getfields(line[i], field, 3, " ")) { case 2: if(strcmp(field[0], "unit") == 0) strncpy(dp->vol, field[1], NAMELEN); diff --git a/pc/devi82365.c b/pc/devi82365.c index 0b81c6682761398ed0521bebdb75f7640b454e77..4d4a345d0da14a35a47978ad05af0edba4b500c6 100644 --- a/pc/devi82365.c +++ b/pc/devi82365.c @@ -151,7 +151,7 @@ struct Slot uchar busy; /* cis info */ - uchar verstr[512]; /* version string */ + char verstr[512]; /* version string */ uchar vpp1; uchar vpp2; uchar bit16; @@ -1173,7 +1173,7 @@ tvers1(Slot *pp, int ttype) if(readc(pp, &minor) != 1) return; for(i = 0; i < sizeof(pp->verstr)-1; i++){ - if(readc(&c) != 1) + if(readc(pp, &c) != 1) return; if(c == 0) c = '\n'; diff --git a/pc/devvga.c b/pc/devvga.c index e162fb43f6dfbc2c597f5d4dcb0c495af7a40f63..d9056d9d6b40b934a622d8439eb9a9125001f9fa 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -256,7 +256,7 @@ vgactl(char *arg) int i, x, y, z; char *cp, *field[3]; - if(getfields(arg, field, 3, ' ') != 2) + if(getfields(arg, field, 3, " ") != 2) error(Ebadarg); if(strcmp(field[0], "hwgc") == 0){ diff --git a/pc/kbd.c b/pc/kbd.c index 04e80b7ba6393844b5e58d31e1fd10f24611c76d..33d02e85e241cef395bb624d639d75e08e9362c1 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -543,7 +543,7 @@ mousectl(char *arg) int n, x; char *field[3]; - n = getfields(arg, field, 3, ' '); + n = getfields(arg, field, 3, " "); if(strncmp(field[0], "serial", 6) == 0){ switch(n){ case 1: diff --git a/pc/main.c b/pc/main.c index bc88dbee58f90a5322cdb4cde8b5507134ff984e..78fe48714de82cadc92273b1506f4b70db38f2d3 100644 --- a/pc/main.c +++ b/pc/main.c @@ -361,7 +361,7 @@ confinit(void) */ cp = BOOTARGS; /* where b.com leaves its config */ cp[BOOTARGSLEN-1] = 0; - n = getfields(cp, line, MAXCONF, '\n'); + n = getfields(cp, line, MAXCONF, "\n"); for(j = 0; j < n; j++){ cp = strchr(line[j], '\r'); if(cp) diff --git a/port/devcons.c b/port/devcons.c index 7e4e0ff7b2e77b51eaa19b671c1c19e57eb4c56d..9a876941554b4eb4c6c39de5e9ada9e1846c7f2b 100644 --- a/port/devcons.c +++ b/port/devcons.c @@ -94,6 +94,12 @@ putstrn(char *str, int n) putstrn0(str, n, 0); } +int +snprint(char *s, int n, char *fmt, ...) +{ + return doprint(s, s+n, fmt, (&fmt+1)) - s; +} + int sprint(char *s, char *fmt, ...) { diff --git a/port/devsd.c b/port/devsd.c index 08fd53da88f4e1fbca306693589ce317a607fc28..17d09f0bf9c36ea9a180c5d6800b0f4ee6b339cc 100644 --- a/port/devsd.c +++ b/port/devsd.c @@ -279,10 +279,10 @@ sdrdpart(Disk *d) /* * parse partition table. */ - n = getfields(b, line, Npart+2, '\n'); + n = getfields(b, line, Npart+2, "\n"); if(n > 0 && strncmp(line[0], MAGIC, sizeof(MAGIC)-1) == 0) { for(i = 1; i < n; i++) { - switch(getfields(line[i], field, 3, ' ')) { + switch(getfields(line[i], field, 3, " ")) { case 2: if(strcmp(field[0], "unit") == 0) strncpy(d->vol, field[1], NAMELEN); diff --git a/port/lib.h b/port/lib.h index a714672185d5847803daa6cdd9a8994c32b2d258..a6750f6bd474164a5ef60ce1baa6b8575f16899e 100644 --- a/port/lib.h +++ b/port/lib.h @@ -60,6 +60,7 @@ extern int numbconv(void*, Fconv*); extern char *doprint(char*, char*, char*, void*); extern int fmtinstall(int, int (*)(void*, Fconv*)); extern int sprint(char*, char*, ...); +extern int snprint(char*, int, char*, ...); extern int print(char*, ...); /* diff --git a/port/portfns.h b/port/portfns.h index 31f6f63468aab97db0f49a0ec25d3cd2d3cadf66..ce3bade66d038aa96d8db22cb2814e30c838013f 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -89,7 +89,7 @@ void freepte(Segment*, Pte*); void freesegs(int); void freesession(Session*); void getcolor(ulong, ulong*, ulong*, ulong*); -int getfields(char*, char**, int, char); +int getfields(char*, char**, int, char*); void gotolabel(Label*); void graphicsactive(int); int haswaitq(void*);