diff options
Diffstat (limited to 'appl')
| -rw-r--r-- | appl/acme/ecmd.b | 4 | ||||
| -rw-r--r-- | appl/cmd/limbo/limbo.y | 4 | ||||
| -rw-r--r-- | appl/cmd/limbo/types.b | 2 | ||||
| -rw-r--r-- | appl/cmd/m4.b | 75 | ||||
| -rw-r--r-- | appl/math/mersenne.b | 8 | ||||
| -rw-r--r-- | appl/math/parts.b | 8 |
6 files changed, 67 insertions, 34 deletions
diff --git a/appl/acme/ecmd.b b/appl/acme/ecmd.b index e05c4e47..19e38eb3 100644 --- a/appl/acme/ecmd.b +++ b/appl/acme/ecmd.b @@ -1192,7 +1192,7 @@ filematch(f: ref File, r: ref String): int { buf: string; w: ref Window; - match, i, dirty: int; + match, dirty: int; s: Rangeset; # compile expr first so if we get an error, we haven't allocated anything @@ -1203,7 +1203,7 @@ filematch(f: ref File, r: ref String): int dirty = !w.isdir && !w.isscratch && f.mod; buf = sprint("%c%c%c %s\n", " '"[dirty], '+', " ."[curtext!=nil && curtext.file==f], f.name); - (match, s) = rxexecute(nil, buf, 0, i); + (match, s) = rxexecute(nil, buf, 0, len buf); buf = nil; return match; } diff --git a/appl/cmd/limbo/limbo.y b/appl/cmd/limbo/limbo.y index 2f7d3ba8..4eb4af8a 100644 --- a/appl/cmd/limbo/limbo.y +++ b/appl/cmd/limbo/limbo.y @@ -655,13 +655,13 @@ ftype : nids ':' type { $$ = mkids($1.src, enter("junk", 0), $3, nil); $$.store = Darg; - yyerror("illegal argument declaraion"); + yyerror("illegal argument declaration"); } | idterms ':' adtk { $$ = mkids($1.src, enter("junk", 0), $3, nil); $$.store = Darg; - yyerror("illegal argument declaraion"); + yyerror("illegal argument declaration"); } ; diff --git a/appl/cmd/limbo/types.b b/appl/cmd/limbo/types.b index 6b1802e5..2ee207b3 100644 --- a/appl/cmd/limbo/types.b +++ b/appl/cmd/limbo/types.b @@ -1775,7 +1775,7 @@ cycfield(base: ref Type, id: ref Decl) +id.sym.name+" of "+stypeconv(base)); id.cycerr = byte 1; }else if(arc & ArcCyc){ - if((arc & ArcArray) && id.cyc == byte 0 && !(arc & ArcPolycyc)){ + if((arc & ArcArray) && oldcycles && id.cyc == byte 0 && !(arc & ArcPolycyc)){ if(id.cycerr == byte 0) error(base.src.start, "illegal circular reference to type "+typeconv(id.ty) +" in field "+id.sym.name+" of "+stypeconv(base)); diff --git a/appl/cmd/m4.b b/appl/cmd/m4.b index bc992b4f..a4648d4c 100644 --- a/appl/cmd/m4.b +++ b/appl/cmd/m4.b @@ -52,8 +52,11 @@ lquote := '`'; rquote := '\''; initcom := "#"; endcom := "\n"; +prefix := ""; bout: ref Iobuf; sh: Sh; +stderr: ref Sys->FD; +tracing := 0; init(nil: ref Draw->Context, args: list of string) { @@ -61,9 +64,27 @@ init(nil: ref Draw->Context, args: list of string) bufio = load Bufio Bufio->PATH; bout = bufio->fopen(sys->fildes(1), Sys->OWRITE); + stderr = sys->fildes(2); define("inferno", "inferno", 0); + arg := load Arg Arg->PATH; + arg->setusage("m4 [-t] [-pprefix] [-Dname[=value]] [-Qname[=value]] [-Uname] [file ...]"); + arg->init(args); + + while((o := arg->opt()) != 0){ + case o { + 'D' or 'Q' or 'U' => + ; # for second pass + 'p' => + prefix = arg->earg(); + 't' => + tracing = 1; + * => + arg->usage(); + } + } + builtin("changecom", dochangecom); builtin("changequote", dochangequote); builtin("copydef", docopydef); @@ -88,11 +109,9 @@ init(nil: ref Draw->Context, args: list of string) builtin("undefine", doundefine); builtin("undivert", doundivert); - arg := load Arg Arg->PATH; - arg->setusage("m4 [-Dname[=value]] [-Qname[=value]] [-Uname] [file ...]"); arg->init(args); - while((o := arg->opt()) != 0){ + while((o = arg->opt()) != 0){ case o { 'D' => argdefine(arg->earg(), 0); @@ -100,6 +119,10 @@ init(nil: ref Draw->Context, args: list of string) argdefine(arg->earg(), 1); 'U' => undefine(arg->earg()); + 'p' => + arg->earg(); + 't' => + ; * => arg->usage(); } @@ -157,7 +180,8 @@ error(s: string) ios := hd instack; where = sys->sprint(" %s:%d:", ios.name, ios.line); } - sys->fprint(sys->fildes(2), "m4:%s %s\n", where, s); + bout.flush(); + sys->fprint(stderr, "m4:%s %s\n", where, s); raise "fail:error"; } @@ -191,9 +215,12 @@ called(c: int) curarg = ref Param(""); nesting := 0; # () depth skipws(); + mark := instack; for(;;){ - if((c = getc()) < 0) + if((c = getc()) < 0) { + instack = mark; error("EOF in parameters"); + } if(isalpha(c)) called(c); else if(c == lquote) @@ -228,9 +255,12 @@ called(c: int) quoted() { nesting :=0; + mark := instack; while((c := getc()) != rquote || nesting > 0){ - if(c < 0) + if(c < 0) { + instack = mark; error("EOF in string"); + } if(c == rquote) nesting--; else if(c == lquote) @@ -276,19 +306,9 @@ isspace(c: int): int return c == ' ' || c == '\t' || c == '\n' || c == '\r'; } -isname(s: string): int -{ - if(s == nil || !isalpha(s[0])) - return 0; - for(i := 1; i < len s; i++) - if(!(isalpha(s[i]) || s[i]>='0' && s[i]<='9')) - return 0; - return 1; -} - isalpha(c: int): int { - return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c > 16rA0; + return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c > 16rA0 && c != lquote && c != rquote; } hash(name: string): int @@ -301,6 +321,13 @@ hash(name: string): int builtin(name: string, impl: ref fn(nil: array of string)) { + if(prefix != "") + name = prefix+name; + ibuiltin(name, impl); +} + +ibuiltin(name: string, impl: ref fn(nil: array of string)) +{ h := hash(name); n := ref Name(name, nil, impl, 0, 0); names[h] = n :: names[h]; @@ -418,6 +445,12 @@ putc(c: int) expand(def: ref Name, args: array of string) { + if(tracing){ + sys->fprint(stderr, "expand %s [%s]", args[0], def.name); + for(i := 1; i < len args; i++) + sys->fprint(stderr, " %d: [%s]", i, args[i]); + sys->fprint(stderr, "\n"); + } if(def.impl != nil){ def.impl(args); return; @@ -474,7 +507,7 @@ docopydef(args: array of string) if(n.impl == nil) define(args[2], n.repl, n.asis); else - builtin(args[2], n.impl); + ibuiltin(args[2], n.impl); }else define(args[2], "", 0); } @@ -524,12 +557,12 @@ doundivert(args: array of string) doifdef(args: array of string) { - if(len args < 2) + if(len args < 3) return; n := lookup(args[1]); if(n != nil) pushs(args[2]); - else if(len args > 2) + else if(len args > 3) pushs(args[3]); } @@ -642,7 +675,7 @@ doerrprint(args: array of string) for(i := 1; i < len args; i++) s += " "+args[i]; if(s != nil) - sys->fprint(sys->fildes(2), "m4:%s\n", s); + sys->fprint(stderr, "m4:%s\n", s); } dolen(args: array of string) diff --git a/appl/math/mersenne.b b/appl/math/mersenne.b index c90254b0..7efc4a97 100644 --- a/appl/math/mersenne.b +++ b/appl/math/mersenne.b @@ -3,9 +3,9 @@ implement Mersenne; include "sys.m"; sys : Sys; include "draw.m"; -include "keyring.m"; - keyring: Keyring; - IPint: import keyring; +include "ipints.m"; + ipints: IPints; + IPint: import ipints; # Test primality of Mersenne numbers @@ -17,7 +17,7 @@ Mersenne: module init(nil: ref Draw->Context, argv: list of string) { sys = load Sys Sys->PATH; - keyring = load Keyring Keyring->PATH; + ipints = load IPints IPints->PATH; p := 3; if(tl argv != nil) p = int hd tl argv; diff --git a/appl/math/parts.b b/appl/math/parts.b index 36c36d8e..be5cd1bb 100644 --- a/appl/math/parts.b +++ b/appl/math/parts.b @@ -3,9 +3,9 @@ implement Partitions; include "sys.m"; sys : Sys; include "draw.m"; -include "keyring.m"; - keyring: Keyring; - IPint: import keyring; +include "ipints.m"; + ipints: IPints; + IPint: import ipints; # # the number p(n) of partitions of n @@ -25,7 +25,7 @@ Partitions: module init(nil: ref Draw->Context, argv: list of string) { sys = load Sys Sys->PATH; - keyring = load Keyring Keyring->PATH; + ipints = load IPints IPints->PATH; argv = tl argv; while(argv != nil){ s := hd argv; |
