diff options
| -rw-r--r-- | CHANGES | 6 | ||||
| -rw-r--r-- | appl/cmd/lc.b | 156 | ||||
| -rw-r--r-- | appl/cmd/mathcalc.b | 79 | ||||
| -rw-r--r-- | dis/lc.dis | bin | 2247 -> 0 bytes | |||
| -rw-r--r-- | man/1/INDEX | 4 | ||||
| -rw-r--r-- | man/1/lc | 51 | ||||
| -rw-r--r-- | man/1/ls | 25 | ||||
| -rw-r--r-- | man/1/mathcalc | 97 |
8 files changed, 27 insertions, 391 deletions
@@ -1,5 +1,9 @@ 20070601 - /apl/cmd/auth/factotum/factotum.b: ignore empty writes, don't fail; make a few diagnostics match plan 9 + /appl/cmd/auth/factotum/factotum.b: ignore empty writes, don't fail; make a few diagnostics match plan 9 + rename /appl/cmd/mc.b to /appl/cmd/calc.b; also /man/1/mc to /man/1/calc; /dis/mc.dis to /dis/calc.dis + add /appl/cmd/mc.b (initial version) + replace /dis/lc.dis by /dis/lc; remove /appl/cmd/lc.b + remove /appl/cmd/mathcalc.b /dis/mathcalc.dis /man/1/mathcalc 20070510 quickly remove references to udp's "oldheaders" because plan 9 removed it remove obootpd completely diff --git a/appl/cmd/lc.b b/appl/cmd/lc.b deleted file mode 100644 index de5ec579..00000000 --- a/appl/cmd/lc.b +++ /dev/null @@ -1,156 +0,0 @@ -implement Lc; - -include "sys.m"; - sys: Sys; -include "draw.m"; -include "readdir.m"; - readdir: Readdir; -include "bufio.m"; - bufio: Bufio; - Iobuf: import bufio; - -Lc: module { - init: fn(nil: ref Draw->Context, argv: list of string); -}; - -t_FILE, t_DIR, t_NUMTYPES: con iota; -columns := 65; -stderr: ref Sys->FD; -stdout: ref Iobuf; - -usage() -{ - sys->fprint(stderr, "usage: lc [-df] [-c columns] [file ...]\n"); - raise "fail:usage"; -} - -init(nil: ref Draw->Context, argv: list of string) -{ - sys = load Sys Sys->PATH; - stderr = sys->fildes(2); - readdir = load Readdir Readdir->PATH; - if (readdir == nil) { - sys->fprint(stderr, "lc: cannot load %s: %r\n", Readdir->PATH); - raise "fail:bad module"; - } - bufio = load Bufio Bufio->PATH; - stdout = bufio->fopen(sys->fildes(1), Sys->OWRITE); - if (bufio == nil) { - sys->fprint(stderr, "lc: cannot load %s: %r\n", Bufio->PATH); - raise "fail:bad module"; - } - if (argv == nil) - return; - argv = tl argv; - flags := 0; -loop: while (argv != nil && hd argv != nil && (hd argv)[0] == '-') { - s := (hd argv)[1:]; - argv = tl argv; - flagloop: for (; s != nil; s = s[1:]) { - case s[0] { - '-' => - break loop; - 'd' => - flags |= 1 << t_DIR; - 'f' => - flags |= 1 << t_FILE; - 'c' => - if (len s > 1) { - columns = int s[1:]; - break flagloop; - } - if (argv == nil) - usage(); - columns = int hd argv; - argv = tl argv; - * => - usage(); - } - } - } - - headings := 0; - if (flags == 0) { - flags = (1<<t_DIR)|(1<<t_FILE); - headings = 1; - } - if (argv == nil) - argv = "." :: nil; - multi := tl argv != nil; - nondir: list of string; - for (; argv != nil; argv = tl argv) { - dname := hd argv; - (ok, dir) := sys->stat(dname); - if(ok < 0) { - sys->fprint(stderr, "lc: can't stat %s: %r\n", hd argv); - continue; - } - if (dir.mode & Sys->DMDIR) { - (d, n) := readdir->init(hd argv, Readdir->NAME | Readdir->COMPACT); - if (n < 0) - sys->fprint(stderr, "lc: cannot read %s: %r\n", hd argv); - else { - indent := 0; - if (multi && headings) { - stdout.puts(hd argv + "/\n"); - indent = 2; - } - l: list of string = nil; - for (i := 0; i < n; i++) { - s := d[i].name; - if (!headings && dname != ".") - s = dname + "/" + s; - if (d[i].mode & Sys->DMDIR) { - if (flags & (1<<t_DIR)) - l = s + "/" :: l; - } else if (flags & (1<<t_FILE)) - l = s :: l; - } - d = nil; - lc(l, indent); - } - } else if (flags & (1 << t_FILE)) - nondir = dname :: nondir; - } - lc(nondir, 0); - stdout.close(); -} - -lc(dl: list of string, indent: int) -{ - a := array[len dl] of string; - j := len a - 1; - maxwidth := 0; - for (; dl != nil; dl = tl dl) { - s := hd dl; - a[j--] = s; - if (len s > maxwidth) - maxwidth = len s; - } - outcols(a, maxwidth, indent); -} - -outcols(stuff: array of string, maxwidth, indent: int) -{ - num := len stuff; - cols := columns - indent; - numcols := cols / (maxwidth + 1); - colwidth: int; - if (numcols == 0) { - numcols = 1; - colwidth = maxwidth; - } else - colwidth = cols / numcols; - numrows := (num + numcols - 1) / numcols; - - for (i := 0; i < numrows; i++) { - if (indent) - stdout.puts(sys->sprint("%*s", indent, "")); - for (j := i; j < num; j += numrows) { - if (j + numrows < num) - stdout.puts(sys->sprint("%*.*s", -colwidth, colwidth, stuff[j])); - else - stdout.puts(sys->sprint("%.*s\n", colwidth, stuff[j])); - } - } -} diff --git a/appl/cmd/mathcalc.b b/appl/cmd/mathcalc.b deleted file mode 100644 index 4f4f475f..00000000 --- a/appl/cmd/mathcalc.b +++ /dev/null @@ -1,79 +0,0 @@ -implement MathCalc; - -include "sys.m"; - sys: Sys; - -include "draw.m"; - -include "tk.m"; - tk: Tk; - -include "bufio.m"; - bufmod : Bufio; -Iobuf : import bufmod; - -include "../lib/tcl.m"; - -include "tcllib.m"; - - -MathCalc : module -{ - init: fn(nil: ref Draw->Context, nil: list of string); -}; - -CALCPATH: con "/dis/lib/tcl_calc.dis"; - -init(nil: ref Draw->Context, nil: list of string) -{ - sys = load Sys Sys->PATH; - cal := load TclLib CALCPATH; - if (cal==nil){ - sys->print("mathcalc: can't load %s: %r\n", CALCPATH); - exit; - } - bufmod = load Bufio Bufio->PATH; - if (bufmod==nil){ - sys->print("bufmod load %r\n"); - exit; - } - iob := bufmod->fopen(sys->fildes(0),bufmod->OREAD); - if (iob==nil){ - sys->print("mathcalc: cannot open stdin for reading: %r\n"); - return; - } - input : string; - new_inp := "calc%"; - sys->print("%s ", new_inp); - while((input=iob.gets('\n'))!=nil){ - input=input[0:len input -1]; - if (input=="quit") - exit; - arr:=array[] of {input}; - (i,msg):=cal->exec(nil,arr); - if (msg!=nil) - sys->print("%s\n",msg); - sys->print("%s ", new_inp); - } - -} - - -# expr0 : expr1 -# | expr0 '+' expr0 -# | expr0 '-' expr0 -# ; -# -# expr1 : expr2 -# | expr1 '*' expr1 -# | expr1 '/' expr1 -# ; -# -# expr2 : '-' expr2 -# | '+' expr2 -# | expr3 -# ; -# -# expr3 : INT -# | REAL -# ; diff --git a/dis/lc.dis b/dis/lc.dis Binary files differdeleted file mode 100644 index 81413ba6..00000000 --- a/dis/lc.dis +++ /dev/null diff --git a/man/1/INDEX b/man/1/INDEX index 58815344..3d907507 100644 --- a/man/1/INDEX +++ b/man/1/INDEX @@ -25,6 +25,7 @@ unmount bind blur blur brutus brutus cal cal +calc calc calendar calendar cat cat cd cd @@ -93,7 +94,6 @@ keyboard keyboard pen keyboard broke kill kill kill -lc lc limbo limbo dial listen listen listen @@ -101,6 +101,7 @@ styxlisten listen logon logon logwindow logwindow look look +lc ls ls ls lookman man man man @@ -126,7 +127,6 @@ pi math-misc powers math-misc primes math-misc sieve math-misc -mathcalc mathcalc mc mc mdb mdb miniterm miniterm diff --git a/man/1/lc b/man/1/lc deleted file mode 100644 index 005e6968..00000000 --- a/man/1/lc +++ /dev/null @@ -1,51 +0,0 @@ -.TH LC 1 -.SH NAME -lc \- list files in columns -.SH SYNOPSIS -.B lc -[ -.B -df -] [ -.B -c -.I columns -] [ -.IR file ... -] -.SH DESCRIPTION -.I Lc -lists in columns the contents of each -.I file -that is a directory. If there is more than -.I file -and neither the -.B -d -or -.B -f -options are given, then the output for each -directory will be indented, and preceded by the -directory's name. After the listings for each directory, -the rest of the -.IR file s -are listed. If either the -.B -d -or -.B -f -options are given, directory headings are omitted and -each file is shown in full (with its containing directory); -.B -d -causes directories to be listed; -.B -f -causes files to be listed. -.I Columns -is an integer specifying the number of character widths -into which -.IR lc 's -output is formatted (default 65). -.SH SOURCE -.B /appl/cmd/lc.b -.SH SEE ALSO -.IR ls (1), -.IR readdir (2) -.SH BUGS -.I Lc -assumes a fixed-width font. @@ -1,6 +1,6 @@ .TH LS 1 .SH NAME -ls \- list files +ls, lc \- list files .SH SYNOPSIS .B ls [ @@ -8,8 +8,15 @@ ls \- list files ] [ .IR file ... ] +.LP +.B lc +[ +.B -lpmnqduntscr +] [ +.IR file ... +] .SH DESCRIPTION -.B Ls +.I Ls lists the named .IR file s in an order and format determined by its options. @@ -134,10 +141,18 @@ Sort by size (smallest first). .TP .B -r Reverse the sort order. +.PP +.I Lc +is the same as +.IR ls , +but sets the +.B -p +option and pipes the output through +.IR mc (1). .SH SOURCE .B /appl/cmd/ls.b +.br +.B /dis/lc .SH SEE ALSO .IR readdir (2), -.IR lc (1) - - +.IR mc (1) diff --git a/man/1/mathcalc b/man/1/mathcalc deleted file mode 100644 index 913ec71e..00000000 --- a/man/1/mathcalc +++ /dev/null @@ -1,97 +0,0 @@ -.TH MATHCALC 1 -.SH NAME -mathcalc \- interface to a TclLib calculator module -.SH SYNOPSIS -.B mathcalc -.SH DESCRIPTION -.I Mathcalc -reads simple expressions from the standard input, evaluates them, -and prints the results on the standard output. -It is a command line interface to a -.L TclLib -calculator module. -It prompts the user -.RL ( calc% ) -for each line, and -exits on end-of-file or on reading a line containing -.RB ` quit '. -.PP -Values are either integer or floating-point constants. -A floating-point constant has a decimal point, an exponent, or both. -Integer constants are taken as hexadecimal if they start -.BR 0x , -octal if they start with -.BR 0 , -and otherwise decimal. -.PP -Expressions are formed using the following C-like operators -and predefined functions, shown in order of decreasing priority: -.TP -.B - + ! ~ -unary: negate, plus (no-op); logical not and one's complement (integers only) -.TP -.B * / % -multiply and divide, integer remainder -.TP -.B + - -add, subtract -.TP -.B << >> -left shift, right shift (integers only) -.TP -.B < <= >= > -relational operators -.TP -.B == != -equality, inequality -.TP -.B & -bit-wise and (integer only) -.TP -.B ^ -bit-wise exclusive-OR (integer only) -.TP -.B | -bit-wise or (integer only) -.TP -.B && -logical and -.TP -.B || -logical or -.TP -.IB a ? b : c -conditional: if -.I a -is non-zero, the result is -.IR b , -otherwise -.I c -.PP -.I Mathcalc -provides the following mathematical functions: -.IP -.EX -.ta +\w'hypot\ \ 'u -abs ceil fmod sin -acos cos hypot sinh -asin cosh log sqrt -atan exp log10 tan -atan2 floor pow tanh -.EE -.PP -See -.IR math-elem (2) -for the usual definitions. -.SH SOURCE -.B /appl/cmd/mathcalc.b -.br -.B /appl/lib/tcl_calc.b -.SH DIAGNOSTICS -.TF ARGXXX -.TP -.B ARRG! -bad constant syntax -.TP -.B Error! -bad expression syntax, or any other error |
