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