home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume27 / encode / part01 next >
SHell self-extracting ARchive  |  1993-09-12  |  35.7 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 75 6e 69 78 0a 46 72 |.sources|.unix.Fr|
|00000020| 6f 6d 3a 20 74 63 6c 40 | 68 65 6c 6c 66 75 64 67 |om: tcl@|hellfudg|
|00000030| 65 2e 61 73 64 2e 73 67 | 69 2e 63 6f 6d 20 28 54 |e.asd.sg|i.com (T|
|00000040| 6f 6d 20 4c 61 77 72 65 | 6e 63 65 29 0a 53 75 62 |om Lawre|nce).Sub|
|00000050| 6a 65 63 74 3a 20 76 32 | 37 69 30 33 35 3a 20 65 |ject: v2|7i035: e|
|00000060| 6e 63 6f 64 65 20 2d 20 | 75 74 69 6c 69 74 69 65 |ncode - |utilitie|
|00000070| 73 20 65 6e 63 6f 64 65 | 2f 64 65 63 6f 64 65 20 |s encode|/decode |
|00000080| 62 69 6e 61 72 79 20 66 | 69 6c 65 73 20 69 6e 20 |binary f|iles in |
|00000090| 61 73 63 69 69 20 66 6f | 72 6d 61 74 2c 20 50 61 |ascii fo|rmat, Pa|
|000000a0| 72 74 30 31 2f 30 31 0a | 4d 65 73 73 61 67 65 2d |rt01/01.|Message-|
|000000b0| 69 64 3a 20 3c 31 2e 37 | 34 37 38 36 31 31 32 39 |id: <1.7|47861129|
|000000c0| 2e 34 32 34 35 40 67 77 | 2e 68 6f 6d 65 2e 76 69 |.4245@gw|.home.vi|
|000000d0| 78 2e 63 6f 6d 3e 0a 53 | 65 6e 64 65 72 3a 20 75 |x.com>.S|ender: u|
|000000e0| 6e 69 78 2d 73 6f 75 72 | 63 65 73 2d 6d 6f 64 65 |nix-sour|ces-mode|
|000000f0| 72 61 74 6f 72 40 67 77 | 2e 68 6f 6d 65 2e 76 69 |rator@gw|.home.vi|
|00000100| 78 2e 63 6f 6d 0a 41 70 | 70 72 6f 76 65 64 3a 20 |x.com.Ap|proved: |
|00000110| 76 69 78 69 65 40 67 77 | 2e 68 6f 6d 65 2e 76 69 |vixie@gw|.home.vi|
|00000120| 78 2e 63 6f 6d 0a 0a 53 | 75 62 6d 69 74 74 65 64 |x.com..S|ubmitted|
|00000130| 2d 42 79 3a 20 74 63 6c | 40 68 65 6c 6c 66 75 64 |-By: tcl|@hellfud|
|00000140| 67 65 2e 61 73 64 2e 73 | 67 69 2e 63 6f 6d 20 28 |ge.asd.s|gi.com (|
|00000150| 54 6f 6d 20 4c 61 77 72 | 65 6e 63 65 29 0a 50 6f |Tom Lawr|ence).Po|
|00000160| 73 74 69 6e 67 2d 4e 75 | 6d 62 65 72 3a 20 56 6f |sting-Nu|mber: Vo|
|00000170| 6c 75 6d 65 20 32 37 2c | 20 49 73 73 75 65 20 33 |lume 27,| Issue 3|
|00000180| 35 0a 41 72 63 68 69 76 | 65 2d 4e 61 6d 65 3a 20 |5.Archiv|e-Name: |
|00000190| 65 6e 63 6f 64 65 2f 70 | 61 72 74 30 31 0a 0a 20 |encode/p|art01.. |
|000001a0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 20 57 68 61 74 |--------|--- What|
|000001b0| 20 61 72 65 20 65 6e 63 | 6f 64 65 2f 64 65 63 6f | are enc|ode/deco|
|000001c0| 64 65 3f 0a 0a 45 6e 63 | 6f 64 65 20 61 6e 64 20 |de?..Enc|ode and |
|000001d0| 64 65 63 6f 64 65 20 61 | 72 65 20 75 74 69 6c 69 |decode a|re utili|
|000001e0| 74 69 65 73 20 77 68 69 | 63 68 20 65 6e 63 6f 64 |ties whi|ch encod|
|000001f0| 65 20 62 69 6e 61 72 79 | 20 64 61 74 61 20 69 6e |e binary| data in|
|00000200| 74 6f 20 70 72 69 6e 74 | 61 62 6c 65 0a 66 6f 72 |to print|able.for|
|00000210| 6d 61 74 20 73 75 69 74 | 61 62 6c 65 20 66 6f 72 |mat suit|able for|
|00000220| 20 74 72 61 6e 73 6d 69 | 73 73 69 6f 6e 20 76 69 | transmi|ssion vi|
|00000230| 61 20 65 6d 61 69 6c 2c | 20 70 6f 73 74 69 6e 67 |a email,| posting|
|00000240| 20 74 6f 20 75 73 65 6e | 65 74 2c 20 65 74 63 2e | to usen|et, etc.|
|00000250| 20 54 68 65 79 20 61 72 | 65 0a 69 6e 74 65 6e 64 | They ar|e.intend|
|00000260| 65 64 20 74 6f 20 72 65 | 70 6c 61 63 65 20 74 68 |ed to re|place th|
|00000270| 65 20 61 67 69 6e 67 20 | 75 75 65 6e 63 6f 64 65 |e aging |uuencode|
|00000280| 20 61 6e 64 20 75 75 64 | 65 63 6f 64 65 2e 0a 0a | and uud|ecode...|
|00000290| 20 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 20 46 65 61 | -------|---- Fea|
|000002a0| 74 75 72 65 73 3a 0a 0a | 45 6e 63 6f 64 65 20 66 |tures:..|Encode f|
|000002b0| 65 61 74 75 72 65 73 20 | 61 20 76 65 72 79 20 66 |eatures |a very f|
|000002c0| 6c 65 78 69 62 6c 65 20 | 65 6e 63 6f 64 69 6e 67 |lexible |encoding|
|000002d0| 20 73 63 68 65 6d 65 20 | 77 68 69 63 68 20 61 6c | scheme |which al|
|000002e0| 6c 6f 77 73 20 74 68 65 | 20 75 73 65 72 20 74 6f |lows the| user to|
|000002f0| 0a 73 70 65 63 69 66 79 | 20 65 78 61 63 74 6c 79 |.specify| exactly|
|00000300| 20 77 68 69 63 68 20 70 | 72 69 6e 74 61 62 6c 65 | which p|rintable|
|00000310| 20 63 68 61 72 61 63 74 | 65 72 73 20 74 6f 20 75 | charact|ers to u|
|00000320| 73 65 20 69 6e 20 74 68 | 65 20 6f 75 74 70 75 74 |se in th|e output|
|00000330| 2e 20 20 54 68 65 0a 64 | 65 66 61 75 6c 74 20 69 |. The.d|efault i|
|00000340| 73 20 74 6f 20 75 73 65 | 20 61 6c 6c 20 39 35 20 |s to use| all 95 |
|00000350| 70 72 69 6e 74 61 62 6c | 65 20 63 68 61 72 61 63 |printabl|e charac|
|00000360| 74 65 72 73 20 69 6e 20 | 74 68 65 20 65 6e 63 6f |ters in |the enco|
|00000370| 64 69 6e 67 20 70 72 6f | 63 65 73 73 2c 20 61 73 |ding pro|cess, as|
|00000380| 0a 74 68 69 73 20 70 72 | 6f 64 75 63 65 73 20 74 |.this pr|oduces t|
|00000390| 68 65 20 6c 65 61 73 74 | 20 65 78 70 61 6e 73 69 |he least| expansi|
|000003a0| 6f 6e 20 6f 66 20 74 68 | 65 20 69 6e 70 75 74 20 |on of th|e input |
|000003b0| 64 61 74 61 2e 20 20 48 | 6f 77 65 76 65 72 2c 20 |data. H|owever, |
|000003c0| 66 6f 72 20 63 61 73 65 | 73 0a 73 75 63 68 20 61 |for case|s.such a|
|000003d0| 73 20 66 69 6c 65 20 74 | 72 61 6e 73 66 65 72 20 |s file t|ransfer |
|000003e0| 74 6f 20 61 20 6d 61 69 | 6e 66 72 61 6d 65 20 6f |to a mai|nframe o|
|000003f0| 72 20 74 6f 20 61 20 66 | 6f 72 65 69 67 6e 20 63 |r to a f|oreign c|
|00000400| 6f 75 6e 74 72 79 20 77 | 68 65 72 65 20 73 6f 6d |ountry w|here som|
|00000410| 65 0a 63 68 61 72 61 63 | 74 65 72 73 20 6d 61 79 |e.charac|ters may|
|00000420| 20 62 65 20 6d 6f 64 69 | 66 69 65 64 20 65 6e 20 | be modi|fied en |
|00000430| 72 6f 75 74 65 2c 20 74 | 68 65 73 65 20 63 68 61 |route, t|hese cha|
|00000440| 72 61 63 74 65 72 73 20 | 63 61 6e 20 73 69 6d 70 |racters |can simp|
|00000450| 6c 79 20 62 65 20 72 65 | 6d 6f 76 65 64 0a 66 72 |ly be re|moved.fr|
|00000460| 6f 6d 20 74 68 65 20 6f | 75 74 70 75 74 20 63 68 |om the o|utput ch|
|00000470| 61 72 61 63 74 65 72 20 | 73 65 74 2e 20 20 45 6e |aracter |set. En|
|00000480| 63 6f 64 69 6e 67 20 69 | 73 20 70 6f 73 73 69 62 |coding i|s possib|
|00000490| 6c 65 20 77 69 74 68 20 | 61 73 20 66 65 77 20 61 |le with |as few a|
|000004a0| 73 20 32 0a 63 68 61 72 | 61 63 74 65 72 73 20 69 |s 2.char|acters i|
|000004b0| 6e 20 74 68 65 20 6f 75 | 74 70 75 74 20 63 68 61 |n the ou|tput cha|
|000004c0| 72 61 63 74 65 72 20 73 | 65 74 2e 0a 0a 52 65 67 |racter s|et...Reg|
|000004d0| 61 72 64 6c 65 73 73 20 | 6f 66 20 68 6f 77 20 6d |ardless |of how m|
|000004e0| 61 6e 79 20 63 68 61 72 | 61 63 74 65 72 73 20 61 |any char|acters a|
|000004f0| 72 65 20 73 70 65 63 69 | 66 69 65 64 20 69 6e 20 |re speci|fied in |
|00000500| 74 68 65 20 6f 75 74 70 | 75 74 20 63 68 61 72 61 |the outp|ut chara|
|00000510| 63 74 65 72 20 73 65 74 | 2c 0a 65 6e 63 6f 64 65 |cter set|,.encode|
|00000520| 20 6f 6e 6c 79 20 65 78 | 70 61 6e 64 73 20 74 68 | only ex|pands th|
|00000530| 65 20 64 61 74 61 20 62 | 79 20 61 20 66 61 63 74 |e data b|y a fact|
|00000540| 6f 72 20 76 65 72 79 20 | 63 6c 6f 73 65 20 74 6f |or very |close to|
|00000550| 20 74 68 65 20 74 68 65 | 6f 72 65 74 69 63 61 6c | the the|oretical|
|00000560| 20 6c 69 6d 69 74 0a 66 | 6f 72 20 74 68 61 74 20 | limit.f|or that |
|00000570| 6e 75 6d 62 65 72 20 6f | 66 20 63 68 61 72 61 63 |number o|f charac|
|00000580| 74 65 72 73 2e 20 28 73 | 65 65 20 6e 65 78 74 20 |ters. (s|ee next |
|00000590| 73 65 63 74 69 6f 6e 29 | 0a 0a 54 68 65 20 69 6d |section)|..The im|
|000005a0| 70 6c 65 6d 65 6e 74 61 | 74 69 6f 6e 20 69 73 20 |plementa|tion is |
|000005b0| 73 69 6d 70 6c 65 20 28 | 6c 65 73 73 20 74 68 61 |simple (|less tha|
|000005c0| 6e 20 35 30 30 20 6c 69 | 6e 65 73 20 74 6f 74 61 |n 500 li|nes tota|
|000005d0| 6c 20 77 69 74 68 6f 75 | 74 20 63 6f 6d 6d 65 6e |l withou|t commen|
|000005e0| 74 73 29 20 61 6e 64 0a | 65 66 66 69 63 69 65 6e |ts) and.|efficien|
|000005f0| 74 20 28 72 75 6e 73 20 | 61 74 20 61 20 73 70 65 |t (runs |at a spe|
|00000600| 65 64 20 63 6f 6d 70 61 | 72 61 62 6c 65 20 74 6f |ed compa|rable to|
|00000610| 20 75 75 65 6e 63 6f 64 | 65 2f 75 75 64 65 63 6f | uuencod|e/uudeco|
|00000620| 64 65 29 0a 0a 23 21 20 | 2f 62 69 6e 2f 73 68 0a |de)..#! |/bin/sh.|
|00000630| 23 20 54 68 69 73 20 69 | 73 20 61 20 73 68 65 6c |# This i|s a shel|
|00000640| 6c 20 61 72 63 68 69 76 | 65 2e 20 20 52 65 6d 6f |l archiv|e. Remo|
|00000650| 76 65 20 61 6e 79 74 68 | 69 6e 67 20 62 65 66 6f |ve anyth|ing befo|
|00000660| 72 65 20 74 68 69 73 20 | 6c 69 6e 65 2c 20 74 68 |re this |line, th|
|00000670| 65 6e 20 75 6e 70 61 63 | 6b 0a 23 20 69 74 20 62 |en unpac|k.# it b|
|00000680| 79 20 73 61 76 69 6e 67 | 20 69 74 20 69 6e 74 6f |y saving| it into|
|00000690| 20 61 20 66 69 6c 65 20 | 61 6e 64 20 74 79 70 69 | a file |and typi|
|000006a0| 6e 67 20 22 73 68 20 66 | 69 6c 65 22 2e 20 20 54 |ng "sh f|ile". T|
|000006b0| 6f 20 6f 76 65 72 77 72 | 69 74 65 20 65 78 69 73 |o overwr|ite exis|
|000006c0| 74 69 6e 67 0a 23 20 66 | 69 6c 65 73 2c 20 74 79 |ting.# f|iles, ty|
|000006d0| 70 65 20 22 73 68 20 66 | 69 6c 65 20 2d 63 22 2e |pe "sh f|ile -c".|
|000006e0| 20 20 59 6f 75 20 63 61 | 6e 20 61 6c 73 6f 20 66 | You ca|n also f|
|000006f0| 65 65 64 20 74 68 69 73 | 20 61 73 20 73 74 61 6e |eed this| as stan|
|00000700| 64 61 72 64 20 69 6e 70 | 75 74 20 76 69 61 0a 23 |dard inp|ut via.#|
|00000710| 20 75 6e 73 68 61 72 2c | 20 6f 72 20 62 79 20 74 | unshar,| or by t|
|00000720| 79 70 69 6e 67 20 22 73 | 68 20 3c 66 69 6c 65 22 |yping "s|h <file"|
|00000730| 2c 20 65 2e 67 2e 2e 20 | 20 49 66 20 74 68 69 73 |, e.g.. | If this|
|00000740| 20 61 72 63 68 69 76 65 | 20 69 73 20 63 6f 6d 70 | archive| is comp|
|00000750| 6c 65 74 65 2c 20 79 6f | 75 0a 23 20 77 69 6c 6c |lete, yo|u.# will|
|00000760| 20 73 65 65 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 | see the| followi|
|00000770| 6e 67 20 6d 65 73 73 61 | 67 65 20 61 74 20 74 68 |ng messa|ge at th|
|00000780| 65 20 65 6e 64 3a 0a 23 | 09 09 22 45 6e 64 20 6f |e end:.#|.."End o|
|00000790| 66 20 61 72 63 68 69 76 | 65 20 31 20 28 6f 66 20 |f archiv|e 1 (of |
|000007a0| 31 29 2e 22 0a 23 20 43 | 6f 6e 74 65 6e 74 73 3a |1).".# C|ontents:|
|000007b0| 20 20 4d 41 4e 49 46 45 | 53 54 20 4d 61 6b 65 66 | MANIFE|ST Makef|
|000007c0| 69 6c 65 20 52 45 41 44 | 4d 45 20 63 6f 64 65 73 |ile READ|ME codes|
|000007d0| 2e 63 20 63 6f 64 65 73 | 2e 68 20 64 65 63 6f 64 |.c codes|.h decod|
|000007e0| 65 2e 31 20 64 65 63 6f | 64 65 2e 63 0a 23 20 20 |e.1 deco|de.c.# |
|000007f0| 20 65 6e 63 6f 64 65 2e | 31 20 65 6e 63 6f 64 65 | encode.|1 encode|
|00000800| 2e 63 0a 23 20 57 72 61 | 70 70 65 64 20 62 79 20 |.c.# Wra|pped by |
|00000810| 76 69 78 69 65 40 67 77 | 2e 68 6f 6d 65 2e 76 69 |vixie@gw|.home.vi|
|00000820| 78 2e 63 6f 6d 20 6f 6e | 20 53 75 6e 20 53 65 70 |x.com on| Sun Sep|
|00000830| 20 31 32 20 31 32 3a 31 | 30 3a 35 33 20 31 39 39 | 12 12:1|0:53 199|
|00000840| 33 0a 50 41 54 48 3d 2f | 62 69 6e 3a 2f 75 73 72 |3.PATH=/|bin:/usr|
|00000850| 2f 62 69 6e 3a 2f 75 73 | 72 2f 75 63 62 20 3b 20 |/bin:/us|r/ucb ; |
|00000860| 65 78 70 6f 72 74 20 50 | 41 54 48 0a 69 66 20 74 |export P|ATH.if t|
|00000870| 65 73 74 20 2d 66 20 27 | 4d 41 4e 49 46 45 53 54 |est -f '|MANIFEST|
|00000880| 27 20 2d 61 20 22 24 7b | 31 7d 22 20 21 3d 20 22 |' -a "${|1}" != "|
|00000890| 2d 63 22 20 3b 20 74 68 | 65 6e 20 0a 20 20 65 63 |-c" ; th|en . ec|
|000008a0| 68 6f 20 73 68 61 72 3a | 20 57 69 6c 6c 20 6e 6f |ho shar:| Will no|
|000008b0| 74 20 63 6c 6f 62 62 65 | 72 20 65 78 69 73 74 69 |t clobbe|r existi|
|000008c0| 6e 67 20 66 69 6c 65 20 | 5c 22 27 4d 41 4e 49 46 |ng file |\"'MANIF|
|000008d0| 45 53 54 27 5c 22 0a 65 | 6c 73 65 0a 65 63 68 6f |EST'\".e|lse.echo|
|000008e0| 20 73 68 61 72 3a 20 45 | 78 74 72 61 63 74 69 6e | shar: E|xtractin|
|000008f0| 67 20 5c 22 27 4d 41 4e | 49 46 45 53 54 27 5c 22 |g \"'MAN|IFEST'\"|
|00000900| 20 5c 28 33 39 33 20 63 | 68 61 72 61 63 74 65 72 | \(393 c|haracter|
|00000910| 73 5c 29 0a 73 65 64 20 | 22 73 2f 5e 58 2f 2f 22 |s\).sed |"s/^X//"|
|00000920| 20 3e 27 4d 41 4e 49 46 | 45 53 54 27 20 3c 3c 27 | >'MANIF|EST' <<'|
|00000930| 45 4e 44 5f 4f 46 5f 46 | 49 4c 45 27 0a 58 20 20 |END_OF_F|ILE'.X |
|00000940| 20 46 69 6c 65 20 4e 61 | 6d 65 09 09 41 72 63 68 | File Na|me..Arch|
|00000950| 69 76 65 20 23 09 44 65 | 73 63 72 69 70 74 69 6f |ive #.De|scriptio|
|00000960| 6e 0a 58 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |n.X-----|--------|
|00000970| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000980| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000990| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 0a 58 |--------|------.X|
|000009a0| 20 4d 41 4e 49 46 45 53 | 54 20 20 20 20 20 20 20 | MANIFES|T |
|000009b0| 20 20 20 20 20 20 20 20 | 20 20 20 20 31 09 54 68 | | 1.Th|
|000009c0| 69 73 20 73 68 69 70 70 | 69 6e 67 20 6c 69 73 74 |is shipp|ing list|
|000009d0| 0a 58 20 4d 61 6b 65 66 | 69 6c 65 20 20 20 20 20 |.X Makef|ile |
|000009e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 31 09 | | 1.|
|000009f0| 0a 58 20 52 45 41 44 4d | 45 20 20 20 20 20 20 20 |.X READM|E |
|00000a00| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 31 09 | | 1.|
|00000a10| 0a 58 20 63 6f 64 65 73 | 2e 63 20 20 20 20 20 20 |.X codes|.c |
|00000a20| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 31 09 | | 1.|
|00000a30| 0a 58 20 63 6f 64 65 73 | 2e 68 20 20 20 20 20 20 |.X codes|.h |
|00000a40| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 31 09 | | 1.|
|00000a50| 0a 58 20 64 65 63 6f 64 | 65 2e 31 20 20 20 20 20 |.X decod|e.1 |
|00000a60| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 31 09 | | 1.|
|00000a70| 0a 58 20 64 65 63 6f 64 | 65 2e 63 20 20 20 20 20 |.X decod|e.c |
|00000a80| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 31 09 | | 1.|
|00000a90| 0a 58 20 65 6e 63 6f 64 | 65 2e 31 20 20 20 20 20 |.X encod|e.1 |
|00000aa0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 31 09 | | 1.|
|00000ab0| 0a 58 20 65 6e 63 6f 64 | 65 2e 63 20 20 20 20 20 |.X encod|e.c |
|00000ac0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 31 09 | | 1.|
|00000ad0| 0a 45 4e 44 5f 4f 46 5f | 46 49 4c 45 0a 69 66 20 |.END_OF_|FILE.if |
|00000ae0| 74 65 73 74 20 33 39 33 | 20 2d 6e 65 20 60 77 63 |test 393| -ne `wc|
|00000af0| 20 2d 63 20 3c 27 4d 41 | 4e 49 46 45 53 54 27 60 | -c <'MA|NIFEST'`|
|00000b00| 3b 20 74 68 65 6e 0a 20 | 20 20 20 65 63 68 6f 20 |; then. | echo |
|00000b10| 73 68 61 72 3a 20 5c 22 | 27 4d 41 4e 49 46 45 53 |shar: \"|'MANIFES|
|00000b20| 54 27 5c 22 20 75 6e 70 | 61 63 6b 65 64 20 77 69 |T'\" unp|acked wi|
|00000b30| 74 68 20 77 72 6f 6e 67 | 20 73 69 7a 65 21 0a 66 |th wrong| size!.f|
|00000b40| 69 0a 23 20 65 6e 64 20 | 6f 66 20 27 4d 41 4e 49 |i.# end |of 'MANI|
|00000b50| 46 45 53 54 27 0a 66 69 | 0a 69 66 20 74 65 73 74 |FEST'.fi|.if test|
|00000b60| 20 2d 66 20 27 4d 61 6b | 65 66 69 6c 65 27 20 2d | -f 'Mak|efile' -|
|00000b70| 61 20 22 24 7b 31 7d 22 | 20 21 3d 20 22 2d 63 22 |a "${1}"| != "-c"|
|00000b80| 20 3b 20 74 68 65 6e 20 | 0a 20 20 65 63 68 6f 20 | ; then |. echo |
|00000b90| 73 68 61 72 3a 20 57 69 | 6c 6c 20 6e 6f 74 20 63 |shar: Wi|ll not c|
|00000ba0| 6c 6f 62 62 65 72 20 65 | 78 69 73 74 69 6e 67 20 |lobber e|xisting |
|00000bb0| 66 69 6c 65 20 5c 22 27 | 4d 61 6b 65 66 69 6c 65 |file \"'|Makefile|
|00000bc0| 27 5c 22 0a 65 6c 73 65 | 0a 65 63 68 6f 20 73 68 |'\".else|.echo sh|
|00000bd0| 61 72 3a 20 45 78 74 72 | 61 63 74 69 6e 67 20 5c |ar: Extr|acting \|
|00000be0| 22 27 4d 61 6b 65 66 69 | 6c 65 27 5c 22 20 5c 28 |"'Makefi|le'\" \(|
|00000bf0| 36 30 31 20 63 68 61 72 | 61 63 74 65 72 73 5c 29 |601 char|acters\)|
|00000c00| 0a 73 65 64 20 22 73 2f | 5e 58 2f 2f 22 20 3e 27 |.sed "s/|^X//" >'|
|00000c10| 4d 61 6b 65 66 69 6c 65 | 27 20 3c 3c 27 45 4e 44 |Makefile|' <<'END|
|00000c20| 5f 4f 46 5f 46 49 4c 45 | 27 0a 58 23 20 24 48 65 |_OF_FILE|'.X# $He|
|00000c30| 61 64 65 72 3a 20 2f 64 | 2f 74 63 6c 2f 73 72 63 |ader: /d|/tcl/src|
|00000c40| 2f 75 75 74 61 72 2f 52 | 43 53 2f 4d 61 6b 65 66 |/uutar/R|CS/Makef|
|00000c50| 69 6c 65 2c 76 20 31 2e | 32 2e 31 2e 32 20 31 39 |ile,v 1.|2.1.2 19|
|00000c60| 39 33 2f 30 39 2f 31 30 | 20 32 31 3a 33 39 3a 32 |93/09/10| 21:39:2|
|00000c70| 34 20 74 63 6c 20 45 78 | 70 20 24 0a 58 0a 58 43 |4 tcl Ex|p $.X.XC|
|00000c80| 43 20 3d 20 63 63 20 0a | 58 43 46 4c 41 47 53 20 |C = cc .|XCFLAGS |
|00000c90| 3d 20 2d 4f 0a 58 0a 58 | 43 4f 4d 4d 4f 4e 5f 53 |= -O.X.X|COMMON_S|
|00000ca0| 52 43 53 20 3d 20 63 6f | 64 65 73 2e 63 0a 58 43 |RCS = co|des.c.XC|
|00000cb0| 4f 4d 4d 4f 4e 5f 42 49 | 4e 41 52 49 45 53 20 3d |OMMON_BI|NARIES =|
|00000cc0| 20 24 7b 43 4f 4d 4d 4f | 4e 5f 53 52 43 53 3a 2e | ${COMMO|N_SRCS:.|
|00000cd0| 63 3d 2e 6f 7d 0a 58 0a | 58 45 4e 43 4f 44 45 5f |c=.o}.X.|XENCODE_|
|00000ce0| 53 52 43 53 20 3d 20 65 | 6e 63 6f 64 65 2e 63 0a |SRCS = e|ncode.c.|
|00000cf0| 58 45 4e 43 4f 44 45 5f | 42 49 4e 41 52 49 45 53 |XENCODE_|BINARIES|
|00000d00| 20 3d 20 24 7b 45 4e 43 | 4f 44 45 5f 53 52 43 53 | = ${ENC|ODE_SRCS|
|00000d10| 3a 2e 63 3d 2e 6f 7d 0a | 58 0a 58 44 45 43 4f 44 |:.c=.o}.|X.XDECOD|
|00000d20| 45 5f 53 52 43 53 20 3d | 20 64 65 63 6f 64 65 2e |E_SRCS =| decode.|
|00000d30| 63 0a 58 44 45 43 4f 44 | 45 5f 42 49 4e 41 52 49 |c.XDECOD|E_BINARI|
|00000d40| 45 53 20 3d 20 24 7b 44 | 45 43 4f 44 45 5f 53 52 |ES = ${D|ECODE_SR|
|00000d50| 43 53 3a 2e 63 3d 2e 6f | 7d 0a 58 0a 58 64 65 66 |CS:.c=.o|}.X.Xdef|
|00000d60| 61 75 6c 74 3a 20 65 6e | 63 6f 64 65 20 64 65 63 |ault: en|code dec|
|00000d70| 6f 64 65 0a 58 0a 58 65 | 6e 63 6f 64 65 3a 09 09 |ode.X.Xe|ncode:..|
|00000d80| 24 28 43 4f 4d 4d 4f 4e | 5f 42 49 4e 41 52 49 45 |$(COMMON|_BINARIE|
|00000d90| 53 29 20 24 28 45 4e 43 | 4f 44 45 5f 42 49 4e 41 |S) $(ENC|ODE_BINA|
|00000da0| 52 49 45 53 29 0a 58 09 | 09 24 28 43 43 29 20 2d |RIES).X.|.$(CC) -|
|00000db0| 6f 20 65 6e 63 6f 64 65 | 20 24 28 43 4f 4d 4d 4f |o encode| $(COMMO|
|00000dc0| 4e 5f 42 49 4e 41 52 49 | 45 53 29 20 24 28 45 4e |N_BINARI|ES) $(EN|
|00000dd0| 43 4f 44 45 5f 42 49 4e | 41 52 49 45 53 29 0a 58 |CODE_BIN|ARIES).X|
|00000de0| 0a 58 64 65 63 6f 64 65 | 3a 09 09 24 28 43 4f 4d |.Xdecode|:..$(COM|
|00000df0| 4d 4f 4e 5f 42 49 4e 41 | 52 49 45 53 29 20 24 28 |MON_BINA|RIES) $(|
|00000e00| 44 45 43 4f 44 45 5f 42 | 49 4e 41 52 49 45 53 29 |DECODE_B|INARIES)|
|00000e10| 0a 58 09 09 24 28 43 43 | 29 20 2d 6f 20 64 65 63 |.X..$(CC|) -o dec|
|00000e20| 6f 64 65 20 24 28 43 4f | 4d 4d 4f 4e 5f 42 49 4e |ode $(CO|MMON_BIN|
|00000e30| 41 52 49 45 53 29 20 24 | 28 44 45 43 4f 44 45 5f |ARIES) $|(DECODE_|
|00000e40| 42 49 4e 41 52 49 45 53 | 29 0a 58 0a 58 63 6c 65 |BINARIES|).X.Xcle|
|00000e50| 61 6e 3a 0a 58 09 09 40 | 74 6f 75 63 68 20 62 75 |an:.X..@|touch bu|
|00000e60| 6e 6b 2e 6f 20 62 75 6e | 6b 7e 20 65 6e 63 6f 64 |nk.o bun|k~ encod|
|00000e70| 65 20 64 65 63 6f 64 65 | 0a 58 09 09 2f 62 69 6e |e decode|.X../bin|
|00000e80| 2f 72 6d 20 2d 66 20 2a | 2e 6f 20 2a 7e 20 65 6e |/rm -f *|.o *~ en|
|00000e90| 63 6f 64 65 20 64 65 63 | 6f 64 65 0a 45 4e 44 5f |code dec|ode.END_|
|00000ea0| 4f 46 5f 46 49 4c 45 0a | 69 66 20 74 65 73 74 20 |OF_FILE.|if test |
|00000eb0| 36 30 31 20 2d 6e 65 20 | 60 77 63 20 2d 63 20 3c |601 -ne |`wc -c <|
|00000ec0| 27 4d 61 6b 65 66 69 6c | 65 27 60 3b 20 74 68 65 |'Makefil|e'`; the|
|00000ed0| 6e 0a 20 20 20 20 65 63 | 68 6f 20 73 68 61 72 3a |n. ec|ho shar:|
|00000ee0| 20 5c 22 27 4d 61 6b 65 | 66 69 6c 65 27 5c 22 20 | \"'Make|file'\" |
|00000ef0| 75 6e 70 61 63 6b 65 64 | 20 77 69 74 68 20 77 72 |unpacked| with wr|
|00000f00| 6f 6e 67 20 73 69 7a 65 | 21 0a 66 69 0a 23 20 65 |ong size|!.fi.# e|
|00000f10| 6e 64 20 6f 66 20 27 4d | 61 6b 65 66 69 6c 65 27 |nd of 'M|akefile'|
|00000f20| 0a 66 69 0a 69 66 20 74 | 65 73 74 20 2d 66 20 27 |.fi.if t|est -f '|
|00000f30| 52 45 41 44 4d 45 27 20 | 2d 61 20 22 24 7b 31 7d |README' |-a "${1}|
|00000f40| 22 20 21 3d 20 22 2d 63 | 22 20 3b 20 74 68 65 6e |" != "-c|" ; then|
|00000f50| 20 0a 20 20 65 63 68 6f | 20 73 68 61 72 3a 20 57 | . echo| shar: W|
|00000f60| 69 6c 6c 20 6e 6f 74 20 | 63 6c 6f 62 62 65 72 20 |ill not |clobber |
|00000f70| 65 78 69 73 74 69 6e 67 | 20 66 69 6c 65 20 5c 22 |existing| file \"|
|00000f80| 27 52 45 41 44 4d 45 27 | 5c 22 0a 65 6c 73 65 0a |'README'|\".else.|
|00000f90| 65 63 68 6f 20 73 68 61 | 72 3a 20 45 78 74 72 61 |echo sha|r: Extra|
|00000fa0| 63 74 69 6e 67 20 5c 22 | 27 52 45 41 44 4d 45 27 |cting \"|'README'|
|00000fb0| 5c 22 20 5c 28 38 38 35 | 39 20 63 68 61 72 61 63 |\" \(885|9 charac|
|00000fc0| 74 65 72 73 5c 29 0a 73 | 65 64 20 22 73 2f 5e 58 |ters\).s|ed "s/^X|
|00000fd0| 2f 2f 22 20 3e 27 52 45 | 41 44 4d 45 27 20 3c 3c |//" >'RE|ADME' <<|
|00000fe0| 27 45 4e 44 5f 4f 46 5f | 46 49 4c 45 27 0a 58 24 |'END_OF_|FILE'.X$|
|00000ff0| 48 65 61 64 65 72 3a 20 | 2f 75 73 72 2f 70 65 6f |Header: |/usr/peo|
|00001000| 70 6c 65 2f 74 63 6c 2f | 73 72 63 2f 75 75 74 61 |ple/tcl/|src/uuta|
|00001010| 72 2f 52 43 53 2f 52 45 | 41 44 4d 45 2c 76 20 31 |r/RCS/RE|ADME,v 1|
|00001020| 2e 33 20 31 39 39 33 2f | 30 39 2f 31 32 20 30 30 |.3 1993/|09/12 00|
|00001030| 3a 34 30 3a 35 32 20 74 | 63 6c 20 45 78 70 20 24 |:40:52 t|cl Exp $|
|00001040| 0a 58 0a 58 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 20 |.X.X----|------- |
|00001050| 57 68 61 74 20 61 72 65 | 20 65 6e 63 6f 64 65 2f |What are| encode/|
|00001060| 64 65 63 6f 64 65 3f 0a | 58 0a 58 45 6e 63 6f 64 |decode?.|X.XEncod|
|00001070| 65 20 61 6e 64 20 64 65 | 63 6f 64 65 20 61 72 65 |e and de|code are|
|00001080| 20 75 74 69 6c 69 74 69 | 65 73 20 77 68 69 63 68 | utiliti|es which|
|00001090| 20 65 6e 63 6f 64 65 20 | 62 69 6e 61 72 79 20 64 | encode |binary d|
|000010a0| 61 74 61 20 69 6e 74 6f | 0a 58 70 72 69 6e 74 61 |ata into|.Xprinta|
|000010b0| 62 6c 65 20 66 6f 72 6d | 61 74 20 73 75 69 74 61 |ble form|at suita|
|000010c0| 62 6c 65 20 66 6f 72 20 | 74 72 61 6e 73 6d 69 73 |ble for |transmis|
|000010d0| 73 69 6f 6e 20 76 69 61 | 20 65 6d 61 69 6c 2c 20 |sion via| email, |
|000010e0| 70 6f 73 74 69 6e 67 20 | 74 6f 0a 58 75 73 65 6e |posting |to.Xusen|
|000010f0| 65 74 2c 20 65 74 63 2e | 20 54 68 65 79 20 61 72 |et, etc.| They ar|
|00001100| 65 20 69 6e 74 65 6e 64 | 65 64 20 74 6f 20 72 65 |e intend|ed to re|
|00001110| 70 6c 61 63 65 20 74 68 | 65 20 61 67 69 6e 67 20 |place th|e aging |
|00001120| 75 75 65 6e 63 6f 64 65 | 20 61 6e 64 0a 58 75 75 |uuencode| and.Xuu|
|00001130| 64 65 63 6f 64 65 2e 0a | 58 0a 58 2d 2d 2d 2d 2d |decode..|X.X-----|
|00001140| 2d 2d 2d 2d 2d 2d 20 46 | 65 61 74 75 72 65 73 3a |------ F|eatures:|
|00001150| 0a 58 0a 58 45 6e 63 6f | 64 65 20 66 65 61 74 75 |.X.XEnco|de featu|
|00001160| 72 65 73 20 61 20 76 65 | 72 79 20 66 6c 65 78 69 |res a ve|ry flexi|
|00001170| 62 6c 65 20 65 6e 63 6f | 64 69 6e 67 20 73 63 68 |ble enco|ding sch|
|00001180| 65 6d 65 20 77 68 69 63 | 68 20 61 6c 6c 6f 77 73 |eme whic|h allows|
|00001190| 20 74 68 65 20 75 73 65 | 72 0a 58 74 6f 20 73 70 | the use|r.Xto sp|
|000011a0| 65 63 69 66 79 20 65 78 | 61 63 74 6c 79 20 77 68 |ecify ex|actly wh|
|000011b0| 69 63 68 20 70 72 69 6e | 74 61 62 6c 65 20 63 68 |ich prin|table ch|
|000011c0| 61 72 61 63 74 65 72 73 | 20 74 6f 20 75 73 65 20 |aracters| to use |
|000011d0| 69 6e 20 74 68 65 20 6f | 75 74 70 75 74 2e 0a 58 |in the o|utput..X|
|000011e0| 54 68 65 20 64 65 66 61 | 75 6c 74 20 69 73 20 74 |The defa|ult is t|
|000011f0| 6f 20 75 73 65 20 61 6c | 6c 20 39 35 20 70 72 69 |o use al|l 95 pri|
|00001200| 6e 74 61 62 6c 65 20 63 | 68 61 72 61 63 74 65 72 |ntable c|haracter|
|00001210| 73 20 69 6e 20 74 68 65 | 20 65 6e 63 6f 64 69 6e |s in the| encodin|
|00001220| 67 0a 58 70 72 6f 63 65 | 73 73 2c 20 61 73 20 74 |g.Xproce|ss, as t|
|00001230| 68 69 73 20 70 72 6f 64 | 75 63 65 73 20 74 68 65 |his prod|uces the|
|00001240| 20 6c 65 61 73 74 20 65 | 78 70 61 6e 73 69 6f 6e | least e|xpansion|
|00001250| 20 6f 66 20 74 68 65 20 | 69 6e 70 75 74 20 64 61 | of the |input da|
|00001260| 74 61 2e 0a 58 48 6f 77 | 65 76 65 72 2c 20 66 6f |ta..XHow|ever, fo|
|00001270| 72 20 63 61 73 65 73 20 | 73 75 63 68 20 61 73 20 |r cases |such as |
|00001280| 66 69 6c 65 20 74 72 61 | 6e 73 66 65 72 20 74 6f |file tra|nsfer to|
|00001290| 20 61 20 6d 61 69 6e 66 | 72 61 6d 65 20 6f 72 20 | a mainf|rame or |
|000012a0| 74 6f 20 61 0a 58 66 6f | 72 65 69 67 6e 20 63 6f |to a.Xfo|reign co|
|000012b0| 75 6e 74 72 79 20 77 68 | 65 72 65 20 73 6f 6d 65 |untry wh|ere some|
|000012c0| 20 63 68 61 72 61 63 74 | 65 72 73 20 6d 61 79 20 | charact|ers may |
|000012d0| 62 65 20 6d 6f 64 69 66 | 69 65 64 20 65 6e 20 72 |be modif|ied en r|
|000012e0| 6f 75 74 65 2c 20 74 68 | 65 73 65 0a 58 63 68 61 |oute, th|ese.Xcha|
|000012f0| 72 61 63 74 65 72 73 20 | 63 61 6e 20 73 69 6d 70 |racters |can simp|
|00001300| 6c 79 20 62 65 20 72 65 | 6d 6f 76 65 64 20 66 72 |ly be re|moved fr|
|00001310| 6f 6d 20 74 68 65 20 6f | 75 74 70 75 74 20 63 68 |om the o|utput ch|
|00001320| 61 72 61 63 74 65 72 20 | 73 65 74 2e 0a 58 45 6e |aracter |set..XEn|
|00001330| 63 6f 64 69 6e 67 20 69 | 73 20 70 6f 73 73 69 62 |coding i|s possib|
|00001340| 6c 65 20 77 69 74 68 20 | 61 73 20 66 65 77 20 61 |le with |as few a|
|00001350| 73 20 32 20 63 68 61 72 | 61 63 74 65 72 73 20 69 |s 2 char|acters i|
|00001360| 6e 20 74 68 65 20 6f 75 | 74 70 75 74 0a 58 63 68 |n the ou|tput.Xch|
|00001370| 61 72 61 63 74 65 72 20 | 73 65 74 2e 0a 58 0a 58 |aracter |set..X.X|
|00001380| 52 65 67 61 72 64 6c 65 | 73 73 20 6f 66 20 68 6f |Regardle|ss of ho|
|00001390| 77 20 6d 61 6e 79 20 63 | 68 61 72 61 63 74 65 72 |w many c|haracter|
|000013a0| 73 20 61 72 65 20 73 70 | 65 63 69 66 69 65 64 20 |s are sp|ecified |
|000013b0| 69 6e 20 74 68 65 20 6f | 75 74 70 75 74 0a 58 63 |in the o|utput.Xc|
|000013c0| 68 61 72 61 63 74 65 72 | 20 73 65 74 2c 20 65 6e |haracter| set, en|
|000013d0| 63 6f 64 65 20 6f 6e 6c | 79 20 65 78 70 61 6e 64 |code onl|y expand|
|000013e0| 73 20 74 68 65 20 64 61 | 74 61 20 62 79 20 61 20 |s the da|ta by a |
|000013f0| 66 61 63 74 6f 72 20 76 | 65 72 79 20 63 6c 6f 73 |factor v|ery clos|
|00001400| 65 20 74 6f 0a 58 74 68 | 65 20 74 68 65 6f 72 65 |e to.Xth|e theore|
|00001410| 74 69 63 61 6c 20 6c 69 | 6d 69 74 20 66 6f 72 20 |tical li|mit for |
|00001420| 74 68 61 74 20 6e 75 6d | 62 65 72 20 6f 66 20 63 |that num|ber of c|
|00001430| 68 61 72 61 63 74 65 72 | 73 2e 20 28 73 65 65 20 |haracter|s. (see |
|00001440| 6e 65 78 74 0a 58 73 65 | 63 74 69 6f 6e 29 0a 58 |next.Xse|ction).X|
|00001450| 0a 58 4d 79 20 69 6d 70 | 6c 65 6d 65 6e 74 61 74 |.XMy imp|lementat|
|00001460| 69 6f 6e 20 69 73 20 73 | 69 6d 70 6c 65 20 28 6c |ion is s|imple (l|
|00001470| 65 73 73 20 74 68 61 6e | 20 35 30 30 20 6c 69 6e |ess than| 500 lin|
|00001480| 65 73 20 74 6f 74 61 6c | 20 77 69 74 68 6f 75 74 |es total| without|
|00001490| 0a 58 63 6f 6d 6d 65 6e | 74 73 29 20 61 6e 64 20 |.Xcommen|ts) and |
|000014a0| 65 66 66 69 63 69 65 6e | 74 20 28 72 75 6e 73 20 |efficien|t (runs |
|000014b0| 61 74 20 61 20 73 70 65 | 65 64 20 63 6f 6d 70 61 |at a spe|ed compa|
|000014c0| 72 61 62 6c 65 20 74 6f | 0a 58 75 75 65 6e 63 6f |rable to|.Xuuenco|
|000014d0| 64 65 2f 75 75 64 65 63 | 6f 64 65 29 0a 58 0a 58 |de/uudec|ode).X.X|
|000014e0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 20 53 6f 6d 65 |--------|--- Some|
|000014f0| 20 74 68 65 6f 72 79 20 | 6f 6e 20 66 69 6c 65 20 | theory |on file |
|00001500| 65 78 70 61 6e 73 69 6f | 6e 20 64 75 72 69 6e 67 |expansio|n during|
|00001510| 20 65 6e 63 6f 64 69 6e | 67 3a 0a 58 0a 58 54 68 | encodin|g:.X.XTh|
|00001520| 65 20 6e 75 6d 62 65 72 | 20 6f 66 20 62 69 74 73 |e number| of bits|
|00001530| 20 72 65 71 75 69 72 65 | 64 20 74 6f 20 65 6e 63 | require|d to enc|
|00001540| 6f 64 65 20 6e 20 64 69 | 73 74 69 6e 63 74 20 76 |ode n di|stinct v|
|00001550| 61 6c 75 65 73 20 69 73 | 20 6c 6f 67 32 28 6e 29 |alues is| log2(n)|
|00001560| 0a 58 28 6c 6f 67 20 62 | 61 73 65 20 32 20 6f 66 |.X(log b|ase 2 of|
|00001570| 20 6e 29 2e 20 46 6f 72 | 20 65 78 61 6d 70 6c 65 | n). For| example|
|00001580| 2c 20 74 6f 20 65 6e 63 | 6f 64 65 20 32 35 36 20 |, to enc|ode 256 |
|00001590| 64 69 73 74 69 6e 63 74 | 20 76 61 6c 75 65 73 2c |distinct| values,|
|000015a0| 20 79 6f 75 0a 58 6e 65 | 65 64 20 6c 6f 67 32 28 | you.Xne|ed log2(|
|000015b0| 32 35 36 29 20 3d 20 38 | 20 62 69 74 73 2e 20 4c |256) = 8| bits. L|
|000015c0| 65 74 27 73 20 74 68 69 | 6e 6b 20 6f 66 20 74 68 |et's thi|nk of th|
|000015d0| 65 20 69 6e 70 75 74 20 | 66 69 6c 65 20 62 65 66 |e input |file bef|
|000015e0| 6f 72 65 20 65 6e 63 6f | 64 69 6e 67 0a 58 61 73 |ore enco|ding.Xas|
|000015f0| 20 61 20 72 61 77 20 73 | 74 72 65 61 6d 20 6f 66 | a raw s|tream of|
|00001600| 20 62 69 74 73 20 77 69 | 74 68 6f 75 74 20 62 79 | bits wi|thout by|
|00001610| 74 65 20 62 6f 75 6e 64 | 61 72 69 65 73 2e 20 49 |te bound|aries. I|
|00001620| 66 20 77 65 20 77 61 6e | 74 20 74 6f 0a 58 72 65 |f we wan|t to.Xre|
|00001630| 70 72 65 73 65 6e 74 20 | 74 68 69 73 20 64 61 74 |present |this dat|
|00001640| 61 20 77 69 74 68 20 32 | 35 36 20 64 69 73 74 69 |a with 2|56 disti|
|00001650| 6e 63 74 20 63 68 61 72 | 61 63 74 65 72 73 2c 20 |nct char|acters, |
|00001660| 77 65 20 77 69 6c 6c 20 | 63 6f 6e 73 75 6d 65 20 |we will |consume |
|00001670| 38 0a 58 62 69 74 73 20 | 6f 66 20 74 68 65 20 69 |8.Xbits |of the i|
|00001680| 6e 70 75 74 20 62 69 74 | 73 74 72 65 61 6d 20 70 |nput bit|stream p|
|00001690| 65 72 20 6f 75 74 70 75 | 74 20 63 68 61 72 61 63 |er outpu|t charac|
|000016a0| 74 65 72 2e 20 54 68 69 | 73 20 69 73 20 68 6f 77 |ter. Thi|s is how|
|000016b0| 20 66 69 6c 65 73 0a 58 | 61 72 65 20 6e 6f 72 6d | files.X|are norm|
|000016c0| 61 6c 6c 79 20 65 6e 63 | 6f 64 65 64 2e 20 48 6f |ally enc|oded. Ho|
|000016d0| 77 65 76 65 72 2c 20 69 | 66 20 77 65 20 63 61 6e |wever, i|f we can|
|000016e0| 27 74 20 75 73 65 20 61 | 6c 6c 20 32 35 36 20 6f |'t use a|ll 256 o|
|000016f0| 75 74 70 75 74 0a 58 63 | 68 61 72 61 63 74 65 72 |utput.Xc|haracter|
|00001700| 73 2c 20 77 65 20 77 69 | 6c 6c 20 63 6f 6e 73 75 |s, we wi|ll consu|
|00001710| 6d 65 20 66 65 77 65 72 | 20 74 68 61 6e 20 38 20 |me fewer| than 8 |
|00001720| 69 6e 70 75 74 20 62 69 | 74 73 20 70 65 72 20 6f |input bi|ts per o|
|00001730| 75 74 70 75 74 0a 58 63 | 68 61 72 61 63 74 65 72 |utput.Xc|haracter|
|00001740| 2c 20 61 6e 64 20 74 68 | 75 73 20 77 65 20 77 69 |, and th|us we wi|
|00001750| 6c 6c 20 72 65 71 75 69 | 72 65 20 6d 6f 72 65 20 |ll requi|re more |
|00001760| 6f 75 74 70 75 74 20 63 | 68 61 72 61 63 74 65 72 |output c|haracter|
|00001770| 73 20 74 6f 0a 58 72 65 | 70 72 65 73 65 6e 74 20 |s to.Xre|present |
|00001780| 74 68 65 20 69 6e 70 75 | 74 20 62 69 74 73 74 72 |the inpu|t bitstr|
|00001790| 65 61 6d 20 74 68 61 6e | 20 69 66 20 77 65 20 68 |eam than| if we h|
|000017a0| 61 64 20 32 35 36 20 6f | 75 74 70 75 74 20 63 68 |ad 256 o|utput ch|
|000017b0| 61 72 61 63 74 65 72 73 | 2e 0a 58 54 68 75 73 2c |aracters|..XThus,|
|000017c0| 20 74 68 65 20 70 72 6f | 63 65 73 73 20 6f 66 20 | the pro|cess of |
|000017d0| 65 6e 63 6f 64 69 6e 67 | 20 61 20 62 69 6e 61 72 |encoding| a binar|
|000017e0| 79 20 66 69 6c 65 20 69 | 6e 20 70 72 69 6e 74 61 |y file i|n printa|
|000017f0| 62 6c 65 20 66 6f 72 6d | 61 74 20 77 69 6c 6c 0a |ble form|at will.|
|00001800| 58 6e 65 63 65 73 73 61 | 72 69 6c 79 20 65 78 70 |Xnecessa|rily exp|
|00001810| 61 6e 64 20 74 68 65 20 | 66 69 6c 65 2e 20 46 6f |and the |file. Fo|
|00001820| 72 20 65 78 61 6d 70 6c | 65 20 69 66 20 77 65 20 |r exampl|e if we |
|00001830| 75 73 65 20 74 68 65 20 | 39 35 20 70 72 69 6e 74 |use the |95 print|
|00001840| 61 62 6c 65 0a 58 63 68 | 61 72 61 63 74 65 72 73 |able.Xch|aracters|
|00001850| 2c 20 77 65 27 6c 6c 20 | 63 6f 6e 73 75 6d 65 20 |, we'll |consume |
|00001860| 61 6e 20 61 76 65 72 61 | 67 65 20 6f 66 20 6c 6f |an avera|ge of lo|
|00001870| 67 32 28 39 35 29 20 3d | 20 36 2e 35 37 20 62 69 |g2(95) =| 6.57 bi|
|00001880| 74 73 20 69 6e 20 74 68 | 65 0a 58 69 6e 70 75 74 |ts in th|e.Xinput|
|00001890| 20 73 74 72 65 61 6d 20 | 66 6f 72 20 65 61 63 68 | stream |for each|
|000018a0| 20 6f 75 74 70 75 74 20 | 63 68 61 72 61 63 74 65 | output |characte|
|000018b0| 72 2e 20 54 68 75 73 20 | 74 68 65 20 66 69 6c 65 |r. Thus |the file|
|000018c0| 20 77 69 6c 6c 20 62 65 | 20 65 78 70 61 6e 64 65 | will be| expande|
|000018d0| 64 0a 58 62 79 20 61 20 | 66 61 63 74 6f 72 20 6f |d.Xby a |factor o|
|000018e0| 66 20 6c 6f 67 32 28 32 | 35 36 29 2f 6c 6f 67 32 |f log2(2|56)/log2|
|000018f0| 28 39 35 29 20 3d 20 6c | 6f 67 28 32 35 36 29 2f |(95) = l|og(256)/|
|00001900| 6c 6f 67 28 39 35 29 20 | 3d 20 31 2e 32 31 37 20 |log(95) |= 1.217 |
|00001910| 6f 72 20 32 31 2e 37 25 | 2e 0a 58 4e 6f 74 65 20 |or 21.7%|..XNote |
|00001920| 74 68 61 74 20 74 68 69 | 73 20 69 73 20 61 20 74 |that thi|s is a t|
|00001930| 68 65 6f 72 65 74 69 63 | 61 6c 20 66 69 67 75 72 |heoretic|al figur|
|00001940| 65 2e 20 49 6e 20 70 72 | 61 63 74 69 63 65 2c 20 |e. In pr|actice, |
|00001950| 77 65 20 63 61 6e 27 74 | 0a 58 73 75 62 64 69 76 |we can't|.Xsubdiv|
|00001960| 69 64 65 20 62 69 74 73 | 2c 20 62 75 74 20 74 68 |ide bits|, but th|
|00001970| 69 73 20 66 69 67 75 72 | 65 20 64 6f 65 73 20 70 |is figur|e does p|
|00001980| 72 6f 76 69 64 65 20 61 | 20 74 68 65 6f 72 65 74 |rovide a| theoret|
|00001990| 69 63 61 6c 20 65 73 74 | 69 6d 61 74 65 20 6f 66 |ical est|imate of|
|000019a0| 0a 58 74 68 65 20 73 6d | 61 6c 6c 65 73 74 20 61 |.Xthe sm|allest a|
|000019b0| 6d 6f 75 6e 74 20 6f 66 | 20 65 78 70 61 6e 73 69 |mount of| expansi|
|000019c0| 6f 6e 20 77 65 20 63 61 | 6e 20 68 6f 70 65 20 74 |on we ca|n hope t|
|000019d0| 6f 20 67 65 74 20 77 69 | 74 68 20 6e 20 6f 75 74 |o get wi|th n out|
|000019e0| 70 75 74 0a 58 63 68 61 | 72 61 63 74 65 72 73 2e |put.Xcha|racters.|
|000019f0| 20 49 6e 20 70 72 61 63 | 74 69 63 65 20 73 6f 6d | In prac|tice som|
|00001a00| 65 20 63 6f 64 69 6e 67 | 20 73 63 68 65 6d 65 73 |e coding| schemes|
|00001a10| 20 73 68 6f 75 6c 64 20 | 62 65 20 61 62 6c 65 20 | should |be able |
|00001a20| 74 6f 20 64 6f 0a 58 62 | 65 74 74 65 72 20 66 6f |to do.Xb|etter fo|
|00001a30| 72 20 73 65 6c 65 63 74 | 20 63 61 73 65 73 2c 20 |r select| cases, |
|00001a40| 62 75 74 20 66 6f 72 20 | 61 20 76 65 72 79 20 6c |but for |a very l|
|00001a50| 61 72 67 65 20 73 61 6d | 70 6c 65 20 73 70 61 63 |arge sam|ple spac|
|00001a60| 65 20 6f 66 20 72 61 6e | 64 6f 6d 0a 58 64 61 74 |e of ran|dom.Xdat|
|00001a70| 61 2c 20 6e 6f 20 65 6e | 63 6f 64 69 6e 67 20 73 |a, no en|coding s|
|00001a80| 63 68 65 6d 65 20 73 68 | 6f 75 6c 64 20 65 76 65 |cheme sh|ould eve|
|00001a90| 72 20 62 65 20 61 62 6c | 65 20 74 6f 20 64 6f 20 |r be abl|e to do |
|00001aa0| 62 65 74 74 65 72 20 74 | 68 61 6e 20 74 68 69 73 |better t|han this|
|00001ab0| 0a 58 74 68 65 6f 72 65 | 74 69 63 61 6c 20 6c 69 |.Xtheore|tical li|
|00001ac0| 6d 69 74 2e 0a 58 0a 58 | 55 75 65 6e 63 6f 64 65 |mit..X.X|Uuencode|
|00001ad0| 20 6d 61 70 73 20 33 20 | 69 6e 70 75 74 20 63 68 | maps 3 |input ch|
|00001ae0| 61 72 61 63 74 65 72 73 | 20 74 6f 20 34 20 6f 75 |aracters| to 4 ou|
|00001af0| 74 70 75 74 20 63 68 61 | 72 61 63 74 65 72 73 20 |tput cha|racters |
|00001b00| 66 6f 72 20 61 6e 0a 58 | 65 78 70 61 6e 73 69 6f |for an.X|expansio|
|00001b10| 6e 20 6f 66 20 33 33 25 | 20 28 6e 6f 74 20 69 6e |n of 33%| (not in|
|00001b20| 63 6c 75 64 69 6e 67 20 | 63 6f 6e 74 72 6f 6c 20 |cluding |control |
|00001b30| 69 6e 66 6f 72 6d 61 74 | 69 6f 6e 29 2e 20 4c 61 |informat|ion). La|
|00001b40| 74 65 6c 79 20 73 65 76 | 65 72 61 6c 0a 58 65 6e |tely sev|eral.Xen|
|00001b50| 63 6f 64 69 6e 67 20 73 | 63 68 65 6d 65 73 20 77 |coding s|chemes w|
|00001b60| 68 69 63 68 20 6d 61 70 | 20 34 20 69 6e 70 75 74 |hich map| 4 input|
|00001b70| 20 63 68 61 72 61 63 74 | 65 72 73 20 74 6f 20 35 | charact|ers to 5|
|00001b80| 20 6f 75 74 70 75 74 20 | 63 68 61 72 61 63 74 65 | output |characte|
|00001b90| 72 73 0a 58 68 61 76 65 | 20 70 6f 70 70 65 64 20 |rs.Xhave| popped |
|00001ba0| 75 70 2c 20 66 6f 72 20 | 61 6e 20 65 78 70 61 6e |up, for |an expan|
|00001bb0| 73 69 6f 6e 20 6f 66 20 | 32 35 25 2e 0a 58 0a 58 |sion of |25%..X.X|
|00001bc0| 41 6e 20 61 6e 61 6c 79 | 73 69 73 20 6f 66 20 65 |An analy|sis of e|
|00001bd0| 6e 63 6f 64 65 20 73 68 | 6f 77 73 20 74 68 61 74 |ncode sh|ows that|
|00001be0| 20 74 68 65 20 61 76 65 | 72 61 67 65 20 65 78 70 | the ave|rage exp|
|00001bf0| 61 6e 73 69 6f 6e 20 6f | 76 65 72 20 61 20 76 65 |ansion o|ver a ve|
|00001c00| 72 79 0a 58 6c 61 72 67 | 65 20 69 6e 70 75 74 20 |ry.Xlarg|e input |
|00001c10| 66 69 6c 65 20 6f 66 20 | 72 61 6e 64 6f 6d 20 64 |file of |random d|
|00001c20| 61 74 61 20 69 73 20 0a | 58 38 20 2f 20 28 70 62 |ata is .|X8 / (pb|
|00001c30| 20 2d 20 32 20 2b 20 32 | 6e 2f 70 29 0a 58 77 68 | - 2 + 2|n/p).Xwh|
|00001c40| 65 72 65 20 6e 20 69 73 | 20 74 68 65 20 6e 75 6d |ere n is| the num|
|00001c50| 62 65 72 20 6f 66 20 6f | 75 74 70 75 74 20 63 68 |ber of o|utput ch|
|00001c60| 61 72 61 63 74 65 72 73 | 2c 20 70 20 69 73 20 74 |aracters|, p is t|
|00001c70| 68 65 20 73 6d 61 6c 6c | 65 73 74 20 70 6f 77 65 |he small|est powe|
|00001c80| 72 20 6f 66 0a 58 32 20 | 67 72 65 61 74 65 72 20 |r of.X2 |greater |
|00001c90| 74 68 61 6e 20 6f 72 20 | 65 71 75 61 6c 20 74 6f |than or |equal to|
|00001ca0| 20 6e 2c 20 61 6e 64 20 | 70 62 20 69 73 20 6c 6f | n, and |pb is lo|
|00001cb0| 67 32 28 70 29 2c 20 6f | 72 20 74 68 65 20 6e 75 |g2(p), o|r the nu|
|00001cc0| 6d 62 65 72 20 6f 66 20 | 62 69 74 73 0a 58 6e 65 |mber of |bits.Xne|
|00001cd0| 65 64 65 64 20 74 6f 20 | 72 65 70 72 65 73 65 6e |eded to |represen|
|00001ce0| 74 20 70 20 76 61 6c 75 | 65 73 2e 20 41 20 67 72 |t p valu|es. A gr|
|00001cf0| 61 70 68 20 6f 66 20 74 | 68 69 73 20 66 75 6e 63 |aph of t|his func|
|00001d00| 74 69 6f 6e 20 66 6f 72 | 20 76 61 6c 75 65 73 20 |tion for| values |
|00001d10| 6f 66 20 6e 0a 58 66 72 | 6f 6d 20 32 20 74 6f 20 |of n.Xfr|om 2 to |
|00001d20| 32 35 36 20 73 68 6f 77 | 73 20 61 20 76 65 72 79 |256 show|s a very|
|00001d30| 20 63 6c 6f 73 65 20 61 | 70 70 72 6f 78 69 6d 61 | close a|pproxima|
|00001d40| 74 69 6f 6e 20 6f 66 20 | 74 68 65 20 74 68 65 6f |tion of |the theo|
|00001d50| 72 65 74 69 63 61 6c 0a | 58 65 78 70 61 6e 73 69 |retical.|Xexpansi|
|00001d60| 6f 6e 20 6f 66 20 6c 6f | 67 28 32 35 36 29 2f 6c |on of lo|g(256)/l|
|00001d70| 6f 67 28 6e 29 2e 20 46 | 6f 72 20 65 78 61 6d 70 |og(n). F|or examp|
|00001d80| 6c 65 2c 20 66 6f 72 20 | 6e 20 3d 20 39 35 2c 20 |le, for |n = 95, |
|00001d90| 74 68 65 20 65 78 70 61 | 6e 73 69 6f 6e 0a 58 66 |the expa|nsion.Xf|
|00001da0| 61 63 74 6f 72 20 69 73 | 0a 58 38 20 2f 20 28 37 |actor is|.X8 / (7|
|00001db0| 20 2d 20 32 20 2b 20 32 | 2a 39 35 2f 31 32 38 29 | - 2 + 2|*95/128)|
|00001dc0| 20 3d 20 31 2e 32 33 34 | 20 6f 72 20 32 33 2e 34 | = 1.234| or 23.4|
|00001dd0| 25 0a 58 0a 58 4e 6f 74 | 65 20 74 68 61 74 20 61 |%.X.XNot|e that a|
|00001de0| 6c 6c 20 65 78 70 61 6e | 73 69 6f 6e 20 66 61 63 |ll expan|sion fac|
|00001df0| 74 6f 72 73 20 67 69 76 | 65 6e 20 61 62 6f 76 65 |tors giv|en above|
|00001e00| 20 66 61 69 6c 20 74 6f | 20 74 61 6b 65 20 69 6e | fail to| take in|
|00001e10| 74 6f 20 61 63 63 6f 75 | 6e 74 0a 58 74 68 65 20 |to accou|nt.Xthe |
|00001e20| 61 64 64 69 74 69 6f 6e | 20 6f 66 20 6e 65 77 6c |addition| of newl|
|00001e30| 69 6e 65 20 63 68 61 72 | 61 63 74 65 72 73 20 74 |ine char|acters t|
|00001e40| 6f 20 6c 69 6d 69 74 20 | 6f 75 74 70 75 74 20 77 |o limit |output w|
|00001e50| 69 64 74 68 2e 0a 58 0a | 58 2d 2d 2d 2d 2d 2d 2d |idth..X.|X-------|
|00001e60| 2d 2d 2d 2d 20 54 68 65 | 20 65 6e 63 6f 64 69 6e |---- The| encodin|
|00001e70| 67 20 70 72 6f 63 65 73 | 73 3a 0a 58 0a 58 54 68 |g proces|s:.X.XTh|
|00001e80| 65 20 65 6e 63 6f 64 69 | 6e 67 20 70 72 6f 63 65 |e encodi|ng proce|
|00001e90| 73 73 20 75 73 65 64 20 | 62 79 20 65 6e 63 6f 64 |ss used |by encod|
|00001ea0| 65 20 69 73 20 73 69 6d | 70 6c 79 20 74 6f 20 74 |e is sim|ply to t|
|00001eb0| 68 72 6f 77 20 61 77 61 | 79 20 74 68 65 20 62 79 |hrow awa|y the by|
|00001ec0| 74 65 0a 58 62 6f 75 6e | 64 61 72 69 65 73 20 69 |te.Xboun|daries i|
|00001ed0| 6e 20 74 68 65 20 69 6e | 70 75 74 20 62 69 74 73 |n the in|put bits|
|00001ee0| 74 72 65 61 6d 20 61 6e | 64 20 69 6e 73 65 72 74 |tream an|d insert|
|00001ef0| 20 6e 65 77 20 62 79 74 | 65 20 62 6f 75 6e 64 61 | new byt|e bounda|
|00001f00| 72 69 65 73 20 69 6e 0a | 58 73 75 63 68 20 61 20 |ries in.|Xsuch a |
|00001f10| 6d 61 6e 6e 65 72 20 74 | 68 61 74 20 74 68 65 72 |manner t|hat ther|
|00001f20| 65 20 61 72 65 20 6f 6e | 6c 79 20 6e 20 64 69 73 |e are on|ly n dis|
|00001f30| 74 69 6e 63 74 20 22 74 | 6f 6b 65 6e 73 22 20 69 |tinct "t|okens" i|
|00001f40| 6e 20 74 68 65 20 69 6e | 70 75 74 0a 58 73 74 72 |n the in|put.Xstr|
|00001f50| 65 61 6d 20 77 68 65 72 | 65 20 6e 20 69 73 20 74 |eam wher|e n is t|
|00001f60| 68 65 20 6e 75 6d 62 65 | 72 20 6f 66 20 6f 75 74 |he numbe|r of out|
|00001f70| 70 75 74 20 63 68 61 72 | 61 63 74 65 72 73 2e 20 |put char|acters. |
|00001f80| 54 68 65 73 65 20 74 6f | 6b 65 6e 73 20 63 61 6e |These to|kens can|
|00001f90| 0a 58 74 68 65 6e 20 62 | 65 20 6d 61 70 70 65 64 |.Xthen b|e mapped|
|00001fa0| 20 6f 6e 65 2d 74 6f 2d | 6f 6e 65 20 77 69 74 68 | one-to-|one with|
|00001fb0| 20 74 68 65 20 6f 75 74 | 70 75 74 20 63 68 61 72 | the out|put char|
|00001fc0| 61 63 74 65 72 73 2c 20 | 62 6f 74 68 20 64 75 72 |acters, |both dur|
|00001fd0| 69 6e 67 0a 58 65 6e 63 | 6f 64 69 6e 67 20 61 6e |ing.Xenc|oding an|
|00001fe0| 64 20 64 65 63 6f 64 69 | 6e 67 2e 20 41 20 67 6f |d decodi|ng. A go|
|00001ff0| 6f 64 20 65 78 61 6d 70 | 6c 65 20 6f 66 20 74 68 |od examp|le of th|
|00002000| 69 73 20 70 72 6f 63 65 | 73 73 20 69 73 20 75 75 |is proce|ss is uu|
|00002010| 65 6e 63 6f 64 65 2c 0a | 58 77 68 69 63 68 20 64 |encode,.|Xwhich d|
|00002020| 69 73 63 61 72 64 73 20 | 74 68 65 20 62 79 74 65 |iscards |the byte|
|00002030| 20 62 6f 75 6e 64 61 72 | 69 65 73 20 77 68 69 63 | boundar|ies whic|
|00002040| 68 20 6f 63 63 75 72 20 | 65 76 65 72 79 20 38 20 |h occur |every 8 |
|00002050| 62 69 74 73 20 61 6e 64 | 0a 58 69 6e 73 65 72 74 |bits and|.Xinsert|
|00002060| 73 20 62 79 74 65 20 62 | 6f 75 6e 64 61 72 69 65 |s byte b|oundarie|
|00002070| 73 20 65 76 65 72 79 20 | 36 20 62 69 74 73 2e 20 |s every |6 bits. |
|00002080| 54 68 65 20 72 65 73 75 | 6c 74 20 69 73 20 61 20 |The resu|lt is a |
|00002090| 73 65 72 69 65 73 20 6f | 66 20 74 6f 6b 65 6e 73 |series o|f tokens|
|000020a0| 0a 58 77 69 74 68 20 61 | 20 6d 61 78 69 6d 75 6d |.Xwith a| maximum|
|000020b0| 20 6f 66 20 36 34 20 70 | 6f 73 73 69 62 6c 65 20 | of 64 p|ossible |
|000020c0| 76 61 6c 75 65 73 2c 20 | 65 61 63 68 20 6f 66 20 |values, |each of |
|000020d0| 77 68 69 63 68 20 69 73 | 20 6d 61 70 70 65 64 0a |which is| mapped.|
|000020e0| 58 6f 6e 65 2d 74 6f 2d | 6f 6e 65 20 77 69 74 68 |Xone-to-|one with|
|000020f0| 20 74 68 65 20 6f 75 74 | 70 75 74 20 63 68 61 72 | the out|put char|
|00002100| 61 63 74 65 72 20 73 65 | 74 20 6f 66 20 36 34 20 |acter se|t of 64 |
|00002110| 70 72 69 6e 74 61 62 6c | 65 20 63 68 61 72 61 63 |printabl|e charac|
|00002120| 74 65 72 73 2e 0a 58 54 | 68 69 73 20 70 72 6f 63 |ters..XT|his proc|
|00002130| 65 73 73 20 69 73 20 74 | 72 69 76 69 61 6c 20 66 |ess is t|rivial f|
|00002140| 6f 72 20 61 6e 79 20 6e | 20 77 68 69 63 68 20 69 |or any n| which i|
|00002150| 73 20 61 20 70 6f 77 65 | 72 20 6f 66 20 74 77 6f |s a powe|r of two|
|00002160| 2c 20 79 6f 75 20 73 69 | 6d 70 6c 79 0a 58 69 6e |, you si|mply.Xin|
|00002170| 73 65 72 74 20 62 79 74 | 65 20 62 6f 75 6e 64 61 |sert byt|e bounda|
|00002180| 72 69 65 73 20 65 76 65 | 72 79 20 6c 6f 67 32 28 |ries eve|ry log2(|
|00002190| 6e 29 20 62 69 74 73 2e | 20 57 68 65 6e 20 6e 20 |n) bits.| When n |
|000021a0| 69 73 20 6e 6f 74 20 61 | 20 70 6f 77 65 72 20 6f |is not a| power o|
|000021b0| 66 20 32 2c 0a 58 68 6f | 77 65 76 65 72 2c 20 74 |f 2,.Xho|wever, t|
|000021c0| 68 65 20 70 72 6f 63 65 | 73 73 20 69 73 20 73 6f |he proce|ss is so|
|000021d0| 6d 65 77 68 61 74 20 6d | 6f 72 65 20 63 6f 6d 70 |mewhat m|ore comp|
|000021e0| 6c 69 63 61 74 65 64 2e | 0a 58 0a 58 57 65 20 63 |licated.|.X.XWe c|
|000021f0| 61 6e 20 6e 6f 20 6c 6f | 6e 67 65 72 20 69 6e 73 |an no lo|nger ins|
|00002200| 65 72 74 20 74 68 65 20 | 62 79 74 65 20 62 6f 75 |ert the |byte bou|
|00002210| 6e 64 61 72 69 65 73 20 | 61 74 20 72 65 67 75 6c |ndaries |at regul|
|00002220| 61 72 20 69 6e 74 65 72 | 76 61 6c 73 20 6f 66 20 |ar inter|vals of |
|00002230| 62 0a 58 62 69 74 73 2c | 20 73 69 6e 63 65 20 74 |b.Xbits,| since t|
|00002240| 68 69 73 20 77 6f 75 6c | 64 20 69 6d 70 6c 79 20 |his woul|d imply |
|00002250| 32 5e 62 20 6f 75 74 70 | 75 74 20 63 68 61 72 61 |2^b outp|ut chara|
|00002260| 63 74 65 72 73 2e 20 49 | 66 20 77 65 20 73 65 6c |cters. I|f we sel|
|00002270| 65 63 74 20 62 0a 58 73 | 75 63 68 20 74 68 61 74 |ect b.Xs|uch that|
|00002280| 20 32 5e 62 20 3c 20 6e | 2c 20 74 68 65 6e 20 77 | 2^b < n|, then w|
|00002290| 65 20 61 72 65 6e 27 74 | 20 75 73 69 6e 67 20 61 |e aren't| using a|
|000022a0| 6c 6c 20 6e 20 6f 75 74 | 70 75 74 20 63 68 61 72 |ll n out|put char|
|000022b0| 61 63 74 65 72 73 2c 20 | 61 6e 64 0a 58 77 65 27 |acters, |and.Xwe'|
|000022c0| 72 65 20 65 78 70 61 6e | 64 69 6e 67 20 74 68 65 |re expan|ding the|
|000022d0| 20 66 69 6c 65 20 6d 6f | 72 65 20 74 68 61 6e 20 | file mo|re than |
|000022e0| 6e 65 63 65 73 73 61 72 | 79 2e 20 4f 6e 20 74 68 |necessar|y. On th|
|000022f0| 65 20 6f 74 68 65 72 20 | 68 61 6e 64 20 69 66 20 |e other |hand if |
|00002300| 77 65 0a 58 73 65 6c 65 | 63 74 20 62 20 73 75 63 |we.Xsele|ct b suc|
|00002310| 68 20 74 68 61 74 20 32 | 5e 62 20 3e 20 6e 2c 20 |h that 2|^b > n, |
|00002320| 77 65 20 64 6f 6e 27 74 | 20 68 61 76 65 20 65 6e |we don't| have en|
|00002330| 6f 75 67 68 20 6f 75 74 | 70 75 74 20 63 68 61 72 |ough out|put char|
|00002340| 61 63 74 65 72 73 20 74 | 6f 0a 58 65 6e 63 6f 64 |acters t|o.Xencod|
|00002350| 65 20 74 68 65 20 64 61 | 74 61 2e 20 54 68 65 20 |e the da|ta. The |
|00002360| 73 6f 6c 75 74 69 6f 6e | 20 69 73 20 74 6f 20 73 |solution| is to s|
|00002370| 74 61 72 74 20 77 69 74 | 68 20 74 68 65 20 73 6d |tart wit|h the sm|
|00002380| 61 6c 6c 65 73 74 20 62 | 20 73 75 63 68 0a 58 74 |allest b| such.Xt|
|00002390| 68 61 74 20 32 5e 62 20 | 3e 3d 20 6e 20 61 6e 64 |hat 2^b |>= n and|
|000023a0| 20 74 68 65 6e 20 65 6c | 69 6d 69 6e 61 74 65 20 | then el|iminate |
|000023b0| 73 6f 6d 65 20 6f 66 20 | 74 68 65 20 69 6e 70 75 |some of |the inpu|
|000023c0| 74 20 74 6f 6b 65 6e 73 | 20 75 6e 74 69 6c 20 74 |t tokens| until t|
|000023d0| 68 65 72 65 0a 58 61 72 | 65 20 65 78 61 63 74 6c |here.Xar|e exactl|
|000023e0| 79 20 6e 20 6f 66 20 74 | 68 65 6d 2c 20 74 68 65 |y n of t|hem, the|
|000023f0| 6e 20 77 65 20 63 61 6e | 20 6d 61 70 20 6f 6e 65 |n we can| map one|
|00002400| 2d 74 6f 2d 6f 6e 65 20 | 77 69 74 68 20 74 68 65 |-to-one |with the|
|00002410| 20 6f 75 74 70 75 74 0a | 58 63 68 61 72 61 63 74 | output.|Xcharact|
|00002420| 65 72 73 2e 20 49 6e 70 | 75 74 20 74 6f 6b 65 6e |ers. Inp|ut token|
|00002430| 73 20 63 61 6e 20 62 65 | 20 65 6c 69 6d 69 6e 61 |s can be| elimina|
|00002440| 74 65 64 20 62 79 20 74 | 61 6b 69 6e 67 20 74 77 |ted by t|aking tw|
|00002450| 6f 20 69 6e 70 75 74 20 | 74 6f 6b 65 6e 73 0a 58 |o input |tokens.X|
|00002460| 61 6e 64 20 63 6f 6d 62 | 69 6e 69 6e 67 20 74 68 |and comb|ining th|
|00002470| 65 6d 20 74 6f 20 66 6f | 72 6d 20 61 20 73 69 6e |em to fo|rm a sin|
|00002480| 67 6c 65 2c 20 73 68 6f | 72 74 65 72 20 74 6f 6b |gle, sho|rter tok|
|00002490| 65 6e 2e 20 54 68 69 73 | 20 69 73 20 62 65 73 74 |en. This| is best|
|000024a0| 0a 58 65 78 70 6c 61 69 | 6e 65 64 20 62 79 20 67 |.Xexplai|ned by g|
|000024b0| 69 76 69 6e 67 20 61 6e | 20 65 78 61 6d 70 6c 65 |iving an| example|
|000024c0| 2e 0a 58 0a 58 4c 65 74 | 27 73 20 73 61 79 20 77 |..X.XLet|'s say w|
|000024d0| 65 20 68 61 76 65 20 36 | 20 6f 75 74 70 75 74 20 |e have 6| output |
|000024e0| 63 68 61 72 61 63 74 65 | 72 73 2e 20 57 65 20 73 |characte|rs. We s|
|000024f0| 74 61 72 74 20 77 69 74 | 68 20 38 20 69 6e 70 75 |tart wit|h 8 inpu|
|00002500| 74 20 74 6f 6b 65 6e 73 | 3a 0a 58 30 30 30 2c 30 |t tokens|:.X000,0|
|00002510| 30 31 2c 30 31 30 2c 30 | 31 31 2c 31 30 30 2c 31 |01,010,0|11,100,1|
|00002520| 30 31 2c 31 31 30 2c 31 | 31 31 0a 58 54 68 69 73 |01,110,1|11.XThis|
|00002530| 20 73 65 74 20 6f 66 20 | 74 6f 6b 65 6e 73 20 68 | set of |tokens h|
|00002540| 61 73 20 74 68 65 20 70 | 72 6f 70 65 72 74 79 20 |as the p|roperty |
|00002550| 74 68 61 74 20 61 6e 79 | 20 69 6e 70 75 74 20 62 |that any| input b|
|00002560| 69 74 73 74 72 65 61 6d | 20 63 61 6e 0a 58 62 65 |itstream| can.Xbe|
|00002570| 20 62 72 6f 6b 65 6e 20 | 64 6f 77 6e 20 74 6f 20 | broken |down to |
|00002580| 61 20 73 65 72 69 65 73 | 20 6f 66 20 74 68 65 73 |a series| of thes|
|00002590| 65 20 74 6f 6b 65 6e 73 | 20 69 6e 20 65 78 61 63 |e tokens| in exac|
|000025a0| 74 6c 79 20 6f 6e 65 20 | 77 61 79 2e 0a 58 4e 6f |tly one |way..XNo|
|000025b0| 77 20 6c 65 74 27 73 20 | 63 6f 6d 62 69 6e 65 20 |w let's |combine |
|000025c0| 74 77 6f 20 6f 66 20 74 | 68 65 20 74 6f 6b 65 6e |two of t|he token|
|000025d0| 73 2e 20 54 68 65 20 74 | 6f 6b 65 6e 73 20 74 6f |s. The t|okens to|
|000025e0| 20 62 65 20 63 6f 6d 62 | 69 6e 65 64 20 6d 75 73 | be comb|ined mus|
|000025f0| 74 0a 58 68 61 76 65 20 | 69 64 65 6e 74 69 63 61 |t.Xhave |identica|
|00002600| 6c 20 62 69 74 73 20 65 | 78 63 65 70 74 20 66 6f |l bits e|xcept fo|
|00002610| 72 20 74 68 65 20 6c 61 | 73 74 20 62 69 74 2c 20 |r the la|st bit, |
|00002620| 61 6e 64 20 74 68 65 20 | 70 72 6f 63 65 73 73 20 |and the |process |
|00002630| 6f 66 0a 58 63 6f 6d 62 | 69 6e 69 6e 67 20 73 74 |of.Xcomb|ining st|
|00002640| 72 69 70 73 20 74 68 61 | 74 20 62 69 74 20 66 72 |rips tha|t bit fr|
|00002650| 6f 6d 20 74 68 65 20 74 | 6f 6b 65 6e 73 2e 20 65 |om the t|okens. e|
|00002660| 2e 67 2e 20 31 31 30 20 | 61 6e 64 20 31 31 31 20 |.g. 110 |and 111 |
|00002670| 63 61 6e 20 62 65 0a 58 | 63 6f 6d 62 69 6e 65 64 |can be.X|combined|
|00002680| 20 69 6e 74 6f 20 74 68 | 65 20 74 6f 6b 65 6e 20 | into th|e token |
|00002690| 31 31 2c 20 73 6f 20 77 | 65 20 6e 6f 77 20 68 61 |11, so w|e now ha|
|000026a0| 76 65 20 74 68 65 20 74 | 6f 6b 65 6e 20 73 65 74 |ve the t|oken set|
|000026b0| 0a 58 30 30 30 2c 30 30 | 31 2c 30 31 30 2c 30 31 |.X000,00|1,010,01|
|000026c0| 31 2c 31 30 30 2c 31 30 | 31 2c 31 31 0a 58 49 66 |1,100,10|1,11.XIf|
|000026d0| 20 77 65 20 63 6f 6d 62 | 69 6e 65 20 74 77 6f 20 | we comb|ine two |
|000026e0| 6d 6f 72 65 20 74 6f 6b | 65 6e 73 2c 20 31 30 30 |more tok|ens, 100|
|000026f0| 20 61 6e 64 20 31 30 31 | 20 2d 3e 20 31 30 2c 20 | and 101| -> 10, |
|00002700| 77 65 20 67 65 74 0a 58 | 30 30 30 2c 30 30 31 2c |we get.X|000,001,|
|00002710| 30 31 30 2c 30 31 31 2c | 31 30 2c 31 31 0a 58 54 |010,011,|10,11.XT|
|00002720| 68 69 73 20 74 6f 6b 65 | 6e 20 73 65 74 20 73 74 |his toke|n set st|
|00002730| 69 6c 6c 20 68 61 73 20 | 74 68 65 20 70 72 6f 70 |ill has |the prop|
|00002740| 65 72 74 79 20 74 68 61 | 74 20 61 6e 79 20 69 6e |erty tha|t any in|
|00002750| 70 75 74 20 62 69 74 73 | 74 72 65 61 6d 20 63 61 |put bits|tream ca|
|00002760| 6e 20 62 65 0a 58 62 72 | 6f 6b 65 6e 20 64 6f 77 |n be.Xbr|oken dow|
|00002770| 6e 20 69 6e 74 6f 20 61 | 20 73 65 72 69 65 73 20 |n into a| series |
|00002780| 6f 66 20 74 68 65 73 65 | 20 74 6f 6b 65 6e 73 20 |of these| tokens |
|00002790| 69 6e 20 65 78 61 63 74 | 6c 79 20 6f 6e 65 20 77 |in exact|ly one w|
|000027a0| 61 79 2c 20 61 6e 64 0a | 58 73 69 6e 63 65 20 74 |ay, and.|Xsince t|
|000027b0| 68 65 72 65 20 61 72 65 | 20 36 20 6f 66 20 74 68 |here are| 6 of th|
|000027c0| 65 6d 2c 20 77 65 20 63 | 61 6e 20 6d 61 70 20 6f |em, we c|an map o|
|000027d0| 6e 65 2d 74 6f 2d 6f 6e | 65 20 77 69 74 68 20 74 |ne-to-on|e with t|
|000027e0| 68 65 20 6f 75 74 70 75 | 74 0a 58 63 68 61 72 61 |he outpu|t.Xchara|
|000027f0| 63 74 65 72 20 73 65 74 | 2e 0a 58 0a 58 54 68 65 |cter set|..X.XThe|
|00002800| 20 73 74 61 6e 64 61 72 | 64 20 66 6f 72 20 74 68 | standar|d for th|
|00002810| 65 20 67 65 6e 65 72 61 | 74 69 6f 6e 20 6f 66 20 |e genera|tion of |
|00002820| 74 68 65 73 65 20 74 6f | 6b 65 6e 73 20 77 69 6c |these to|kens wil|
|00002830| 6c 20 62 65 20 61 73 20 | 66 6f 6c 6c 6f 77 73 3a |l be as |follows:|
|00002840| 0a 58 53 74 61 72 74 20 | 77 69 74 68 20 32 5e 62 |.XStart |with 2^b|
|00002850| 20 64 69 73 74 69 6e 63 | 74 20 74 6f 6b 65 6e 73 | distinc|t tokens|
|00002860| 20 6f 66 20 6c 65 6e 67 | 74 68 20 62 20 62 69 74 | of leng|th b bit|
|00002870| 73 2c 20 77 68 65 72 65 | 20 62 20 69 73 20 74 68 |s, where| b is th|
|00002880| 65 0a 58 73 6d 61 6c 6c | 65 73 74 20 69 6e 74 65 |e.Xsmall|est inte|
|00002890| 67 65 72 20 73 75 63 68 | 20 74 68 61 74 20 32 5e |ger such| that 2^|
|000028a0| 62 20 3e 3d 20 6e 2c 20 | 77 68 65 72 65 20 6e 20 |b >= n, |where n |
|000028b0| 69 73 20 74 68 65 20 6e | 75 6d 62 65 72 20 6f 66 |is the n|umber of|
|000028c0| 20 6f 75 74 70 75 74 0a | 58 63 68 61 72 61 63 74 | output.|Xcharact|
|000028d0| 65 72 73 2e 20 54 68 65 | 6e 2c 20 61 73 20 61 62 |ers. The|n, as ab|
|000028e0| 6f 76 65 2c 20 77 68 69 | 6c 65 20 74 68 65 72 65 |ove, whi|le there|
|000028f0| 20 61 72 65 20 6d 6f 72 | 65 20 74 68 61 6e 20 6e | are mor|e than n|
|00002900| 20 74 6f 6b 65 6e 73 20 | 6f 66 20 61 6e 79 0a 58 | tokens |of any.X|
|00002910| 6c 65 6e 67 74 68 2c 20 | 72 65 70 6c 61 63 65 20 |length, |replace |
|00002920| 74 68 65 20 74 77 6f 20 | 6e 75 6d 65 72 69 63 61 |the two |numerica|
|00002930| 6c 6c 79 20 67 72 65 61 | 74 65 73 74 20 62 20 6c |lly grea|test b l|
|00002940| 65 6e 67 74 68 20 74 6f | 6b 65 6e 73 20 77 69 74 |ength to|kens wit|
|00002950| 68 20 61 0a 58 73 69 6e | 67 6c 65 20 62 2d 31 20 |h a.Xsin|gle b-1 |
|00002960| 6c 65 6e 67 74 68 20 74 | 6f 6b 65 6e 20 73 75 63 |length t|oken suc|
|00002970| 68 20 74 68 61 74 20 74 | 68 65 20 62 2d 31 20 6c |h that t|he b-1 l|
|00002980| 65 6e 67 74 68 20 74 6f | 6b 65 6e 20 69 73 20 65 |ength to|ken is e|
|00002990| 71 75 69 76 61 6c 65 6e | 74 0a 58 74 6f 20 74 68 |quivalen|t.Xto th|
|000029a0| 65 20 62 2d 31 20 6d 6f | 73 74 20 73 69 67 6e 69 |e b-1 mo|st signi|
|000029b0| 66 69 63 61 6e 74 20 62 | 69 74 73 20 6f 66 20 65 |ficant b|its of e|
|000029c0| 69 74 68 65 72 20 62 20 | 6c 65 6e 67 74 68 20 74 |ither b |length t|
|000029d0| 6f 6b 65 6e 2e 20 28 49 | 74 20 69 73 0a 58 61 73 |oken. (I|t is.Xas|
|000029e0| 73 65 72 74 65 64 20 74 | 68 61 74 20 61 74 20 61 |serted t|hat at a|
|000029f0| 6e 79 20 74 69 6d 65 20 | 69 6e 20 74 68 65 20 70 |ny time |in the p|
|00002a00| 72 6f 63 65 64 75 72 65 | 2c 20 74 68 65 20 74 77 |rocedure|, the tw|
|00002a10| 6f 20 6e 75 6d 65 72 69 | 63 61 6c 6c 79 0a 58 67 |o numeri|cally.Xg|
|00002a20| 72 65 61 74 65 73 74 20 | 62 20 6c 65 6e 67 74 68 |reatest |b length|
|00002a30| 20 74 6f 6b 65 6e 73 20 | 64 69 66 66 65 72 20 6f | tokens |differ o|
|00002a40| 6e 6c 79 20 69 6e 20 74 | 68 65 20 6c 65 61 73 74 |nly in t|he least|
|00002a50| 20 73 69 67 6e 69 66 69 | 63 61 6e 74 20 62 69 74 | signifi|cant bit|
|00002a60| 29 2e 0a 58 0a 58 54 68 | 65 20 73 74 61 6e 64 61 |)..X.XTh|e standa|
|00002a70| 72 64 20 66 6f 72 20 74 | 68 65 20 6f 6e 65 2d 74 |rd for t|he one-t|
|00002a80| 6f 2d 6f 6e 65 20 6d 61 | 70 70 69 6e 67 20 62 65 |o-one ma|pping be|
|00002a90| 74 77 65 65 6e 20 74 6f | 6b 65 6e 73 20 61 6e 64 |tween to|kens and|
|00002aa0| 20 6f 75 74 70 75 74 0a | 58 63 68 61 72 61 63 74 | output.|Xcharact|
|00002ab0| 65 72 73 20 77 69 6c 6c | 20 62 65 20 61 73 20 66 |ers will| be as f|
|00002ac0| 6f 6c 6c 6f 77 73 3a 20 | 74 6f 6b 65 6e 73 20 77 |ollows: |tokens w|
|00002ad0| 69 6c 6c 20 62 65 20 73 | 6f 72 74 65 64 20 73 75 |ill be s|orted su|
|00002ae0| 63 68 20 74 68 61 74 20 | 61 6c 6c 20 62 0a 58 6c |ch that |all b.Xl|
|00002af0| 65 6e 67 74 68 20 74 6f | 6b 65 6e 73 20 63 6f 6d |ength to|kens com|
|00002b00| 65 20 66 69 72 73 74 2c | 20 69 6e 20 6e 75 6d 65 |e first,| in nume|
|00002b10| 72 69 63 61 6c 20 6f 72 | 64 65 72 2c 20 66 6f 6c |rical or|der, fol|
|00002b20| 6c 6f 77 65 64 20 62 79 | 20 61 6c 6c 20 62 2d 31 |lowed by| all b-1|
|00002b30| 0a 58 6c 65 6e 67 74 68 | 20 74 6f 6b 65 6e 73 2c |.Xlength| tokens,|
|00002b40| 20 69 6e 20 6e 75 6d 65 | 72 69 63 61 6c 20 6f 72 | in nume|rical or|
|00002b50| 64 65 72 2e 20 4f 75 74 | 70 75 74 20 63 68 61 72 |der. Out|put char|
|00002b60| 61 63 74 65 72 73 20 77 | 69 6c 6c 20 62 65 20 73 |acters w|ill be s|
|00002b70| 6f 72 74 65 64 20 62 79 | 0a 58 61 73 63 69 69 20 |orted by|.Xascii |
|00002b80| 63 6f 64 65 20 69 6e 20 | 6e 75 6d 65 72 69 63 61 |code in |numerica|
|00002b90| 6c 20 6f 72 64 65 72 2e | 20 41 20 6f 6e 65 2d 74 |l order.| A one-t|
|00002ba0| 6f 2d 6f 6e 65 20 6d 61 | 70 70 69 6e 67 20 77 69 |o-one ma|pping wi|
|00002bb0| 6c 6c 20 62 65 0a 58 65 | 73 74 61 62 6c 69 73 68 |ll be.Xe|stablish|
|00002bc0| 65 64 20 62 65 74 77 65 | 65 6e 20 74 68 65 73 65 |ed betwe|en these|
|00002bd0| 20 74 77 6f 20 73 65 74 | 73 2e 0a 58 0a 58 54 68 | two set|s..X.XTh|
|00002be0| 65 20 73 74 61 6e 64 61 | 72 64 20 66 6f 72 20 74 |e standa|rd for t|
|00002bf0| 68 65 20 63 68 65 63 6b | 73 75 6d 20 77 69 6c 6c |he check|sum will|
|00002c00| 20 62 65 20 61 73 20 66 | 6f 6c 6c 6f 77 73 3a 20 | be as f|ollows: |
|00002c10| 54 68 65 20 63 68 65 63 | 6b 73 75 6d 20 77 69 6c |The chec|ksum wil|
|00002c20| 6c 20 62 65 0a 58 63 6f | 6d 70 75 74 65 64 20 6f |l be.Xco|mputed o|
|00002c30| 6e 20 74 68 65 20 64 65 | 63 6f 64 65 64 20 64 61 |n the de|coded da|
|00002c40| 74 61 2e 20 49 74 20 77 | 69 6c 6c 20 62 65 20 33 |ta. It w|ill be 3|
|00002c50| 32 20 62 69 74 73 20 77 | 69 64 65 2e 20 46 6f 72 |2 bits w|ide. For|
|00002c60| 20 65 61 63 68 0a 58 63 | 68 61 72 61 63 74 65 72 | each.Xc|haracter|
|00002c70| 20 72 65 61 64 20 66 72 | 6f 6d 20 74 68 65 20 69 | read fr|om the i|
|00002c80| 6e 70 75 74 20 66 69 6c | 65 20 64 75 72 69 6e 67 |nput fil|e during|
|00002c90| 20 65 6e 63 6f 64 69 6e | 67 20 6f 72 20 77 72 69 | encodin|g or wri|
|00002ca0| 74 74 65 6e 20 74 6f 20 | 74 68 65 0a 58 6f 75 74 |tten to |the.Xout|
|00002cb0| 70 75 74 20 66 69 6c 65 | 20 64 69 72 69 6e 67 20 |put file| diring |
|00002cc0| 64 65 63 6f 64 69 6e 67 | 2c 20 74 68 65 20 63 68 |decoding|, the ch|
|00002cd0| 65 63 6b 73 75 6d 20 77 | 69 6c 6c 20 66 69 72 73 |ecksum w|ill firs|
|00002ce0| 74 20 62 65 20 72 6f 6c | 6c 65 64 20 37 20 62 69 |t be rol|led 7 bi|
|00002cf0| 74 73 0a 58 74 6f 20 74 | 68 65 20 6c 65 66 74 20 |ts.Xto t|he left |
|00002d00| 28 74 68 65 20 37 20 62 | 69 74 73 20 77 68 69 63 |(the 7 b|its whic|
|00002d10| 68 20 73 6c 69 64 65 20 | 6f 66 66 20 74 68 65 20 |h slide |off the |
|00002d20| 4d 53 42 20 65 6e 64 20 | 77 69 6c 6c 20 62 65 20 |MSB end |will be |
|00002d30| 72 65 69 6e 73 65 72 74 | 65 64 0a 58 69 6e 74 6f |reinsert|ed.Xinto|
|00002d40| 20 74 68 65 20 4c 53 42 | 20 65 6e 64 29 20 61 6e | the LSB| end) an|
|00002d50| 64 20 74 68 65 6e 20 74 | 68 65 20 63 68 61 72 61 |d then t|he chara|
|00002d60| 63 74 65 72 20 77 69 6c | 6c 20 62 65 20 78 6f 72 |cter wil|l be xor|
|00002d70| 27 64 20 6f 6e 74 6f 20 | 74 68 65 20 6c 6f 77 0a |'d onto |the low.|
|00002d80| 58 6f 72 64 65 72 20 38 | 20 62 69 74 73 20 6f 66 |Xorder 8| bits of|
|00002d90| 20 74 68 65 20 63 68 65 | 63 6b 73 75 6d 2e 0a 58 | the che|cksum..X|
|00002da0| 0a 58 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 20 49 6d |.X------|----- Im|
|00002db0| 70 6c 65 6d 65 6e 74 61 | 74 69 6f 6e 3a 0a 58 0a |plementa|tion:.X.|
|00002dc0| 58 44 65 63 6f 64 69 6e | 67 20 77 69 74 68 20 74 |XDecodin|g with t|
|00002dd0| 68 69 73 20 73 63 68 65 | 6d 65 20 69 73 20 74 72 |his sche|me is tr|
|00002de0| 69 76 69 61 6c 3a 20 79 | 6f 75 20 73 69 6d 70 6c |ivial: y|ou simpl|
|00002df0| 79 20 6d 61 70 20 74 68 | 65 20 70 72 69 6e 74 61 |y map th|e printa|
|00002e00| 62 6c 65 0a 58 63 68 61 | 72 61 63 74 65 72 20 66 |ble.Xcha|racter f|
|00002e10| 72 6f 6d 20 74 68 65 20 | 69 6e 70 75 74 20 74 6f |rom the |input to|
|00002e20| 20 74 68 65 20 63 6f 72 | 72 65 73 70 6f 6e 64 69 | the cor|respondi|
|00002e30| 6e 67 20 76 61 72 69 61 | 62 6c 65 20 6c 65 6e 67 |ng varia|ble leng|
|00002e40| 74 68 20 74 6f 6b 65 6e | 2c 0a 58 61 6e 64 20 74 |th token|,.Xand t|
|00002e50| 68 65 6e 20 61 70 70 65 | 6e 64 20 74 68 61 74 20 |hen appe|nd that |
|00002e60| 74 6f 6b 65 6e 20 74 6f | 20 74 68 65 20 64 65 63 |token to| the dec|
|00002e70| 6f 64 65 64 20 62 69 74 | 73 74 72 65 61 6d 2e 0a |oded bit|stream..|
|00002e80| 58 0a 58 45 6e 63 6f 64 | 69 6e 67 20 69 73 20 61 |X.XEncod|ing is a|
|00002e90| 20 62 69 74 20 6d 6f 72 | 65 20 74 72 69 63 6b 79 | bit mor|e tricky|
|00002ea0| 20 68 6f 77 65 76 65 72 | 2c 20 73 69 6e 63 65 20 | however|, since |
|00002eb0| 74 68 65 20 74 6f 6b 65 | 6e 20 6c 65 6e 67 74 68 |the toke|n length|
|00002ec0| 20 69 73 0a 58 76 61 72 | 69 61 62 6c 65 2c 20 61 | is.Xvar|iable, a|
|00002ed0| 6e 64 20 74 68 65 20 69 | 6e 70 75 74 20 62 69 74 |nd the i|nput bit|
|00002ee0| 73 74 72 65 61 6d 20 68 | 61 73 20 6e 6f 20 74 6f |stream h|as no to|
|00002ef0| 6b 65 6e 20 62 6f 75 6e | 64 61 72 69 65 73 20 69 |ken boun|daries i|
|00002f00| 6e 20 69 74 2e 20 54 68 | 65 0a 58 73 6f 6c 75 74 |n it. Th|e.Xsolut|
|00002f10| 69 6f 6e 20 69 73 20 74 | 6f 20 73 65 74 20 75 70 |ion is t|o set up|
|00002f20| 20 61 20 32 35 36 20 65 | 6c 65 6d 65 6e 74 20 61 | a 256 e|lement a|
|00002f30| 72 72 61 79 20 77 68 69 | 63 68 20 69 73 20 69 6e |rray whi|ch is in|
|00002f40| 64 65 78 65 64 20 62 79 | 20 74 68 65 20 6e 65 78 |dexed by| the nex|
|00002f50| 74 0a 58 38 20 62 69 74 | 73 20 69 6e 20 74 68 65 |t.X8 bit|s in the|
|00002f60| 20 69 6e 70 75 74 20 62 | 69 74 73 74 72 65 61 6d | input b|itstream|
|00002f70| 2e 20 4e 6f 74 65 20 74 | 68 61 74 20 74 68 65 73 |. Note t|hat thes|
|00002f80| 65 20 38 20 62 69 74 73 | 20 61 72 65 20 6e 6f 74 |e 8 bits| are not|
|00002f90| 0a 58 6e 65 63 65 73 73 | 61 72 69 6c 79 20 62 79 |.Xnecess|arily by|
|00002fa0| 74 65 2d 61 6c 69 67 6e | 65 64 20 69 6e 20 74 68 |te-align|ed in th|
|00002fb0| 65 20 69 6e 70 75 74 20 | 66 69 6c 65 2e 20 54 68 |e input |file. Th|
|00002fc0| 65 20 69 6e 64 65 78 65 | 64 20 65 6c 65 6d 65 6e |e indexe|d elemen|
|00002fd0| 74 20 69 6e 20 74 68 65 | 0a 58 61 72 72 61 79 20 |t in the|.Xarray |
|00002fe0| 77 69 6c 6c 20 69 6e 64 | 69 63 61 74 65 20 68 6f |will ind|icate ho|
|00002ff0| 77 20 6d 61 6e 79 20 62 | 69 74 73 20 73 68 6f 75 |w many b|its shou|
|00003000| 6c 64 20 62 65 20 63 6f | 6e 73 75 6d 65 64 20 69 |ld be co|nsumed i|
|00003010| 6e 20 74 68 65 20 69 6e | 70 75 74 2c 20 61 6e 64 |n the in|put, and|
|00003020| 0a 58 77 68 61 74 20 70 | 72 69 6e 74 61 62 6c 65 |.Xwhat p|rintable|
|00003030| 20 63 68 61 72 61 63 74 | 65 72 20 74 6f 20 61 70 | charact|er to ap|
|00003040| 70 65 6e 64 20 74 6f 20 | 74 68 65 20 6f 75 74 70 |pend to |the outp|
|00003050| 75 74 2e 20 46 6f 72 20 | 65 78 61 6d 70 6c 65 2c |ut. For |example,|
|00003060| 20 69 6e 0a 58 6f 72 64 | 65 72 20 74 6f 20 72 65 | in.Xord|er to re|
|00003070| 63 6f 67 6e 69 7a 65 20 | 74 68 65 20 74 6f 6b 65 |cognize |the toke|
|00003080| 6e 20 30 31 30 2c 20 61 | 6c 6c 20 65 6c 65 6d 65 |n 010, a|ll eleme|
|00003090| 6e 74 73 20 6f 66 20 74 | 68 65 20 61 72 72 61 79 |nts of t|he array|
|000030a0| 20 77 68 6f 73 65 0a 58 | 69 6e 64 65 78 20 69 73 | whose.X|index is|
|000030b0| 20 30 31 30 78 78 78 78 | 78 20 66 6f 72 20 61 6c | 010xxxx|x for al|
|000030c0| 6c 20 78 78 78 78 78 20 | 73 68 6f 75 6c 64 20 62 |l xxxxx |should b|
|000030d0| 65 20 73 65 74 20 75 70 | 20 74 6f 20 69 6e 64 69 |e set up| to indi|
|000030e0| 63 61 74 65 20 74 68 61 | 74 20 33 0a 58 62 69 74 |cate tha|t 3.Xbit|
|000030f0| 73 20 77 65 72 65 20 73 | 65 65 6e 20 61 6e 64 20 |s were s|een and |
|00003100| 67 69 76 65 20 74 68 65 | 20 70 72 69 6e 74 61 62 |give the| printab|
|00003110| 6c 65 20 63 68 61 72 61 | 63 74 65 72 20 74 68 61 |le chara|cter tha|
|00003120| 74 20 6d 61 70 73 20 74 | 6f 20 30 31 30 2e 20 54 |t maps t|o 010. T|
|00003130| 68 65 0a 58 69 6e 70 75 | 74 20 62 69 74 73 74 72 |he.Xinpu|t bitstr|
|00003140| 65 61 6d 20 77 69 6c 6c | 20 74 68 65 6e 20 62 65 |eam will| then be|
|00003150| 20 61 64 76 61 6e 63 65 | 64 20 62 79 20 33 20 62 | advance|d by 3 b|
|00003160| 69 74 73 20 61 6e 64 20 | 74 68 65 20 6f 70 65 72 |its and |the oper|
|00003170| 61 74 69 6f 6e 20 69 73 | 0a 58 72 65 70 65 61 74 |ation is|.Xrepeat|
|00003180| 65 64 2c 20 75 73 69 6e | 67 20 74 68 65 20 6e 65 |ed, usin|g the ne|
|00003190| 78 74 20 38 20 62 69 74 | 73 20 74 6f 20 69 6e 64 |xt 8 bit|s to ind|
|000031a0| 65 78 20 74 68 65 20 61 | 72 72 61 79 20 61 67 61 |ex the a|rray aga|
|000031b0| 69 6e 2e 0a 58 0a 58 4d | 79 20 69 6d 70 6c 65 6d |in..X.XM|y implem|
|000031c0| 65 6e 74 61 74 69 6f 6e | 20 6f 66 20 74 68 69 73 |entation| of this|
|000031d0| 20 65 6e 63 6f 64 69 6e | 67 20 70 72 6f 63 65 73 | encodin|g proces|
|000031e0| 73 20 69 73 20 66 61 69 | 72 6c 79 20 73 69 6d 70 |s is fai|rly simp|
|000031f0| 6c 69 73 74 69 63 20 61 | 6e 64 0a 58 69 6e 63 6f |listic a|nd.Xinco|
|00003200| 72 70 6f 72 61 74 65 73 | 20 6e 6f 20 6d 6f 72 65 |rporates| no more|
|00003210| 20 74 68 61 6e 20 74 68 | 65 20 62 61 73 69 63 20 | than th|e basic |
|00003220| 66 75 6e 63 74 69 6f 6e | 61 6c 69 74 79 20 70 72 |function|ality pr|
|00003230| 6f 76 69 64 65 64 20 62 | 79 0a 58 75 75 65 6e 63 |ovided b|y.Xuuenc|
|00003240| 6f 64 65 2f 75 75 64 65 | 63 6f 64 65 2e 20 49 74 |ode/uude|code. It|
|00003250| 20 69 73 20 69 6e 74 65 | 6e 64 65 64 20 70 72 69 | is inte|nded pri|
|00003260| 6d 61 72 69 6c 79 20 74 | 6f 20 69 6e 74 72 6f 64 |marily t|o introd|
|00003270| 75 63 65 20 74 68 69 73 | 20 65 6e 63 6f 64 69 6e |uce this| encodin|
|00003280| 67 0a 58 73 63 68 65 6d | 65 20 74 6f 20 74 68 65 |g.Xschem|e to the|
|00003290| 20 70 75 62 6c 69 63 20 | 69 6e 20 74 68 65 20 68 | public |in the h|
|000032a0| 6f 70 65 73 20 74 68 61 | 74 20 69 74 20 77 69 6c |opes tha|t it wil|
|000032b0| 6c 20 62 65 20 77 69 64 | 65 6c 79 20 61 64 6f 70 |l be wid|ely adop|
|000032c0| 74 65 64 2e 0a 58 53 68 | 6f 75 6c 64 20 73 75 63 |ted..XSh|ould suc|
|000032d0| 68 20 61 64 6f 70 74 69 | 6f 6e 20 6f 63 63 75 72 |h adopti|on occur|
|000032e0| 2c 20 74 68 69 73 20 66 | 69 6c 65 20 73 68 6f 75 |, this f|ile shou|
|000032f0| 6c 64 20 62 65 20 75 73 | 65 64 20 61 73 20 61 20 |ld be us|ed as a |
|00003300| 73 74 61 6e 64 61 72 64 | 0a 58 72 65 66 65 72 65 |standard|.Xrefere|
|00003310| 6e 63 65 20 66 6f 72 20 | 74 68 65 20 65 6e 63 6f |nce for |the enco|
|00003320| 64 69 6e 67 20 61 6c 67 | 6f 72 69 74 68 6d 2e 0a |ding alg|orithm..|
|00003330| 58 0a 45 4e 44 5f 4f 46 | 5f 46 49 4c 45 0a 69 66 |X.END_OF|_FILE.if|
|00003340| 20 74 65 73 74 20 38 38 | 35 39 20 2d 6e 65 20 60 | test 88|59 -ne `|
|00003350| 77 63 20 2d 63 20 3c 27 | 52 45 41 44 4d 45 27 60 |wc -c <'|README'`|
|00003360| 3b 20 74 68 65 6e 0a 20 | 20 20 20 65 63 68 6f 20 |; then. | echo |
|00003370| 73 68 61 72 3a 20 5c 22 | 27 52 45 41 44 4d 45 27 |shar: \"|'README'|
|00003380| 5c 22 20 75 6e 70 61 63 | 6b 65 64 20 77 69 74 68 |\" unpac|ked with|
|00003390| 20 77 72 6f 6e 67 20 73 | 69 7a 65 21 0a 66 69 0a | wrong s|ize!.fi.|
|000033a0| 23 20 65 6e 64 20 6f 66 | 20 27 52 45 41 44 4d 45 |# end of| 'README|
|000033b0| 27 0a 66 69 0a 69 66 20 | 74 65 73 74 20 2d 66 20 |'.fi.if |test -f |
|000033c0| 27 63 6f 64 65 73 2e 63 | 27 20 2d 61 20 22 24 7b |'codes.c|' -a "${|
|000033d0| 31 7d 22 20 21 3d 20 22 | 2d 63 22 20 3b 20 74 68 |1}" != "|-c" ; th|
|000033e0| 65 6e 20 0a 20 20 65 63 | 68 6f 20 73 68 61 72 3a |en . ec|ho shar:|
|000033f0| 20 57 69 6c 6c 20 6e 6f | 74 20 63 6c 6f 62 62 65 | Will no|t clobbe|
|00003400| 72 20 65 78 69 73 74 69 | 6e 67 20 66 69 6c 65 20 |r existi|ng file |
|00003410| 5c 22 27 63 6f 64 65 73 | 2e 63 27 5c 22 0a 65 6c |\"'codes|.c'\".el|
|00003420| 73 65 0a 65 63 68 6f 20 | 73 68 61 72 3a 20 45 78 |se.echo |shar: Ex|
|00003430| 74 72 61 63 74 69 6e 67 | 20 5c 22 27 63 6f 64 65 |tracting| \"'code|
|00003440| 73 2e 63 27 5c 22 20 5c | 28 35 31 39 35 20 63 68 |s.c'\" \|(5195 ch|
|00003450| 61 72 61 63 74 65 72 73 | 5c 29 0a 73 65 64 20 22 |aracters|\).sed "|
|00003460| 73 2f 5e 58 2f 2f 22 20 | 3e 27 63 6f 64 65 73 2e |s/^X//" |>'codes.|
|00003470| 63 27 20 3c 3c 27 45 4e | 44 5f 4f 46 5f 46 49 4c |c' <<'EN|D_OF_FIL|
|00003480| 45 27 0a 58 2f 2a 0a 58 | 20 2a 20 24 48 65 61 64 |E'.X/*.X| * $Head|
|00003490| 65 72 3a 20 2f 75 73 72 | 2f 70 65 6f 70 6c 65 2f |er: /usr|/people/|
|000034a0| 74 63 6c 2f 73 72 63 2f | 75 75 74 61 72 2f 52 43 |tcl/src/|uutar/RC|
|000034b0| 53 2f 63 6f 64 65 73 2e | 63 2c 76 20 31 2e 31 2e |S/codes.|c,v 1.1.|
|000034c0| 31 2e 34 20 31 39 39 33 | 2f 30 39 2f 31 31 20 32 |1.4 1993|/09/11 2|
|000034d0| 32 3a 34 32 3a 34 34 20 | 74 63 6c 20 45 78 70 20 |2:42:44 |tcl Exp |
|000034e0| 24 0a 58 20 2a 20 54 6f | 6d 20 4c 61 77 72 65 6e |$.X * To|m Lawren|
|000034f0| 63 65 0a 58 20 2a 20 74 | 63 6c 40 73 67 69 2e 63 |ce.X * t|cl@sgi.c|
|00003500| 6f 6d 0a 58 20 2a 2f 0a | 58 0a 58 23 69 6e 63 6c |om.X */.|X.X#incl|
|00003510| 75 64 65 20 3c 73 74 64 | 69 6f 2e 68 3e 0a 58 23 |ude <std|io.h>.X#|
|00003520| 69 6e 63 6c 75 64 65 20 | 3c 73 74 64 6c 69 62 2e |include |<stdlib.|
|00003530| 68 3e 0a 58 23 69 6e 63 | 6c 75 64 65 20 22 63 6f |h>.X#inc|lude "co|
|00003540| 64 65 73 2e 68 22 0a 58 | 0a 58 2f 2a 20 73 65 65 |des.h".X|.X/* see|
|00003550| 20 63 6f 64 65 73 2e 68 | 20 2a 2f 0a 58 69 6e 74 | codes.h| */.Xint|
|00003560| 20 6e 75 6d 63 68 61 72 | 73 3b 0a 58 73 74 72 75 | numchar|s;.Xstru|
|00003570| 63 74 20 63 6f 64 65 20 | 63 6f 64 65 73 5b 32 35 |ct code |codes[25|
|00003580| 36 5d 3b 0a 58 0a 58 2f | 2a 20 69 6e 69 74 69 61 |6];.X.X/|* initia|
|00003590| 6c 69 7a 65 20 61 20 73 | 75 62 73 65 74 20 6f 66 |lize a s|ubset of|
|000035a0| 20 74 68 65 20 63 6f 64 | 65 73 20 61 72 72 61 79 | the cod|es array|
|000035b0| 2e 20 76 61 6c 20 61 6e | 64 20 6c 65 6e 20 64 65 |. val an|d len de|
|000035c0| 66 69 6e 65 20 61 20 76 | 61 72 69 61 62 6c 65 0a |fine a v|ariable.|
|000035d0| 58 20 2a 20 6c 65 6e 67 | 74 68 20 62 69 74 66 69 |X * leng|th bitfi|
|000035e0| 65 6c 64 2e 20 54 68 65 | 20 61 72 72 61 79 20 65 |eld. The| array e|
|000035f0| 6c 65 6d 65 6e 74 73 20 | 77 69 6c 6c 20 62 65 20 |lements |will be |
|00003600| 73 65 74 20 75 70 20 73 | 6f 20 74 68 61 74 20 61 |set up s|o that a|
|00003610| 6e 79 20 65 6c 65 6d 65 | 6e 74 0a 58 20 2a 20 6f |ny eleme|nt.X * o|
|00003620| 66 20 74 68 65 20 61 72 | 72 61 79 20 77 68 6f 73 |f the ar|ray whos|
|00003630| 65 20 69 6e 64 65 78 20 | 69 73 20 61 20 6c 65 66 |e index |is a lef|
|00003640| 74 2d 61 6c 69 67 6e 65 | 64 20 73 75 70 65 72 73 |t-aligne|d supers|
|00003650| 65 74 20 6f 66 20 74 68 | 69 73 20 62 69 74 66 69 |et of th|is bitfi|
|00003660| 65 6c 64 0a 58 20 2a 20 | 77 69 6c 6c 20 63 6f 6e |eld.X * |will con|
|00003670| 74 61 69 6e 20 74 68 65 | 20 67 69 76 65 6e 20 6f |tain the| given o|
|00003680| 75 74 70 75 74 20 61 73 | 63 69 69 20 63 68 61 72 |utput as|cii char|
|00003690| 61 63 74 65 72 2e 20 45 | 2e 67 2e 20 69 66 20 74 |acter. E|.g. if t|
|000036a0| 68 65 20 62 69 74 66 69 | 65 6c 64 20 69 73 0a 58 |he bitfi|eld is.X|
|000036b0| 20 2a 20 31 30 30 31 30 | 2c 20 74 68 65 6e 20 61 | * 10010|, then a|
|000036c0| 6c 6c 20 65 6c 65 6d 65 | 6e 74 73 20 69 6e 20 74 |ll eleme|nts in t|
|000036d0| 68 65 20 61 72 72 61 79 | 20 77 69 74 68 20 73 75 |he array| with su|
|000036e0| 62 73 63 72 69 70 74 20 | 31 30 30 31 30 78 78 78 |bscript |10010xxx|
|000036f0| 20 66 6f 72 20 61 6c 6c | 0a 58 20 2a 20 78 78 78 | for all|.X * xxx|
|00003700| 2c 20 77 69 6c 6c 20 73 | 74 6f 72 65 20 74 68 65 |, will s|tore the|
|00003710| 20 67 69 76 65 6e 20 61 | 73 63 69 69 20 63 6f 64 | given a|scii cod|
|00003720| 65 2c 20 61 6e 64 20 74 | 68 65 20 6c 65 6e 67 74 |e, and t|he lengt|
|00003730| 68 20 6f 66 20 74 68 65 | 20 62 69 74 66 69 65 6c |h of the| bitfiel|
|00003740| 64 2c 0a 58 20 2a 20 69 | 6e 20 74 68 69 73 20 63 |d,.X * i|n this c|
|00003750| 61 73 65 20 35 2e 0a 58 | 20 2a 2f 0a 58 73 74 61 |ase 5..X| */.Xsta|
|00003760| 74 69 63 20 76 6f 69 64 | 0a 58 69 6e 69 74 5f 65 |tic void|.Xinit_e|
|00003770| 6e 63 6f 64 65 76 61 6c | 28 63 6f 64 65 73 2c 20 |ncodeval|(codes, |
|00003780| 76 61 6c 2c 20 6c 65 6e | 2c 20 61 73 63 69 69 29 |val, len|, ascii)|
|00003790| 0a 58 20 20 20 20 73 74 | 72 75 63 74 20 63 6f 64 |.X st|ruct cod|
|000037a0| 65 20 2a 63 6f 64 65 73 | 3b 0a 58 20 20 20 20 69 |e *codes|;.X i|
|000037b0| 6e 74 20 76 61 6c 3b 0a | 58 20 20 20 20 69 6e 74 |nt val;.|X int|
|000037c0| 20 6c 65 6e 3b 0a 58 20 | 20 20 20 69 6e 74 20 61 | len;.X | int a|
|000037d0| 73 63 69 69 3b 0a 58 7b | 0a 58 20 20 20 20 69 6e |scii;.X{|.X in|
|000037e0| 74 20 73 68 69 66 74 2c | 20 73 74 6f 70 3b 0a 58 |t shift,| stop;.X|
|000037f0| 0a 58 20 20 20 20 2f 2a | 20 64 65 74 65 72 6d 69 |.X /*| determi|
|00003800| 6e 65 20 68 6f 77 20 66 | 61 72 20 74 68 65 20 63 |ne how f|ar the c|
|00003810| 6f 64 65 20 6d 75 73 74 | 20 62 65 20 73 68 69 66 |ode must| be shif|
|00003820| 74 65 64 20 74 6f 20 62 | 65 20 0a 58 20 20 20 20 |ted to b|e .X |
|00003830| 20 2a 20 4d 53 42 20 6a | 75 73 74 69 66 69 65 64 | * MSB j|ustified|
|00003840| 20 69 6e 20 74 68 65 20 | 62 79 74 65 0a 58 20 20 | in the |byte.X |
|00003850| 20 20 20 2a 2f 0a 58 20 | 20 20 20 73 68 69 66 74 | */.X | shift|
|00003860| 20 3d 20 38 20 2d 20 6c | 65 6e 3b 0a 58 0a 58 20 | = 8 - l|en;.X.X |
|00003870| 20 20 20 2f 2a 20 63 61 | 6c 63 75 6c 61 74 65 20 | /* ca|lculate |
|00003880| 74 68 65 20 75 70 70 65 | 72 20 62 6f 75 6e 64 20 |the uppe|r bound |
|00003890| 6f 66 20 69 6e 64 69 63 | 65 73 20 77 68 69 63 68 |of indic|es which|
|000038a0| 20 74 68 69 73 20 62 69 | 74 66 69 65 6c 64 0a 58 | this bi|tfield.X|
|000038b0| 20 20 20 20 20 2a 20 77 | 69 6c 6c 20 6d 61 74 63 | * w|ill matc|
|000038c0| 68 0a 58 20 20 20 20 20 | 2a 2f 0a 58 20 20 20 20 |h.X |*/.X |
|000038d0| 73 74 6f 70 20 3d 20 28 | 76 61 6c 20 2b 20 31 29 |stop = (|val + 1)|
|000038e0| 20 3c 3c 20 73 68 69 66 | 74 3b 0a 58 0a 58 20 20 | << shif|t;.X.X |
|000038f0| 20 20 2f 2a 20 73 68 69 | 66 74 20 74 68 65 20 63 | /* shi|ft the c|
|00003900| 6f 64 65 20 6f 76 65 72 | 20 74 6f 20 74 68 65 20 |ode over| to the |
|00003910| 6c 65 66 74 20 65 64 67 | 65 20 6f 66 20 74 68 65 |left edg|e of the|
|00003920| 20 62 79 74 65 20 2a 2f | 0a 58 20 20 20 20 76 61 | byte */|.X va|
|00003930| 6c 20 3c 3c 3d 20 73 68 | 69 66 74 3b 0a 58 0a 58 |l <<= sh|ift;.X.X|
|00003940| 20 20 20 20 2f 2a 20 74 | 68 75 73 2c 20 66 6f 72 | /* t|hus, for|
|00003950| 20 65 76 65 72 79 20 69 | 6e 64 65 78 20 69 6e 20 | every i|ndex in |
|00003960| 74 68 65 20 32 35 36 20 | 65 6c 65 6d 65 6e 74 20 |the 256 |element |
|00003970| 61 72 72 61 79 20 77 68 | 69 63 68 20 68 61 73 0a |array wh|ich has.|
|00003980| 58 20 20 20 20 20 2a 20 | 74 68 69 73 20 63 6f 64 |X * |this cod|
|00003990| 65 20 61 73 20 61 20 70 | 72 65 66 69 78 0a 58 20 |e as a p|refix.X |
|000039a0| 20 20 20 20 2a 2f 0a 58 | 20 20 20 20 66 6f 72 28 | */.X| for(|
|000039b0| 3b 20 76 61 6c 20 3c 20 | 73 74 6f 70 3b 20 76 61 |; val < |stop; va|
|000039c0| 6c 2b 2b 29 20 7b 0a 58 | 09 2f 2a 20 73 74 6f 72 |l++) {.X|./* stor|
|000039d0| 65 20 74 68 65 20 63 6f | 64 65 20 6c 65 6e 67 74 |e the co|de lengt|
|000039e0| 68 20 61 6e 64 20 74 68 | 65 20 70 72 69 6e 74 61 |h and th|e printa|
|000039f0| 62 6c 65 20 63 68 61 72 | 61 63 74 65 72 20 0a 58 |ble char|acter .X|
|00003a00| 09 20 2a 20 69 74 20 72 | 65 70 72 65 73 65 6e 74 |. * it r|epresent|
|00003a10| 73 0a 58 09 20 2a 2f 0a | 58 09 63 6f 64 65 73 5b |s.X. */.|X.codes[|
|00003a20| 76 61 6c 5d 2e 6c 65 6e | 20 3d 20 28 63 68 61 72 |val].len| = (char|
|00003a30| 29 6c 65 6e 3b 0a 58 09 | 63 6f 64 65 73 5b 76 61 |)len;.X.|codes[va|
|00003a40| 6c 5d 2e 63 6f 64 65 20 | 3d 20 28 63 68 61 72 29 |l].code |= (char)|
|00003a50| 61 73 63 69 69 3b 0a 58 | 20 20 20 20 7d 0a 58 7d |ascii;.X| }.X}|
|00003a60| 0a 58 0a 58 2f 2a 20 63 | 6f 6e 76 65 72 74 20 61 |.X.X/* c|onvert a|
|00003a70| 6e 20 61 73 63 69 69 20 | 63 68 61 72 61 63 74 65 |n ascii |characte|
|00003a80| 72 20 63 6f 64 65 20 74 | 6f 20 61 6e 20 69 6e 74 |r code t|o an int|
|00003a90| 65 67 65 72 2e 20 54 68 | 65 20 63 68 61 72 61 63 |eger. Th|e charac|
|00003aa0| 74 65 72 20 63 6f 64 65 | 20 6d 61 79 0a 58 20 2a |ter code| may.X *|
|00003ab0| 20 62 65 20 69 6e 20 64 | 65 63 69 6d 61 6c 2c 20 | be in d|ecimal, |
|00003ac0| 68 65 78 20 6f 72 20 6f | 63 74 61 6c 2c 20 6f 72 |hex or o|ctal, or|
|00003ad0| 20 69 74 20 6d 61 79 20 | 62 65 20 61 6e 20 61 63 | it may |be an ac|
|00003ae0| 74 75 61 6c 20 63 68 61 | 72 61 63 74 65 72 20 65 |tual cha|racter e|
|00003af0| 73 63 61 70 65 64 0a 58 | 20 2a 20 77 69 74 68 20 |scaped.X| * with |
|00003b00| 61 20 62 61 63 6b 2d 73 | 6c 61 73 68 0a 58 20 2a |a back-s|lash.X *|
|00003b10| 2f 0a 58 73 74 61 74 69 | 63 20 69 6e 74 0a 58 73 |/.Xstati|c int.Xs|
|00003b20| 74 72 32 76 61 6c 28 73 | 74 72 29 0a 58 20 20 20 |tr2val(s|tr).X |
|00003b30| 20 63 68 61 72 20 2a 73 | 74 72 3b 0a 58 7b 0a 58 | char *s|tr;.X{.X|
|00003b40| 20 20 20 20 69 6e 74 20 | 76 61 6c 3b 0a 58 20 20 | int |val;.X |
|00003b50| 20 20 63 68 61 72 20 2a | 65 6e 64 3b 0a 58 0a 58 | char *|end;.X.X|
|00003b60| 20 20 20 20 77 68 69 6c | 65 28 2a 73 74 72 20 3d | whil|e(*str =|
|00003b70| 3d 20 27 20 27 20 7c 7c | 20 2a 73 74 72 20 3d 3d |= ' ' ||| *str ==|
|00003b80| 20 27 5c 74 27 29 0a 58 | 09 73 74 72 2b 2b 3b 0a | '\t').X|.str++;.|
|00003b90| 58 0a 58 20 20 20 20 2f | 2a 20 63 68 65 63 6b 20 |X.X /|* check |
|00003ba0| 69 66 20 74 68 69 73 20 | 69 73 20 61 6e 20 65 73 |if this |is an es|
|00003bb0| 63 61 70 65 64 20 63 68 | 61 72 61 63 74 65 72 20 |caped ch|aracter |
|00003bc0| 2a 2f 0a 58 20 20 20 20 | 69 66 20 28 2a 73 74 72 |*/.X |if (*str|
|00003bd0| 20 3d 3d 20 27 5c 5c 27 | 29 20 7b 0a 58 09 73 74 | == '\\'|) {.X.st|
|00003be0| 72 2b 2b 3b 0a 58 09 69 | 66 20 28 2a 73 74 72 20 |r++;.X.i|f (*str |
|00003bf0| 3d 3d 20 30 29 20 7b 0a | 58 09 20 20 20 20 66 70 |== 0) {.|X. fp|
|00003c00| 72 69 6e 74 66 28 73 74 | 64 65 72 72 2c 20 22 6d |rintf(st|derr, "m|
|00003c10| 69 73 73 69 6e 67 20 63 | 68 61 72 61 63 74 65 72 |issing c|haracter|
|00003c20| 20 69 6e 20 61 6c 70 68 | 61 62 65 74 5c 6e 22 29 | in alph|abet\n")|
|00003c30| 3b 0a 58 09 20 20 20 20 | 65 78 69 74 28 31 29 3b |;.X. |exit(1);|
|00003c40| 0a 58 09 7d 0a 58 09 72 | 65 74 75 72 6e 28 28 69 |.X.}.X.r|eturn((i|
|00003c50| 6e 74 29 2a 73 74 72 29 | 3b 0a 58 20 20 20 20 7d |nt)*str)|;.X }|
|00003c60| 0a 58 0a 58 20 20 20 20 | 76 61 6c 20 3d 20 28 69 |.X.X |val = (i|
|00003c70| 6e 74 29 73 74 72 74 6f | 6c 28 73 74 72 2c 20 26 |nt)strto|l(str, &|
|00003c80| 65 6e 64 2c 20 30 29 3b | 0a 58 20 20 20 20 69 66 |end, 0);|.X if|
|00003c90| 20 28 65 6e 64 20 3d 3d | 20 73 74 72 29 20 7b 0a | (end ==| str) {.|
|00003ca0| 58 09 69 66 20 28 2a 73 | 74 72 29 0a 58 09 20 20 |X.if (*s|tr).X. |
|00003cb0| 20 20 66 70 72 69 6e 74 | 66 28 73 74 64 65 72 72 | fprint|f(stderr|
|00003cc0| 2c 20 22 69 6e 76 61 6c | 69 64 20 63 68 61 72 20 |, "inval|id char |
|00003cd0| 5c 27 25 63 5c 27 20 69 | 6e 20 61 6c 70 68 61 62 |\'%c\' i|n alphab|
|00003ce0| 65 74 5c 6e 22 2c 20 2a | 73 74 72 29 3b 0a 58 09 |et\n", *|str);.X.|
|00003cf0| 65 6c 73 65 0a 58 09 20 | 20 20 20 66 70 72 69 6e |else.X. | fprin|
|00003d00| 74 66 28 73 74 64 65 72 | 72 2c 20 22 65 6d 70 74 |tf(stder|r, "empt|
|00003d10| 79 20 6e 75 6d 65 72 69 | 63 61 6c 20 66 69 65 6c |y numeri|cal fiel|
|00003d20| 64 20 69 6e 20 61 6c 70 | 68 61 62 65 74 5c 6e 22 |d in alp|habet\n"|
|00003d30| 29 3b 0a 58 09 65 78 69 | 74 28 31 29 3b 0a 58 20 |);.X.exi|t(1);.X |
|00003d40| 20 20 20 7d 0a 58 20 20 | 20 20 72 65 74 75 72 6e | }.X | return|
|00003d50| 28 76 61 6c 29 3b 0a 58 | 7d 0a 58 0a 58 2f 2a 20 |(val);.X|}.X.X/* |
|00003d60| 70 61 72 73 65 20 61 20 | 72 61 6e 67 65 20 6f 66 |parse a |range of|
|00003d70| 20 63 68 61 72 61 63 74 | 65 72 73 20 66 6f 72 20 | charact|ers for |
|00003d80| 74 68 65 20 6f 75 74 70 | 75 74 20 63 68 61 72 61 |the outp|ut chara|
|00003d90| 63 74 65 72 20 73 65 74 | 20 61 6e 64 20 6d 61 72 |cter set| and mar|
|00003da0| 6b 20 65 61 63 68 0a 58 | 20 2a 20 63 68 61 72 61 |k each.X| * chara|
|00003db0| 63 74 65 72 20 61 73 20 | 69 6e 20 75 73 65 20 69 |cter as |in use i|
|00003dc0| 6e 20 74 68 65 20 63 6f | 64 65 73 20 61 72 72 61 |n the co|des arra|
|00003dd0| 79 2e 20 41 20 72 61 6e | 67 65 20 69 73 20 65 69 |y. A ran|ge is ei|
|00003de0| 74 68 65 72 20 69 6e 20 | 74 68 65 20 66 6f 72 6d |ther in |the form|
|00003df0| 0a 58 20 2a 20 6e 75 6d | 2d 6e 75 6d 20 6f 72 20 |.X * num|-num or |
|00003e00| 6a 75 73 74 20 6e 75 6d | 0a 58 20 2a 2f 0a 58 73 |just num|.X */.Xs|
|00003e10| 74 61 74 69 63 20 76 6f | 69 64 0a 58 70 61 72 73 |tatic vo|id.Xpars|
|00003e20| 65 5f 63 68 61 72 76 61 | 6c 5f 72 61 6e 67 65 28 |e_charva|l_range(|
|00003e30| 72 61 6e 67 65 29 0a 58 | 20 20 20 20 63 68 61 72 |range).X| char|
|00003e40| 20 2a 72 61 6e 67 65 3b | 0a 58 7b 0a 58 20 20 20 | *range;|.X{.X |
|00003e50| 20 63 68 61 72 20 2a 63 | 2c 20 73 61 76 65 63 20 | char *c|, savec |
|00003e60| 3d 20 30 3b 0a 58 20 20 | 20 20 69 6e 74 20 73 74 |= 0;.X | int st|
|00003e70| 61 72 74 2c 20 65 6e 64 | 2c 20 78 3b 0a 58 0a 58 |art, end|, x;.X.X|
|00003e80| 20 20 20 20 66 6f 72 28 | 63 20 3d 20 72 61 6e 67 | for(|c = rang|
|00003e90| 65 3b 20 2a 63 20 26 26 | 20 2a 63 20 21 3d 20 27 |e; *c &&| *c != '|
|00003ea0| 2d 27 3b 20 63 2b 2b 29 | 3b 0a 58 20 20 20 20 73 |-'; c++)|;.X s|
|00003eb0| 61 76 65 63 20 3d 20 2a | 63 3b 0a 58 20 20 20 20 |avec = *|c;.X |
|00003ec0| 2a 63 20 3d 20 30 3b 0a | 58 0a 58 20 20 20 20 73 |*c = 0;.|X.X s|
|00003ed0| 74 61 72 74 20 3d 20 73 | 74 72 32 76 61 6c 28 72 |tart = s|tr2val(r|
|00003ee0| 61 6e 67 65 29 3b 0a 58 | 20 20 20 20 69 66 20 28 |ange);.X| if (|
|00003ef0| 73 61 76 65 63 20 3d 3d | 20 27 2d 27 29 20 7b 0a |savec ==| '-') {.|
|00003f00| 58 09 65 6e 64 20 3d 20 | 73 74 72 32 76 61 6c 28 |X.end = |str2val(|
|00003f10| 63 20 2b 20 31 29 3b 0a | 58 09 2a 63 20 3d 20 73 |c + 1);.|X.*c = s|
|00003f20| 61 76 65 63 3b 0a 58 09 | 66 6f 72 28 78 20 3d 20 |avec;.X.|for(x = |
|00003f30| 73 74 61 72 74 3b 20 78 | 20 3c 3d 20 65 6e 64 3b |start; x| <= end;|
|00003f40| 20 78 2b 2b 29 0a 58 09 | 20 20 20 20 63 6f 64 65 | x++).X.| code|
|00003f50| 73 5b 78 5d 2e 69 6e 75 | 73 65 20 3d 20 31 3b 0a |s[x].inu|se = 1;.|
|00003f60| 58 20 20 20 20 7d 0a 58 | 20 20 20 20 65 6c 73 65 |X }.X| else|
|00003f70| 0a 58 09 63 6f 64 65 73 | 5b 73 74 61 72 74 5d 2e |.X.codes|[start].|
|00003f80| 69 6e 75 73 65 20 3d 20 | 31 3b 0a 58 7d 0a 58 0a |inuse = |1;.X}.X.|
|00003f90| 58 2f 2a 20 70 61 72 73 | 65 20 61 20 6c 69 73 74 |X/* pars|e a list|
|00003fa0| 20 6f 66 20 63 68 61 72 | 61 63 74 65 72 20 72 61 | of char|acter ra|
|00003fb0| 6e 67 65 73 20 66 6f 72 | 20 74 68 65 20 6f 75 74 |nges for| the out|
|00003fc0| 70 75 74 20 63 68 61 72 | 61 63 74 65 72 20 73 65 |put char|acter se|
|00003fd0| 74 20 61 6e 64 20 74 68 | 65 6e 0a 58 20 2a 20 70 |t and th|en.X * p|
|00003fe0| 61 72 73 65 20 65 61 63 | 68 20 72 61 6e 67 65 20 |arse eac|h range |
|00003ff0| 66 6f 75 6e 64 2e 20 41 | 20 6c 69 73 74 20 69 73 |found. A| list is|
|00004000| 20 6f 66 20 74 68 65 20 | 66 6f 72 6d 20 72 61 6e | of the |form ran|
|00004010| 67 65 2c 72 61 6e 67 65 | 2c 2e 2e 2e 0a 58 20 2a |ge,range|,....X *|
|00004020| 2f 0a 58 76 6f 69 64 0a | 58 70 61 72 73 65 5f 63 |/.Xvoid.|Xparse_c|
|00004030| 68 61 72 76 61 6c 5f 6c | 69 73 74 28 6c 69 73 74 |harval_l|ist(list|
|00004040| 29 0a 58 20 20 20 20 63 | 68 61 72 20 2a 6c 69 73 |).X c|har *lis|
|00004050| 74 3b 0a 58 7b 0a 58 20 | 20 20 20 63 68 61 72 20 |t;.X{.X | char |
|00004060| 2a 63 31 2c 20 2a 63 32 | 2c 20 73 61 76 65 63 32 |*c1, *c2|, savec2|
|00004070| 3b 0a 58 20 20 20 20 69 | 6e 74 20 78 3b 0a 58 0a |;.X i|nt x;.X.|
|00004080| 58 20 20 20 20 66 6f 72 | 28 78 20 3d 20 30 3b 20 |X for|(x = 0; |
|00004090| 78 20 3c 20 32 35 36 3b | 20 78 2b 2b 29 0a 58 09 |x < 256;| x++).X.|
|000040a0| 63 6f 64 65 73 5b 78 5d | 2e 69 6e 75 73 65 20 3d |codes[x]|.inuse =|
|000040b0| 20 30 3b 0a 58 0a 58 20 | 20 20 20 63 31 20 3d 20 | 0;.X.X | c1 = |
|000040c0| 6c 69 73 74 3b 0a 58 20 | 20 20 20 77 68 69 6c 65 |list;.X | while|
|000040d0| 28 2a 63 31 29 20 7b 0a | 58 09 77 68 69 6c 65 28 |(*c1) {.|X.while(|
|000040e0| 2a 63 31 20 3d 3d 20 27 | 2c 27 29 0a 58 09 20 20 |*c1 == '|,').X. |
|000040f0| 20 20 63 31 2b 2b 3b 0a | 58 09 69 66 20 28 2a 63 | c1++;.|X.if (*c|
|00004100| 31 20 3d 3d 20 30 29 0a | 58 09 20 20 20 20 72 65 |1 == 0).|X. re|
|00004110| 74 75 72 6e 3b 0a 58 09 | 66 6f 72 28 63 32 20 3d |turn;.X.|for(c2 =|
|00004120| 20 63 31 3b 20 2a 63 32 | 20 26 26 20 2a 63 32 20 | c1; *c2| && *c2 |
|00004130| 21 3d 20 27 2c 27 3b 20 | 63 32 2b 2b 29 3b 0a 58 |!= ','; |c2++);.X|
|00004140| 09 73 61 76 65 63 32 20 | 3d 20 2a 63 32 3b 0a 58 |.savec2 |= *c2;.X|
|00004150| 09 2a 63 32 20 3d 20 30 | 3b 0a 58 09 70 61 72 73 |.*c2 = 0|;.X.pars|
|00004160| 65 5f 63 68 61 72 76 61 | 6c 5f 72 61 6e 67 65 28 |e_charva|l_range(|
|00004170| 63 31 29 3b 0a 58 09 2a | 63 32 20 3d 20 73 61 76 |c1);.X.*|c2 = sav|
|00004180| 65 63 32 3b 0a 58 09 63 | 31 20 3d 20 63 32 3b 0a |ec2;.X.c|1 = c2;.|
|00004190| 58 20 20 20 20 7d 0a 58 | 20 20 20 20 72 65 74 75 |X }.X| retu|
|000041a0| 72 6e 3b 0a 58 7d 0a 58 | 0a 58 2f 2a 20 70 72 69 |rn;.X}.X|.X/* pri|
|000041b0| 6e 74 20 6f 75 74 20 74 | 68 65 20 63 68 61 72 61 |nt out t|he chara|
|000041c0| 63 74 65 72 20 73 65 74 | 20 69 6e 20 74 68 65 20 |cter set| in the |
|000041d0| 66 6f 72 6d 20 6f 66 20 | 61 20 6c 69 73 74 20 6f |form of |a list o|
|000041e0| 66 20 72 61 6e 67 65 73 | 2c 20 65 6e 63 6f 64 65 |f ranges|, encode|
|000041f0| 64 0a 58 20 2a 20 69 6e | 20 64 65 63 69 6d 61 6c |d.X * in| decimal|
|00004200| 0a 58 20 2a 2f 0a 58 76 | 6f 69 64 0a 58 70 72 69 |.X */.Xv|oid.Xpri|
|00004210| 6e 74 5f 63 68 61 72 76 | 61 6c 5f 6c 69 73 74 28 |nt_charv|al_list(|
|00004220| 66 70 29 0a 58 20 20 20 | 20 46 49 4c 45 20 2a 66 |fp).X | FILE *f|
|00004230| 70 3b 0a 58 7b 0a 58 20 | 20 20 20 69 6e 74 20 78 |p;.X{.X | int x|
|00004240| 2c 20 75 73 65 63 6f 6d | 6d 61 3b 0a 58 0a 58 20 |, usecom|ma;.X.X |
|00004250| 20 20 20 75 73 65 63 6f | 6d 6d 61 20 3d 20 30 3b | useco|mma = 0;|
|00004260| 0a 58 20 20 20 20 66 6f | 72 28 78 20 3d 20 30 3b |.X fo|r(x = 0;|
|00004270| 20 78 20 3c 20 32 35 36 | 3b 20 78 2b 2b 29 20 7b | x < 256|; x++) {|
|00004280| 0a 58 09 69 66 20 28 63 | 6f 64 65 73 5b 78 5d 2e |.X.if (c|odes[x].|
|00004290| 69 6e 75 73 65 29 20 7b | 0a 58 09 20 20 20 20 69 |inuse) {|.X. i|
|000042a0| 66 20 28 75 73 65 63 6f | 6d 6d 61 29 0a 58 09 09 |f (useco|mma).X..|
|000042b0| 70 75 74 63 28 27 2c 27 | 2c 20 66 70 29 3b 0a 58 |putc(','|, fp);.X|
|000042c0| 09 20 20 20 20 66 70 72 | 69 6e 74 66 28 66 70 2c |. fpr|intf(fp,|
|000042d0| 20 22 25 64 22 2c 20 78 | 29 3b 0a 58 09 20 20 20 | "%d", x|);.X. |
|000042e0| 20 75 73 65 63 6f 6d 6d | 61 20 3d 20 31 3b 0a 58 | usecomm|a = 1;.X|
|000042f0| 09 20 20 20 20 69 66 20 | 28 78 20 3c 20 32 35 35 |. if |(x < 255|
|00004300| 20 26 26 20 63 6f 64 65 | 73 5b 78 2b 31 5d 2e 69 | && code|s[x+1].i|
|00004310| 6e 75 73 65 29 20 7b 0a | 58 09 09 70 75 74 63 28 |nuse) {.|X..putc(|
|00004320| 27 2d 27 2c 20 66 70 29 | 3b 0a 58 09 09 77 68 69 |'-', fp)|;.X..whi|
|00004330| 6c 65 28 2b 2b 78 20 3c | 20 32 35 36 20 26 26 20 |le(++x <| 256 && |
|00004340| 63 6f 64 65 73 5b 78 5d | 2e 69 6e 75 73 65 29 3b |codes[x]|.inuse);|
|00004350| 0a 58 09 09 66 70 72 69 | 6e 74 66 28 66 70 2c 20 |.X..fpri|ntf(fp, |
|00004360| 22 25 64 22 2c 20 78 2d | 31 29 3b 0a 58 09 20 20 |"%d", x-|1);.X. |
|00004370| 20 20 7d 0a 58 09 7d 0a | 58 20 20 20 20 7d 0a 58 | }.X.}.|X }.X|
|00004380| 7d 0a 58 0a 58 2f 2a 0a | 58 20 2a 20 49 6e 69 74 |}.X.X/*.|X * Init|
|00004390| 69 61 6c 69 7a 65 20 74 | 68 65 20 74 61 62 6c 65 |ialize t|he table|
|000043a0| 73 20 66 6f 72 20 65 6e | 63 6f 64 69 6e 67 20 6f |s for en|coding o|
|000043b0| 72 20 64 65 63 6f 64 69 | 6e 67 20 64 65 70 65 6e |r decodi|ng depen|
|000043c0| 64 69 6e 67 20 6f 6e 20 | 74 68 65 20 67 69 76 65 |ding on |the give|
|000043d0| 6e 0a 58 20 2a 20 64 69 | 72 65 63 74 69 6f 6e 2e |n.X * di|rection.|
|000043e0| 20 0a 58 20 2a 2f 0a 58 | 76 6f 69 64 0a 58 69 6e | .X */.X|void.Xin|
|000043f0| 69 74 5f 63 6f 64 65 73 | 28 64 69 72 65 63 74 69 |it_codes|(directi|
|00004400| 6f 6e 29 0a 58 20 20 20 | 20 69 6e 74 20 64 69 72 |on).X | int dir|
|00004410| 65 63 74 69 6f 6e 3b 0a | 58 7b 0a 58 20 20 20 20 |ection;.|X{.X |
|00004420| 69 6e 74 20 78 2c 20 63 | 6f 64 65 2c 20 6e 75 6d |int x, c|ode, num|
|00004430| 63 68 61 72 73 3b 0a 58 | 20 20 20 20 69 6e 74 20 |chars;.X| int |
|00004440| 70 6f 66 32 2c 20 70 6f | 66 32 6c 65 6e 2c 20 68 |pof2, po|f2len, h|
|00004450| 61 6c 66 2c 20 77 68 6f | 6c 65 3b 0a 58 0a 58 20 |alf, who|le;.X.X |
|00004460| 20 20 20 2f 2a 20 63 6f | 75 6e 74 20 68 6f 77 20 | /* co|unt how |
|00004470| 62 69 67 20 6f 75 72 20 | 63 68 61 72 61 63 74 65 |big our |characte|
|00004480| 72 20 73 65 74 20 69 73 | 20 2a 2f 0a 58 20 20 20 |r set is| */.X |
|00004490| 20 6e 75 6d 63 68 61 72 | 73 20 3d 20 30 3b 0a 58 | numchar|s = 0;.X|
|000044a0| 20 20 20 20 66 6f 72 28 | 78 20 3d 20 30 3b 20 78 | for(|x = 0; x|
|000044b0| 20 3c 20 32 35 36 3b 20 | 78 2b 2b 29 0a 58 09 69 | < 256; |x++).X.i|
|000044c0| 66 20 28 63 6f 64 65 73 | 5b 78 5d 2e 69 6e 75 73 |f (codes|[x].inus|
|000044d0| 65 29 0a 58 09 20 20 20 | 20 6e 75 6d 63 68 61 72 |e).X. | numchar|
|000044e0| 73 2b 2b 3b 0a 58 0a 58 | 20 20 20 20 69 66 20 28 |s++;.X.X| if (|
|000044f0| 6e 75 6d 63 68 61 72 73 | 20 3c 20 32 29 20 7b 0a |numchars| < 2) {.|
|00004500| 58 09 66 70 72 69 6e 74 | 66 28 73 74 64 65 72 72 |X.fprint|f(stderr|
|00004510| 2c 0a 58 09 09 22 75 75 | 74 61 72 3a 20 61 6c 70 |,.X.."uu|tar: alp|
|00004520| 68 61 62 65 74 20 64 6f | 65 73 6e 27 74 20 63 6f |habet do|esn't co|
|00004530| 6e 74 61 69 6e 20 65 6e | 6f 75 67 68 20 63 68 61 |ntain en|ough cha|
|00004540| 72 61 63 74 65 72 73 2e | 5c 6e 22 29 3b 0a 58 09 |racters.|\n");.X.|
|00004550| 65 78 69 74 28 31 29 3b | 0a 58 20 20 20 20 7d 0a |exit(1);|.X }.|
|00004560| 58 0a 58 20 20 20 20 2f | 2a 20 64 65 74 65 72 6d |X.X /|* determ|
|00004570| 69 6e 65 20 74 68 65 20 | 6c 6f 77 65 73 74 20 70 |ine the |lowest p|
|00004580| 6f 77 65 72 20 6f 66 20 | 32 20 74 68 61 74 20 69 |ower of |2 that i|
|00004590| 73 20 3e 3d 20 6e 75 6d | 63 68 61 72 73 2c 20 61 |s >= num|chars, a|
|000045a0| 6e 64 20 74 68 65 20 6e | 75 6d 62 65 72 0a 58 20 |nd the n|umber.X |
|000045b0| 20 20 20 20 2a 20 6f 66 | 20 62 69 74 73 20 6e 65 | * of| bits ne|
|000045c0| 65 64 65 64 20 74 6f 20 | 73 74 6f 72 65 20 74 68 |eded to |store th|
|000045d0| 61 74 20 6d 61 6e 79 20 | 76 61 6c 75 65 73 2e 0a |at many |values..|
|000045e0| 58 20 20 20 20 20 2a 2f | 0a 58 20 20 20 20 66 6f |X */|.X fo|
|000045f0| 72 28 70 6f 66 32 20 3d | 20 32 2c 20 70 6f 66 32 |r(pof2 =| 2, pof2|
|00004600| 6c 65 6e 20 3d 20 31 3b | 20 70 6f 66 32 20 3c 20 |len = 1;| pof2 < |
|00004610| 6e 75 6d 63 68 61 72 73 | 3b 0a 58 09 70 6f 66 32 |numchars|;.X.pof2|
|00004620| 20 3c 3c 3d 20 31 2c 20 | 70 6f 66 32 6c 65 6e 2b | <<= 1, |pof2len+|
|00004630| 2b 29 3b 0a 58 0a 58 20 | 20 20 20 2f 2a 20 63 6f |+);.X.X | /* co|
|00004640| 6d 70 75 74 65 20 68 6f | 77 20 6d 61 6e 79 20 68 |mpute ho|w many h|
|00004650| 61 6c 66 20 63 6f 64 65 | 73 20 77 65 20 6e 65 65 |alf code|s we nee|
|00004660| 64 20 2a 2f 0a 58 20 20 | 20 20 68 61 6c 66 20 3d |d */.X | half =|
|00004670| 20 70 6f 66 32 20 2d 20 | 6e 75 6d 63 68 61 72 73 | pof2 - |numchars|
|00004680| 3b 0a 58 0a 58 20 20 20 | 20 2f 2a 20 63 6f 6d 70 |;.X.X | /* comp|
|00004690| 75 74 65 20 68 6f 77 20 | 6d 61 6e 79 20 77 68 6f |ute how |many who|
|000046a0| 6c 65 20 63 6f 64 65 73 | 20 77 65 20 6e 65 65 64 |le codes| we need|
|000046b0| 20 2a 2f 0a 58 20 20 20 | 20 77 68 6f 6c 65 20 3d | */.X | whole =|
|000046c0| 20 6e 75 6d 63 68 61 72 | 73 20 2d 20 68 61 6c 66 | numchar|s - half|
|000046d0| 3b 0a 58 0a 58 20 20 20 | 20 2f 2a 20 63 72 65 61 |;.X.X | /* crea|
|000046e0| 74 65 20 61 20 76 61 72 | 69 61 62 6c 65 20 6c 65 |te a var|iable le|
|000046f0| 6e 67 74 68 20 63 6f 64 | 65 20 66 6f 72 20 65 61 |ngth cod|e for ea|
|00004700| 63 68 20 76 61 6c 69 64 | 20 65 6e 74 72 79 20 2a |ch valid| entry *|
|00004710| 2f 0a 58 20 20 20 20 63 | 6f 64 65 20 3d 20 30 3b |/.X c|ode = 0;|
|00004720| 0a 58 20 20 20 20 78 20 | 3d 20 2d 31 3b 0a 58 0a |.X x |= -1;.X.|
|00004730| 58 20 20 20 20 2f 2a 20 | 63 72 65 61 74 65 20 74 |X /* |create t|
|00004740| 68 65 20 77 68 6f 6c 65 | 20 63 6f 64 65 73 20 2a |he whole| codes *|
|00004750| 2f 0a 58 20 20 20 20 77 | 68 69 6c 65 28 77 68 6f |/.X w|hile(who|
|00004760| 6c 65 2d 2d 29 20 7b 0a | 58 09 2f 2a 20 67 65 74 |le--) {.|X./* get|
|00004770| 20 6e 65 78 74 20 73 6c | 6f 74 20 2a 2f 0a 58 09 | next sl|ot */.X.|
|00004780| 64 6f 20 78 2b 2b 3b 20 | 77 68 69 6c 65 28 63 6f |do x++; |while(co|
|00004790| 64 65 73 5b 78 5d 2e 69 | 6e 75 73 65 20 3d 3d 20 |des[x].i|nuse == |
|000047a0| 30 29 3b 0a 58 0a 58 09 | 69 66 20 28 64 69 72 65 |0);.X.X.|if (dire|
|000047b0| 63 74 69 6f 6e 20 3d 3d | 20 44 45 43 4f 44 45 29 |ction ==| DECODE)|
|000047c0| 20 7b 0a 58 09 20 20 20 | 20 63 6f 64 65 73 5b 78 | {.X. | codes[x|
|000047d0| 5d 2e 63 6f 64 65 20 3d | 20 28 63 68 61 72 29 63 |].code =| (char)c|
|000047e0| 6f 64 65 3b 0a 58 09 20 | 20 20 20 63 6f 64 65 73 |ode;.X. | codes|
|000047f0| 5b 78 5d 2e 6c 65 6e 20 | 3d 20 28 63 68 61 72 29 |[x].len |= (char)|
|00004800| 70 6f 66 32 6c 65 6e 3b | 0a 58 09 7d 0a 58 09 65 |pof2len;|.X.}.X.e|
|00004810| 6c 73 65 0a 58 09 20 20 | 20 20 69 6e 69 74 5f 65 |lse.X. | init_e|
|00004820| 6e 63 6f 64 65 76 61 6c | 28 63 6f 64 65 73 2c 20 |ncodeval|(codes, |
|00004830| 63 6f 64 65 2c 20 70 6f | 66 32 6c 65 6e 2c 20 78 |code, po|f2len, x|
|00004840| 29 3b 0a 58 09 63 6f 64 | 65 2b 2b 3b 0a 58 20 20 |);.X.cod|e++;.X |
|00004850| 20 20 7d 0a 58 20 20 20 | 20 0a 58 20 20 20 20 2f | }.X | .X /|
|00004860| 2a 20 63 68 6f 70 20 6f | 66 66 20 4c 53 42 20 74 |* chop o|ff LSB t|
|00004870| 6f 20 66 6f 72 6d 20 74 | 68 65 20 68 61 6c 66 20 |o form t|he half |
|00004880| 63 6f 64 65 73 20 2a 2f | 0a 58 20 20 20 20 63 6f |codes */|.X co|
|00004890| 64 65 20 3e 3e 3d 20 31 | 3b 0a 58 20 20 20 20 70 |de >>= 1|;.X p|
|000048a0| 6f 66 32 6c 65 6e 2d 2d | 3b 0a 58 20 20 20 20 0a |of2len--|;.X .|
|000048b0| 58 20 20 20 20 2f 2a 20 | 63 72 65 61 74 65 20 74 |X /* |create t|
|000048c0| 68 65 20 68 61 6c 66 20 | 63 6f 64 65 73 20 2a 2f |he half |codes */|
|000048d0| 0a 58 20 20 20 20 77 68 | 69 6c 65 28 68 61 6c 66 |.X wh|ile(half|
|000048e0| 2d 2d 29 20 7b 0a 58 09 | 64 6f 20 78 2b 2b 3b 20 |--) {.X.|do x++; |
|000048f0| 77 68 69 6c 65 28 63 6f | 64 65 73 5b 78 5d 2e 69 |while(co|des[x].i|
|00004900| 6e 75 73 65 20 3d 3d 20 | 30 29 3b 0a 58 0a 58 09 |nuse == |0);.X.X.|
|00004910| 69 66 20 28 64 69 72 65 | 63 74 69 6f 6e 20 3d 3d |if (dire|ction ==|
|00004920| 20 44 45 43 4f 44 45 29 | 20 7b 0a 58 09 20 20 20 | DECODE)| {.X. |
|00004930| 20 63 6f 64 65 73 5b 78 | 5d 2e 63 6f 64 65 20 3d | codes[x|].code =|
|00004940| 20 28 63 68 61 72 29 63 | 6f 64 65 3b 0a 58 09 20 | (char)c|ode;.X. |
|00004950| 20 20 20 63 6f 64 65 73 | 5b 78 5d 2e 6c 65 6e 20 | codes|[x].len |
|00004960| 3d 20 28 63 68 61 72 29 | 70 6f 66 32 6c 65 6e 3b |= (char)|pof2len;|
|00004970| 0a 58 09 7d 0a 58 09 65 | 6c 73 65 0a 58 09 20 20 |.X.}.X.e|lse.X. |
|00004980| 20 20 69 6e 69 74 5f 65 | 6e 63 6f 64 65 76 61 6c | init_e|ncodeval|
|00004990| 28 63 6f 64 65 73 2c 20 | 63 6f 64 65 2c 20 70 6f |(codes, |code, po|
|000049a0| 66 32 6c 65 6e 2c 20 78 | 29 3b 0a 58 09 63 6f 64 |f2len, x|);.X.cod|
|000049b0| 65 2b 2b 3b 0a 58 20 20 | 20 20 7d 0a 58 7d 0a 45 |e++;.X | }.X}.E|
|000049c0| 4e 44 5f 4f 46 5f 46 49 | 4c 45 0a 69 66 20 74 65 |ND_OF_FI|LE.if te|
|000049d0| 73 74 20 35 31 39 35 20 | 2d 6e 65 20 60 77 63 20 |st 5195 |-ne `wc |
|000049e0| 2d 63 20 3c 27 63 6f 64 | 65 73 2e 63 27 60 3b 20 |-c <'cod|es.c'`; |
|000049f0| 74 68 65 6e 0a 20 20 20 | 20 65 63 68 6f 20 73 68 |then. | echo sh|
|00004a00| 61 72 3a 20 5c 22 27 63 | 6f 64 65 73 2e 63 27 5c |ar: \"'c|odes.c'\|
|00004a10| 22 20 75 6e 70 61 63 6b | 65 64 20 77 69 74 68 20 |" unpack|ed with |
|00004a20| 77 72 6f 6e 67 20 73 69 | 7a 65 21 0a 66 69 0a 23 |wrong si|ze!.fi.#|
|00004a30| 20 65 6e 64 20 6f 66 20 | 27 63 6f 64 65 73 2e 63 | end of |'codes.c|
|00004a40| 27 0a 66 69 0a 69 66 20 | 74 65 73 74 20 2d 66 20 |'.fi.if |test -f |
|00004a50| 27 63 6f 64 65 73 2e 68 | 27 20 2d 61 20 22 24 7b |'codes.h|' -a "${|
|00004a60| 31 7d 22 20 21 3d 20 22 | 2d 63 22 20 3b 20 74 68 |1}" != "|-c" ; th|
|00004a70| 65 6e 20 0a 20 20 65 63 | 68 6f 20 73 68 61 72 3a |en . ec|ho shar:|
|00004a80| 20 57 69 6c 6c 20 6e 6f | 74 20 63 6c 6f 62 62 65 | Will no|t clobbe|
|00004a90| 72 20 65 78 69 73 74 69 | 6e 67 20 66 69 6c 65 20 |r existi|ng file |
|00004aa0| 5c 22 27 63 6f 64 65 73 | 2e 68 27 5c 22 0a 65 6c |\"'codes|.h'\".el|
|00004ab0| 73 65 0a 65 63 68 6f 20 | 73 68 61 72 3a 20 45 78 |se.echo |shar: Ex|
|00004ac0| 74 72 61 63 74 69 6e 67 | 20 5c 22 27 63 6f 64 65 |tracting| \"'code|
|00004ad0| 73 2e 68 27 5c 22 20 5c | 28 31 31 38 38 20 63 68 |s.h'\" \|(1188 ch|
|00004ae0| 61 72 61 63 74 65 72 73 | 5c 29 0a 73 65 64 20 22 |aracters|\).sed "|
|00004af0| 73 2f 5e 58 2f 2f 22 20 | 3e 27 63 6f 64 65 73 2e |s/^X//" |>'codes.|
|00004b00| 68 27 20 3c 3c 27 45 4e | 44 5f 4f 46 5f 46 49 4c |h' <<'EN|D_OF_FIL|
|00004b10| 45 27 0a 58 2f 2a 0a 58 | 20 2a 20 24 48 65 61 64 |E'.X/*.X| * $Head|
|00004b20| 65 72 3a 20 2f 75 73 72 | 2f 70 65 6f 70 6c 65 2f |er: /usr|/people/|
|00004b30| 74 63 6c 2f 73 72 63 2f | 75 75 74 61 72 2f 52 43 |tcl/src/|uutar/RC|
|00004b40| 53 2f 63 6f 64 65 73 2e | 68 2c 76 20 31 2e 31 2e |S/codes.|h,v 1.1.|
|00004b50| 31 2e 32 20 31 39 39 33 | 2f 30 39 2f 31 31 20 31 |1.2 1993|/09/11 1|
|00004b60| 38 3a 34 31 3a 34 36 20 | 74 63 6c 20 45 78 70 20 |8:41:46 |tcl Exp |
|00004b70| 24 0a 58 20 2a 20 54 6f | 6d 20 4c 61 77 72 65 6e |$.X * To|m Lawren|
|00004b80| 63 65 0a 58 20 2a 20 74 | 63 6c 40 73 67 69 2e 63 |ce.X * t|cl@sgi.c|
|00004b90| 6f 6d 0a 58 20 2a 2f 0a | 58 0a 58 2f 2a 20 6e 75 |om.X */.|X.X/* nu|
|00004ba0| 6d 62 65 72 20 6f 66 20 | 70 72 69 6e 74 61 62 6c |mber of |printabl|
|00004bb0| 65 20 63 68 61 72 61 63 | 74 65 72 73 20 69 6e 20 |e charac|ters in |
|00004bc0| 6f 75 74 70 75 74 20 63 | 68 61 72 61 63 74 65 72 |output c|haracter|
|00004bd0| 20 73 65 74 20 2a 2f 0a | 58 65 78 74 65 72 6e 20 | set */.|Xextern |
|00004be0| 69 6e 74 20 6e 75 6d 63 | 68 61 72 73 3b 0a 58 0a |int numc|hars;.X.|
|00004bf0| 58 2f 2a 20 65 6e 63 6f | 64 69 6e 67 2f 64 65 63 |X/* enco|ding/dec|
|00004c00| 6f 64 69 6e 67 20 74 61 | 62 6c 65 2e 20 69 6e 75 |oding ta|ble. inu|
|00004c10| 73 65 20 69 6e 64 69 63 | 61 74 65 73 20 77 68 65 |se indic|ates whe|
|00004c20| 74 68 65 72 20 6f 72 20 | 6e 6f 74 20 74 68 65 20 |ther or |not the |
|00004c30| 63 68 61 72 61 63 74 65 | 72 0a 58 20 2a 20 77 68 |characte|r.X * wh|
|00004c40| 6f 73 65 20 61 73 63 69 | 69 20 63 6f 64 65 20 69 |ose asci|i code i|
|00004c50| 73 20 74 68 65 20 6f 66 | 66 73 65 74 20 69 6e 74 |s the of|fset int|
|00004c60| 6f 20 74 68 69 73 20 61 | 72 72 61 79 20 69 73 20 |o this a|rray is |
|00004c70| 70 61 72 74 20 6f 66 20 | 74 68 65 20 6f 75 74 70 |part of |the outp|
|00004c80| 75 74 20 0a 58 20 2a 20 | 70 72 69 6e 74 61 62 6c |ut .X * |printabl|
|00004c90| 65 20 63 68 61 72 61 63 | 74 65 72 20 73 65 74 2e |e charac|ter set.|
|00004ca0| 0a 58 20 2a 0a 58 20 2a | 20 57 68 65 6e 20 65 6e |.X *.X *| When en|
|00004cb0| 63 6f 64 69 6e 67 2c 20 | 74 68 65 20 6e 65 78 74 |coding, |the next|
|00004cc0| 20 38 20 62 69 74 73 20 | 28 6e 6f 74 20 6e 65 63 | 8 bits |(not nec|
|00004cd0| 65 73 73 61 72 69 6c 79 | 20 62 79 74 65 20 61 6c |essarily| byte al|
|00004ce0| 69 67 6e 65 64 29 20 69 | 6e 20 74 68 65 0a 58 20 |igned) i|n the.X |
|00004cf0| 2a 20 69 6e 70 75 74 20 | 62 69 6e 61 72 79 20 62 |* input |binary b|
|00004d00| 69 74 73 74 72 65 61 6d | 20 61 72 65 20 75 73 65 |itstream| are use|
|00004d10| 64 20 74 6f 20 69 6e 64 | 65 78 20 69 6e 74 6f 20 |d to ind|ex into |
|00004d20| 74 68 69 73 20 61 72 72 | 61 79 2e 20 54 68 65 20 |this arr|ay. The |
|00004d30| 63 6f 64 65 0a 58 20 2a | 20 66 69 65 6c 64 20 74 |code.X *| field t|
|00004d40| 68 65 6e 20 69 6e 64 69 | 63 61 74 65 73 20 74 68 |hen indi|cates th|
|00004d50| 65 20 70 72 69 6e 74 61 | 62 6c 65 20 6f 75 74 70 |e printa|ble outp|
|00004d60| 75 74 20 63 68 61 72 61 | 63 74 65 72 20 74 6f 20 |ut chara|cter to |
|00004d70| 61 70 70 65 6e 64 20 74 | 6f 20 74 68 65 0a 58 20 |append t|o the.X |
|00004d80| 2a 20 6f 75 74 70 75 74 | 2c 20 61 6e 64 20 74 68 |* output|, and th|
|00004d90| 65 20 6c 65 6e 20 66 69 | 65 6c 64 20 69 6e 64 69 |e len fi|eld indi|
|00004da0| 63 61 74 65 73 20 68 6f | 77 20 6d 61 6e 79 20 6f |cates ho|w many o|
|00004db0| 66 20 74 68 65 20 69 6e | 70 75 74 20 38 20 62 69 |f the in|put 8 bi|
|00004dc0| 74 73 0a 58 20 2a 20 73 | 68 6f 75 6c 64 20 62 65 |ts.X * s|hould be|
|00004dd0| 20 63 6f 6d 73 75 6d 65 | 64 20 62 79 20 74 68 69 | comsume|d by thi|
|00004de0| 73 20 6f 70 65 72 61 74 | 69 6f 6e 2c 20 69 2e 65 |s operat|ion, i.e|
|00004df0| 2e 20 74 68 65 20 69 6e | 70 75 74 20 62 69 74 73 |. the in|put bits|
|00004e00| 74 72 65 61 6d 20 69 73 | 0a 58 20 2a 20 61 64 76 |tream is|.X * adv|
|00004e10| 61 6e 63 65 64 20 62 79 | 20 6c 65 6e 20 62 69 74 |anced by| len bit|
|00004e20| 73 2e 0a 58 20 2a 0a 58 | 20 2a 20 57 68 65 6e 20 |s..X *.X| * When |
|00004e30| 64 65 63 6f 64 69 6e 67 | 2c 20 74 68 65 20 69 6e |decoding|, the in|
|00004e40| 70 75 74 20 70 72 69 6e | 74 61 62 6c 65 20 61 73 |put prin|table as|
|00004e50| 63 69 69 20 63 68 61 72 | 61 63 74 65 72 20 69 73 |cii char|acter is|
|00004e60| 20 75 73 65 64 20 74 6f | 20 69 6e 64 65 78 0a 58 | used to| index.X|
|00004e70| 20 2a 20 69 6e 74 6f 20 | 74 68 69 73 20 61 72 72 | * into |this arr|
|00004e80| 61 79 2e 20 54 68 65 20 | 76 61 72 69 61 62 6c 65 |ay. The |variable|
|00004e90| 20 6c 65 6e 67 74 68 20 | 28 38 20 62 69 74 73 20 | length |(8 bits |
|00004ea0| 6f 72 20 6c 65 73 73 29 | 20 62 69 74 66 69 65 6c |or less)| bitfiel|
|00004eb0| 64 20 73 74 6f 72 65 64 | 0a 58 20 2a 20 69 6e 20 |d stored|.X * in |
|00004ec0| 63 6f 64 65 20 61 6e 64 | 20 77 68 6f 73 65 20 6c |code and| whose l|
|00004ed0| 65 6e 67 74 68 20 69 73 | 20 6c 65 6e 2c 20 69 73 |ength is| len, is|
|00004ee0| 20 61 70 70 65 6e 64 65 | 64 20 74 6f 20 74 68 65 | appende|d to the|
|00004ef0| 20 6f 75 74 70 75 74 20 | 62 69 6e 61 72 79 0a 58 | output |binary.X|
|00004f00| 20 2a 20 62 69 74 73 74 | 72 65 61 6d 2e 0a 58 20 | * bitst|ream..X |
|00004f10| 2a 2f 0a 58 65 78 74 65 | 72 6e 20 73 74 72 75 63 |*/.Xexte|rn struc|
|00004f20| 74 20 63 6f 64 65 20 7b | 0a 58 20 20 20 20 63 68 |t code {|.X ch|
|00004f30| 61 72 20 69 6e 75 73 65 | 3b 0a 58 20 20 20 20 63 |ar inuse|;.X c|
|00004f40| 68 61 72 20 63 6f 64 65 | 3b 0a 58 20 20 20 20 63 |har code|;.X c|
|00004f50| 68 61 72 20 6c 65 6e 3b | 0a 58 7d 20 63 6f 64 65 |har len;|.X} code|
|00004f60| 73 5b 32 35 36 5d 3b 0a | 58 0a 58 76 6f 69 64 20 |s[256];.|X.Xvoid |
|00004f70| 69 6e 69 74 5f 63 6f 64 | 65 73 28 29 3b 0a 58 76 |init_cod|es();.Xv|
|00004f80| 6f 69 64 20 70 61 72 73 | 65 5f 63 68 61 72 76 61 |oid pars|e_charva|
|00004f90| 6c 5f 6c 69 73 74 28 29 | 3b 0a 58 76 6f 69 64 20 |l_list()|;.Xvoid |
|00004fa0| 70 72 69 6e 74 5f 63 68 | 61 72 76 61 6c 5f 6c 69 |print_ch|arval_li|
|00004fb0| 73 74 28 29 3b 0a 58 0a | 58 23 64 65 66 69 6e 65 |st();.X.|X#define|
|00004fc0| 20 45 4e 43 4f 44 45 20 | 30 0a 58 23 64 65 66 69 | ENCODE |0.X#defi|
|00004fd0| 6e 65 20 44 45 43 4f 44 | 45 20 31 0a 45 4e 44 5f |ne DECOD|E 1.END_|
|00004fe0| 4f 46 5f 46 49 4c 45 0a | 69 66 20 74 65 73 74 20 |OF_FILE.|if test |
|00004ff0| 31 31 38 38 20 2d 6e 65 | 20 60 77 63 20 2d 63 20 |1188 -ne| `wc -c |
|00005000| 3c 27 63 6f 64 65 73 2e | 68 27 60 3b 20 74 68 65 |<'codes.|h'`; the|
|00005010| 6e 0a 20 20 20 20 65 63 | 68 6f 20 73 68 61 72 3a |n. ec|ho shar:|
|00005020| 20 5c 22 27 63 6f 64 65 | 73 2e 68 27 5c 22 20 75 | \"'code|s.h'\" u|
|00005030| 6e 70 61 63 6b 65 64 20 | 77 69 74 68 20 77 72 6f |npacked |with wro|
|00005040| 6e 67 20 73 69 7a 65 21 | 0a 66 69 0a 23 20 65 6e |ng size!|.fi.# en|
|00005050| 64 20 6f 66 20 27 63 6f | 64 65 73 2e 68 27 0a 66 |d of 'co|des.h'.f|
|00005060| 69 0a 69 66 20 74 65 73 | 74 20 2d 66 20 27 64 65 |i.if tes|t -f 'de|
|00005070| 63 6f 64 65 2e 31 27 20 | 2d 61 20 22 24 7b 31 7d |code.1' |-a "${1}|
|00005080| 22 20 21 3d 20 22 2d 63 | 22 20 3b 20 74 68 65 6e |" != "-c|" ; then|
|00005090| 20 0a 20 20 65 63 68 6f | 20 73 68 61 72 3a 20 57 | . echo| shar: W|
|000050a0| 69 6c 6c 20 6e 6f 74 20 | 63 6c 6f 62 62 65 72 20 |ill not |clobber |
|000050b0| 65 78 69 73 74 69 6e 67 | 20 66 69 6c 65 20 5c 22 |existing| file \"|
|000050c0| 27 64 65 63 6f 64 65 2e | 31 27 5c 22 0a 65 6c 73 |'decode.|1'\".els|
|000050d0| 65 0a 65 63 68 6f 20 73 | 68 61 72 3a 20 45 78 74 |e.echo s|har: Ext|
|000050e0| 72 61 63 74 69 6e 67 20 | 5c 22 27 64 65 63 6f 64 |racting |\"'decod|
|000050f0| 65 2e 31 27 5c 22 20 5c | 28 37 31 37 20 63 68 61 |e.1'\" \|(717 cha|
|00005100| 72 61 63 74 65 72 73 5c | 29 0a 73 65 64 20 22 73 |racters\|).sed "s|
|00005110| 2f 5e 58 2f 2f 22 20 3e | 27 64 65 63 6f 64 65 2e |/^X//" >|'decode.|
|00005120| 31 27 20 3c 3c 27 45 4e | 44 5f 4f 46 5f 46 49 4c |1' <<'EN|D_OF_FIL|
|00005130| 45 27 0a 58 2e 5c 22 20 | 24 48 65 61 64 65 72 3a |E'.X.\" |$Header:|
|00005140| 20 2f 75 73 72 2f 70 65 | 6f 70 6c 65 2f 74 63 6c | /usr/pe|ople/tcl|
|00005150| 2f 73 72 63 2f 75 75 74 | 61 72 2f 52 43 53 2f 64 |/src/uut|ar/RCS/d|
|00005160| 65 63 6f 64 65 2e 31 2c | 76 20 31 2e 31 20 31 39 |ecode.1,|v 1.1 19|
|00005170| 39 33 2f 30 39 2f 31 31 | 20 32 30 3a 30 36 3a 30 |93/09/11| 20:06:0|
|00005180| 39 20 74 63 6c 20 45 78 | 70 20 24 0a 58 2e 54 48 |9 tcl Ex|p $.X.TH|
|00005190| 20 64 65 63 6f 64 65 20 | 31 20 22 31 31 20 53 65 | decode |1 "11 Se|
|000051a0| 70 74 20 31 39 39 33 22 | 0a 58 2e 53 48 20 4e 41 |pt 1993"|.X.SH NA|
|000051b0| 4d 45 0a 58 64 65 63 6f | 64 65 20 5c 2d 20 64 65 |ME.Xdeco|de \- de|
|000051c0| 63 6f 64 65 20 61 20 66 | 69 6c 65 20 65 6e 63 6f |code a f|ile enco|
|000051d0| 64 65 64 20 77 69 74 68 | 20 74 68 65 20 65 6e 63 |ded with| the enc|
|000051e0| 6f 64 65 28 31 29 20 75 | 74 69 6c 69 74 79 0a 58 |ode(1) u|tility.X|
|000051f0| 2e 53 48 20 53 59 4e 4f | 50 53 49 53 0a 58 2e 42 |.SH SYNO|PSIS.X.B|
|00005200| 20 64 65 63 6f 64 65 0a | 58 5b 0a 58 2e 42 20 5c | decode.|X[.X.B \|
|00005210| 2d 69 20 5c 63 0a 58 2e | 49 20 3c 69 6e 70 75 74 |-i \c.X.|I <input|
|00005220| 66 69 6c 65 3e 0a 58 5d | 0a 58 5b 0a 58 2e 42 20 |file>.X]|.X[.X.B |
|00005230| 5c 2d 6f 20 5c 63 0a 58 | 2e 49 20 3c 6f 75 74 70 |\-o \c.X|.I <outp|
|00005240| 75 74 66 69 6c 65 3e 0a | 58 5d 0a 58 2e 53 48 20 |utfile>.|X].X.SH |
|00005250| 44 45 53 43 52 49 50 54 | 49 4f 4e 0a 58 2e 4c 50 |DESCRIPT|ION.X.LP|
|00005260| 0a 58 44 65 63 6f 64 65 | 20 64 65 63 6f 64 65 73 |.XDecode| decodes|
|00005270| 20 61 20 66 69 6c 65 20 | 77 68 69 63 68 20 68 61 | a file |which ha|
|00005280| 73 20 62 65 65 6e 20 65 | 6e 63 6f 64 65 64 20 69 |s been e|ncoded i|
|00005290| 6e 20 70 72 69 6e 74 61 | 62 6c 65 20 66 6f 72 6d |n printa|ble form|
|000052a0| 61 74 20 77 69 74 68 0a | 58 74 68 65 20 65 6e 63 |at with.|Xthe enc|
|000052b0| 6f 64 65 28 31 29 20 75 | 74 69 6c 69 74 79 2e 0a |ode(1) u|tility..|
|000052c0| 58 2e 53 48 20 4f 50 54 | 49 4f 4e 53 0a 58 2e 54 |X.SH OPT|IONS.X.T|
|000052d0| 50 0a 58 2e 42 20 5c 2d | 69 5c 63 0a 58 2e 49 20 |P.X.B \-|i\c.X.I |
|000052e0| 3c 69 6e 70 75 74 66 69 | 6c 65 3e 0a 58 2e 62 72 |<inputfi|le>.X.br|
|000052f0| 0a 58 73 70 65 63 69 66 | 69 65 73 20 74 68 65 20 |.Xspecif|ies the |
|00005300| 66 69 6c 65 20 74 6f 20 | 72 65 61 64 20 69 6e 70 |file to |read inp|
|00005310| 75 74 20 66 72 6f 6d 2e | 20 49 66 20 74 68 69 73 |ut from.| If this|
|00005320| 20 61 72 67 75 6d 65 6e | 74 20 69 73 20 6f 6d 69 | argumen|t is omi|
|00005330| 74 74 65 64 2c 0a 58 73 | 74 64 69 6e 20 69 73 20 |tted,.Xs|tdin is |
|00005340| 75 73 65 64 2e 0a 58 2e | 54 50 0a 58 2e 42 20 5c |used..X.|TP.X.B \|
|00005350| 2d 6f 5c 63 0a 58 2e 49 | 20 3c 6f 75 74 70 75 74 |-o\c.X.I| <output|
|00005360| 66 69 6c 65 3e 0a 58 2e | 62 72 0a 58 73 70 65 63 |file>.X.|br.Xspec|
|00005370| 69 66 69 65 73 20 74 68 | 65 20 66 69 6c 65 20 74 |ifies th|e file t|
|00005380| 6f 20 77 72 69 74 65 20 | 6f 75 74 70 75 74 20 74 |o write |output t|
|00005390| 6f 2e 20 49 66 20 74 68 | 69 73 20 61 72 67 75 6d |o. If th|is argum|
|000053a0| 65 6e 74 20 69 73 20 6f | 6d 69 74 74 65 64 2c 0a |ent is o|mitted,.|
|000053b0| 58 74 68 65 20 6e 61 6d | 65 20 6f 66 20 74 68 65 |Xthe nam|e of the|
|000053c0| 20 6f 75 74 70 75 74 20 | 66 69 6c 65 20 69 73 20 | output |file is |
|000053d0| 6f 62 74 61 69 6e 65 64 | 20 66 72 6f 6d 20 74 68 |obtained| from th|
|000053e0| 65 20 66 69 72 73 74 20 | 6c 69 6e 65 20 6f 66 20 |e first |line of |
|000053f0| 74 68 65 0a 58 69 6e 70 | 75 74 20 66 69 6c 65 2e |the.Xinp|ut file.|
|00005400| 0a 58 2e 53 48 20 22 53 | 45 45 20 41 4c 53 4f 22 |.X.SH "S|EE ALSO"|
|00005410| 0a 58 2e 42 52 20 65 6e | 63 6f 64 65 20 28 31 29 |.X.BR en|code (1)|
|00005420| 2c 0a 45 4e 44 5f 4f 46 | 5f 46 49 4c 45 0a 69 66 |,.END_OF|_FILE.if|
|00005430| 20 74 65 73 74 20 37 31 | 37 20 2d 6e 65 20 60 77 | test 71|7 -ne `w|
|00005440| 63 20 2d 63 20 3c 27 64 | 65 63 6f 64 65 2e 31 27 |c -c <'d|ecode.1'|
|00005450| 60 3b 20 74 68 65 6e 0a | 20 20 20 20 65 63 68 6f |`; then.| echo|
|00005460| 20 73 68 61 72 3a 20 5c | 22 27 64 65 63 6f 64 65 | shar: \|"'decode|
|00005470| 2e 31 27 5c 22 20 75 6e | 70 61 63 6b 65 64 20 77 |.1'\" un|packed w|
|00005480| 69 74 68 20 77 72 6f 6e | 67 20 73 69 7a 65 21 0a |ith wron|g size!.|
|00005490| 66 69 0a 23 20 65 6e 64 | 20 6f 66 20 27 64 65 63 |fi.# end| of 'dec|
|000054a0| 6f 64 65 2e 31 27 0a 66 | 69 0a 69 66 20 74 65 73 |ode.1'.f|i.if tes|
|000054b0| 74 20 2d 66 20 27 64 65 | 63 6f 64 65 2e 63 27 20 |t -f 'de|code.c' |
|000054c0| 2d 61 20 22 24 7b 31 7d | 22 20 21 3d 20 22 2d 63 |-a "${1}|" != "-c|
|000054d0| 22 20 3b 20 74 68 65 6e | 20 0a 20 20 65 63 68 6f |" ; then| . echo|
|000054e0| 20 73 68 61 72 3a 20 57 | 69 6c 6c 20 6e 6f 74 20 | shar: W|ill not |
|000054f0| 63 6c 6f 62 62 65 72 20 | 65 78 69 73 74 69 6e 67 |clobber |existing|
|00005500| 20 66 69 6c 65 20 5c 22 | 27 64 65 63 6f 64 65 2e | file \"|'decode.|
|00005510| 63 27 5c 22 0a 65 6c 73 | 65 0a 65 63 68 6f 20 73 |c'\".els|e.echo s|
|00005520| 68 61 72 3a 20 45 78 74 | 72 61 63 74 69 6e 67 20 |har: Ext|racting |
|00005530| 5c 22 27 64 65 63 6f 64 | 65 2e 63 27 5c 22 20 5c |\"'decod|e.c'\" \|
|00005540| 28 35 35 38 34 20 63 68 | 61 72 61 63 74 65 72 73 |(5584 ch|aracters|
|00005550| 5c 29 0a 73 65 64 20 22 | 73 2f 5e 58 2f 2f 22 20 |\).sed "|s/^X//" |
|00005560| 3e 27 64 65 63 6f 64 65 | 2e 63 27 20 3c 3c 27 45 |>'decode|.c' <<'E|
|00005570| 4e 44 5f 4f 46 5f 46 49 | 4c 45 27 0a 58 2f 2a 0a |ND_OF_FI|LE'.X/*.|
|00005580| 58 20 2a 20 24 48 65 61 | 64 65 72 3a 20 2f 75 73 |X * $Hea|der: /us|
|00005590| 72 2f 70 65 6f 70 6c 65 | 2f 74 63 6c 2f 73 72 63 |r/people|/tcl/src|
|000055a0| 2f 75 75 74 61 72 2f 52 | 43 53 2f 64 65 63 6f 64 |/uutar/R|CS/decod|
|000055b0| 65 2e 63 2c 76 20 31 2e | 31 2e 31 2e 33 20 31 39 |e.c,v 1.|1.1.3 19|
|000055c0| 39 33 2f 30 39 2f 31 31 | 20 31 38 3a 34 32 3a 31 |93/09/11| 18:42:1|
|000055d0| 37 20 74 63 6c 20 45 78 | 70 20 24 0a 58 20 2a 20 |7 tcl Ex|p $.X * |
|000055e0| 54 6f 6d 20 4c 61 77 72 | 65 6e 63 65 0a 58 20 2a |Tom Lawr|ence.X *|
|000055f0| 20 74 63 6c 40 73 67 69 | 2e 63 6f 6d 0a 58 20 2a | tcl@sgi|.com.X *|
|00005600| 2f 0a 58 0a 58 23 69 6e | 63 6c 75 64 65 20 3c 73 |/.X.X#in|clude <s|
|00005610| 74 64 69 6f 2e 68 3e 0a | 58 23 69 6e 63 6c 75 64 |tdio.h>.|X#includ|
|00005620| 65 20 3c 66 63 6e 74 6c | 2e 68 3e 0a 58 23 69 6e |e <fcntl|.h>.X#in|
|00005630| 63 6c 75 64 65 20 3c 73 | 74 64 6c 69 62 2e 68 3e |clude <s|tdlib.h>|
|00005640| 0a 58 23 69 6e 63 6c 75 | 64 65 20 3c 73 74 72 69 |.X#inclu|de <stri|
|00005650| 6e 67 2e 68 3e 0a 58 23 | 69 6e 63 6c 75 64 65 20 |ng.h>.X#|include |
|00005660| 3c 73 74 72 69 6e 67 73 | 2e 68 3e 0a 58 23 69 6e |<strings|.h>.X#in|
|00005670| 63 6c 75 64 65 20 3c 63 | 74 79 70 65 2e 68 3e 0a |clude <c|type.h>.|
|00005680| 58 23 69 6e 63 6c 75 64 | 65 20 22 63 6f 64 65 73 |X#includ|e "codes|
|00005690| 2e 68 22 0a 58 0a 58 2f | 2a 0a 58 20 2a 20 67 69 |.h".X.X/|*.X * gi|
|000056a0| 76 65 6e 20 61 20 73 74 | 72 69 6e 67 20 77 69 74 |ven a st|ring wit|
|000056b0| 68 20 6e 20 74 6f 6b 65 | 6e 73 20 73 65 70 61 72 |h n toke|ns separ|
|000056c0| 61 74 65 64 20 62 79 20 | 77 68 69 74 65 20 73 70 |ated by |white sp|
|000056d0| 61 63 65 20 69 6e 20 69 | 74 2c 20 61 6e 64 20 61 |ace in i|t, and a|
|000056e0| 0a 58 20 2a 20 70 6f 69 | 6e 74 65 72 20 74 6f 20 |.X * poi|nter to |
|000056f0| 61 20 63 68 61 72 20 76 | 65 63 74 6f 72 2c 20 63 |a char v|ector, c|
|00005700| 72 65 61 74 65 20 61 20 | 76 65 63 74 6f 72 20 77 |reate a |vector w|
|00005710| 69 74 68 20 65 61 63 68 | 20 70 6f 69 6e 74 65 72 |ith each| pointer|
|00005720| 20 70 6f 69 6e 74 69 6e | 67 0a 58 20 2a 20 74 6f | pointin|g.X * to|
|00005730| 20 61 20 73 75 63 63 65 | 73 73 69 76 65 20 74 6f | a succe|ssive to|
|00005740| 6b 65 6e 20 61 6e 64 20 | 6e 75 6c 6c 20 74 65 72 |ken and |null ter|
|00005750| 6d 69 6e 61 74 65 20 74 | 68 65 20 74 6f 6b 65 6e |minate t|he token|
|00005760| 73 2e 20 20 52 65 74 75 | 72 6e 20 74 68 65 0a 58 |s. Retu|rn the.X|
|00005770| 20 2a 20 6e 75 6d 62 65 | 72 20 6f 66 20 74 6f 6b | * numbe|r of tok|
|00005780| 65 6e 73 20 6f 72 20 2d | 31 20 6f 6e 20 65 72 72 |ens or -|1 on err|
|00005790| 6f 72 2e 20 20 54 68 69 | 73 20 72 6f 75 74 69 6e |or. Thi|s routin|
|000057a0| 65 20 69 73 20 64 65 73 | 74 72 75 63 74 69 76 65 |e is des|tructive|
|000057b0| 20 74 6f 20 74 68 65 0a | 58 20 2a 20 70 61 73 73 | to the.|X * pass|
|000057c0| 65 64 20 73 74 72 69 6e | 67 0a 58 20 2a 2f 0a 58 |ed strin|g.X */.X|
|000057d0| 23 64 65 66 69 6e 65 20 | 49 53 5f 57 48 49 54 45 |#define |IS_WHITE|
|000057e0| 5f 53 50 41 43 45 28 63 | 29 20 28 63 20 3d 3d 20 |_SPACE(c|) (c == |
|000057f0| 27 20 27 20 7c 7c 20 63 | 20 3d 3d 20 27 5c 74 27 |' ' || c| == '\t'|
|00005800| 29 0a 58 23 64 65 66 69 | 6e 65 20 56 45 43 4c 45 |).X#defi|ne VECLE|
|00005810| 4e 20 31 30 0a 58 0a 58 | 46 49 4c 45 20 2a 69 6e |N 10.X.X|FILE *in|
|00005820| 66 70 2c 20 2a 6f 75 74 | 66 70 3b 0a 58 0a 58 73 |fp, *out|fp;.X.Xs|
|00005830| 74 61 74 69 63 20 69 6e | 74 0a 58 74 6f 6b 65 6e |tatic in|t.Xtoken|
|00005840| 69 7a 65 28 73 74 72 69 | 6e 67 2c 20 76 65 63 74 |ize(stri|ng, vect|
|00005850| 6f 72 29 0a 58 20 20 20 | 20 63 68 61 72 20 2a 73 |or).X | char *s|
|00005860| 74 72 69 6e 67 3b 0a 58 | 20 20 20 20 63 68 61 72 |tring;.X| char|
|00005870| 20 2a 2a 76 65 63 74 6f | 72 3b 0a 58 7b 0a 58 20 | **vecto|r;.X{.X |
|00005880| 20 20 20 69 6e 74 20 74 | 6f 6b 65 6e 73 3b 0a 58 | int t|okens;.X|
|00005890| 20 20 20 20 65 6e 75 6d | 20 7b 0a 58 09 57 48 49 | enum| {.X.WHI|
|000058a0| 54 45 5f 53 50 41 43 45 | 2c 0a 58 09 54 4f 4b 45 |TE_SPACE|,.X.TOKE|
|000058b0| 4e 0a 58 20 20 20 20 7d | 20 73 74 61 74 65 3b 0a |N.X }| state;.|
|000058c0| 58 20 20 20 20 63 68 61 | 72 20 2a 63 3b 0a 58 0a |X cha|r *c;.X.|
|000058d0| 58 20 20 20 20 2f 2a 20 | 73 63 61 6e 20 74 68 72 |X /* |scan thr|
|000058e0| 6f 75 67 68 20 74 68 65 | 20 73 74 72 69 6e 67 20 |ough the| string |
|000058f0| 73 65 74 74 69 6e 67 20 | 75 70 20 74 68 65 20 76 |setting |up the v|
|00005900| 65 63 74 6f 72 20 70 6f | 69 6e 74 65 72 73 20 61 |ector po|inters a|
|00005910| 6e 64 0a 58 20 20 20 20 | 20 2a 20 6e 75 6c 6c 20 |nd.X | * null |
|00005920| 74 65 72 6d 69 6e 61 74 | 69 6e 67 20 74 68 65 20 |terminat|ing the |
|00005930| 74 6f 6b 65 6e 73 0a 58 | 20 20 20 20 20 2a 2f 0a |tokens.X| */.|
|00005940| 58 20 20 20 20 74 6f 6b | 65 6e 73 20 3d 20 30 3b |X tok|ens = 0;|
|00005950| 0a 58 20 20 20 20 73 74 | 61 74 65 20 3d 20 57 48 |.X st|ate = WH|
|00005960| 49 54 45 5f 53 50 41 43 | 45 3b 0a 58 0a 58 20 20 |ITE_SPAC|E;.X.X |
|00005970| 20 20 66 6f 72 28 63 20 | 3d 20 73 74 72 69 6e 67 | for(c |= string|
|00005980| 3b 20 2a 63 3b 20 63 2b | 2b 29 20 7b 0a 58 09 69 |; *c; c+|+) {.X.i|
|00005990| 66 20 28 73 74 61 74 65 | 20 3d 3d 20 57 48 49 54 |f (state| == WHIT|
|000059a0| 45 5f 53 50 41 43 45 20 | 26 26 20 21 49 53 5f 57 |E_SPACE |&& !IS_W|
|000059b0| 48 49 54 45 5f 53 50 41 | 43 45 28 2a 63 29 29 20 |HITE_SPA|CE(*c)) |
|000059c0| 7b 0a 58 09 20 20 20 20 | 2f 2a 20 6a 75 73 74 20 |{.X. |/* just |
|000059d0| 68 69 74 20 62 65 67 69 | 6e 6e 69 6e 67 20 6f 66 |hit begi|nning of|
|000059e0| 20 61 20 74 6f 6b 65 6e | 20 2a 2f 0a 58 09 20 20 | a token| */.X. |
|000059f0| 20 20 76 65 63 74 6f 72 | 5b 74 6f 6b 65 6e 73 5d | vector|[tokens]|
|00005a00| 20 3d 20 63 3b 0a 58 09 | 20 20 20 20 74 6f 6b 65 | = c;.X.| toke|
|00005a10| 6e 73 2b 2b 3b 0a 58 09 | 20 20 20 20 73 74 61 74 |ns++;.X.| stat|
|00005a20| 65 20 3d 20 54 4f 4b 45 | 4e 3b 0a 58 0a 58 09 20 |e = TOKE|N;.X.X. |
|00005a30| 20 20 20 69 66 20 28 74 | 6f 6b 65 6e 73 20 3e 3d | if (t|okens >=|
|00005a40| 20 56 45 43 4c 45 4e 29 | 20 7b 0a 58 09 09 66 70 | VECLEN)| {.X..fp|
|00005a50| 72 69 6e 74 66 28 73 74 | 64 65 72 72 2c 20 22 74 |rintf(st|derr, "t|
|00005a60| 6f 6f 20 6d 61 6e 79 20 | 74 6f 6b 65 6e 73 20 69 |oo many |tokens i|
|00005a70| 6e 20 69 6e 70 75 74 5c | 6e 22 29 3b 0a 58 09 09 |n input\|n");.X..|
|00005a80| 65 78 69 74 28 31 29 3b | 0a 58 09 20 20 20 20 7d |exit(1);|.X. }|
|00005a90| 0a 58 09 7d 0a 58 09 65 | 6c 73 65 20 69 66 20 28 |.X.}.X.e|lse if (|
|00005aa0| 73 74 61 74 65 20 3d 3d | 20 54 4f 4b 45 4e 20 26 |state ==| TOKEN &|
|00005ab0| 26 20 49 53 5f 57 48 49 | 54 45 5f 53 50 41 43 45 |& IS_WHI|TE_SPACE|
|00005ac0| 28 2a 63 29 29 20 7b 0a | 58 09 20 20 20 20 2f 2a |(*c)) {.|X. /*|
|00005ad0| 20 6a 75 73 74 20 65 6e | 64 65 64 20 61 20 74 6f | just en|ded a to|
|00005ae0| 6b 65 6e 20 2a 2f 0a 58 | 09 20 20 20 20 2a 63 20 |ken */.X|. *c |
|00005af0| 3d 20 30 3b 0a 58 09 20 | 20 20 20 73 74 61 74 65 |= 0;.X. | state|
|00005b00| 20 3d 20 57 48 49 54 45 | 5f 53 50 41 43 45 3b 0a | = WHITE|_SPACE;.|
|00005b10| 58 09 7d 0a 58 20 20 20 | 20 7d 0a 58 20 20 20 20 |X.}.X | }.X |
|00005b20| 72 65 74 75 72 6e 28 74 | 6f 6b 65 6e 73 29 3b 0a |return(t|okens);.|
|00005b30| 58 7d 0a 58 0a 58 2f 2a | 20 6e 6f 72 6d 61 6c 6c |X}.X.X/*| normall|
|00005b40| 79 20 49 27 64 20 75 73 | 65 20 73 74 72 74 6f 6c |y I'd us|e strtol|
|00005b50| 20 66 6f 72 20 74 68 69 | 73 2c 20 62 75 74 20 73 | for thi|s, but s|
|00005b60| 74 72 74 6f 6c 20 63 61 | 6e 27 74 20 68 61 6e 64 |trtol ca|n't hand|
|00005b70| 6c 65 0a 58 20 2a 20 75 | 6e 73 69 67 6e 65 64 20 |le.X * u|nsigned |
|00005b80| 76 61 6c 75 65 73 20 67 | 72 65 61 74 65 72 20 74 |values g|reater t|
|00005b90| 68 61 6e 20 30 78 37 46 | 46 46 46 46 46 46 20 6f |han 0x7F|FFFFFF o|
|00005ba0| 6e 20 73 6f 6d 65 20 6d | 61 63 68 69 6e 65 73 2e |n some m|achines.|
|00005bb0| 0a 58 20 2a 2f 0a 58 73 | 74 61 74 69 63 20 75 6e |.X */.Xs|tatic un|
|00005bc0| 73 69 67 6e 65 64 20 69 | 6e 74 0a 58 68 65 78 32 |signed i|nt.Xhex2|
|00005bd0| 6c 6f 6e 67 28 73 74 72 | 29 0a 58 20 20 20 20 63 |long(str|).X c|
|00005be0| 68 61 72 20 2a 73 74 72 | 3b 0a 58 7b 0a 58 20 20 |har *str|;.X{.X |
|00005bf0| 20 20 75 6e 73 69 67 6e | 65 64 20 6c 6f 6e 67 20 | unsign|ed long |
|00005c00| 72 65 74 20 3d 20 30 3b | 0a 58 20 20 20 20 63 68 |ret = 0;|.X ch|
|00005c10| 61 72 20 2a 63 2c 20 63 | 31 3b 0a 58 0a 58 20 20 |ar *c, c|1;.X.X |
|00005c20| 20 20 66 6f 72 28 63 20 | 3d 20 73 74 72 3b 20 2a | for(c |= str; *|
|00005c30| 63 3b 20 63 2b 2b 29 20 | 7b 0a 58 09 63 31 20 3d |c; c++) |{.X.c1 =|
|00005c40| 20 2a 63 3b 0a 58 09 69 | 66 20 28 63 31 20 3e 3d | *c;.X.i|f (c1 >=|
|00005c50| 20 27 30 27 20 26 26 20 | 63 31 20 3c 3d 20 27 39 | '0' && |c1 <= '9|
|00005c60| 27 29 0a 58 09 20 20 20 | 20 63 31 20 2d 3d 20 27 |').X. | c1 -= '|
|00005c70| 30 27 3b 0a 58 09 65 6c | 73 65 20 69 66 20 28 63 |0';.X.el|se if (c|
|00005c80| 31 20 3e 3d 20 27 61 27 | 20 26 26 20 63 31 20 3c |1 >= 'a'| && c1 <|
|00005c90| 3d 20 27 66 27 29 0a 58 | 09 20 20 20 20 63 31 20 |= 'f').X|. c1 |
|00005ca0| 2d 3d 20 28 27 61 27 20 | 2d 20 31 30 29 3b 0a 58 |-= ('a' |- 10);.X|
|00005cb0| 09 65 6c 73 65 20 69 66 | 20 28 63 31 20 3e 3d 20 |.else if| (c1 >= |
|00005cc0| 27 41 27 20 26 26 20 63 | 31 20 3c 3d 20 27 46 27 |'A' && c|1 <= 'F'|
|00005cd0| 29 0a 58 09 20 20 20 20 | 63 31 20 2d 3d 20 28 27 |).X. |c1 -= ('|
|00005ce0| 41 27 20 2d 20 31 30 29 | 3b 0a 58 09 72 65 74 20 |A' - 10)|;.X.ret |
|00005cf0| 3d 20 28 72 65 74 20 3c | 3c 20 34 29 20 2b 20 63 |= (ret <|< 4) + c|
|00005d00| 31 3b 0a 58 20 20 20 20 | 7d 0a 58 20 20 20 20 72 |1;.X |}.X r|
|00005d10| 65 74 75 72 6e 28 72 65 | 74 29 3b 0a 58 7d 0a 58 |eturn(re|t);.X}.X|
|00005d20| 0a 58 73 74 61 74 69 63 | 20 76 6f 69 64 0a 58 75 |.Xstatic| void.Xu|
|00005d30| 73 61 67 65 28 29 0a 58 | 7b 0a 58 20 20 20 20 70 |sage().X|{.X p|
|00005d40| 72 69 6e 74 66 28 22 6f | 70 74 69 6f 6e 73 3a 5c |rintf("o|ptions:\|
|00005d50| 6e 22 29 3b 0a 58 20 20 | 20 20 70 72 69 6e 74 66 |n");.X | printf|
|00005d60| 28 22 2d 69 20 3c 69 6e | 70 75 74 66 69 6c 65 3e |("-i <in|putfile>|
|00005d70| 5c 6e 22 29 3b 0a 58 20 | 20 20 20 70 72 69 6e 74 |\n");.X | print|
|00005d80| 66 28 22 2d 6f 20 3c 6f | 75 74 70 75 74 66 69 6c |f("-o <o|utputfil|
|00005d90| 65 3e 5c 6e 22 29 3b 0a | 58 20 20 20 20 65 78 69 |e>\n");.|X exi|
|00005da0| 74 28 31 29 3b 0a 58 7d | 0a 58 0a 58 2f 2a 20 70 |t(1);.X}|.X.X/* p|
|00005db0| 61 72 73 65 20 63 6f 6d | 6d 61 6e 64 20 6c 69 6e |arse com|mand lin|
|00005dc0| 65 20 61 72 67 75 6d 65 | 6e 74 73 20 2a 2f 0a 58 |e argume|nts */.X|
|00005dd0| 73 74 61 74 69 63 20 76 | 6f 69 64 0a 58 70 61 72 |static v|oid.Xpar|
|00005de0| 73 65 28 61 72 67 63 2c | 20 61 72 67 76 29 0a 58 |se(argc,| argv).X|
|00005df0| 20 20 20 20 69 6e 74 20 | 61 72 67 63 3b 0a 58 20 | int |argc;.X |
|00005e00| 20 20 20 63 68 61 72 20 | 2a 2a 61 72 67 76 3b 0a | char |**argv;.|
|00005e10| 58 7b 0a 58 20 20 20 20 | 63 68 61 72 20 2a 69 6e |X{.X |char *in|
|00005e20| 66 69 6c 65 2c 20 2a 6f | 75 74 66 69 6c 65 3b 0a |file, *o|utfile;.|
|00005e30| 58 0a 58 20 20 20 20 69 | 6e 66 69 6c 65 20 3d 20 |X.X i|nfile = |
|00005e40| 6f 75 74 66 69 6c 65 20 | 3d 20 30 3b 0a 58 0a 58 |outfile |= 0;.X.X|
|00005e50| 20 20 20 20 77 68 69 6c | 65 28 2d 2d 61 72 67 63 | whil|e(--argc|
|00005e60| 29 20 7b 0a 58 09 61 72 | 67 76 2b 2b 3b 0a 58 09 |) {.X.ar|gv++;.X.|
|00005e70| 69 66 20 28 21 73 74 72 | 63 6d 70 28 2a 61 72 67 |if (!str|cmp(*arg|
|00005e80| 76 2c 20 22 2d 69 22 29 | 29 20 7b 0a 58 09 20 20 |v, "-i")|) {.X. |
|00005e90| 20 20 69 66 20 28 61 72 | 67 63 20 3c 20 32 29 0a | if (ar|gc < 2).|
|00005ea0| 58 09 09 75 73 61 67 65 | 28 29 3b 0a 58 09 20 20 |X..usage|();.X. |
|00005eb0| 20 20 61 72 67 63 2d 2d | 3b 0a 58 09 20 20 20 20 | argc--|;.X. |
|00005ec0| 61 72 67 76 2b 2b 3b 0a | 58 09 20 20 20 20 69 6e |argv++;.|X. in|
|00005ed0| 66 69 6c 65 20 3d 20 2a | 61 72 67 76 3b 0a 58 09 |file = *|argv;.X.|
|00005ee0| 7d 0a 58 09 65 6c 73 65 | 20 69 66 20 28 21 73 74 |}.X.else| if (!st|
|00005ef0| 72 63 6d 70 28 2a 61 72 | 67 76 2c 20 22 2d 6f 22 |rcmp(*ar|gv, "-o"|
|00005f00| 29 29 20 7b 0a 58 09 20 | 20 20 20 69 66 20 28 61 |)) {.X. | if (a|
|00005f10| 72 67 63 20 3c 20 32 29 | 0a 58 09 09 75 73 61 67 |rgc < 2)|.X..usag|
|00005f20| 65 28 29 3b 0a 58 09 20 | 20 20 20 61 72 67 63 2d |e();.X. | argc-|
|00005f30| 2d 3b 0a 58 09 20 20 20 | 20 61 72 67 76 2b 2b 3b |-;.X. | argv++;|
|00005f40| 0a 58 09 20 20 20 20 6f | 75 74 66 69 6c 65 20 3d |.X. o|utfile =|
|00005f50| 20 2a 61 72 67 76 3b 0a | 58 09 7d 0a 58 09 65 6c | *argv;.|X.}.X.el|
|00005f60| 73 65 0a 58 09 20 20 20 | 20 75 73 61 67 65 28 29 |se.X. | usage()|
|00005f70| 3b 0a 58 20 20 20 20 7d | 0a 58 0a 58 20 20 20 20 |;.X }|.X.X |
|00005f80| 2f 2a 20 6f 70 65 6e 20 | 69 6e 70 75 74 20 73 74 |/* open |input st|
|00005f90| 72 65 61 6d 20 2a 2f 0a | 58 20 20 20 20 69 66 20 |ream */.|X if |
|00005fa0| 28 69 6e 66 69 6c 65 29 | 20 7b 0a 58 09 69 66 20 |(infile)| {.X.if |
|00005fb0| 28 28 69 6e 66 70 20 3d | 20 66 6f 70 65 6e 28 69 |((infp =| fopen(i|
|00005fc0| 6e 66 69 6c 65 2c 20 22 | 72 22 29 29 20 3d 3d 20 |nfile, "|r")) == |
|00005fd0| 30 29 20 7b 0a 58 09 20 | 20 20 20 70 65 72 72 6f |0) {.X. | perro|
|00005fe0| 72 28 69 6e 66 69 6c 65 | 29 3b 0a 58 09 20 20 20 |r(infile|);.X. |
|00005ff0| 20 65 78 69 74 28 31 29 | 3b 0a 58 09 7d 0a 58 20 | exit(1)|;.X.}.X |
|00006000| 20 20 20 7d 0a 58 20 20 | 20 20 65 6c 73 65 0a 58 | }.X | else.X|
|00006010| 09 69 6e 66 70 20 3d 20 | 73 74 64 69 6e 3b 0a 58 |.infp = |stdin;.X|
|00006020| 0a 58 20 20 20 20 2f 2a | 20 6f 70 65 6e 20 6f 75 |.X /*| open ou|
|00006030| 74 70 75 74 20 73 74 72 | 65 61 6d 20 6f 72 20 6c |tput str|eam or l|
|00006040| 65 61 76 65 20 69 74 20 | 66 6f 72 20 6c 61 74 65 |eave it |for late|
|00006050| 72 20 69 66 20 6e 6f 20 | 6f 75 74 70 75 74 20 66 |r if no |output f|
|00006060| 69 6c 65 0a 58 20 20 20 | 20 20 2a 20 77 61 73 20 |ile.X | * was |
|00006070| 73 70 65 63 69 66 69 65 | 64 20 0a 58 20 20 20 20 |specifie|d .X |
|00006080| 20 2a 2f 0a 58 20 20 20 | 20 69 66 20 28 6f 75 74 | */.X | if (out|
|00006090| 66 69 6c 65 29 20 7b 0a | 58 09 69 66 20 28 28 6f |file) {.|X.if ((o|
|000060a0| 75 74 66 70 20 3d 20 66 | 6f 70 65 6e 28 6f 75 74 |utfp = f|open(out|
|000060b0| 66 69 6c 65 2c 20 22 77 | 22 29 29 20 3d 3d 20 30 |file, "w|")) == 0|
|000060c0| 29 20 7b 0a 58 09 20 20 | 20 20 70 65 72 72 6f 72 |) {.X. | perror|
|000060d0| 28 6f 75 74 66 69 6c 65 | 29 3b 0a 58 09 20 20 20 |(outfile|);.X. |
|000060e0| 20 65 78 69 74 28 31 29 | 3b 0a 58 09 7d 0a 58 20 | exit(1)|;.X.}.X |
|000060f0| 20 20 20 7d 0a 58 20 20 | 20 20 65 6c 73 65 0a 58 | }.X | else.X|
|00006100| 09 6f 75 74 66 70 20 3d | 20 30 3b 0a 58 7d 0a 58 |.outfp =| 0;.X}.X|
|00006110| 0a 58 6d 61 69 6e 28 61 | 72 67 63 2c 20 61 72 67 |.Xmain(a|rgc, arg|
|00006120| 76 29 0a 58 20 20 20 20 | 69 6e 74 20 61 72 67 63 |v).X |int argc|
|00006130| 3b 0a 58 20 20 20 20 63 | 68 61 72 20 2a 2a 61 72 |;.X c|har **ar|
|00006140| 67 76 3b 0a 58 7b 0a 58 | 20 20 20 20 63 68 61 72 |gv;.X{.X| char|
|00006150| 20 62 75 66 66 65 72 5b | 31 30 32 34 5d 2c 20 2a | buffer[|1024], *|
|00006160| 74 6f 6b 65 6e 73 5b 56 | 45 43 4c 45 4e 5d 2c 20 |tokens[V|ECLEN], |
|00006170| 2a 63 2c 20 6f 75 74 3b | 0a 58 20 20 20 20 69 6e |*c, out;|.X in|
|00006180| 74 20 73 74 61 74 65 2c | 20 6e 75 6d 74 6f 6b 65 |t state,| numtoke|
|00006190| 6e 73 2c 20 6f 75 74 66 | 64 2c 20 62 75 66 5f 6f |ns, outf|d, buf_o|
|000061a0| 66 66 73 65 74 2c 20 6c | 6f 6f 6b 66 6f 72 65 6e |ffset, l|ookforen|
|000061b0| 64 3b 0a 58 20 20 20 20 | 75 6e 73 69 67 6e 65 64 |d;.X |unsigned|
|000061c0| 20 69 6e 74 20 63 6b 73 | 75 6d 3b 0a 58 20 20 20 | int cks|um;.X |
|000061d0| 20 75 6e 73 69 67 6e 65 | 64 20 73 68 6f 72 74 20 | unsigne|d short |
|000061e0| 62 75 66 3b 0a 58 0a 58 | 20 20 20 20 2f 2a 20 70 |buf;.X.X| /* p|
|000061f0| 61 72 73 65 20 63 6f 6d | 6d 61 6e 64 20 6c 69 6e |arse com|mand lin|
|00006200| 65 20 61 72 67 75 6d 65 | 6e 74 73 20 2a 2f 0a 58 |e argume|nts */.X|
|00006210| 20 20 20 20 70 61 72 73 | 65 28 61 72 67 63 2c 20 | pars|e(argc, |
|00006220| 61 72 67 76 29 3b 0a 58 | 0a 58 20 20 20 20 73 74 |argv);.X|.X st|
|00006230| 61 74 65 20 3d 20 30 3b | 0a 58 0a 58 20 20 20 20 |ate = 0;|.X.X |
|00006240| 2f 2a 20 63 6c 65 61 72 | 20 74 68 65 20 6f 75 74 |/* clear| the out|
|00006250| 70 75 74 20 62 75 66 66 | 65 72 20 2a 2f 0a 58 20 |put buff|er */.X |
|00006260| 20 20 20 62 75 66 20 3d | 20 30 3b 0a 58 20 20 20 | buf =| 0;.X |
|00006270| 20 62 75 66 5f 6f 66 66 | 73 65 74 20 3d 20 31 36 | buf_off|set = 16|
|00006280| 3b 0a 58 0a 58 20 20 20 | 20 63 6b 73 75 6d 20 3d |;.X.X | cksum =|
|00006290| 20 30 3b 0a 58 20 20 20 | 20 6c 6f 6f 6b 66 6f 72 | 0;.X | lookfor|
|000062a0| 65 6e 64 20 3d 20 30 3b | 0a 58 0a 58 20 20 20 20 |end = 0;|.X.X |
|000062b0| 2f 2a 20 73 63 61 6e 20 | 74 68 65 20 69 6e 70 75 |/* scan |the inpu|
|000062c0| 74 20 66 69 6c 65 20 2a | 2f 0a 58 20 20 20 20 77 |t file *|/.X w|
|000062d0| 68 69 6c 65 28 66 67 65 | 74 73 28 62 75 66 66 65 |hile(fge|ts(buffe|
|000062e0| 72 2c 20 73 69 7a 65 6f | 66 28 62 75 66 66 65 72 |r, sizeo|f(buffer|
|000062f0| 29 2c 20 69 6e 66 70 29 | 29 20 7b 0a 58 09 2f 2a |), infp)|) {.X./*|
|00006300| 20 72 65 6d 6f 76 65 20 | 61 6e 79 20 6e 65 77 6c | remove |any newl|
|00006310| 69 6e 65 73 20 2a 2f 0a | 58 09 69 66 20 28 63 20 |ines */.|X.if (c |
|00006320| 3d 20 69 6e 64 65 78 28 | 62 75 66 66 65 72 2c 20 |= index(|buffer, |
|00006330| 27 5c 6e 27 29 29 0a 58 | 09 20 20 20 20 2a 63 20 |'\n')).X|. *c |
|00006340| 3d 20 30 3b 0a 58 0a 58 | 09 2f 2a 20 69 66 20 74 |= 0;.X.X|./* if t|
|00006350| 68 69 73 20 6c 69 6e 65 | 20 69 73 20 62 6c 61 6e |his line| is blan|
|00006360| 6b 2c 20 63 68 65 63 6b | 20 66 6f 72 20 61 6e 64 |k, check| for and|
|00006370| 20 45 4e 44 20 6b 65 79 | 77 6f 72 64 0a 58 09 20 | END key|word.X. |
|00006380| 2a 20 6f 6e 20 74 68 65 | 20 6e 65 78 74 20 6c 69 |* on the| next li|
|00006390| 6e 65 0a 58 09 20 2a 2f | 0a 58 09 69 66 20 28 2a |ne.X. */|.X.if (*|
|000063a0| 62 75 66 66 65 72 20 3d | 3d 20 30 29 20 7b 0a 58 |buffer =|= 0) {.X|
|000063b0| 09 20 20 20 20 6c 6f 6f | 6b 66 6f 72 65 6e 64 20 |. loo|kforend |
|000063c0| 3d 20 31 3b 0a 58 09 20 | 20 20 20 63 6f 6e 74 69 |= 1;.X. | conti|
|000063d0| 6e 75 65 3b 0a 58 09 7d | 0a 58 0a 58 09 2f 2a 20 |nue;.X.}|.X.X./* |
|000063e0| 73 74 61 74 65 20 30 20 | 3d 3d 20 68 61 76 65 6e |state 0 |== haven|
|000063f0| 27 74 20 73 65 65 6e 20 | 42 45 47 49 4e 20 79 65 |'t seen |BEGIN ye|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.