| @@ -175,7 +175,7 @@ patrule: ref Rule; · 174 unmodified lines |
| 175 | main(argc: int, argv: array of array of byte) | 175 | main(argc: int, argv: array of array of byte) |
| 176 | { | 176 | { |
| 177 | w: ref Word; | 177 | w: ref Word; |
| 178 | s, temp: array of byte; | 178 | s: array of byte; |
| 179 | files := array[256] of array of byte; | 179 | files := array[256] of array of byte; |
| 180 | f: array of array of byte = files; | 180 | f: array of array of byte = files; |
| 181 | ff: int; | 181 | ff: int; |
| @@ -265,20 +265,15 @@ main(argc: int, argv: array of array of byte) · 83 unmodified lines |
| 265 | # | 265 | # |
| 266 | # assignment args become null strings | 266 | # assignment args become null strings |
| 267 | # | 267 | # |
| 268 | temp = nil; | 268 | temp: string; |
| 269 | for(i = 0; argv[i] != nil; i++) | 269 | for(i = 0; argv[i] != nil; i++) |
| 270 | if(libc0->strchr(argv[i], '=') != nil){ | 270 | if(libc0->strchr(argv[i], '=') != nil){ |
| 271 | bufcpy(buf, argv[i], libc0->strlen(argv[i])); | 271 | bufcpy(buf, argv[i], libc0->strlen(argv[i])); |
| 272 | insert(buf, ' '); | 272 | insert(buf, ' '); |
| 273 | if(tfd == nil){ | 273 | if(tfd == nil){ |
| 274 | temp = maketmp(); | 274 | (temp, tfd) = tmpfile("/tmp/mkarg"); |
| 275 | if(temp == nil){ | 275 | if(tfd == nil){ |
| 276 | perrors("temp file"); | 276 | perror(array of byte temp); |
| 277 | Exit(); | | |
| 278 | } | | |
| 279 | sys->create(libc0->ab2s(temp), Sys->OWRITE, 8r600); | | |
| 280 | if((tfd = sys->open(libc0->ab2s(temp), 2)) == nil){ | | |
| 281 | perror(temp); | | |
| 282 | Exit(); | 277 | Exit(); |
| 283 | } | 278 | } |
| 284 | tb = bufio->fopen(tfd, Sys->OWRITE); | 279 | tb = bufio->fopen(tfd, Sys->OWRITE); |
| @@ -290,7 +285,7 @@ main(argc: int, argv: array of array of byte) · 5 unmodified lines |
| 290 | tb.flush(); | 285 | tb.flush(); |
| 291 | sys->seek(tfd, big 0, 0); | 286 | sys->seek(tfd, big 0, 0); |
| 292 | parse(libc0->s2ab("command line args"), tfd, 1); | 287 | parse(libc0->s2ab("command line args"), tfd, 1); |
| 293 | sys->remove(libc0->ab2s(temp)); | 288 | sys->remove(temp); |
| 294 | } | 289 | } |
| 295 | if(buf.current != 0){ | 290 | if(buf.current != 0){ |
| 296 | buf.current--; | 291 | buf.current--; |
| @@ -424,20 +419,16 @@ stob(buf: array of byte, s: string) · 127 unmodified lines |
| 424 | libc0->strncpy(buf, b, len buf); | 419 | libc0->strncpy(buf, b, len buf); |
| 425 | } | 420 | } |
| 426 | | 421 | |
| 427 | mktemp(t: array of byte) | 422 | tmpfile(basename: string): (string, ref Sys->FD) |
| 428 | { | 423 | { |
| 429 | x := libc0->strchr(t, 'X'); | 424 | pid := sys->pctl(0, nil); |
| 430 | if(x == nil) | 425 | for(i := 0; i < 100; i++){ |
| 431 | return; | 426 | t := basename+sys->sprint("%8.8d.%.2d", pid, i); |
| 432 | pid := libc0->s2ab(string sys->pctl(0, nil)); | 427 | fd := sys->create(t, Sys->OEXCL|Sys->ORDWR, 8r600); |
| 433 | for(i := 'a'; i <= 'z'; i++){ | 428 | if(fd != nil) |
| 434 | x[0] = byte i; | 429 | return (t, fd); |
| 435 | x = x[1: ]; | | |
| 436 | libc0->strncpy(x, pid, libc0->strlen(x)); | | |
| 437 | (ok, nil) := sys->stat(libc0->ab2s(t)); | | |
| 438 | if(ok >= 0) | | |
| 439 | continue; | | |
| 440 | } | 430 | } |
| | 431 | return (nil, nil); |
| 441 | } | 432 | } |
| 442 | | 433 | |
| 443 | postnote(t: int, pid: int, note: array of byte) | 434 | postnote(t: int, pid: int, note: array of byte) |
| @@ -3385,15 +3376,6 @@ catchnotes() · 2941 unmodified lines |
| 3385 | # atnotify(notifyf, 1); | 3376 | # atnotify(notifyf, 1); |
| 3386 | } | 3377 | } |
| 3387 | | 3378 | |
| 3388 | temp := array[] of { byte '/', byte 't', byte 'm', byte 'p', byte '/', byte 'm', byte 'k', byte 'a', byte 'r', byte 'g', byte 'X', byte 'X', byte 'X', byte 'X', byte 'X', byte 'X', byte '\0' }; | | |
| 3389 | | | |
| 3390 | maketmp(): array of byte | | |
| 3391 | { | | |
| 3392 | t := libc0->strdup(temp); | | |
| 3393 | mktemp(t); | | |
| 3394 | return t; | | |
| 3395 | } | | |
| 3396 | | | |
| 3397 | chgtime(name: array of byte): int | 3379 | chgtime(name: array of byte): int |
| 3398 | { | 3380 | { |
| 3399 | (ok, nil) := sys->stat(libc0->ab2s(name)); | 3381 | (ok, nil) := sys->stat(libc0->ab2s(name)); |