home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| NWiper Show (other/nWiperShow)
| ext
| Unsupported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document, ASCII text, with CR line terminators
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[CR]
| default (weak)
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [MPS ] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 25 20 43 6f 70 79 72 69 | 67 68 74 20 31 39 39 31 |% Copyri|ght 1991|
|00000010| 20 62 79 20 4e 6f 72 6d | 61 6e 20 52 61 6d 73 65 | by Norm|an Ramse|
|00000020| 79 2e 20 20 41 6c 6c 20 | 72 69 67 68 74 73 20 72 |y. All |rights r|
|00000030| 65 73 65 72 76 65 64 2e | 0d 25 20 53 65 65 20 66 |eserved.|.% See f|
|00000040| 69 6c 65 20 43 4f 50 59 | 52 49 47 48 54 20 66 6f |ile COPY|RIGHT fo|
|00000050| 72 20 6d 6f 72 65 20 69 | 6e 66 6f 72 6d 61 74 69 |r more i|nformati|
|00000060| 6f 6e 2e 0d 5c 73 65 63 | 74 69 6f 6e 7b 43 6f 6e |on..\sec|tion{Con|
|00000070| 76 65 72 74 69 6e 67 20 | 61 20 7b 5c 74 74 20 6e |verting |a {\tt n|
|00000080| 6f 77 65 62 7d 20 66 69 | 6c 65 20 74 6f 20 74 6f |oweb} fi|le to to|
|00000090| 6f 6c 20 6d 61 72 6b 75 | 70 7d 0d 5c 73 75 62 73 |ol marku|p}.\subs|
|000000a0| 65 63 74 69 6f 6e 7b 4d | 61 69 6e 20 70 72 6f 67 |ection{M|ain prog|
|000000b0| 72 61 6d 7d 0d 54 68 69 | 73 20 69 73 20 74 68 65 |ram}.Thi|s is the|
|000000c0| 20 69 6e 69 74 69 61 6c | 20 66 69 6c 74 65 72 20 | initial| filter |
|000000d0| 69 6e 20 74 68 65 20 70 | 69 70 65 6c 69 6e 65 2e |in the p|ipeline.|
|000000e0| 0d 53 79 6e 74 61 78 20 | 66 72 6f 6d 20 7b 5c 74 |.Syntax |from {\t|
|000000f0| 74 20 6d 61 72 6b 75 70 | 2e 6f 77 7d 2e 0d 4f 75 |t markup|.ow}..Ou|
|00000100| 74 70 75 74 20 6d 61 79 | 20 63 6f 6e 74 61 69 6e |tput may| contain|
|00000110| 20 5b 5b 0d 20 20 20 20 | 20 20 20 20 40 5b 62 65 | [[. | @[be|
|00000120| 67 69 6e 7c 65 6e 64 5d | 20 5b 63 6f 64 65 7c 64 |gin|end]| [code|d|
|00000130| 6f 63 73 5d 20 6e 6e 6e | 20 2e 2e 2e 0d 20 20 20 |ocs] nnn| .... |
|00000140| 20 20 20 20 20 40 74 65 | 78 74 20 3c 6c 69 6e 65 | @te|xt <line|
|00000150| 20 6f 66 20 74 65 78 74 | 3e 0d 20 20 20 20 20 20 | of text|>. |
|00000160| 20 20 40 71 75 6f 74 65 | 0d 20 20 20 20 20 20 20 | @quote|. |
|00000170| 20 40 65 6e 64 71 75 6f | 74 65 0d 20 20 20 20 20 | @endquo|te. |
|00000180| 20 20 20 40 64 65 66 6e | 20 3c 6d 6f 64 75 6c 65 | @defn| <module|
|00000190| 20 6e 61 6d 65 3e 0d 20 | 20 20 20 20 20 20 20 40 | name>. | @|
|000001a0| 75 73 65 20 3c 6d 6f 64 | 75 6c 65 20 6e 61 6d 65 |use <mod|ule name|
|000001b0| 3e 0d 20 20 20 20 20 20 | 20 20 40 6e 6c 0d 20 20 |>. | @nl. |
|000001c0| 20 20 20 20 20 20 40 66 | 69 6c 65 20 3c 66 69 6c | @f|ile <fil|
|000001d0| 65 6e 61 6d 65 3e 0d 20 | 20 20 20 20 20 20 20 40 |ename>. | @|
|000001e0| 6c 69 6e 65 20 6e 6e 6e | 0d 09 40 69 6e 64 65 78 |line nnn|..@index|
|000001f0| 20 5b 64 65 66 6e 7c 75 | 73 65 5d 20 3c 69 6e 64 | [defn|u|se] <ind|
|00000200| 65 78 65 64 20 73 74 72 | 69 6e 67 3e 0d 09 40 69 |exed str|ing>..@i|
|00000210| 6e 64 65 78 20 6e 6c 09 | 0d 09 40 6c 69 74 65 72 |ndex nl.|..@liter|
|00000220| 61 6c 20 3c 6c 69 74 65 | 72 61 6c 20 74 65 78 74 |al <lite|ral text|
|00000230| 20 66 6f 72 20 77 65 61 | 76 65 20 6f 72 20 6f 74 | for wea|ve or ot|
|00000240| 68 65 72 20 74 6f 6f 6c | 3e 0d 5d 5d 0d 48 65 72 |her tool|>.]].Her|
|00000250| 65 27 73 20 74 68 65 20 | 63 6f 64 65 20 74 68 61 |e's the |code tha|
|00000260| 74 20 77 72 69 74 65 73 | 20 74 68 65 20 6f 75 74 |t writes| the out|
|00000270| 70 75 74 2e 0d 57 65 20 | 68 61 76 65 20 6f 6e 65 |put..We |have one|
|00000280| 20 66 75 6e 63 74 69 6f | 6e 20 74 6f 20 70 72 69 | functio|n to pri|
|00000290| 6e 74 20 74 68 65 20 73 | 74 61 74 65 2c 20 77 68 |nt the s|tate, wh|
|000002a0| 69 63 68 20 74 61 6b 65 | 73 20 63 61 72 65 20 6f |ich take|s care o|
|000002b0| 66 0d 5b 5b 40 62 65 67 | 69 6e 5d 5d 20 61 6e 64 |f.[[@beg|in]] and|
|000002c0| 20 5b 5b 40 65 6e 64 5d | 5d 20 61 6e 64 20 72 65 | [[@end]|] and re|
|000002d0| 6d 65 6d 62 65 72 69 6e | 67 20 77 68 61 74 20 6b |memberin|g what k|
|000002e0| 69 6e 64 20 6f 66 20 63 | 68 75 6e 6b 20 77 65 20 |ind of c|hunk we |
|000002f0| 68 61 76 65 2e 0d 41 6e | 6f 74 68 65 72 20 66 75 |have..An|other fu|
|00000300| 6e 63 74 69 6f 6e 20 70 | 72 69 6e 74 73 20 5b 5b |nction p|rints [[|
|00000310| 40 6e 61 6d 65 20 76 61 | 6c 75 65 5d 5d 20 70 61 |@name va|lue]] pa|
|00000320| 69 72 73 2e 0d 49 66 20 | 74 68 65 20 5b 5b 76 61 |irs..If |the [[va|
|00000330| 6c 75 65 5d 5d 20 68 61 | 73 20 61 20 74 72 61 69 |lue]] ha|s a trai|
|00000340| 6c 69 6e 67 20 6e 65 77 | 6c 69 6e 65 2c 20 74 68 |ling new|line, th|
|00000350| 65 20 70 61 69 72 20 69 | 73 20 66 6f 6c 6c 6f 77 |e pair i|s follow|
|00000360| 65 64 20 62 79 20 5b 5b | 40 6e 6c 5d 5d 2e 0d 0d |ed by [[|@nl]]...|
|00000370| 49 66 20 74 68 65 20 6f | 6e 6c 79 20 77 61 79 20 |If the o|nly way |
|00000380| 69 6e 64 65 78 20 65 6e | 74 72 69 65 73 20 77 65 |index en|tries we|
|00000390| 72 65 20 63 72 65 61 74 | 65 64 20 77 61 73 20 62 |re creat|ed was b|
|000003a0| 79 20 74 6f 6f 6c 73 2c | 20 6c 69 66 65 20 77 6f |y tools,| life wo|
|000003b0| 75 6c 64 20 62 65 20 65 | 61 73 79 2e 0d 50 65 72 |uld be e|asy..Per|
|000003c0| 6d 69 74 74 69 6e 67 20 | 69 6e 64 65 78 20 64 65 |mitting |index de|
|000003d0| 66 69 6e 69 74 69 6f 6e | 73 20 69 6e 20 74 68 65 |finition|s in the|
|000003e0| 20 69 6e 70 75 74 20 63 | 61 75 73 65 73 20 74 77 | input c|auses tw|
|000003f0| 6f 20 63 6f 6d 70 6c 69 | 63 61 74 69 6f 6e 73 2e |o compli|cations.|
|00000400| 0d 46 69 72 73 74 2c 20 | 69 74 20 69 6e 74 72 6f |.First, |it intro|
|00000410| 64 75 63 65 73 20 6e 65 | 77 6c 69 6e 65 73 20 74 |duces ne|wlines t|
|00000420| 68 61 74 20 64 6f 6e 27 | 74 20 62 65 6c 6f 6e 67 |hat don'|t belong|
|00000430| 20 74 6f 20 61 6e 79 20 | 63 68 75 6e 6b 2c 20 62 | to any |chunk, b|
|00000440| 75 74 20 74 68 61 74 20 | 6d 75 73 74 20 62 65 20 |ut that |must be |
|00000450| 63 6f 75 6e 74 65 64 2e | 0d 53 65 63 6f 6e 64 2c |counted.|.Second,|
|00000460| 20 69 74 20 69 6e 74 72 | 6f 64 75 63 65 73 20 61 | it intr|oduces a|
|00000470| 20 73 70 65 63 69 61 6c | 20 73 74 61 74 65 2c 20 | special| state, |
|00000480| 5b 5b 43 6f 64 65 49 6e | 64 65 78 5d 5d 0d 69 6e |[[CodeIn|dex]].in|
|00000490| 20 77 68 69 63 68 20 61 | 20 63 6f 64 65 20 63 68 | which a| code ch|
|000004a0| 75 6e 6b 20 69 73 20 61 | 62 6f 75 74 20 74 6f 20 |unk is a|bout to |
|000004b0| 62 65 20 74 65 72 6d 69 | 6e 61 74 65 64 0d 62 75 |be termi|nated.bu|
|000004c0| 74 20 77 6f 6e 27 74 20 | 62 65 20 75 6e 74 69 6c |t won't |be until|
|000004d0| 20 74 68 65 72 65 20 61 | 72 65 20 6e 6f 20 6d 6f | there a|re no mo|
|000004e0| 72 65 20 69 6e 64 65 78 | 20 64 65 66 69 6e 69 74 |re index| definit|
|000004f0| 69 6f 6e 73 2e 0d 3c 3c | 73 74 61 74 65 20 61 6e |ions..<<|state an|
|00000500| 64 20 70 72 69 6e 74 69 | 6e 67 20 64 65 66 69 6e |d printi|ng defin|
|00000510| 69 74 69 6f 6e 73 3e 3e | 3d 0d 74 79 70 65 64 65 |itions>>|=.typede|
|00000520| 66 20 65 6e 75 6d 20 73 | 74 61 74 65 20 7b 43 6f |f enum s|tate {Co|
|00000530| 64 65 3d 31 2c 20 44 6f | 63 73 3d 32 2c 20 43 6f |de=1, Do|cs=2, Co|
|00000540| 64 65 49 6e 64 65 78 3d | 33 7d 20 53 74 61 74 65 |deIndex=|3} State|
|00000550| 3b 0d 74 79 70 65 64 65 | 66 20 65 6e 75 6d 20 6d |;.typede|f enum m|
|00000560| 61 72 6b 20 7b 42 65 67 | 69 6e 3d 31 2c 20 45 6e |ark {Beg|in=1, En|
|00000570| 64 3d 32 7d 20 4d 61 72 | 6b 3b 0d 74 79 70 65 64 |d=2} Mar|k;.typed|
|00000580| 65 66 20 65 6e 75 6d 20 | 69 6e 64 65 78 20 7b 44 |ef enum |index {D|
|00000590| 65 66 6e 3d 31 2c 20 55 | 73 65 3d 32 2c 20 4e 65 |efn=1, U|se=2, Ne|
|000005a0| 77 6c 69 6e 65 3d 33 7d | 20 49 6e 64 65 78 3b 0d |wline=3}| Index;.|
|000005b0| 0d 73 74 61 74 69 63 20 | 63 68 61 72 20 2a 73 74 |.static |char *st|
|000005c0| 61 74 65 73 5b 5d 20 20 | 3d 20 7b 20 22 62 61 64 |ates[] |= { "bad|
|000005d0| 20 73 74 61 74 65 22 2c | 20 22 63 6f 64 65 22 2c | state",| "code",|
|000005e0| 20 22 64 6f 63 73 22 2c | 20 22 63 6f 64 65 22 20 | "docs",| "code" |
|000005f0| 7d 3b 0d 73 74 61 74 69 | 63 20 63 68 61 72 20 2a |};.stati|c char *|
|00000600| 6d 61 72 6b 73 5b 5d 20 | 20 20 3d 20 7b 20 22 62 |marks[] | = { "b|
|00000610| 61 64 20 6d 61 72 6b 22 | 2c 20 22 62 65 67 69 6e |ad mark"|, "begin|
|00000620| 22 2c 20 22 65 6e 64 22 | 20 7d 3b 0d 73 74 61 74 |", "end"| };.stat|
|00000630| 69 63 20 63 68 61 72 20 | 2a 69 6e 64 69 63 65 73 |ic char |*indices|
|00000640| 5b 5d 20 3d 20 7b 20 22 | 62 61 64 20 69 6e 64 65 |[] = { "|bad inde|
|00000650| 78 22 2c 20 22 64 65 66 | 6e 22 2c 20 22 75 73 65 |x", "def|n", "use|
|00000660| 22 2c 20 22 6e 6c 22 20 | 7d 3b 0d 73 74 61 74 69 |", "nl" |};.stati|
|00000670| 63 20 63 68 61 72 20 6c | 6f 77 5f 61 74 5f 73 69 |c char l|ow_at_si|
|00000680| 67 6e 20 3d 20 27 40 27 | 3b 0d 0d 73 74 61 74 69 |gn = '@'|;..stati|
|00000690| 63 20 76 6f 69 64 20 70 | 72 69 6e 74 5f 73 74 61 |c void p|rint_sta|
|000006a0| 74 65 28 46 49 4c 45 20 | 2a 6f 75 74 2c 20 4d 61 |te(FILE |*out, Ma|
|000006b0| 72 6b 20 62 65 2c 20 53 | 74 61 74 65 20 73 74 61 |rk be, S|tate sta|
|000006c0| 74 65 2c 20 69 6e 74 20 | 63 6f 75 6e 74 29 20 7b |te, int |count) {|
|000006d0| 0d 20 20 20 20 66 70 72 | 69 6e 74 66 28 6f 75 74 |. fpr|intf(out|
|000006e0| 2c 20 22 25 63 25 73 20 | 25 73 20 25 64 5c 6e 22 |, "%c%s |%s %d\n"|
|000006f0| 2c 20 6c 6f 77 5f 61 74 | 5f 73 69 67 6e 2c 20 6d |, low_at|_sign, m|
|00000700| 61 72 6b 73 5b 62 65 5d | 2c 20 73 74 61 74 65 73 |arks[be]|, states|
|00000710| 5b 73 74 61 74 65 5d 2c | 20 63 6f 75 6e 74 29 3b |[state],| count);|
|00000720| 0d 7d 0d 0d 73 74 61 74 | 69 63 20 76 6f 69 64 20 |.}..stat|ic void |
|00000730| 70 72 69 6e 74 5f 69 6e | 64 65 78 28 46 49 4c 45 |print_in|dex(FILE|
|00000740| 20 2a 6f 75 74 2c 20 49 | 6e 64 65 78 20 69 64 78 | *out, I|ndex idx|
|00000750| 2c 20 63 68 61 72 20 2a | 61 72 67 29 20 7b 0d 20 |, char *|arg) {. |
|00000760| 20 20 20 69 66 20 28 61 | 72 67 29 0d 20 20 20 20 | if (a|rg). |
|00000770| 20 20 20 20 66 70 72 69 | 6e 74 66 28 6f 75 74 2c | fpri|ntf(out,|
|00000780| 20 22 25 63 69 6e 64 65 | 78 20 25 73 20 25 73 5c | "%cinde|x %s %s\|
|00000790| 6e 22 2c 20 6c 6f 77 5f | 61 74 5f 73 69 67 6e 2c |n", low_|at_sign,|
|000007a0| 20 69 6e 64 69 63 65 73 | 5b 69 64 78 5d 2c 20 61 | indices|[idx], a|
|000007b0| 72 67 29 3b 0d 20 20 20 | 20 65 6c 73 65 0d 20 20 |rg);. | else. |
|000007c0| 20 20 20 20 20 20 66 70 | 72 69 6e 74 66 28 6f 75 | fp|rintf(ou|
|000007d0| 74 2c 20 22 25 63 69 6e | 64 65 78 20 25 73 5c 6e |t, "%cin|dex %s\n|
|000007e0| 22 2c 20 20 20 20 6c 6f | 77 5f 61 74 5f 73 69 67 |", lo|w_at_sig|
|000007f0| 6e 2c 20 69 6e 64 69 63 | 65 73 5b 69 64 78 5d 29 |n, indic|es[idx])|
|00000800| 3b 0d 7d 0d 0d 73 74 61 | 74 69 63 20 76 6f 69 64 |;.}..sta|tic void|
|00000810| 20 70 72 69 6e 74 5f 70 | 61 69 72 28 46 49 4c 45 | print_p|air(FILE|
|00000820| 20 2a 6f 75 74 2c 20 63 | 68 61 72 20 2a 6e 61 6d | *out, c|har *nam|
|00000830| 65 2c 20 63 68 61 72 20 | 2a 76 61 6c 75 65 29 20 |e, char |*value) |
|00000840| 7b 0d 20 20 20 20 69 66 | 20 28 76 61 6c 75 65 29 |{. if| (value)|
|00000850| 20 7b 0d 20 20 20 20 20 | 20 20 20 69 6e 74 20 6c | {. | int l|
|00000860| 61 73 74 3d 73 74 72 6c | 65 6e 28 76 61 6c 75 65 |ast=strl|en(value|
|00000870| 29 2d 31 3b 0d 20 20 20 | 20 20 20 20 20 69 66 20 |)-1;. | if |
|00000880| 28 6c 61 73 74 3e 3d 30 | 20 26 26 20 76 61 6c 75 |(last>=0| && valu|
|00000890| 65 5b 6c 61 73 74 5d 3d | 3d 27 5c 6e 27 29 0d 20 |e[last]=|='\n'). |
|000008a0| 20 20 20 20 20 20 20 20 | 20 20 20 66 70 72 69 6e | | fprin|
|000008b0| 74 66 28 6f 75 74 2c 20 | 22 25 63 25 73 20 25 73 |tf(out, |"%c%s %s|
|000008c0| 25 63 6e 6c 5c 6e 22 2c | 20 6c 6f 77 5f 61 74 5f |%cnl\n",| low_at_|
|000008d0| 73 69 67 6e 2c 20 6e 61 | 6d 65 2c 20 76 61 6c 75 |sign, na|me, valu|
|000008e0| 65 2c 20 6c 6f 77 5f 61 | 74 5f 73 69 67 6e 29 3b |e, low_a|t_sign);|
|000008f0| 0d 20 20 20 20 20 20 20 | 20 65 6c 73 65 0d 20 20 |. | else. |
|00000900| 20 20 20 20 20 20 20 20 | 20 20 66 70 72 69 6e 74 | | fprint|
|00000910| 66 28 6f 75 74 2c 20 22 | 25 63 25 73 20 25 73 5c |f(out, "|%c%s %s\|
|00000920| 6e 22 2c 20 6c 6f 77 5f | 61 74 5f 73 69 67 6e 2c |n", low_|at_sign,|
|00000930| 20 6e 61 6d 65 2c 20 76 | 61 6c 75 65 29 3b 0d 20 | name, v|alue);. |
|00000940| 20 20 20 7d 20 65 6c 73 | 65 0d 20 20 20 20 20 20 | } els|e. |
|00000950| 20 20 66 70 72 69 6e 74 | 66 28 6f 75 74 2c 20 22 | fprint|f(out, "|
|00000960| 25 63 25 73 5c 6e 22 2c | 20 6c 6f 77 5f 61 74 5f |%c%s\n",| low_at_|
|00000970| 73 69 67 6e 2c 20 6e 61 | 6d 65 29 3b 0d 7d 0d 40 |sign, na|me);.}.@|
|00000980| 20 25 64 65 66 20 73 74 | 61 74 65 20 6d 61 72 6b | %def st|ate mark|
|00000990| 20 69 6e 64 65 78 20 70 | 72 69 6e 74 5f 73 74 61 | index p|rint_sta|
|000009a0| 74 65 20 70 72 69 6e 74 | 5f 69 6e 64 65 78 20 70 |te print|_index p|
|000009b0| 72 69 6e 74 5f 70 61 69 | 72 0d 3c 3c 2a 3e 3e 3d |rint_pai|r.<<*>>=|
|000009c0| 0d 23 69 6e 63 6c 75 64 | 65 20 3c 73 74 64 69 6f |.#includ|e <stdio|
|000009d0| 2e 68 3e 0d 23 69 6e 63 | 6c 75 64 65 20 3c 73 74 |.h>.#inc|lude <st|
|000009e0| 64 6c 69 62 2e 68 3e 0d | 23 69 6e 63 6c 75 64 65 |dlib.h>.|#include|
|000009f0| 20 3c 73 74 72 69 6e 67 | 2e 68 3e 0d 23 69 6e 63 | <string|.h>.#inc|
|00000a00| 6c 75 64 65 20 3c 63 74 | 79 70 65 2e 68 3e 0d 23 |lude <ct|ype.h>.#|
|00000a10| 69 6e 63 6c 75 64 65 20 | 22 65 72 72 6f 72 73 2e |include |"errors.|
|00000a20| 68 22 0d 23 69 6e 63 6c | 75 64 65 20 22 6d 61 72 |h".#incl|ude "mar|
|00000a30| 6b 75 70 2e 68 22 0d 23 | 69 6e 63 6c 75 64 65 20 |kup.h".#|include |
|00000a40| 22 67 65 74 6c 69 6e 65 | 2e 68 22 0d 23 69 6e 63 |"getline|.h".#inc|
|00000a50| 6c 75 64 65 20 22 63 6f | 6c 75 6d 6e 73 2e 68 22 |lude "co|lumns.h"|
|00000a60| 0d 0d 3c 3c 73 74 61 74 | 65 20 61 6e 64 20 70 72 |..<<stat|e and pr|
|00000a70| 69 6e 74 69 6e 67 20 64 | 65 66 69 6e 69 74 69 6f |inting d|efinitio|
|00000a80| 6e 73 3e 3e 0d 0d 76 6f | 69 64 20 6d 61 72 6b 75 |ns>>..vo|id marku|
|00000a90| 70 20 28 46 49 4c 45 2a | 20 69 6e 2c 20 46 49 4c |p (FILE*| in, FIL|
|00000aa0| 45 20 2a 6f 75 74 2c 20 | 63 68 61 72 20 2a 66 69 |E *out, |char *fi|
|00000ab0| 6c 65 6e 61 6d 65 29 20 | 7b 0d 20 20 20 20 53 74 |lename) |{. St|
|00000ac0| 61 74 65 20 73 74 61 74 | 65 20 3d 20 44 6f 63 73 |ate stat|e = Docs|
|00000ad0| 3b 20 20 20 20 20 20 20 | 20 20 2f 2a 20 77 68 61 |; | /* wha|
|00000ae0| 74 20 77 65 20 61 72 65 | 20 72 65 61 64 69 6e 67 |t we are| reading|
|00000af0| 20 2a 2f 0d 20 20 20 20 | 69 6e 74 20 71 75 6f 74 | */. |int quot|
|00000b00| 69 6e 67 20 3d 20 30 3b | 20 20 20 20 20 20 20 20 |ing = 0;| |
|00000b10| 20 20 20 20 2f 2a 20 63 | 75 72 72 65 6e 74 6c 79 | /* c|urrently|
|00000b20| 20 71 75 6f 74 69 6e 67 | 20 63 6f 64 65 3f 20 2a | quoting| code? *|
|00000b30| 2f 0d 20 20 20 20 69 6e | 74 20 63 6f 75 6e 74 20 |/. in|t count |
|00000b40| 3d 20 30 3b 20 20 20 20 | 20 20 20 20 20 20 20 20 |= 0; | |
|00000b50| 20 20 2f 2a 20 6e 75 6d | 62 65 72 20 6f 66 20 63 | /* num|ber of c|
|00000b60| 75 72 72 65 6e 74 20 63 | 68 75 6e 6b 2c 20 66 72 |urrent c|hunk, fr|
|00000b70| 6f 6d 20 30 20 2a 2f 0d | 20 20 20 20 69 6e 74 20 |om 0 */.| int |
|00000b80| 6d 69 73 73 69 6e 67 5f | 6e 65 77 6c 69 6e 65 3b |missing_|newline;|
|00000b90| 20 20 20 20 20 20 20 20 | 2f 2a 20 77 61 73 20 6c | |/* was l|
|00000ba0| 61 73 74 20 6c 69 6e 65 | 20 6d 69 73 73 69 6e 67 |ast line| missing|
|00000bb0| 20 61 20 74 72 61 69 6c | 69 6e 67 20 5c 6e 3f 20 | a trail|ing \n? |
|00000bc0| 2a 2f 0d 20 20 20 20 69 | 6e 74 20 6c 69 6e 65 6e |*/. i|nt linen|
|00000bd0| 6f 20 3d 20 30 3b 09 09 | 2f 2a 20 6e 75 6d 62 65 |o = 0;..|/* numbe|
|00000be0| 72 20 6f 66 20 6c 69 6e | 65 73 20 72 65 61 64 20 |r of lin|es read |
|00000bf0| 2a 2f 0d 20 20 20 20 69 | 6e 74 20 6c 61 73 74 5f |*/. i|nt last_|
|00000c00| 6f 70 65 6e 5f 71 75 6f | 74 65 3b 09 2f 2a 20 6c |open_quo|te;./* l|
|00000c10| 69 6e 65 20 6e 75 6d 62 | 65 72 20 6f 66 20 6c 61 |ine numb|er of la|
|00000c20| 73 74 20 75 6e 6d 61 74 | 63 68 65 64 20 6f 70 65 |st unmat|ched ope|
|00000c30| 6e 20 71 75 6f 74 65 20 | 2a 2f 0d 0d 20 20 20 20 |n quote |*/.. |
|00000c40| 63 68 61 72 20 2a 6c 69 | 6e 65 3b 20 20 20 20 20 |char *li|ne; |
|00000c50| 20 20 20 20 20 20 20 20 | 20 20 20 20 2f 2a 20 70 | | /* p|
|00000c60| 61 72 74 20 6f 66 20 6c | 69 6e 65 20 75 70 20 74 |art of l|ine up t|
|00000c70| 6f 20 6d 61 72 6b 20 28 | 6f 72 20 65 6e 64 29 20 |o mark (|or end) |
|00000c80| 2a 2f 0d 20 20 20 20 63 | 68 61 72 20 2a 6d 61 72 |*/. c|har *mar|
|00000c90| 6b 3b 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |k; | |
|00000ca0| 20 20 20 2f 2a 20 70 6f | 74 65 6e 74 69 61 6c 6c | /* po|tentiall|
|00000cb0| 79 20 6d 61 72 6b 65 64 | 20 70 61 72 74 20 6f 66 |y marked| part of|
|00000cc0| 20 6c 69 6e 65 20 2a 2f | 0d 23 64 65 66 69 6e 65 | line */|.#define|
|00000cd0| 20 4d 41 58 5f 4d 4f 44 | 4e 41 4d 45 20 32 35 35 | MAX_MOD|NAME 255|
|00000ce0| 0d 20 20 20 20 63 68 61 | 72 20 6d 6f 64 6e 61 6d |. cha|r modnam|
|00000cf0| 65 5b 4d 41 58 5f 4d 4f | 44 4e 41 4d 45 2b 31 5d |e[MAX_MO|DNAME+1]|
|00000d00| 20 3d 20 22 22 3b 20 2f | 2a 20 6e 61 6d 65 20 6f | = ""; /|* name o|
|00000d10| 66 20 6d 6f 64 75 6c 65 | 20 63 75 72 72 65 6e 74 |f module| current|
|00000d20| 6c 79 20 62 65 69 6e 67 | 20 72 65 61 64 2c 20 0d |ly being| read, .|
|00000d30| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000d40| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000d50| 20 20 20 20 20 20 20 20 | 20 5b 5b 22 22 5d 5d 20 | | [[""]] |
|00000d60| 69 66 20 6e 6f 20 6d 6f | 64 75 6c 65 20 69 73 20 |if no mo|dule is |
|00000d70| 62 65 69 6e 67 20 72 65 | 61 64 20 2a 2f 20 0d 0d |being re|ad */ ..|
|00000d80| 20 20 20 20 3c 3c 63 6f | 70 79 20 61 6c 6c 20 6c | <<co|py all l|
|00000d90| 69 6e 65 73 20 66 72 6f | 6d 20 5b 5b 69 6e 5d 5d |ines fro|m [[in]]|
|00000da0| 20 74 6f 20 5b 5b 6f 75 | 74 5d 5d 2c 20 61 64 64 | to [[ou|t]], add|
|00000db0| 69 6e 67 20 6d 61 72 6b | 75 70 3e 3e 0d 7d 0d 40 |ing mark|up>>.}.@|
|00000dc0| 20 25 64 65 66 20 6d 61 | 72 6b 75 70 0d 41 20 7b | %def ma|rkup.A {|
|00000dd0| 5c 65 6d 20 6e 6f 77 65 | 62 20 7d 20 66 69 6c 65 |\em nowe|b } file|
|00000de0| 20 63 6f 6e 73 69 73 74 | 73 20 6f 66 20 61 20 73 | consist|s of a s|
|00000df0| 65 71 75 65 6e 63 65 20 | 6f 66 0d 7b 5c 65 6d 20 |equence |of.{\em |
|00000e00| 63 68 75 6e 6b 73 2c 7d | 20 77 68 69 63 68 20 6d |chunks,}| which m|
|00000e10| 61 79 20 61 70 70 65 61 | 72 20 69 6e 20 61 6e 79 |ay appea|r in any|
|00000e20| 20 6f 72 64 65 72 2e 0d | 7b 5c 65 6d 20 6e 6f 77 | order..|{\em now|
|00000e30| 65 62 7d 20 73 75 70 70 | 6f 72 74 73 20 74 77 6f |eb} supp|orts two|
|00000e40| 20 6b 69 6e 64 73 20 6f | 66 20 63 68 75 6e 6b 73 | kinds o|f chunks|
|00000e50| 3a 20 64 6f 63 75 6d 65 | 6e 74 61 74 69 6f 6e 20 |: docume|ntation |
|00000e60| 63 68 75 6e 6b 73 20 61 | 6e 64 20 63 6f 64 65 20 |chunks a|nd code |
|00000e70| 63 68 75 6e 6b 73 2e 0d | 44 6f 63 75 6d 65 6e 74 |chunks..|Document|
|00000e80| 61 74 69 6f 6e 20 63 68 | 75 6e 6b 73 20 62 65 67 |ation ch|unks beg|
|00000e90| 69 6e 20 77 69 74 68 20 | 61 6e 20 61 74 20 73 69 |in with |an at si|
|00000ea0| 67 6e 20 28 40 29 20 61 | 74 20 74 68 65 20 62 65 |gn (@) a|t the be|
|00000eb0| 67 69 6e 6e 69 6e 67 20 | 6f 66 20 61 20 6c 69 6e |ginning |of a lin|
|00000ec0| 65 2c 0d 66 6f 6c 6c 6f | 77 65 64 20 62 79 20 61 |e,.follo|wed by a|
|00000ed0| 20 73 70 61 63 65 20 0d | 28 6f 72 20 77 69 74 68 | space .|(or with|
|00000ee0| 20 61 6e 20 61 74 20 73 | 69 67 6e 20 6f 6e 20 61 | an at s|ign on a|
|00000ef0| 20 6c 69 6e 65 20 62 79 | 20 69 74 73 65 6c 66 29 | line by| itself)|
|00000f00| 2e 0d 54 68 65 79 20 68 | 61 76 65 20 6e 6f 20 6e |..They h|ave no n|
|00000f10| 61 6d 65 73 2e 0d 43 6f | 64 65 20 63 68 75 6e 6b |ames..Co|de chunk|
|00000f20| 73 20 62 65 67 69 6e 20 | 77 69 74 68 0d 24 24 5c |s begin |with.$$\|
|00000f30| 68 62 6f 78 7b 5c 74 74 | 40 3c 3c 7b 5c 65 6d 20 |hbox{\tt|@<<{\em |
|00000f40| 63 68 75 6e 6b 20 6e 61 | 6d 65 5c 2f 7d 40 3e 3e |chunk na|me\/}@>>|
|00000f50| 3d 7d 24 24 0d 6f 6e 20 | 61 20 6c 69 6e 65 20 62 |=}$$.on |a line b|
|00000f60| 79 20 69 74 73 65 6c 66 | 2e 0d 54 68 65 20 6c 65 |y itself|..The le|
|00000f70| 66 74 20 64 6f 75 62 6c | 65 20 61 6e 67 6c 65 20 |ft doubl|e angle |
|00000f80| 62 72 61 63 6b 65 74 20 | 28 7b 5c 74 74 20 40 3c |bracket |({\tt @<|
|00000f90| 3c 7d 29 20 6d 75 73 74 | 20 62 65 20 69 6e 20 74 |<}) must| be in t|
|00000fa0| 68 65 20 66 69 72 73 74 | 20 63 6f 6c 75 6d 6e 2e |he first| column.|
|00000fb0| 0d 43 68 75 6e 6b 73 20 | 61 72 65 20 74 65 72 6d |.Chunks |are term|
|00000fc0| 69 6e 61 74 65 64 20 62 | 79 20 74 68 65 20 62 65 |inated b|y the be|
|00000fd0| 67 69 6e 6e 69 6e 67 20 | 6f 66 20 61 6e 6f 74 68 |ginning |of anoth|
|00000fe0| 65 72 20 63 68 75 6e 6b | 2c 20 6f 72 20 62 79 20 |er chunk|, or by |
|00000ff0| 65 6e 64 20 6f 66 20 66 | 69 6c 65 2e 0d 49 66 20 |end of f|ile..If |
|00001000| 74 68 65 20 66 69 72 73 | 74 20 6c 69 6e 65 20 69 |the firs|t line i|
|00001010| 6e 20 74 68 65 20 66 69 | 6c 65 20 64 6f 65 73 20 |n the fi|le does |
|00001020| 6e 6f 74 20 73 69 67 6e | 61 6c 20 74 68 65 20 62 |not sign|al the b|
|00001030| 65 67 69 6e 6e 69 6e 67 | 20 6f 66 20 61 20 64 6f |eginning| of a do|
|00001040| 63 75 6d 65 6e 74 61 74 | 69 6f 6e 0d 6f 72 20 63 |cumentat|ion.or c|
|00001050| 6f 64 65 20 63 68 75 6e | 6b 2c 20 74 68 65 20 66 |ode chun|k, the f|
|00001060| 69 72 73 74 20 63 68 75 | 6e 6b 20 69 73 20 61 73 |irst chu|nk is as|
|00001070| 73 75 6d 65 64 20 74 6f | 20 62 65 20 61 20 64 6f |sumed to| be a do|
|00001080| 63 75 6d 65 6e 74 61 74 | 69 6f 6e 20 63 68 75 6e |cumentat|ion chun|
|00001090| 6b 2e 0d 0d 57 65 20 69 | 6d 70 6c 65 6d 65 6e 74 |k...We i|mplement|
|000010a0| 20 74 68 69 73 20 62 79 | 20 6a 75 73 74 20 6c 6f | this by| just lo|
|000010b0| 6f 70 69 6e 67 20 74 68 | 72 6f 75 67 68 20 74 68 |oping th|rough th|
|000010c0| 65 20 64 6f 63 75 6d 65 | 6e 74 2c 20 6c 6f 6f 6b |e docume|nt, look|
|000010d0| 69 6e 67 20 66 6f 72 20 | 74 68 65 0d 62 65 67 69 |ing for |the.begi|
|000010e0| 6e 6e 69 6e 67 73 20 6f | 66 20 63 68 75 6e 6b 73 |nnings o|f chunks|
|000010f0| 2e 0d 57 65 20 75 73 65 | 20 5b 5b 73 74 61 74 65 |..We use| [[state|
|00001100| 5d 5d 20 74 6f 20 6b 65 | 65 70 20 74 72 61 63 6b |]] to ke|ep track|
|00001110| 20 6f 66 20 77 68 61 74 | 27 73 20 65 6e 64 69 6e | of what|'s endin|
|00001120| 67 2e 0d 57 65 20 61 64 | 64 20 61 20 6c 69 74 74 |g..We ad|d a litt|
|00001130| 6c 65 20 65 78 74 72 61 | 20 6d 61 72 6b 75 70 20 |le extra| markup |
|00001140| 66 6f 72 20 66 69 6c 65 | 20 6e 61 6d 65 20 61 6e |for file| name an|
|00001150| 64 20 6d 6f 64 75 6c 65 | 20 6e 61 6d 65 73 0d 53 |d module| names.S|
|00001160| 74 61 72 74 69 6e 67 20 | 63 6f 64 65 20 61 6e 64 |tarting |code and|
|00001170| 20 73 74 61 72 74 69 6e | 67 20 64 6f 63 75 6d 65 | startin|g docume|
|00001180| 6e 74 61 74 69 6f 6e 20 | 61 72 65 20 6e 6f 74 61 |ntation |are nota|
|00001190| 62 6c 79 20 64 69 66 66 | 65 72 65 6e 74 3a 20 0d |bly diff|erent: .|
|000011a0| 63 6f 64 65 20 69 73 20 | 73 74 61 72 74 65 64 20 |code is |started |
|000011b0| 62 79 20 61 20 6d 6f 64 | 75 6c 65 20 64 65 66 69 |by a mod|ule defi|
|000011c0| 6e 69 74 69 6f 6e 2c 20 | 77 68 69 63 68 20 6d 75 |nition, |which mu|
|000011d0| 73 74 20 61 70 70 65 61 | 72 20 6f 6e 20 61 20 6c |st appea|r on a l|
|000011e0| 69 6e 65 20 62 79 20 69 | 74 73 65 6c 66 2e 0d 44 |ine by i|tself..D|
|000011f0| 6f 63 75 6d 65 6e 74 61 | 74 69 6f 6e 20 69 73 20 |ocumenta|tion is |
|00001200| 73 74 61 72 74 65 64 20 | 62 79 20 61 20 63 68 61 |started |by a cha|
|00001210| 72 61 63 74 65 72 20 73 | 65 71 75 65 6e 63 65 2c |racter s|equence,|
|00001220| 20 0d 61 6e 64 20 61 72 | 62 69 74 72 61 72 79 20 | .and ar|bitrary |
|00001230| 64 6f 63 75 6d 65 6e 74 | 61 74 69 6f 6e 20 74 65 |document|ation te|
|00001240| 78 74 20 63 61 6e 20 66 | 6f 6c 6c 6f 77 20 6f 6e |xt can f|ollow on|
|00001250| 20 74 68 65 20 73 61 6d | 65 20 6c 69 6e 65 2e 0d | the sam|e line..|
|00001260| 3c 3c 63 6f 70 79 20 61 | 6c 6c 20 6c 69 6e 65 73 |<<copy a|ll lines|
|00001270| 20 66 72 6f 6d 20 5b 5b | 69 6e 5d 5d 20 74 6f 20 | from [[|in]] to |
|00001280| 5b 5b 6f 75 74 5d 5d 2c | 20 61 64 64 69 6e 67 20 |[[out]],| adding |
|00001290| 6d 61 72 6b 75 70 3e 3e | 3d 0d 70 72 69 6e 74 5f |markup>>|=.print_|
|000012a0| 70 61 69 72 28 6f 75 74 | 2c 20 22 66 69 6c 65 22 |pair(out|, "file"|
|000012b0| 2c 20 66 69 6c 65 6e 61 | 6d 65 29 3b 0d 70 72 69 |, filena|me);.pri|
|000012c0| 6e 74 5f 73 74 61 74 65 | 28 6f 75 74 2c 20 42 65 |nt_state|(out, Be|
|000012d0| 67 69 6e 2c 20 73 74 61 | 74 65 2c 20 63 6f 75 6e |gin, sta|te, coun|
|000012e0| 74 29 3b 0d 77 68 69 6c | 65 20 28 28 6c 69 6e 65 |t);.whil|e ((line|
|000012f0| 20 3d 20 67 65 74 6c 69 | 6e 65 5f 65 78 70 61 6e | = getli|ne_expan|
|00001300| 64 28 69 6e 29 29 20 21 | 3d 20 4e 55 4c 4c 29 20 |d(in)) !|= NULL) |
|00001310| 7b 0d 20 20 20 20 6c 69 | 6e 65 6e 6f 2b 2b 3b 0d |{. li|neno++;.|
|00001320| 20 20 20 20 3c 3c 72 65 | 6d 65 6d 62 65 72 20 69 | <<re|member i|
|00001330| 66 20 61 20 6e 65 77 6c | 69 6e 65 20 77 61 73 20 |f a newl|ine was |
|00001340| 6d 69 73 73 69 6e 67 20 | 66 72 6f 6d 20 74 68 65 |missing |from the|
|00001350| 20 6c 61 73 74 20 6c 69 | 6e 65 3e 3e 0d 20 20 20 | last li|ne>>. |
|00001360| 20 69 66 20 28 73 74 61 | 72 74 73 5f 63 6f 64 65 | if (sta|rts_code|
|00001370| 28 6c 69 6e 65 2c 20 66 | 69 6c 65 6e 61 6d 65 2c |(line, f|ilename,|
|00001380| 20 6c 69 6e 65 6e 6f 29 | 29 20 7b 0d 20 20 20 20 | lineno)|) {. |
|00001390| 20 20 20 20 3c 3c 63 6f | 6d 70 6c 61 69 6e 20 61 | <<co|mplain a|
|000013a0| 6e 64 20 63 6f 72 72 65 | 63 74 20 75 6e 6d 61 74 |nd corre|ct unmat|
|000013b0| 63 68 65 64 20 6f 70 65 | 6e 20 71 75 6f 74 65 2c |ched ope|n quote,|
|000013c0| 20 69 66 20 61 6e 79 3e | 3e 0d 20 20 20 20 20 20 | if any>|>. |
|000013d0| 20 20 70 72 69 6e 74 5f | 73 74 61 74 65 28 6f 75 | print_|state(ou|
|000013e0| 74 2c 20 45 6e 64 2c 20 | 73 74 61 74 65 2c 20 63 |t, End, |state, c|
|000013f0| 6f 75 6e 74 29 3b 0d 20 | 20 20 20 20 20 20 20 63 |ount);. | c|
|00001400| 6f 75 6e 74 2b 2b 3b 0d | 20 20 20 20 20 20 20 20 |ount++;.| |
|00001410| 73 74 61 74 65 20 3d 20 | 43 6f 64 65 3b 0d 20 20 |state = |Code;. |
|00001420| 20 20 20 20 20 20 70 72 | 69 6e 74 5f 73 74 61 74 | pr|int_stat|
|00001430| 65 28 6f 75 74 2c 20 42 | 65 67 69 6e 2c 20 73 74 |e(out, B|egin, st|
|00001440| 61 74 65 2c 20 63 6f 75 | 6e 74 29 3b 0d 20 20 20 |ate, cou|nt);. |
|00001450| 20 20 20 20 20 67 65 74 | 6d 6f 64 6e 61 6d 65 28 | get|modname(|
|00001460| 6d 6f 64 6e 61 6d 65 2c | 4d 41 58 5f 4d 4f 44 4e |modname,|MAX_MODN|
|00001470| 41 4d 45 2c 6c 69 6e 65 | 29 3b 0d 20 20 20 20 20 |AME,line|);. |
|00001480| 20 20 20 70 72 69 6e 74 | 5f 70 61 69 72 28 6f 75 | print|_pair(ou|
|00001490| 74 2c 22 64 65 66 6e 22 | 2c 6d 6f 64 6e 61 6d 65 |t,"defn"|,modname|
|000014a0| 29 3b 0d 20 20 20 20 20 | 20 20 20 70 72 69 6e 74 |);. | print|
|000014b0| 5f 70 61 69 72 28 6f 75 | 74 2c 22 6e 6c 22 2c 30 |_pair(ou|t,"nl",0|
|000014c0| 29 3b 20 20 20 20 20 2f | 2a 20 63 6f 75 6c 64 20 |); /|* could |
|000014d0| 62 65 20 69 6d 70 6c 69 | 63 69 74 20 62 75 74 20 |be impli|cit but |
|000014e0| 74 68 69 73 20 69 73 20 | 62 65 74 74 65 72 20 2a |this is |better *|
|000014f0| 2f 0d 20 20 20 20 7d 20 | 65 6c 73 65 20 69 66 20 |/. } |else if |
|00001500| 28 69 73 5f 64 65 66 28 | 6c 69 6e 65 29 29 20 7b |(is_def(|line)) {|
|00001510| 0d 20 20 20 20 20 20 20 | 20 3c 3c 65 6d 69 74 20 |. | <<emit |
|00001520| 69 6e 64 65 78 20 64 65 | 66 69 6e 69 74 69 6f 6e |index de|finition|
|00001530| 73 20 61 6e 64 20 69 6e | 64 65 78 20 6e 65 77 6c |s and in|dex newl|
|00001540| 69 6e 65 3e 3e 0d 09 69 | 66 20 28 73 74 61 74 65 |ine>>..i|f (state|
|00001550| 20 3d 3d 20 43 6f 64 65 | 29 0d 09 20 20 20 20 73 | == Code|).. s|
|00001560| 74 61 74 65 20 3d 20 43 | 6f 64 65 49 6e 64 65 78 |tate = C|odeIndex|
|00001570| 3b 0d 20 20 20 20 7d 20 | 65 6c 73 65 20 7b 0d 20 |;. } |else {. |
|00001580| 20 20 20 20 20 20 20 69 | 66 20 28 73 74 61 72 74 | i|f (start|
|00001590| 73 5f 64 6f 63 28 6c 69 | 6e 65 29 20 7c 7c 20 73 |s_doc(li|ne) || s|
|000015a0| 74 61 74 65 20 3d 3d 20 | 43 6f 64 65 49 6e 64 65 |tate == |CodeInde|
|000015b0| 78 29 20 7b 0d 20 20 20 | 20 20 20 20 20 20 20 20 |x) {. | |
|000015c0| 20 3c 3c 63 6f 6d 70 6c | 61 69 6e 20 61 6e 64 20 | <<compl|ain and |
|000015d0| 63 6f 72 72 65 63 74 20 | 75 6e 6d 61 74 63 68 65 |correct |unmatche|
|000015e0| 64 20 6f 70 65 6e 20 71 | 75 6f 74 65 2c 20 69 66 |d open q|uote, if|
|000015f0| 20 61 6e 79 3e 3e 0d 20 | 20 20 20 20 20 20 20 20 | any>>. | |
|00001600| 20 20 20 70 72 69 6e 74 | 5f 73 74 61 74 65 28 6f | print|_state(o|
|00001610| 75 74 2c 20 45 6e 64 2c | 20 73 74 61 74 65 2c 20 |ut, End,| state, |
|00001620| 63 6f 75 6e 74 29 3b 0d | 20 20 20 20 20 20 20 20 |count);.| |
|00001630| 20 20 20 20 63 6f 75 6e | 74 2b 2b 3b 0d 20 20 20 | coun|t++;. |
|00001640| 20 20 20 20 20 20 20 20 | 20 73 74 61 74 65 20 3d | | state =|
|00001650| 20 44 6f 63 73 3b 20 20 | 20 20 20 20 20 2f 2a 20 | Docs; | /* |
|00001660| 61 6c 77 61 79 73 20 72 | 65 61 64 69 6e 67 20 64 |always r|eading d|
|00001670| 6f 63 73 20 61 66 74 65 | 72 20 61 20 73 74 6f 70 |ocs afte|r a stop|
|00001680| 20 2a 2f 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 | */. | |
|00001690| 70 72 69 6e 74 5f 73 74 | 61 74 65 28 6f 75 74 2c |print_st|ate(out,|
|000016a0| 20 42 65 67 69 6e 2c 20 | 73 74 61 74 65 2c 20 63 | Begin, |state, c|
|000016b0| 6f 75 6e 74 29 3b 0d 09 | 20 20 20 20 69 66 20 28 |ount);..| if (|
|000016c0| 73 74 61 72 74 73 5f 64 | 6f 63 28 6c 69 6e 65 29 |starts_d|oc(line)|
|000016d0| 29 0d 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |). | |
|000016e0| 20 20 6c 69 6e 65 20 3d | 20 66 69 72 73 74 5f 64 | line =| first_d|
|000016f0| 6f 63 5f 6c 69 6e 65 28 | 6c 69 6e 65 29 3b 0d 20 |oc_line(|line);. |
|00001700| 20 20 20 20 20 20 20 7d | 0d 20 20 20 20 20 20 20 | }|. |
|00001710| 20 73 77 69 74 63 68 28 | 73 74 61 74 65 29 20 7b | switch(|state) {|
|00001720| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 63 61 73 |. | cas|
|00001730| 65 20 43 6f 64 65 3a 20 | 3c 3c 63 6f 6e 76 65 72 |e Code: |<<conver|
|00001740| 74 20 61 20 63 6f 64 65 | 20 6c 69 6e 65 3e 3e 20 |t a code| line>> |
|00001750| 62 72 65 61 6b 3b 0d 20 | 20 20 20 20 20 20 20 20 |break;. | |
|00001760| 20 20 20 63 61 73 65 20 | 44 6f 63 73 3a 20 3c 3c | case |Docs: <<|
|00001770| 63 6f 6e 76 65 72 74 20 | 61 20 64 6f 63 75 6d 65 |convert |a docume|
|00001780| 6e 74 61 74 69 6f 6e 20 | 6c 69 6e 65 3e 3e 20 62 |ntation |line>> b|
|00001790| 72 65 61 6b 3b 0d 20 20 | 20 20 20 20 20 20 20 20 |reak;. | |
|000017a0| 20 20 64 65 66 61 75 6c | 74 3a 20 69 6d 70 6f 73 | defaul|t: impos|
|000017b0| 73 69 62 6c 65 28 22 62 | 61 64 20 73 74 61 74 65 |sible("b|ad state|
|000017c0| 22 29 3b 0d 20 20 20 20 | 20 20 20 20 7d 20 20 20 |");. | } |
|000017d0| 20 0d 20 20 20 20 7d 0d | 7d 0d 3c 3c 61 64 64 20 | . }.|}.<<add |
|000017e0| 61 20 74 72 61 69 6c 69 | 6e 67 20 6e 65 77 6c 69 |a traili|ng newli|
|000017f0| 6e 65 20 69 66 20 6f 6e | 65 20 77 61 73 20 6d 69 |ne if on|e was mi|
|00001800| 73 73 69 6e 67 3e 3e 0d | 70 72 69 6e 74 5f 73 74 |ssing>>.|print_st|
|00001810| 61 74 65 28 6f 75 74 2c | 20 45 6e 64 2c 20 73 74 |ate(out,| End, st|
|00001820| 61 74 65 2c 20 63 6f 75 | 6e 74 29 3b 0d 40 0d 57 |ate, cou|nt);.@.W|
|00001830| 65 20 6d 61 6b 65 20 69 | 74 20 73 61 66 65 20 74 |e make i|t safe t|
|00001840| 6f 20 61 73 73 75 6d 65 | 20 68 65 6e 63 65 66 6f |o assume| hencefo|
|00001850| 72 74 68 20 74 68 61 74 | 20 65 76 65 72 79 20 63 |rth that| every c|
|00001860| 68 75 6e 6b 20 65 6e 64 | 73 20 77 69 74 68 20 6e |hunk end|s with n|
|00001870| 65 77 6c 69 6e 65 2c 0d | 65 76 65 6e 20 69 66 20 |ewline,.|even if |
|00001880| 74 68 65 20 66 69 6c 65 | 20 64 69 64 6e 27 74 20 |the file| didn't |
|00001890| 65 6e 64 20 77 69 74 68 | 20 6e 65 77 6c 69 6e 65 |end with| newline|
|000018a0| 2e 0d 49 66 20 74 68 65 | 20 66 69 6c 65 20 64 69 |..If the| file di|
|000018b0| 64 6e 27 74 20 65 6e 64 | 20 77 69 74 68 20 6e 65 |dn't end| with ne|
|000018c0| 77 6c 69 6e 65 2c 20 77 | 65 20 61 64 64 20 61 20 |wline, w|e add a |
|000018d0| 6e 65 77 6c 69 6e 65 20 | 74 6f 20 74 68 65 20 6c |newline |to the l|
|000018e0| 61 73 74 20 6c 69 6e 65 | 0d 62 65 66 6f 72 65 20 |ast line|.before |
|000018f0| 70 72 69 6e 74 69 6e 67 | 20 74 68 65 20 66 69 6e |printing| the fin|
|00001900| 61 6c 20 5b 5b 40 65 6e | 64 5d 5d 2e 0d 3c 3c 72 |al [[@en|d]]..<<r|
|00001910| 65 6d 65 6d 62 65 72 20 | 69 66 20 61 20 6e 65 77 |emember |if a new|
|00001920| 6c 69 6e 65 20 77 61 73 | 20 6d 69 73 73 69 6e 67 |line was| missing|
|00001930| 20 66 72 6f 6d 20 74 68 | 65 20 6c 61 73 74 20 6c | from th|e last l|
|00001940| 69 6e 65 3e 3e 3d 0d 6d | 69 73 73 69 6e 67 5f 6e |ine>>=.m|issing_n|
|00001950| 65 77 6c 69 6e 65 20 3d | 20 6c 69 6e 65 5b 73 74 |ewline =| line[st|
|00001960| 72 6c 65 6e 28 6c 69 6e | 65 29 2d 31 5d 20 21 3d |rlen(lin|e)-1] !=|
|00001970| 20 27 5c 6e 27 3b 0d 3c | 3c 61 64 64 20 61 20 74 | '\n';.<|<add a t|
|00001980| 72 61 69 6c 69 6e 67 20 | 6e 65 77 6c 69 6e 65 20 |railing |newline |
|00001990| 69 66 20 6f 6e 65 20 77 | 61 73 20 6d 69 73 73 69 |if one w|as missi|
|000019a0| 6e 67 3e 3e 3d 0d 69 66 | 20 28 6d 69 73 73 69 6e |ng>>=.if| (missin|
|000019b0| 67 5f 6e 65 77 6c 69 6e | 65 29 20 70 72 69 6e 74 |g_newlin|e) print|
|000019c0| 5f 70 61 69 72 28 6f 75 | 74 2c 20 22 6e 6c 22 2c |_pair(ou|t, "nl",|
|000019d0| 30 29 3b 0d 40 0d 54 6f | 20 63 6f 6e 76 65 72 74 |0);.@.To| convert|
|000019e0| 20 61 20 63 6f 64 65 20 | 6c 69 6e 65 2c 20 77 65 | a code |line, we|
|000019f0| 20 68 61 76 65 20 74 6f | 20 73 63 61 6e 20 66 6f | have to| scan fo|
|00001a00| 72 20 74 68 65 20 73 74 | 61 72 74 20 61 6e 64 20 |r the st|art and |
|00001a10| 65 6e 64 20 6f 66 20 6d | 6f 64 75 6c 65 20 0d 72 |end of m|odule .r|
|00001a20| 65 66 65 72 65 6e 63 65 | 73 2e 20 0d 3c 3c 63 6f |eference|s. .<<co|
|00001a30| 6e 76 65 72 74 20 61 20 | 63 6f 64 65 20 6c 69 6e |nvert a |code lin|
|00001a40| 65 3e 3e 3d 0d 77 68 69 | 6c 65 20 28 28 6d 61 72 |e>>=.whi|le ((mar|
|00001a50| 6b 20 3d 20 6d 6f 64 5f | 73 74 61 72 74 28 6c 69 |k = mod_|start(li|
|00001a60| 6e 65 2c 31 29 29 20 21 | 3d 20 4e 55 4c 4c 29 20 |ne,1)) !|= NULL) |
|00001a70| 7b 20 0d 20 20 20 20 69 | 66 20 28 2a 6c 69 6e 65 |{ . i|f (*line|
|00001a80| 29 20 70 72 69 6e 74 5f | 70 61 69 72 28 6f 75 74 |) print_|pair(out|
|00001a90| 2c 20 22 74 65 78 74 22 | 2c 75 6e 65 73 63 61 70 |, "text"|,unescap|
|00001aa0| 65 28 6c 69 6e 65 29 29 | 3b 20 0d 20 20 20 20 20 |e(line))|; . |
|00001ab0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001ac0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 2f 2a | | /*|
|00001ad0| 20 65 6d 69 74 20 73 74 | 72 69 6e 67 20 62 65 66 | emit st|ring bef|
|00001ae0| 6f 72 65 20 6d 6f 64 75 | 6c 65 20 2a 2f 0d 20 20 |ore modu|le */. |
|00001af0| 20 20 69 66 20 28 28 6c | 69 6e 65 3d 6d 6f 64 5f | if ((l|ine=mod_|
|00001b00| 65 6e 64 28 6d 61 72 6b | 2c 31 29 29 3d 3d 4e 55 |end(mark|,1))==NU|
|00001b10| 4c 4c 29 20 7b 20 2f 2a | 20 6e 6f 20 6d 61 74 63 |LL) { /*| no matc|
|00001b20| 68 69 6e 67 20 40 3e 3e | 3b 20 74 72 65 61 74 20 |hing @>>|; treat |
|00001b30| 40 3c 3c 20 61 73 20 74 | 65 78 74 20 2a 2f 0d 20 |@<< as t|ext */. |
|00001b40| 20 20 20 20 20 20 20 6c | 69 6e 65 20 3d 20 6d 61 | l|ine = ma|
|00001b50| 72 6b 20 2d 20 32 3b 20 | 20 20 20 20 20 20 20 2f |rk - 2; | /|
|00001b60| 2a 20 62 61 63 6b 20 75 | 70 3b 20 70 6f 69 6e 74 |* back u|p; point|
|00001b70| 20 74 6f 20 40 3c 3c 20 | 2a 2f 0d 20 20 20 20 20 | to @<< |*/. |
|00001b80| 20 20 20 2a 6c 69 6e 65 | 20 3d 20 27 3c 27 3b 20 | *line| = '<'; |
|00001b90| 20 20 20 20 20 20 20 20 | 20 20 20 2f 2a 20 72 65 | | /* re|
|00001ba0| 73 74 6f 72 65 20 6d 69 | 73 73 69 6e 67 20 3c 20 |store mi|ssing < |
|00001bb0| 28 77 61 73 20 27 5c 30 | 27 29 20 2a 2f 0d 20 20 |(was '\0|') */. |
|00001bc0| 20 20 20 20 20 20 62 72 | 65 61 6b 3b 0d 20 20 20 | br|eak;. |
|00001bd0| 20 7d 20 65 6c 73 65 20 | 7b 20 20 0d 20 20 20 20 | } else |{ . |
|00001be0| 20 20 20 20 70 72 69 6e | 74 5f 70 61 69 72 28 6f | prin|t_pair(o|
|00001bf0| 75 74 2c 20 22 75 73 65 | 22 2c 6d 61 72 6b 29 3b |ut, "use|",mark);|
|00001c00| 20 20 20 20 20 20 20 2f | 2a 20 65 6d 69 74 20 74 | /|* emit t|
|00001c10| 68 65 20 6d 6f 64 75 6c | 65 20 2a 2f 0d 20 20 20 |he modul|e */. |
|00001c20| 20 7d 0d 7d 0d 69 66 20 | 28 2a 6c 69 6e 65 29 20 | }.}.if |(*line) |
|00001c30| 70 72 69 6e 74 5f 70 61 | 69 72 28 6f 75 74 2c 20 |print_pa|ir(out, |
|00001c40| 22 74 65 78 74 22 2c 75 | 6e 65 73 63 61 70 65 28 |"text",u|nescape(|
|00001c50| 6c 69 6e 65 29 29 3b 20 | 0d 20 20 20 20 20 20 20 |line)); |. |
|00001c60| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001c70| 20 20 20 20 20 20 20 20 | 20 20 20 2f 2a 20 63 6f | | /* co|
|00001c80| 6e 74 72 69 62 75 74 65 | 20 74 68 65 20 74 72 61 |ntribute| the tra|
|00001c90| 69 6c 69 6e 67 20 73 74 | 72 69 6e 67 20 2a 2f 0d |iling st|ring */.|
|00001ca0| 40 20 54 6f 20 63 6f 6e | 76 65 72 74 20 64 6f 63 |@ To con|vert doc|
|00001cb0| 75 6d 65 6e 74 61 74 69 | 6f 6e 20 6c 69 6e 65 73 |umentati|on lines|
|00001cc0| 2c 20 77 65 20 68 61 76 | 65 20 74 6f 20 74 72 61 |, we hav|e to tra|
|00001cd0| 63 6b 20 74 68 65 20 71 | 75 6f 74 69 6e 67 20 62 |ck the q|uoting b|
|00001ce0| 72 61 63 6b 65 74 73 2e | 0d 4e 6f 74 65 20 74 68 |rackets.|.Note th|
|00001cf0| 61 74 20 5b 5b 69 66 20 | 28 71 75 6f 74 69 6e 67 |at [[if |(quoting|
|00001d00| 20 3d 20 21 71 75 6f 74 | 69 6e 67 29 5d 5d 20 69 | = !quot|ing)]] i|
|00001d10| 73 20 61 20 73 69 6d 75 | 6c 74 61 6e 65 6f 75 73 |s a simu|ltaneous|
|00001d20| 20 74 6f 67 67 6c 65 20 | 61 6e 64 20 74 65 73 74 | toggle |and test|
|00001d30| 2e 0d 3c 3c 63 6f 6e 76 | 65 72 74 20 61 20 64 6f |..<<conv|ert a do|
|00001d40| 63 75 6d 65 6e 74 61 74 | 69 6f 6e 20 6c 69 6e 65 |cumentat|ion line|
|00001d50| 3e 3e 3d 0d 66 6f 72 20 | 28 3b 20 28 6d 61 72 6b |>>=.for |(; (mark|
|00001d60| 20 3d 20 28 71 75 6f 74 | 69 6e 67 20 3f 20 71 75 | = (quot|ing ? qu|
|00001d70| 6f 74 65 5f 65 6e 64 20 | 3a 20 71 75 6f 74 65 5f |ote_end |: quote_|
|00001d80| 73 74 61 72 74 29 28 6c | 69 6e 65 2c 31 29 29 20 |start)(l|ine,1)) |
|00001d90| 21 3d 20 4e 55 4c 4c 3b | 20 0d 20 20 20 20 20 20 |!= NULL;| . |
|00001da0| 20 6c 69 6e 65 20 3d 20 | 6d 61 72 6b 29 20 7b 0d | line = |mark) {.|
|00001db0| 20 20 20 20 69 66 20 28 | 21 71 75 6f 74 69 6e 67 | if (|!quoting|
|00001dc0| 29 20 7b 3c 3c 63 6f 6d | 70 6c 61 69 6e 20 69 66 |) {<<com|plain if|
|00001dd0| 20 5b 5b 6c 69 6e 65 5d | 5d 20 68 61 73 20 5b 5b | [[line]|] has [[|
|00001de0| 6d 6f 64 5f 73 74 61 72 | 74 5d 5d 3e 3e 7d 0d 20 |mod_star|t]]>>}. |
|00001df0| 20 20 20 69 66 20 28 2a | 6c 69 6e 65 29 20 70 72 | if (*|line) pr|
|00001e00| 69 6e 74 5f 70 61 69 72 | 28 6f 75 74 2c 20 22 74 |int_pair|(out, "t|
|00001e10| 65 78 74 22 2c 20 75 6e | 65 73 63 61 70 65 28 6c |ext", un|escape(l|
|00001e20| 69 6e 65 29 29 3b 0d 20 | 20 20 20 70 72 69 6e 74 |ine));. | print|
|00001e30| 5f 70 61 69 72 28 6f 75 | 74 2c 20 71 75 6f 74 69 |_pair(ou|t, quoti|
|00001e40| 6e 67 20 3f 20 22 65 6e | 64 71 75 6f 74 65 22 20 |ng ? "en|dquote" |
|00001e50| 3a 20 22 71 75 6f 74 65 | 22 2c 20 30 29 3b 0d 20 |: "quote|", 0);. |
|00001e60| 20 20 20 69 66 20 28 71 | 75 6f 74 69 6e 67 20 3d | if (q|uoting =|
|00001e70| 20 21 71 75 6f 74 69 6e | 67 29 20 6c 61 73 74 5f | !quotin|g) last_|
|00001e80| 6f 70 65 6e 5f 71 75 6f | 74 65 20 3d 20 6c 69 6e |open_quo|te = lin|
|00001e90| 65 6e 6f 3b 0d 7d 0d 69 | 66 20 28 21 71 75 6f 74 |eno;.}.i|f (!quot|
|00001ea0| 69 6e 67 29 20 7b 3c 3c | 63 6f 6d 70 6c 61 69 6e |ing) {<<|complain|
|00001eb0| 20 69 66 20 5b 5b 6c 69 | 6e 65 5d 5d 20 68 61 73 | if [[li|ne]] has|
|00001ec0| 20 5b 5b 6d 6f 64 5f 73 | 74 61 72 74 5d 5d 3e 3e | [[mod_s|tart]]>>|
|00001ed0| 7d 0d 69 66 20 28 2a 6c | 69 6e 65 29 20 70 72 69 |}.if (*l|ine) pri|
|00001ee0| 6e 74 5f 70 61 69 72 28 | 6f 75 74 2c 20 22 74 65 |nt_pair(|out, "te|
|00001ef0| 78 74 22 2c 20 75 6e 65 | 73 63 61 70 65 28 6c 69 |xt", une|scape(li|
|00001f00| 6e 65 29 29 3b 20 0d 40 | 0d 49 66 20 77 65 20 73 |ne)); .@|.If we s|
|00001f10| 65 65 20 61 20 60 60 6d | 6f 64 75 6c 65 20 73 74 |ee a ``m|odule st|
|00001f20| 61 72 74 27 27 20 69 6e | 20 64 6f 63 75 6d 65 6e |art'' in| documen|
|00001f30| 74 61 74 69 6f 6e 2c 20 | 74 68 69 73 20 6d 69 67 |tation, |this mig|
|00001f40| 68 74 20 73 75 67 67 65 | 73 74 20 74 6f 20 75 73 |ht sugge|st to us|
|00001f50| 0d 74 68 61 74 20 77 65 | 27 76 65 20 6d 61 64 65 |.that we|'ve made|
|00001f60| 20 61 20 6d 69 73 74 61 | 6b 65 2d 2d 2d 70 65 72 | a mista|ke---per|
|00001f70| 68 61 70 73 20 77 65 20 | 6c 65 66 74 20 74 68 65 |haps we |left the|
|00001f80| 20 74 72 61 69 6c 69 6e | 67 20 5b 5b 3d 5d 5d 20 | trailin|g [[=]] |
|00001f90| 6f 66 66 20 6f 66 20 61 | 20 64 65 66 69 6e 69 74 |off of a| definit|
|00001fa0| 69 6f 6e 2e 0d 3c 3c 63 | 6f 6d 70 6c 61 69 6e 20 |ion..<<c|omplain |
|00001fb0| 69 66 20 5b 5b 6c 69 6e | 65 5d 5d 20 68 61 73 20 |if [[lin|e]] has |
|00001fc0| 5b 5b 6d 6f 64 5f 73 74 | 61 72 74 5d 5d 3e 3e 3d |[[mod_st|art]]>>=|
|00001fd0| 0d 69 66 20 28 6d 6f 64 | 5f 73 74 61 72 74 28 6c |.if (mod|_start(l|
|00001fe0| 69 6e 65 2c 30 29 20 21 | 3d 20 4e 55 4c 4c 29 0d |ine,0) !|= NULL).|
|00001ff0| 20 20 20 20 65 72 72 6f | 72 61 74 28 66 69 6c 65 | erro|rat(file|
|00002000| 6e 61 6d 65 2c 20 6c 69 | 6e 65 6e 6f 2c 20 57 61 |name, li|neno, Wa|
|00002010| 72 6e 69 6e 67 2c 20 0d | 20 20 20 20 20 20 20 20 |rning, .| |
|00002020| 20 20 20 20 22 57 61 72 | 6e 69 6e 67 3a 20 63 68 | "War|ning: ch|
|00002030| 75 6e 6b 20 6e 61 6d 65 | 20 69 6e 20 64 6f 63 75 |unk name| in docu|
|00002040| 6d 65 6e 74 61 74 69 6f | 6e 20 28 6f 72 20 6d 69 |mentatio|n (or mi|
|00002050| 73 73 69 6e 67 20 3d 20 | 69 6e 20 64 65 66 69 6e |ssing = |in defin|
|00002060| 69 74 69 6f 6e 29 22 29 | 3b 0d 40 0d 3c 3c 65 6d |ition)")|;.@.<<em|
|00002070| 69 74 20 69 6e 64 65 78 | 20 64 65 66 69 6e 69 74 |it index| definit|
|00002080| 69 6f 6e 73 20 61 6e 64 | 20 69 6e 64 65 78 20 6e |ions and| index n|
|00002090| 65 77 6c 69 6e 65 3e 3e | 3d 0d 6c 69 6e 65 20 3d |ewline>>|=.line =|
|000020a0| 20 72 65 6d 6f 76 65 5f | 64 65 66 5f 6d 61 72 6b | remove_|def_mark|
|000020b0| 65 72 28 6c 69 6e 65 29 | 3b 0d 77 68 69 6c 65 20 |er(line)|;.while |
|000020c0| 28 2a 6c 69 6e 65 20 26 | 26 20 69 73 73 70 61 63 |(*line &|& isspac|
|000020d0| 65 28 2a 6c 69 6e 65 29 | 29 20 6c 69 6e 65 2b 2b |e(*line)|) line++|
|000020e0| 3b 0d 77 68 69 6c 65 20 | 28 2a 6c 69 6e 65 29 20 |;.while |(*line) |
|000020f0| 7b 0d 20 20 63 68 61 72 | 20 74 6d 70 3b 0d 20 20 |{. char| tmp;. |
|00002100| 63 68 61 72 20 2a 73 20 | 3d 20 6c 69 6e 65 2b 31 |char *s |= line+1|
|00002110| 3b 0d 20 20 77 68 69 6c | 65 20 28 2a 73 20 26 26 |;. whil|e (*s &&|
|00002120| 20 21 69 73 73 70 61 63 | 65 28 2a 73 29 29 20 73 | !isspac|e(*s)) s|
|00002130| 2b 2b 3b 0d 20 20 74 6d | 70 20 3d 20 2a 73 3b 20 |++;. tm|p = *s; |
|00002140| 2a 73 20 3d 20 30 3b 0d | 20 20 70 72 69 6e 74 5f |*s = 0;.| print_|
|00002150| 69 6e 64 65 78 28 6f 75 | 74 2c 20 44 65 66 6e 2c |index(ou|t, Defn,|
|00002160| 20 6c 69 6e 65 29 3b 0d | 20 20 2a 73 20 3d 20 74 | line);.| *s = t|
|00002170| 6d 70 3b 0d 20 20 77 68 | 69 6c 65 20 28 69 73 73 |mp;. wh|ile (iss|
|00002180| 70 61 63 65 28 2a 73 29 | 29 20 73 2b 2b 3b 0d 20 |pace(*s)|) s++;. |
|00002190| 20 6c 69 6e 65 20 3d 20 | 73 3b 0d 7d 0d 70 72 69 | line = |s;.}.pri|
|000021a0| 6e 74 5f 69 6e 64 65 78 | 28 6f 75 74 2c 20 4e 65 |nt_index|(out, Ne|
|000021b0| 77 6c 69 6e 65 2c 20 30 | 29 3b 0d 3c 3c 63 6f 6d |wline, 0|);.<<com|
|000021c0| 70 6c 61 69 6e 20 61 6e | 64 20 63 6f 72 72 65 63 |plain an|d correc|
|000021d0| 74 20 75 6e 6d 61 74 63 | 68 65 64 20 6f 70 65 6e |t unmatc|hed open|
|000021e0| 20 71 75 6f 74 65 2c 20 | 69 66 20 61 6e 79 3e 3e | quote, |if any>>|
|000021f0| 3d 0d 69 66 20 28 71 75 | 6f 74 69 6e 67 29 20 7b |=.if (qu|oting) {|
|00002200| 0d 20 20 20 20 65 72 72 | 6f 72 61 74 28 66 69 6c |. err|orat(fil|
|00002210| 65 6e 61 6d 65 2c 20 6c | 61 73 74 5f 6f 70 65 6e |ename, l|ast_open|
|00002220| 5f 71 75 6f 74 65 2c 20 | 57 61 72 6e 69 6e 67 2c |_quote, |Warning,|
|00002230| 20 22 6f 70 65 6e 20 71 | 75 6f 74 65 20 60 5b 5b | "open q|uote `[[|
|00002240| 27 20 6e 65 76 65 72 20 | 63 6c 6f 73 65 64 22 29 |' never |closed")|
|00002250| 3b 0d 20 20 20 20 71 75 | 6f 74 69 6e 67 20 3d 20 |;. qu|oting = |
|00002260| 30 3b 0d 7d 0d 40 0d 46 | 69 6e 61 6c 6c 79 2c 20 |0;.}.@.F|inally, |
|00002270| 77 65 20 67 69 76 65 20 | 74 68 65 20 6d 61 69 6e |we give |the main|
|00002280| 20 70 72 6f 67 72 61 6d | 2c 20 77 68 69 63 68 20 | program|, which |
|00002290| 6f 70 65 6e 73 20 65 61 | 63 68 20 66 69 6c 65 20 |opens ea|ch file |
|000022a0| 61 6e 64 20 70 61 73 73 | 65 73 20 69 74 0d 74 6f |and pass|es it.to|
|000022b0| 20 5b 5b 6d 61 72 6b 75 | 70 5d 5d 2e 0d 4c 69 6b | [[marku|p]]..Lik|
|000022c0| 65 20 6d 61 6e 79 20 6d | 61 69 6e 20 70 72 6f 67 |e many m|ain prog|
|000022d0| 72 61 6d 73 2c 20 69 74 | 27 73 20 62 61 73 65 64 |rams, it|'s based|
|000022e0| 20 6f 6e 20 4b 20 5c 26 | 20 52 20 5b 5b 63 61 74 | on K \&| R [[cat|
|000022f0| 5d 5d 2e 0d 3c 3c 2a 3e | 3e 3d 0d 6d 61 69 6e 28 |]]..<<*>|>=.main(|
|00002300| 69 6e 74 20 61 72 67 63 | 2c 20 63 68 61 72 20 2a |int argc|, char *|
|00002310| 2a 61 72 67 76 29 20 7b | 0d 0d 20 20 20 20 46 49 |*argv) {|.. FI|
|00002320| 4c 45 20 2a 66 70 3b 0d | 20 20 20 20 63 68 61 72 |LE *fp;.| char|
|00002330| 20 2a 6d 79 73 65 6c 66 | 3d 2a 61 72 67 76 3b 0d | *myself|=*argv;.|
|00002340| 20 20 20 20 69 6e 74 20 | 69 3b 0d 0d 20 20 20 20 | int |i;.. |
|00002350| 66 6f 72 20 28 69 20 3d | 20 31 3b 20 69 20 3c 20 |for (i =| 1; i < |
|00002360| 61 72 67 63 20 26 26 20 | 61 72 67 76 5b 69 5d 5b |argc && |argv[i][|
|00002370| 30 5d 20 3d 3d 20 27 2d | 27 20 26 26 20 61 72 67 |0] == '-|' && arg|
|00002380| 76 5b 69 5d 5b 31 5d 20 | 21 3d 20 30 3b 20 69 2b |v[i][1] |!= 0; i+|
|00002390| 2b 29 0d 20 20 20 20 20 | 20 20 20 73 77 69 74 63 |+). | switc|
|000023a0| 68 28 61 72 67 76 5b 69 | 5d 5b 31 5d 29 20 7b 0d |h(argv[i|][1]) {.|
|000023b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 63 61 73 65 | | case|
|000023c0| 20 27 74 27 3a 20 3c 3c | 68 61 6e 64 6c 65 20 5b | 't': <<|handle [|
|000023d0| 5b 2d 74 5d 5d 3e 3e 20 | 62 72 65 61 6b 3b 0d 20 |[-t]]>> |break;. |
|000023e0| 20 20 20 20 20 20 20 20 | 20 20 20 64 65 66 61 75 | | defau|
|000023f0| 6c 74 20 3a 20 65 72 72 | 6f 72 6d 73 67 28 45 72 |lt : err|ormsg(Er|
|00002400| 72 6f 72 2c 20 22 25 73 | 3a 20 75 6e 6b 6e 6f 77 |ror, "%s|: unknow|
|00002410| 6e 20 6f 70 74 69 6f 6e | 20 2d 25 63 5c 6e 22 2c |n option| -%c\n",|
|00002420| 20 6d 79 73 65 6c 66 2c | 20 61 72 67 76 5b 69 5d | myself,| argv[i]|
|00002430| 5b 31 5d 29 3b 0d 20 20 | 20 20 20 20 20 20 20 20 |[1]);. | |
|00002440| 20 20 20 20 20 20 20 20 | 20 20 20 20 62 72 65 61 | | brea|
|00002450| 6b 3b 0d 20 20 20 20 20 | 20 20 20 7d 0d 20 20 20 |k;. | }. |
|00002460| 20 69 66 20 28 69 20 3c | 20 61 72 67 63 29 0d 20 | if (i <| argc). |
|00002470| 20 20 20 20 20 20 20 66 | 6f 72 20 28 3b 20 69 20 | f|or (; i |
|00002480| 3c 20 61 72 67 63 3b 20 | 69 2b 2b 29 20 7b 0d 20 |< argc; |i++) {. |
|00002490| 20 20 20 20 20 20 20 20 | 20 20 20 69 66 20 28 21 | | if (!|
|000024a0| 73 74 72 63 6d 70 28 61 | 72 67 76 5b 69 5d 2c 20 |strcmp(a|rgv[i], |
|000024b0| 22 2d 22 29 29 20 7b 0d | 20 20 20 20 20 20 20 20 |"-")) {.| |
|000024c0| 20 20 20 20 20 20 20 20 | 6d 61 72 6b 75 70 28 73 | |markup(s|
|000024d0| 74 64 69 6e 2c 73 74 64 | 6f 75 74 2c 22 22 29 3b |tdin,std|out,"");|
|000024e0| 0d 20 20 20 20 20 20 20 | 20 20 20 20 20 7d 20 65 |. | } e|
|000024f0| 6c 73 65 20 0d 20 20 20 | 20 20 20 20 20 20 20 20 |lse . | |
|00002500| 20 20 20 20 20 69 66 20 | 28 28 66 70 3d 66 6f 70 | if |((fp=fop|
|00002510| 65 6e 28 61 72 67 76 5b | 69 5d 2c 22 72 22 29 29 |en(argv[|i],"r"))|
|00002520| 3d 3d 4e 55 4c 4c 29 0d | 20 20 20 20 20 20 20 20 |==NULL).| |
|00002530| 20 20 20 20 20 20 20 20 | 20 20 20 20 65 72 72 6f | | erro|
|00002540| 72 6d 73 67 28 45 72 72 | 6f 72 2c 20 22 25 73 3a |rmsg(Err|or, "%s:|
|00002550| 20 63 6f 75 6c 64 6e 27 | 74 20 6f 70 65 6e 20 66 | couldn'|t open f|
|00002560| 69 6c 65 20 25 73 5c 6e | 22 2c 20 6d 79 73 65 6c |ile %s\n|", mysel|
|00002570| 66 2c 20 61 72 67 76 5b | 69 5d 29 3b 0d 20 20 20 |f, argv[|i]);. |
|00002580| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 65 6c 73 | | els|
|00002590| 65 20 7b 0d 20 20 20 20 | 20 20 20 20 20 20 20 20 |e {. | |
|000025a0| 20 20 20 20 20 20 20 20 | 6d 61 72 6b 75 70 28 66 | |markup(f|
|000025b0| 70 2c 73 74 64 6f 75 74 | 2c 61 72 67 76 5b 69 5d |p,stdout|,argv[i]|
|000025c0| 29 3b 0d 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |);. | |
|000025d0| 20 20 20 20 20 20 20 66 | 63 6c 6f 73 65 28 66 70 | f|close(fp|
|000025e0| 29 3b 0d 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |);. | |
|000025f0| 20 20 20 7d 0d 20 20 20 | 20 20 20 20 20 7d 0d 20 | }. | }. |
|00002600| 20 20 20 65 6c 73 65 0d | 20 20 20 20 20 20 20 20 | else.| |
|00002610| 6d 61 72 6b 75 70 28 73 | 74 64 69 6e 2c 73 74 64 |markup(s|tdin,std|
|00002620| 6f 75 74 2c 22 22 29 3b | 0d 20 20 20 20 65 78 69 |out,"");|. exi|
|00002630| 74 28 65 72 72 6f 72 6c | 65 76 65 6c 29 3b 0d 20 |t(errorl|evel);. |
|00002640| 20 20 20 72 65 74 75 72 | 6e 20 65 72 72 6f 72 6c | retur|n errorl|
|00002650| 65 76 65 6c 3b 20 09 09 | 2f 2a 20 73 6c 61 79 20 |evel; ..|/* slay |
|00002660| 77 61 72 6e 69 6e 67 20 | 2a 2f 0d 7d 0d 40 0d 3c |warning |*/.}.@.<|
|00002670| 3c 68 61 6e 64 6c 65 20 | 5b 5b 2d 74 5d 5d 3e 3e |<handle |[[-t]]>>|
|00002680| 3d 0d 69 66 20 28 69 73 | 64 69 67 69 74 28 61 72 |=.if (is|digit(ar|
|00002690| 67 76 5b 69 5d 5b 32 5d | 29 29 0d 20 20 20 20 74 |gv[i][2]|)). t|
|000026a0| 61 62 73 69 7a 65 20 3d | 20 61 74 6f 69 28 61 72 |absize =| atoi(ar|
|000026b0| 67 76 5b 69 5d 2b 32 29 | 3b 0d 65 6c 73 65 20 69 |gv[i]+2)|;.else i|
|000026c0| 66 20 28 61 72 67 76 5b | 69 5d 5b 32 5d 3d 3d 30 |f (argv[|i][2]==0|
|000026d0| 29 0d 20 20 20 20 74 61 | 62 73 69 7a 65 20 3d 20 |). ta|bsize = |
|000026e0| 30 3b 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |0; | |
|000026f0| 20 20 2f 2a 20 6e 6f 20 | 74 61 62 73 20 2a 2f 0d | /* no |tabs */.|
|00002700| 65 6c 73 65 20 0d 20 20 | 20 20 65 72 72 6f 72 6d |else . | errorm|
|00002710| 73 67 28 45 72 72 6f 72 | 2c 20 22 25 73 3a 20 69 |sg(Error|, "%s: i|
|00002720| 6c 6c 2d 66 6f 72 6d 65 | 64 20 6f 70 74 69 6f 6e |ll-forme|d option|
|00002730| 20 25 73 5c 6e 22 2c 20 | 6d 79 73 65 6c 66 2c 20 | %s\n", |myself, |
|00002740| 61 72 67 76 5b 69 5d 29 | 3b 0d |argv[i])|;. |
+--------+-------------------------+-------------------------+--------+--------+