| plan 9 kernel history: overview | file list | diff list |
2001/0331/port/parse.c (diff list | history)
| port/parse.c on 1999/0316 | ||
| 1999/0316 | #include "u.h" #include "../port/lib.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "../port/error.h" /* * parse a command written to a device */ Cmdbuf* parsecmd(char *p, int n) { | |
| 2001/0331 | Cmdbuf *volatile cb; | |
| 1999/0316 | cb = smalloc(sizeof(*cb)); if(n > sizeof(cb->buf)-1) n = sizeof(cb->buf)-1; | |
| 2001/0331 | if(waserror()){ free(cb); nexterror(); } | |
| 1999/0316 | memmove(cb->buf, p, n); | |
| 2001/0331 | poperror(); | |
| 1999/0316 | if(n > 0 && cb->buf[n-1] == '\n') n--; cb->buf[n] = '\0'; | |
| 2000/0308 | cb->nf = getfields(cb->buf, cb->f, nelem(cb->f), 1, " "); | |
| 1999/0316 | return cb; } | |