home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume34 / splash / part01 next >
SHell self-extracting ARchive  |  1993-01-18  |  52.8 KB

view JSON data     |     view as text     |     open on a Mac     |     open on a PC

This file was processed as: SHell self-extracting ARchive (archive/shar).

You can browse this item here: part01

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file ASCII text default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000010| 2e 73 6f 75 72 63 65 73 | 2e 6d 69 73 63 0a 46 72 |.sources|.misc.Fr|
|00000020| 6f 6d 3a 20 6d 6f 72 72 | 69 73 40 6e 65 74 63 6f |om: morr|is@netco|
|00000030| 6d 2e 63 6f 6d 20 28 4a | 69 6d 20 4d 6f 72 72 69 |m.com (J|im Morri|
|00000040| 73 29 0a 53 75 62 6a 65 | 63 74 3a 20 76 33 34 69 |s).Subje|ct: v34i|
|00000050| 31 32 31 3a 20 73 70 6c | 61 73 68 20 2d 20 53 6d |121: spl|ash - Sm|
|00000060| 61 6c 6c 20 50 65 72 6c | 2d 6c 69 6b 65 20 4c 69 |all Perl|-like Li|
|00000070| 73 74 20 41 6e 64 20 53 | 74 72 69 6e 67 20 48 61 |st And S|tring Ha|
|00000080| 6e 64 6c 69 6e 67 20 63 | 6c 61 73 73 20 6c 69 62 |ndling c|lass lib|
|00000090| 2c 20 76 31 2e 38 2c 20 | 50 61 72 74 30 31 2f 30 |, v1.8, |Part01/0|
|000000a0| 33 0a 4d 65 73 73 61 67 | 65 2d 49 44 3a 20 3c 63 |3.Messag|e-ID: <c|
|000000b0| 73 6d 2d 76 33 34 69 31 | 32 31 3d 73 70 6c 61 73 |sm-v34i1|21=splas|
|000000c0| 68 2e 31 35 34 31 35 30 | 40 73 70 61 72 6b 79 2e |h.154150|@sparky.|
|000000d0| 49 4d 44 2e 53 74 65 72 | 6c 69 6e 67 2e 43 4f 4d |IMD.Ster|ling.COM|
|000000e0| 3e 0a 58 2d 4d 64 34 2d | 53 69 67 6e 61 74 75 72 |>.X-Md4-|Signatur|
|000000f0| 65 3a 20 32 36 30 31 30 | 38 35 63 38 34 34 62 31 |e: 26010|85c844b1|
|00000100| 32 36 63 63 63 35 31 62 | 37 33 66 66 66 37 30 31 |26ccc51b|73fff701|
|00000110| 61 66 61 0a 44 61 74 65 | 3a 20 4d 6f 6e 2c 20 31 |afa.Date|: Mon, 1|
|00000120| 38 20 4a 61 6e 20 31 39 | 39 33 20 32 31 3a 34 32 |8 Jan 19|93 21:42|
|00000130| 3a 34 37 20 47 4d 54 0a | 41 70 70 72 6f 76 65 64 |:47 GMT.|Approved|
|00000140| 3a 20 6b 65 6e 74 40 73 | 70 61 72 6b 79 2e 69 6d |: kent@s|parky.im|
|00000150| 64 2e 73 74 65 72 6c 69 | 6e 67 2e 63 6f 6d 0a 0a |d.sterli|ng.com..|
|00000160| 53 75 62 6d 69 74 74 65 | 64 2d 62 79 3a 20 6d 6f |Submitte|d-by: mo|
|00000170| 72 72 69 73 40 6e 65 74 | 63 6f 6d 2e 63 6f 6d 20 |rris@net|com.com |
|00000180| 28 4a 69 6d 20 4d 6f 72 | 72 69 73 29 0a 50 6f 73 |(Jim Mor|ris).Pos|
|00000190| 74 69 6e 67 2d 6e 75 6d | 62 65 72 3a 20 56 6f 6c |ting-num|ber: Vol|
|000001a0| 75 6d 65 20 33 34 2c 20 | 49 73 73 75 65 20 31 32 |ume 34, |Issue 12|
|000001b0| 31 0a 41 72 63 68 69 76 | 65 2d 6e 61 6d 65 3a 20 |1.Archiv|e-name: |
|000001c0| 73 70 6c 61 73 68 2f 70 | 61 72 74 30 31 0a 45 6e |splash/p|art01.En|
|000001d0| 76 69 72 6f 6e 6d 65 6e | 74 3a 20 43 2b 2b 0a 0a |vironmen|t: C++..|
|000001e0| 53 50 4c 41 53 48 20 69 | 73 20 61 20 63 2b 2b 20 |SPLASH i|s a c++ |
|000001f0| 63 6c 61 73 73 20 6c 69 | 62 72 61 72 79 20 74 68 |class li|brary th|
|00000200| 61 74 20 69 6d 70 6c 65 | 6d 65 6e 74 73 20 61 20 |at imple|ments a |
|00000210| 73 74 72 69 6e 67 20 64 | 61 74 61 20 74 79 70 65 |string d|ata type|
|00000220| 20 61 6e 64 20 61 0a 6c | 69 73 74 20 64 61 74 61 | and a.l|ist data|
|00000230| 20 74 79 70 65 2e 20 54 | 68 65 73 65 20 64 61 74 | type. T|hese dat|
|00000240| 61 20 74 79 70 65 73 20 | 61 72 65 20 62 61 73 65 |a types |are base|
|00000250| 64 20 6f 6e 20 74 68 65 | 20 65 71 75 69 76 61 6c |d on the| equival|
|00000260| 65 6e 74 20 64 61 74 61 | 20 74 79 70 65 73 0a 66 |ent data| types.f|
|00000270| 6f 75 6e 64 20 69 6e 20 | 4c 61 72 72 79 20 57 61 |ound in |Larry Wa|
|00000280| 6c 6c 27 73 20 50 65 72 | 6c 20 6c 61 6e 67 75 61 |ll's Per|l langua|
|00000290| 67 65 2e 0a 0a 53 70 6c | 61 73 68 20 68 61 73 20 |ge...Spl|ash has |
|000002a0| 65 78 74 65 6e 73 69 76 | 65 20 72 65 67 75 6c 61 |extensiv|e regula|
|000002b0| 72 20 65 78 70 72 65 73 | 73 69 6f 6e 20 6f 70 65 |r expres|sion ope|
|000002c0| 72 61 74 69 6f 6e 73 20 | 6f 6e 20 73 74 72 69 6e |rations |on strin|
|000002d0| 67 73 20 61 6e 64 20 6c | 69 73 74 73 0a 6f 66 20 |gs and l|ists.of |
|000002e0| 73 74 72 69 6e 67 73 20 | 61 73 20 77 65 6c 6c 20 |strings |as well |
|000002f0| 61 73 20 74 68 65 20 74 | 79 70 69 63 61 6c 20 73 |as the t|ypical s|
|00000300| 74 72 69 6e 67 20 6f 70 | 65 72 61 74 69 6f 6e 73 |tring op|erations|
|00000310| 2e 0a 0a 54 68 65 20 6c | 69 73 74 20 64 61 74 61 |...The l|ist data|
|00000320| 20 74 79 70 65 20 61 6c | 6c 6f 77 73 20 65 6e 74 | type al|lows ent|
|00000330| 72 79 20 6f 66 20 64 61 | 74 61 20 74 6f 20 74 68 |ry of da|ta to th|
|00000340| 65 20 74 6f 70 2c 20 62 | 6f 74 74 6f 6d 20 61 6e |e top, b|ottom an|
|00000350| 64 20 6d 69 64 64 6c 65 | 0a 6f 66 20 74 68 65 20 |d middle|.of the |
|00000360| 6c 69 73 74 2e 20 49 74 | 20 61 6c 73 6f 20 69 6d |list. It| also im|
|00000370| 70 6c 65 6d 65 6e 74 73 | 20 74 68 65 20 61 62 69 |plements| the abi|
|00000380| 6c 69 74 79 20 74 6f 20 | 65 78 74 72 61 63 74 20 |lity to |extract |
|00000390| 73 6c 69 63 65 73 20 66 | 72 6f 6d 0a 6c 69 73 74 |slices f|rom.list|
|000003a0| 73 2e 0a 0a 41 6e 20 61 | 73 73 6f 63 69 61 74 69 |s...An a|ssociati|
|000003b0| 76 65 20 61 72 72 61 79 | 20 64 61 74 61 20 74 79 |ve array| data ty|
|000003c0| 70 65 2c 20 69 73 20 61 | 6c 73 6f 20 69 6d 70 6c |pe, is a|lso impl|
|000003d0| 65 6d 65 6e 74 65 64 20 | 75 73 69 6e 67 20 74 68 |emented |using th|
|000003e0| 65 20 6c 69 73 74 20 63 | 6c 61 73 73 2e 0a 0a 2d |e list c|lass...-|
|000003f0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000400| 0a 23 21 20 2f 62 69 6e | 2f 73 68 0a 23 20 54 68 |.#! /bin|/sh.# Th|
|00000410| 69 73 20 69 73 20 61 20 | 73 68 65 6c 6c 20 61 72 |is is a |shell ar|
|00000420| 63 68 69 76 65 2e 20 20 | 52 65 6d 6f 76 65 20 61 |chive. |Remove a|
|00000430| 6e 79 74 68 69 6e 67 20 | 62 65 66 6f 72 65 20 74 |nything |before t|
|00000440| 68 69 73 20 6c 69 6e 65 | 2c 20 74 68 65 6e 20 66 |his line|, then f|
|00000450| 65 65 64 20 69 74 0a 23 | 20 69 6e 74 6f 20 61 20 |eed it.#| into a |
|00000460| 73 68 65 6c 6c 20 76 69 | 61 20 22 73 68 20 66 69 |shell vi|a "sh fi|
|00000470| 6c 65 22 20 6f 72 20 73 | 69 6d 69 6c 61 72 2e 20 |le" or s|imilar. |
|00000480| 20 54 6f 20 6f 76 65 72 | 77 72 69 74 65 20 65 78 | To over|write ex|
|00000490| 69 73 74 69 6e 67 20 66 | 69 6c 65 73 2c 0a 23 20 |isting f|iles,.# |
|000004a0| 74 79 70 65 20 22 73 68 | 20 66 69 6c 65 20 2d 63 |type "sh| file -c|
|000004b0| 22 2e 0a 23 20 43 6f 6e | 74 65 6e 74 73 3a 20 20 |"..# Con|tents: |
|000004c0| 52 45 41 44 4d 45 20 50 | 61 74 63 68 6c 65 76 65 |README P|atchleve|
|000004d0| 6c 20 72 65 67 65 78 2e | 63 20 73 61 6d 70 6c 65 |l regex.|c sample|
|000004e0| 20 73 6c 69 63 65 74 73 | 74 2e 76 20 73 70 6c 61 | slicets|t.v spla|
|000004f0| 73 68 2e 64 6f 63 0a 23 | 20 57 72 61 70 70 65 64 |sh.doc.#| Wrapped|
|00000500| 20 62 79 20 6b 65 6e 74 | 40 73 70 61 72 6b 79 20 | by kent|@sparky |
|00000510| 6f 6e 20 4d 6f 6e 20 4a | 61 6e 20 31 38 20 31 35 |on Mon J|an 18 15|
|00000520| 3a 32 39 3a 30 34 20 31 | 39 39 33 0a 50 41 54 48 |:29:04 1|993.PATH|
|00000530| 3d 2f 62 69 6e 3a 2f 75 | 73 72 2f 62 69 6e 3a 2f |=/bin:/u|sr/bin:/|
|00000540| 75 73 72 2f 75 63 62 3a | 2f 75 73 72 2f 6c 6f 63 |usr/ucb:|/usr/loc|
|00000550| 61 6c 2f 62 69 6e 3a 2f | 75 73 72 2f 6c 62 69 6e |al/bin:/|usr/lbin|
|00000560| 20 3b 20 65 78 70 6f 72 | 74 20 50 41 54 48 0a 65 | ; expor|t PATH.e|
|00000570| 63 68 6f 20 49 66 20 74 | 68 69 73 20 61 72 63 68 |cho If t|his arch|
|00000580| 69 76 65 20 69 73 20 63 | 6f 6d 70 6c 65 74 65 2c |ive is c|omplete,|
|00000590| 20 79 6f 75 20 77 69 6c | 6c 20 73 65 65 20 74 68 | you wil|l see th|
|000005a0| 65 20 66 6f 6c 6c 6f 77 | 69 6e 67 20 6d 65 73 73 |e follow|ing mess|
|000005b0| 61 67 65 3a 0a 65 63 68 | 6f 20 27 20 20 20 20 20 |age:.ech|o ' |
|000005c0| 20 20 20 20 20 22 73 68 | 61 72 3a 20 45 6e 64 20 | "sh|ar: End |
|000005d0| 6f 66 20 61 72 63 68 69 | 76 65 20 31 20 28 6f 66 |of archi|ve 1 (of|
|000005e0| 20 33 29 2e 22 27 0a 69 | 66 20 74 65 73 74 20 2d | 3)."'.i|f test -|
|000005f0| 66 20 27 52 45 41 44 4d | 45 27 20 2d 61 20 22 24 |f 'READM|E' -a "$|
|00000600| 7b 31 7d 22 20 21 3d 20 | 22 2d 63 22 20 3b 20 74 |{1}" != |"-c" ; t|
|00000610| 68 65 6e 20 0a 20 20 65 | 63 68 6f 20 73 68 61 72 |hen . e|cho shar|
|00000620| 3a 20 57 69 6c 6c 20 6e | 6f 74 20 63 6c 6f 62 62 |: Will n|ot clobb|
|00000630| 65 72 20 65 78 69 73 74 | 69 6e 67 20 66 69 6c 65 |er exist|ing file|
|00000640| 20 5c 22 27 52 45 41 44 | 4d 45 27 5c 22 0a 65 6c | \"'READ|ME'\".el|
|00000650| 73 65 0a 20 20 65 63 68 | 6f 20 73 68 61 72 3a 20 |se. ech|o shar: |
|00000660| 45 78 74 72 61 63 74 69 | 6e 67 20 5c 22 27 52 45 |Extracti|ng \"'RE|
|00000670| 41 44 4d 45 27 5c 22 20 | 5c 28 36 38 38 37 20 63 |ADME'\" |\(6887 c|
|00000680| 68 61 72 61 63 74 65 72 | 73 5c 29 0a 20 20 73 65 |haracter|s\). se|
|00000690| 64 20 22 73 2f 5e 58 2f | 2f 22 20 3e 27 52 45 41 |d "s/^X/|/" >'REA|
|000006a0| 44 4d 45 27 20 3c 3c 27 | 45 4e 44 5f 4f 46 5f 46 |DME' <<'|END_OF_F|
|000006b0| 49 4c 45 27 0a 58 54 68 | 65 20 53 50 4c 41 53 48 |ILE'.XTh|e SPLASH|
|000006c0| 20 63 2b 2b 20 63 6c 61 | 73 73 20 6c 69 62 72 61 | c++ cla|ss libra|
|000006d0| 72 79 0a 58 3d 3d 3d 3d | 3d 3d 3d 3d 3d 3d 3d 3d |ry.X====|========|
|000006e0| 3d 3d 3d 3d 3d 3d 3d 3d | 3d 3d 3d 3d 3d 3d 3d 3d |========|========|
|000006f0| 0a 58 0a 58 28 53 6d 61 | 6c 6c 20 50 65 72 6c 2d |.X.X(Sma|ll Perl-|
|00000700| 6c 69 6b 65 20 4c 69 73 | 74 20 41 6e 64 20 53 74 |like Lis|t And St|
|00000710| 72 69 6e 67 20 48 61 6e | 64 6c 69 6e 67 20 63 6c |ring Han|dling cl|
|00000720| 61 73 73 20 6c 69 62 72 | 61 72 79 29 0a 58 0a 58 |ass libr|ary).X.X|
|00000730| 0a 58 53 50 4c 41 53 48 | 20 69 73 20 61 20 63 2b |.XSPLASH| is a c+|
|00000740| 2b 20 63 6c 61 73 73 20 | 6c 69 62 72 61 72 79 20 |+ class |library |
|00000750| 74 68 61 74 20 69 6d 70 | 6c 65 6d 65 6e 74 73 20 |that imp|lements |
|00000760| 6d 79 20 66 61 76 6f 75 | 72 69 74 65 20 50 65 72 |my favou|rite Per|
|00000770| 6c 0a 58 63 6f 6e 73 74 | 72 75 63 74 73 2e 0a 58 |l.Xconst|ructs..X|
|00000780| 0a 58 46 6f 72 20 74 68 | 6f 73 65 20 6e 6f 74 20 |.XFor th|ose not |
|00000790| 66 61 6d 69 6c 69 61 72 | 20 77 69 74 68 20 50 65 |familiar| with Pe|
|000007a0| 72 6c 2c 20 69 74 20 69 | 73 20 61 6e 20 65 78 63 |rl, it i|s an exc|
|000007b0| 65 6c 6c 65 6e 74 20 73 | 63 72 69 70 74 69 6e 67 |ellent s|cripting|
|000007c0| 20 6c 61 6e 67 75 61 67 | 65 0a 58 62 79 20 4c 61 | languag|e.Xby La|
|000007d0| 72 72 79 20 57 61 6c 6c | 20 61 6e 64 20 69 73 20 |rry Wall| and is |
|000007e0| 61 76 61 69 6c 61 62 6c | 65 20 66 6f 72 20 6d 6f |availabl|e for mo|
|000007f0| 73 74 20 70 6c 61 74 66 | 6f 72 6d 73 2e 0a 58 0a |st platf|orms..X.|
|00000800| 58 54 68 69 73 20 43 6c | 61 73 73 20 6c 69 62 72 |XThis Cl|ass libr|
|00000810| 61 72 79 20 70 72 6f 76 | 69 64 65 73 20 4c 69 73 |ary prov|ides Lis|
|00000820| 74 20 61 6e 64 20 53 74 | 72 69 6e 67 20 68 61 6e |t and St|ring han|
|00000830| 64 6c 69 6e 67 20 63 61 | 70 61 62 69 6c 69 74 69 |dling ca|pabiliti|
|00000840| 65 73 20 62 61 73 65 64 | 0a 58 6f 6e 20 74 68 6f |es based|.Xon tho|
|00000850| 73 65 20 70 72 6f 76 69 | 64 65 64 20 69 6e 20 50 |se provi|ded in P|
|00000860| 65 72 6c 2c 20 62 65 63 | 61 75 73 65 20 74 68 65 |erl, bec|ause the|
|00000870| 20 50 65 72 6c 20 63 6f | 6e 73 74 72 75 63 74 73 | Perl co|nstructs|
|00000880| 20 61 72 65 20 73 6f 20 | 75 73 65 66 75 6c 2e 0a | are so |useful..|
|00000890| 58 0a 58 4f 76 65 72 76 | 69 65 77 0a 58 2d 2d 2d |X.XOverv|iew.X---|
|000008a0| 2d 2d 2d 2d 2d 20 0a 58 | 49 6e 20 61 20 6e 75 74 |----- .X|In a nut|
|000008b0| 2d 73 68 65 6c 6c 20 53 | 50 4c 41 53 48 20 70 72 |-shell S|PLASH pr|
|000008c0| 6f 76 69 64 65 73 20 61 | 20 44 79 6e 61 6d 69 63 |ovides a| Dynamic|
|000008d0| 20 4c 69 73 74 20 74 65 | 6d 70 6c 61 74 65 20 63 | List te|mplate c|
|000008e0| 6c 61 73 73 0a 58 28 53 | 50 4c 69 73 74 3c 54 3e |lass.X(S|PList<T>|
|000008f0| 29 20 74 68 61 74 20 61 | 6c 6c 6f 77 73 20 79 6f |) that a|llows yo|
|00000900| 75 20 74 6f 20 61 64 64 | 20 61 6e 64 20 65 78 74 |u to add| and ext|
|00000910| 72 61 63 74 20 64 61 74 | 61 20 66 72 6f 6d 20 74 |ract dat|a from t|
|00000920| 68 65 20 74 6f 70 20 6f | 66 20 74 68 65 0a 58 6c |he top o|f the.Xl|
|00000930| 69 73 74 20 28 70 75 73 | 68 20 26 20 70 6f 70 29 |ist (pus|h & pop)|
|00000940| 2c 20 61 6e 64 20 66 72 | 6f 6d 20 74 68 65 20 62 |, and fr|om the b|
|00000950| 6f 74 74 6f 6d 20 6f 66 | 20 74 68 65 20 6c 69 73 |ottom of| the lis|
|00000960| 74 20 28 75 6e 73 68 69 | 66 74 20 26 20 73 68 69 |t (unshi|ft & shi|
|00000970| 66 74 29 2e 0a 58 69 65 | 20 61 20 46 49 46 4f 20 |ft)..Xie| a FIFO |
|00000980| 63 6f 75 6c 64 20 62 65 | 20 69 6d 70 6c 65 6d 65 |could be| impleme|
|00000990| 6e 74 65 64 20 62 79 20 | 70 75 73 68 27 69 6e 67 |nted by |push'ing|
|000009a0| 20 64 61 74 61 20 6f 6e | 74 6f 20 74 68 65 20 6c | data on|to the l|
|000009b0| 69 73 74 20 61 6e 64 0a | 58 73 68 69 66 74 27 69 |ist and.|Xshift'i|
|000009c0| 6e 67 20 64 61 74 61 20 | 6f 66 66 20 74 68 65 20 |ng data |off the |
|000009d0| 6c 69 73 74 2e 20 20 54 | 68 65 20 6c 69 73 74 20 |list. T|he list |
|000009e0| 63 61 6e 20 62 65 20 73 | 6f 72 74 65 64 20 28 75 |can be s|orted (u|
|000009f0| 73 65 73 20 6f 70 65 72 | 61 74 6f 72 3c 20 6f 6e |ses oper|ator< on|
|00000a00| 0a 58 74 68 65 20 65 6c | 65 6d 65 6e 74 73 29 20 |.Xthe el|ements) |
|00000a10| 61 6e 64 20 72 65 76 65 | 72 73 65 64 2e 20 20 28 |and reve|rsed. (|
|00000a20| 6d 79 6c 69 73 74 2e 73 | 6f 72 74 28 29 2e 72 65 |mylist.s|ort().re|
|00000a30| 76 65 72 73 65 28 29 20 | 77 69 6c 6c 20 70 72 6f |verse() |will pro|
|00000a40| 64 75 63 65 20 61 0a 58 | 6c 69 73 74 20 73 6f 72 |duce a.X|list sor|
|00000a50| 74 65 64 20 69 6e 20 72 | 65 76 65 72 73 65 20 6f |ted in r|everse o|
|00000a60| 72 64 65 72 29 2e 20 20 | 41 6e 6f 74 68 65 72 20 |rder). |Another |
|00000a70| 6c 69 73 74 20 63 61 6e | 20 62 65 20 69 6e 73 65 |list can| be inse|
|00000a80| 72 74 65 64 20 61 6e 79 | 77 68 65 72 65 0a 58 69 |rted any|where.Xi|
|00000a90| 6e 20 61 20 6c 69 73 74 | 2c 20 6f 72 20 65 6c 65 |n a list|, or ele|
|00000aa0| 6d 65 6e 74 73 20 64 65 | 6c 65 74 65 64 20 66 72 |ments de|leted fr|
|00000ab0| 6f 6d 20 77 69 74 68 69 | 6e 20 74 68 65 20 6c 69 |om withi|n the li|
|00000ac0| 73 74 20 28 73 70 6c 69 | 63 65 29 2e 20 20 41 6e |st (spli|ce). An|
|00000ad0| 64 20 61 6e 79 0a 58 69 | 6e 64 69 76 69 64 75 61 |d any.Xi|ndividua|
|00000ae0| 6c 20 65 6c 65 6d 65 6e | 74 20 63 61 6e 20 62 65 |l elemen|t can be|
|00000af0| 20 61 63 63 65 73 73 65 | 64 20 75 73 69 6e 67 20 | accesse|d using |
|00000b00| 74 68 65 20 27 5b 5d 27 | 20 6f 70 65 72 61 74 6f |the '[]'| operato|
|00000b10| 72 2e 0a 58 0a 58 54 68 | 65 20 53 74 72 69 6e 67 |r..X.XTh|e String|
|00000b20| 20 63 6c 61 73 73 20 28 | 53 50 53 74 72 69 6e 67 | class (|SPString|
|00000b30| 29 20 69 6d 70 6c 65 6d | 65 6e 74 73 20 61 20 44 |) implem|ents a D|
|00000b40| 79 6e 61 6d 69 63 20 73 | 74 72 69 6e 67 20 77 68 |ynamic s|tring wh|
|00000b50| 69 63 68 20 70 72 6f 76 | 69 64 65 73 0a 58 61 6e |ich prov|ides.Xan|
|00000b60| 20 69 6e 64 65 78 28 29 | 20 61 6e 64 20 72 69 6e | index()| and rin|
|00000b70| 64 65 78 28 29 20 66 75 | 6e 63 74 69 6f 6e 20 74 |dex() fu|nction t|
|00000b80| 68 61 74 20 66 69 6e 64 | 73 20 74 68 65 20 6f 66 |hat find|s the of|
|00000b90| 66 73 65 74 20 77 69 74 | 68 69 6e 20 74 68 65 0a |fset wit|hin the.|
|00000ba0| 58 73 74 72 69 6e 67 20 | 6f 66 20 61 20 73 75 62 |Xstring |of a sub|
|00000bb0| 2d 73 74 72 69 6e 67 2e | 20 41 20 73 75 62 73 74 |-string.| A subst|
|00000bc0| 72 69 6e 67 20 6d 61 79 | 20 62 65 20 65 78 74 72 |ring may| be extr|
|00000bd0| 61 63 74 65 64 20 66 72 | 6f 6d 20 74 68 65 20 73 |acted fr|om the s|
|00000be0| 74 72 69 6e 67 2c 0a 58 | 6f 72 20 61 73 73 69 67 |tring,.X|or assig|
|00000bf0| 6e 65 64 20 74 6f 20 77 | 69 74 68 69 6e 20 61 20 |ned to w|ithin a |
|00000c00| 73 74 72 69 6e 67 20 28 | 65 78 70 61 6e 64 69 6e |string (|expandin|
|00000c10| 67 20 6f 72 20 73 68 72 | 69 6e 6b 69 6e 67 20 74 |g or shr|inking t|
|00000c20| 68 65 20 73 74 72 69 6e | 67 20 61 73 0a 58 72 65 |he strin|g as.Xre|
|00000c30| 71 75 69 72 65 64 29 2e | 20 54 68 65 20 73 74 72 |quired).| The str|
|00000c40| 69 6e 67 20 6d 61 79 20 | 62 65 20 75 73 65 64 20 |ing may |be used |
|00000c50| 61 6e 79 77 68 65 72 65 | 20 61 20 63 6f 6e 73 74 |anywhere| a const|
|00000c60| 20 63 68 61 72 20 2a 20 | 63 61 6e 20 62 65 20 75 | char * |can be u|
|00000c70| 73 65 64 2e 0a 58 54 68 | 65 20 73 74 61 6e 64 61 |sed..XTh|e standa|
|00000c80| 72 64 20 63 6f 6d 70 61 | 72 69 73 6f 6e 20 66 75 |rd compa|rison fu|
|00000c90| 6e 63 74 69 6f 6e 73 20 | 28 3c 20 3e 20 3d 3d 20 |nctions |(< > == |
|00000ca0| 65 74 63 29 20 61 72 65 | 20 61 76 61 69 6c 61 62 |etc) are| availab|
|00000cb0| 6c 65 2e 20 20 49 74 0a | 58 61 6c 6c 6f 77 73 20 |le. It.|Xallows |
|00000cc0| 73 74 72 69 6e 67 20 63 | 6f 6e 63 61 74 65 6e 61 |string c|oncatena|
|00000cd0| 74 69 6f 6e 20 75 73 69 | 6e 67 20 74 68 65 20 27 |tion usi|ng the '|
|00000ce0| 2b 27 20 61 6e 64 20 27 | 2b 3d 27 20 6f 70 65 72 |+' and '|+=' oper|
|00000cf0| 61 74 6f 72 2e 20 20 49 | 74 0a 58 70 72 6f 76 69 |ator. I|t.Xprovi|
|00000d00| 64 65 73 20 72 65 67 75 | 6c 61 72 20 65 78 70 72 |des regu|lar expr|
|00000d10| 65 73 73 69 6f 6e 73 20 | 28 77 69 74 68 20 73 75 |essions |(with su|
|00000d20| 62 2d 65 78 70 72 65 73 | 73 69 6f 6e 20 65 78 74 |b-expres|sion ext|
|00000d30| 72 61 63 74 69 6f 6e 29 | 20 74 68 61 74 20 63 61 |raction)| that ca|
|00000d40| 6e 0a 58 62 65 20 65 61 | 73 69 6c 79 20 61 70 70 |n.Xbe ea|sily app|
|00000d50| 6c 69 65 64 20 74 6f 20 | 74 68 65 20 73 74 72 69 |lied to |the stri|
|00000d60| 6e 67 73 2e 20 41 20 70 | 6f 77 65 72 66 75 6c 20 |ngs. A p|owerful |
|00000d70| 73 75 62 73 74 69 74 75 | 74 65 20 66 75 6e 63 74 |substitu|te funct|
|00000d80| 69 6f 6e 20 61 6e 64 0a | 58 74 72 61 6e 73 6c 61 |ion and.|Xtransla|
|00000d90| 74 69 6f 6e 20 66 75 6e | 63 74 69 6f 6e 20 28 73 |tion fun|ction (s|
|00000da0| 28 29 20 61 6e 64 20 74 | 72 28 29 29 20 61 72 65 |() and t|r()) are|
|00000db0| 20 61 76 61 69 6c 61 62 | 6c 65 2e 0a 58 0a 58 54 | availab|le..X.XT|
|00000dc0| 68 65 20 53 74 72 69 6e | 67 20 4c 69 73 74 20 63 |he Strin|g List c|
|00000dd0| 6c 61 73 73 20 28 53 50 | 53 74 72 69 6e 67 4c 69 |lass (SP|StringLi|
|00000de0| 73 74 29 20 69 73 20 62 | 61 73 69 63 61 6c 6c 79 |st) is b|asically|
|00000df0| 20 61 20 4c 69 73 74 20 | 63 6c 61 73 73 20 77 69 | a List |class wi|
|00000e00| 74 68 0a 58 73 6f 6d 65 | 20 61 64 64 65 64 20 66 |th.Xsome| added f|
|00000e10| 75 6e 63 74 69 6f 6e 61 | 6c 69 74 79 20 73 70 65 |unctiona|lity spe|
|00000e20| 63 69 66 69 63 20 74 6f | 20 6c 69 73 74 73 20 6f |cific to| lists o|
|00000e30| 66 20 73 74 72 69 6e 67 | 73 2e 20 49 74 20 6c 65 |f string|s. It le|
|00000e40| 74 73 20 79 6f 75 20 67 | 72 65 70 0a 58 66 6f 72 |ts you g|rep.Xfor|
|00000e50| 20 61 20 72 65 67 75 6c | 61 72 20 65 78 70 72 65 | a regul|ar expre|
|00000e60| 73 73 69 6f 6e 20 77 69 | 74 68 69 6e 20 74 68 65 |ssion wi|thin the|
|00000e70| 20 6c 69 73 74 2c 20 72 | 65 74 75 72 6e 69 6e 67 | list, r|eturning|
|00000e80| 20 61 20 6c 69 73 74 20 | 6f 66 20 73 74 72 69 6e | a list |of strin|
|00000e90| 67 73 0a 58 74 68 61 74 | 20 6d 61 74 63 68 2e 20 |gs.Xthat| match. |
|00000ea0| 49 74 20 6c 65 74 73 20 | 79 6f 75 20 67 65 6e 65 |It lets |you gene|
|00000eb0| 72 61 74 65 20 61 20 6c | 69 73 74 20 6f 66 20 73 |rate a l|ist of s|
|00000ec0| 74 72 69 6e 67 73 20 66 | 72 6f 6d 20 61 20 73 69 |trings f|rom a si|
|00000ed0| 6e 67 6c 65 20 73 74 72 | 69 6e 67 0a 58 62 79 20 |ngle str|ing.Xby |
|00000ee0| 73 70 6c 69 74 74 69 6e | 67 20 74 68 65 20 73 74 |splittin|g the st|
|00000ef0| 72 69 6e 67 20 61 74 20 | 61 20 67 69 76 65 6e 20 |ring at |a given |
|00000f00| 72 65 67 75 6c 61 72 20 | 65 78 70 72 65 73 73 69 |regular |expressi|
|00000f10| 6f 6e 20 28 74 6f 6b 65 | 6e 20 70 61 72 73 69 6e |on (toke|n parsin|
|00000f20| 67 29 2e 0a 58 49 74 20 | 6c 65 74 73 20 79 6f 75 |g)..XIt |lets you|
|00000f30| 20 67 65 6e 65 72 61 74 | 65 20 61 20 73 69 6e 67 | generat|e a sing|
|00000f40| 6c 65 20 73 74 72 69 6e | 67 20 62 79 20 63 6f 6e |le strin|g by con|
|00000f50| 63 61 74 65 6e 61 74 69 | 6e 67 20 61 20 6c 69 73 |catenati|ng a lis|
|00000f60| 74 20 6f 66 20 73 74 72 | 69 6e 67 73 0a 58 73 65 |t of str|ings.Xse|
|00000f70| 70 61 72 61 74 65 64 20 | 62 79 20 61 20 67 69 76 |parated |by a giv|
|00000f80| 65 6e 20 73 74 72 69 6e | 67 2e 0a 58 0a 58 54 68 |en strin|g..X.XTh|
|00000f90| 65 20 41 73 73 6f 63 69 | 61 74 69 76 65 20 61 72 |e Associ|ative ar|
|00000fa0| 72 61 79 20 63 6c 61 73 | 73 20 28 41 73 73 6f 63 |ray clas|s (Assoc|
|00000fb0| 3c 54 3e 29 20 6c 65 74 | 73 20 79 6f 75 20 6b 65 |<T>) let|s you ke|
|00000fc0| 65 70 20 61 20 6c 69 73 | 74 20 77 68 69 63 68 20 |ep a lis|t which |
|00000fd0| 69 73 0a 58 69 6e 64 65 | 78 65 64 20 62 79 20 61 |is.Xinde|xed by a|
|00000fe0| 20 73 74 72 69 6e 67 2e | 0a 58 0a 58 41 6c 6c 20 | string.|.X.XAll |
|00000ff0| 74 68 65 20 43 6c 61 73 | 73 65 73 20 68 61 76 65 |the Clas|ses have|
|00001000| 20 66 75 6c 6c 79 20 69 | 6d 70 6c 65 6d 65 6e 74 | fully i|mplement|
|00001010| 65 64 20 73 74 72 65 61 | 6d 73 20 6f 70 65 72 61 |ed strea|ms opera|
|00001020| 74 6f 72 73 20 66 6f 72 | 20 69 6e 70 75 74 20 61 |tors for| input a|
|00001030| 6e 64 0a 58 6f 75 74 70 | 75 74 2c 20 74 6f 20 61 |nd.Xoutp|ut, to a|
|00001040| 6c 6c 6f 77 20 63 6f 6e | 76 65 6e 69 65 6e 74 20 |llow con|venient |
|00001050| 66 69 6c 65 20 6f 72 20 | 73 74 72 65 61 6d 20 70 |file or |stream p|
|00001060| 72 6f 63 65 73 73 69 6e | 67 2e 0a 58 0a 58 54 68 |rocessin|g..X.XTh|
|00001070| 65 20 52 65 67 65 78 70 | 20 63 6c 61 73 73 20 66 |e Regexp| class f|
|00001080| 75 6c 6c 79 20 65 6e 63 | 61 70 73 75 6c 61 74 65 |ully enc|apsulate|
|00001090| 73 20 74 68 65 20 72 65 | 67 75 6c 61 72 20 65 78 |s the re|gular ex|
|000010a0| 70 72 65 73 73 69 6f 6e | 20 6c 69 62 72 61 72 79 |pression| library|
|000010b0| 2c 20 73 6f 0a 58 79 6f | 75 20 63 61 6e 20 65 61 |, so.Xyo|u can ea|
|000010c0| 73 69 6c 79 20 75 73 65 | 20 79 6f 75 72 20 6f 77 |sily use| your ow|
|000010d0| 6e 20 66 61 76 6f 75 72 | 69 74 65 20 6f 6e 65 2e |n favour|ite one.|
|000010e0| 0a 58 0a 58 55 73 61 67 | 65 20 52 65 73 74 72 69 |.X.XUsag|e Restri|
|000010f0| 63 74 69 6f 6e 73 0a 58 | 2d 2d 2d 2d 2d 2d 2d 2d |ctions.X|--------|
|00001100| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 0a 58 0a 58 54 68 |--------|--.X.XTh|
|00001110| 65 72 65 20 61 72 65 20 | 6e 6f 6e 65 2e 20 54 68 |ere are |none. Th|
|00001120| 69 73 20 43 6f 64 65 20 | 69 73 20 6e 6f 74 20 43 |is Code |is not C|
|00001130| 6f 70 79 72 69 67 68 74 | 2c 20 75 73 65 20 61 73 |opyright|, use as|
|00001140| 20 79 6f 75 20 77 69 6c | 6c 2e 20 20 54 68 65 0a | you wil|l. The.|
|00001150| 58 72 65 67 65 78 70 20 | 63 6f 64 65 20 69 73 20 |Xregexp |code is |
|00001160| 43 6f 70 79 72 69 67 68 | 74 20 62 79 20 48 65 6e |Copyrigh|t by Hen|
|00001170| 72 79 20 53 70 65 6e 63 | 65 72 2c 20 73 65 65 20 |ry Spenc|er, see |
|00001180| 74 68 65 20 63 6f 6d 6d | 65 6e 74 73 20 69 6e 20 |the comm|ents in |
|00001190| 72 65 67 65 78 2e 63 0a | 58 66 6f 72 20 43 6f 70 |regex.c.|Xfor Cop|
|000011a0| 79 72 69 67 68 74 20 69 | 6e 66 6f 2e 20 20 54 68 |yright i|nfo. Th|
|000011b0| 65 20 6f 6e 6c 79 20 63 | 68 61 6e 67 65 73 20 49 |e only c|hanges I|
|000011c0| 20 68 61 76 65 20 6d 61 | 64 65 20 61 72 65 20 74 | have ma|de are t|
|000011d0| 6f 20 74 68 65 20 68 65 | 61 64 65 72 0a 58 66 69 |o the he|ader.Xfi|
|000011e0| 6c 65 2c 20 62 79 20 61 | 64 64 69 6e 67 20 61 20 |le, by a|dding a |
|000011f0| 63 2b 2b 20 70 72 6f 74 | 6f 74 79 70 65 20 66 69 |c++ prot|otype fi|
|00001200| 65 6c 64 2e 0a 58 0a 58 | 43 6c 61 73 73 20 64 65 |eld..X.X|Class de|
|00001210| 73 63 72 69 70 74 69 6f | 6e 0a 58 2d 2d 2d 2d 2d |scriptio|n.X-----|
|00001220| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 0a 58 54 68 |--------|----.XTh|
|00001230| 65 20 43 6c 61 73 73 20 | 48 69 65 72 61 72 63 68 |e Class |Hierarch|
|00001240| 79 20 61 6e 64 20 6d 65 | 6d 62 65 72 20 66 75 6e |y and me|mber fun|
|00001250| 63 74 69 6f 6e 73 20 61 | 72 65 3a 2d 0a 58 0a 58 |ctions a|re:-.X.X|
|00001260| 63 6c 61 73 73 20 53 50 | 4c 69 73 74 3c 54 3e 0a |class SP|List<T>.|
|00001270| 58 20 20 20 20 54 26 20 | 6f 70 65 72 61 74 6f 72 |X T& |operator|
|00001280| 5b 5d 09 2f 2f 20 69 6e | 64 65 78 20 69 6e 74 6f |[].// in|dex into|
|00001290| 20 6c 69 73 74 0a 58 20 | 20 20 20 76 6f 69 64 20 | list.X | void |
|000012a0| 72 65 73 65 74 28 29 09 | 2f 2f 20 63 6c 65 61 72 |reset().|// clear|
|000012b0| 20 6f 75 74 20 6c 69 73 | 74 0a 58 20 20 20 20 69 | out lis|t.X i|
|000012c0| 6e 74 20 73 63 61 6c 61 | 72 28 29 09 2f 2f 20 72 |nt scala|r().// r|
|000012d0| 65 74 75 72 6e 73 20 6e | 75 6d 62 65 72 20 6f 66 |eturns n|umber of|
|000012e0| 20 65 6c 65 6d 65 6e 74 | 73 20 69 6e 20 6c 69 73 | element|s in lis|
|000012f0| 74 0a 58 20 20 20 20 69 | 6e 74 20 63 6f 75 6e 74 |t.X i|nt count|
|00001300| 28 29 09 09 2f 2f 20 64 | 69 74 74 6f 0a 58 20 20 |()..// d|itto.X |
|00001310| 20 20 54 20 70 6f 70 28 | 29 09 09 2f 2f 20 72 65 | T pop(|)..// re|
|00001320| 74 75 72 6e 73 20 61 6e | 64 20 72 65 6d 6f 76 65 |turns an|d remove|
|00001330| 73 20 74 6f 70 20 6f 66 | 20 6c 69 73 74 0a 58 20 |s top of| list.X |
|00001340| 20 20 20 76 6f 69 64 20 | 70 75 73 68 28 54 29 09 | void |push(T).|
|00001350| 2f 2f 20 65 6e 74 65 72 | 73 20 65 6c 65 6d 65 6e |// enter|s elemen|
|00001360| 74 20 6f 6e 74 6f 20 74 | 6f 70 20 6f 66 20 6c 69 |t onto t|op of li|
|00001370| 73 74 0a 58 20 20 20 20 | 76 6f 69 64 20 70 75 73 |st.X |void pus|
|00001380| 68 28 53 50 4c 69 73 74 | 3c 54 3e 29 20 2f 2f 20 |h(SPList|<T>) // |
|00001390| 65 6e 74 65 72 73 20 61 | 20 6c 69 73 74 20 6f 66 |enters a| list of|
|000013a0| 20 65 6c 65 6d 65 6e 74 | 73 20 6f 6e 74 6f 20 74 | element|s onto t|
|000013b0| 6f 70 20 6f 66 20 6c 69 | 73 74 0a 58 20 20 20 20 |op of li|st.X |
|000013c0| 54 20 73 68 69 66 74 28 | 29 09 09 2f 2f 20 72 65 |T shift(|)..// re|
|000013d0| 74 75 72 6e 73 20 26 20 | 72 65 6d 6f 76 65 73 20 |turns & |removes |
|000013e0| 65 6c 65 6d 65 6e 74 20 | 61 74 20 62 6f 74 74 6f |element |at botto|
|000013f0| 6d 20 6f 66 20 6c 69 73 | 74 0a 58 20 20 20 20 69 |m of lis|t.X i|
|00001400| 6e 74 20 75 6e 73 68 69 | 66 74 28 54 29 09 2f 2f |nt unshi|ft(T).//|
|00001410| 20 65 6e 74 65 72 73 20 | 65 6c 65 6d 65 6e 74 20 | enters |element |
|00001420| 69 6e 74 6f 20 62 6f 74 | 74 6f 6d 20 6f 66 20 6c |into bot|tom of l|
|00001430| 69 73 74 0a 58 20 20 20 | 20 69 6e 74 20 75 6e 73 |ist.X | int uns|
|00001440| 68 69 66 74 28 53 50 4c | 69 73 74 3c 54 3e 29 20 |hift(SPL|ist<T>) |
|00001450| 2f 2f 20 65 6e 74 65 72 | 73 20 6c 69 73 74 73 20 |// enter|s lists |
|00001460| 69 6e 74 6f 20 62 6f 74 | 74 6f 6d 20 6f 66 20 6c |into bot|tom of l|
|00001470| 69 73 74 0a 58 20 20 20 | 20 53 50 4c 69 73 74 3c |ist.X | SPList<|
|00001480| 54 3e 20 72 65 76 65 72 | 73 65 28 29 09 20 20 20 |T> rever|se(). |
|00001490| 2f 2f 20 72 65 74 75 72 | 6e 73 20 72 65 76 65 72 |// retur|ns rever|
|000014a0| 73 65 20 6f 72 64 65 72 | 20 6f 66 20 6c 69 73 74 |se order| of list|
|000014b0| 0a 58 20 20 20 20 53 50 | 4c 69 73 74 3c 54 3e 20 |.X SP|List<T> |
|000014c0| 73 70 6c 69 63 65 28 6f | 66 66 73 65 74 29 20 2f |splice(o|ffset) /|
|000014d0| 2f 20 72 65 6d 6f 76 65 | 73 20 65 6c 65 6d 65 6e |/ remove|s elemen|
|000014e0| 74 73 20 69 6e 20 6c 69 | 73 74 20 66 72 6f 6d 20 |ts in li|st from |
|000014f0| 27 6f 66 66 73 65 74 27 | 0a 58 20 20 20 20 53 50 |'offset'|.X SP|
|00001500| 4c 69 73 74 3c 54 3e 20 | 73 70 6c 69 63 65 28 6f |List<T> |splice(o|
|00001510| 66 66 73 65 74 2c 20 6c | 65 6e 29 20 2f 2f 20 72 |ffset, l|en) // r|
|00001520| 65 6d 6f 76 65 73 20 27 | 6c 65 6e 27 20 65 6c 65 |emoves '|len' ele|
|00001530| 6d 65 6e 74 73 20 69 6e | 20 6c 69 73 74 0a 58 20 |ments in| list.X |
|00001540| 20 20 20 53 50 4c 69 73 | 74 3c 54 3e 20 73 70 6c | SPLis|t<T> spl|
|00001550| 69 63 65 28 6f 66 66 73 | 65 74 2c 20 6c 65 6e 2c |ice(offs|et, len,|
|00001560| 20 53 50 4c 69 73 74 3c | 54 3e 29 2f 2f 20 72 65 | SPList<|T>)// re|
|00001570| 70 6c 61 63 65 73 20 65 | 6c 65 6d 65 6e 74 73 20 |places e|lements |
|00001580| 69 6e 20 6c 69 73 74 0a | 58 20 20 20 20 53 50 4c |in list.|X SPL|
|00001590| 69 73 74 3c 54 3e 20 73 | 6f 72 74 28 29 20 2f 2f |ist<T> s|ort() //|
|000015a0| 20 73 6f 72 74 73 20 6c | 69 73 74 20 61 63 63 6f | sorts l|ist acco|
|000015b0| 72 64 69 6e 67 20 74 6f | 20 72 65 73 75 6c 74 20 |rding to| result |
|000015c0| 6f 66 20 27 3c 27 20 6f | 70 65 72 61 74 6f 72 0a |of '<' o|perator.|
|000015d0| 58 20 20 20 20 6f 73 74 | 72 65 61 6d 26 20 6f 70 |X ost|ream& op|
|000015e0| 65 72 61 74 6f 72 3e 3e | 28 29 20 2f 2f 20 69 6e |erator>>|() // in|
|000015f0| 70 75 74 20 73 74 72 65 | 61 6d 0a 58 20 20 20 20 |put stre|am.X |
|00001600| 69 73 74 72 65 61 6d 26 | 20 6f 70 65 72 61 74 6f |istream&| operato|
|00001610| 72 3c 3c 28 29 20 2f 2f | 20 6f 75 74 70 75 74 20 |r<<() //| output |
|00001620| 73 74 72 65 61 6d 0a 58 | 0a 58 20 20 20 20 63 6c |stream.X|.X cl|
|00001630| 61 73 73 20 53 50 53 74 | 72 69 6e 67 4c 69 73 74 |ass SPSt|ringList|
|00001640| 20 2f 2f 20 65 76 65 72 | 79 74 68 69 6e 67 20 53 | // ever|ything S|
|00001650| 50 4c 69 73 74 20 64 6f | 65 73 20 61 6e 64 20 2e |PList do|es and .|
|00001660| 2e 2e 0a 58 20 20 20 20 | 20 20 20 20 69 6e 74 20 |...X | int |
|00001670| 73 70 6c 69 74 28 73 74 | 72 20 5b 2c 70 61 74 5d |split(st|r [,pat]|
|00001680| 20 5b 2c 6c 69 6d 69 74 | 5d 29 20 2f 2f 20 73 70 | [,limit|]) // sp|
|00001690| 6c 69 74 73 20 73 74 72 | 69 6e 67 20 6f 6e 20 70 |lits str|ing on p|
|000016a0| 61 74 74 65 72 6e 0a 58 | 09 53 50 53 74 72 69 6e |attern.X|.SPStrin|
|000016b0| 67 20 6a 6f 69 6e 28 5b | 70 61 74 5d 29 09 20 2f |g join([|pat]). /|
|000016c0| 2f 20 63 6f 6e 63 61 74 | 65 6e 61 74 65 73 20 6c |/ concat|enates l|
|000016d0| 69 73 74 20 77 69 74 68 | 20 27 70 61 74 27 0a 58 |ist with| 'pat'.X|
|000016e0| 09 69 6e 74 20 6d 28 65 | 78 70 2c 20 74 61 72 67 |.int m(e|xp, targ|
|000016f0| 29 20 09 20 2f 2f 20 6d | 61 6b 65 73 20 6c 69 73 |) . // m|akes lis|
|00001700| 74 20 6f 66 20 73 75 62 | 20 65 78 70 20 6d 61 74 |t of sub| exp mat|
|00001710| 63 68 65 73 0a 58 09 53 | 50 53 74 72 69 6e 67 4c |ches.X.S|PStringL|
|00001720| 69 73 74 20 67 72 65 70 | 28 65 78 70 29 20 2f 2f |ist grep|(exp) //|
|00001730| 20 72 65 74 75 72 6e 73 | 20 6d 61 74 63 68 65 73 | returns| matches|
|00001740| 20 69 6e 20 6c 69 73 74 | 0a 58 09 6f 73 74 72 65 | in list|.X.ostre|
|00001750| 61 6d 26 20 6f 70 65 72 | 61 74 6f 72 3e 3e 28 29 |am& oper|ator>>()|
|00001760| 0a 58 20 20 20 20 09 69 | 73 74 72 65 61 6d 26 20 |.X .i|stream& |
|00001770| 6f 70 65 72 61 74 6f 72 | 3c 3c 28 29 0a 58 0a 58 |operator|<<().X.X|
|00001780| 63 6c 61 73 73 20 53 50 | 53 74 72 69 6e 67 0a 58 |class SP|String.X|
|00001790| 20 20 20 20 69 6e 74 20 | 6c 65 6e 67 74 68 28 29 | int |length()|
|000017a0| 09 2f 2f 20 6c 65 6e 67 | 74 68 20 6f 66 20 73 74 |.// leng|th of st|
|000017b0| 72 69 6e 67 0a 58 20 20 | 20 20 63 68 61 72 20 63 |ring.X | char c|
|000017c0| 68 6f 70 28 29 09 09 2f | 2f 20 72 65 6d 6f 76 65 |hop()../|/ remove|
|000017d0| 20 6c 61 73 74 20 63 68 | 61 72 61 63 74 65 72 20 | last ch|aracter |
|000017e0| 69 6e 20 73 74 72 69 6e | 67 0a 58 20 20 20 20 69 |in strin|g.X i|
|000017f0| 6e 74 20 69 6e 64 65 78 | 28 53 50 53 74 72 69 6e |nt index|(SPStrin|
|00001800| 67 20 5b 2c 20 6f 66 66 | 73 65 74 5d 29 20 2f 2f |g [, off|set]) //|
|00001810| 20 66 69 6e 64 20 73 74 | 72 69 6e 67 20 66 72 6f | find st|ring fro|
|00001820| 6d 20 73 74 61 72 74 0a | 58 20 20 20 20 69 6e 74 |m start.|X int|
|00001830| 20 72 69 6e 64 65 78 28 | 53 50 53 74 72 69 6e 67 | rindex(|SPString|
|00001840| 20 5b 2c 20 6f 66 66 73 | 65 74 5d 29 20 2f 2f 20 | [, offs|et]) // |
|00001850| 66 69 6e 64 20 73 74 72 | 69 6e 67 20 66 72 6f 6d |find str|ing from|
|00001860| 20 65 6e 64 0a 58 20 20 | 20 20 53 50 53 74 72 69 | end.X | SPStri|
|00001870| 6e 67 20 73 75 62 73 74 | 72 28 6f 66 66 73 65 74 |ng subst|r(offset|
|00001880| 20 5b 2c 20 6c 65 6e 5d | 29 20 2f 2f 20 73 75 62 | [, len]|) // sub|
|00001890| 73 74 72 69 6e 67 20 77 | 6f 72 6b 73 20 61 73 20 |string w|orks as |
|000018a0| 6c 76 61 6c 75 65 20 61 | 73 20 77 65 6c 6c 0a 58 |lvalue a|s well.X|
|000018b0| 20 20 20 20 6f 70 65 72 | 61 74 6f 72 5b 5d 09 2f | oper|ator[]./|
|000018c0| 2f 20 69 6e 64 65 78 20 | 63 68 61 72 61 63 74 65 |/ index |characte|
|000018d0| 72 0a 58 20 20 20 20 6f | 70 65 72 61 74 6f 72 3c |r.X o|perator<|
|000018e0| 20 20 20 2f 2f 20 6c 65 | 73 73 20 74 68 61 6e 0a | // le|ss than.|
|000018f0| 58 20 20 20 20 6f 70 65 | 72 61 74 6f 72 3e 0a 58 |X ope|rator>.X|
|00001900| 20 20 20 20 6f 70 65 72 | 61 74 6f 72 3c 3d 0a 58 | oper|ator<=.X|
|00001910| 20 20 20 20 6f 70 65 72 | 61 74 6f 72 3e 3d 0a 58 | oper|ator>=.X|
|00001920| 20 20 20 20 6f 70 65 72 | 61 74 6f 72 3d 3d 0a 58 | oper|ator==.X|
|00001930| 20 20 20 20 6f 70 65 72 | 61 74 6f 72 21 3d 0a 58 | oper|ator!=.X|
|00001940| 20 20 20 20 6f 70 65 72 | 61 74 6f 72 2b 09 20 20 | oper|ator+. |
|00001950| 20 20 2f 2f 20 63 6f 6e | 63 61 74 65 6e 61 74 65 | // con|catenate|
|00001960| 20 32 20 73 74 72 69 6e | 67 73 0a 58 20 20 20 20 | 2 strin|gs.X |
|00001970| 6f 70 65 72 61 74 6f 72 | 2b 3d 09 20 20 20 20 2f |operator|+=. /|
|00001980| 2f 20 61 73 20 70 65 72 | 20 63 0a 58 20 20 20 20 |/ as per| c.X |
|00001990| 69 6e 74 20 6d 28 65 78 | 70 29 20 09 20 20 20 20 |int m(ex|p) . |
|000019a0| 2f 2f 20 72 65 74 75 72 | 6e 20 74 72 75 65 20 69 |// retur|n true i|
|000019b0| 66 20 72 65 67 65 78 70 | 20 6d 61 74 63 68 65 73 |f regexp| matches|
|000019c0| 20 73 74 72 69 6e 67 0a | 58 20 20 20 20 69 6e 74 | string.|X int|
|000019d0| 20 6d 28 65 78 70 2c 20 | 53 50 53 74 72 69 6e 67 | m(exp, |SPString|
|000019e0| 4c 69 73 74 26 29 20 2f | 2f 20 64 69 74 74 6f 20 |List&) /|/ ditto |
|000019f0| 26 20 67 65 6e 65 72 61 | 74 65 73 20 61 20 6c 69 |& genera|tes a li|
|00001a00| 73 74 20 6f 66 20 73 75 | 62 65 78 70 72 65 73 73 |st of su|bexpress|
|00001a10| 69 6f 6e 73 0a 58 20 20 | 20 20 69 6e 74 20 74 72 |ions.X | int tr|
|00001a20| 28 65 78 70 2c 20 72 65 | 70 20 5b 2c 6f 70 74 73 |(exp, re|p [,opts|
|00001a30| 5d 29 20 2f 2f 20 74 72 | 61 6e 73 6c 61 74 65 20 |]) // tr|anslate |
|00001a40| 27 65 78 27 70 20 69 6e | 74 6f 20 27 72 65 70 27 |'ex'p in|to 'rep'|
|00001a50| 0a 58 20 20 20 20 69 6e | 74 20 73 28 65 78 70 2c |.X in|t s(exp,|
|00001a60| 20 72 65 70 20 5b 2c 6f | 70 74 73 5d 29 20 2f 2f | rep [,o|pts]) //|
|00001a70| 20 73 75 62 73 74 69 74 | 75 74 65 20 27 65 78 70 | substit|ute 'exp|
|00001a80| 27 20 77 69 74 68 20 27 | 72 65 70 27 0a 58 20 20 |' with '|rep'.X |
|00001a90| 20 20 6f 73 74 72 65 61 | 6d 26 20 6f 70 65 72 61 | ostrea|m& opera|
|00001aa0| 74 6f 72 3e 3e 28 29 0a | 58 20 20 20 20 69 73 74 |tor>>().|X ist|
|00001ab0| 72 65 61 6d 26 20 6f 70 | 65 72 61 74 6f 72 3c 3c |ream& op|erator<<|
|00001ac0| 28 29 0a 58 0a 58 41 73 | 73 6f 63 69 61 74 69 76 |().X.XAs|sociativ|
|00001ad0| 65 20 61 72 72 61 79 20 | 61 6e 64 20 68 65 6c 70 |e array |and help|
|00001ae0| 65 72 73 0a 58 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |ers.X---|--------|
|00001af0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00001b00| 2d 2d 0a 58 0a 58 63 6c | 61 73 73 20 42 69 6e 61 |--.X.Xcl|ass Bina|
|00001b10| 72 3c 54 3e 09 2f 2f 20 | 61 20 6b 65 79 2c 20 76 |r<T>.// |a key, v|
|00001b20| 61 6c 75 65 20 70 61 69 | 72 0a 58 20 20 20 20 54 |alue pai|r.X T|
|00001b30| 26 20 76 61 6c 75 65 28 | 29 0a 58 20 20 20 20 53 |& value(|).X S|
|00001b40| 50 53 74 72 69 6e 67 26 | 20 6b 65 79 28 29 0a 58 |PString&| key().X|
|00001b50| 0a 58 63 6c 61 73 73 20 | 41 73 73 6f 63 3c 54 3e |.Xclass |Assoc<T>|
|00001b60| 09 2f 2f 20 61 6e 20 61 | 73 73 6f 63 69 61 74 65 |.// an a|ssociate|
|00001b70| 69 76 65 20 61 72 72 61 | 79 2c 20 6c 6f 6f 73 65 |ive arra|y, loose|
|00001b80| 6c 79 20 62 61 73 65 64 | 20 6f 6e 20 74 68 65 20 |ly based| on the |
|00001b90| 70 65 72 6c 20 6f 6e 65 | 0a 58 20 20 20 20 54 26 |perl one|.X T&|
|00001ba0| 20 6f 70 65 72 61 74 6f | 72 28 53 50 53 74 72 69 | operato|r(SPStri|
|00001bb0| 6e 67 29 20 2f 2f 20 65 | 71 75 69 76 61 6c 65 6e |ng) // e|quivalen|
|00001bc0| 74 20 74 6f 20 70 65 72 | 6c 20 24 61 73 73 6f 63 |t to per|l $assoc|
|00001bd0| 7b 22 6f 6e 65 22 7d 20 | 3d 20 76 61 6c 75 65 0a |{"one"} |= value.|
|00001be0| 58 20 20 20 20 42 69 6e | 61 72 26 20 6f 70 65 72 |X Bin|ar& oper|
|00001bf0| 61 74 6f 72 5b 6e 5d 20 | 20 20 20 20 20 2f 2f 20 |ator[n] | // |
|00001c00| 72 65 74 75 72 6e 73 20 | 6e 27 74 68 20 65 6e 74 |returns |n'th ent|
|00001c10| 72 79 20 69 6e 20 61 73 | 73 6f 63 69 61 74 69 76 |ry in as|sociativ|
|00001c20| 65 20 61 72 72 61 79 0a | 58 20 20 20 20 53 50 53 |e array.|X SPS|
|00001c30| 74 72 69 6e 67 4c 69 73 | 74 20 6b 65 79 73 28 29 |tringLis|t keys()|
|00001c40| 20 20 20 2f 2f 20 72 65 | 74 75 72 6e 73 20 61 20 | // re|turns a |
|00001c50| 6c 69 73 74 20 6f 66 20 | 6b 65 79 73 0a 58 20 20 |list of |keys.X |
|00001c60| 20 20 53 50 4c 69 73 74 | 3c 54 3e 20 76 61 6c 75 | SPList|<T> valu|
|00001c70| 65 73 28 29 20 20 20 20 | 2f 2f 20 72 65 74 75 72 |es() |// retur|
|00001c80| 6e 73 20 61 20 6c 69 73 | 74 20 6f 66 20 76 61 6c |ns a lis|t of val|
|00001c90| 75 65 73 0a 58 20 20 20 | 20 69 6e 74 20 69 73 69 |ues.X | int isi|
|00001ca0| 6e 28 53 50 53 74 72 69 | 6e 67 29 20 20 20 20 2f |n(SPStri|ng) /|
|00001cb0| 2f 20 74 65 73 74 73 20 | 69 66 20 6b 65 79 20 69 |/ tests |if key i|
|00001cc0| 73 20 69 6e 20 61 73 73 | 6f 63 20 61 72 72 61 79 |s in ass|oc array|
|00001cd0| 0a 58 20 20 20 20 54 20 | 61 64 65 6c 65 74 65 28 |.X T |adelete(|
|00001ce0| 53 50 53 74 72 69 6e 67 | 29 20 20 20 20 2f 2f 20 |SPString|) // |
|00001cf0| 64 65 6c 65 74 65 73 20 | 67 69 76 65 6e 20 6b 65 |deletes |given ke|
|00001d00| 79 2f 76 61 6c 75 65 0a | 58 0a 58 4f 74 68 65 72 |y/value.|X.XOther|
|00001d10| 20 43 6c 61 73 73 65 73 | 0a 58 2d 2d 2d 2d 2d 2d | Classes|.X------|
|00001d20| 2d 2d 2d 2d 2d 2d 2d 0a | 58 0a 58 56 61 72 53 74 |-------.|X.XVarSt|
|00001d30| 72 69 6e 67 09 2d 20 41 | 20 76 61 72 69 61 62 6c |ring.- A| variabl|
|00001d40| 65 20 6c 65 6e 67 74 68 | 20 73 74 72 69 6e 67 20 |e length| string |
|00001d50| 63 6c 61 73 73 2c 20 75 | 73 65 64 20 69 6e 20 53 |class, u|sed in S|
|00001d60| 50 53 74 72 69 6e 67 2e | 0a 58 0a 58 53 50 4c 69 |PString.|.X.XSPLi|
|00001d70| 73 74 42 61 73 65 3c 54 | 3e 20 09 2d 20 69 73 20 |stBase<T|> .- is |
|00001d80| 74 68 65 20 62 61 73 65 | 20 63 6c 61 73 73 20 66 |the base| class f|
|00001d90| 6f 72 20 53 50 4c 69 73 | 74 20 61 6e 64 20 68 61 |or SPLis|t and ha|
|00001da0| 6e 64 6c 65 73 20 74 68 | 65 0a 58 09 09 20 20 61 |ndles th|e.X.. a|
|00001db0| 75 74 6f 20 65 78 70 61 | 6e 64 69 6e 67 20 64 79 |uto expa|nding dy|
|00001dc0| 6e 61 6d 69 63 20 61 72 | 72 61 79 2c 20 6f 70 74 |namic ar|ray, opt|
|00001dd0| 69 6d 69 7a 65 64 20 66 | 6f 72 0a 58 09 09 20 20 |imized f|or.X.. |
|00001de0| 70 72 65 70 65 6e 64 69 | 6e 67 20 61 6e 64 20 61 |prependi|ng and a|
|00001df0| 70 70 65 6e 64 69 6e 67 | 20 64 61 74 61 2e 0a 58 |ppending| data..X|
|00001e00| 0a 58 54 65 6d 70 53 74 | 72 69 6e 67 20 09 2d 20 |.XTempSt|ring .- |
|00001e10| 6d 61 6b 65 73 20 61 20 | 63 6f 70 79 20 6f 66 20 |makes a |copy of |
|00001e20| 61 20 73 74 72 69 6e 67 | 2c 20 61 6e 64 20 63 61 |a string|, and ca|
|00001e30| 6e 20 72 65 74 75 72 6e | 20 61 20 63 68 61 72 20 |n return| a char |
|00001e40| 2a 0a 58 09 20 20 20 20 | 20 09 20 20 61 6e 64 20 |*.X. | . and |
|00001e50| 77 69 6c 6c 20 66 72 65 | 65 20 74 68 65 20 73 74 |will fre|e the st|
|00001e60| 6f 72 61 67 65 20 77 68 | 65 6e 20 64 6f 6e 65 2e |orage wh|en done.|
|00001e70| 20 53 6f 6d 65 74 68 69 | 6e 67 20 6c 69 6b 65 0a | Somethi|ng like.|
|00001e80| 58 09 09 20 20 61 20 63 | 72 6f 73 73 20 62 65 74 |X.. a c|ross bet|
|00001e90| 77 65 65 6e 20 73 74 72 | 73 61 76 65 28 29 20 61 |ween str|save() a|
|00001ea0| 6e 64 20 61 6c 6c 6f 63 | 61 28 29 2e 0a 58 0a 58 |nd alloc|a()..X.X|
|00001eb0| 52 65 67 65 78 70 09 09 | 2d 20 48 61 6e 64 6c 65 |Regexp..|- Handle|
|00001ec0| 73 20 74 68 65 20 69 6e | 74 65 72 66 61 63 65 20 |s the in|terface |
|00001ed0| 74 6f 20 74 68 65 20 72 | 65 67 75 6c 61 72 20 65 |to the r|egular e|
|00001ee0| 78 70 72 65 73 73 69 6f | 6e 0a 58 09 09 20 20 6c |xpressio|n.X.. l|
|00001ef0| 69 62 72 61 72 79 20 62 | 65 69 6e 67 20 75 73 65 |ibrary b|eing use|
|00001f00| 64 2e 0a 58 0a 58 52 61 | 6e 67 65 20 09 09 2d 20 |d..X.XRa|nge ..- |
|00001f10| 53 69 6d 70 6c 65 20 63 | 6c 61 73 73 20 74 6f 20 |Simple c|lass to |
|00001f20| 6d 61 69 6e 74 61 69 6e | 20 61 20 72 61 6e 67 65 |maintain| a range|
|00001f30| 2c 20 6a 75 73 74 20 6d | 61 6b 65 73 20 74 68 69 |, just m|akes thi|
|00001f40| 6e 67 73 0a 58 09 09 20 | 20 65 61 73 69 65 72 2e |ngs.X.. | easier.|
|00001f50| 0a 58 0a 58 46 6f 72 20 | 4d 6f 72 65 20 49 6e 66 |.X.XFor |More Inf|
|00001f60| 6f 0a 58 3d 3d 3d 3d 3d | 3d 3d 3d 3d 3d 3d 3d 3d |o.X=====|========|
|00001f70| 0a 58 0a 58 53 65 65 20 | 72 65 61 64 6d 65 2e 32 |.X.XSee |readme.2|
|00001f80| 6e 64 20 66 6f 72 20 68 | 6f 77 20 74 6f 20 62 75 |nd for h|ow to bu|
|00001f90| 69 6c 64 20 61 6e 64 20 | 74 65 73 74 2c 20 61 6e |ild and |test, an|
|00001fa0| 64 20 76 61 72 69 6f 75 | 73 20 63 61 76 65 61 74 |d variou|s caveat|
|00001fb0| 73 2e 0a 58 53 65 65 20 | 73 70 6c 61 73 68 2e 64 |s..XSee |splash.d|
|00001fc0| 6f 63 20 66 6f 72 20 64 | 6f 63 75 6d 65 6e 74 61 |oc for d|ocumenta|
|00001fd0| 74 69 6f 6e 20 6f 6e 20 | 65 61 63 68 20 66 75 6e |tion on |each fun|
|00001fe0| 63 74 69 6f 6e 2e 0a 58 | 53 65 65 20 73 61 6d 70 |ction..X|See samp|
|00001ff0| 6c 65 2f 2a 2e 63 2b 2b | 20 66 6f 72 20 65 78 61 |le/*.c++| for exa|
|00002000| 6d 70 6c 65 73 20 6f 66 | 20 68 6f 77 20 74 6f 20 |mples of| how to |
|00002010| 75 73 65 20 73 70 6c 61 | 73 68 0a 58 53 65 65 20 |use spla|sh.XSee |
|00002020| 72 65 67 65 78 70 2e 64 | 6f 63 20 66 6f 72 20 61 |regexp.d|oc for a|
|00002030| 6e 20 65 78 70 6c 61 6e | 61 74 69 6f 6e 20 6f 66 |n explan|ation of|
|00002040| 20 74 68 65 20 72 65 67 | 65 78 70 20 6c 69 62 72 | the reg|exp libr|
|00002050| 61 72 79 20 75 73 65 64 | 0a 58 0a 58 44 69 73 74 |ary used|.X.XDist|
|00002060| 72 69 62 75 74 69 6f 6e | 0a 58 2d 2d 2d 2d 2d 2d |ribution|.X------|
|00002070| 2d 2d 2d 2d 2d 2d 0a 58 | 0a 58 54 68 69 73 20 69 |------.X|.XThis i|
|00002080| 73 20 61 6c 73 6f 20 61 | 76 61 69 6c 61 62 6c 65 |s also a|vailable|
|00002090| 20 61 73 20 61 20 63 6f | 6d 70 72 65 73 73 65 64 | as a co|mpressed|
|000020a0| 20 74 61 72 20 66 69 6c | 65 20 6f 72 0a 58 2e 7a | tar fil|e or.X.z|
|000020b0| 6f 6f 20 66 6f 72 6d 61 | 74 20 77 69 74 68 20 4d |oo forma|t with M|
|000020c0| 53 44 4f 53 20 63 6f 6d | 70 61 74 69 62 6c 65 20 |SDOS com|patible |
|000020d0| 6e 61 6d 65 73 2e 0a 58 | 0a 58 45 6d 61 69 6c 3a |names..X|.XEmail:|
|000020e0| 20 6d 6f 72 72 69 73 40 | 6e 65 74 63 6f 6d 2e 63 | morris@|netcom.c|
|000020f0| 6f 6d 20 6f 72 20 6a 65 | 67 6d 40 73 67 69 2e 63 |om or je|gm@sgi.c|
|00002100| 6f 6d 20 66 6f 72 20 61 | 20 64 69 66 66 65 72 65 |om for a| differe|
|00002110| 6e 74 20 66 6f 72 6d 61 | 74 2e 0a 58 6f 72 0a 58 |nt forma|t..Xor.X|
|00002120| 67 65 74 20 74 68 65 20 | 6c 61 74 65 73 74 20 76 |get the |latest v|
|00002130| 65 72 73 69 6f 6e 20 6f | 66 20 53 50 4c 41 53 48 |ersion o|f SPLASH|
|00002140| 2c 20 77 68 69 63 68 20 | 69 73 20 61 6c 77 61 79 |, which |is alway|
|00002150| 73 20 61 76 61 69 6c 61 | 62 6c 65 20 76 69 61 0a |s availa|ble via.|
|00002160| 58 61 6e 6f 6e 79 6d 6f | 75 73 20 46 54 50 2e 0a |Xanonymo|us FTP..|
|00002170| 58 0a 58 41 6c 73 6f 20 | 74 68 65 20 63 75 72 72 |X.XAlso |the curr|
|00002180| 65 6e 74 20 61 6c 70 68 | 61 20 76 65 72 73 69 6f |ent alph|a versio|
|00002190| 6e 20 77 69 6c 6c 20 61 | 6c 73 6f 20 62 65 20 61 |n will a|lso be a|
|000021a0| 76 61 69 6c 61 62 6c 65 | 2e 20 54 68 69 73 20 69 |vailable|. This i|
|000021b0| 73 20 66 6f 72 0a 58 61 | 64 76 65 6e 74 75 72 6f |s for.Xa|dventuro|
|000021c0| 75 73 20 75 73 65 72 73 | 20 6f 6e 6c 79 2e 20 49 |us users| only. I|
|000021d0| 74 20 77 69 6c 6c 20 62 | 65 20 63 61 6c 6c 65 64 |t will b|e called|
|000021e0| 20 73 70 6c 61 6c 70 68 | 61 78 78 78 2e 74 61 72 | splalph|axxx.tar|
|000021f0| 2e 5a 0a 58 0a 58 73 69 | 74 65 3a 2d 0a 58 6e 65 |.Z.X.Xsi|te:-.Xne|
|00002200| 74 63 6f 6d 2e 63 6f 6d | 0a 58 0a 58 50 61 74 68 |tcom.com|.X.XPath|
|00002210| 3a 2d 0a 58 7e 66 74 70 | 2f 70 75 62 2f 6d 6f 72 |:-.X~ftp|/pub/mor|
|00002220| 72 69 73 2f 73 70 6c 61 | 73 68 2e 74 61 72 2e 5a |ris/spla|sh.tar.Z|
|00002230| 0a 58 7e 66 74 70 2f 70 | 75 62 2f 6d 6f 72 72 69 |.X~ftp/p|ub/morri|
|00002240| 73 2f 73 70 6c 61 73 68 | 2e 7a 6f 6f 0a 58 0a 45 |s/splash|.zoo.X.E|
|00002250| 4e 44 5f 4f 46 5f 46 49 | 4c 45 0a 20 20 69 66 20 |ND_OF_FI|LE. if |
|00002260| 74 65 73 74 20 36 38 38 | 37 20 2d 6e 65 20 60 77 |test 688|7 -ne `w|
|00002270| 63 20 2d 63 20 3c 27 52 | 45 41 44 4d 45 27 60 3b |c -c <'R|EADME'`;|
|00002280| 20 74 68 65 6e 0a 20 20 | 20 20 65 63 68 6f 20 73 | then. | echo s|
|00002290| 68 61 72 3a 20 5c 22 27 | 52 45 41 44 4d 45 27 5c |har: \"'|README'\|
|000022a0| 22 20 75 6e 70 61 63 6b | 65 64 20 77 69 74 68 20 |" unpack|ed with |
|000022b0| 77 72 6f 6e 67 20 73 69 | 7a 65 21 0a 20 20 66 69 |wrong si|ze!. fi|
|000022c0| 0a 20 20 23 20 65 6e 64 | 20 6f 66 20 27 52 45 41 |. # end| of 'REA|
|000022d0| 44 4d 45 27 0a 66 69 0a | 69 66 20 74 65 73 74 20 |DME'.fi.|if test |
|000022e0| 2d 66 20 27 50 61 74 63 | 68 6c 65 76 65 6c 27 20 |-f 'Patc|hlevel' |
|000022f0| 2d 61 20 22 24 7b 31 7d | 22 20 21 3d 20 22 2d 63 |-a "${1}|" != "-c|
|00002300| 22 20 3b 20 74 68 65 6e | 20 0a 20 20 65 63 68 6f |" ; then| . echo|
|00002310| 20 73 68 61 72 3a 20 57 | 69 6c 6c 20 6e 6f 74 20 | shar: W|ill not |
|00002320| 63 6c 6f 62 62 65 72 20 | 65 78 69 73 74 69 6e 67 |clobber |existing|
|00002330| 20 66 69 6c 65 20 5c 22 | 27 50 61 74 63 68 6c 65 | file \"|'Patchle|
|00002340| 76 65 6c 27 5c 22 0a 65 | 6c 73 65 0a 20 20 65 63 |vel'\".e|lse. ec|
|00002350| 68 6f 20 73 68 61 72 3a | 20 45 78 74 72 61 63 74 |ho shar:| Extract|
|00002360| 69 6e 67 20 5c 22 27 50 | 61 74 63 68 6c 65 76 65 |ing \"'P|atchleve|
|00002370| 6c 27 5c 22 20 5c 28 34 | 20 63 68 61 72 61 63 74 |l'\" \(4| charact|
|00002380| 65 72 73 5c 29 0a 20 20 | 73 65 64 20 22 73 2f 5e |ers\). |sed "s/^|
|00002390| 58 2f 2f 22 20 3e 27 50 | 61 74 63 68 6c 65 76 65 |X//" >'P|atchleve|
|000023a0| 6c 27 20 3c 3c 27 45 4e | 44 5f 4f 46 5f 46 49 4c |l' <<'EN|D_OF_FIL|
|000023b0| 45 27 0a 58 31 2e 38 0a | 45 4e 44 5f 4f 46 5f 46 |E'.X1.8.|END_OF_F|
|000023c0| 49 4c 45 0a 20 20 69 66 | 20 74 65 73 74 20 34 20 |ILE. if| test 4 |
|000023d0| 2d 6e 65 20 60 77 63 20 | 2d 63 20 3c 27 50 61 74 |-ne `wc |-c <'Pat|
|000023e0| 63 68 6c 65 76 65 6c 27 | 60 3b 20 74 68 65 6e 0a |chlevel'|`; then.|
|000023f0| 20 20 20 20 65 63 68 6f | 20 73 68 61 72 3a 20 5c | echo| shar: \|
|00002400| 22 27 50 61 74 63 68 6c | 65 76 65 6c 27 5c 22 20 |"'Patchl|evel'\" |
|00002410| 75 6e 70 61 63 6b 65 64 | 20 77 69 74 68 20 77 72 |unpacked| with wr|
|00002420| 6f 6e 67 20 73 69 7a 65 | 21 0a 20 20 66 69 0a 20 |ong size|!. fi. |
|00002430| 20 23 20 65 6e 64 20 6f | 66 20 27 50 61 74 63 68 | # end o|f 'Patch|
|00002440| 6c 65 76 65 6c 27 0a 66 | 69 0a 69 66 20 74 65 73 |level'.f|i.if tes|
|00002450| 74 20 2d 66 20 27 72 65 | 67 65 78 2e 63 27 20 2d |t -f 're|gex.c' -|
|00002460| 61 20 22 24 7b 31 7d 22 | 20 21 3d 20 22 2d 63 22 |a "${1}"| != "-c"|
|00002470| 20 3b 20 74 68 65 6e 20 | 0a 20 20 65 63 68 6f 20 | ; then |. echo |
|00002480| 73 68 61 72 3a 20 57 69 | 6c 6c 20 6e 6f 74 20 63 |shar: Wi|ll not c|
|00002490| 6c 6f 62 62 65 72 20 65 | 78 69 73 74 69 6e 67 20 |lobber e|xisting |
|000024a0| 66 69 6c 65 20 5c 22 27 | 72 65 67 65 78 2e 63 27 |file \"'|regex.c'|
|000024b0| 5c 22 0a 65 6c 73 65 0a | 20 20 65 63 68 6f 20 73 |\".else.| echo s|
|000024c0| 68 61 72 3a 20 45 78 74 | 72 61 63 74 69 6e 67 20 |har: Ext|racting |
|000024d0| 5c 22 27 72 65 67 65 78 | 2e 63 27 5c 22 20 5c 28 |\"'regex|.c'\" \(|
|000024e0| 32 37 37 30 32 20 63 68 | 61 72 61 63 74 65 72 73 |27702 ch|aracters|
|000024f0| 5c 29 0a 20 20 73 65 64 | 20 22 73 2f 5e 58 2f 2f |\). sed| "s/^X//|
|00002500| 22 20 3e 27 72 65 67 65 | 78 2e 63 27 20 3c 3c 27 |" >'rege|x.c' <<'|
|00002510| 45 4e 44 5f 4f 46 5f 46 | 49 4c 45 27 0a 58 2f 2a |END_OF_F|ILE'.X/*|
|00002520| 0a 58 20 2a 20 72 65 67 | 63 6f 6d 70 20 61 6e 64 |.X * reg|comp and|
|00002530| 20 72 65 67 65 78 65 63 | 20 2d 2d 20 72 65 67 73 | regexec| -- regs|
|00002540| 75 62 20 61 6e 64 20 72 | 65 67 65 72 72 6f 72 20 |ub and r|egerror |
|00002550| 61 72 65 20 65 6c 73 65 | 77 68 65 72 65 0a 58 20 |are else|where.X |
|00002560| 2a 0a 58 20 2a 09 43 6f | 70 79 72 69 67 68 74 20 |*.X *.Co|pyright |
|00002570| 28 63 29 20 31 39 38 36 | 20 62 79 20 55 6e 69 76 |(c) 1986| by Univ|
|00002580| 65 72 73 69 74 79 20 6f | 66 20 54 6f 72 6f 6e 74 |ersity o|f Toront|
|00002590| 6f 2e 0a 58 20 2a 09 57 | 72 69 74 74 65 6e 20 62 |o..X *.W|ritten b|
|000025a0| 79 20 48 65 6e 72 79 20 | 53 70 65 6e 63 65 72 2e |y Henry |Spencer.|
|000025b0| 20 20 4e 6f 74 20 64 65 | 72 69 76 65 64 20 66 72 | Not de|rived fr|
|000025c0| 6f 6d 20 6c 69 63 65 6e | 73 65 64 20 73 6f 66 74 |om licen|sed soft|
|000025d0| 77 61 72 65 2e 0a 58 20 | 2a 0a 58 20 2a 09 50 65 |ware..X |*.X *.Pe|
|000025e0| 72 6d 69 73 73 69 6f 6e | 20 69 73 20 67 72 61 6e |rmission| is gran|
|000025f0| 74 65 64 20 74 6f 20 61 | 6e 79 6f 6e 65 20 74 6f |ted to a|nyone to|
|00002600| 20 75 73 65 20 74 68 69 | 73 20 73 6f 66 74 77 61 | use thi|s softwa|
|00002610| 72 65 20 66 6f 72 20 61 | 6e 79 0a 58 20 2a 09 70 |re for a|ny.X *.p|
|00002620| 75 72 70 6f 73 65 20 6f | 6e 20 61 6e 79 20 63 6f |urpose o|n any co|
|00002630| 6d 70 75 74 65 72 20 73 | 79 73 74 65 6d 2c 20 61 |mputer s|ystem, a|
|00002640| 6e 64 20 74 6f 20 72 65 | 64 69 73 74 72 69 62 75 |nd to re|distribu|
|00002650| 74 65 20 69 74 20 66 72 | 65 65 6c 79 2c 0a 58 20 |te it fr|eely,.X |
|00002660| 2a 09 73 75 62 6a 65 63 | 74 20 74 6f 20 74 68 65 |*.subjec|t to the|
|00002670| 20 66 6f 6c 6c 6f 77 69 | 6e 67 20 72 65 73 74 72 | followi|ng restr|
|00002680| 69 63 74 69 6f 6e 73 3a | 0a 58 20 2a 0a 58 20 2a |ictions:|.X *.X *|
|00002690| 09 31 2e 20 54 68 65 20 | 61 75 74 68 6f 72 20 69 |.1. The |author i|
|000026a0| 73 20 6e 6f 74 20 72 65 | 73 70 6f 6e 73 69 62 6c |s not re|sponsibl|
|000026b0| 65 20 66 6f 72 20 74 68 | 65 20 63 6f 6e 73 65 71 |e for th|e conseq|
|000026c0| 75 65 6e 63 65 73 20 6f | 66 20 75 73 65 20 6f 66 |uences o|f use of|
|000026d0| 0a 58 20 2a 09 09 74 68 | 69 73 20 73 6f 66 74 77 |.X *..th|is softw|
|000026e0| 61 72 65 2c 20 6e 6f 20 | 6d 61 74 74 65 72 20 68 |are, no |matter h|
|000026f0| 6f 77 20 61 77 66 75 6c | 2c 20 65 76 65 6e 20 69 |ow awful|, even i|
|00002700| 66 20 74 68 65 79 20 61 | 72 69 73 65 0a 58 20 2a |f they a|rise.X *|
|00002710| 09 09 66 72 6f 6d 20 64 | 65 66 65 63 74 73 20 69 |..from d|efects i|
|00002720| 6e 20 69 74 2e 0a 58 20 | 2a 0a 58 20 2a 09 32 2e |n it..X |*.X *.2.|
|00002730| 20 54 68 65 20 6f 72 69 | 67 69 6e 20 6f 66 20 74 | The ori|gin of t|
|00002740| 68 69 73 20 73 6f 66 74 | 77 61 72 65 20 6d 75 73 |his soft|ware mus|
|00002750| 74 20 6e 6f 74 20 62 65 | 20 6d 69 73 72 65 70 72 |t not be| misrepr|
|00002760| 65 73 65 6e 74 65 64 2c | 20 65 69 74 68 65 72 0a |esented,| either.|
|00002770| 58 20 2a 09 09 62 79 20 | 65 78 70 6c 69 63 69 74 |X *..by |explicit|
|00002780| 20 63 6c 61 69 6d 20 6f | 72 20 62 79 20 6f 6d 69 | claim o|r by omi|
|00002790| 73 73 69 6f 6e 2e 0a 58 | 20 2a 0a 58 20 2a 09 33 |ssion..X| *.X *.3|
|000027a0| 2e 20 41 6c 74 65 72 65 | 64 20 76 65 72 73 69 6f |. Altere|d versio|
|000027b0| 6e 73 20 6d 75 73 74 20 | 62 65 20 70 6c 61 69 6e |ns must |be plain|
|000027c0| 6c 79 20 6d 61 72 6b 65 | 64 20 61 73 20 73 75 63 |ly marke|d as suc|
|000027d0| 68 2c 20 61 6e 64 20 6d | 75 73 74 20 6e 6f 74 0a |h, and m|ust not.|
|000027e0| 58 20 2a 09 09 62 65 20 | 6d 69 73 72 65 70 72 65 |X *..be |misrepre|
|000027f0| 73 65 6e 74 65 64 20 61 | 73 20 62 65 69 6e 67 20 |sented a|s being |
|00002800| 74 68 65 20 6f 72 69 67 | 69 6e 61 6c 20 73 6f 66 |the orig|inal sof|
|00002810| 74 77 61 72 65 2e 0a 58 | 20 2a 0a 58 20 2a 20 42 |tware..X| *.X * B|
|00002820| 65 77 61 72 65 20 74 68 | 61 74 20 73 6f 6d 65 20 |eware th|at some |
|00002830| 6f 66 20 74 68 69 73 20 | 63 6f 64 65 20 69 73 20 |of this |code is |
|00002840| 73 75 62 74 6c 79 20 61 | 77 61 72 65 20 6f 66 20 |subtly a|ware of |
|00002850| 74 68 65 20 77 61 79 20 | 6f 70 65 72 61 74 6f 72 |the way |operator|
|00002860| 0a 58 20 2a 20 70 72 65 | 63 65 64 65 6e 63 65 20 |.X * pre|cedence |
|00002870| 69 73 20 73 74 72 75 63 | 74 75 72 65 64 20 69 6e |is struc|tured in|
|00002880| 20 72 65 67 75 6c 61 72 | 20 65 78 70 72 65 73 73 | regular| express|
|00002890| 69 6f 6e 73 2e 20 20 53 | 65 72 69 6f 75 73 20 63 |ions. S|erious c|
|000028a0| 68 61 6e 67 65 73 20 69 | 6e 0a 58 20 2a 20 72 65 |hanges i|n.X * re|
|000028b0| 67 75 6c 61 72 2d 65 78 | 70 72 65 73 73 69 6f 6e |gular-ex|pression|
|000028c0| 20 73 79 6e 74 61 78 20 | 6d 69 67 68 74 20 72 65 | syntax |might re|
|000028d0| 71 75 69 72 65 20 61 20 | 74 6f 74 61 6c 20 72 65 |quire a |total re|
|000028e0| 74 68 69 6e 6b 2e 0a 58 | 20 2a 2f 0a 58 23 69 6e |think..X| */.X#in|
|000028f0| 63 6c 75 64 65 20 3c 73 | 74 64 69 6f 2e 68 3e 0a |clude <s|tdio.h>.|
|00002900| 58 23 69 6e 63 6c 75 64 | 65 20 3c 73 74 64 6c 69 |X#includ|e <stdli|
|00002910| 62 2e 68 3e 0a 58 23 69 | 6e 63 6c 75 64 65 20 22 |b.h>.X#i|nclude "|
|00002920| 72 65 67 65 78 2e 68 22 | 0a 58 23 69 6e 63 6c 75 |regex.h"|.X#inclu|
|00002930| 64 65 20 22 72 65 67 6d | 61 67 69 63 2e 68 22 0a |de "regm|agic.h".|
|00002940| 58 0a 58 2f 2a 0a 58 20 | 2a 20 54 68 65 20 22 69 |X.X/*.X |* The "i|
|00002950| 6e 74 65 72 6e 61 6c 20 | 75 73 65 20 6f 6e 6c 79 |nternal |use only|
|00002960| 22 20 66 69 65 6c 64 73 | 20 69 6e 20 72 65 67 65 |" fields| in rege|
|00002970| 78 70 2e 68 20 61 72 65 | 20 70 72 65 73 65 6e 74 |xp.h are| present|
|00002980| 20 74 6f 20 70 61 73 73 | 20 69 6e 66 6f 20 66 72 | to pass| info fr|
|00002990| 6f 6d 0a 58 20 2a 20 63 | 6f 6d 70 69 6c 65 20 74 |om.X * c|ompile t|
|000029a0| 6f 20 65 78 65 63 75 74 | 65 20 74 68 61 74 20 70 |o execut|e that p|
|000029b0| 65 72 6d 69 74 73 20 74 | 68 65 20 65 78 65 63 75 |ermits t|he execu|
|000029c0| 74 65 20 70 68 61 73 65 | 20 74 6f 20 72 75 6e 20 |te phase| to run |
|000029d0| 6c 6f 74 73 20 66 61 73 | 74 65 72 20 6f 6e 0a 58 |lots fas|ter on.X|
|000029e0| 20 2a 20 73 69 6d 70 6c | 65 20 63 61 73 65 73 2e | * simpl|e cases.|
|000029f0| 20 20 54 68 65 79 20 61 | 72 65 3a 0a 58 20 2a 0a | They a|re:.X *.|
|00002a00| 58 20 2a 20 72 65 67 73 | 74 61 72 74 09 63 68 61 |X * regs|tart.cha|
|00002a10| 72 20 74 68 61 74 20 6d | 75 73 74 20 62 65 67 69 |r that m|ust begi|
|00002a20| 6e 20 61 20 6d 61 74 63 | 68 3b 20 27 5c 30 27 20 |n a matc|h; '\0' |
|00002a30| 69 66 20 6e 6f 6e 65 20 | 6f 62 76 69 6f 75 73 0a |if none |obvious.|
|00002a40| 58 20 2a 20 72 65 67 61 | 6e 63 68 09 69 73 20 74 |X * rega|nch.is t|
|00002a50| 68 65 20 6d 61 74 63 68 | 20 61 6e 63 68 6f 72 65 |he match| anchore|
|00002a60| 64 20 28 61 74 20 62 65 | 67 69 6e 6e 69 6e 67 2d |d (at be|ginning-|
|00002a70| 6f 66 2d 6c 69 6e 65 20 | 6f 6e 6c 79 29 3f 0a 58 |of-line |only)?.X|
|00002a80| 20 2a 20 72 65 67 6d 75 | 73 74 09 73 74 72 69 6e | * regmu|st.strin|
|00002a90| 67 20 28 70 6f 69 6e 74 | 65 72 20 69 6e 74 6f 20 |g (point|er into |
|00002aa0| 70 72 6f 67 72 61 6d 29 | 20 74 68 61 74 20 6d 61 |program)| that ma|
|00002ab0| 74 63 68 20 6d 75 73 74 | 20 69 6e 63 6c 75 64 65 |tch must| include|
|00002ac0| 2c 20 6f 72 20 4e 55 4c | 4c 0a 58 20 2a 20 72 65 |, or NUL|L.X * re|
|00002ad0| 67 6d 6c 65 6e 09 6c 65 | 6e 67 74 68 20 6f 66 20 |gmlen.le|ngth of |
|00002ae0| 72 65 67 6d 75 73 74 20 | 73 74 72 69 6e 67 0a 58 |regmust |string.X|
|00002af0| 20 2a 0a 58 20 2a 20 52 | 65 67 73 74 61 72 74 20 | *.X * R|egstart |
|00002b00| 61 6e 64 20 72 65 67 61 | 6e 63 68 20 70 65 72 6d |and rega|nch perm|
|00002b10| 69 74 20 76 65 72 79 20 | 66 61 73 74 20 64 65 63 |it very |fast dec|
|00002b20| 69 73 69 6f 6e 73 20 6f | 6e 20 73 75 69 74 61 62 |isions o|n suitab|
|00002b30| 6c 65 20 73 74 61 72 74 | 69 6e 67 20 70 6f 69 6e |le start|ing poin|
|00002b40| 74 73 0a 58 20 2a 20 66 | 6f 72 20 61 20 6d 61 74 |ts.X * f|or a mat|
|00002b50| 63 68 2c 20 63 75 74 74 | 69 6e 67 20 64 6f 77 6e |ch, cutt|ing down|
|00002b60| 20 74 68 65 20 77 6f 72 | 6b 20 61 20 6c 6f 74 2e | the wor|k a lot.|
|00002b70| 20 20 52 65 67 6d 75 73 | 74 20 70 65 72 6d 69 74 | Regmus|t permit|
|00002b80| 73 20 66 61 73 74 20 72 | 65 6a 65 63 74 69 6f 6e |s fast r|ejection|
|00002b90| 0a 58 20 2a 20 6f 66 20 | 6c 69 6e 65 73 20 74 68 |.X * of |lines th|
|00002ba0| 61 74 20 63 61 6e 6e 6f | 74 20 70 6f 73 73 69 62 |at canno|t possib|
|00002bb0| 6c 79 20 6d 61 74 63 68 | 2e 20 20 54 68 65 20 72 |ly match|. The r|
|00002bc0| 65 67 6d 75 73 74 20 74 | 65 73 74 73 20 61 72 65 |egmust t|ests are|
|00002bd0| 20 63 6f 73 74 6c 79 20 | 65 6e 6f 75 67 68 0a 58 | costly |enough.X|
|00002be0| 20 2a 20 74 68 61 74 20 | 72 65 67 63 6f 6d 70 28 | * that |regcomp(|
|00002bf0| 29 20 73 75 70 70 6c 69 | 65 73 20 61 20 72 65 67 |) suppli|es a reg|
|00002c00| 6d 75 73 74 20 6f 6e 6c | 79 20 69 66 20 74 68 65 |must onl|y if the|
|00002c10| 20 72 2e 65 2e 20 63 6f | 6e 74 61 69 6e 73 20 73 | r.e. co|ntains s|
|00002c20| 6f 6d 65 74 68 69 6e 67 | 0a 58 20 2a 20 70 6f 74 |omething|.X * pot|
|00002c30| 65 6e 74 69 61 6c 6c 79 | 20 65 78 70 65 6e 73 69 |entially| expensi|
|00002c40| 76 65 20 28 61 74 20 70 | 72 65 73 65 6e 74 2c 20 |ve (at p|resent, |
|00002c50| 74 68 65 20 6f 6e 6c 79 | 20 73 75 63 68 20 74 68 |the only| such th|
|00002c60| 69 6e 67 20 64 65 74 65 | 63 74 65 64 20 69 73 20 |ing dete|cted is |
|00002c70| 2a 20 6f 72 20 2b 0a 58 | 20 2a 20 61 74 20 74 68 |* or +.X| * at th|
|00002c80| 65 20 73 74 61 72 74 20 | 6f 66 20 74 68 65 20 72 |e start |of the r|
|00002c90| 2e 65 2e 2c 20 77 68 69 | 63 68 20 63 61 6e 20 69 |.e., whi|ch can i|
|00002ca0| 6e 76 6f 6c 76 65 20 61 | 20 6c 6f 74 20 6f 66 20 |nvolve a| lot of |
|00002cb0| 62 61 63 6b 75 70 29 2e | 20 20 52 65 67 6d 6c 65 |backup).| Regmle|
|00002cc0| 6e 20 69 73 0a 58 20 2a | 20 73 75 70 70 6c 69 65 |n is.X *| supplie|
|00002cd0| 64 20 62 65 63 61 75 73 | 65 20 74 68 65 20 74 65 |d becaus|e the te|
|00002ce0| 73 74 20 69 6e 20 72 65 | 67 65 78 65 63 28 29 20 |st in re|gexec() |
|00002cf0| 6e 65 65 64 73 20 69 74 | 20 61 6e 64 20 72 65 67 |needs it| and reg|
|00002d00| 63 6f 6d 70 28 29 20 69 | 73 20 63 6f 6d 70 75 74 |comp() i|s comput|
|00002d10| 69 6e 67 0a 58 20 2a 20 | 69 74 20 61 6e 79 77 61 |ing.X * |it anywa|
|00002d20| 79 2e 0a 58 20 2a 2f 0a | 58 0a 58 2f 2a 0a 58 20 |y..X */.|X.X/*.X |
|00002d30| 2a 20 53 74 72 75 63 74 | 75 72 65 20 66 6f 72 20 |* Struct|ure for |
|00002d40| 72 65 67 65 78 70 20 22 | 70 72 6f 67 72 61 6d 22 |regexp "|program"|
|00002d50| 2e 20 20 54 68 69 73 20 | 69 73 20 65 73 73 65 6e |. This |is essen|
|00002d60| 74 69 61 6c 6c 79 20 61 | 20 6c 69 6e 65 61 72 20 |tially a| linear |
|00002d70| 65 6e 63 6f 64 69 6e 67 | 0a 58 20 2a 20 6f 66 20 |encoding|.X * of |
|00002d80| 61 20 6e 6f 6e 64 65 74 | 65 72 6d 69 6e 69 73 74 |a nondet|erminist|
|00002d90| 69 63 20 66 69 6e 69 74 | 65 2d 73 74 61 74 65 20 |ic finit|e-state |
|00002da0| 6d 61 63 68 69 6e 65 20 | 28 61 6b 61 20 73 79 6e |machine |(aka syn|
|00002db0| 74 61 78 20 63 68 61 72 | 74 73 20 6f 72 0a 58 20 |tax char|ts or.X |
|00002dc0| 2a 20 22 72 61 69 6c 72 | 6f 61 64 20 6e 6f 72 6d |* "railr|oad norm|
|00002dd0| 61 6c 20 66 6f 72 6d 22 | 20 69 6e 20 70 61 72 73 |al form"| in pars|
|00002de0| 69 6e 67 20 74 65 63 68 | 6e 6f 6c 6f 67 79 29 2e |ing tech|nology).|
|00002df0| 20 20 45 61 63 68 20 6e | 6f 64 65 20 69 73 20 61 | Each n|ode is a|
|00002e00| 6e 20 6f 70 63 6f 64 65 | 0a 58 20 2a 20 70 6c 75 |n opcode|.X * plu|
|00002e10| 73 20 61 20 22 6e 65 78 | 74 22 20 70 6f 69 6e 74 |s a "nex|t" point|
|00002e20| 65 72 2c 20 70 6f 73 73 | 69 62 6c 79 20 70 6c 75 |er, poss|ibly plu|
|00002e30| 73 20 61 6e 20 6f 70 65 | 72 61 6e 64 2e 20 20 22 |s an ope|rand. "|
|00002e40| 4e 65 78 74 22 20 70 6f | 69 6e 74 65 72 73 20 6f |Next" po|inters o|
|00002e50| 66 0a 58 20 2a 20 61 6c | 6c 20 6e 6f 64 65 73 20 |f.X * al|l nodes |
|00002e60| 65 78 63 65 70 74 20 42 | 52 41 4e 43 48 20 69 6d |except B|RANCH im|
|00002e70| 70 6c 65 6d 65 6e 74 20 | 63 6f 6e 63 61 74 65 6e |plement |concaten|
|00002e80| 61 74 69 6f 6e 3b 20 61 | 20 22 6e 65 78 74 22 20 |ation; a| "next" |
|00002e90| 70 6f 69 6e 74 65 72 20 | 77 69 74 68 0a 58 20 2a |pointer |with.X *|
|00002ea0| 20 61 20 42 52 41 4e 43 | 48 20 6f 6e 20 62 6f 74 | a BRANC|H on bot|
|00002eb0| 68 20 65 6e 64 73 20 6f | 66 20 69 74 20 69 73 20 |h ends o|f it is |
|00002ec0| 63 6f 6e 6e 65 63 74 69 | 6e 67 20 74 77 6f 20 61 |connecti|ng two a|
|00002ed0| 6c 74 65 72 6e 61 74 69 | 76 65 73 2e 20 20 28 48 |lternati|ves. (H|
|00002ee0| 65 72 65 20 77 65 0a 58 | 20 2a 20 68 61 76 65 20 |ere we.X| * have |
|00002ef0| 6f 6e 65 20 6f 66 20 74 | 68 65 20 73 75 62 74 6c |one of t|he subtl|
|00002f00| 65 20 73 79 6e 74 61 78 | 20 64 65 70 65 6e 64 65 |e syntax| depende|
|00002f10| 6e 63 69 65 73 3a 20 20 | 61 6e 20 69 6e 64 69 76 |ncies: |an indiv|
|00002f20| 69 64 75 61 6c 20 42 52 | 41 4e 43 48 20 28 61 73 |idual BR|ANCH (as|
|00002f30| 0a 58 20 2a 20 6f 70 70 | 6f 73 65 64 20 74 6f 20 |.X * opp|osed to |
|00002f40| 61 20 63 6f 6c 6c 65 63 | 74 69 6f 6e 20 6f 66 20 |a collec|tion of |
|00002f50| 74 68 65 6d 29 20 69 73 | 20 6e 65 76 65 72 20 63 |them) is| never c|
|00002f60| 6f 6e 63 61 74 65 6e 61 | 74 65 64 20 77 69 74 68 |oncatena|ted with|
|00002f70| 20 61 6e 79 74 68 69 6e | 67 0a 58 20 2a 20 62 65 | anythin|g.X * be|
|00002f80| 63 61 75 73 65 20 6f 66 | 20 6f 70 65 72 61 74 6f |cause of| operato|
|00002f90| 72 20 70 72 65 63 65 64 | 65 6e 63 65 2e 29 20 20 |r preced|ence.) |
|00002fa0| 54 68 65 20 6f 70 65 72 | 61 6e 64 20 6f 66 20 73 |The oper|and of s|
|00002fb0| 6f 6d 65 20 74 79 70 65 | 73 20 6f 66 20 6e 6f 64 |ome type|s of nod|
|00002fc0| 65 20 69 73 0a 58 20 2a | 20 61 20 6c 69 74 65 72 |e is.X *| a liter|
|00002fd0| 61 6c 20 73 74 72 69 6e | 67 3b 20 66 6f 72 20 6f |al strin|g; for o|
|00002fe0| 74 68 65 72 73 2c 20 69 | 74 20 69 73 20 61 20 6e |thers, i|t is a n|
|00002ff0| 6f 64 65 20 6c 65 61 64 | 69 6e 67 20 69 6e 74 6f |ode lead|ing into|
|00003000| 20 61 20 73 75 62 2d 46 | 53 4d 2e 20 20 49 6e 0a | a sub-F|SM. In.|
|00003010| 58 20 2a 20 70 61 72 74 | 69 63 75 6c 61 72 2c 20 |X * part|icular, |
|00003020| 74 68 65 20 6f 70 65 72 | 61 6e 64 20 6f 66 20 61 |the oper|and of a|
|00003030| 20 42 52 41 4e 43 48 20 | 6e 6f 64 65 20 69 73 20 | BRANCH |node is |
|00003040| 74 68 65 20 66 69 72 73 | 74 20 6e 6f 64 65 20 6f |the firs|t node o|
|00003050| 66 20 74 68 65 20 62 72 | 61 6e 63 68 2e 0a 58 20 |f the br|anch..X |
|00003060| 2a 20 28 4e 42 20 74 68 | 69 73 20 69 73 20 2a 6e |* (NB th|is is *n|
|00003070| 6f 74 2a 20 61 20 74 72 | 65 65 20 73 74 72 75 63 |ot* a tr|ee struc|
|00003080| 74 75 72 65 3a 20 20 74 | 68 65 20 74 61 69 6c 20 |ture: t|he tail |
|00003090| 6f 66 20 74 68 65 20 62 | 72 61 6e 63 68 20 63 6f |of the b|ranch co|
|000030a0| 6e 6e 65 63 74 73 0a 58 | 20 2a 20 74 6f 20 74 68 |nnects.X| * to th|
|000030b0| 65 20 74 68 69 6e 67 20 | 66 6f 6c 6c 6f 77 69 6e |e thing |followin|
|000030c0| 67 20 74 68 65 20 73 65 | 74 20 6f 66 20 42 52 41 |g the se|t of BRA|
|000030d0| 4e 43 48 65 73 2e 29 20 | 20 54 68 65 20 6f 70 63 |NCHes.) | The opc|
|000030e0| 6f 64 65 73 20 61 72 65 | 3a 0a 58 20 2a 2f 0a 58 |odes are|:.X */.X|
|000030f0| 0a 58 2f 2a 20 64 65 66 | 69 6e 69 74 69 6f 6e 09 |.X/* def|inition.|
|00003100| 6e 75 6d 62 65 72 09 6f | 70 6e 64 3f 09 6d 65 61 |number.o|pnd?.mea|
|00003110| 6e 69 6e 67 20 2a 2f 0a | 58 23 64 65 66 69 6e 65 |ning */.|X#define|
|00003120| 09 45 4e 44 09 30 09 2f | 2a 20 6e 6f 09 45 6e 64 |.END.0./|* no.End|
|00003130| 20 6f 66 20 70 72 6f 67 | 72 61 6d 2e 20 2a 2f 0a | of prog|ram. */.|
|00003140| 58 23 64 65 66 69 6e 65 | 09 42 4f 4c 09 31 09 2f |X#define|.BOL.1./|
|00003150| 2a 20 6e 6f 09 4d 61 74 | 63 68 20 22 22 20 61 74 |* no.Mat|ch "" at|
|00003160| 20 62 65 67 69 6e 6e 69 | 6e 67 20 6f 66 20 6c 69 | beginni|ng of li|
|00003170| 6e 65 2e 20 2a 2f 0a 58 | 23 64 65 66 69 6e 65 09 |ne. */.X|#define.|
|00003180| 45 4f 4c 09 32 09 2f 2a | 20 6e 6f 09 4d 61 74 63 |EOL.2./*| no.Matc|
|00003190| 68 20 22 22 20 61 74 20 | 65 6e 64 20 6f 66 20 6c |h "" at |end of l|
|000031a0| 69 6e 65 2e 20 2a 2f 0a | 58 23 64 65 66 69 6e 65 |ine. */.|X#define|
|000031b0| 09 41 4e 59 09 33 09 2f | 2a 20 6e 6f 09 4d 61 74 |.ANY.3./|* no.Mat|
|000031c0| 63 68 20 61 6e 79 20 6f | 6e 65 20 63 68 61 72 61 |ch any o|ne chara|
|000031d0| 63 74 65 72 2e 20 2a 2f | 0a 58 23 64 65 66 69 6e |cter. */|.X#defin|
|000031e0| 65 09 41 4e 59 4f 46 09 | 34 09 2f 2a 20 73 74 72 |e.ANYOF.|4./* str|
|000031f0| 09 4d 61 74 63 68 20 61 | 6e 79 20 63 68 61 72 61 |.Match a|ny chara|
|00003200| 63 74 65 72 20 69 6e 20 | 74 68 69 73 20 73 74 72 |cter in |this str|
|00003210| 69 6e 67 2e 20 2a 2f 0a | 58 23 64 65 66 69 6e 65 |ing. */.|X#define|
|00003220| 09 41 4e 59 42 55 54 09 | 35 09 2f 2a 20 73 74 72 |.ANYBUT.|5./* str|
|00003230| 09 4d 61 74 63 68 20 61 | 6e 79 20 63 68 61 72 61 |.Match a|ny chara|
|00003240| 63 74 65 72 20 6e 6f 74 | 20 69 6e 20 74 68 69 73 |cter not| in this|
|00003250| 20 73 74 72 69 6e 67 2e | 20 2a 2f 0a 58 23 64 65 | string.| */.X#de|
|00003260| 66 69 6e 65 09 42 52 41 | 4e 43 48 09 36 09 2f 2a |fine.BRA|NCH.6./*|
|00003270| 20 6e 6f 64 65 09 4d 61 | 74 63 68 20 74 68 69 73 | node.Ma|tch this|
|00003280| 20 61 6c 74 65 72 6e 61 | 74 69 76 65 2c 20 6f 72 | alterna|tive, or|
|00003290| 20 74 68 65 20 6e 65 78 | 74 2e 2e 2e 20 2a 2f 0a | the nex|t... */.|
|000032a0| 58 23 64 65 66 69 6e 65 | 09 42 41 43 4b 09 37 09 |X#define|.BACK.7.|
|000032b0| 2f 2a 20 6e 6f 09 4d 61 | 74 63 68 20 22 22 2c 20 |/* no.Ma|tch "", |
|000032c0| 22 6e 65 78 74 22 20 70 | 74 72 20 70 6f 69 6e 74 |"next" p|tr point|
|000032d0| 73 20 62 61 63 6b 77 61 | 72 64 2e 20 2a 2f 0a 58 |s backwa|rd. */.X|
|000032e0| 23 64 65 66 69 6e 65 09 | 45 58 41 43 54 4c 59 09 |#define.|EXACTLY.|
|000032f0| 38 09 2f 2a 20 73 74 72 | 09 4d 61 74 63 68 20 74 |8./* str|.Match t|
|00003300| 68 69 73 20 73 74 72 69 | 6e 67 2e 20 2a 2f 0a 58 |his stri|ng. */.X|
|00003310| 23 64 65 66 69 6e 65 09 | 4e 4f 54 48 49 4e 47 09 |#define.|NOTHING.|
|00003320| 39 09 2f 2a 20 6e 6f 09 | 4d 61 74 63 68 20 65 6d |9./* no.|Match em|
|00003330| 70 74 79 20 73 74 72 69 | 6e 67 2e 20 2a 2f 0a 58 |pty stri|ng. */.X|
|00003340| 23 64 65 66 69 6e 65 09 | 53 54 41 52 09 31 30 09 |#define.|STAR.10.|
|00003350| 2f 2a 20 6e 6f 64 65 09 | 4d 61 74 63 68 20 74 68 |/* node.|Match th|
|00003360| 69 73 20 28 73 69 6d 70 | 6c 65 29 20 74 68 69 6e |is (simp|le) thin|
|00003370| 67 20 30 20 6f 72 20 6d | 6f 72 65 20 74 69 6d 65 |g 0 or m|ore time|
|00003380| 73 2e 20 2a 2f 0a 58 23 | 64 65 66 69 6e 65 09 50 |s. */.X#|define.P|
|00003390| 4c 55 53 09 31 31 09 2f | 2a 20 6e 6f 64 65 09 4d |LUS.11./|* node.M|
|000033a0| 61 74 63 68 20 74 68 69 | 73 20 28 73 69 6d 70 6c |atch thi|s (simpl|
|000033b0| 65 29 20 74 68 69 6e 67 | 20 31 20 6f 72 20 6d 6f |e) thing| 1 or mo|
|000033c0| 72 65 20 74 69 6d 65 73 | 2e 20 2a 2f 0a 58 23 64 |re times|. */.X#d|
|000033d0| 65 66 69 6e 65 09 4f 50 | 45 4e 09 32 30 09 2f 2a |efine.OP|EN.20./*|
|000033e0| 20 6e 6f 09 4d 61 72 6b | 20 74 68 69 73 20 70 6f | no.Mark| this po|
|000033f0| 69 6e 74 20 69 6e 20 69 | 6e 70 75 74 20 61 73 20 |int in i|nput as |
|00003400| 73 74 61 72 74 20 6f 66 | 20 23 6e 2e 20 2a 2f 0a |start of| #n. */.|
|00003410| 58 09 09 09 2f 2a 09 4f | 50 45 4e 2b 31 20 69 73 |X.../*.O|PEN+1 is|
|00003420| 20 6e 75 6d 62 65 72 20 | 31 2c 20 65 74 63 2e 20 | number |1, etc. |
|00003430| 2a 2f 0a 58 23 64 65 66 | 69 6e 65 09 43 4c 4f 53 |*/.X#def|ine.CLOS|
|00003440| 45 09 33 30 09 2f 2a 20 | 6e 6f 09 41 6e 61 6c 6f |E.30./* |no.Analo|
|00003450| 67 6f 75 73 20 74 6f 20 | 4f 50 45 4e 2e 20 2a 2f |gous to |OPEN. */|
|00003460| 0a 58 0a 58 2f 2a 0a 58 | 20 2a 20 4f 70 63 6f 64 |.X.X/*.X| * Opcod|
|00003470| 65 20 6e 6f 74 65 73 3a | 0a 58 20 2a 0a 58 20 2a |e notes:|.X *.X *|
|00003480| 20 42 52 41 4e 43 48 09 | 54 68 65 20 73 65 74 20 | BRANCH.|The set |
|00003490| 6f 66 20 62 72 61 6e 63 | 68 65 73 20 63 6f 6e 73 |of branc|hes cons|
|000034a0| 74 69 74 75 74 69 6e 67 | 20 61 20 73 69 6e 67 6c |tituting| a singl|
|000034b0| 65 20 63 68 6f 69 63 65 | 20 61 72 65 20 68 6f 6f |e choice| are hoo|
|000034c0| 6b 65 64 0a 58 20 2a 09 | 09 74 6f 67 65 74 68 65 |ked.X *.|.togethe|
|000034d0| 72 20 77 69 74 68 20 74 | 68 65 69 72 20 22 6e 65 |r with t|heir "ne|
|000034e0| 78 74 22 20 70 6f 69 6e | 74 65 72 73 2c 20 73 69 |xt" poin|ters, si|
|000034f0| 6e 63 65 20 70 72 65 63 | 65 64 65 6e 63 65 20 70 |nce prec|edence p|
|00003500| 72 65 76 65 6e 74 73 0a | 58 20 2a 09 09 61 6e 79 |revents.|X *..any|
|00003510| 74 68 69 6e 67 20 62 65 | 69 6e 67 20 63 6f 6e 63 |thing be|ing conc|
|00003520| 61 74 65 6e 61 74 65 64 | 20 74 6f 20 61 6e 79 20 |atenated| to any |
|00003530| 69 6e 64 69 76 69 64 75 | 61 6c 20 62 72 61 6e 63 |individu|al branc|
|00003540| 68 2e 20 20 54 68 65 0a | 58 20 2a 09 09 22 6e 65 |h. The.|X *.."ne|
|00003550| 78 74 22 20 70 6f 69 6e | 74 65 72 20 6f 66 20 74 |xt" poin|ter of t|
|00003560| 68 65 20 6c 61 73 74 20 | 42 52 41 4e 43 48 20 69 |he last |BRANCH i|
|00003570| 6e 20 61 20 63 68 6f 69 | 63 65 20 70 6f 69 6e 74 |n a choi|ce point|
|00003580| 73 20 74 6f 20 74 68 65 | 0a 58 20 2a 09 09 74 68 |s to the|.X *..th|
|00003590| 69 6e 67 20 66 6f 6c 6c | 6f 77 69 6e 67 20 74 68 |ing foll|owing th|
|000035a0| 65 20 77 68 6f 6c 65 20 | 63 68 6f 69 63 65 2e 20 |e whole |choice. |
|000035b0| 20 54 68 69 73 20 69 73 | 20 61 6c 73 6f 20 77 68 | This is| also wh|
|000035c0| 65 72 65 20 74 68 65 0a | 58 20 2a 09 09 66 69 6e |ere the.|X *..fin|
|000035d0| 61 6c 20 22 6e 65 78 74 | 22 20 70 6f 69 6e 74 65 |al "next|" pointe|
|000035e0| 72 20 6f 66 20 65 61 63 | 68 20 69 6e 64 69 76 69 |r of eac|h indivi|
|000035f0| 64 75 61 6c 20 62 72 61 | 6e 63 68 20 70 6f 69 6e |dual bra|nch poin|
|00003600| 74 73 3b 20 65 61 63 68 | 0a 58 20 2a 09 09 62 72 |ts; each|.X *..br|
|00003610| 61 6e 63 68 20 73 74 61 | 72 74 73 20 77 69 74 68 |anch sta|rts with|
|00003620| 20 74 68 65 20 6f 70 65 | 72 61 6e 64 20 6e 6f 64 | the ope|rand nod|
|00003630| 65 20 6f 66 20 61 20 42 | 52 41 4e 43 48 20 6e 6f |e of a B|RANCH no|
|00003640| 64 65 2e 0a 58 20 2a 0a | 58 20 2a 20 42 41 43 4b |de..X *.|X * BACK|
|00003650| 09 09 4e 6f 72 6d 61 6c | 20 22 6e 65 78 74 22 20 |..Normal| "next" |
|00003660| 70 6f 69 6e 74 65 72 73 | 20 61 6c 6c 20 69 6d 70 |pointers| all imp|
|00003670| 6c 69 63 69 74 6c 79 20 | 70 6f 69 6e 74 20 66 6f |licitly |point fo|
|00003680| 72 77 61 72 64 3b 20 42 | 41 43 4b 0a 58 20 2a 09 |rward; B|ACK.X *.|
|00003690| 09 65 78 69 73 74 73 20 | 74 6f 20 6d 61 6b 65 20 |.exists |to make |
|000036a0| 6c 6f 6f 70 20 73 74 72 | 75 63 74 75 72 65 73 20 |loop str|uctures |
|000036b0| 70 6f 73 73 69 62 6c 65 | 2e 0a 58 20 2a 0a 58 20 |possible|..X *.X |
|000036c0| 2a 20 53 54 41 52 2c 50 | 4c 55 53 09 27 3f 27 2c |* STAR,P|LUS.'?',|
|000036d0| 20 61 6e 64 20 63 6f 6d | 70 6c 65 78 20 27 2a 27 | and com|plex '*'|
|000036e0| 20 61 6e 64 20 27 2b 27 | 2c 20 61 72 65 20 69 6d | and '+'|, are im|
|000036f0| 70 6c 65 6d 65 6e 74 65 | 64 20 61 73 20 63 69 72 |plemente|d as cir|
|00003700| 63 75 6c 61 72 0a 58 20 | 2a 09 09 42 52 41 4e 43 |cular.X |*..BRANC|
|00003710| 48 20 73 74 72 75 63 74 | 75 72 65 73 20 75 73 69 |H struct|ures usi|
|00003720| 6e 67 20 42 41 43 4b 2e | 20 20 53 69 6d 70 6c 65 |ng BACK.| Simple|
|00003730| 20 63 61 73 65 73 20 28 | 6f 6e 65 20 63 68 61 72 | cases (|one char|
|00003740| 61 63 74 65 72 0a 58 20 | 2a 09 09 70 65 72 20 6d |acter.X |*..per m|
|00003750| 61 74 63 68 29 20 61 72 | 65 20 69 6d 70 6c 65 6d |atch) ar|e implem|
|00003760| 65 6e 74 65 64 20 77 69 | 74 68 20 53 54 41 52 20 |ented wi|th STAR |
|00003770| 61 6e 64 20 50 4c 55 53 | 20 66 6f 72 20 73 70 65 |and PLUS| for spe|
|00003780| 65 64 0a 58 20 2a 09 09 | 61 6e 64 20 74 6f 20 6d |ed.X *..|and to m|
|00003790| 69 6e 69 6d 69 7a 65 20 | 72 65 63 75 72 73 69 76 |inimize |recursiv|
|000037a0| 65 20 70 6c 75 6e 67 65 | 73 2e 0a 58 20 2a 0a 58 |e plunge|s..X *.X|
|000037b0| 20 2a 20 4f 50 45 4e 2c | 43 4c 4f 53 45 09 2e 2e | * OPEN,|CLOSE...|
|000037c0| 2e 61 72 65 20 6e 75 6d | 62 65 72 65 64 20 61 74 |.are num|bered at|
|000037d0| 20 63 6f 6d 70 69 6c 65 | 20 74 69 6d 65 2e 0a 58 | compile| time..X|
|000037e0| 20 2a 2f 0a 58 0a 58 2f | 2a 0a 58 20 2a 20 41 20 | */.X.X/|*.X * A |
|000037f0| 6e 6f 64 65 20 69 73 20 | 6f 6e 65 20 63 68 61 72 |node is |one char|
|00003800| 20 6f 66 20 6f 70 63 6f | 64 65 20 66 6f 6c 6c 6f | of opco|de follo|
|00003810| 77 65 64 20 62 79 20 74 | 77 6f 20 63 68 61 72 73 |wed by t|wo chars|
|00003820| 20 6f 66 20 22 6e 65 78 | 74 22 20 70 6f 69 6e 74 | of "nex|t" point|
|00003830| 65 72 2e 0a 58 20 2a 20 | 22 4e 65 78 74 22 20 70 |er..X * |"Next" p|
|00003840| 6f 69 6e 74 65 72 73 20 | 61 72 65 20 73 74 6f 72 |ointers |are stor|
|00003850| 65 64 20 61 73 20 74 77 | 6f 20 38 2d 62 69 74 20 |ed as tw|o 8-bit |
|00003860| 70 69 65 63 65 73 2c 20 | 68 69 67 68 20 6f 72 64 |pieces, |high ord|
|00003870| 65 72 20 66 69 72 73 74 | 2e 20 20 54 68 65 0a 58 |er first|. The.X|
|00003880| 20 2a 20 76 61 6c 75 65 | 20 69 73 20 61 20 70 6f | * value| is a po|
|00003890| 73 69 74 69 76 65 20 6f | 66 66 73 65 74 20 66 72 |sitive o|ffset fr|
|000038a0| 6f 6d 20 74 68 65 20 6f | 70 63 6f 64 65 20 6f 66 |om the o|pcode of|
|000038b0| 20 74 68 65 20 6e 6f 64 | 65 20 63 6f 6e 74 61 69 | the nod|e contai|
|000038c0| 6e 69 6e 67 20 69 74 2e | 0a 58 20 2a 20 41 6e 20 |ning it.|.X * An |
|000038d0| 6f 70 65 72 61 6e 64 2c | 20 69 66 20 61 6e 79 2c |operand,| if any,|
|000038e0| 20 73 69 6d 70 6c 79 20 | 66 6f 6c 6c 6f 77 73 20 | simply |follows |
|000038f0| 74 68 65 20 6e 6f 64 65 | 2e 20 20 28 4e 6f 74 65 |the node|. (Note|
|00003900| 20 74 68 61 74 20 6d 75 | 63 68 20 6f 66 20 74 68 | that mu|ch of th|
|00003910| 65 0a 58 20 2a 20 63 6f | 64 65 20 67 65 6e 65 72 |e.X * co|de gener|
|00003920| 61 74 69 6f 6e 20 6b 6e | 6f 77 73 20 61 62 6f 75 |ation kn|ows abou|
|00003930| 74 20 74 68 69 73 20 69 | 6d 70 6c 69 63 69 74 20 |t this i|mplicit |
|00003940| 72 65 6c 61 74 69 6f 6e | 73 68 69 70 2e 29 0a 58 |relation|ship.).X|
|00003950| 20 2a 0a 58 20 2a 20 55 | 73 69 6e 67 20 74 77 6f | *.X * U|sing two|
|00003960| 20 62 79 74 65 73 20 66 | 6f 72 20 74 68 65 20 22 | bytes f|or the "|
|00003970| 6e 65 78 74 22 20 70 6f | 69 6e 74 65 72 20 69 73 |next" po|inter is|
|00003980| 20 76 61 73 74 20 6f 76 | 65 72 6b 69 6c 6c 20 66 | vast ov|erkill f|
|00003990| 6f 72 20 6d 6f 73 74 20 | 74 68 69 6e 67 73 2c 0a |or most |things,.|
|000039a0| 58 20 2a 20 62 75 74 20 | 61 6c 6c 6f 77 73 20 70 |X * but |allows p|
|000039b0| 61 74 74 65 72 6e 73 20 | 74 6f 20 67 65 74 20 62 |atterns |to get b|
|000039c0| 69 67 20 77 69 74 68 6f | 75 74 20 64 69 73 61 73 |ig witho|ut disas|
|000039d0| 74 65 72 73 2e 0a 58 20 | 2a 2f 0a 58 23 64 65 66 |ters..X |*/.X#def|
|000039e0| 69 6e 65 09 4f 50 28 70 | 29 09 28 2a 28 70 29 29 |ine.OP(p|).(*(p))|
|000039f0| 0a 58 23 64 65 66 69 6e | 65 09 4e 45 58 54 28 70 |.X#defin|e.NEXT(p|
|00003a00| 29 09 28 28 28 2a 28 28 | 70 29 2b 31 29 26 30 33 |).(((*((|p)+1)&03|
|00003a10| 37 37 29 3c 3c 38 29 20 | 2b 20 28 2a 28 28 70 29 |77)<<8) |+ (*((p)|
|00003a20| 2b 32 29 26 30 33 37 37 | 29 29 0a 58 23 64 65 66 |+2)&0377|)).X#def|
|00003a30| 69 6e 65 09 4f 50 45 52 | 41 4e 44 28 70 29 09 28 |ine.OPER|AND(p).(|
|00003a40| 28 70 29 20 2b 20 33 29 | 0a 58 0a 58 2f 2a 0a 58 |(p) + 3)|.X.X/*.X|
|00003a50| 20 2a 20 53 65 65 20 72 | 65 67 6d 61 67 69 63 2e | * See r|egmagic.|
|00003a60| 68 20 66 6f 72 20 6f 6e | 65 20 66 75 72 74 68 65 |h for on|e furthe|
|00003a70| 72 20 64 65 74 61 69 6c | 20 6f 66 20 70 72 6f 67 |r detail| of prog|
|00003a80| 72 61 6d 20 73 74 72 75 | 63 74 75 72 65 2e 0a 58 |ram stru|cture..X|
|00003a90| 20 2a 2f 0a 58 0a 58 0a | 58 2f 2a 0a 58 20 2a 20 | */.X.X.|X/*.X * |
|00003aa0| 55 74 69 6c 69 74 79 20 | 64 65 66 69 6e 69 74 69 |Utility |definiti|
|00003ab0| 6f 6e 73 2e 0a 58 20 2a | 2f 0a 58 23 69 66 6e 64 |ons..X *|/.X#ifnd|
|00003ac0| 65 66 20 43 48 41 52 42 | 49 54 53 0a 58 23 64 65 |ef CHARB|ITS.X#de|
|00003ad0| 66 69 6e 65 09 55 43 48 | 41 52 41 54 28 70 29 09 |fine.UCH|ARAT(p).|
|00003ae0| 28 28 69 6e 74 29 2a 28 | 75 6e 73 69 67 6e 65 64 |((int)*(|unsigned|
|00003af0| 20 63 68 61 72 20 2a 29 | 28 70 29 29 0a 58 23 65 | char *)|(p)).X#e|
|00003b00| 6c 73 65 0a 58 23 64 65 | 66 69 6e 65 09 55 43 48 |lse.X#de|fine.UCH|
|00003b10| 41 52 41 54 28 70 29 09 | 28 28 69 6e 74 29 2a 28 |ARAT(p).|((int)*(|
|00003b20| 70 29 26 43 48 41 52 42 | 49 54 53 29 0a 58 23 65 |p)&CHARB|ITS).X#e|
|00003b30| 6e 64 69 66 0a 58 0a 58 | 23 64 65 66 69 6e 65 09 |ndif.X.X|#define.|
|00003b40| 46 41 49 4c 28 6d 29 09 | 7b 20 72 65 67 65 72 72 |FAIL(m).|{ regerr|
|00003b50| 6f 72 28 6d 29 3b 20 72 | 65 74 75 72 6e 28 4e 55 |or(m); r|eturn(NU|
|00003b60| 4c 4c 29 3b 20 7d 0a 58 | 23 64 65 66 69 6e 65 09 |LL); }.X|#define.|
|00003b70| 49 53 4d 55 4c 54 28 63 | 29 09 28 28 63 29 20 3d |ISMULT(c|).((c) =|
|00003b80| 3d 20 27 2a 27 20 7c 7c | 20 28 63 29 20 3d 3d 20 |= '*' ||| (c) == |
|00003b90| 27 2b 27 20 7c 7c 20 28 | 63 29 20 3d 3d 20 27 3f |'+' || (|c) == '?|
|00003ba0| 27 29 0a 58 23 64 65 66 | 69 6e 65 09 4d 45 54 41 |').X#def|ine.META|
|00003bb0| 09 22 5e 24 2e 5b 28 29 | 7c 3f 2b 2a 5c 5c 22 0a |."^$.[()||?+*\\".|
|00003bc0| 58 0a 58 2f 2a 0a 58 20 | 2a 20 46 6c 61 67 73 20 |X.X/*.X |* Flags |
|00003bd0| 74 6f 20 62 65 20 70 61 | 73 73 65 64 20 75 70 20 |to be pa|ssed up |
|00003be0| 61 6e 64 20 64 6f 77 6e | 2e 0a 58 20 2a 2f 0a 58 |and down|..X */.X|
|00003bf0| 23 64 65 66 69 6e 65 09 | 48 41 53 57 49 44 54 48 |#define.|HASWIDTH|
|00003c00| 09 30 31 09 2f 2a 20 4b | 6e 6f 77 6e 20 6e 65 76 |.01./* K|nown nev|
|00003c10| 65 72 20 74 6f 20 6d 61 | 74 63 68 20 6e 75 6c 6c |er to ma|tch null|
|00003c20| 20 73 74 72 69 6e 67 2e | 20 2a 2f 0a 58 23 64 65 | string.| */.X#de|
|00003c30| 66 69 6e 65 09 53 49 4d | 50 4c 45 09 09 30 32 09 |fine.SIM|PLE..02.|
|00003c40| 2f 2a 20 53 69 6d 70 6c | 65 20 65 6e 6f 75 67 68 |/* Simpl|e enough|
|00003c50| 20 74 6f 20 62 65 20 53 | 54 41 52 2f 50 4c 55 53 | to be S|TAR/PLUS|
|00003c60| 20 6f 70 65 72 61 6e 64 | 2e 20 2a 2f 0a 58 23 64 | operand|. */.X#d|
|00003c70| 65 66 69 6e 65 09 53 50 | 53 54 41 52 54 09 09 30 |efine.SP|START..0|
|00003c80| 34 09 2f 2a 20 53 74 61 | 72 74 73 20 77 69 74 68 |4./* Sta|rts with|
|00003c90| 20 2a 20 6f 72 20 2b 2e | 20 2a 2f 0a 58 23 64 65 | * or +.| */.X#de|
|00003ca0| 66 69 6e 65 09 57 4f 52 | 53 54 09 09 30 09 2f 2a |fine.WOR|ST..0./*|
|00003cb0| 20 57 6f 72 73 74 20 63 | 61 73 65 2e 20 2a 2f 0a | Worst c|ase. */.|
|00003cc0| 58 0a 58 2f 2a 0a 58 20 | 2a 20 47 6c 6f 62 61 6c |X.X/*.X |* Global|
|00003cd0| 20 77 6f 72 6b 20 76 61 | 72 69 61 62 6c 65 73 20 | work va|riables |
|00003ce0| 66 6f 72 20 72 65 67 63 | 6f 6d 70 28 29 2e 0a 58 |for regc|omp()..X|
|00003cf0| 20 2a 2f 0a 58 73 74 61 | 74 69 63 20 63 68 61 72 | */.Xsta|tic char|
|00003d00| 20 2a 72 65 67 70 61 72 | 73 65 3b 09 09 2f 2a 20 | *regpar|se;../* |
|00003d10| 49 6e 70 75 74 2d 73 63 | 61 6e 20 70 6f 69 6e 74 |Input-sc|an point|
|00003d20| 65 72 2e 20 2a 2f 0a 58 | 73 74 61 74 69 63 20 69 |er. */.X|static i|
|00003d30| 6e 74 20 72 65 67 6e 70 | 61 72 3b 09 09 2f 2a 20 |nt regnp|ar;../* |
|00003d40| 28 29 20 63 6f 75 6e 74 | 2e 20 2a 2f 0a 58 73 74 |() count|. */.Xst|
|00003d50| 61 74 69 63 20 63 68 61 | 72 20 72 65 67 64 75 6d |atic cha|r regdum|
|00003d60| 6d 79 3b 0a 58 73 74 61 | 74 69 63 20 63 68 61 72 |my;.Xsta|tic char|
|00003d70| 20 2a 72 65 67 63 6f 64 | 65 3b 09 09 2f 2a 20 43 | *regcod|e;../* C|
|00003d80| 6f 64 65 2d 65 6d 69 74 | 20 70 6f 69 6e 74 65 72 |ode-emit| pointer|
|00003d90| 3b 20 26 72 65 67 64 75 | 6d 6d 79 20 3d 20 64 6f |; &regdu|mmy = do|
|00003da0| 6e 27 74 2e 20 2a 2f 0a | 58 73 74 61 74 69 63 20 |n't. */.|Xstatic |
|00003db0| 6c 6f 6e 67 20 72 65 67 | 73 69 7a 65 3b 09 09 2f |long reg|size;../|
|00003dc0| 2a 20 43 6f 64 65 20 73 | 69 7a 65 2e 20 2a 2f 0a |* Code s|ize. */.|
|00003dd0| 58 0a 58 2f 2a 0a 58 20 | 2a 20 46 6f 72 77 61 72 |X.X/*.X |* Forwar|
|00003de0| 64 20 64 65 63 6c 61 72 | 61 74 69 6f 6e 73 20 66 |d declar|ations f|
|00003df0| 6f 72 20 72 65 67 63 6f | 6d 70 28 29 27 73 20 66 |or regco|mp()'s f|
|00003e00| 72 69 65 6e 64 73 2e 0a | 58 20 2a 2f 0a 58 23 69 |riends..|X */.X#i|
|00003e10| 66 6e 64 65 66 20 53 54 | 41 54 49 43 0a 58 23 64 |fndef ST|ATIC.X#d|
|00003e20| 65 66 69 6e 65 09 53 54 | 41 54 49 43 09 73 74 61 |efine.ST|ATIC.sta|
|00003e30| 74 69 63 0a 58 23 65 6e | 64 69 66 0a 58 53 54 41 |tic.X#en|dif.XSTA|
|00003e40| 54 49 43 20 63 68 61 72 | 20 2a 72 65 67 28 29 3b |TIC char| *reg();|
|00003e50| 0a 58 53 54 41 54 49 43 | 20 63 68 61 72 20 2a 72 |.XSTATIC| char *r|
|00003e60| 65 67 62 72 61 6e 63 68 | 28 29 3b 0a 58 53 54 41 |egbranch|();.XSTA|
|00003e70| 54 49 43 20 63 68 61 72 | 20 2a 72 65 67 70 69 65 |TIC char| *regpie|
|00003e80| 63 65 28 29 3b 0a 58 53 | 54 41 54 49 43 20 63 68 |ce();.XS|TATIC ch|
|00003e90| 61 72 20 2a 72 65 67 61 | 74 6f 6d 28 29 3b 0a 58 |ar *rega|tom();.X|
|00003ea0| 53 54 41 54 49 43 20 63 | 68 61 72 20 2a 72 65 67 |STATIC c|har *reg|
|00003eb0| 6e 6f 64 65 28 29 3b 0a | 58 53 54 41 54 49 43 20 |node();.|XSTATIC |
|00003ec0| 63 68 61 72 20 2a 72 65 | 67 6e 65 78 74 28 29 3b |char *re|gnext();|
|00003ed0| 0a 58 53 54 41 54 49 43 | 20 76 6f 69 64 20 72 65 |.XSTATIC| void re|
|00003ee0| 67 63 28 29 3b 0a 58 53 | 54 41 54 49 43 20 76 6f |gc();.XS|TATIC vo|
|00003ef0| 69 64 20 72 65 67 69 6e | 73 65 72 74 28 29 3b 0a |id regin|sert();.|
|00003f00| 58 53 54 41 54 49 43 20 | 76 6f 69 64 20 72 65 67 |XSTATIC |void reg|
|00003f10| 74 61 69 6c 28 29 3b 0a | 58 53 54 41 54 49 43 20 |tail();.|XSTATIC |
|00003f20| 76 6f 69 64 20 72 65 67 | 6f 70 74 61 69 6c 28 29 |void reg|optail()|
|00003f30| 3b 0a 58 23 69 66 64 65 | 66 20 53 54 52 43 53 50 |;.X#ifde|f STRCSP|
|00003f40| 4e 0a 58 53 54 41 54 49 | 43 20 69 6e 74 20 73 74 |N.XSTATI|C int st|
|00003f50| 72 63 73 70 6e 28 29 3b | 0a 58 23 65 6e 64 69 66 |rcspn();|.X#endif|
|00003f60| 0a 58 0a 58 2f 2a 0a 58 | 20 2d 20 72 65 67 63 6f |.X.X/*.X| - regco|
|00003f70| 6d 70 20 2d 20 63 6f 6d | 70 69 6c 65 20 61 20 72 |mp - com|pile a r|
|00003f80| 65 67 75 6c 61 72 20 65 | 78 70 72 65 73 73 69 6f |egular e|xpressio|
|00003f90| 6e 20 69 6e 74 6f 20 69 | 6e 74 65 72 6e 61 6c 20 |n into i|nternal |
|00003fa0| 63 6f 64 65 0a 58 20 2a | 0a 58 20 2a 20 57 65 20 |code.X *|.X * We |
|00003fb0| 63 61 6e 27 74 20 61 6c | 6c 6f 63 61 74 65 20 73 |can't al|locate s|
|00003fc0| 70 61 63 65 20 75 6e 74 | 69 6c 20 77 65 20 6b 6e |pace unt|il we kn|
|00003fd0| 6f 77 20 68 6f 77 20 62 | 69 67 20 74 68 65 20 63 |ow how b|ig the c|
|00003fe0| 6f 6d 70 69 6c 65 64 20 | 66 6f 72 6d 20 77 69 6c |ompiled |form wil|
|00003ff0| 6c 20 62 65 2c 0a 58 20 | 2a 20 62 75 74 20 77 65 |l be,.X |* but we|
|00004000| 20 63 61 6e 27 74 20 63 | 6f 6d 70 69 6c 65 20 69 | can't c|ompile i|
|00004010| 74 20 28 61 6e 64 20 74 | 68 75 73 20 6b 6e 6f 77 |t (and t|hus know|
|00004020| 20 68 6f 77 20 62 69 67 | 20 69 74 20 69 73 29 20 | how big| it is) |
|00004030| 75 6e 74 69 6c 20 77 65 | 27 76 65 20 67 6f 74 20 |until we|'ve got |
|00004040| 61 0a 58 20 2a 20 70 6c | 61 63 65 20 74 6f 20 70 |a.X * pl|ace to p|
|00004050| 75 74 20 74 68 65 20 63 | 6f 64 65 2e 20 20 53 6f |ut the c|ode. So|
|00004060| 20 77 65 20 63 68 65 61 | 74 3a 20 20 77 65 20 63 | we chea|t: we c|
|00004070| 6f 6d 70 69 6c 65 20 69 | 74 20 74 77 69 63 65 2c |ompile i|t twice,|
|00004080| 20 6f 6e 63 65 20 77 69 | 74 68 20 63 6f 64 65 0a | once wi|th code.|
|00004090| 58 20 2a 20 67 65 6e 65 | 72 61 74 69 6f 6e 20 74 |X * gene|ration t|
|000040a0| 75 72 6e 65 64 20 6f 66 | 66 20 61 6e 64 20 73 69 |urned of|f and si|
|000040b0| 7a 65 20 63 6f 75 6e 74 | 69 6e 67 20 74 75 72 6e |ze count|ing turn|
|000040c0| 65 64 20 6f 6e 2c 20 61 | 6e 64 20 6f 6e 63 65 20 |ed on, a|nd once |
|000040d0| 22 66 6f 72 20 72 65 61 | 6c 22 2e 0a 58 20 2a 20 |"for rea|l"..X * |
|000040e0| 54 68 69 73 20 61 6c 73 | 6f 20 6d 65 61 6e 73 20 |This als|o means |
|000040f0| 74 68 61 74 20 77 65 20 | 64 6f 6e 27 74 20 61 6c |that we |don't al|
|00004100| 6c 6f 63 61 74 65 20 73 | 70 61 63 65 20 75 6e 74 |locate s|pace unt|
|00004110| 69 6c 20 77 65 20 61 72 | 65 20 73 75 72 65 20 74 |il we ar|e sure t|
|00004120| 68 61 74 20 74 68 65 0a | 58 20 2a 20 74 68 69 6e |hat the.|X * thin|
|00004130| 67 20 72 65 61 6c 6c 79 | 20 77 69 6c 6c 20 63 6f |g really| will co|
|00004140| 6d 70 69 6c 65 20 73 75 | 63 63 65 73 73 66 75 6c |mpile su|ccessful|
|00004150| 6c 79 2c 20 61 6e 64 20 | 77 65 20 6e 65 76 65 72 |ly, and |we never|
|00004160| 20 68 61 76 65 20 74 6f | 20 6d 6f 76 65 20 74 68 | have to| move th|
|00004170| 65 0a 58 20 2a 20 63 6f | 64 65 20 61 6e 64 20 74 |e.X * co|de and t|
|00004180| 68 75 73 20 69 6e 76 61 | 6c 69 64 61 74 65 20 70 |hus inva|lidate p|
|00004190| 6f 69 6e 74 65 72 73 20 | 69 6e 74 6f 20 69 74 2e |ointers |into it.|
|000041a0| 20 20 28 4e 6f 74 65 20 | 74 68 61 74 20 69 74 20 | (Note |that it |
|000041b0| 68 61 73 20 74 6f 20 62 | 65 20 69 6e 0a 58 20 2a |has to b|e in.X *|
|000041c0| 20 6f 6e 65 20 70 69 65 | 63 65 20 62 65 63 61 75 | one pie|ce becau|
|000041d0| 73 65 20 66 72 65 65 28 | 29 20 6d 75 73 74 20 62 |se free(|) must b|
|000041e0| 65 20 61 62 6c 65 20 74 | 6f 20 66 72 65 65 20 69 |e able t|o free i|
|000041f0| 74 20 61 6c 6c 2e 29 0a | 58 20 2a 0a 58 20 2a 20 |t all.).|X *.X * |
|00004200| 42 65 77 61 72 65 20 74 | 68 61 74 20 74 68 65 20 |Beware t|hat the |
|00004210| 6f 70 74 69 6d 69 7a 61 | 74 69 6f 6e 2d 70 72 65 |optimiza|tion-pre|
|00004220| 70 61 72 61 74 69 6f 6e | 20 63 6f 64 65 20 69 6e |paration| code in|
|00004230| 20 68 65 72 65 20 6b 6e | 6f 77 73 20 61 62 6f 75 | here kn|ows abou|
|00004240| 74 20 73 6f 6d 65 0a 58 | 20 2a 20 6f 66 20 74 68 |t some.X| * of th|
|00004250| 65 20 73 74 72 75 63 74 | 75 72 65 20 6f 66 20 74 |e struct|ure of t|
|00004260| 68 65 20 63 6f 6d 70 69 | 6c 65 64 20 72 65 67 65 |he compi|led rege|
|00004270| 78 70 2e 0a 58 20 2a 2f | 0a 58 72 65 67 65 78 70 |xp..X */|.Xregexp|
|00004280| 20 2a 0a 58 72 65 67 63 | 6f 6d 70 28 65 78 70 29 | *.Xregc|omp(exp)|
|00004290| 0a 58 63 68 61 72 20 2a | 65 78 70 3b 0a 58 7b 0a |.Xchar *|exp;.X{.|
|000042a0| 58 09 72 65 67 69 73 74 | 65 72 20 72 65 67 65 78 |X.regist|er regex|
|000042b0| 70 20 2a 72 3b 0a 58 09 | 72 65 67 69 73 74 65 72 |p *r;.X.|register|
|000042c0| 20 63 68 61 72 20 2a 73 | 63 61 6e 3b 0a 58 09 72 | char *s|can;.X.r|
|000042d0| 65 67 69 73 74 65 72 20 | 63 68 61 72 20 2a 6c 6f |egister |char *lo|
|000042e0| 6e 67 65 73 74 3b 0a 58 | 09 72 65 67 69 73 74 65 |ngest;.X|.registe|
|000042f0| 72 20 69 6e 74 20 6c 65 | 6e 3b 0a 58 09 69 6e 74 |r int le|n;.X.int|
|00004300| 20 66 6c 61 67 73 3b 0a | 58 0a 58 09 69 66 20 28 | flags;.|X.X.if (|
|00004310| 65 78 70 20 3d 3d 20 4e | 55 4c 4c 29 0a 58 09 09 |exp == N|ULL).X..|
|00004320| 46 41 49 4c 28 22 4e 55 | 4c 4c 20 61 72 67 75 6d |FAIL("NU|LL argum|
|00004330| 65 6e 74 22 29 3b 0a 58 | 0a 58 09 2f 2a 20 46 69 |ent");.X|.X./* Fi|
|00004340| 72 73 74 20 70 61 73 73 | 3a 20 64 65 74 65 72 6d |rst pass|: determ|
|00004350| 69 6e 65 20 73 69 7a 65 | 2c 20 6c 65 67 61 6c 69 |ine size|, legali|
|00004360| 74 79 2e 20 2a 2f 0a 58 | 09 72 65 67 70 61 72 73 |ty. */.X|.regpars|
|00004370| 65 20 3d 20 65 78 70 3b | 0a 58 09 72 65 67 6e 70 |e = exp;|.X.regnp|
|00004380| 61 72 20 3d 20 31 3b 0a | 58 09 72 65 67 73 69 7a |ar = 1;.|X.regsiz|
|00004390| 65 20 3d 20 30 4c 3b 0a | 58 09 72 65 67 63 6f 64 |e = 0L;.|X.regcod|
|000043a0| 65 20 3d 20 26 72 65 67 | 64 75 6d 6d 79 3b 0a 58 |e = &reg|dummy;.X|
|000043b0| 09 72 65 67 63 28 4d 41 | 47 49 43 29 3b 0a 58 09 |.regc(MA|GIC);.X.|
|000043c0| 69 66 20 28 72 65 67 28 | 30 2c 20 26 66 6c 61 67 |if (reg(|0, &flag|
|000043d0| 73 29 20 3d 3d 20 4e 55 | 4c 4c 29 0a 58 09 09 72 |s) == NU|LL).X..r|
|000043e0| 65 74 75 72 6e 28 4e 55 | 4c 4c 29 3b 0a 58 0a 58 |eturn(NU|LL);.X.X|
|000043f0| 09 2f 2a 20 53 6d 61 6c | 6c 20 65 6e 6f 75 67 68 |./* Smal|l enough|
|00004400| 20 66 6f 72 20 70 6f 69 | 6e 74 65 72 2d 73 74 6f | for poi|nter-sto|
|00004410| 72 61 67 65 20 63 6f 6e | 76 65 6e 74 69 6f 6e 3f |rage con|vention?|
|00004420| 20 2a 2f 0a 58 09 69 66 | 20 28 72 65 67 73 69 7a | */.X.if| (regsiz|
|00004430| 65 20 3e 3d 20 33 32 37 | 36 37 4c 29 09 09 2f 2a |e >= 327|67L)../*|
|00004440| 20 50 72 6f 62 61 62 6c | 79 20 63 6f 75 6c 64 20 | Probabl|y could |
|00004450| 62 65 20 36 35 35 33 35 | 4c 2e 20 2a 2f 0a 58 09 |be 65535|L. */.X.|
|00004460| 09 46 41 49 4c 28 22 72 | 65 67 65 78 70 20 74 6f |.FAIL("r|egexp to|
|00004470| 6f 20 62 69 67 22 29 3b | 0a 58 0a 58 09 2f 2a 20 |o big");|.X.X./* |
|00004480| 41 6c 6c 6f 63 61 74 65 | 20 73 70 61 63 65 2e 20 |Allocate| space. |
|00004490| 2a 2f 0a 58 09 72 20 3d | 20 28 72 65 67 65 78 70 |*/.X.r =| (regexp|
|000044a0| 20 2a 29 6d 61 6c 6c 6f | 63 28 73 69 7a 65 6f 66 | *)mallo|c(sizeof|
|000044b0| 28 72 65 67 65 78 70 29 | 20 2b 20 28 75 6e 73 69 |(regexp)| + (unsi|
|000044c0| 67 6e 65 64 29 72 65 67 | 73 69 7a 65 29 3b 0a 58 |gned)reg|size);.X|
|000044d0| 09 69 66 20 28 72 20 3d | 3d 20 4e 55 4c 4c 29 0a |.if (r =|= NULL).|
|000044e0| 58 09 09 46 41 49 4c 28 | 22 6f 75 74 20 6f 66 20 |X..FAIL(|"out of |
|000044f0| 73 70 61 63 65 22 29 3b | 0a 58 0a 58 09 2f 2a 20 |space");|.X.X./* |
|00004500| 53 65 63 6f 6e 64 20 70 | 61 73 73 3a 20 65 6d 69 |Second p|ass: emi|
|00004510| 74 20 63 6f 64 65 2e 20 | 2a 2f 0a 58 09 72 65 67 |t code. |*/.X.reg|
|00004520| 70 61 72 73 65 20 3d 20 | 65 78 70 3b 0a 58 09 72 |parse = |exp;.X.r|
|00004530| 65 67 6e 70 61 72 20 3d | 20 31 3b 0a 58 09 72 65 |egnpar =| 1;.X.re|
|00004540| 67 63 6f 64 65 20 3d 20 | 72 2d 3e 70 72 6f 67 72 |gcode = |r->progr|
|00004550| 61 6d 3b 0a 58 09 72 65 | 67 63 28 4d 41 47 49 43 |am;.X.re|gc(MAGIC|
|00004560| 29 3b 0a 58 09 69 66 20 | 28 72 65 67 28 30 2c 20 |);.X.if |(reg(0, |
|00004570| 26 66 6c 61 67 73 29 20 | 3d 3d 20 4e 55 4c 4c 29 |&flags) |== NULL)|
|00004580| 0a 58 09 09 72 65 74 75 | 72 6e 28 4e 55 4c 4c 29 |.X..retu|rn(NULL)|
|00004590| 3b 0a 58 0a 58 09 2f 2a | 20 44 69 67 20 6f 75 74 |;.X.X./*| Dig out|
|000045a0| 20 69 6e 66 6f 72 6d 61 | 74 69 6f 6e 20 66 6f 72 | informa|tion for|
|000045b0| 20 6f 70 74 69 6d 69 7a | 61 74 69 6f 6e 73 2e 20 | optimiz|ations. |
|000045c0| 2a 2f 0a 58 09 72 2d 3e | 72 65 67 73 74 61 72 74 |*/.X.r->|regstart|
|000045d0| 20 3d 20 27 5c 30 27 3b | 09 2f 2a 20 57 6f 72 73 | = '\0';|./* Wors|
|000045e0| 74 2d 63 61 73 65 20 64 | 65 66 61 75 6c 74 73 2e |t-case d|efaults.|
|000045f0| 20 2a 2f 0a 58 09 72 2d | 3e 72 65 67 61 6e 63 68 | */.X.r-|>reganch|
|00004600| 20 3d 20 30 3b 0a 58 09 | 72 2d 3e 72 65 67 6d 75 | = 0;.X.|r->regmu|
|00004610| 73 74 20 3d 20 4e 55 4c | 4c 3b 0a 58 09 72 2d 3e |st = NUL|L;.X.r->|
|00004620| 72 65 67 6d 6c 65 6e 20 | 3d 20 30 3b 0a 58 09 73 |regmlen |= 0;.X.s|
|00004630| 63 61 6e 20 3d 20 72 2d | 3e 70 72 6f 67 72 61 6d |can = r-|>program|
|00004640| 2b 31 3b 09 09 09 2f 2a | 20 46 69 72 73 74 20 42 |+1;.../*| First B|
|00004650| 52 41 4e 43 48 2e 20 2a | 2f 0a 58 09 69 66 20 28 |RANCH. *|/.X.if (|
|00004660| 4f 50 28 72 65 67 6e 65 | 78 74 28 73 63 61 6e 29 |OP(regne|xt(scan)|
|00004670| 29 20 3d 3d 20 45 4e 44 | 29 20 7b 09 09 2f 2a 20 |) == END|) {../* |
|00004680| 4f 6e 6c 79 20 6f 6e 65 | 20 74 6f 70 2d 6c 65 76 |Only one| top-lev|
|00004690| 65 6c 20 63 68 6f 69 63 | 65 2e 20 2a 2f 0a 58 09 |el choic|e. */.X.|
|000046a0| 09 73 63 61 6e 20 3d 20 | 4f 50 45 52 41 4e 44 28 |.scan = |OPERAND(|
|000046b0| 73 63 61 6e 29 3b 0a 58 | 0a 58 09 09 2f 2a 20 53 |scan);.X|.X../* S|
|000046c0| 74 61 72 74 69 6e 67 2d | 70 6f 69 6e 74 20 69 6e |tarting-|point in|
|000046d0| 66 6f 2e 20 2a 2f 0a 58 | 09 09 69 66 20 28 4f 50 |fo. */.X|..if (OP|
|000046e0| 28 73 63 61 6e 29 20 3d | 3d 20 45 58 41 43 54 4c |(scan) =|= EXACTL|
|000046f0| 59 29 0a 58 09 09 09 72 | 2d 3e 72 65 67 73 74 61 |Y).X...r|->regsta|
|00004700| 72 74 20 3d 20 2a 4f 50 | 45 52 41 4e 44 28 73 63 |rt = *OP|ERAND(sc|
|00004710| 61 6e 29 3b 0a 58 09 09 | 65 6c 73 65 20 69 66 20 |an);.X..|else if |
|00004720| 28 4f 50 28 73 63 61 6e | 29 20 3d 3d 20 42 4f 4c |(OP(scan|) == BOL|
|00004730| 29 0a 58 09 09 09 72 2d | 3e 72 65 67 61 6e 63 68 |).X...r-|>reganch|
|00004740| 2b 2b 3b 0a 58 0a 58 09 | 09 2f 2a 0a 58 09 09 20 |++;.X.X.|./*.X.. |
|00004750| 2a 20 49 66 20 74 68 65 | 72 65 27 73 20 73 6f 6d |* If the|re's som|
|00004760| 65 74 68 69 6e 67 20 65 | 78 70 65 6e 73 69 76 65 |ething e|xpensive|
|00004770| 20 69 6e 20 74 68 65 20 | 72 2e 65 2e 2c 20 66 69 | in the |r.e., fi|
|00004780| 6e 64 20 74 68 65 0a 58 | 09 09 20 2a 20 6c 6f 6e |nd the.X|.. * lon|
|00004790| 67 65 73 74 20 6c 69 74 | 65 72 61 6c 20 73 74 72 |gest lit|eral str|
|000047a0| 69 6e 67 20 74 68 61 74 | 20 6d 75 73 74 20 61 70 |ing that| must ap|
|000047b0| 70 65 61 72 20 61 6e 64 | 20 6d 61 6b 65 20 69 74 |pear and| make it|
|000047c0| 20 74 68 65 0a 58 09 09 | 20 2a 20 72 65 67 6d 75 | the.X..| * regmu|
|000047d0| 73 74 2e 20 20 52 65 73 | 6f 6c 76 65 20 74 69 65 |st. Res|olve tie|
|000047e0| 73 20 69 6e 20 66 61 76 | 6f 72 20 6f 66 20 6c 61 |s in fav|or of la|
|000047f0| 74 65 72 20 73 74 72 69 | 6e 67 73 2c 20 73 69 6e |ter stri|ngs, sin|
|00004800| 63 65 0a 58 09 09 20 2a | 20 74 68 65 20 72 65 67 |ce.X.. *| the reg|
|00004810| 73 74 61 72 74 20 63 68 | 65 63 6b 20 77 6f 72 6b |start ch|eck work|
|00004820| 73 20 77 69 74 68 20 74 | 68 65 20 62 65 67 69 6e |s with t|he begin|
|00004830| 6e 69 6e 67 20 6f 66 20 | 74 68 65 20 72 2e 65 2e |ning of |the r.e.|
|00004840| 0a 58 09 09 20 2a 20 61 | 6e 64 20 61 76 6f 69 64 |.X.. * a|nd avoid|
|00004850| 69 6e 67 20 64 75 70 6c | 69 63 61 74 69 6f 6e 20 |ing dupl|ication |
|00004860| 73 74 72 65 6e 67 74 68 | 65 6e 73 20 63 68 65 63 |strength|ens chec|
|00004870| 6b 69 6e 67 2e 20 20 4e | 6f 74 20 61 0a 58 09 09 |king. N|ot a.X..|
|00004880| 20 2a 20 73 74 72 6f 6e | 67 20 72 65 61 73 6f 6e | * stron|g reason|
|00004890| 2c 20 62 75 74 20 73 75 | 66 66 69 63 69 65 6e 74 |, but su|fficient|
|000048a0| 20 69 6e 20 74 68 65 20 | 61 62 73 65 6e 63 65 20 | in the |absence |
|000048b0| 6f 66 20 6f 74 68 65 72 | 73 2e 0a 58 09 09 20 2a |of other|s..X.. *|
|000048c0| 2f 0a 58 09 09 69 66 20 | 28 66 6c 61 67 73 26 53 |/.X..if |(flags&S|
|000048d0| 50 53 54 41 52 54 29 20 | 7b 0a 58 09 09 09 6c 6f |PSTART) |{.X...lo|
|000048e0| 6e 67 65 73 74 20 3d 20 | 4e 55 4c 4c 3b 0a 58 09 |ngest = |NULL;.X.|
|000048f0| 09 09 6c 65 6e 20 3d 20 | 30 3b 0a 58 09 09 09 66 |..len = |0;.X...f|
|00004900| 6f 72 20 28 3b 20 73 63 | 61 6e 20 21 3d 20 4e 55 |or (; sc|an != NU|
|00004910| 4c 4c 3b 20 73 63 61 6e | 20 3d 20 72 65 67 6e 65 |LL; scan| = regne|
|00004920| 78 74 28 73 63 61 6e 29 | 29 0a 58 09 09 09 09 69 |xt(scan)|).X....i|
|00004930| 66 20 28 4f 50 28 73 63 | 61 6e 29 20 3d 3d 20 45 |f (OP(sc|an) == E|
|00004940| 58 41 43 54 4c 59 20 26 | 26 20 73 74 72 6c 65 6e |XACTLY &|& strlen|
|00004950| 28 4f 50 45 52 41 4e 44 | 28 73 63 61 6e 29 29 20 |(OPERAND|(scan)) |
|00004960| 3e 3d 20 6c 65 6e 29 20 | 7b 0a 58 09 09 09 09 09 |>= len) |{.X.....|
|00004970| 6c 6f 6e 67 65 73 74 20 | 3d 20 4f 50 45 52 41 4e |longest |= OPERAN|
|00004980| 44 28 73 63 61 6e 29 3b | 0a 58 09 09 09 09 09 6c |D(scan);|.X.....l|
|00004990| 65 6e 20 3d 20 73 74 72 | 6c 65 6e 28 4f 50 45 52 |en = str|len(OPER|
|000049a0| 41 4e 44 28 73 63 61 6e | 29 29 3b 0a 58 09 09 09 |AND(scan|));.X...|
|000049b0| 09 7d 0a 58 09 09 09 72 | 2d 3e 72 65 67 6d 75 73 |.}.X...r|->regmus|
|000049c0| 74 20 3d 20 6c 6f 6e 67 | 65 73 74 3b 0a 58 09 09 |t = long|est;.X..|
|000049d0| 09 72 2d 3e 72 65 67 6d | 6c 65 6e 20 3d 20 6c 65 |.r->regm|len = le|
|000049e0| 6e 3b 0a 58 09 09 7d 0a | 58 09 7d 0a 58 0a 58 09 |n;.X..}.|X.}.X.X.|
|000049f0| 72 65 74 75 72 6e 28 72 | 29 3b 0a 58 7d 0a 58 0a |return(r|);.X}.X.|
|00004a00| 58 2f 2a 0a 58 20 2d 20 | 72 65 67 20 2d 20 72 65 |X/*.X - |reg - re|
|00004a10| 67 75 6c 61 72 20 65 78 | 70 72 65 73 73 69 6f 6e |gular ex|pression|
|00004a20| 2c 20 69 2e 65 2e 20 6d | 61 69 6e 20 62 6f 64 79 |, i.e. m|ain body|
|00004a30| 20 6f 72 20 70 61 72 65 | 6e 74 68 65 73 69 7a 65 | or pare|nthesize|
|00004a40| 64 20 74 68 69 6e 67 0a | 58 20 2a 0a 58 20 2a 20 |d thing.|X *.X * |
|00004a50| 43 61 6c 6c 65 72 20 6d | 75 73 74 20 61 62 73 6f |Caller m|ust abso|
|00004a60| 72 62 20 6f 70 65 6e 69 | 6e 67 20 70 61 72 65 6e |rb openi|ng paren|
|00004a70| 74 68 65 73 69 73 2e 0a | 58 20 2a 0a 58 20 2a 20 |thesis..|X *.X * |
|00004a80| 43 6f 6d 62 69 6e 69 6e | 67 20 70 61 72 65 6e 74 |Combinin|g parent|
|00004a90| 68 65 73 69 73 20 68 61 | 6e 64 6c 69 6e 67 20 77 |hesis ha|ndling w|
|00004aa0| 69 74 68 20 74 68 65 20 | 62 61 73 65 20 6c 65 76 |ith the |base lev|
|00004ab0| 65 6c 20 6f 66 20 72 65 | 67 75 6c 61 72 20 65 78 |el of re|gular ex|
|00004ac0| 70 72 65 73 73 69 6f 6e | 0a 58 20 2a 20 69 73 20 |pression|.X * is |
|00004ad0| 61 20 74 72 69 66 6c 65 | 20 66 6f 72 63 65 64 2c |a trifle| forced,|
|00004ae0| 20 62 75 74 20 74 68 65 | 20 6e 65 65 64 20 74 6f | but the| need to|
|00004af0| 20 74 69 65 20 74 68 65 | 20 74 61 69 6c 73 20 6f | tie the| tails o|
|00004b00| 66 20 74 68 65 20 62 72 | 61 6e 63 68 65 73 20 74 |f the br|anches t|
|00004b10| 6f 20 77 68 61 74 0a 58 | 20 2a 20 66 6f 6c 6c 6f |o what.X| * follo|
|00004b20| 77 73 20 6d 61 6b 65 73 | 20 69 74 20 68 61 72 64 |ws makes| it hard|
|00004b30| 20 74 6f 20 61 76 6f 69 | 64 2e 0a 58 20 2a 2f 0a | to avoi|d..X */.|
|00004b40| 58 73 74 61 74 69 63 20 | 63 68 61 72 20 2a 0a 58 |Xstatic |char *.X|
|00004b50| 72 65 67 28 70 61 72 65 | 6e 2c 20 66 6c 61 67 70 |reg(pare|n, flagp|
|00004b60| 29 0a 58 69 6e 74 20 70 | 61 72 65 6e 3b 09 09 09 |).Xint p|aren;...|
|00004b70| 2f 2a 20 50 61 72 65 6e | 74 68 65 73 69 7a 65 64 |/* Paren|thesized|
|00004b80| 3f 20 2a 2f 0a 58 69 6e | 74 20 2a 66 6c 61 67 70 |? */.Xin|t *flagp|
|00004b90| 3b 0a 58 7b 0a 58 09 72 | 65 67 69 73 74 65 72 20 |;.X{.X.r|egister |
|00004ba0| 63 68 61 72 20 2a 72 65 | 74 3b 0a 58 09 72 65 67 |char *re|t;.X.reg|
|00004bb0| 69 73 74 65 72 20 63 68 | 61 72 20 2a 62 72 3b 0a |ister ch|ar *br;.|
|00004bc0| 58 09 72 65 67 69 73 74 | 65 72 20 63 68 61 72 20 |X.regist|er char |
|00004bd0| 2a 65 6e 64 65 72 3b 0a | 58 09 72 65 67 69 73 74 |*ender;.|X.regist|
|00004be0| 65 72 20 69 6e 74 20 70 | 61 72 6e 6f 3b 0a 58 09 |er int p|arno;.X.|
|00004bf0| 69 6e 74 20 66 6c 61 67 | 73 3b 0a 58 0a 58 09 2a |int flag|s;.X.X.*|
|00004c00| 66 6c 61 67 70 20 3d 20 | 48 41 53 57 49 44 54 48 |flagp = |HASWIDTH|
|00004c10| 3b 09 2f 2a 20 54 65 6e | 74 61 74 69 76 65 6c 79 |;./* Ten|tatively|
|00004c20| 2e 20 2a 2f 0a 58 0a 58 | 09 2f 2a 20 4d 61 6b 65 |. */.X.X|./* Make|
|00004c30| 20 61 6e 20 4f 50 45 4e | 20 6e 6f 64 65 2c 20 69 | an OPEN| node, i|
|00004c40| 66 20 70 61 72 65 6e 74 | 68 65 73 69 7a 65 64 2e |f parent|hesized.|
|00004c50| 20 2a 2f 0a 58 09 69 66 | 20 28 70 61 72 65 6e 29 | */.X.if| (paren)|
|00004c60| 20 7b 0a 58 09 09 69 66 | 20 28 72 65 67 6e 70 61 | {.X..if| (regnpa|
|00004c70| 72 20 3e 3d 20 4e 53 55 | 42 45 58 50 29 0a 58 09 |r >= NSU|BEXP).X.|
|00004c80| 09 09 46 41 49 4c 28 22 | 74 6f 6f 20 6d 61 6e 79 |..FAIL("|too many|
|00004c90| 20 28 29 22 29 3b 0a 58 | 09 09 70 61 72 6e 6f 20 | ()");.X|..parno |
|00004ca0| 3d 20 72 65 67 6e 70 61 | 72 3b 0a 58 09 09 72 65 |= regnpa|r;.X..re|
|00004cb0| 67 6e 70 61 72 2b 2b 3b | 0a 58 09 09 72 65 74 20 |gnpar++;|.X..ret |
|00004cc0| 3d 20 72 65 67 6e 6f 64 | 65 28 4f 50 45 4e 2b 70 |= regnod|e(OPEN+p|
|00004cd0| 61 72 6e 6f 29 3b 0a 58 | 09 7d 20 65 6c 73 65 0a |arno);.X|.} else.|
|00004ce0| 58 09 09 72 65 74 20 3d | 20 4e 55 4c 4c 3b 0a 58 |X..ret =| NULL;.X|
|00004cf0| 0a 58 09 2f 2a 20 50 69 | 63 6b 20 75 70 20 74 68 |.X./* Pi|ck up th|
|00004d00| 65 20 62 72 61 6e 63 68 | 65 73 2c 20 6c 69 6e 6b |e branch|es, link|
|00004d10| 69 6e 67 20 74 68 65 6d | 20 74 6f 67 65 74 68 65 |ing them| togethe|
|00004d20| 72 2e 20 2a 2f 0a 58 09 | 62 72 20 3d 20 72 65 67 |r. */.X.|br = reg|
|00004d30| 62 72 61 6e 63 68 28 26 | 66 6c 61 67 73 29 3b 0a |branch(&|flags);.|
|00004d40| 58 09 69 66 20 28 62 72 | 20 3d 3d 20 4e 55 4c 4c |X.if (br| == NULL|
|00004d50| 29 0a 58 09 09 72 65 74 | 75 72 6e 28 4e 55 4c 4c |).X..ret|urn(NULL|
|00004d60| 29 3b 0a 58 09 69 66 20 | 28 72 65 74 20 21 3d 20 |);.X.if |(ret != |
|00004d70| 4e 55 4c 4c 29 0a 58 09 | 09 72 65 67 74 61 69 6c |NULL).X.|.regtail|
|00004d80| 28 72 65 74 2c 20 62 72 | 29 3b 09 2f 2a 20 4f 50 |(ret, br|);./* OP|
|00004d90| 45 4e 20 2d 3e 20 66 69 | 72 73 74 2e 20 2a 2f 0a |EN -> fi|rst. */.|
|00004da0| 58 09 65 6c 73 65 0a 58 | 09 09 72 65 74 20 3d 20 |X.else.X|..ret = |
|00004db0| 62 72 3b 0a 58 09 69 66 | 20 28 21 28 66 6c 61 67 |br;.X.if| (!(flag|
|00004dc0| 73 26 48 41 53 57 49 44 | 54 48 29 29 0a 58 09 09 |s&HASWID|TH)).X..|
|00004dd0| 2a 66 6c 61 67 70 20 26 | 3d 20 7e 48 41 53 57 49 |*flagp &|= ~HASWI|
|00004de0| 44 54 48 3b 0a 58 09 2a | 66 6c 61 67 70 20 7c 3d |DTH;.X.*|flagp |=|
|00004df0| 20 66 6c 61 67 73 26 53 | 50 53 54 41 52 54 3b 0a | flags&S|PSTART;.|
|00004e00| 58 09 77 68 69 6c 65 20 | 28 2a 72 65 67 70 61 72 |X.while |(*regpar|
|00004e10| 73 65 20 3d 3d 20 27 7c | 27 29 20 7b 0a 58 09 09 |se == '||') {.X..|
|00004e20| 72 65 67 70 61 72 73 65 | 2b 2b 3b 0a 58 09 09 62 |regparse|++;.X..b|
|00004e30| 72 20 3d 20 72 65 67 62 | 72 61 6e 63 68 28 26 66 |r = regb|ranch(&f|
|00004e40| 6c 61 67 73 29 3b 0a 58 | 09 09 69 66 20 28 62 72 |lags);.X|..if (br|
|00004e50| 20 3d 3d 20 4e 55 4c 4c | 29 0a 58 09 09 09 72 65 | == NULL|).X...re|
|00004e60| 74 75 72 6e 28 4e 55 4c | 4c 29 3b 0a 58 09 09 72 |turn(NUL|L);.X..r|
|00004e70| 65 67 74 61 69 6c 28 72 | 65 74 2c 20 62 72 29 3b |egtail(r|et, br);|
|00004e80| 09 2f 2a 20 42 52 41 4e | 43 48 20 2d 3e 20 42 52 |./* BRAN|CH -> BR|
|00004e90| 41 4e 43 48 2e 20 2a 2f | 0a 58 09 09 69 66 20 28 |ANCH. */|.X..if (|
|00004ea0| 21 28 66 6c 61 67 73 26 | 48 41 53 57 49 44 54 48 |!(flags&|HASWIDTH|
|00004eb0| 29 29 0a 58 09 09 09 2a | 66 6c 61 67 70 20 26 3d |)).X...*|flagp &=|
|00004ec0| 20 7e 48 41 53 57 49 44 | 54 48 3b 0a 58 09 09 2a | ~HASWID|TH;.X..*|
|00004ed0| 66 6c 61 67 70 20 7c 3d | 20 66 6c 61 67 73 26 53 |flagp |=| flags&S|
|00004ee0| 50 53 54 41 52 54 3b 0a | 58 09 7d 0a 58 0a 58 09 |PSTART;.|X.}.X.X.|
|00004ef0| 2f 2a 20 4d 61 6b 65 20 | 61 20 63 6c 6f 73 69 6e |/* Make |a closin|
|00004f00| 67 20 6e 6f 64 65 2c 20 | 61 6e 64 20 68 6f 6f 6b |g node, |and hook|
|00004f10| 20 69 74 20 6f 6e 20 74 | 68 65 20 65 6e 64 2e 20 | it on t|he end. |
|00004f20| 2a 2f 0a 58 09 65 6e 64 | 65 72 20 3d 20 72 65 67 |*/.X.end|er = reg|
|00004f30| 6e 6f 64 65 28 28 70 61 | 72 65 6e 29 20 3f 20 43 |node((pa|ren) ? C|
|00004f40| 4c 4f 53 45 2b 70 61 72 | 6e 6f 20 3a 20 45 4e 44 |LOSE+par|no : END|
|00004f50| 29 3b 09 0a 58 09 72 65 | 67 74 61 69 6c 28 72 65 |);..X.re|gtail(re|
|00004f60| 74 2c 20 65 6e 64 65 72 | 29 3b 0a 58 0a 58 09 2f |t, ender|);.X.X./|
|00004f70| 2a 20 48 6f 6f 6b 20 74 | 68 65 20 74 61 69 6c 73 |* Hook t|he tails|
|00004f80| 20 6f 66 20 74 68 65 20 | 62 72 61 6e 63 68 65 73 | of the |branches|
|00004f90| 20 74 6f 20 74 68 65 20 | 63 6c 6f 73 69 6e 67 20 | to the |closing |
|00004fa0| 6e 6f 64 65 2e 20 2a 2f | 0a 58 09 66 6f 72 20 28 |node. */|.X.for (|
|00004fb0| 62 72 20 3d 20 72 65 74 | 3b 20 62 72 20 21 3d 20 |br = ret|; br != |
|00004fc0| 4e 55 4c 4c 3b 20 62 72 | 20 3d 20 72 65 67 6e 65 |NULL; br| = regne|
|00004fd0| 78 74 28 62 72 29 29 0a | 58 09 09 72 65 67 6f 70 |xt(br)).|X..regop|
|00004fe0| 74 61 69 6c 28 62 72 2c | 20 65 6e 64 65 72 29 3b |tail(br,| ender);|
|00004ff0| 0a 58 0a 58 09 2f 2a 20 | 43 68 65 63 6b 20 66 6f |.X.X./* |Check fo|
|00005000| 72 20 70 72 6f 70 65 72 | 20 74 65 72 6d 69 6e 61 |r proper| termina|
|00005010| 74 69 6f 6e 2e 20 2a 2f | 0a 58 09 69 66 20 28 70 |tion. */|.X.if (p|
|00005020| 61 72 65 6e 20 26 26 20 | 2a 72 65 67 70 61 72 73 |aren && |*regpars|
|00005030| 65 2b 2b 20 21 3d 20 27 | 29 27 29 20 7b 0a 58 09 |e++ != '|)') {.X.|
|00005040| 09 46 41 49 4c 28 22 75 | 6e 6d 61 74 63 68 65 64 |.FAIL("u|nmatched|
|00005050| 20 28 29 22 29 3b 0a 58 | 09 7d 20 65 6c 73 65 20 | ()");.X|.} else |
|00005060| 69 66 20 28 21 70 61 72 | 65 6e 20 26 26 20 2a 72 |if (!par|en && *r|
|00005070| 65 67 70 61 72 73 65 20 | 21 3d 20 27 5c 30 27 29 |egparse |!= '\0')|
|00005080| 20 7b 0a 58 09 09 69 66 | 20 28 2a 72 65 67 70 61 | {.X..if| (*regpa|
|00005090| 72 73 65 20 3d 3d 20 27 | 29 27 29 20 7b 0a 58 09 |rse == '|)') {.X.|
|000050a0| 09 09 46 41 49 4c 28 22 | 75 6e 6d 61 74 63 68 65 |..FAIL("|unmatche|
|000050b0| 64 20 28 29 22 29 3b 0a | 58 09 09 7d 20 65 6c 73 |d ()");.|X..} els|
|000050c0| 65 0a 58 09 09 09 46 41 | 49 4c 28 22 6a 75 6e 6b |e.X...FA|IL("junk|
|000050d0| 20 6f 6e 20 65 6e 64 22 | 29 3b 09 2f 2a 20 22 43 | on end"|);./* "C|
|000050e0| 61 6e 27 74 20 68 61 70 | 70 65 6e 22 2e 20 2a 2f |an't hap|pen". */|
|000050f0| 0a 58 09 09 2f 2a 20 4e | 4f 54 52 45 41 43 48 45 |.X../* N|OTREACHE|
|00005100| 44 20 2a 2f 0a 58 09 7d | 0a 58 0a 58 09 72 65 74 |D */.X.}|.X.X.ret|
|00005110| 75 72 6e 28 72 65 74 29 | 3b 0a 58 7d 0a 58 0a 58 |urn(ret)|;.X}.X.X|
|00005120| 2f 2a 0a 58 20 2d 20 72 | 65 67 62 72 61 6e 63 68 |/*.X - r|egbranch|
|00005130| 20 2d 20 6f 6e 65 20 61 | 6c 74 65 72 6e 61 74 69 | - one a|lternati|
|00005140| 76 65 20 6f 66 20 61 6e | 20 7c 20 6f 70 65 72 61 |ve of an| | opera|
|00005150| 74 6f 72 0a 58 20 2a 0a | 58 20 2a 20 49 6d 70 6c |tor.X *.|X * Impl|
|00005160| 65 6d 65 6e 74 73 20 74 | 68 65 20 63 6f 6e 63 61 |ements t|he conca|
|00005170| 74 65 6e 61 74 69 6f 6e | 20 6f 70 65 72 61 74 6f |tenation| operato|
|00005180| 72 2e 0a 58 20 2a 2f 0a | 58 73 74 61 74 69 63 20 |r..X */.|Xstatic |
|00005190| 63 68 61 72 20 2a 0a 58 | 72 65 67 62 72 61 6e 63 |char *.X|regbranc|
|000051a0| 68 28 66 6c 61 67 70 29 | 0a 58 69 6e 74 20 2a 66 |h(flagp)|.Xint *f|
|000051b0| 6c 61 67 70 3b 0a 58 7b | 0a 58 09 72 65 67 69 73 |lagp;.X{|.X.regis|
|000051c0| 74 65 72 20 63 68 61 72 | 20 2a 72 65 74 3b 0a 58 |ter char| *ret;.X|
|000051d0| 09 72 65 67 69 73 74 65 | 72 20 63 68 61 72 20 2a |.registe|r char *|
|000051e0| 63 68 61 69 6e 3b 0a 58 | 09 72 65 67 69 73 74 65 |chain;.X|.registe|
|000051f0| 72 20 63 68 61 72 20 2a | 6c 61 74 65 73 74 3b 0a |r char *|latest;.|
|00005200| 58 09 69 6e 74 20 66 6c | 61 67 73 3b 0a 58 0a 58 |X.int fl|ags;.X.X|
|00005210| 09 2a 66 6c 61 67 70 20 | 3d 20 57 4f 52 53 54 3b |.*flagp |= WORST;|
|00005220| 09 09 2f 2a 20 54 65 6e | 74 61 74 69 76 65 6c 79 |../* Ten|tatively|
|00005230| 2e 20 2a 2f 0a 58 0a 58 | 09 72 65 74 20 3d 20 72 |. */.X.X|.ret = r|
|00005240| 65 67 6e 6f 64 65 28 42 | 52 41 4e 43 48 29 3b 0a |egnode(B|RANCH);.|
|00005250| 58 09 63 68 61 69 6e 20 | 3d 20 4e 55 4c 4c 3b 0a |X.chain |= NULL;.|
|00005260| 58 09 77 68 69 6c 65 20 | 28 2a 72 65 67 70 61 72 |X.while |(*regpar|
|00005270| 73 65 20 21 3d 20 27 5c | 30 27 20 26 26 20 2a 72 |se != '\|0' && *r|
|00005280| 65 67 70 61 72 73 65 20 | 21 3d 20 27 7c 27 20 26 |egparse |!= '|' &|
|00005290| 26 20 2a 72 65 67 70 61 | 72 73 65 20 21 3d 20 27 |& *regpa|rse != '|
|000052a0| 29 27 29 20 7b 0a 58 09 | 09 6c 61 74 65 73 74 20 |)') {.X.|.latest |
|000052b0| 3d 20 72 65 67 70 69 65 | 63 65 28 26 66 6c 61 67 |= regpie|ce(&flag|
|000052c0| 73 29 3b 0a 58 09 09 69 | 66 20 28 6c 61 74 65 73 |s);.X..i|f (lates|
|000052d0| 74 20 3d 3d 20 4e 55 4c | 4c 29 0a 58 09 09 09 72 |t == NUL|L).X...r|
|000052e0| 65 74 75 72 6e 28 4e 55 | 4c 4c 29 3b 0a 58 09 09 |eturn(NU|LL);.X..|
|000052f0| 2a 66 6c 61 67 70 20 7c | 3d 20 66 6c 61 67 73 26 |*flagp ||= flags&|
|00005300| 48 41 53 57 49 44 54 48 | 3b 0a 58 09 09 69 66 20 |HASWIDTH|;.X..if |
|00005310| 28 63 68 61 69 6e 20 3d | 3d 20 4e 55 4c 4c 29 09 |(chain =|= NULL).|
|00005320| 2f 2a 20 46 69 72 73 74 | 20 70 69 65 63 65 2e 20 |/* First| piece. |
|00005330| 2a 2f 0a 58 09 09 09 2a | 66 6c 61 67 70 20 7c 3d |*/.X...*|flagp |=|
|00005340| 20 66 6c 61 67 73 26 53 | 50 53 54 41 52 54 3b 0a | flags&S|PSTART;.|
|00005350| 58 09 09 65 6c 73 65 0a | 58 09 09 09 72 65 67 74 |X..else.|X...regt|
|00005360| 61 69 6c 28 63 68 61 69 | 6e 2c 20 6c 61 74 65 73 |ail(chai|n, lates|
|00005370| 74 29 3b 0a 58 09 09 63 | 68 61 69 6e 20 3d 20 6c |t);.X..c|hain = l|
|00005380| 61 74 65 73 74 3b 0a 58 | 09 7d 0a 58 09 69 66 20 |atest;.X|.}.X.if |
|00005390| 28 63 68 61 69 6e 20 3d | 3d 20 4e 55 4c 4c 29 09 |(chain =|= NULL).|
|000053a0| 2f 2a 20 4c 6f 6f 70 20 | 72 61 6e 20 7a 65 72 6f |/* Loop |ran zero|
|000053b0| 20 74 69 6d 65 73 2e 20 | 2a 2f 0a 58 09 09 28 76 | times. |*/.X..(v|
|000053c0| 6f 69 64 29 20 72 65 67 | 6e 6f 64 65 28 4e 4f 54 |oid) reg|node(NOT|
|000053d0| 48 49 4e 47 29 3b 0a 58 | 0a 58 09 72 65 74 75 72 |HING);.X|.X.retur|
|000053e0| 6e 28 72 65 74 29 3b 0a | 58 7d 0a 58 0a 58 2f 2a |n(ret);.|X}.X.X/*|
|000053f0| 0a 58 20 2d 20 72 65 67 | 70 69 65 63 65 20 2d 20 |.X - reg|piece - |
|00005400| 73 6f 6d 65 74 68 69 6e | 67 20 66 6f 6c 6c 6f 77 |somethin|g follow|
|00005410| 65 64 20 62 79 20 70 6f | 73 73 69 62 6c 65 20 5b |ed by po|ssible [|
|00005420| 2a 2b 3f 5d 0a 58 20 2a | 0a 58 20 2a 20 4e 6f 74 |*+?].X *|.X * Not|
|00005430| 65 20 74 68 61 74 20 74 | 68 65 20 62 72 61 6e 63 |e that t|he branc|
|00005440| 68 69 6e 67 20 63 6f 64 | 65 20 73 65 71 75 65 6e |hing cod|e sequen|
|00005450| 63 65 73 20 75 73 65 64 | 20 66 6f 72 20 3f 20 61 |ces used| for ? a|
|00005460| 6e 64 20 74 68 65 20 67 | 65 6e 65 72 61 6c 20 63 |nd the g|eneral c|
|00005470| 61 73 65 73 0a 58 20 2a | 20 6f 66 20 2a 20 61 6e |ases.X *| of * an|
|00005480| 64 20 2b 20 61 72 65 20 | 73 6f 6d 65 77 68 61 74 |d + are |somewhat|
|00005490| 20 6f 70 74 69 6d 69 7a | 65 64 3a 20 20 74 68 65 | optimiz|ed: the|
|000054a0| 79 20 75 73 65 20 74 68 | 65 20 73 61 6d 65 20 4e |y use th|e same N|
|000054b0| 4f 54 48 49 4e 47 20 6e | 6f 64 65 20 61 73 0a 58 |OTHING n|ode as.X|
|000054c0| 20 2a 20 62 6f 74 68 20 | 74 68 65 20 65 6e 64 6d | * both |the endm|
|000054d0| 61 72 6b 65 72 20 66 6f | 72 20 74 68 65 69 72 20 |arker fo|r their |
|000054e0| 62 72 61 6e 63 68 20 6c | 69 73 74 20 61 6e 64 20 |branch l|ist and |
|000054f0| 74 68 65 20 62 6f 64 79 | 20 6f 66 20 74 68 65 20 |the body| of the |
|00005500| 6c 61 73 74 20 62 72 61 | 6e 63 68 2e 0a 58 20 2a |last bra|nch..X *|
|00005510| 20 49 74 20 6d 69 67 68 | 74 20 73 65 65 6d 20 74 | It migh|t seem t|
|00005520| 68 61 74 20 74 68 69 73 | 20 6e 6f 64 65 20 63 6f |hat this| node co|
|00005530| 75 6c 64 20 62 65 20 64 | 69 73 70 65 6e 73 65 64 |uld be d|ispensed|
|00005540| 20 77 69 74 68 20 65 6e | 74 69 72 65 6c 79 2c 20 | with en|tirely, |
|00005550| 62 75 74 20 74 68 65 0a | 58 20 2a 20 65 6e 64 6d |but the.|X * endm|
|00005560| 61 72 6b 65 72 20 72 6f | 6c 65 20 69 73 20 6e 6f |arker ro|le is no|
|00005570| 74 20 72 65 64 75 6e 64 | 61 6e 74 2e 0a 58 20 2a |t redund|ant..X *|
|00005580| 2f 0a 58 73 74 61 74 69 | 63 20 63 68 61 72 20 2a |/.Xstati|c char *|
|00005590| 0a 58 72 65 67 70 69 65 | 63 65 28 66 6c 61 67 70 |.Xregpie|ce(flagp|
|000055a0| 29 0a 58 69 6e 74 20 2a | 66 6c 61 67 70 3b 0a 58 |).Xint *|flagp;.X|
|000055b0| 7b 0a 58 09 72 65 67 69 | 73 74 65 72 20 63 68 61 |{.X.regi|ster cha|
|000055c0| 72 20 2a 72 65 74 3b 0a | 58 09 72 65 67 69 73 74 |r *ret;.|X.regist|
|000055d0| 65 72 20 63 68 61 72 20 | 6f 70 3b 0a 58 09 72 65 |er char |op;.X.re|
|000055e0| 67 69 73 74 65 72 20 63 | 68 61 72 20 2a 6e 65 78 |gister c|har *nex|
|000055f0| 74 3b 0a 58 09 69 6e 74 | 20 66 6c 61 67 73 3b 0a |t;.X.int| flags;.|
|00005600| 58 0a 58 09 72 65 74 20 | 3d 20 72 65 67 61 74 6f |X.X.ret |= regato|
|00005610| 6d 28 26 66 6c 61 67 73 | 29 3b 0a 58 09 69 66 20 |m(&flags|);.X.if |
|00005620| 28 72 65 74 20 3d 3d 20 | 4e 55 4c 4c 29 0a 58 09 |(ret == |NULL).X.|
|00005630| 09 72 65 74 75 72 6e 28 | 4e 55 4c 4c 29 3b 0a 58 |.return(|NULL);.X|
|00005640| 0a 58 09 6f 70 20 3d 20 | 2a 72 65 67 70 61 72 73 |.X.op = |*regpars|
|00005650| 65 3b 0a 58 09 69 66 20 | 28 21 49 53 4d 55 4c 54 |e;.X.if |(!ISMULT|
|00005660| 28 6f 70 29 29 20 7b 0a | 58 09 09 2a 66 6c 61 67 |(op)) {.|X..*flag|
|00005670| 70 20 3d 20 66 6c 61 67 | 73 3b 0a 58 09 09 72 65 |p = flag|s;.X..re|
|00005680| 74 75 72 6e 28 72 65 74 | 29 3b 0a 58 09 7d 0a 58 |turn(ret|);.X.}.X|
|00005690| 0a 58 09 69 66 20 28 21 | 28 66 6c 61 67 73 26 48 |.X.if (!|(flags&H|
|000056a0| 41 53 57 49 44 54 48 29 | 20 26 26 20 6f 70 20 21 |ASWIDTH)| && op !|
|000056b0| 3d 20 27 3f 27 29 0a 58 | 09 09 46 41 49 4c 28 22 |= '?').X|..FAIL("|
|000056c0| 2a 2b 20 6f 70 65 72 61 | 6e 64 20 63 6f 75 6c 64 |*+ opera|nd could|
|000056d0| 20 62 65 20 65 6d 70 74 | 79 22 29 3b 0a 58 09 2a | be empt|y");.X.*|
|000056e0| 66 6c 61 67 70 20 3d 20 | 28 6f 70 20 21 3d 20 27 |flagp = |(op != '|
|000056f0| 2b 27 29 20 3f 20 28 57 | 4f 52 53 54 7c 53 50 53 |+') ? (W|ORST|SPS|
|00005700| 54 41 52 54 29 20 3a 20 | 28 57 4f 52 53 54 7c 48 |TART) : |(WORST|H|
|00005710| 41 53 57 49 44 54 48 29 | 3b 0a 58 0a 58 09 69 66 |ASWIDTH)|;.X.X.if|
|00005720| 20 28 6f 70 20 3d 3d 20 | 27 2a 27 20 26 26 20 28 | (op == |'*' && (|
|00005730| 66 6c 61 67 73 26 53 49 | 4d 50 4c 45 29 29 0a 58 |flags&SI|MPLE)).X|
|00005740| 09 09 72 65 67 69 6e 73 | 65 72 74 28 53 54 41 52 |..regins|ert(STAR|
|00005750| 2c 20 72 65 74 29 3b 0a | 58 09 65 6c 73 65 20 69 |, ret);.|X.else i|
|00005760| 66 20 28 6f 70 20 3d 3d | 20 27 2a 27 29 20 7b 0a |f (op ==| '*') {.|
|00005770| 58 09 09 2f 2a 20 45 6d | 69 74 20 78 2a 20 61 73 |X../* Em|it x* as|
|00005780| 20 28 78 26 7c 29 2c 20 | 77 68 65 72 65 20 26 20 | (x&|), |where & |
|00005790| 6d 65 61 6e 73 20 22 73 | 65 6c 66 22 2e 20 2a 2f |means "s|elf". */|
|000057a0| 0a 58 09 09 72 65 67 69 | 6e 73 65 72 74 28 42 52 |.X..regi|nsert(BR|
|000057b0| 41 4e 43 48 2c 20 72 65 | 74 29 3b 09 09 09 2f 2a |ANCH, re|t);.../*|
|000057c0| 20 45 69 74 68 65 72 20 | 78 20 2a 2f 0a 58 09 09 | Either |x */.X..|
|000057d0| 72 65 67 6f 70 74 61 69 | 6c 28 72 65 74 2c 20 72 |regoptai|l(ret, r|
|000057e0| 65 67 6e 6f 64 65 28 42 | 41 43 4b 29 29 3b 09 09 |egnode(B|ACK));..|
|000057f0| 2f 2a 20 61 6e 64 20 6c | 6f 6f 70 20 2a 2f 0a 58 |/* and l|oop */.X|
|00005800| 09 09 72 65 67 6f 70 74 | 61 69 6c 28 72 65 74 2c |..regopt|ail(ret,|
|00005810| 20 72 65 74 29 3b 09 09 | 09 2f 2a 20 62 61 63 6b | ret);..|./* back|
|00005820| 20 2a 2f 0a 58 09 09 72 | 65 67 74 61 69 6c 28 72 | */.X..r|egtail(r|
|00005830| 65 74 2c 20 72 65 67 6e | 6f 64 65 28 42 52 41 4e |et, regn|ode(BRAN|
|00005840| 43 48 29 29 3b 09 09 2f | 2a 20 6f 72 20 2a 2f 0a |CH));../|* or */.|
|00005850| 58 09 09 72 65 67 74 61 | 69 6c 28 72 65 74 2c 20 |X..regta|il(ret, |
|00005860| 72 65 67 6e 6f 64 65 28 | 4e 4f 54 48 49 4e 47 29 |regnode(|NOTHING)|
|00005870| 29 3b 09 09 2f 2a 20 6e | 75 6c 6c 2e 20 2a 2f 0a |);../* n|ull. */.|
|00005880| 58 09 7d 20 65 6c 73 65 | 20 69 66 20 28 6f 70 20 |X.} else| if (op |
|00005890| 3d 3d 20 27 2b 27 20 26 | 26 20 28 66 6c 61 67 73 |== '+' &|& (flags|
|000058a0| 26 53 49 4d 50 4c 45 29 | 29 0a 58 09 09 72 65 67 |&SIMPLE)|).X..reg|
|000058b0| 69 6e 73 65 72 74 28 50 | 4c 55 53 2c 20 72 65 74 |insert(P|LUS, ret|
|000058c0| 29 3b 0a 58 09 65 6c 73 | 65 20 69 66 20 28 6f 70 |);.X.els|e if (op|
|000058d0| 20 3d 3d 20 27 2b 27 29 | 20 7b 0a 58 09 09 2f 2a | == '+')| {.X../*|
|000058e0| 20 45 6d 69 74 20 78 2b | 20 61 73 20 78 28 26 7c | Emit x+| as x(&||
|000058f0| 29 2c 20 77 68 65 72 65 | 20 26 20 6d 65 61 6e 73 |), where| & means|
|00005900| 20 22 73 65 6c 66 22 2e | 20 2a 2f 0a 58 09 09 6e | "self".| */.X..n|
|00005910| 65 78 74 20 3d 20 72 65 | 67 6e 6f 64 65 28 42 52 |ext = re|gnode(BR|
|00005920| 41 4e 43 48 29 3b 09 09 | 09 2f 2a 20 45 69 74 68 |ANCH);..|./* Eith|
|00005930| 65 72 20 2a 2f 0a 58 09 | 09 72 65 67 74 61 69 6c |er */.X.|.regtail|
|00005940| 28 72 65 74 2c 20 6e 65 | 78 74 29 3b 0a 58 09 09 |(ret, ne|xt);.X..|
|00005950| 72 65 67 74 61 69 6c 28 | 72 65 67 6e 6f 64 65 28 |regtail(|regnode(|
|00005960| 42 41 43 4b 29 2c 20 72 | 65 74 29 3b 09 09 2f 2a |BACK), r|et);../*|
|00005970| 20 6c 6f 6f 70 20 62 61 | 63 6b 20 2a 2f 0a 58 09 | loop ba|ck */.X.|
|00005980| 09 72 65 67 74 61 69 6c | 28 6e 65 78 74 2c 20 72 |.regtail|(next, r|
|00005990| 65 67 6e 6f 64 65 28 42 | 52 41 4e 43 48 29 29 3b |egnode(B|RANCH));|
|000059a0| 09 09 2f 2a 20 6f 72 20 | 2a 2f 0a 58 09 09 72 65 |../* or |*/.X..re|
|000059b0| 67 74 61 69 6c 28 72 65 | 74 2c 20 72 65 67 6e 6f |gtail(re|t, regno|
|000059c0| 64 65 28 4e 4f 54 48 49 | 4e 47 29 29 3b 09 09 2f |de(NOTHI|NG));../|
|000059d0| 2a 20 6e 75 6c 6c 2e 20 | 2a 2f 0a 58 09 7d 20 65 |* null. |*/.X.} e|
|000059e0| 6c 73 65 20 69 66 20 28 | 6f 70 20 3d 3d 20 27 3f |lse if (|op == '?|
|000059f0| 27 29 20 7b 0a 58 09 09 | 2f 2a 20 45 6d 69 74 20 |') {.X..|/* Emit |
|00005a00| 78 3f 20 61 73 20 28 78 | 7c 29 20 2a 2f 0a 58 09 |x? as (x||) */.X.|
|00005a10| 09 72 65 67 69 6e 73 65 | 72 74 28 42 52 41 4e 43 |.reginse|rt(BRANC|
|00005a20| 48 2c 20 72 65 74 29 3b | 09 09 09 2f 2a 20 45 69 |H, ret);|.../* Ei|
|00005a30| 74 68 65 72 20 78 20 2a | 2f 0a 58 09 09 72 65 67 |ther x *|/.X..reg|
|00005a40| 74 61 69 6c 28 72 65 74 | 2c 20 72 65 67 6e 6f 64 |tail(ret|, regnod|
|00005a50| 65 28 42 52 41 4e 43 48 | 29 29 3b 09 09 2f 2a 20 |e(BRANCH|));../* |
|00005a60| 6f 72 20 2a 2f 0a 58 09 | 09 6e 65 78 74 20 3d 20 |or */.X.|.next = |
|00005a70| 72 65 67 6e 6f 64 65 28 | 4e 4f 54 48 49 4e 47 29 |regnode(|NOTHING)|
|00005a80| 3b 09 09 2f 2a 20 6e 75 | 6c 6c 2e 20 2a 2f 0a 58 |;../* nu|ll. */.X|
|00005a90| 09 09 72 65 67 74 61 69 | 6c 28 72 65 74 2c 20 6e |..regtai|l(ret, n|
|00005aa0| 65 78 74 29 3b 0a 58 09 | 09 72 65 67 6f 70 74 61 |ext);.X.|.regopta|
|00005ab0| 69 6c 28 72 65 74 2c 20 | 6e 65 78 74 29 3b 0a 58 |il(ret, |next);.X|
|00005ac0| 09 7d 0a 58 09 72 65 67 | 70 61 72 73 65 2b 2b 3b |.}.X.reg|parse++;|
|00005ad0| 0a 58 09 69 66 20 28 49 | 53 4d 55 4c 54 28 2a 72 |.X.if (I|SMULT(*r|
|00005ae0| 65 67 70 61 72 73 65 29 | 29 0a 58 09 09 46 41 49 |egparse)|).X..FAI|
|00005af0| 4c 28 22 6e 65 73 74 65 | 64 20 2a 3f 2b 22 29 3b |L("neste|d *?+");|
|00005b00| 0a 58 0a 58 09 72 65 74 | 75 72 6e 28 72 65 74 29 |.X.X.ret|urn(ret)|
|00005b10| 3b 0a 58 7d 0a 58 0a 58 | 2f 2a 0a 58 20 2d 20 72 |;.X}.X.X|/*.X - r|
|00005b20| 65 67 61 74 6f 6d 20 2d | 20 74 68 65 20 6c 6f 77 |egatom -| the low|
|00005b30| 65 73 74 20 6c 65 76 65 | 6c 0a 58 20 2a 0a 58 20 |est leve|l.X *.X |
|00005b40| 2a 20 4f 70 74 69 6d 69 | 7a 61 74 69 6f 6e 3a 20 |* Optimi|zation: |
|00005b50| 20 67 6f 62 62 6c 65 73 | 20 61 6e 20 65 6e 74 69 | gobbles| an enti|
|00005b60| 72 65 20 73 65 71 75 65 | 6e 63 65 20 6f 66 20 6f |re seque|nce of o|
|00005b70| 72 64 69 6e 61 72 79 20 | 63 68 61 72 61 63 74 65 |rdinary |characte|
|00005b80| 72 73 20 73 6f 20 74 68 | 61 74 0a 58 20 2a 20 69 |rs so th|at.X * i|
|00005b90| 74 20 63 61 6e 20 74 75 | 72 6e 20 74 68 65 6d 20 |t can tu|rn them |
|00005ba0| 69 6e 74 6f 20 61 20 73 | 69 6e 67 6c 65 20 6e 6f |into a s|ingle no|
|00005bb0| 64 65 2c 20 77 68 69 63 | 68 20 69 73 20 73 6d 61 |de, whic|h is sma|
|00005bc0| 6c 6c 65 72 20 74 6f 20 | 73 74 6f 72 65 20 61 6e |ller to |store an|
|00005bd0| 64 0a 58 20 2a 20 66 61 | 73 74 65 72 20 74 6f 20 |d.X * fa|ster to |
|00005be0| 72 75 6e 2e 20 20 42 61 | 63 6b 73 6c 61 73 68 65 |run. Ba|ckslashe|
|00005bf0| 64 20 63 68 61 72 61 63 | 74 65 72 73 20 61 72 65 |d charac|ters are|
|00005c00| 20 65 78 63 65 70 74 69 | 6f 6e 73 2c 20 65 61 63 | excepti|ons, eac|
|00005c10| 68 20 62 65 63 6f 6d 69 | 6e 67 20 61 0a 58 20 2a |h becomi|ng a.X *|
|00005c20| 20 73 65 70 61 72 61 74 | 65 20 6e 6f 64 65 3b 20 | separat|e node; |
|00005c30| 74 68 65 20 63 6f 64 65 | 20 69 73 20 73 69 6d 70 |the code| is simp|
|00005c40| 6c 65 72 20 74 68 61 74 | 20 77 61 79 20 61 6e 64 |ler that| way and|
|00005c50| 20 69 74 27 73 20 6e 6f | 74 20 77 6f 72 74 68 20 | it's no|t worth |
|00005c60| 66 69 78 69 6e 67 2e 0a | 58 20 2a 2f 0a 58 73 74 |fixing..|X */.Xst|
|00005c70| 61 74 69 63 20 63 68 61 | 72 20 2a 0a 58 72 65 67 |atic cha|r *.Xreg|
|00005c80| 61 74 6f 6d 28 66 6c 61 | 67 70 29 0a 58 69 6e 74 |atom(fla|gp).Xint|
|00005c90| 20 2a 66 6c 61 67 70 3b | 0a 58 7b 0a 58 09 72 65 | *flagp;|.X{.X.re|
|00005ca0| 67 69 73 74 65 72 20 63 | 68 61 72 20 2a 72 65 74 |gister c|har *ret|
|00005cb0| 3b 0a 58 09 69 6e 74 20 | 66 6c 61 67 73 3b 0a 58 |;.X.int |flags;.X|
|00005cc0| 0a 58 09 2a 66 6c 61 67 | 70 20 3d 20 57 4f 52 53 |.X.*flag|p = WORS|
|00005cd0| 54 3b 09 09 2f 2a 20 54 | 65 6e 74 61 74 69 76 65 |T;../* T|entative|
|00005ce0| 6c 79 2e 20 2a 2f 0a 58 | 0a 58 09 73 77 69 74 63 |ly. */.X|.X.switc|
|00005cf0| 68 20 28 2a 72 65 67 70 | 61 72 73 65 2b 2b 29 20 |h (*regp|arse++) |
|00005d00| 7b 0a 58 09 63 61 73 65 | 20 27 5e 27 3a 0a 58 09 |{.X.case| '^':.X.|
|00005d10| 09 72 65 74 20 3d 20 72 | 65 67 6e 6f 64 65 28 42 |.ret = r|egnode(B|
|00005d20| 4f 4c 29 3b 0a 58 09 09 | 62 72 65 61 6b 3b 0a 58 |OL);.X..|break;.X|
|00005d30| 09 63 61 73 65 20 27 24 | 27 3a 0a 58 09 09 72 65 |.case '$|':.X..re|
|00005d40| 74 20 3d 20 72 65 67 6e | 6f 64 65 28 45 4f 4c 29 |t = regn|ode(EOL)|
|00005d50| 3b 0a 58 09 09 62 72 65 | 61 6b 3b 0a 58 09 63 61 |;.X..bre|ak;.X.ca|
|00005d60| 73 65 20 27 2e 27 3a 0a | 58 09 09 72 65 74 20 3d |se '.':.|X..ret =|
|00005d70| 20 72 65 67 6e 6f 64 65 | 28 41 4e 59 29 3b 0a 58 | regnode|(ANY);.X|
|00005d80| 09 09 2a 66 6c 61 67 70 | 20 7c 3d 20 48 41 53 57 |..*flagp| |= HASW|
|00005d90| 49 44 54 48 7c 53 49 4d | 50 4c 45 3b 0a 58 09 09 |IDTH|SIM|PLE;.X..|
|00005da0| 62 72 65 61 6b 3b 0a 58 | 09 63 61 73 65 20 27 5b |break;.X|.case '[|
|00005db0| 27 3a 20 7b 0a 58 09 09 | 09 72 65 67 69 73 74 65 |': {.X..|.registe|
|00005dc0| 72 20 69 6e 74 20 63 6c | 61 73 73 3b 0a 58 09 09 |r int cl|ass;.X..|
|00005dd0| 09 72 65 67 69 73 74 65 | 72 20 69 6e 74 20 63 6c |.registe|r int cl|
|00005de0| 61 73 73 65 6e 64 3b 0a | 58 0a 58 09 09 09 69 66 |assend;.|X.X...if|
|00005df0| 20 28 2a 72 65 67 70 61 | 72 73 65 20 3d 3d 20 27 | (*regpa|rse == '|
|00005e00| 5e 27 29 20 7b 09 2f 2a | 20 43 6f 6d 70 6c 65 6d |^') {./*| Complem|
|00005e10| 65 6e 74 20 6f 66 20 72 | 61 6e 67 65 2e 20 2a 2f |ent of r|ange. */|
|00005e20| 0a 58 09 09 09 09 72 65 | 74 20 3d 20 72 65 67 6e |.X....re|t = regn|
|00005e30| 6f 64 65 28 41 4e 59 42 | 55 54 29 3b 0a 58 09 09 |ode(ANYB|UT);.X..|
|00005e40| 09 09 72 65 67 70 61 72 | 73 65 2b 2b 3b 0a 58 09 |..regpar|se++;.X.|
|00005e50| 09 09 7d 20 65 6c 73 65 | 0a 58 09 09 09 09 72 65 |..} else|.X....re|
|00005e60| 74 20 3d 20 72 65 67 6e | 6f 64 65 28 41 4e 59 4f |t = regn|ode(ANYO|
|00005e70| 46 29 3b 0a 58 09 09 09 | 69 66 20 28 2a 72 65 67 |F);.X...|if (*reg|
|00005e80| 70 61 72 73 65 20 3d 3d | 20 27 5d 27 20 7c 7c 20 |parse ==| ']' || |
|00005e90| 2a 72 65 67 70 61 72 73 | 65 20 3d 3d 20 27 2d 27 |*regpars|e == '-'|
|00005ea0| 29 0a 58 09 09 09 09 72 | 65 67 63 28 2a 72 65 67 |).X....r|egc(*reg|
|00005eb0| 70 61 72 73 65 2b 2b 29 | 3b 0a 58 09 09 09 77 68 |parse++)|;.X...wh|
|00005ec0| 69 6c 65 20 28 2a 72 65 | 67 70 61 72 73 65 20 21 |ile (*re|gparse !|
|00005ed0| 3d 20 27 5c 30 27 20 26 | 26 20 2a 72 65 67 70 61 |= '\0' &|& *regpa|
|00005ee0| 72 73 65 20 21 3d 20 27 | 5d 27 29 20 7b 0a 58 09 |rse != '|]') {.X.|
|00005ef0| 09 09 09 69 66 20 28 2a | 72 65 67 70 61 72 73 65 |...if (*|regparse|
|00005f00| 20 3d 3d 20 27 2d 27 29 | 20 7b 0a 58 09 09 09 09 | == '-')| {.X....|
|00005f10| 09 72 65 67 70 61 72 73 | 65 2b 2b 3b 0a 58 09 09 |.regpars|e++;.X..|
|00005f20| 09 09 09 69 66 20 28 2a | 72 65 67 70 61 72 73 65 |...if (*|regparse|
|00005f30| 20 3d 3d 20 27 5d 27 20 | 7c 7c 20 2a 72 65 67 70 | == ']' ||| *regp|
|00005f40| 61 72 73 65 20 3d 3d 20 | 27 5c 30 27 29 0a 58 09 |arse == |'\0').X.|
|00005f50| 09 09 09 09 09 72 65 67 | 63 28 27 2d 27 29 3b 0a |.....reg|c('-');.|
|00005f60| 58 09 09 09 09 09 65 6c | 73 65 20 7b 0a 58 09 09 |X.....el|se {.X..|
|00005f70| 09 09 09 09 63 6c 61 73 | 73 20 3d 20 55 43 48 41 |....clas|s = UCHA|
|00005f80| 52 41 54 28 72 65 67 70 | 61 72 73 65 2d 32 29 2b |RAT(regp|arse-2)+|
|00005f90| 31 3b 0a 58 09 09 09 09 | 09 09 63 6c 61 73 73 65 |1;.X....|..classe|
|00005fa0| 6e 64 20 3d 20 55 43 48 | 41 52 41 54 28 72 65 67 |nd = UCH|ARAT(reg|
|00005fb0| 70 61 72 73 65 29 3b 0a | 58 09 09 09 09 09 09 69 |parse);.|X......i|
|00005fc0| 66 20 28 63 6c 61 73 73 | 20 3e 20 63 6c 61 73 73 |f (class| > class|
|00005fd0| 65 6e 64 2b 31 29 0a 58 | 09 09 09 09 09 09 09 46 |end+1).X|.......F|
|00005fe0| 41 49 4c 28 22 69 6e 76 | 61 6c 69 64 20 5b 5d 20 |AIL("inv|alid [] |
|00005ff0| 72 61 6e 67 65 22 29 3b | 0a 58 09 09 09 09 09 09 |range");|.X......|
|00006000| 66 6f 72 20 28 3b 20 63 | 6c 61 73 73 20 3c 3d 20 |for (; c|lass <= |
|00006010| 63 6c 61 73 73 65 6e 64 | 3b 20 63 6c 61 73 73 2b |classend|; class+|
|00006020| 2b 29 0a 58 09 09 09 09 | 09 09 09 72 65 67 63 28 |+).X....|...regc(|
|00006030| 63 6c 61 73 73 29 3b 0a | 58 09 09 09 09 09 09 72 |class);.|X......r|
|00006040| 65 67 70 61 72 73 65 2b | 2b 3b 0a 58 09 09 09 09 |egparse+|+;.X....|
|00006050| 09 7d 0a 58 09 09 09 09 | 7d 20 65 6c 73 65 0a 58 |.}.X....|} else.X|
|00006060| 09 09 09 09 09 72 65 67 | 63 28 2a 72 65 67 70 61 |.....reg|c(*regpa|
|00006070| 72 73 65 2b 2b 29 3b 0a | 58 09 09 09 7d 0a 58 09 |rse++);.|X...}.X.|
|00006080| 09 09 72 65 67 63 28 27 | 5c 30 27 29 3b 0a 58 09 |..regc('|\0');.X.|
|00006090| 09 09 69 66 20 28 2a 72 | 65 67 70 61 72 73 65 20 |..if (*r|egparse |
|000060a0| 21 3d 20 27 5d 27 29 0a | 58 09 09 09 09 46 41 49 |!= ']').|X....FAI|
|000060b0| 4c 28 22 75 6e 6d 61 74 | 63 68 65 64 20 5b 5d 22 |L("unmat|ched []"|
|000060c0| 29 3b 0a 58 09 09 09 72 | 65 67 70 61 72 73 65 2b |);.X...r|egparse+|
|000060d0| 2b 3b 0a 58 09 09 09 2a | 66 6c 61 67 70 20 7c 3d |+;.X...*|flagp |=|
|000060e0| 20 48 41 53 57 49 44 54 | 48 7c 53 49 4d 50 4c 45 | HASWIDT|H|SIMPLE|
|000060f0| 3b 0a 58 09 09 7d 0a 58 | 09 09 62 72 65 61 6b 3b |;.X..}.X|..break;|
|00006100| 0a 58 09 63 61 73 65 20 | 27 28 27 3a 0a 58 09 09 |.X.case |'(':.X..|
|00006110| 72 65 74 20 3d 20 72 65 | 67 28 31 2c 20 26 66 6c |ret = re|g(1, &fl|
|00006120| 61 67 73 29 3b 0a 58 09 | 09 69 66 20 28 72 65 74 |ags);.X.|.if (ret|
|00006130| 20 3d 3d 20 4e 55 4c 4c | 29 0a 58 09 09 09 72 65 | == NULL|).X...re|
|00006140| 74 75 72 6e 28 4e 55 4c | 4c 29 3b 0a 58 09 09 2a |turn(NUL|L);.X..*|
|00006150| 66 6c 61 67 70 20 7c 3d | 20 66 6c 61 67 73 26 28 |flagp |=| flags&(|
|00006160| 48 41 53 57 49 44 54 48 | 7c 53 50 53 54 41 52 54 |HASWIDTH||SPSTART|
|00006170| 29 3b 0a 58 09 09 62 72 | 65 61 6b 3b 0a 58 09 63 |);.X..br|eak;.X.c|
|00006180| 61 73 65 20 27 5c 30 27 | 3a 0a 58 09 63 61 73 65 |ase '\0'|:.X.case|
|00006190| 20 27 7c 27 3a 0a 58 09 | 63 61 73 65 20 27 29 27 | '|':.X.|case ')'|
|000061a0| 3a 0a 58 09 09 46 41 49 | 4c 28 22 69 6e 74 65 72 |:.X..FAI|L("inter|
|000061b0| 6e 61 6c 20 75 72 70 22 | 29 3b 09 2f 2a 20 53 75 |nal urp"|);./* Su|
|000061c0| 70 70 6f 73 65 64 20 74 | 6f 20 62 65 20 63 61 75 |pposed t|o be cau|
|000061d0| 67 68 74 20 65 61 72 6c | 69 65 72 2e 20 2a 2f 0a |ght earl|ier. */.|
|000061e0| 58 09 09 62 72 65 61 6b | 3b 0a 58 09 63 61 73 65 |X..break|;.X.case|
|000061f0| 20 27 3f 27 3a 0a 58 09 | 63 61 73 65 20 27 2b 27 | '?':.X.|case '+'|
|00006200| 3a 0a 58 09 63 61 73 65 | 20 27 2a 27 3a 0a 58 09 |:.X.case| '*':.X.|
|00006210| 09 46 41 49 4c 28 22 3f | 2b 2a 20 66 6f 6c 6c 6f |.FAIL("?|+* follo|
|00006220| 77 73 20 6e 6f 74 68 69 | 6e 67 22 29 3b 0a 58 09 |ws nothi|ng");.X.|
|00006230| 09 62 72 65 61 6b 3b 0a | 58 09 63 61 73 65 20 27 |.break;.|X.case '|
|00006240| 5c 5c 27 3a 0a 58 09 09 | 69 66 20 28 2a 72 65 67 |\\':.X..|if (*reg|
|00006250| 70 61 72 73 65 20 3d 3d | 20 27 5c 30 27 29 0a 58 |parse ==| '\0').X|
|00006260| 09 09 09 46 41 49 4c 28 | 22 74 72 61 69 6c 69 6e |...FAIL(|"trailin|
|00006270| 67 20 5c 5c 22 29 3b 0a | 58 09 09 72 65 74 20 3d |g \\");.|X..ret =|
|00006280| 20 72 65 67 6e 6f 64 65 | 28 45 58 41 43 54 4c 59 | regnode|(EXACTLY|
|00006290| 29 3b 0a 58 09 09 72 65 | 67 63 28 2a 72 65 67 70 |);.X..re|gc(*regp|
|000062a0| 61 72 73 65 2b 2b 29 3b | 0a 58 09 09 72 65 67 63 |arse++);|.X..regc|
|000062b0| 28 27 5c 30 27 29 3b 0a | 58 09 09 2a 66 6c 61 67 |('\0');.|X..*flag|
|000062c0| 70 20 7c 3d 20 48 41 53 | 57 49 44 54 48 7c 53 49 |p |= HAS|WIDTH|SI|
|000062d0| 4d 50 4c 45 3b 0a 58 09 | 09 62 72 65 61 6b 3b 0a |MPLE;.X.|.break;.|
|000062e0| 58 09 64 65 66 61 75 6c | 74 3a 20 7b 0a 58 09 09 |X.defaul|t: {.X..|
|000062f0| 09 72 65 67 69 73 74 65 | 72 20 69 6e 74 20 6c 65 |.registe|r int le|
|00006300| 6e 3b 0a 58 09 09 09 72 | 65 67 69 73 74 65 72 20 |n;.X...r|egister |
|00006310| 63 68 61 72 20 65 6e 64 | 65 72 3b 0a 58 0a 58 09 |char end|er;.X.X.|
|00006320| 09 09 72 65 67 70 61 72 | 73 65 2d 2d 3b 0a 58 09 |..regpar|se--;.X.|
|00006330| 09 09 6c 65 6e 20 3d 20 | 73 74 72 63 73 70 6e 28 |..len = |strcspn(|
|00006340| 72 65 67 70 61 72 73 65 | 2c 20 4d 45 54 41 29 3b |regparse|, META);|
|00006350| 0a 58 09 09 09 69 66 20 | 28 6c 65 6e 20 3c 3d 20 |.X...if |(len <= |
|00006360| 30 29 0a 58 09 09 09 09 | 46 41 49 4c 28 22 69 6e |0).X....|FAIL("in|
|00006370| 74 65 72 6e 61 6c 20 64 | 69 73 61 73 74 65 72 22 |ternal d|isaster"|
|00006380| 29 3b 0a 58 09 09 09 65 | 6e 64 65 72 20 3d 20 2a |);.X...e|nder = *|
|00006390| 28 72 65 67 70 61 72 73 | 65 2b 6c 65 6e 29 3b 0a |(regpars|e+len);.|
|000063a0| 58 09 09 09 69 66 20 28 | 6c 65 6e 20 3e 20 31 20 |X...if (|len > 1 |
|000063b0| 26 26 20 49 53 4d 55 4c | 54 28 65 6e 64 65 72 29 |&& ISMUL|T(ender)|
|000063c0| 29 0a 58 09 09 09 09 6c | 65 6e 2d 2d 3b 09 09 2f |).X....l|en--;../|
|000063d0| 2a 20 42 61 63 6b 20 6f | 66 66 20 63 6c 65 61 72 |* Back o|ff clear|
|000063e0| 20 6f 66 20 3f 2b 2a 20 | 6f 70 65 72 61 6e 64 2e | of ?+* |operand.|
|000063f0| 20 2a 2f 0a 58 09 09 09 | 2a 66 6c 61 67 70 20 7c | */.X...|*flagp ||
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.