Unified · Split
| @@ -1,3 +1,5 @@ | ||
| 1 | +20070608 | |
| 2 | + update /lib9 functions to use silly va_copy (and then va_end) instead of just assigning, to account for silly C implementations | |
| 1 | 3 | 20070607 |
| 2 | 4 | /appl/wm/man.b /appl/lib/man.b to allow 10.1 etc as section references |
| 3 | 5 | 20070605 |
| @@ -38,7 +38,6 @@ init(nil: ref Draw->Context, args: list of string) · 37 unmodified lines | ||
| 38 | 38 | |
| 39 | 39 | arg->init(args); |
| 40 | 40 | arg->setusage("9export [-aA9] [-k keyspec] [-e enc digest]"); |
| 41 | − flags := 0; | |
| 42 | 41 | cryptalg := ""; # will be rc4_256 sha1 |
| 43 | 42 | keyspec := ""; |
| 44 | 43 | noauth := 0; |
| @@ -122,7 +122,7 @@ contents(e: ref Entry): string · 121 unmodified lines | ||
| 122 | 122 | s := ""; |
| 123 | 123 | for(cl := e.contents; cl != nil; cl = tl cl) |
| 124 | 124 | s += " " + hd cl; |
| 125 | − return s[1:]; | |
| 125 | + return s; # includes initial space | |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | Entry.text(e: self ref Entry): string |
Binary file not shown.
Binary file not shown.
| @@ -1 +1 @@ | ||
| 1 | −#define VERSION "Fourth Edition (20070607)" | |
| 1 | +#define VERSION "Fourth Edition (20070608)" | |
| @@ -96,3 +96,7 @@ void _fmtunlock(void); · 95 unmodified lines | ||
| 96 | 96 | t += runetochar(t, &_rune);\ |
| 97 | 97 | }\ |
| 98 | 98 | }while(0) |
| 99 | + | |
| 100 | +#ifndef va_copy | |
| 101 | +#define va_copy(a, b) ((a) = (b)) | |
| 102 | +#endif | |
| @@ -29,14 +29,16 @@ fmtprint(Fmt *f, char *fmt, ...) · 28 unmodified lines | ||
| 29 | 29 | f->flags = 0; |
| 30 | 30 | f->width = 0; |
| 31 | 31 | f->prec = 0; |
| 32 | − va = f->args; | |
| 32 | + va_copy(va, f->args); | |
| 33 | + va_end(f->args); | |
| 33 | 34 | va_start(f->args, fmt); |
| 34 | 35 | n = dofmt(f, fmt); |
| 35 | 36 | va_end(f->args); |
| 36 | 37 | f->flags = 0; |
| 37 | 38 | f->width = 0; |
| 38 | 39 | f->prec = 0; |
| 39 | − f->args = va; | |
| 40 | + va_copy(f->args, va); | |
| 41 | + va_end(va); | |
| 40 | 42 | if(n >= 0) |
| 41 | 43 | return 0; |
| 42 | 44 | return n; |
| @@ -29,13 +29,16 @@ fmtvprint(Fmt *f, char *fmt, va_list args) · 28 unmodified lines | ||
| 29 | 29 | f->flags = 0; |
| 30 | 30 | f->width = 0; |
| 31 | 31 | f->prec = 0; |
| 32 | − va = f->args; | |
| 33 | − f->args = args; | |
| 32 | + va_copy(va, f->args); | |
| 33 | + va_end(f->args); | |
| 34 | + va_copy(f->args, args); | |
| 34 | 35 | n = dofmt(f, fmt); |
| 35 | 36 | f->flags = 0; |
| 36 | 37 | f->width = 0; |
| 37 | 38 | f->prec = 0; |
| 38 | − f->args = va; | |
| 39 | + va_end(f->args); | |
| 40 | + va_copy(f->args, va); | |
| 41 | + va_end(va); | |
| 39 | 42 | if(n >= 0) |
| 40 | 43 | return 0; |
| 41 | 44 | return n; |
| @@ -14,8 +14,9 @@ runevseprint(Rune *buf, Rune *e, char *fmt, va_list args) · 13 unmodified lines | ||
| 14 | 14 | f.flush = nil; |
| 15 | 15 | f.farg = nil; |
| 16 | 16 | f.nfmt = 0; |
| 17 | − f.args = args; | |
| 17 | + va_copy(f.args, args); | |
| 18 | 18 | dofmt(&f, fmt); |
| 19 | + va_end(f.args); | |
| 19 | 20 | *(Rune*)f.to = '\0'; |
| 20 | 21 | return f.to; |
| 21 | 22 | } |
| @@ -38,8 +38,9 @@ vfprint(int fd, char *fmt, va_list args) · 37 unmodified lines | ||
| 38 | 38 | int n; |
| 39 | 39 | |
| 40 | 40 | fmtfdinit(&f, fd, buf, sizeof(buf)); |
| 41 | − f.args = args; | |
| 41 | + va_copy(f.args, args); | |
| 42 | 42 | n = dofmt(&f, fmt); |
| 43 | + va_end(f.args); | |
| 43 | 44 | if(n > 0 && _fmtFdFlush(&f) == 0) |
| 44 | 45 | return -1; |
| 45 | 46 | return n; |
| @@ -27,8 +27,9 @@ vseprint(char *buf, char *e, char *fmt, va_list args) · 26 unmodified lines | ||
| 27 | 27 | f.flush = nil; |
| 28 | 28 | f.farg = nil; |
| 29 | 29 | f.nfmt = 0; |
| 30 | − f.args = args; | |
| 30 | + va_copy(f.args, args); | |
| 31 | 31 | dofmt(&f, fmt); |
| 32 | + va_end(f.args); | |
| 32 | 33 | *(char*)f.to = '\0'; |
| 33 | 34 | return f.to; |
| 34 | 35 | } |
| @@ -20,6 +20,8 @@ fmtStrFlush(Fmt *f) · 19 unmodified lines | ||
| 20 | 20 | char *s; |
| 21 | 21 | int n; |
| 22 | 22 | |
| 23 | + if(f->start == nil) | |
| 24 | + return 0; | |
| 23 | 25 | n = (int)f->farg; |
| 24 | 26 | n += 256; |
| 25 | 27 | f->farg = (void*)n; |
| @@ -41,7 +43,7 @@ fmtstrinit(Fmt *f) · 15 unmodified lines | ||
| 41 | 43 | { |
| 42 | 44 | int n; |
| 43 | 45 | |
| 44 | − f->runes = 0; | |
| 46 | + memset(f, 0, sizeof(*f)); | |
| 45 | 47 | n = 32; |
| 46 | 48 | f->start = malloc(n); |
| 47 | 49 | if(f->start == nil) |
| @@ -65,10 +67,13 @@ vsmprint(char *fmt, va_list args) · 17 unmodified lines | ||
| 65 | 67 | |
| 66 | 68 | if(fmtstrinit(&f) < 0) |
| 67 | 69 | return nil; |
| 68 | − f.args = args; | |
| 70 | + va_copy(f.args, args); | |
| 69 | 71 | n = dofmt(&f, fmt); |
| 70 | − if(n < 0) | |
| 72 | + va_end(f.args); | |
| 73 | + if(n < 0){ | |
| 74 | + free(f.start); | |
| 75 | + f.start = nil; | |
| 71 | 76 | return nil; |
| 72 | − *(char*)f.to = '\0'; | |
| 73 | − return f.start; | |
| 77 | + } | |
| 78 | + return fmtstrflush(&f); | |
| 74 | 79 | } |
| @@ -27,8 +27,9 @@ vsnprint(char *buf, int len, char *fmt, va_list args) · 26 unmodified lines | ||
| 27 | 27 | f.flush = nil; |
| 28 | 28 | f.farg = nil; |
| 29 | 29 | f.nfmt = 0; |
| 30 | − f.args = args; | |
| 30 | + va_copy(f.args, args); | |
| 31 | 31 | dofmt(&f, fmt); |
| 32 | + va_end(f.args); | |
| 32 | 33 | *(char*)f.to = '\0'; |
| 33 | 34 | return (char*)f.to - buf; |
| 34 | 35 | } |