home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / unix / volume03 / hdiff < prev    next >
SHell self-extracting ARchive  |  1988-09-11  |  47.2 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

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

You can browse this item here: hdiff

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news or mail text default
99% file C source, ASCII text default
100% TrID E-Mail message (Var. 2) 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)
100% xdgMime message/rfc822 default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 46 72 6f 6d 3a 20 44 65 | 6e 6e 69 73 20 42 65 64 |From: De|nnis Bed|
|00000010| 6e 61 72 20 3c 74 61 6c | 63 6f 74 74 21 73 65 69 |nar <tal|cott!sei|
|00000020| 73 6d 6f 21 72 6c 67 76 | 61 78 21 64 65 6e 6e 69 |smo!rlgv|ax!denni|
|00000030| 73 3e 0a 53 75 62 6a 65 | 63 74 3a 20 68 64 69 66 |s>.Subje|ct: hdif|
|00000040| 66 3a 20 2d 20 73 6f 75 | 72 63 65 20 66 69 6c 65 |f: - sou|rce file|
|00000050| 20 63 6f 6d 70 61 72 65 | 20 70 72 6f 67 72 61 6d | compare| program|
|00000060| 0a 4e 65 77 73 67 72 6f | 75 70 73 3a 20 6d 6f 64 |.Newsgro|ups: mod|
|00000070| 2e 73 6f 75 72 63 65 73 | 0a 41 70 70 72 6f 76 65 |.sources|.Approve|
|00000080| 64 3a 20 6a 70 6e 40 70 | 61 6e 64 61 2e 55 55 43 |d: jpn@p|anda.UUC|
|00000090| 50 0a 0a 4d 6f 64 2e 73 | 6f 75 72 63 65 73 3a 20 |P..Mod.s|ources: |
|000000a0| 20 56 6f 6c 75 6d 65 20 | 33 2c 20 49 73 73 75 65 | Volume |3, Issue|
|000000b0| 20 31 31 37 0a 53 75 62 | 6d 69 74 74 65 64 20 62 | 117.Sub|mitted b|
|000000c0| 79 3a 20 44 65 6e 6e 69 | 73 20 42 65 64 6e 61 72 |y: Denni|s Bednar|
|000000d0| 20 3c 74 61 6c 63 6f 74 | 74 21 73 65 69 73 6d 6f | <talcot|t!seismo|
|000000e0| 21 72 6c 67 76 61 78 21 | 64 65 6e 6e 69 73 3e 0a |!rlgvax!|dennis>.|
|000000f0| 0a 23 21 20 2f 62 69 6e | 2f 73 68 0a 23 20 54 68 |.#! /bin|/sh.# Th|
|00000100| 69 73 20 69 73 20 61 20 | 73 68 65 6c 6c 20 61 72 |is is a |shell ar|
|00000110| 63 68 69 76 65 2c 20 6d | 65 61 6e 69 6e 67 3a 0a |chive, m|eaning:.|
|00000120| 23 20 31 2e 20 52 65 6d | 6f 76 65 20 65 76 65 72 |# 1. Rem|ove ever|
|00000130| 79 74 68 69 6e 67 20 61 | 62 6f 76 65 20 74 68 65 |ything a|bove the|
|00000140| 20 23 21 20 2f 62 69 6e | 2f 73 68 20 6c 69 6e 65 | #! /bin|/sh line|
|00000150| 2e 0a 23 20 32 2e 20 53 | 61 76 65 20 74 68 65 20 |..# 2. S|ave the |
|00000160| 72 65 73 75 6c 74 69 6e | 67 20 74 65 78 74 20 69 |resultin|g text i|
|00000170| 6e 20 61 20 66 69 6c 65 | 2e 0a 23 20 33 2e 20 45 |n a file|..# 3. E|
|00000180| 78 65 63 75 74 65 20 74 | 68 65 20 66 69 6c 65 20 |xecute t|he file |
|00000190| 77 69 74 68 20 2f 62 69 | 6e 2f 73 68 20 28 6e 6f |with /bi|n/sh (no|
|000001a0| 74 20 63 73 68 29 20 74 | 6f 20 63 72 65 61 74 65 |t csh) t|o create|
|000001b0| 20 74 68 65 20 66 69 6c | 65 73 3a 0a 23 09 68 64 | the fil|es:.#.hd|
|000001c0| 69 66 66 2e 68 6c 70 0a | 23 09 4d 61 6b 65 66 69 |iff.hlp.|#.Makefi|
|000001d0| 6c 65 0a 23 09 68 64 69 | 66 66 2e 63 0a 23 09 72 |le.#.hdi|ff.c.#.r|
|000001e0| 65 6d 77 68 69 74 65 2e | 63 0a 23 09 73 74 72 69 |emwhite.|c.#.stri|
|000001f0| 70 6e 6c 2e 63 0a 23 09 | 73 74 72 69 70 6e 6c 2e |pnl.c.#.|stripnl.|
|00000200| 68 0a 23 20 54 68 69 73 | 20 61 72 63 68 69 76 65 |h.# This| archive|
|00000210| 20 63 72 65 61 74 65 64 | 3a 20 53 61 74 20 46 65 | created|: Sat Fe|
|00000220| 62 20 20 38 20 30 37 3a | 34 32 3a 31 37 20 31 39 |b 8 07:|42:17 19|
|00000230| 38 36 0a 65 78 70 6f 72 | 74 20 50 41 54 48 3b 20 |86.expor|t PATH; |
|00000240| 50 41 54 48 3d 2f 62 69 | 6e 3a 24 50 41 54 48 0a |PATH=/bi|n:$PATH.|
|00000250| 65 63 68 6f 20 73 68 61 | 72 3a 20 65 78 74 72 61 |echo sha|r: extra|
|00000260| 63 74 69 6e 67 20 22 27 | 68 64 69 66 66 2e 68 6c |cting "'|hdiff.hl|
|00000270| 70 27 22 20 27 28 32 34 | 33 33 20 63 68 61 72 61 |p'" '(24|33 chara|
|00000280| 63 74 65 72 73 29 27 0a | 69 66 20 74 65 73 74 20 |cters)'.|if test |
|00000290| 2d 66 20 27 68 64 69 66 | 66 2e 68 6c 70 27 0a 74 |-f 'hdif|f.hlp'.t|
|000002a0| 68 65 6e 0a 09 65 63 68 | 6f 20 73 68 61 72 3a 20 |hen..ech|o shar: |
|000002b0| 77 69 6c 6c 20 6e 6f 74 | 20 6f 76 65 72 2d 77 72 |will not| over-wr|
|000002c0| 69 74 65 20 65 78 69 73 | 74 69 6e 67 20 66 69 6c |ite exis|ting fil|
|000002d0| 65 20 22 27 68 64 69 66 | 66 2e 68 6c 70 27 22 0a |e "'hdif|f.hlp'".|
|000002e0| 65 6c 73 65 0a 63 61 74 | 20 3c 3c 20 5c 53 48 41 |else.cat| << \SHA|
|000002f0| 52 5f 45 4f 46 20 3e 20 | 27 68 64 69 66 66 2e 68 |R_EOF > |'hdiff.h|
|00000300| 6c 70 27 0a 68 64 69 66 | 66 20 5b 2d 63 64 6d 76 |lp'.hdif|f [-cdmv|
|00000310| 77 5d 20 6f 6c 64 66 69 | 6c 65 20 6e 65 77 66 69 |w] oldfi|le newfi|
|00000320| 6c 65 0a 0a 53 6f 75 72 | 63 65 20 66 69 6c 65 20 |le..Sour|ce file |
|00000330| 63 6f 6d 70 61 72 65 20 | 70 72 6f 67 72 61 6d 2e |compare |program.|
|00000340| 0a 59 65 74 20 61 6e 6f | 74 68 65 72 20 73 6f 75 |.Yet ano|ther sou|
|00000350| 72 63 65 20 63 6f 6d 70 | 61 72 65 20 70 72 6f 67 |rce comp|are prog|
|00000360| 72 61 6d 20 6c 69 6b 65 | 20 64 69 66 66 2e 20 20 |ram like| diff. |
|00000370| 54 68 69 73 20 6f 6e 65 | 20 72 65 70 6f 72 74 73 |This one| reports|
|00000380| 20 6d 6f 76 65 64 20 6c | 69 6e 65 73 2c 0a 6e 6f | moved l|ines,.no|
|00000390| 74 20 64 65 6c 65 74 65 | 2f 69 6e 73 65 72 74 20 |t delete|/insert |
|000003a0| 61 73 20 74 68 65 20 55 | 4e 49 58 20 64 69 66 66 |as the U|NIX diff|
|000003b0| 20 64 6f 65 73 2e 20 20 | 54 68 65 20 68 20 69 73 | does. |The h is|
|000003c0| 20 69 6e 20 68 6f 6e 6f | 72 20 6f 66 20 50 61 75 | in hono|r of Pau|
|000003d0| 6c 20 48 65 63 6b 65 6c | 2c 0a 74 68 65 20 67 75 |l Heckel|,.the gu|
|000003e0| 79 20 77 68 6f 20 66 69 | 72 73 74 20 77 72 6f 74 |y who fi|rst wrot|
|000003f0| 65 20 61 62 6f 75 74 20 | 74 68 69 73 20 61 6c 67 |e about |this alg|
|00000400| 6f 72 69 74 68 6d 20 69 | 6e 20 43 41 43 4d 20 4a |orithm i|n CACM J|
|00000410| 75 6c 79 20 31 39 37 38 | 2e 0a 0a 4f 6e 65 20 6f |uly 1978|...One o|
|00000420| 66 20 63 2c 64 2c 20 6f | 72 20 6d 20 73 68 6f 75 |f c,d, o|r m shou|
|00000430| 6c 64 20 62 65 20 75 73 | 65 64 20 74 6f 20 61 64 |ld be us|ed to ad|
|00000440| 6a 75 73 74 20 74 68 65 | 20 69 6e 74 65 72 6e 61 |just the| interna|
|00000450| 6c 20 61 6c 67 6f 72 69 | 74 68 6d 2e 0a 43 75 72 |l algori|thm..Cur|
|00000460| 72 65 6e 74 6c 79 20 49 | 20 61 6d 20 70 6c 61 79 |rently I| am play|
|00000470| 69 6e 67 20 77 69 74 68 | 20 74 68 65 20 61 6c 67 |ing with| the alg|
|00000480| 6f 72 69 74 68 6d 2e 0a | 0a 53 77 69 74 63 68 65 |orithm..|.Switche|
|00000490| 73 0a 09 2d 63 20 3d 20 | 75 73 65 20 61 20 22 63 |s..-c = |use a "c|
|000004a0| 6f 75 6e 74 20 62 65 74 | 77 65 65 6e 20 74 68 65 |ount bet|ween the|
|000004b0| 20 73 74 61 72 74 20 6f | 66 20 74 68 65 20 6f 74 | start o|f the ot|
|000004c0| 68 65 72 20 6d 6f 76 65 | 20 62 6c 6f 63 6b 20 61 |her move| block a|
|000004d0| 6e 64 0a 09 09 74 68 65 | 20 66 69 72 73 74 20 6c |nd...the| first l|
|000004e0| 69 6e 65 20 69 6e 20 74 | 68 65 20 6f 74 68 65 72 |ine in t|he other|
|000004f0| 20 66 69 6c 65 20 77 68 | 69 63 68 20 6d 61 74 63 | file wh|ich matc|
|00000500| 68 65 64 20 74 68 69 73 | 20 6d 6f 76 65 0a 09 09 |hed this| move...|
|00000510| 62 6c 6f 63 6b 22 20 74 | 6f 20 64 65 74 65 72 6d |block" t|o determ|
|00000520| 69 6e 65 20 6d 6f 76 65 | 64 20 62 6c 6f 63 6b 73 |ine move|d blocks|
|00000530| 20 5b 44 45 46 41 55 4c | 54 5d 0a 09 2d 64 20 3d | [DEFAUL|T]..-d =|
|00000540| 20 75 73 65 20 61 20 22 | 64 72 6f 70 22 20 6f 72 | use a "|drop" or|
|00000550| 20 72 65 6c 61 74 69 76 | 65 20 73 6c 6f 70 65 20 | relativ|e slope |
|00000560| 74 6f 20 64 65 74 65 72 | 6d 69 6e 65 20 6d 6f 76 |to deter|mine mov|
|00000570| 65 64 20 62 6c 6f 63 6b | 73 0a 09 2d 6d 20 3d 20 |ed block|s..-m = |
|00000580| 75 73 65 20 22 6d 6f 6e | 6f 6e 6f 74 6f 6e 69 63 |use "mon|onotonic|
|00000590| 61 6c 6c 79 20 69 6e 63 | 72 65 61 73 69 6e 67 20 |ally inc|reasing |
|000005a0| 62 79 20 6f 6e 65 22 20 | 74 6f 20 64 65 74 65 72 |by one" |to deter|
|000005b0| 6d 69 6e 65 20 6d 6f 76 | 65 64 20 62 6c 6f 63 6b |mine mov|ed block|
|000005c0| 73 0a 09 2d 76 20 3d 20 | 76 65 72 62 6f 73 65 20 |s..-v = |verbose |
|000005d0| 28 64 65 62 75 67 67 69 | 6e 67 29 0a 09 2d 77 20 |(debuggi|ng)..-w |
|000005e0| 3d 20 63 6f 6d 70 72 65 | 73 73 20 77 68 69 74 65 |= compre|ss white|
|000005f0| 20 73 70 61 63 65 20 6f | 6e 6c 79 20 6f 6e 20 65 | space o|nly on e|
|00000600| 61 63 68 20 6c 69 6e 65 | 20 62 65 66 6f 72 65 20 |ach line| before |
|00000610| 63 6f 6d 70 61 72 69 73 | 6f 6e 2c 0a 09 09 61 6e |comparis|on,...an|
|00000620| 64 20 72 65 6d 6f 76 65 | 20 6c 65 61 64 69 6e 67 |d remove| leading|
|00000630| 20 77 68 69 74 65 20 73 | 70 61 63 65 20 28 72 65 | white s|pace (re|
|00000640| 6d 77 68 69 74 65 20 2d | 61 20 6f 70 74 69 6f 6e |mwhite -|a option|
|00000650| 29 2e 0a 0a 28 73 65 65 | 20 43 41 43 4d 2c 20 41 |)...(see| CACM, A|
|00000660| 70 72 69 6c 20 37 38 2c | 20 22 41 20 54 65 63 68 |pril 78,| "A Tech|
|00000670| 6e 69 71 75 65 20 66 6f | 72 20 49 73 6f 6c 61 74 |nique fo|r Isolat|
|00000680| 69 6e 67 20 44 69 66 66 | 65 72 65 6e 63 65 73 20 |ing Diff|erences |
|00000690| 42 65 74 77 65 65 6e 20 | 46 69 6c 65 73 22 2c 0a |Between |Files",.|
|000006a0| 62 79 20 50 61 75 6c 20 | 48 65 63 6b 65 6c 29 2e |by Paul |Heckel).|
|000006b0| 0a 0a 4f 75 74 70 75 74 | 3a 0a 09 54 68 65 20 6f |..Output|:..The o|
|000006c0| 75 74 70 75 74 20 69 73 | 20 69 64 65 6e 74 69 63 |utput is| identic|
|000006d0| 61 6c 20 69 6e 20 6d 65 | 61 6e 69 6e 67 20 74 6f |al in me|aning to|
|000006e0| 20 74 68 65 20 6f 75 74 | 70 75 74 20 66 72 6f 6d | the out|put from|
|000006f0| 20 55 4e 49 58 20 64 69 | 66 66 2c 0a 09 65 78 63 | UNIX di|ff,..exc|
|00000700| 65 70 74 20 74 68 61 74 | 20 61 20 22 6d 6f 76 65 |ept that| a "move|
|00000710| 22 20 63 6f 6d 6d 61 6e | 64 20 69 73 20 70 72 65 |" comman|d is pre|
|00000720| 73 65 6e 74 20 68 65 72 | 65 2c 20 62 75 74 20 6e |sent her|e, but n|
|00000730| 6f 74 20 69 6e 20 64 69 | 66 66 2e 0a 0a 44 45 4c |ot in di|ff...DEL|
|00000740| 45 54 45 53 0a 2d 2d 2d | 2d 2d 2d 2d 0a 6f 6c 64 |ETES.---|----.old|
|00000750| 20 64 20 6e 65 77 20 09 | 09 2f 2f 20 53 69 6e 67 | d new .|.// Sing|
|00000760| 6c 65 20 6c 69 6e 65 20 | 64 65 6c 65 74 65 20 2d |le line |delete -|
|00000770| 20 4f 6c 64 20 6c 69 6e | 65 20 6e 75 6d 62 65 72 | Old lin|e number|
|00000780| 20 27 6f 6c 64 27 20 69 | 73 0a 09 09 09 2f 2f 20 | 'old' i|s....// |
|00000790| 64 65 6c 65 74 65 64 20 | 61 66 74 65 72 20 6e 65 |deleted |after ne|
|000007a0| 77 20 6c 69 6e 65 20 6e | 75 6d 62 65 72 65 64 20 |w line n|umbered |
|000007b0| 27 6e 65 77 27 0a 73 74 | 61 72 74 6f 6c 64 2c 65 |'new'.st|artold,e|
|000007c0| 6e 64 6f 6c 64 20 64 20 | 6e 65 77 09 2f 2f 20 42 |ndold d |new.// B|
|000007d0| 6c 6f 63 6b 20 6c 69 6e | 65 20 64 65 6c 65 74 65 |lock lin|e delete|
|000007e0| 20 2d 20 4f 6c 64 20 62 | 6c 6f 63 6b 20 6f 66 20 | - Old b|lock of |
|000007f0| 6c 69 6e 65 73 20 27 73 | 74 61 72 74 6f 6c 64 27 |lines 's|tartold'|
|00000800| 0a 09 09 09 2f 2f 20 74 | 6f 20 27 65 6e 64 6f 6c |....// t|o 'endol|
|00000810| 64 27 20 61 72 65 20 64 | 65 6c 65 74 65 64 20 61 |d' are d|eleted a|
|00000820| 66 74 65 72 20 6e 65 77 | 20 6c 69 6e 65 20 6e 75 |fter new| line nu|
|00000830| 6d 62 65 72 20 27 6e 65 | 77 27 0a 0a 49 4e 53 45 |mber 'ne|w'..INSE|
|00000840| 52 54 53 0a 2d 2d 2d 2d | 2d 2d 2d 0a 6f 6c 64 20 |RTS.----|---.old |
|00000850| 61 20 6e 65 77 09 09 2f | 2f 20 41 66 74 65 72 20 |a new../|/ After |
|00000860| 6f 6c 64 20 6c 69 6e 65 | 20 6e 75 6d 62 65 72 20 |old line| number |
|00000870| 27 6f 6c 64 27 20 69 73 | 20 6e 65 77 20 6c 69 6e |'old' is| new lin|
|00000880| 65 20 6e 75 6d 62 65 72 | 20 27 6e 65 77 27 0a 6f |e number| 'new'.o|
|00000890| 6c 64 20 61 20 73 74 61 | 72 74 6e 65 77 2c 65 6e |ld a sta|rtnew,en|
|000008a0| 64 6e 65 77 09 2f 2f 20 | 41 66 74 65 72 20 6f 6c |dnew.// |After ol|
|000008b0| 64 20 6c 69 6e 65 20 6e | 75 6d 62 65 72 20 27 6f |d line n|umber 'o|
|000008c0| 6c 64 27 2c 20 6e 65 77 | 20 6c 69 6e 65 73 20 6e |ld', new| lines n|
|000008d0| 75 6d 62 65 72 65 64 0a | 09 09 09 2f 2f 20 27 73 |umbered.|...// 's|
|000008e0| 74 61 72 74 6e 65 77 27 | 20 74 6f 20 27 65 6e 64 |tartnew'| to 'end|
|000008f0| 6e 65 77 27 0a 0a 43 48 | 41 4e 47 45 53 0a 2d 2d |new'..CH|ANGES.--|
|00000900| 2d 2d 2d 2d 2d 0a 6f 6c | 64 20 63 20 6e 65 77 09 |-----.ol|d c new.|
|00000910| 09 2f 2f 20 43 68 61 6e | 67 65 20 6f 6e 65 20 6c |.// Chan|ge one l|
|00000920| 69 6e 65 20 74 6f 20 6f | 6e 65 20 6e 65 77 20 6c |ine to o|ne new l|
|00000930| 69 6e 65 2e 20 20 54 68 | 65 20 6f 6c 64 20 6c 69 |ine. Th|e old li|
|00000940| 6e 65 0a 09 09 09 2f 2f | 20 6e 75 6d 62 65 72 65 |ne....//| numbere|
|00000950| 64 20 27 6f 6c 64 27 20 | 62 65 63 6f 6d 65 73 20 |d 'old' |becomes |
|00000960| 6e 65 77 20 6c 69 6e 65 | 20 6e 75 6d 62 65 72 65 |new line| numbere|
|00000970| 64 20 27 6e 65 77 27 0a | 6f 6c 64 20 63 20 73 74 |d 'new'.|old c st|
|00000980| 61 72 74 6e 65 77 2c 65 | 6e 64 6e 65 77 09 2f 2f |artnew,e|ndnew.//|
|00000990| 20 43 68 61 6e 67 65 20 | 6f 6e 65 20 6c 69 6e 65 | Change |one line|
|000009a0| 20 74 6f 20 61 20 62 6c | 6f 63 6b 20 6f 66 20 6c | to a bl|ock of l|
|000009b0| 69 6e 65 73 2e 20 20 4f | 6c 64 20 6c 69 6e 65 0a |ines. O|ld line.|
|000009c0| 09 09 09 2f 2f 20 6e 75 | 6d 62 65 72 65 64 20 27 |...// nu|mbered '|
|000009d0| 6f 6c 64 27 20 62 65 63 | 6f 6d 65 73 20 74 68 65 |old' bec|omes the|
|000009e0| 20 6e 65 77 20 73 65 74 | 20 6f 66 20 6c 69 6e 65 | new set| of line|
|000009f0| 73 2e 0a 73 74 61 72 74 | 6f 6c 64 2c 65 6e 64 6f |s..start|old,endo|
|00000a00| 6c 64 20 63 20 6e 65 77 | 09 2f 2f 20 20 43 68 61 |ld c new|.// Cha|
|00000a10| 6e 67 65 20 61 20 62 6c | 6f 63 6b 20 6f 66 20 6f |nge a bl|ock of o|
|00000a20| 6c 64 20 6c 69 6e 65 73 | 20 74 6f 20 6f 6e 65 20 |ld lines| to one |
|00000a30| 6e 65 77 20 6c 69 6e 65 | 2e 0a 73 74 61 72 74 6f |new line|..starto|
|00000a40| 6c 64 2c 65 6e 64 6f 6c | 64 20 63 20 73 74 61 72 |ld,endol|d c star|
|00000a50| 74 6e 65 77 2c 65 6e 64 | 6e 65 77 09 2f 2f 20 43 |tnew,end|new.// C|
|00000a60| 68 61 6e 67 65 20 61 20 | 62 6c 6f 63 6b 20 6f 66 |hange a |block of|
|00000a70| 20 6c 69 6e 65 73 20 74 | 6f 0a 09 09 09 2f 2f 20 | lines t|o....// |
|00000a80| 61 20 64 69 66 66 65 72 | 65 6e 74 20 62 6c 6f 63 |a differ|ent bloc|
|00000a90| 6b 20 6f 66 20 6c 69 6e | 65 73 2e 0a 0a 4d 4f 56 |k of lin|es...MOV|
|00000aa0| 45 53 0a 2d 2d 2d 2d 2d | 0a 6f 6c 64 20 6d 20 6e |ES.-----|.old m n|
|00000ab0| 65 77 09 09 2f 2f 20 4f | 6c 64 20 6c 69 6e 65 20 |ew..// O|ld line |
|00000ac0| 6e 75 6d 62 65 72 20 27 | 6f 6c 64 27 20 69 73 20 |number '|old' is |
|00000ad0| 6d 6f 76 65 64 20 74 6f | 20 6e 65 77 20 6c 69 6e |moved to| new lin|
|00000ae0| 65 0a 09 09 09 2f 2f 20 | 6e 75 6d 62 65 72 20 27 |e....// |number '|
|00000af0| 6e 65 77 27 0a 73 74 61 | 72 74 6f 6c 64 2c 65 6e |new'.sta|rtold,en|
|00000b00| 64 6f 6c 64 20 6d 20 73 | 74 61 72 74 6e 65 77 2c |dold m s|tartnew,|
|00000b10| 65 6e 64 6e 65 77 20 20 | 2f 2f 20 54 68 65 20 6f |endnew |// The o|
|00000b20| 6c 64 20 62 6c 6f 63 6b | 20 6f 66 20 6c 69 6e 65 |ld block| of line|
|00000b30| 73 20 68 61 76 65 20 62 | 65 65 6e 20 6d 6f 76 65 |s have b|een move|
|00000b40| 64 0a 09 09 09 2f 2f 20 | 61 6e 64 20 74 68 65 20 |d....// |and the |
|00000b50| 6f 6c 64 20 6c 69 6e 65 | 20 6e 75 6d 62 65 72 73 |old line| numbers|
|00000b60| 20 68 61 76 65 20 63 68 | 61 6e 67 65 64 2e 0a 0a | have ch|anged...|
|00000b70| 0a 46 6f 72 20 44 45 4c | 45 54 45 53 2c 20 49 4e |.For DEL|ETES, IN|
|00000b80| 53 45 52 54 53 2c 20 61 | 6e 64 20 43 48 41 4e 47 |SERTS, a|nd CHANG|
|00000b90| 45 53 20 28 62 75 74 20 | 6e 6f 74 20 4d 4f 56 45 |ES (but |not MOVE|
|00000ba0| 53 29 20 74 68 65 20 6f | 6c 64 20 6c 69 6e 65 20 |S) the o|ld line |
|00000bb0| 61 6e 64 20 6e 65 77 20 | 6c 69 6e 65 73 0a 61 72 |and new |lines.ar|
|00000bc0| 65 20 64 69 73 70 6c 61 | 79 65 64 20 61 73 20 66 |e displa|yed as f|
|00000bd0| 6f 6c 6c 6f 77 73 20 28 | 73 61 6d 65 20 61 73 20 |ollows (|same as |
|00000be0| 74 68 65 20 55 4e 49 58 | 20 64 69 66 66 29 3a 0a |the UNIX| diff):.|
|00000bf0| 3c 20 6f 6c 64 20 6c 69 | 6e 65 0a 3e 20 6e 65 77 |< old li|ne.> new|
|00000c00| 20 6c 69 6e 65 0a 0a 42 | 55 47 53 3a 0a 09 48 64 | line..B|UGS:..Hd|
|00000c10| 69 66 66 20 69 73 20 6c | 69 6d 69 74 65 64 20 74 |iff is l|imited t|
|00000c20| 6f 20 66 69 6c 65 73 20 | 77 69 74 68 20 61 74 20 |o files |with at |
|00000c30| 6d 6f 73 74 20 35 30 30 | 30 20 6c 69 6e 65 73 20 |most 500|0 lines |
|00000c40| 70 65 72 20 66 69 6c 65 | 2e 0a 09 54 6f 20 66 69 |per file|...To fi|
|00000c50| 78 2c 20 72 65 63 6f 6d | 70 69 6c 65 20 68 64 69 |x, recom|pile hdi|
|00000c60| 66 66 2e 63 20 77 69 74 | 68 20 61 20 6c 61 72 67 |ff.c wit|h a larg|
|00000c70| 65 72 20 4d 41 58 4c 49 | 4e 45 53 20 23 64 65 66 |er MAXLI|NES #def|
|00000c80| 69 6e 65 2e 0a 53 48 41 | 52 5f 45 4f 46 0a 69 66 |ine..SHA|R_EOF.if|
|00000c90| 20 74 65 73 74 20 32 34 | 33 33 20 2d 6e 65 20 22 | test 24|33 -ne "|
|00000ca0| 60 77 63 20 2d 63 20 3c | 20 27 68 64 69 66 66 2e |`wc -c <| 'hdiff.|
|00000cb0| 68 6c 70 27 60 22 0a 74 | 68 65 6e 0a 09 65 63 68 |hlp'`".t|hen..ech|
|00000cc0| 6f 20 73 68 61 72 3a 20 | 65 72 72 6f 72 20 74 72 |o shar: |error tr|
|00000cd0| 61 6e 73 6d 69 74 74 69 | 6e 67 20 22 27 68 64 69 |ansmitti|ng "'hdi|
|00000ce0| 66 66 2e 68 6c 70 27 22 | 20 27 28 73 68 6f 75 6c |ff.hlp'"| '(shoul|
|00000cf0| 64 20 68 61 76 65 20 62 | 65 65 6e 20 32 34 33 33 |d have b|een 2433|
|00000d00| 20 63 68 61 72 61 63 74 | 65 72 73 29 27 0a 66 69 | charact|ers)'.fi|
|00000d10| 0a 66 69 0a 65 63 68 6f | 20 73 68 61 72 3a 20 65 |.fi.echo| shar: e|
|00000d20| 78 74 72 61 63 74 69 6e | 67 20 22 27 4d 61 6b 65 |xtractin|g "'Make|
|00000d30| 66 69 6c 65 27 22 20 27 | 28 31 30 33 34 20 63 68 |file'" '|(1034 ch|
|00000d40| 61 72 61 63 74 65 72 73 | 29 27 0a 69 66 20 74 65 |aracters|)'.if te|
|00000d50| 73 74 20 2d 66 20 27 4d | 61 6b 65 66 69 6c 65 27 |st -f 'M|akefile'|
|00000d60| 0a 74 68 65 6e 0a 09 65 | 63 68 6f 20 73 68 61 72 |.then..e|cho shar|
|00000d70| 3a 20 77 69 6c 6c 20 6e | 6f 74 20 6f 76 65 72 2d |: will n|ot over-|
|00000d80| 77 72 69 74 65 20 65 78 | 69 73 74 69 6e 67 20 66 |write ex|isting f|
|00000d90| 69 6c 65 20 22 27 4d 61 | 6b 65 66 69 6c 65 27 22 |ile "'Ma|kefile'"|
|00000da0| 0a 65 6c 73 65 0a 63 61 | 74 20 3c 3c 20 5c 53 48 |.else.ca|t << \SH|
|00000db0| 41 52 5f 45 4f 46 20 3e | 20 27 4d 61 6b 65 66 69 |AR_EOF >| 'Makefi|
|00000dc0| 6c 65 27 0a 53 52 43 20 | 3d 20 68 64 69 66 66 2e |le'.SRC |= hdiff.|
|00000dd0| 63 20 72 65 6d 77 68 69 | 74 65 2e 63 20 73 74 72 |c remwhi|te.c str|
|00000de0| 69 70 6e 6c 2e 63 20 73 | 74 72 69 70 6e 6c 2e 68 |ipnl.c s|tripnl.h|
|00000df0| 20 68 64 69 66 66 2e 6d | 6b 0a 23 20 61 6c 73 6f | hdiff.m|k.# also|
|00000e00| 20 74 68 65 20 68 64 69 | 66 66 20 68 65 6c 70 20 | the hdi|ff help |
|00000e10| 66 69 6c 65 20 69 73 20 | 73 6f 75 72 63 65 20 62 |file is |source b|
|00000e20| 75 74 20 69 74 20 69 73 | 20 72 65 6e 61 6d 65 64 |ut it is| renamed|
|00000e30| 20 6f 6e 20 74 68 65 20 | 63 6f 70 79 0a 0a 23 20 | on the |copy..# |
|00000e40| 63 68 61 6e 67 65 20 74 | 68 69 73 20 66 6f 72 20 |change t|his for |
|00000e50| 79 6f 75 72 20 73 69 74 | 65 0a 49 4e 53 54 41 4c |your sit|e.INSTAL|
|00000e60| 4c 44 49 52 20 3d 20 2e | 0a 0a 0a 68 64 69 66 66 |LDIR = .|...hdiff|
|00000e70| 3a 20 68 64 69 66 66 2e | 6f 20 72 65 6d 77 68 69 |: hdiff.|o remwhi|
|00000e80| 74 65 2e 6f 20 73 74 72 | 69 70 6e 6c 2e 6f 0a 09 |te.o str|ipnl.o..|
|00000e90| 63 63 20 2d 4f 20 68 64 | 69 66 66 2e 6f 20 72 65 |cc -O hd|iff.o re|
|00000ea0| 6d 77 68 69 74 65 2e 6f | 20 73 74 72 69 70 6e 6c |mwhite.o| stripnl|
|00000eb0| 2e 6f 0a 09 6d 76 20 61 | 2e 6f 75 74 20 68 64 69 |.o..mv a|.out hdi|
|00000ec0| 66 66 0a 0a 68 64 69 66 | 66 2e 6f 3a 20 73 74 72 |ff..hdif|f.o: str|
|00000ed0| 69 70 6e 6c 2e 68 0a 09 | 63 63 20 2d 4f 20 2d 63 |ipnl.h..|cc -O -c|
|00000ee0| 20 68 64 69 66 66 2e 63 | 0a 0a 72 65 6d 77 68 69 | hdiff.c|..remwhi|
|00000ef0| 74 65 2e 6f 3a 20 73 74 | 72 69 70 6e 6c 2e 68 0a |te.o: st|ripnl.h.|
|00000f00| 09 63 63 20 2d 4f 20 2d | 55 53 54 41 4e 44 20 2d |.cc -O -|USTAND -|
|00000f10| 63 20 72 65 6d 77 68 69 | 74 65 2e 63 0a 0a 73 74 |c remwhi|te.c..st|
|00000f20| 72 69 70 6e 6c 2e 6f 3a | 20 73 74 72 69 70 6e 6c |ripnl.o:| stripnl|
|00000f30| 2e 68 0a 09 63 63 20 2d | 4f 20 2d 63 20 73 74 72 |.h..cc -|O -c str|
|00000f40| 69 70 6e 6c 2e 63 0a 0a | 63 6c 65 61 6e 3a 0a 09 |ipnl.c..|clean:..|
|00000f50| 72 6d 20 2d 66 20 68 64 | 69 66 66 2e 6f 20 72 65 |rm -f hd|iff.o re|
|00000f60| 6d 77 68 69 74 65 2e 6f | 20 73 74 72 69 70 6e 6c |mwhite.o| stripnl|
|00000f70| 2e 6f 20 68 64 69 66 66 | 0a 0a 69 6e 73 74 61 6c |.o hdiff|..instal|
|00000f80| 6c 3a 20 68 64 69 66 66 | 0a 09 63 70 20 68 64 69 |l: hdiff|..cp hdi|
|00000f90| 66 66 20 24 28 49 4e 53 | 54 41 4c 4c 44 49 52 29 |ff $(INS|TALLDIR)|
|00000fa0| 0a 0a 23 20 64 69 73 74 | 72 69 62 75 74 65 20 68 |..# dist|ribute h|
|00000fb0| 64 69 66 66 2e 20 70 65 | 72 73 6f 6e 61 6c 20 66 |diff. pe|rsonal f|
|00000fc0| 6f 72 20 64 65 6e 6e 69 | 73 20 6f 6e 6c 79 2e 0a |or denni|s only..|
|00000fd0| 64 69 73 74 3a 0a 09 72 | 6d 20 2d 72 66 20 2f 74 |dist:..r|m -rf /t|
|00000fe0| 6d 70 2f 64 70 62 0a 09 | 6d 6b 64 69 72 20 2f 74 |mp/dpb..|mkdir /t|
|00000ff0| 6d 70 2f 64 70 62 0a 09 | 63 70 20 24 28 53 52 43 |mp/dpb..|cp $(SRC|
|00001000| 29 20 2f 74 6d 70 2f 64 | 70 62 0a 09 63 70 20 2e |) /tmp/d|pb..cp .|
|00001010| 2e 2f 68 65 6c 70 2f 68 | 64 69 66 66 20 2f 74 6d |./help/h|diff /tm|
|00001020| 70 2f 64 70 62 2f 68 64 | 69 66 66 2e 68 6c 70 09 |p/dpb/hd|iff.hlp.|
|00001030| 23 20 68 65 6c 70 20 66 | 69 6c 65 0a 09 28 63 64 |# help f|ile..(cd|
|00001040| 20 2f 74 6d 70 2f 64 70 | 62 3b 20 6d 61 6b 65 20 | /tmp/dp|b; make |
|00001050| 2d 66 20 68 64 69 66 66 | 2e 6d 6b 20 6d 61 6b 65 |-f hdiff|.mk make|
|00001060| 73 68 61 72 29 0a 0a 6d | 61 6b 65 73 68 61 72 3a |shar)..m|akeshar:|
|00001070| 0a 09 73 70 6c 69 74 66 | 69 6c 65 73 20 2a 20 20 |..splitf|iles * |
|00001080| 09 23 20 73 70 6c 69 74 | 20 73 6f 75 72 63 65 20 |.# split| source |
|00001090| 66 69 6c 65 73 20 69 6e | 74 6f 20 6c 69 74 74 6c |files in|to littl|
|000010a0| 65 20 62 75 6e 64 6c 65 | 73 0a 09 66 6f 72 20 69 |e bundle|s..for i|
|000010b0| 20 69 6e 20 6c 69 73 74 | 2e 2a 20 3b 20 5c 0a 09 | in list|.* ; \..|
|000010c0| 64 6f 20 5c 0a 09 09 6d | 61 6b 65 73 68 61 72 20 |do \...m|akeshar |
|000010d0| 60 63 61 74 20 24 24 69 | 60 20 3e 20 73 68 61 72 |`cat $$i|` > shar|
|000010e0| 2e 24 24 69 20 3b 20 5c | 0a 09 64 6f 6e 65 0a 0a |.$$i ; \|..done..|
|000010f0| 0a 23 20 79 6f 75 20 6d | 75 73 74 20 72 75 6e 20 |.# you m|ust run |
|00001100| 6d 61 6b 65 20 2d 66 20 | 68 64 69 66 66 2e 6d 6b |make -f |hdiff.mk|
|00001110| 20 6d 61 6b 65 73 68 61 | 72 20 66 69 72 73 74 0a | makesha|r first.|
|00001120| 23 20 73 65 6e 64 73 20 | 73 68 61 72 20 66 69 6c |# sends |shar fil|
|00001130| 65 73 20 74 6f 20 6d 6f | 64 2e 73 6f 75 72 63 65 |es to mo|d.source|
|00001140| 73 0a 23 20 68 61 72 64 | 63 6f 64 65 64 20 66 6f |s.# hard|coded fo|
|00001150| 72 20 32 20 62 75 6e 64 | 6c 65 73 0a 73 65 6e 64 |r 2 bund|les.send|
|00001160| 74 6f 6e 65 74 3a 0a 09 | 66 6f 72 20 69 20 69 6e |tonet:..|for i in|
|00001170| 20 31 20 32 20 3b 20 5c | 0a 09 64 6f 20 5c 0a 09 | 1 2 ; \|..do \..|
|00001180| 09 4d 61 69 6c 20 3c 20 | 73 68 61 72 2e 6c 69 73 |.Mail < |shar.lis|
|00001190| 74 2e 24 24 69 20 2d 73 | 20 22 68 64 69 66 66 3a |t.$$i -s| "hdiff:|
|000011a0| 20 2d 20 70 61 72 74 20 | 24 24 69 20 6f 66 20 32 | - part |$$i of 2|
|000011b0| 22 20 73 6f 75 72 63 65 | 73 40 70 61 6e 64 61 2e |" source|s@panda.|
|000011c0| 75 75 63 70 3b 20 5c 0a | 09 64 6f 6e 65 0a 53 48 |uucp; \.|.done.SH|
|000011d0| 41 52 5f 45 4f 46 0a 69 | 66 20 74 65 73 74 20 31 |AR_EOF.i|f test 1|
|000011e0| 30 33 34 20 2d 6e 65 20 | 22 60 77 63 20 2d 63 20 |034 -ne |"`wc -c |
|000011f0| 3c 20 27 4d 61 6b 65 66 | 69 6c 65 27 60 22 0a 74 |< 'Makef|ile'`".t|
|00001200| 68 65 6e 0a 09 65 63 68 | 6f 20 73 68 61 72 3a 20 |hen..ech|o shar: |
|00001210| 65 72 72 6f 72 20 74 72 | 61 6e 73 6d 69 74 74 69 |error tr|ansmitti|
|00001220| 6e 67 20 22 27 4d 61 6b | 65 66 69 6c 65 27 22 20 |ng "'Mak|efile'" |
|00001230| 27 28 73 68 6f 75 6c 64 | 20 68 61 76 65 20 62 65 |'(should| have be|
|00001240| 65 6e 20 31 30 33 34 20 | 63 68 61 72 61 63 74 65 |en 1034 |characte|
|00001250| 72 73 29 27 0a 66 69 0a | 66 69 0a 65 63 68 6f 20 |rs)'.fi.|fi.echo |
|00001260| 73 68 61 72 3a 20 65 78 | 74 72 61 63 74 69 6e 67 |shar: ex|tracting|
|00001270| 20 22 27 68 64 69 66 66 | 2e 63 27 22 20 27 28 33 | "'hdiff|.c'" '(3|
|00001280| 34 37 34 38 20 63 68 61 | 72 61 63 74 65 72 73 29 |4748 cha|racters)|
|00001290| 27 0a 69 66 20 74 65 73 | 74 20 2d 66 20 27 68 64 |'.if tes|t -f 'hd|
|000012a0| 69 66 66 2e 63 27 0a 74 | 68 65 6e 0a 09 65 63 68 |iff.c'.t|hen..ech|
|000012b0| 6f 20 73 68 61 72 3a 20 | 77 69 6c 6c 20 6e 6f 74 |o shar: |will not|
|000012c0| 20 6f 76 65 72 2d 77 72 | 69 74 65 20 65 78 69 73 | over-wr|ite exis|
|000012d0| 74 69 6e 67 20 66 69 6c | 65 20 22 27 68 64 69 66 |ting fil|e "'hdif|
|000012e0| 66 2e 63 27 22 0a 65 6c | 73 65 0a 63 61 74 20 3c |f.c'".el|se.cat <|
|000012f0| 3c 20 5c 53 48 41 52 5f | 45 4f 46 20 3e 20 27 68 |< \SHAR_|EOF > 'h|
|00001300| 64 69 66 66 2e 63 27 0a | 2f 2a 0a 20 2a 20 66 3d |diff.c'.|/*. * f=|
|00001310| 68 64 69 66 66 2e 63 20 | 20 28 49 6e 20 68 6f 6e |hdiff.c | (In hon|
|00001320| 6f 72 20 6f 66 20 4d 72 | 20 48 65 63 6b 65 6c 2c |or of Mr| Heckel,|
|00001330| 20 74 68 65 20 67 75 79 | 20 77 68 6f 20 74 68 6f | the guy| who tho|
|00001340| 75 67 68 74 20 75 70 20 | 74 68 69 73 0a 20 2a 20 |ught up |this. * |
|00001350| 61 6c 67 6f 72 69 74 68 | 6d 29 2e 0a 20 2a 0a 20 |algorith|m).. *. |
|00001360| 2a 20 61 75 74 68 6f 72 | 20 2d 20 64 65 6e 6e 69 |* author| - denni|
|00001370| 73 20 62 65 64 6e 61 72 | 20 20 38 20 32 32 20 38 |s bednar| 8 22 8|
|00001380| 34 0a 20 2a 20 53 6f 75 | 72 63 65 20 66 69 6c 65 |4. * Sou|rce file|
|00001390| 20 63 6f 6d 70 61 72 69 | 73 6f 6e 20 70 72 6f 67 | compari|son prog|
|000013a0| 72 61 6d 20 73 69 6d 69 | 6c 61 72 20 74 6f 20 55 |ram simi|lar to U|
|000013b0| 4e 49 58 20 64 69 66 66 | 2c 20 65 78 63 65 70 74 |NIX diff|, except|
|000013c0| 20 74 68 69 73 0a 20 2a | 20 76 65 72 73 69 6f 6e | this. *| version|
|000013d0| 20 6f 75 74 70 75 74 73 | 20 6d 6f 76 65 64 20 62 | outputs| moved b|
|000013e0| 6c 6f 63 6b 73 20 77 68 | 65 72 65 61 73 20 55 4e |locks wh|ereas UN|
|000013f0| 49 58 20 64 69 66 66 20 | 72 65 70 6f 72 74 73 20 |IX diff |reports |
|00001400| 69 74 20 61 73 0a 20 2a | 20 64 65 6c 65 74 65 2f |it as. *| delete/|
|00001410| 61 64 64 20 62 6c 6f 63 | 6b 73 2e 0a 20 2a 0a 20 |add bloc|ks.. *. |
|00001420| 2a 20 41 6c 67 6f 72 69 | 74 68 6d 20 66 72 6f 6d |* Algori|thm from|
|00001430| 20 22 41 20 54 65 63 68 | 6e 69 71 75 65 20 66 6f | "A Tech|nique fo|
|00001440| 72 20 49 73 6f 6c 61 74 | 69 6e 67 20 44 69 66 66 |r Isolat|ing Diff|
|00001450| 65 72 65 6e 63 65 73 20 | 42 65 74 77 65 65 6e 20 |erences |Between |
|00001460| 46 69 6c 65 73 22 0a 20 | 2a 20 43 41 43 4d 2c 20 |Files". |* CACM, |
|00001470| 41 70 72 69 6c 20 31 39 | 37 38 2c 20 62 79 20 50 |April 19|78, by P|
|00001480| 61 75 6c 20 48 65 63 6b | 65 6c 2e 0a 20 2a 20 53 |aul Heck|el.. * S|
|00001490| 6f 6d 65 20 69 64 65 61 | 73 20 66 6f 72 20 70 61 |ome idea|s for pa|
|000014a0| 73 73 20 36 20 77 65 72 | 65 20 62 6f 72 72 6f 77 |ss 6 wer|e borrow|
|000014b0| 65 64 20 66 72 6f 6d 20 | 22 57 68 61 74 27 73 20 |ed from |"What's |
|000014c0| 54 68 65 20 44 69 66 66 | 3f 20 2d 2d 20 41 20 46 |The Diff|? -- A F|
|000014d0| 69 6c 65 0a 20 2a 20 43 | 6f 6d 70 61 72 61 74 6f |ile. * C|omparato|
|000014e0| 72 20 66 6f 72 20 43 50 | 2f 4d 22 2c 20 44 72 2e |r for CP|/M", Dr.|
|000014f0| 20 44 6f 62 62 27 73 20 | 4a 6f 75 72 6e 61 6c 2c | Dobb's |Journal,|
|00001500| 20 41 75 67 75 73 74 20 | 31 39 38 34 2c 20 62 79 | August |1984, by|
|00001510| 20 44 2e 45 2e 20 43 6f | 72 74 65 73 69 2e 0a 20 | D.E. Co|rtesi.. |
|00001520| 2a 20 54 68 65 20 62 6f | 72 72 6f 77 65 64 20 69 |* The bo|rrowed i|
|00001530| 64 65 61 20 77 61 73 20 | 74 68 61 74 20 77 68 65 |dea was |that whe|
|00001540| 6e 20 79 6f 75 20 61 72 | 65 20 61 74 20 74 68 65 |n you ar|e at the|
|00001550| 20 62 65 67 69 6e 6e 69 | 6e 67 20 6f 66 20 74 77 | beginni|ng of tw|
|00001560| 6f 0a 20 2a 20 62 6c 6f | 63 6b 73 20 6f 66 20 6c |o. * blo|cks of l|
|00001570| 69 6e 65 73 20 77 68 69 | 63 68 20 6c 69 6e 6b 20 |ines whi|ch link |
|00001580| 77 69 74 68 20 6c 69 6e | 65 73 20 69 6e 20 74 68 |with lin|es in th|
|00001590| 65 20 6f 74 68 65 72 20 | 66 69 6c 65 2c 20 62 75 |e other |file, bu|
|000015a0| 74 20 64 6f 6e 27 74 0a | 20 2a 20 6d 61 74 63 68 |t don't.| * match|
|000015b0| 2c 20 74 68 65 6e 20 74 | 68 65 20 73 6d 61 6c 6c |, then t|he small|
|000015c0| 65 72 20 61 73 63 65 6e | 64 69 6e 67 20 62 6c 6f |er ascen|ding blo|
|000015d0| 63 6b 20 69 73 20 74 68 | 65 20 22 6d 6f 76 65 64 |ck is th|e "moved|
|000015e0| 20 62 6c 6f 63 6b 22 2e | 0a 20 2a 0a 20 2a 20 54 | block".|. *. * T|
|000015f0| 68 65 20 70 61 73 73 35 | 61 20 28 29 20 69 73 20 |he pass5|a () is |
|00001600| 63 6f 64 65 64 20 64 69 | 72 65 63 74 6c 79 20 66 |coded di|rectly f|
|00001610| 72 6f 6d 20 68 69 73 20 | 68 69 73 20 70 61 73 73 |rom his |his pass|
|00001620| 35 20 50 61 73 63 61 6c | 20 70 72 6f 63 65 64 75 |5 Pascal| procedu|
|00001630| 72 65 2e 0a 20 2a 20 49 | 74 20 64 6f 65 73 6e 27 |re.. * I|t doesn'|
|00001640| 74 20 77 6f 72 6b 20 69 | 66 20 74 68 65 20 6f 6c |t work i|f the ol|
|00001650| 64 20 6c 69 6e 65 20 62 | 65 69 6e 67 20 6c 6f 6f |d line b|eing loo|
|00001660| 6b 65 64 20 75 70 20 69 | 6e 20 74 68 65 20 73 79 |ked up i|n the sy|
|00001670| 6d 62 6f 6c 20 74 61 62 | 6c 65 0a 20 2a 20 69 73 |mbol tab|le. * is|
|00001680| 6e 27 74 20 75 6e 69 71 | 75 65 21 21 21 20 20 59 |n't uniq|ue!!! Y|
|00001690| 6f 75 20 77 6f 75 6c 64 | 20 68 61 76 65 20 74 6f |ou would| have to|
|000016a0| 20 63 68 61 6e 67 65 20 | 74 68 65 20 66 6f 72 6d | change |the form|
|000016b0| 61 74 20 6f 66 20 74 68 | 65 20 6c 69 6e 65 72 65 |at of th|e linere|
|000016c0| 63 0a 20 2a 20 72 65 63 | 6f 72 64 20 74 6f 20 6d |c. * rec|ord to m|
|000016d0| 61 6b 65 20 69 74 20 77 | 6f 72 6b 2e 20 20 54 68 |ake it w|ork. Th|
|000016e0| 61 74 27 73 20 77 68 79 | 20 69 74 27 73 20 63 6f |at's why| it's co|
|000016f0| 6d 6d 65 6e 74 65 64 20 | 6f 75 74 2e 0a 20 2a 0a |mmented |out.. *.|
|00001700| 20 2a 20 4f 75 74 70 75 | 74 0a 0a 44 45 4c 45 54 | * Outpu|t..DELET|
|00001710| 45 53 0a 2d 2d 2d 2d 2d | 2d 2d 0a 6f 6c 64 20 64 |ES.-----|--.old d|
|00001720| 20 6e 65 77 20 09 09 2f | 2f 20 53 69 6e 67 6c 65 | new ../|/ Single|
|00001730| 20 6c 69 6e 65 20 64 65 | 6c 65 74 65 20 2d 20 4f | line de|lete - O|
|00001740| 6c 64 20 6c 69 6e 65 20 | 6e 75 6d 62 65 72 20 27 |ld line |number '|
|00001750| 6f 6c 64 27 20 69 73 0a | 09 09 09 2f 2f 20 64 65 |old' is.|...// de|
|00001760| 6c 65 74 65 64 20 61 66 | 74 65 72 20 6e 65 77 20 |leted af|ter new |
|00001770| 6c 69 6e 65 20 6e 75 6d | 62 65 72 65 64 20 27 6e |line num|bered 'n|
|00001780| 65 77 27 0a 73 74 61 72 | 74 6f 6c 64 2c 65 6e 64 |ew'.star|told,end|
|00001790| 6f 6c 64 20 64 20 6e 65 | 77 09 2f 2f 20 42 6c 6f |old d ne|w.// Blo|
|000017a0| 63 6b 20 6c 69 6e 65 20 | 64 65 6c 65 74 65 20 2d |ck line |delete -|
|000017b0| 20 4f 6c 64 20 62 6c 6f | 63 6b 20 6f 66 20 6c 69 | Old blo|ck of li|
|000017c0| 6e 65 73 20 27 73 74 61 | 72 74 6f 6c 64 27 0a 09 |nes 'sta|rtold'..|
|000017d0| 09 09 2f 2f 20 74 6f 20 | 27 65 6e 64 6f 6c 64 27 |..// to |'endold'|
|000017e0| 20 61 72 65 20 64 65 6c | 65 74 65 64 20 61 66 74 | are del|eted aft|
|000017f0| 65 72 20 6e 65 77 20 6c | 69 6e 65 20 6e 75 6d 62 |er new l|ine numb|
|00001800| 65 72 20 27 6e 65 77 27 | 0a 0a 49 4e 53 45 52 54 |er 'new'|..INSERT|
|00001810| 53 0a 2d 2d 2d 2d 2d 2d | 2d 0a 6f 6c 64 20 61 20 |S.------|-.old a |
|00001820| 6e 65 77 09 09 2f 2f 20 | 41 66 74 65 72 20 6f 6c |new..// |After ol|
|00001830| 64 20 6c 69 6e 65 20 6e | 75 6d 62 65 72 20 27 6f |d line n|umber 'o|
|00001840| 6c 64 27 20 69 73 20 6e | 65 77 20 6c 69 6e 65 20 |ld' is n|ew line |
|00001850| 6e 75 6d 62 65 72 20 27 | 6e 65 77 27 0a 6f 6c 64 |number '|new'.old|
|00001860| 20 61 20 73 74 61 72 74 | 6e 65 77 2c 65 6e 64 6e | a start|new,endn|
|00001870| 65 77 09 2f 2f 20 41 66 | 74 65 72 20 6f 6c 64 20 |ew.// Af|ter old |
|00001880| 6c 69 6e 65 20 6e 75 6d | 62 65 72 20 27 6f 6c 64 |line num|ber 'old|
|00001890| 27 2c 20 6e 65 77 20 6c | 69 6e 65 73 20 6e 75 6d |', new l|ines num|
|000018a0| 62 65 72 65 64 0a 09 09 | 09 2f 2f 20 27 73 74 61 |bered...|.// 'sta|
|000018b0| 72 74 6e 65 77 27 20 74 | 6f 20 27 65 6e 64 6e 65 |rtnew' t|o 'endne|
|000018c0| 77 27 0a 0a 43 48 41 4e | 47 45 53 0a 2d 2d 2d 2d |w'..CHAN|GES.----|
|000018d0| 2d 2d 2d 0a 6f 6c 64 20 | 63 20 6e 65 77 09 09 2f |---.old |c new../|
|000018e0| 2f 20 43 68 61 6e 67 65 | 20 6f 6c 64 20 6c 69 6e |/ Change| old lin|
|000018f0| 65 20 6e 75 6d 62 65 72 | 65 64 20 27 6f 6c 64 27 |e number|ed 'old'|
|00001900| 20 74 6f 20 6e 65 77 20 | 6c 69 6e 65 20 6e 75 6d | to new |line num|
|00001910| 62 65 72 65 64 0a 09 09 | 09 2f 2f 20 27 6e 65 77 |bered...|.// 'new|
|00001920| 27 0a 6f 6c 64 20 63 20 | 73 74 61 72 74 6e 65 77 |'.old c |startnew|
|00001930| 2c 65 6e 64 6e 65 77 09 | 2f 2f 20 43 68 61 6e 67 |,endnew.|// Chang|
|00001940| 65 20 6f 6e 65 20 6c 69 | 6e 65 20 74 6f 20 61 20 |e one li|ne to a |
|00001950| 62 6c 6f 63 6b 20 6f 66 | 20 6c 69 6e 65 73 2e 20 |block of| lines. |
|00001960| 20 4f 6c 64 20 6c 69 6e | 65 0a 09 09 09 2f 2f 20 | Old lin|e....// |
|00001970| 6e 75 6d 62 65 72 65 64 | 20 27 6f 6c 64 27 20 62 |numbered| 'old' b|
|00001980| 65 63 6f 6d 65 73 20 74 | 68 65 20 6e 65 77 20 73 |ecomes t|he new s|
|00001990| 65 74 20 6f 66 20 6c 69 | 6e 65 73 2e 0a 73 74 61 |et of li|nes..sta|
|000019a0| 72 74 6f 6c 64 2c 65 6e | 64 6f 6c 64 20 63 20 6e |rtold,en|dold c n|
|000019b0| 65 77 09 2f 2f 20 20 43 | 68 61 6e 67 65 20 61 20 |ew.// C|hange a |
|000019c0| 62 6c 6f 63 6b 20 6f 66 | 20 6f 6c 64 20 6c 69 6e |block of| old lin|
|000019d0| 65 73 20 74 6f 20 6f 6e | 65 20 6e 65 77 20 6c 69 |es to on|e new li|
|000019e0| 6e 65 2e 0a 73 74 61 72 | 74 6f 6c 64 2c 65 6e 64 |ne..star|told,end|
|000019f0| 6f 6c 64 20 63 20 73 74 | 61 72 74 6e 65 77 2c 65 |old c st|artnew,e|
|00001a00| 6e 64 6e 65 77 09 2f 2f | 20 43 68 61 6e 67 65 20 |ndnew.//| Change |
|00001a10| 61 20 62 6c 6f 63 6b 20 | 6f 66 20 6c 69 6e 65 73 |a block |of lines|
|00001a20| 20 74 6f 0a 09 09 09 2f | 2f 20 61 20 64 69 66 66 | to..../|/ a diff|
|00001a30| 65 72 65 6e 74 20 62 6c | 6f 63 6b 20 6f 66 20 6c |erent bl|ock of l|
|00001a40| 69 6e 65 73 2e 0a 0a 4d | 4f 56 45 53 0a 2d 2d 2d |ines...M|OVES.---|
|00001a50| 2d 2d 0a 6f 6c 64 20 6d | 20 6e 65 77 09 09 2f 2f |--.old m| new..//|
|00001a60| 20 4f 6c 64 20 6c 69 6e | 65 20 6e 75 6d 62 65 72 | Old lin|e number|
|00001a70| 20 27 6f 6c 64 27 20 69 | 73 20 6d 6f 76 65 64 20 | 'old' i|s moved |
|00001a80| 74 6f 20 6e 65 77 20 6c | 69 6e 65 0a 09 09 09 2f |to new l|ine..../|
|00001a90| 2f 20 6e 75 6d 62 65 72 | 20 27 6e 65 77 27 0a 73 |/ number| 'new'.s|
|00001aa0| 74 61 72 74 6f 6c 64 2c | 65 6e 64 6f 6c 64 20 6d |tartold,|endold m|
|00001ab0| 20 73 74 61 72 74 6e 65 | 77 2c 65 6e 64 6e 65 77 | startne|w,endnew|
|00001ac0| 20 20 2f 2f 20 54 68 65 | 20 6f 6c 64 20 62 6c 6f | // The| old blo|
|00001ad0| 63 6b 20 6f 66 20 6c 69 | 6e 65 73 20 68 61 76 65 |ck of li|nes have|
|00001ae0| 20 62 65 65 6e 20 6d 6f | 76 65 64 0a 09 09 09 2f | been mo|ved..../|
|00001af0| 2f 20 61 6e 64 20 74 68 | 65 20 6f 6c 64 20 6c 69 |/ and th|e old li|
|00001b00| 6e 65 20 6e 75 6d 62 65 | 72 73 20 68 61 76 65 20 |ne numbe|rs have |
|00001b10| 63 68 61 6e 67 65 64 2e | 0a 0a 0a 46 6f 72 20 44 |changed.|...For D|
|00001b20| 45 4c 45 54 45 53 2c 20 | 49 4e 53 45 52 54 53 2c |ELETES, |INSERTS,|
|00001b30| 20 61 6e 64 20 43 48 41 | 4e 47 45 53 20 28 62 75 | and CHA|NGES (bu|
|00001b40| 74 20 6e 6f 74 20 4d 4f | 56 45 53 29 20 74 68 65 |t not MO|VES) the|
|00001b50| 20 6f 6c 64 20 6c 69 6e | 65 20 61 6e 64 20 6e 65 | old lin|e and ne|
|00001b60| 77 20 6c 69 6e 65 73 0a | 61 72 65 20 64 69 73 70 |w lines.|are disp|
|00001b70| 6c 61 79 65 64 20 61 73 | 20 66 6f 6c 6c 6f 77 73 |layed as| follows|
|00001b80| 3a 0a 3c 20 6f 6c 64 20 | 6c 69 6e 65 0a 3e 20 6e |:.< old |line.> n|
|00001b90| 65 77 20 6c 69 6e 65 0a | 0a 20 2a 2f 0a 0a 23 69 |ew line.|. */..#i|
|00001ba0| 6e 63 6c 75 64 65 20 3c | 73 74 64 69 6f 2e 68 3e |nclude <|stdio.h>|
|00001bb0| 0a 23 69 6e 63 6c 75 64 | 65 20 22 73 74 72 69 70 |.#includ|e "strip|
|00001bc0| 6e 6c 2e 68 22 0a 0a 2f | 2a 20 63 68 6f 6f 73 65 |nl.h"../|* choose|
|00001bd0| 20 53 4b 49 50 43 4f 55 | 4e 54 20 61 6e 64 20 42 | SKIPCOU|NT and B|
|00001be0| 49 47 50 52 49 4d 45 20 | 61 73 20 66 6f 6c 6c 6f |IGPRIME |as follo|
|00001bf0| 77 73 3a 0a 20 2a 20 42 | 49 47 50 52 49 4d 45 20 |ws:. * B|IGPRIME |
|00001c00| 3e 20 32 2a 4d 41 58 4c | 49 4e 45 53 20 69 6e 20 |> 2*MAXL|INES in |
|00001c10| 63 61 73 65 20 62 6f 74 | 68 20 66 69 6c 65 73 20 |case bot|h files |
|00001c20| 68 61 76 65 20 61 6c 6c | 20 75 6e 69 71 75 65 20 |have all| unique |
|00001c30| 6c 69 6e 65 73 0a 20 2a | 20 73 75 63 68 20 74 68 |lines. *| such th|
|00001c40| 61 74 20 53 4b 49 50 43 | 4f 55 4e 54 2a 74 61 62 |at SKIPC|OUNT*tab|
|00001c50| 6c 65 73 69 7a 65 20 70 | 72 6f 62 65 73 20 77 69 |lesize p|robes wi|
|00001c60| 6c 6c 20 68 69 74 20 65 | 76 65 72 79 20 73 6c 6f |ll hit e|very slo|
|00001c70| 74 20 69 6e 20 68 61 73 | 68 20 74 62 6c 0a 20 2a |t in has|h tbl. *|
|00001c80| 20 28 68 69 6e 74 3a 20 | 75 73 65 20 74 68 65 20 | (hint: |use the |
|00001c90| 68 61 73 68 74 62 6c 20 | 61 2e 6f 75 74 20 74 6f |hashtbl |a.out to|
|00001ca0| 20 68 65 6c 70 20 79 6f | 75 29 0a 20 2a 2f 0a 23 | help yo|u). */.#|
|00001cb0| 64 65 66 69 6e 65 20 4d | 41 58 4c 49 4e 45 53 20 |define M|AXLINES |
|00001cc0| 35 30 30 30 09 09 2f 2a | 20 6d 61 78 20 6c 69 6e |5000../*| max lin|
|00001cd0| 65 73 20 70 65 72 20 66 | 69 6c 65 20 74 68 61 74 |es per f|ile that|
|00001ce0| 20 63 61 6e 20 68 61 6e | 64 6c 65 09 2a 2f 0a 23 | can han|dle.*/.#|
|00001cf0| 64 65 66 69 6e 65 20 42 | 49 47 50 52 49 4d 45 20 |define B|IGPRIME |
|00001d00| 31 30 30 30 31 09 09 2f | 2a 20 69 64 65 61 6c 6c |10001../|* ideall|
|00001d10| 79 20 61 20 70 72 69 6d | 65 20 6e 75 6d 62 65 72 |y a prim|e number|
|00001d20| 20 3e 20 32 2a 4d 41 58 | 4c 49 4e 45 53 20 66 6f | > 2*MAX|LINES fo|
|00001d30| 72 20 68 61 73 68 20 69 | 6e 74 6f 20 73 79 6d 74 |r hash i|nto symt|
|00001d40| 62 6c 20 2a 2f 0a 23 64 | 65 66 69 6e 65 20 5f 4d |bl */.#d|efine _M|
|00001d50| 41 58 4c 49 4e 45 31 20 | 4d 41 58 4c 49 4e 45 53 |AXLINE1 |MAXLINES|
|00001d60| 2b 32 09 2f 2a 20 74 77 | 6f 20 65 78 74 72 61 20 |+2./* tw|o extra |
|00001d70| 66 6f 72 20 66 69 72 73 | 74 2c 20 6c 61 73 74 20 |for firs|t, last |
|00001d80| 73 65 6e 74 69 6e 65 6c | 09 2a 2f 0a 23 64 65 66 |sentinel|.*/.#def|
|00001d90| 69 6e 65 20 4c 49 4e 45 | 53 49 5a 45 20 31 30 32 |ine LINE|SIZE 102|
|00001da0| 34 09 09 2f 2a 20 6d 61 | 78 20 63 68 61 72 73 20 |4../* ma|x chars |
|00001db0| 70 65 72 20 6c 69 6e 65 | 09 09 09 2a 2f 0a 23 64 |per line|...*/.#d|
|00001dc0| 65 66 69 6e 65 20 5f 4c | 49 4e 45 53 49 5a 45 20 |efine _L|INESIZE |
|00001dd0| 4c 49 4e 45 53 49 5a 45 | 2b 32 09 2f 2a 20 74 77 |LINESIZE|+2./* tw|
|00001de0| 6f 20 65 78 74 72 61 20 | 66 6f 72 20 27 5c 6e 27 |o extra |for '\n'|
|00001df0| 2c 20 27 5c 30 27 20 66 | 67 65 74 73 20 72 74 6e |, '\0' f|gets rtn|
|00001e00| 73 09 2a 2f 0a 23 64 65 | 66 69 6e 65 20 53 4b 49 |s.*/.#de|fine SKI|
|00001e10| 50 43 4f 55 4e 54 09 34 | 09 2f 2a 20 72 65 70 72 |PCOUNT.4|./* repr|
|00001e20| 6f 62 65 20 69 6e 74 6f | 20 68 61 73 68 20 73 79 |obe into| hash sy|
|00001e30| 6d 62 6f 6c 20 74 61 62 | 6c 65 09 2a 2f 0a 23 64 |mbol tab|le.*/.#d|
|00001e40| 65 66 69 6e 65 20 43 48 | 41 4e 47 45 53 45 50 09 |efine CH|ANGESEP.|
|00001e50| 22 2d 2d 2d 5c 6e 22 09 | 2f 2a 20 6c 69 6e 65 20 |"---\n".|/* line |
|00001e60| 73 65 70 61 72 61 74 6f | 72 20 66 6f 72 20 63 68 |separato|r for ch|
|00001e70| 61 6e 67 65 20 62 6c 6f | 63 6b 09 2a 2f 0a 23 64 |ange blo|ck.*/.#d|
|00001e80| 65 66 69 6e 65 20 5a 41 | 50 46 4c 41 47 09 31 09 |efine ZA|PFLAG.1.|
|00001e90| 09 2f 2a 20 31 20 3d 20 | 79 65 73 2c 20 72 65 6d |./* 1 = |yes, rem|
|00001ea0| 6f 76 65 20 6c 65 61 64 | 69 6e 67 20 77 68 69 74 |ove lead|ing whit|
|00001eb0| 65 20 73 70 61 63 65 09 | 2a 2f 0a 0a 0a 0a 0a 2f |e space.|*/...../|
|00001ec0| 2a 20 73 74 72 75 63 74 | 75 72 65 20 66 6f 72 20 |* struct|ure for |
|00001ed0| 6f 6c 64 2c 20 6e 65 77 | 20 66 69 6c 65 73 2e 20 |old, new| files. |
|00001ee0| 20 4f 6e 65 20 73 74 72 | 75 63 74 75 72 65 20 70 | One str|ucture p|
|00001ef0| 65 72 20 6c 69 6e 65 2e | 0a 20 2a 20 41 6e 20 61 |er line.|. * An a|
|00001f00| 72 72 61 79 20 6f 61 20 | 66 6f 72 20 74 68 65 20 |rray oa |for the |
|00001f10| 6f 6c 64 20 66 69 6c 65 | 2c 20 61 6e 64 20 61 6e |old file|, and an|
|00001f20| 20 61 72 72 61 79 20 6e | 61 20 66 6f 72 20 74 68 | array n|a for th|
|00001f30| 65 20 6e 65 77 20 66 69 | 6c 65 2e 0a 20 2a 20 49 |e new fi|le.. * I|
|00001f40| 66 20 74 68 65 20 6c 69 | 6e 65 20 27 6f 6c 64 69 |f the li|ne 'oldi|
|00001f50| 27 20 69 6e 20 74 68 65 | 20 6f 6c 64 20 66 69 6c |' in the| old fil|
|00001f60| 65 20 68 61 73 20 4e 4f | 54 20 62 65 65 6e 20 6d |e has NO|T been m|
|00001f70| 61 74 63 68 65 64 20 74 | 6f 20 61 20 6c 69 6e 65 |atched t|o a line|
|00001f80| 20 69 6e 0a 20 2a 20 74 | 68 65 20 6e 65 77 20 66 | in. * t|he new f|
|00001f90| 69 6c 65 20 74 68 65 6e | 20 6f 61 5b 6f 6c 64 69 |ile then| oa[oldi|
|00001fa0| 5d 2e 66 6c 61 67 20 3d | 3d 20 4c 5f 53 59 4d 49 |].flag =|= L_SYMI|
|00001fb0| 4e 44 58 2e 0a 20 2a 20 | 53 69 6d 69 6c 61 72 6c |NDX.. * |Similarl|
|00001fc0| 79 20 69 66 20 74 68 65 | 20 6c 69 6e 65 20 27 6e |y if the| line 'n|
|00001fd0| 65 77 69 27 20 69 6e 20 | 74 68 65 20 6e 65 77 20 |ewi' in |the new |
|00001fe0| 66 69 6c 65 20 68 61 73 | 20 4e 4f 54 20 62 65 65 |file has| NOT bee|
|00001ff0| 6e 20 6d 61 74 63 68 65 | 64 20 74 6f 0a 20 2a 20 |n matche|d to. * |
|00002000| 61 20 6c 69 6e 65 20 69 | 6e 20 74 68 65 20 6f 6c |a line i|n the ol|
|00002010| 64 20 66 69 6c 65 2c 20 | 74 68 65 6e 20 6e 61 5b |d file, |then na[|
|00002020| 6e 65 77 69 5d 2e 66 6c | 61 67 20 3d 3d 20 4c 5f |newi].fl|ag == L_|
|00002030| 53 59 4d 49 4e 44 58 2e | 0a 20 2a 20 57 68 65 6e |SYMINDX.|. * When|
|00002040| 20 6c 69 6e 65 20 27 6f | 6c 64 69 27 20 69 6e 20 | line 'o|ldi' in |
|00002050| 74 68 65 20 6f 6c 64 20 | 66 69 6c 65 20 68 61 73 |the old |file has|
|00002060| 20 62 65 65 6e 20 6d 61 | 74 63 68 65 64 20 74 6f | been ma|tched to|
|00002070| 20 6c 69 6e 65 20 27 6e | 65 77 69 27 0a 20 2a 20 | line 'n|ewi'. * |
|00002080| 69 6e 20 74 68 65 20 6e | 65 77 20 66 69 6c 65 2c |in the n|ew file,|
|00002090| 20 74 68 65 6e 20 6f 61 | 5b 6f 6c 64 69 5d 2e 66 | then oa|[oldi].f|
|000020a0| 6c 61 67 20 3d 3d 20 4c | 5f 4c 49 4e 45 4e 55 4d |lag == L|_LINENUM|
|000020b0| 2c 0a 20 2a 20 6e 61 5b | 6e 65 77 69 5d 2e 66 6c |,. * na[|newi].fl|
|000020c0| 61 67 20 3d 3d 20 4c 5f | 4c 49 4e 45 4e 55 4d 2c |ag == L_|LINENUM,|
|000020d0| 20 61 6e 64 20 65 61 63 | 68 20 6c 69 6e 65 20 70 | and eac|h line p|
|000020e0| 6f 69 6e 74 73 20 74 6f | 20 74 68 65 20 6f 74 68 |oints to| the oth|
|000020f0| 65 72 2c 20 65 2e 67 2e | 2c 0a 20 2a 20 6f 61 5b |er, e.g.|,. * oa[|
|00002100| 6f 6c 64 69 5d 2e 6c 69 | 6e 65 6c 6f 63 20 3d 3d |oldi].li|neloc ==|
|00002110| 20 6e 65 77 69 2c 20 61 | 6e 64 20 6e 61 5b 6e 65 | newi, a|nd na[ne|
|00002120| 77 69 5d 2e 6c 69 6e 65 | 6c 6f 63 20 3d 3d 20 6f |wi].line|loc == o|
|00002130| 6c 64 69 2e 0a 20 2a 2f | 0a 73 74 72 75 63 74 20 |ldi.. */|.struct |
|00002140| 6c 69 6e 65 72 65 63 20 | 7b 0a 09 69 6e 74 20 6c |linerec |{..int l|
|00002150| 69 6e 65 6c 6f 63 3b 09 | 09 2f 2a 20 6c 69 6e 65 |ineloc;.|./* line|
|00002160| 20 6e 75 6d 62 65 72 20 | 69 6e 20 6f 74 68 65 72 | number |in other|
|00002170| 20 66 69 6c 65 20 6f 72 | 20 73 79 6d 74 62 6c 20 | file or| symtbl |
|00002180| 69 6e 64 65 78 20 2a 2f | 0a 09 69 6e 74 20 66 6c |index */|..int fl|
|00002190| 61 67 3b 09 09 2f 2a 20 | 74 65 6c 6c 73 20 77 68 |ag;../* |tells wh|
|000021a0| 69 63 68 20 61 73 20 64 | 65 66 69 6e 65 64 20 62 |ich as d|efined b|
|000021b0| 65 6c 6f 77 09 09 2a 2f | 0a 09 7d 3b 0a 23 64 65 |elow..*/|..};.#de|
|000021c0| 66 69 6e 65 20 4c 5f 4c | 49 4e 45 4e 55 4d 20 30 |fine L_L|INENUM 0|
|000021d0| 0a 23 64 65 66 69 6e 65 | 20 4c 5f 53 59 4d 49 4e |.#define| L_SYMIN|
|000021e0| 44 58 20 31 0a 0a 0a 0a | 2f 2a 20 73 79 6d 62 6f |DX 1....|/* symbo|
|000021f0| 6c 20 74 61 62 6c 65 20 | 73 74 72 75 63 74 75 72 |l table |structur|
|00002200| 65 2e 20 20 4f 6e 65 20 | 70 65 72 20 75 6e 69 71 |e. One |per uniq|
|00002210| 75 65 20 6c 69 6e 65 20 | 69 6e 20 62 6f 74 68 20 |ue line |in both |
|00002220| 66 69 6c 65 73 2e 09 09 | 2a 2f 0a 2f 2a 20 74 68 |files...|*/./* th|
|00002230| 65 20 6c 69 6e 65 20 69 | 73 20 6b 65 79 65 64 20 |e line i|s keyed |
|00002240| 69 6e 74 6f 20 74 68 65 | 20 61 72 72 61 79 20 76 |into the| array v|
|00002250| 69 61 20 61 20 68 61 73 | 68 20 63 6f 64 65 09 09 |ia a has|h code..|
|00002260| 09 2a 2f 0a 73 74 72 75 | 63 74 20 73 79 6d 72 65 |.*/.stru|ct symre|
|00002270| 63 20 7b 0a 09 63 68 61 | 72 09 2a 73 74 61 73 68 |c {..cha|r.*stash|
|00002280| 6c 69 6e 65 3b 09 2f 2a | 20 73 61 76 65 64 20 6c |line;./*| saved l|
|00002290| 69 6e 65 20 69 6e 20 6d | 61 6c 6c 6f 63 27 65 64 |ine in m|alloc'ed|
|000022a0| 20 6d 65 6d 6f 72 79 09 | 2a 2f 0a 09 69 6e 74 09 | memory.|*/..int.|
|000022b0| 6f 63 6f 75 6e 74 3b 09 | 09 2f 2a 20 63 6f 75 6e |ocount;.|./* coun|
|000022c0| 74 20 6f 66 20 6c 69 6e | 65 73 20 69 6e 20 6f 6c |t of lin|es in ol|
|000022d0| 64 20 66 69 6c 65 2c 20 | 30 2c 31 2c 6d 61 6e 79 |d file, |0,1,many|
|000022e0| 09 2a 2f 0a 09 69 6e 74 | 09 6e 63 6f 75 6e 74 3b |.*/..int|.ncount;|
|000022f0| 09 09 2f 2a 20 63 6f 75 | 6e 74 20 6f 66 20 6c 69 |../* cou|nt of li|
|00002300| 6e 65 73 20 69 6e 20 6e | 65 77 20 66 69 6c 65 2c |nes in n|ew file,|
|00002310| 20 30 2c 31 2c 6d 61 6e | 79 09 2a 2f 0a 09 69 6e | 0,1,man|y.*/..in|
|00002320| 74 09 6f 6c 69 6e 65 6e | 75 6d 3b 09 2f 2a 20 6c |t.olinen|um;./* l|
|00002330| 69 6e 65 20 6e 75 6d 62 | 65 72 20 69 6e 20 74 68 |ine numb|er in th|
|00002340| 65 20 6f 6c 64 20 66 69 | 6c 65 09 09 2a 2f 0a 09 |e old fi|le..*/..|
|00002350| 7d 3b 0a 0a 0a 0a 0a 2f | 2a 67 6c 6f 62 61 6c 73 |};...../|*globals|
|00002360| 20 2a 2f 0a 63 68 61 72 | 09 2a 63 6d 64 2c 09 09 | */.char|.*cmd,..|
|00002370| 09 2f 2a 20 6e 61 6d 65 | 20 6f 66 20 74 68 69 73 |./* name| of this|
|00002380| 20 63 6f 6d 6d 61 6e 64 | 09 09 09 2a 2f 0a 09 65 | command|...*/..e|
|00002390| 72 72 62 75 66 20 5b 5f | 4c 49 4e 45 53 49 5a 45 |rrbuf [_|LINESIZE|
|000023a0| 5d 2c 09 2f 2a 20 62 75 | 69 6c 64 20 65 72 72 20 |],./* bu|ild err |
|000023b0| 6d 73 67 20 66 6f 72 20 | 70 65 72 72 6f 72 09 09 |msg for |perror..|
|000023c0| 2a 2f 0a 09 6c 69 6e 65 | 62 75 66 20 5b 5f 4c 49 |*/..line|buf [_LI|
|000023d0| 4e 45 53 49 5a 45 5d 2c | 09 2f 2a 20 72 65 61 64 |NESIZE],|./* read|
|000023e0| 20 6c 69 6e 65 20 66 72 | 6f 6d 20 65 69 74 68 65 | line fr|om eithe|
|000023f0| 72 20 66 69 6c 65 20 69 | 6e 74 6f 20 68 65 72 65 |r file i|nto here|
|00002400| 09 2a 2f 0a 09 72 75 6e | 66 6c 61 67 20 5b 32 36 |.*/..run|flag [26|
|00002410| 5d 2c 09 09 2f 2a 20 61 | 72 72 61 79 20 6f 66 20 |],../* a|rray of |
|00002420| 6f 70 74 69 6f 6e 73 20 | 66 6c 61 67 73 20 73 65 |options |flags se|
|00002430| 74 09 09 2a 2f 0a 09 2a | 6f 6c 64 66 69 6c 65 2c |t..*/..*|oldfile,|
|00002440| 09 09 2f 2a 20 6e 61 6d | 65 20 6f 66 20 6f 6c 64 |../* nam|e of old|
|00002450| 20 66 69 6c 65 09 09 09 | 2a 2f 0a 09 2a 6e 65 77 | file...|*/..*new|
|00002460| 66 69 6c 65 3b 09 09 2f | 2a 20 6e 61 6d 65 20 6f |file;../|* name o|
|00002470| 66 20 6e 65 77 20 66 69 | 6c 65 09 09 09 2a 2f 0a |f new fi|le...*/.|
|00002480| 0a 46 49 4c 45 09 2a 6f | 6c 64 66 70 2c 09 09 09 |.FILE.*o|ldfp,...|
|00002490| 2f 2a 20 73 74 72 65 61 | 6d 20 66 6f 72 20 6f 6c |/* strea|m for ol|
|000024a0| 64 20 66 69 6c 65 09 09 | 09 2a 2f 0a 09 2a 6e 65 |d file..|.*/..*ne|
|000024b0| 77 66 70 3b 09 09 09 2f | 2a 20 73 74 72 65 61 6d |wfp;.../|* stream|
|000024c0| 20 66 6f 72 20 6e 65 77 | 20 66 69 6c 65 09 09 09 | for new| file...|
|000024d0| 2a 2f 0a 0a 73 74 72 75 | 63 74 20 6c 69 6e 65 72 |*/..stru|ct liner|
|000024e0| 65 63 0a 09 6f 61 20 5b | 5f 4d 41 58 4c 49 4e 45 |ec..oa [|_MAXLINE|
|000024f0| 31 5d 2c 09 09 2f 2a 20 | 66 6f 72 20 6f 6c 64 20 |1],../* |for old |
|00002500| 66 69 6c 65 09 09 09 09 | 2a 2f 0a 09 6e 61 20 5b |file....|*/..na [|
|00002510| 5f 4d 41 58 4c 49 4e 45 | 31 5d 3b 09 09 2f 2a 20 |_MAXLINE|1];../* |
|00002520| 66 6f 72 20 6e 65 77 20 | 66 69 6c 65 09 09 09 09 |for new |file....|
|00002530| 2a 2f 0a 0a 73 74 72 75 | 63 74 20 73 79 6d 72 65 |*/..stru|ct symre|
|00002540| 63 0a 09 73 79 6d 74 62 | 6c 20 5b 42 49 47 50 52 |c..symtb|l [BIGPR|
|00002550| 49 4d 45 5d 3b 09 2f 2a | 20 73 79 6d 62 6f 6c 20 |IME];./*| symbol |
|00002560| 74 61 62 6c 65 20 6f 66 | 20 61 6c 6c 20 6c 69 6e |table of| all lin|
|00002570| 65 73 20 73 65 65 6e 09 | 2a 2f 0a 0a 69 6e 74 09 |es seen.|*/..int.|
|00002580| 6c 61 73 74 6e 65 77 2c | 09 09 2f 2a 20 74 6f 74 |lastnew,|../* tot|
|00002590| 61 6c 20 6c 69 6e 65 73 | 20 72 65 61 64 20 66 72 |al lines| read fr|
|000025a0| 6f 6d 20 6e 65 77 20 66 | 69 6c 65 09 2a 2f 0a 09 |om new f|ile.*/..|
|000025b0| 6c 61 73 74 6f 6c 64 2c | 09 09 2f 2a 20 74 6f 74 |lastold,|../* tot|
|000025c0| 61 6c 20 6c 69 6e 65 73 | 20 69 6e 20 6f 6c 64 20 |al lines| in old |
|000025d0| 66 69 6c 65 09 09 2a 2f | 0a 09 6e 75 6d 73 79 6d |file..*/|..numsym|
|000025e0| 62 6f 6c 73 2c 09 09 2f | 2a 20 6e 75 6d 62 65 72 |bols,../|* number|
|000025f0| 20 6f 66 20 65 6e 74 72 | 69 65 73 20 69 6e 20 73 | of entr|ies in s|
|00002600| 79 6d 62 6f 6c 20 74 61 | 62 6c 65 09 2a 2f 0a 09 |ymbol ta|ble.*/..|
|00002610| 64 65 62 75 67 3b 09 09 | 09 2f 2a 20 64 65 62 75 |debug;..|./* debu|
|00002620| 67 20 66 6c 61 67 20 73 | 65 74 20 62 79 20 2d 64 |g flag s|et by -d|
|00002630| 20 66 6c 61 67 09 09 2a | 2f 0a 0a 0a 0a 0a 2f 2a | flag..*|/...../*|
|00002640| 20 65 78 74 65 72 6e 61 | 6c 20 6e 6f 6e 2d 69 6e | externa|l non-in|
|00002650| 74 65 67 65 72 20 66 75 | 6e 63 74 69 6f 6e 73 20 |teger fu|nctions |
|00002660| 2a 2f 0a 46 49 4c 45 09 | 2a 66 6f 70 65 6e 28 29 |*/.FILE.|*fopen()|
|00002670| 3b 09 09 2f 2a 20 66 6f | 70 65 6e 20 28 33 29 09 |;../* fo|pen (3).|
|00002680| 09 09 2a 2f 0a 63 68 61 | 72 09 2a 6d 61 6c 6c 6f |..*/.cha|r.*mallo|
|00002690| 63 20 28 29 3b 09 09 2f | 2a 20 6d 61 6c 6c 6f 63 |c ();../|* malloc|
|000026a0| 20 28 33 29 09 09 09 2a | 2f 0a 63 68 61 72 09 2a | (3)...*|/.char.*|
|000026b0| 72 65 6d 77 68 69 74 65 | 20 28 29 3b 09 09 2f 2a |remwhite| ();../*|
|000026c0| 20 72 65 6d 6f 76 65 20 | 77 68 69 74 65 20 73 70 | remove |white sp|
|000026d0| 61 63 65 20 66 72 6f 6d | 20 73 74 72 69 6e 67 20 |ace from| string |
|000026e0| 2a 2f 0a 0a 2f 2a 20 69 | 6e 74 65 72 6e 61 6c 20 |*/../* i|nternal |
|000026f0| 6e 6f 6e 2d 69 6e 74 65 | 67 65 72 20 66 75 6e 63 |non-inte|ger func|
|00002700| 74 69 6f 6e 73 20 2a 2f | 0a 75 6e 73 69 67 6e 65 |tions */|.unsigne|
|00002710| 64 20 69 6e 74 20 68 61 | 73 68 6c 69 6e 65 20 28 |d int ha|shline (|
|00002720| 29 3b 0a 0a 0a 6d 61 69 | 6e 20 28 61 72 67 63 2c |);...mai|n (argc,|
|00002730| 20 61 72 67 76 29 0a 09 | 69 6e 74 20 61 72 67 63 | argv)..|int argc|
|00002740| 3b 0a 09 63 68 61 72 20 | 2a 2a 61 72 67 76 3b 0a |;..char |**argv;.|
|00002750| 0a 7b 0a 09 69 6e 74 09 | 75 73 61 67 65 3b 09 09 |.{..int.|usage;..|
|00002760| 2f 2a 20 54 52 55 45 20 | 69 66 66 20 74 68 65 72 |/* TRUE |iff ther|
|00002770| 65 20 69 73 20 61 20 75 | 73 61 67 65 20 65 72 72 |e is a u|sage err|
|00002780| 6f 72 20 2a 2f 0a 0a 09 | 2f 2a 20 6e 61 6d 65 20 |or */...|/* name |
|00002790| 6f 66 20 63 6f 6d 6d 61 | 6e 64 20 2a 2f 0a 09 63 |of comma|nd */..c|
|000027a0| 6d 64 20 3d 20 61 72 67 | 76 20 5b 30 5d 3b 0a 0a |md = arg|v [0];..|
|000027b0| 09 2f 2a 20 63 68 65 63 | 6b 20 61 72 67 75 6d 65 |./* chec|k argume|
|000027c0| 6e 74 73 20 61 6e 64 20 | 61 73 73 69 67 6e 20 67 |nts and |assign g|
|000027d0| 6c 6f 62 61 6c 20 66 69 | 6c 65 20 6e 61 6d 65 73 |lobal fi|le names|
|000027e0| 20 2a 2f 0a 09 75 73 61 | 67 65 20 3d 20 30 3b 09 | */..usa|ge = 0;.|
|000027f0| 09 2f 2a 20 61 73 73 75 | 6d 65 20 6e 6f 20 75 73 |./* assu|me no us|
|00002800| 61 67 65 20 65 72 72 6f | 72 20 2a 2f 0a 09 64 65 |age erro|r */..de|
|00002810| 62 75 67 20 3d 20 30 3b | 09 09 2f 2a 20 61 73 73 |bug = 0;|../* ass|
|00002820| 75 6d 65 20 6e 6f 20 64 | 65 62 75 67 67 69 6e 67 |ume no d|ebugging|
|00002830| 20 77 61 6e 74 65 64 20 | 2a 2f 0a 09 69 66 20 28 | wanted |*/..if (|
|00002840| 61 72 67 63 20 3d 3d 20 | 33 29 0a 09 09 7b 0a 09 |argc == |3)...{..|
|00002850| 09 6f 6c 64 66 69 6c 65 | 20 3d 20 61 72 67 76 20 |.oldfile| = argv |
|00002860| 5b 31 5d 3b 0a 09 09 6e | 65 77 66 69 6c 65 20 3d |[1];...n|ewfile =|
|00002870| 20 61 72 67 76 20 5b 32 | 5d 3b 0a 09 09 7d 0a 09 | argv [2|];...}..|
|00002880| 65 6c 73 65 20 69 66 20 | 28 61 72 67 63 20 3d 3d |else if |(argc ==|
|00002890| 20 34 20 26 26 20 2a 61 | 72 67 76 5b 31 5d 20 3d | 4 && *a|rgv[1] =|
|000028a0| 3d 20 27 2d 27 29 0a 09 | 09 7b 0a 09 09 72 65 67 |= '-')..|.{...reg|
|000028b0| 69 73 74 65 72 20 63 68 | 61 72 20 2a 63 70 3b 0a |ister ch|ar *cp;.|
|000028c0| 09 09 66 6f 72 20 28 63 | 70 20 3d 20 61 72 67 76 |..for (c|p = argv|
|000028d0| 5b 31 5d 2b 31 3b 20 2a | 63 70 3b 20 2b 2b 63 70 |[1]+1; *|cp; ++cp|
|000028e0| 29 0a 09 09 09 69 66 20 | 28 27 61 27 20 3c 3d 20 |)....if |('a' <= |
|000028f0| 2a 63 70 20 26 26 20 2a | 63 70 20 3c 3d 20 27 7a |*cp && *|cp <= 'z|
|00002900| 27 29 0a 09 09 09 09 73 | 77 69 74 63 68 20 28 2a |').....s|witch (*|
|00002910| 63 70 29 20 7b 0a 09 09 | 09 09 63 61 73 65 20 27 |cp) {...|..case '|
|00002920| 76 27 3a 09 2f 2a 20 76 | 65 72 62 6f 73 65 20 2d |v':./* v|erbose -|
|00002930| 20 64 65 62 75 67 20 2a | 2f 0a 09 09 09 09 63 61 | debug *|/.....ca|
|00002940| 73 65 20 27 64 27 3a 09 | 2f 2a 20 64 72 6f 70 20 |se 'd':.|/* drop |
|00002950| 2a 2f 0a 09 09 09 09 63 | 61 73 65 20 27 6d 27 3a |*/.....c|ase 'm':|
|00002960| 09 2f 2a 20 6d 6f 6e 6f | 74 6f 6e 69 63 61 6c 20 |./* mono|tonical |
|00002970| 62 79 20 31 20 2a 2f 0a | 09 09 09 09 63 61 73 65 |by 1 */.|....case|
|00002980| 20 27 63 27 3a 09 2f 2a | 20 63 6f 75 6e 74 20 2a | 'c':./*| count *|
|00002990| 2f 0a 09 09 09 09 63 61 | 73 65 20 27 77 27 3a 09 |/.....ca|se 'w':.|
|000029a0| 2f 2a 20 77 68 69 74 65 | 20 73 70 61 63 65 20 2a |/* white| space *|
|000029b0| 2f 0a 09 09 09 09 09 69 | 66 20 28 2a 63 70 20 3d |/......i|f (*cp =|
|000029c0| 3d 20 27 76 27 29 0a 09 | 09 09 09 09 09 64 65 62 |= 'v')..|.....deb|
|000029d0| 75 67 20 3d 20 31 3b 0a | 09 09 09 09 09 72 75 6e |ug = 1;.|.....run|
|000029e0| 66 6c 61 67 20 5b 2a 63 | 70 20 2d 20 27 61 27 5d |flag [*c|p - 'a']|
|000029f0| 20 3d 20 31 3b 0a 09 09 | 09 09 09 62 72 65 61 6b | = 1;...|...break|
|00002a00| 3b 0a 09 09 09 09 64 65 | 66 61 75 6c 74 3a 0a 09 |;.....de|fault:..|
|00002a10| 09 09 09 09 75 73 61 67 | 65 20 3d 20 31 3b 0a 09 |....usag|e = 1;..|
|00002a20| 09 09 09 09 62 72 65 61 | 6b 3b 0a 09 09 09 09 7d |....brea|k;.....}|
|00002a30| 0a 09 09 09 65 6c 73 65 | 0a 09 09 09 09 75 73 61 |....else|.....usa|
|00002a40| 67 65 20 3d 20 31 3b 0a | 09 09 6f 6c 64 66 69 6c |ge = 1;.|..oldfil|
|00002a50| 65 20 3d 20 61 72 67 76 | 5b 32 5d 3b 0a 09 09 6e |e = argv|[2];...n|
|00002a60| 65 77 66 69 6c 65 20 3d | 20 61 72 67 76 5b 33 5d |ewfile =| argv[3]|
|00002a70| 3b 0a 09 09 7d 0a 09 65 | 6c 73 65 0a 09 09 75 73 |;...}..e|lse...us|
|00002a80| 61 67 65 20 3d 20 31 3b | 0a 0a 09 69 66 20 28 75 |age = 1;|...if (u|
|00002a90| 73 61 67 65 29 0a 09 09 | 7b 0a 09 09 66 70 72 69 |sage)...|{...fpri|
|00002aa0| 6e 74 66 20 28 73 74 64 | 65 72 72 2c 20 22 75 73 |ntf (std|err, "us|
|00002ab0| 61 67 65 3a 20 25 73 20 | 5b 2d 63 64 6d 76 77 5d |age: %s |[-cdmvw]|
|00002ac0| 20 6f 6c 64 66 69 6c 65 | 20 6e 65 77 66 69 6c 65 | oldfile| newfile|
|00002ad0| 5c 6e 22 2c 20 63 6d 64 | 29 3b 0a 09 09 65 78 69 |\n", cmd|);...exi|
|00002ae0| 74 20 28 31 29 3b 0a 09 | 09 7d 0a 0a 0a 09 2f 2a |t (1);..|.}..../*|
|00002af0| 20 6f 70 65 6e 20 62 6f | 74 68 20 66 69 6c 65 73 | open bo|th files|
|00002b00| 20 2a 2f 0a 09 6f 70 65 | 6e 66 69 6c 65 73 20 28 | */..ope|nfiles (|
|00002b10| 29 3b 0a 0a 09 69 6e 69 | 74 76 61 72 73 20 28 29 |);...ini|tvars ()|
|00002b20| 3b 0a 0a 09 73 72 63 5f | 63 6f 6d 70 61 72 65 20 |;...src_|compare |
|00002b30| 28 29 3b 0a 0a 09 2f 2a | 20 63 6c 6f 73 65 20 62 |();.../*| close b|
|00002b40| 6f 74 68 20 66 69 6c 65 | 73 20 2a 2f 0a 09 63 6c |oth file|s */..cl|
|00002b50| 6f 73 65 66 69 6c 65 73 | 20 28 29 3b 0a 0a 7d 0a |osefiles| ();..}.|
|00002b60| 0a 69 6e 69 74 76 61 72 | 73 20 28 29 0a 7b 0a 09 |.initvar|s ().{..|
|00002b70| 6e 75 6d 73 79 6d 62 6f | 6c 73 20 3d 20 30 3b 0a |numsymbo|ls = 0;.|
|00002b80| 7d 0a 0a 0a 0a 2f 2a 0a | 20 2a 20 63 6f 6d 70 61 |}..../*.| * compa|
|00002b90| 72 65 20 74 68 65 20 32 | 20 66 69 6c 65 73 20 69 |re the 2| files i|
|00002ba0| 6e 20 36 20 65 61 73 79 | 20 70 61 73 73 65 73 0a |n 6 easy| passes.|
|00002bb0| 20 2a 2f 0a 0a 73 72 63 | 5f 63 6f 6d 70 61 72 65 | */..src|_compare|
|00002bc0| 20 28 29 0a 7b 0a 09 70 | 61 73 73 31 20 28 29 3b | ().{..p|ass1 ();|
|00002bd0| 09 2f 2a 20 72 65 61 64 | 2c 20 73 74 6f 72 65 20 |./* read|, store |
|00002be0| 6e 65 77 20 66 69 6c 65 | 09 09 09 09 2a 2f 0a 09 |new file|....*/..|
|00002bf0| 70 61 73 73 32 20 28 29 | 3b 09 2f 2a 20 72 65 61 |pass2 ()|;./* rea|
|00002c00| 64 2c 20 73 74 6f 72 65 | 20 6f 6c 64 20 66 69 6c |d, store| old fil|
|00002c10| 65 09 09 09 09 2a 2f 0a | 09 70 61 73 73 33 20 28 |e....*/.|.pass3 (|
|00002c20| 29 3b 09 2f 2a 20 6d 61 | 74 63 68 20 75 70 20 6c |);./* ma|tch up l|
|00002c30| 69 6e 65 73 20 77 68 69 | 63 68 20 6f 63 63 75 72 |ines whi|ch occur|
|00002c40| 20 6f 6e 6c 79 20 6f 6e | 63 65 09 09 2a 2f 0a 09 | only on|ce..*/..|
|00002c50| 70 61 73 73 34 20 28 29 | 3b 09 2f 2a 20 61 70 70 |pass4 ()|;./* app|
|00002c60| 6c 79 20 72 75 6c 65 20 | 32 20 77 6f 72 6b 69 6e |ly rule |2 workin|
|00002c70| 67 20 74 6f 77 61 72 64 | 20 65 6e 64 09 09 2a 2f |g toward| end..*/|
|00002c80| 0a 09 70 61 73 73 35 20 | 28 29 3b 09 2f 2a 20 61 |..pass5 |();./* a|
|00002c90| 70 70 6c 79 20 72 75 6c | 65 20 32 20 77 6f 72 6b |pply rul|e 2 work|
|00002ca0| 69 6e 67 20 74 6f 77 61 | 72 64 20 62 65 67 69 6e |ing towa|rd begin|
|00002cb0| 6e 69 6e 67 09 2a 2f 0a | 2f 2a 09 70 61 73 73 35 |ning.*/.|/*.pass5|
|00002cc0| 61 20 28 29 3b 09 2f 2a | 20 63 6f 6e 76 65 72 74 |a ();./*| convert|
|00002cd0| 20 62 6c 6f 63 6b 2d 6d | 6f 76 65 73 20 74 6f 20 | block-m|oves to |
|00002ce0| 69 6e 73 65 72 74 2f 64 | 65 6c 65 74 65 73 09 2a |insert/d|eletes.*|
|00002cf0| 2f 0a 2f 2a 09 64 75 6d | 70 61 72 72 61 79 20 28 |/./*.dum|parray (|
|00002d00| 29 3b 09 2f 2a 20 73 65 | 65 20 69 66 20 69 6e 74 |);./* se|e if int|
|00002d10| 65 72 6e 61 6c 20 74 61 | 62 6c 65 73 20 61 72 65 |ernal ta|bles are|
|00002d20| 20 62 75 69 6c 74 20 63 | 6f 72 72 65 63 74 6c 79 | built c|orrectly|
|00002d30| 09 2a 2f 0a 09 70 61 73 | 73 36 20 28 29 3b 09 2f |.*/..pas|s6 ();./|
|00002d40| 2a 20 70 72 69 6e 74 20 | 6f 75 74 20 64 69 66 66 |* print |out diff|
|00002d50| 65 72 65 6e 63 65 73 09 | 09 09 2a 2f 0a 09 69 66 |erences.|..*/..if|
|00002d60| 20 28 64 65 62 75 67 29 | 0a 09 09 70 72 69 6e 74 | (debug)|...print|
|00002d70| 66 20 28 22 64 65 62 75 | 67 3a 20 73 79 6d 62 6f |f ("debu|g: symbo|
|00002d80| 6c 20 74 61 62 6c 65 3a | 20 6f 63 63 75 70 69 65 |l table:| occupie|
|00002d90| 64 20 3d 20 25 64 2c 20 | 74 6f 74 61 6c 20 3d 20 |d = %d, |total = |
|00002da0| 25 64 5c 6e 22 2c 0a 09 | 09 6e 75 6d 73 79 6d 62 |%d\n",..|.numsymb|
|00002db0| 6f 6c 73 2c 20 42 49 47 | 50 52 49 4d 45 29 3b 0a |ols, BIG|PRIME);.|
|00002dc0| 7d 0a 0a 2f 2a 0a 20 2a | 20 70 61 73 73 20 31 0a |}../*. *| pass 1.|
|00002dd0| 20 2a 20 72 65 61 64 20 | 69 6e 20 6e 65 77 20 66 | * read |in new f|
|00002de0| 69 6c 65 2e 0a 20 2a 2f | 0a 0a 70 61 73 73 31 20 |ile.. */|..pass1 |
|00002df0| 28 29 0a 7b 0a 09 69 6e | 74 0a 09 09 6c 69 6e 65 |().{..in|t...line|
|00002e00| 6e 75 6d 2c 09 2f 2a 20 | 77 68 69 63 68 20 6c 69 |num,./* |which li|
|00002e10| 6e 65 20 77 65 20 61 72 | 65 20 6f 6e 09 09 09 2a |ne we ar|e on...*|
|00002e20| 2f 0a 09 09 73 74 61 74 | 2c 09 09 2f 2a 20 72 65 |/...stat|,../* re|
|00002e30| 73 75 6c 74 20 66 72 6f | 6d 20 73 74 72 69 70 6e |sult fro|m stripn|
|00002e40| 6c 09 09 09 2a 2f 0a 09 | 09 73 69 6e 64 65 78 3b |l...*/..|.sindex;|
|00002e50| 09 09 2f 2a 20 69 6e 64 | 65 78 20 69 6e 74 6f 20 |../* ind|ex into |
|00002e60| 73 79 6d 62 6f 6c 20 74 | 61 62 6c 65 09 09 2a 2f |symbol t|able..*/|
|00002e70| 0a 09 63 68 61 72 09 2a | 63 70 3b 09 09 2f 2a 20 |..char.*|cp;../* |
|00002e80| 63 68 61 72 20 70 6f 69 | 6e 74 65 72 20 69 6e 74 |char poi|nter int|
|00002e90| 6f 20 6c 69 6e 65 09 09 | 2a 2f 0a 0a 0a 0a 09 2f |o line..|*/...../|
|00002ea0| 2a 20 72 65 61 64 20 65 | 61 63 68 20 6c 69 6e 65 |* read e|ach line|
|00002eb0| 20 6f 66 20 6e 65 77 20 | 66 69 6c 65 20 69 6e 20 | of new |file in |
|00002ec0| 61 20 6c 6f 6f 70 2e 09 | 09 2a 2f 0a 09 2f 2a 20 |a loop..|.*/../* |
|00002ed0| 73 74 6f 70 20 69 66 20 | 65 6f 66 20 6f 72 20 63 |stop if |eof or c|
|00002ee0| 61 6e 27 74 20 68 61 6e | 64 6c 65 20 74 68 61 74 |an't han|dle that|
|00002ef0| 20 6d 61 6e 79 20 6c 69 | 6e 65 73 09 09 2a 2f 0a | many li|nes..*/.|
|00002f00| 09 66 6f 72 20 28 6c 69 | 6e 65 6e 75 6d 20 3d 20 |.for (li|nenum = |
|00002f10| 30 3b 0a 09 09 66 67 65 | 74 73 20 28 6c 69 6e 65 |0;...fge|ts (line|
|00002f20| 62 75 66 2c 20 73 69 7a | 65 6f 66 28 6c 69 6e 65 |buf, siz|eof(line|
|00002f30| 62 75 66 29 2c 20 6e 65 | 77 66 70 29 20 21 3d 20 |buf), ne|wfp) != |
|00002f40| 28 63 68 61 72 20 2a 29 | 4e 55 4c 4c 20 26 26 0a |(char *)|NULL &&.|
|00002f50| 09 09 2b 2b 6c 69 6e 65 | 6e 75 6d 20 3c 3d 20 4d |..++line|num <= M|
|00002f60| 41 58 4c 49 4e 45 53 3b | 20 29 0a 09 09 7b 0a 0a |AXLINES;| )...{..|
|00002f70| 09 09 2f 2a 20 73 74 72 | 69 70 20 6e 65 77 6c 69 |../* str|ip newli|
|00002f80| 6e 65 20 61 74 20 65 6e | 64 20 61 6e 64 20 6d 61 |ne at en|d and ma|
|00002f90| 6b 65 20 73 75 72 65 20 | 6c 69 6e 65 20 77 61 73 |ke sure |line was|
|00002fa0| 6e 27 74 20 74 6f 6f 20 | 6c 6f 6e 67 20 2a 2f 0a |n't too |long */.|
|00002fb0| 09 09 73 74 61 74 20 3d | 20 73 74 72 69 70 6e 6c |..stat =| stripnl|
|00002fc0| 20 28 6c 69 6e 65 62 75 | 66 2c 20 73 69 7a 65 6f | (linebu|f, sizeo|
|00002fd0| 66 28 6c 69 6e 65 62 75 | 66 29 20 29 3b 0a 0a 09 |f(linebu|f) );...|
|00002fe0| 09 69 66 20 28 73 74 61 | 74 20 3d 3d 20 4c 5f 53 |.if (sta|t == L_S|
|00002ff0| 55 43 43 45 53 53 29 0a | 09 09 09 3b 0a 09 09 65 |UCCESS).|...;...e|
|00003000| 6c 73 65 20 69 66 20 28 | 73 74 61 74 20 3d 3d 20 |lse if (|stat == |
|00003010| 4c 5f 42 41 44 46 4f 52 | 4d 29 0a 09 09 09 66 70 |L_BADFOR|M)....fp|
|00003020| 72 69 6e 74 66 20 28 73 | 74 64 65 72 72 2c 20 22 |rintf (s|tderr, "|
|00003030| 25 73 3a 20 57 61 72 6e | 69 6e 67 2c 20 6c 69 6e |%s: Warn|ing, lin|
|00003040| 65 20 25 64 20 69 6e 20 | 66 69 6c 65 20 25 73 20 |e %d in |file %s |
|00003050| 6e 6f 74 20 74 65 72 6d | 69 6e 61 74 65 64 20 77 |not term|inated w|
|00003060| 69 74 68 20 6e 65 77 6c | 69 6e 65 5c 6e 22 2c 0a |ith newl|ine\n",.|
|00003070| 09 09 09 63 6d 64 2c 20 | 6c 69 6e 65 6e 75 6d 2c |...cmd, |linenum,|
|00003080| 20 6e 65 77 66 69 6c 65 | 29 3b 0a 09 09 65 6c 73 | newfile|);...els|
|00003090| 65 0a 09 09 09 7b 0a 09 | 09 09 66 70 72 69 6e 74 |e....{..|..fprint|
|000030a0| 66 20 28 73 74 64 65 72 | 72 2c 20 22 25 73 3a 20 |f (stder|r, "%s: |
|000030b0| 6c 69 6e 65 20 25 64 20 | 6c 6f 6e 67 65 72 20 74 |line %d |longer t|
|000030c0| 68 61 6e 20 25 64 20 63 | 68 61 72 73 20 69 6e 20 |han %d c|hars in |
|000030d0| 66 69 6c 65 20 25 73 5c | 6e 22 2c 0a 09 09 09 63 |file %s\|n",....c|
|000030e0| 6d 64 2c 20 6c 69 6e 65 | 6e 75 6d 2c 20 4c 49 4e |md, line|num, LIN|
|000030f0| 45 53 49 5a 45 2c 20 6e | 65 77 66 69 6c 65 29 3b |ESIZE, n|ewfile);|
|00003100| 0a 09 09 09 65 78 69 74 | 20 28 31 29 3b 0a 09 09 |....exit| (1);...|
|00003110| 09 7d 0a 0a 09 09 2f 2a | 20 69 66 20 63 6f 6d 70 |.}..../*| if comp|
|00003120| 72 65 73 73 69 6e 67 20 | 77 68 69 74 65 20 73 70 |ressing |white sp|
|00003130| 61 63 65 2c 20 74 68 65 | 6e 20 63 6f 6d 70 72 65 |ace, the|n compre|
|00003140| 73 73 20 69 6e 74 6f 20 | 6c 69 6e 65 20 62 75 66 |ss into |line buf|
|00003150| 20 2a 2f 0a 09 09 69 66 | 20 28 72 75 6e 66 6c 61 | */...if| (runfla|
|00003160| 67 20 5b 27 77 27 20 2d | 20 27 61 27 5d 20 29 0a |g ['w' -| 'a'] ).|
|00003170| 09 09 09 7b 0a 09 09 09 | 63 68 61 72 20 2a 63 70 |...{....|char *cp|
|00003180| 3b 0a 09 09 09 63 70 20 | 3d 20 72 65 6d 77 68 69 |;....cp |= remwhi|
|00003190| 74 65 20 28 6c 69 6e 65 | 62 75 66 2c 20 5a 41 50 |te (line|buf, ZAP|
|000031a0| 46 4c 41 47 29 3b 0a 09 | 09 09 73 74 72 63 70 79 |FLAG);..|..strcpy|
|000031b0| 20 28 6c 69 6e 65 62 75 | 66 2c 20 63 70 29 3b 0a | (linebu|f, cp);.|
|000031c0| 09 09 09 7d 0a 0a 09 09 | 73 69 6e 64 65 78 20 3d |...}....|sindex =|
|000031d0| 20 61 64 64 73 79 6d 62 | 6f 6c 20 28 6c 69 6e 65 | addsymb|ol (line|
|000031e0| 62 75 66 29 3b 09 2f 2a | 20 70 75 74 20 6c 69 6e |buf);./*| put lin|
|000031f0| 65 20 69 6e 74 6f 20 73 | 79 6d 62 6f 6c 20 74 62 |e into s|ymbol tb|
|00003200| 6c 20 2a 2f 0a 09 09 69 | 66 20 28 73 79 6d 74 62 |l */...i|f (symtb|
|00003210| 6c 20 5b 73 69 6e 64 65 | 78 5d 2e 6e 63 6f 75 6e |l [sinde|x].ncoun|
|00003220| 74 20 3c 20 32 29 0a 09 | 09 09 2b 2b 73 79 6d 74 |t < 2)..|..++symt|
|00003230| 62 6c 20 5b 73 69 6e 64 | 65 78 5d 2e 6e 63 6f 75 |bl [sind|ex].ncou|
|00003240| 6e 74 3b 0a 09 09 6e 61 | 20 5b 6c 69 6e 65 6e 75 |nt;...na| [linenu|
|00003250| 6d 5d 2e 6c 69 6e 65 6c | 6f 63 20 3d 20 73 69 6e |m].linel|oc = sin|
|00003260| 64 65 78 3b 0a 09 09 6e | 61 20 5b 6c 69 6e 65 6e |dex;...n|a [linen|
|00003270| 75 6d 5d 2e 66 6c 61 67 | 20 3d 20 4c 5f 53 59 4d |um].flag| = L_SYM|
|00003280| 49 4e 44 58 3b 0a 09 09 | 7d 0a 0a 09 2f 2a 20 73 |INDX;...|}.../* s|
|00003290| 65 65 20 69 66 20 6e 65 | 77 20 66 69 6c 65 20 77 |ee if ne|w file w|
|000032a0| 61 73 20 65 6d 70 74 79 | 20 2a 2f 0a 09 69 66 20 |as empty| */..if |
|000032b0| 28 6c 69 6e 65 6e 75 6d | 20 3d 3d 20 30 29 0a 09 |(linenum| == 0)..|
|000032c0| 09 7b 0a 09 09 66 70 72 | 69 6e 74 66 20 28 73 74 |.{...fpr|intf (st|
|000032d0| 64 65 72 72 2c 20 22 25 | 73 3a 20 20 4e 65 77 20 |derr, "%|s: New |
|000032e0| 66 69 6c 65 20 25 73 20 | 69 73 20 65 6d 70 74 79 |file %s |is empty|
|000032f0| 2e 20 20 44 69 66 66 20 | 69 73 20 64 65 6c 65 74 |. Diff |is delet|
|00003300| 65 20 65 6e 74 69 72 65 | 20 6f 6c 64 20 66 69 6c |e entire| old fil|
|00003310| 65 2e 5c 6e 22 2c 20 6e | 65 77 66 69 6c 65 2c 20 |e.\n", n|ewfile, |
|00003320| 63 6d 64 29 3b 0a 09 09 | 65 78 69 74 20 28 31 29 |cmd);...|exit (1)|
|00003330| 3b 0a 09 09 7d 0a 0a 09 | 69 66 20 28 6c 69 6e 65 |;...}...|if (line|
|00003340| 6e 75 6d 20 3e 20 4d 41 | 58 4c 49 4e 45 53 29 0a |num > MA|XLINES).|
|00003350| 09 09 7b 0a 09 09 66 70 | 72 69 6e 74 66 20 28 73 |..{...fp|rintf (s|
|00003360| 74 64 65 72 72 2c 20 22 | 25 73 3a 20 20 4e 65 77 |tderr, "|%s: New|
|00003370| 20 66 69 6c 65 20 25 73 | 20 69 73 20 74 6f 6f 20 | file %s| is too |
|00003380| 62 69 67 2e 20 20 4c 61 | 73 74 20 6c 69 6e 65 20 |big. La|st line |
|00003390| 72 65 61 64 20 77 61 73 | 20 25 64 2e 5c 6e 22 2c |read was| %d.\n",|
|000033a0| 20 63 6d 64 2c 20 6e 65 | 77 66 69 6c 65 2c 20 4d | cmd, ne|wfile, M|
|000033b0| 41 58 4c 49 4e 45 53 29 | 3b 0a 09 09 65 78 69 74 |AXLINES)|;...exit|
|000033c0| 20 28 31 29 3b 0a 09 09 | 7d 0a 0a 09 2f 2a 20 61 | (1);...|}.../* a|
|000033d0| 73 73 69 67 6e 20 67 6c | 6f 62 61 6c 20 6e 75 6d |ssign gl|obal num|
|000033e0| 62 65 72 20 6f 66 20 6e | 65 77 20 6c 69 6e 65 73 |ber of n|ew lines|
|000033f0| 20 2a 2f 0a 09 6c 61 73 | 74 6e 65 77 20 3d 20 6c | */..las|tnew = l|
|00003400| 69 6e 65 6e 75 6d 3b 0a | 7d 0a 0a 0a 2f 2a 0a 20 |inenum;.|}.../*. |
|00003410| 2a 20 70 61 73 73 20 32 | 0a 20 2a 20 72 65 61 64 |* pass 2|. * read|
|00003420| 20 69 6e 20 6f 6c 64 20 | 66 69 6c 65 2e 0a 20 2a | in old |file.. *|
|00003430| 2f 0a 0a 70 61 73 73 32 | 20 28 29 0a 7b 0a 09 69 |/..pass2| ().{..i|
|00003440| 6e 74 0a 09 09 6c 69 6e | 65 6e 75 6d 2c 09 2f 2a |nt...lin|enum,./*|
|00003450| 20 77 68 69 63 68 20 6c | 69 6e 65 6e 75 6d 20 77 | which l|inenum w|
|00003460| 65 20 61 72 65 20 6f 6e | 09 09 2a 2f 0a 09 09 73 |e are on|..*/...s|
|00003470| 74 61 74 2c 09 09 2f 2a | 20 72 65 73 75 6c 74 20 |tat,../*| result |
|00003480| 66 72 6f 6d 20 73 74 72 | 69 70 6e 6c 09 09 09 2a |from str|ipnl...*|
|00003490| 2f 0a 09 09 73 69 6e 64 | 65 78 3b 09 09 2f 2a 20 |/...sind|ex;../* |
|000034a0| 69 6e 64 65 78 20 69 6e | 74 6f 20 73 79 6d 62 6f |index in|to symbo|
|000034b0| 6c 20 74 61 62 6c 65 09 | 09 2a 2f 0a 09 63 68 61 |l table.|.*/..cha|
|000034c0| 72 09 2a 63 70 3b 09 09 | 2f 2a 20 63 68 61 72 20 |r.*cp;..|/* char |
|000034d0| 70 6f 69 6e 74 65 72 20 | 69 6e 74 6f 20 6c 69 6e |pointer |into lin|
|000034e0| 65 09 09 2a 2f 0a 0a 0a | 0a 09 2f 2a 20 72 65 61 |e..*/...|../* rea|
|000034f0| 64 20 65 61 63 68 20 6c | 69 6e 65 20 6f 66 20 6f |d each l|ine of o|
|00003500| 6c 64 20 66 69 6c 65 20 | 69 6e 20 61 20 6c 6f 6f |ld file |in a loo|
|00003510| 70 2e 09 09 2a 2f 0a 09 | 2f 2a 20 73 74 6f 70 20 |p...*/..|/* stop |
|00003520| 69 66 20 65 6f 66 20 6f | 72 20 63 61 6e 27 74 20 |if eof o|r can't |
|00003530| 68 61 6e 64 6c 65 20 74 | 68 61 74 20 6d 61 6e 79 |handle t|hat many|
|00003540| 20 6c 69 6e 65 73 09 09 | 2a 2f 0a 09 66 6f 72 20 | lines..|*/..for |
|00003550| 28 6c 69 6e 65 6e 75 6d | 20 3d 20 30 3b 0a 09 09 |(linenum| = 0;...|
|00003560| 66 67 65 74 73 20 28 6c | 69 6e 65 62 75 66 2c 20 |fgets (l|inebuf, |
|00003570| 73 69 7a 65 6f 66 28 6c | 69 6e 65 62 75 66 29 2c |sizeof(l|inebuf),|
|00003580| 20 6f 6c 64 66 70 29 20 | 21 3d 20 28 63 68 61 72 | oldfp) |!= (char|
|00003590| 20 2a 29 4e 55 4c 4c 20 | 26 26 0a 09 09 2b 2b 6c | *)NULL |&&...++l|
|000035a0| 69 6e 65 6e 75 6d 20 3c | 3d 20 4d 41 58 4c 49 4e |inenum <|= MAXLIN|
|000035b0| 45 53 3b 20 29 0a 09 09 | 7b 0a 0a 23 69 66 20 30 |ES; )...|{..#if 0|
|000035c0| 09 09 2f 2a 20 6f 6c 64 | 20 77 61 79 20 2a 2f 0a |../* old| way */.|
|000035d0| 09 09 2f 2a 20 73 74 72 | 69 70 20 6e 65 77 6c 69 |../* str|ip newli|
|000035e0| 6e 65 20 61 74 20 65 6e | 64 20 61 6e 64 20 6d 61 |ne at en|d and ma|
|000035f0| 6b 65 20 73 75 72 65 20 | 6c 69 6e 65 20 77 61 73 |ke sure |line was|
|00003600| 6e 27 74 20 74 6f 6f 20 | 6c 6f 6e 67 20 2a 2f 0a |n't too |long */.|
|00003610| 09 09 63 70 20 3d 20 26 | 6c 69 6e 65 62 75 66 5b |..cp = &|linebuf[|
|00003620| 73 74 72 6c 65 6e 28 6c | 69 6e 65 62 75 66 29 2d |strlen(l|inebuf)-|
|00003630| 31 5d 3b 0a 09 09 69 66 | 20 28 2a 63 70 20 3d 3d |1];...if| (*cp ==|
|00003640| 20 27 5c 6e 27 29 0a 09 | 09 09 2a 63 70 20 3d 20 | '\n')..|..*cp = |
|00003650| 27 5c 30 27 3b 0a 09 09 | 65 6c 73 65 20 69 66 20 |'\0';...|else if |
|00003660| 28 73 74 72 6c 65 6e 28 | 6c 69 6e 65 62 75 66 29 |(strlen(|linebuf)|
|00003670| 20 3c 20 73 69 7a 65 6f | 66 28 6c 69 6e 65 62 75 | < sizeo|f(linebu|
|00003680| 66 29 2d 31 29 0a 09 09 | 09 66 70 72 69 6e 74 66 |f)-1)...|.fprintf|
|00003690| 20 28 73 74 64 65 72 72 | 2c 20 22 25 73 3a 20 57 | (stderr|, "%s: W|
|000036a0| 61 72 6e 69 6e 67 2c 20 | 6c 69 6e 65 20 25 64 20 |arning, |line %d |
|000036b0| 69 6e 20 66 69 6c 65 20 | 25 73 20 6e 6f 74 20 74 |in file |%s not t|
|000036c0| 65 72 6d 69 6e 61 74 65 | 64 20 77 69 74 68 20 6e |erminate|d with n|
|000036d0| 65 77 6c 69 6e 65 5c 6e | 22 2c 20 63 6d 64 2c 20 |ewline\n|", cmd, |
|000036e0| 6c 69 6e 65 6e 75 6d 2c | 20 6f 6c 64 66 69 6c 65 |linenum,| oldfile|
|000036f0| 29 3b 0a 09 09 65 6c 73 | 65 0a 09 09 09 7b 0a 09 |);...els|e....{..|
|00003700| 09 09 66 70 72 69 6e 74 | 66 20 28 73 74 64 65 72 |..fprint|f (stder|
|00003710| 72 2c 20 22 25 73 3a 20 | 6c 69 6e 65 20 25 64 20 |r, "%s: |line %d |
|00003720| 6c 6f 6e 67 65 72 20 74 | 68 61 6e 20 25 64 20 63 |longer t|han %d c|
|00003730| 68 61 72 73 20 69 6e 20 | 66 69 6c 65 20 25 73 5c |hars in |file %s\|
|00003740| 6e 22 2c 0a 09 09 09 09 | 63 6d 64 2c 20 6c 69 6e |n",.....|cmd, lin|
|00003750| 65 6e 75 6d 2c 20 4c 49 | 4e 45 53 49 5a 45 2c 20 |enum, LI|NESIZE, |
|00003760| 6f 6c 64 66 69 6c 65 29 | 3b 0a 09 09 09 65 78 69 |oldfile)|;....exi|
|00003770| 74 20 28 31 29 3b 0a 09 | 09 09 7d 0a 23 65 6e 64 |t (1);..|..}.#end|
|00003780| 69 66 0a 0a 09 09 2f 2a | 20 73 74 72 69 70 20 6e |if..../*| strip n|
|00003790| 65 77 6c 69 6e 65 20 61 | 74 20 65 6e 64 20 61 6e |ewline a|t end an|
|000037a0| 64 20 6d 61 6b 65 20 73 | 75 72 65 20 6c 69 6e 65 |d make s|ure line|
|000037b0| 20 77 61 73 6e 27 74 20 | 74 6f 6f 20 6c 6f 6e 67 | wasn't |too long|
|000037c0| 20 2a 2f 0a 09 09 73 74 | 61 74 20 3d 20 73 74 72 | */...st|at = str|
|000037d0| 69 70 6e 6c 20 28 6c 69 | 6e 65 62 75 66 2c 20 73 |ipnl (li|nebuf, s|
|000037e0| 69 7a 65 6f 66 28 6c 69 | 6e 65 62 75 66 29 20 29 |izeof(li|nebuf) )|
|000037f0| 3b 0a 0a 09 09 69 66 20 | 28 73 74 61 74 20 3d 3d |;....if |(stat ==|
|00003800| 20 4c 5f 53 55 43 43 45 | 53 53 29 0a 09 09 09 3b | L_SUCCE|SS)....;|
|00003810| 0a 09 09 65 6c 73 65 20 | 69 66 20 28 73 74 61 74 |...else |if (stat|
|00003820| 20 3d 3d 20 4c 5f 42 41 | 44 46 4f 52 4d 29 0a 09 | == L_BA|DFORM)..|
|00003830| 09 09 66 70 72 69 6e 74 | 66 20 28 73 74 64 65 72 |..fprint|f (stder|
|00003840| 72 2c 20 22 25 73 3a 20 | 57 61 72 6e 69 6e 67 2c |r, "%s: |Warning,|
|00003850| 20 6c 69 6e 65 20 25 64 | 20 69 6e 20 66 69 6c 65 | line %d| in file|
|00003860| 20 25 73 20 6e 6f 74 20 | 74 65 72 6d 69 6e 61 74 | %s not |terminat|
|00003870| 65 64 20 77 69 74 68 20 | 6e 65 77 6c 69 6e 65 5c |ed with |newline\|
|00003880| 6e 22 2c 0a 09 09 09 63 | 6d 64 2c 20 6c 69 6e 65 |n",....c|md, line|
|00003890| 6e 75 6d 2c 20 6f 6c 64 | 66 69 6c 65 29 3b 0a 09 |num, old|file);..|
|000038a0| 09 65 6c 73 65 0a 09 09 | 09 7b 0a 09 09 09 66 70 |.else...|.{....fp|
|000038b0| 72 69 6e 74 66 20 28 73 | 74 64 65 72 72 2c 20 22 |rintf (s|tderr, "|
|000038c0| 25 73 3a 20 6c 69 6e 65 | 20 25 64 20 6c 6f 6e 67 |%s: line| %d long|
|000038d0| 65 72 20 74 68 61 6e 20 | 25 64 20 63 68 61 72 73 |er than |%d chars|
|000038e0| 20 69 6e 20 66 69 6c 65 | 20 25 73 5c 6e 22 2c 0a | in file| %s\n",.|
|000038f0| 09 09 09 63 6d 64 2c 20 | 6c 69 6e 65 6e 75 6d 2c |...cmd, |linenum,|
|00003900| 20 4c 49 4e 45 53 49 5a | 45 2c 20 6f 6c 64 66 69 | LINESIZ|E, oldfi|
|00003910| 6c 65 29 3b 0a 09 09 09 | 65 78 69 74 20 28 31 29 |le);....|exit (1)|
|00003920| 3b 0a 09 09 09 7d 0a 0a | 0a 09 09 2f 2a 20 69 66 |;....}..|.../* if|
|00003930| 20 63 6f 6d 70 72 65 73 | 73 69 6e 67 20 77 68 69 | compres|sing whi|
|00003940| 74 65 20 73 70 61 63 65 | 2c 20 74 68 65 6e 20 63 |te space|, then c|
|00003950| 6f 6d 70 72 65 73 73 20 | 69 6e 74 6f 20 6c 69 6e |ompress |into lin|
|00003960| 65 20 62 75 66 20 2a 2f | 0a 09 09 69 66 20 28 72 |e buf */|...if (r|
|00003970| 75 6e 66 6c 61 67 20 5b | 27 77 27 20 2d 20 27 61 |unflag [|'w' - 'a|
|00003980| 27 5d 20 29 0a 09 09 09 | 7b 0a 09 09 09 63 68 61 |'] )....|{....cha|
|00003990| 72 20 2a 63 70 3b 0a 09 | 09 09 63 70 20 3d 20 72 |r *cp;..|..cp = r|
|000039a0| 65 6d 77 68 69 74 65 20 | 28 6c 69 6e 65 62 75 66 |emwhite |(linebuf|
|000039b0| 2c 20 5a 41 50 46 4c 41 | 47 29 3b 0a 09 09 09 73 |, ZAPFLA|G);....s|
|000039c0| 74 72 63 70 79 20 28 6c | 69 6e 65 62 75 66 2c 20 |trcpy (l|inebuf, |
|000039d0| 63 70 29 3b 0a 09 09 09 | 7d 0a 0a 09 09 73 69 6e |cp);....|}....sin|
|000039e0| 64 65 78 20 3d 20 61 64 | 64 73 79 6d 62 6f 6c 20 |dex = ad|dsymbol |
|000039f0| 28 6c 69 6e 65 62 75 66 | 29 3b 09 2f 2a 20 70 75 |(linebuf|);./* pu|
|00003a00| 74 20 6c 69 6e 65 20 69 | 6e 74 6f 20 73 79 6d 62 |t line i|nto symb|
|00003a10| 6f 6c 20 74 62 6c 20 2a | 2f 0a 09 09 69 66 20 28 |ol tbl *|/...if (|
|00003a20| 73 79 6d 74 62 6c 20 5b | 73 69 6e 64 65 78 5d 2e |symtbl [|sindex].|
|00003a30| 6f 63 6f 75 6e 74 20 3c | 20 32 29 0a 09 09 09 2b |ocount <| 2)....+|
|00003a40| 2b 73 79 6d 74 62 6c 20 | 5b 73 69 6e 64 65 78 5d |+symtbl |[sindex]|
|00003a50| 2e 6f 63 6f 75 6e 74 3b | 0a 09 09 73 79 6d 74 62 |.ocount;|...symtb|
|00003a60| 6c 5b 73 69 6e 64 65 78 | 5d 2e 6f 6c 69 6e 65 6e |l[sindex|].olinen|
|00003a70| 75 6d 20 3d 20 6c 69 6e | 65 6e 75 6d 3b 0a 09 09 |um = lin|enum;...|
|00003a80| 6f 61 20 5b 6c 69 6e 65 | 6e 75 6d 5d 2e 6c 69 6e |oa [line|num].lin|
|00003a90| 65 6c 6f 63 20 3d 20 73 | 69 6e 64 65 78 3b 0a 09 |eloc = s|index;..|
|00003aa0| 09 6f 61 20 5b 6c 69 6e | 65 6e 75 6d 5d 2e 66 6c |.oa [lin|enum].fl|
|00003ab0| 61 67 20 3d 20 4c 5f 53 | 59 4d 49 4e 44 58 3b 0a |ag = L_S|YMINDX;.|
|00003ac0| 09 09 7d 0a 0a 09 2f 2a | 20 73 65 65 20 69 66 20 |..}.../*| see if |
|00003ad0| 6f 6c 64 20 66 69 6c 65 | 20 77 61 73 20 65 6d 70 |old file| was emp|
|00003ae0| 74 79 20 2a 2f 0a 09 69 | 66 20 28 6c 69 6e 65 6e |ty */..i|f (linen|
|00003af0| 75 6d 20 3d 3d 20 30 29 | 0a 09 09 7b 0a 09 09 66 |um == 0)|...{...f|
|00003b00| 70 72 69 6e 74 66 20 28 | 73 74 64 65 72 72 2c 20 |printf (|stderr, |
|00003b10| 22 25 73 3a 20 20 4f 6c | 64 20 66 69 6c 65 20 25 |"%s: Ol|d file %|
|00003b20| 73 20 69 73 20 65 6d 70 | 74 79 2e 20 20 44 69 66 |s is emp|ty. Dif|
|00003b30| 66 20 69 73 20 61 64 64 | 20 65 6e 74 69 72 65 20 |f is add| entire |
|00003b40| 6e 65 77 20 66 69 6c 65 | 2e 5c 6e 22 2c 20 6f 6c |new file|.\n", ol|
|00003b50| 64 66 69 6c 65 2c 20 63 | 6d 64 29 3b 0a 09 09 65 |dfile, c|md);...e|
|00003b60| 78 69 74 20 28 31 29 3b | 0a 09 09 7d 0a 0a 09 69 |xit (1);|...}...i|
|00003b70| 66 20 28 6c 69 6e 65 6e | 75 6d 20 3e 20 4d 41 58 |f (linen|um > MAX|
|00003b80| 4c 49 4e 45 53 29 0a 09 | 09 7b 0a 09 09 66 70 72 |LINES)..|.{...fpr|
|00003b90| 69 6e 74 66 20 28 73 74 | 64 65 72 72 2c 20 22 25 |intf (st|derr, "%|
|00003ba0| 73 3a 20 20 4f 6c 64 20 | 66 69 6c 65 20 25 73 20 |s: Old |file %s |
|00003bb0| 69 73 20 74 6f 6f 20 62 | 69 67 2e 20 20 4c 61 73 |is too b|ig. Las|
|00003bc0| 74 20 6c 69 6e 65 20 72 | 65 61 64 20 77 61 73 20 |t line r|ead was |
|00003bd0| 25 64 2e 5c 6e 22 2c 20 | 63 6d 64 2c 20 6f 6c 64 |%d.\n", |cmd, old|
|00003be0| 66 69 6c 65 2c 20 4d 41 | 58 4c 49 4e 45 53 29 3b |file, MA|XLINES);|
|00003bf0| 0a 09 09 65 78 69 74 20 | 28 31 29 3b 0a 09 09 7d |...exit |(1);...}|
|00003c00| 0a 0a 09 2f 2a 20 61 73 | 73 69 67 6e 20 6e 75 6d |.../* as|sign num|
|00003c10| 62 65 72 20 6f 66 20 6c | 69 6e 65 73 20 69 6e 20 |ber of l|ines in |
|00003c20| 6f 6c 64 20 66 69 6c 65 | 20 2a 2f 0a 09 6c 61 73 |old file| */..las|
|00003c30| 74 6f 6c 64 20 3d 20 6c | 69 6e 65 6e 75 6d 3b 0a |told = l|inenum;.|
|00003c40| 7d 0a 0a 0a 2f 2a 0a 20 | 2a 20 41 64 64 20 61 20 |}.../*. |* Add a |
|00003c50| 6c 69 6e 65 20 74 6f 20 | 74 68 65 20 73 79 6d 62 |line to |the symb|
|00003c60| 6f 6c 20 74 61 62 6c 65 | 2e 0a 20 2a 20 54 68 65 |ol table|.. * The|
|00003c70| 20 68 61 73 68 20 66 75 | 6e 63 74 69 6f 6e 20 64 | hash fu|nction d|
|00003c80| 65 74 65 72 6d 69 6e 65 | 73 20 74 68 65 20 69 6e |etermine|s the in|
|00003c90| 69 74 69 61 6c 20 70 72 | 6f 62 65 20 69 6e 74 6f |itial pr|obe into|
|00003ca0| 20 74 68 65 20 73 79 6d | 62 6f 6c 20 74 61 62 6c | the sym|bol tabl|
|00003cb0| 65 2e 0a 20 2a 20 49 66 | 20 74 68 65 20 6c 69 6e |e.. * If| the lin|
|00003cc0| 65 20 69 73 20 6e 65 77 | 2c 20 74 68 65 6e 20 63 |e is new|, then c|
|00003cd0| 6f 72 65 20 69 73 20 6d | 61 6c 6c 6f 63 27 65 64 |ore is m|alloc'ed|
|00003ce0| 20 66 6f 72 20 73 74 6f | 72 61 67 65 2c 20 61 6e | for sto|rage, an|
|00003cf0| 64 0a 20 2a 20 74 68 65 | 20 27 76 61 6c 75 65 27 |d. * the| 'value'|
|00003d00| 20 69 73 20 74 68 65 20 | 70 6f 69 6e 74 65 72 20 | is the |pointer |
|00003d10| 74 6f 20 74 68 65 20 6c | 69 6e 65 20 28 65 6d 70 |to the l|ine (emp|
|00003d20| 74 79 20 73 6c 6f 74 20 | 63 61 6e 20 62 65 20 66 |ty slot |can be f|
|00003d30| 6f 75 6e 64 29 2e 0a 20 | 2a 20 49 66 20 74 68 65 |ound).. |* If the|
|00003d40| 20 6c 69 6e 65 20 69 73 | 20 6f 6c 64 2c 20 74 68 | line is| old, th|
|00003d50| 65 20 6f 6c 64 20 69 6e | 64 65 78 20 69 73 20 72 |e old in|dex is r|
|00003d60| 65 74 75 72 6e 65 64 2e | 0a 20 2a 0a 20 2a 20 72 |eturned.|. *. * r|
|00003d70| 65 74 75 72 6e 73 0a 20 | 2a 09 69 6e 64 65 78 20 |eturns. |*.index |
|00003d80| 69 6e 74 6f 20 73 79 6d | 62 6f 6c 20 74 61 62 6c |into sym|bol tabl|
|00003d90| 65 0a 20 2a 09 75 70 64 | 61 74 65 64 20 67 6c 6f |e. *.upd|ated glo|
|00003da0| 62 61 6c 20 27 6e 75 6d | 73 79 6d 62 6f 6c 73 27 |bal 'num|symbols'|
|00003db0| 20 66 6f 72 20 64 65 62 | 75 67 67 69 6e 67 2e 0a | for deb|ugging..|
|00003dc0| 20 2a 0a 20 2a 2f 0a 61 | 64 64 73 79 6d 62 6f 6c | *. */.a|ddsymbol|
|00003dd0| 20 28 6c 69 6e 65 29 0a | 09 63 68 61 72 20 2a 6c | (line).|.char *l|
|00003de0| 69 6e 65 3b 0a 7b 0a 09 | 69 6e 74 09 73 69 6e 64 |ine;.{..|int.sind|
|00003df0| 65 78 2c 09 09 2f 2a 20 | 73 79 6d 62 6f 6c 20 74 |ex,../* |symbol t|
|00003e00| 61 62 6c 65 20 69 6e 64 | 65 78 09 09 09 2a 2f 0a |able ind|ex...*/.|
|00003e10| 09 09 66 69 72 73 74 70 | 72 6f 62 65 3b 09 2f 2a |..firstp|robe;./*|
|00003e20| 20 69 6e 64 65 78 20 6f | 66 20 66 69 72 73 74 20 | index o|f first |
|00003e30| 70 72 6f 62 65 20 69 6e | 74 6f 20 73 79 6d 62 6f |probe in|to symbo|
|00003e40| 6c 20 74 62 6c 09 2a 2f | 0a 09 63 68 61 72 09 2a |l tbl.*/|..char.*|
|00003e50| 63 70 3b 09 09 2f 2a 20 | 6d 61 6c 6c 6f 63 20 63 |cp;../* |malloc c|
|00003e60| 68 61 72 20 70 6f 69 6e | 74 65 72 09 09 09 2a 2f |har poin|ter...*/|
|00003e70| 0a 0a 09 73 69 6e 64 65 | 78 20 3d 20 66 69 72 73 |...sinde|x = firs|
|00003e80| 74 70 72 6f 62 65 20 3d | 20 68 61 73 68 6c 69 6e |tprobe =| hashlin|
|00003e90| 65 20 28 6c 69 6e 65 2c | 20 42 49 47 50 52 49 4d |e (line,| BIGPRIM|
|00003ea0| 45 29 3b 0a 0a 09 2f 2a | 20 6b 65 65 70 20 6c 6f |E);.../*| keep lo|
|00003eb0| 6f 70 69 6e 67 20 75 6e | 74 69 6c 20 65 6d 70 74 |oping un|til empt|
|00003ec0| 79 20 73 6c 6f 74 20 66 | 6f 75 6e 64 20 6f 72 20 |y slot f|ound or |
|00003ed0| 74 61 62 6c 65 20 69 73 | 20 66 75 6c 6c 2e 09 2a |table is| full..*|
|00003ee0| 2f 0a 09 2f 2a 20 74 61 | 62 6c 65 20 63 61 6e 6e |/../* ta|ble cann|
|00003ef0| 6f 74 20 62 65 20 66 75 | 6c 6c 2e 09 09 09 09 09 |ot be fu|ll......|
|00003f00| 2a 2f 0a 09 77 68 69 6c | 65 20 28 31 29 0a 09 09 |*/..whil|e (1)...|
|00003f10| 7b 0a 09 09 2f 2a 20 69 | 66 20 66 69 6e 64 20 61 |{.../* i|f find a|
|00003f20| 6e 20 65 6d 70 74 79 20 | 73 6c 6f 74 2c 20 61 64 |n empty |slot, ad|
|00003f30| 64 20 74 68 65 20 6c 69 | 6e 65 20 74 68 65 72 65 |d the li|ne there|
|00003f40| 2e 09 09 2a 2f 0a 09 09 | 69 66 20 28 73 79 6d 74 |...*/...|if (symt|
|00003f50| 62 6c 20 5b 73 69 6e 64 | 65 78 5d 2e 73 74 61 73 |bl [sind|ex].stas|
|00003f60| 68 6c 69 6e 65 20 3d 3d | 20 28 63 68 61 72 20 2a |hline ==| (char *|
|00003f70| 29 4e 55 4c 4c 29 0a 09 | 09 09 7b 0a 09 09 09 63 |)NULL)..|..{....c|
|00003f80| 70 20 3d 20 6d 61 6c 6c | 6f 63 20 28 73 74 72 6c |p = mall|oc (strl|
|00003f90| 65 6e 20 28 6c 69 6e 65 | 62 75 66 29 20 2b 20 31 |en (line|buf) + 1|
|00003fa0| 29 3b 0a 09 09 09 69 66 | 20 28 63 70 20 3d 3d 20 |);....if| (cp == |
|00003fb0| 28 63 68 61 72 20 2a 29 | 4e 55 4c 4c 29 0a 09 09 |(char *)|NULL)...|
|00003fc0| 09 09 7b 0a 09 09 09 09 | 66 70 72 69 6e 74 66 20 |..{.....|fprintf |
|00003fd0| 28 73 74 64 65 72 72 2c | 20 22 25 73 3a 20 6f 75 |(stderr,| "%s: ou|
|00003fe0| 74 20 6f 66 20 73 70 61 | 63 65 20 69 6e 20 66 75 |t of spa|ce in fu|
|00003ff0| 6e 63 74 69 6f 6e 20 61 | 64 64 73 79 6d 62 6f 6c |nction a|ddsymbol|
|00004000| 5c 6e 22 2c 20 63 6d 64 | 29 3b 0a 09 09 09 09 65 |\n", cmd|);.....e|
|00004010| 78 69 74 20 28 31 29 3b | 0a 09 09 09 09 7d 0a 0a |xit (1);|.....}..|
|00004020| 09 09 09 2f 2a 20 63 6f | 70 79 20 74 68 65 20 6c |.../* co|py the l|
|00004030| 69 6e 65 20 74 6f 20 73 | 74 6f 72 61 67 65 20 61 |ine to s|torage a|
|00004040| 72 65 61 09 09 2a 2f 0a | 09 09 09 73 74 72 63 70 |rea..*/.|...strcp|
|00004050| 79 20 28 63 70 2c 20 6c | 69 6e 65 29 3b 0a 0a 09 |y (cp, l|ine);...|
|00004060| 09 09 2f 2a 20 73 61 76 | 65 20 74 68 65 20 6c 69 |../* sav|e the li|
|00004070| 6e 65 20 69 6e 20 74 68 | 65 20 73 79 6d 62 6f 6c |ne in th|e symbol|
|00004080| 20 74 61 62 6c 65 20 65 | 6e 74 72 79 09 2a 2f 0a | table e|ntry.*/.|
|00004090| 09 09 09 73 79 6d 74 62 | 6c 20 5b 73 69 6e 64 65 |...symtb|l [sinde|
|000040a0| 78 5d 2e 73 74 61 73 68 | 6c 69 6e 65 20 3d 20 63 |x].stash|line = c|
|000040b0| 70 3b 0a 0a 09 09 09 2b | 2b 6e 75 6d 73 79 6d 62 |p;.....+|+numsymb|
|000040c0| 6f 6c 73 3b 0a 0a 09 09 | 09 62 72 65 61 6b 3b 0a |ols;....|.break;.|
|000040d0| 09 09 09 7d 0a 0a 09 09 | 2f 2a 20 69 66 20 74 68 |...}....|/* if th|
|000040e0| 65 20 6c 69 6e 65 20 69 | 73 20 61 6c 72 65 61 64 |e line i|s alread|
|000040f0| 79 20 69 6e 20 74 68 65 | 20 74 61 62 6c 65 2c 20 |y in the| table, |
|00004100| 74 68 65 6e 20 64 6f 6e | 65 20 2a 2f 0a 09 09 65 |then don|e */...e|
|00004110| 6c 73 65 20 69 66 20 28 | 73 74 72 63 6d 70 20 28 |lse if (|strcmp (|
|00004120| 73 79 6d 74 62 6c 20 5b | 73 69 6e 64 65 78 5d 2e |symtbl [|sindex].|
|00004130| 73 74 61 73 68 6c 69 6e | 65 2c 20 6c 69 6e 65 29 |stashlin|e, line)|
|00004140| 20 3d 3d 20 30 29 0a 09 | 09 09 62 72 65 61 6b 3b | == 0)..|..break;|
|00004150| 0a 0a 09 09 2f 2a 20 65 | 6c 73 65 20 69 74 27 73 |..../* e|lse it's|
|00004160| 20 61 20 63 6f 6c 6c 69 | 73 69 6f 6e 20 77 69 74 | a colli|sion wit|
|00004170| 68 20 61 20 64 69 66 66 | 65 72 65 6e 74 20 6c 69 |h a diff|erent li|
|00004180| 6e 65 2c 20 73 6f 0a 09 | 09 20 2a 20 6c 65 74 27 |ne, so..|. * let'|
|00004190| 73 20 64 6f 20 6c 69 6e | 65 61 72 20 6f 70 65 6e |s do lin|ear open|
|000041a0| 20 61 64 64 72 65 73 73 | 69 6e 67 2e 20 20 54 68 | address|ing. Th|
|000041b0| 61 74 20 69 73 2c 20 72 | 65 70 72 6f 62 65 0a 09 |at is, r|eprobe..|
|000041c0| 09 20 2a 20 53 4b 49 50 | 43 4f 55 4e 54 20 73 6c |. * SKIP|COUNT sl|
|000041d0| 6f 74 73 20 62 65 6c 6f | 77 2c 20 6d 6f 64 75 6c |ots belo|w, modul|
|000041e0| 6f 20 74 68 65 20 74 61 | 62 6c 65 20 73 69 7a 65 |o the ta|ble size|
|000041f0| 2e 0a 09 09 20 2a 20 53 | 4b 49 50 43 4f 55 4e 54 |.... * S|KIPCOUNT|
|00004200| 20 3d 3d 20 31 20 6d 65 | 61 6e 73 20 70 72 69 6d | == 1 me|ans prim|
|00004210| 61 72 61 79 20 63 6c 75 | 73 74 65 72 69 6e 67 2e |aray clu|stering.|
|00004220| 0a 09 09 20 2a 20 53 4b | 49 50 43 4f 55 4e 54 20 |... * SK|IPCOUNT |
|00004230| 3e 20 31 20 6d 65 61 6e | 73 20 73 65 63 6f 6e 64 |> 1 mean|s second|
|00004240| 61 72 79 20 63 6c 75 73 | 74 65 72 69 6e 67 2e 0a |ary clus|tering..|
|00004250| 09 09 20 2a 20 43 68 65 | 63 6b 20 66 6f 72 20 6f |.. * Che|ck for o|
|00004260| 76 65 72 66 6c 6f 77 2e | 0a 09 09 20 2a 2f 0a 09 |verflow.|... */..|
|00004270| 09 65 6c 73 65 0a 09 09 | 09 7b 0a 09 09 09 73 69 |.else...|.{....si|
|00004280| 6e 64 65 78 20 2b 3d 20 | 53 4b 49 50 43 4f 55 4e |ndex += |SKIPCOUN|
|00004290| 54 3b 0a 09 09 09 69 66 | 20 28 73 69 6e 64 65 78 |T;....if| (sindex|
|000042a0| 20 3e 3d 20 42 49 47 50 | 52 49 4d 45 29 0a 09 09 | >= BIGP|RIME)...|
|000042b0| 09 09 73 69 6e 64 65 78 | 20 3d 20 30 3b 09 09 2f |..sindex| = 0;../|
|000042c0| 2a 20 77 72 61 70 61 72 | 6f 75 6e 64 20 2a 2f 0a |* wrapar|ound */.|
|000042d0| 09 09 09 69 66 20 28 73 | 69 6e 64 65 78 20 3d 3d |...if (s|index ==|
|000042e0| 20 66 69 72 73 74 70 72 | 6f 62 65 29 0a 09 09 09 | firstpr|obe)....|
|000042f0| 09 7b 0a 09 09 09 09 66 | 70 72 69 6e 74 66 20 28 |.{.....f|printf (|
|00004300| 73 74 64 65 72 72 2c 20 | 22 25 73 3a 20 73 79 6d |stderr, |"%s: sym|
|00004310| 74 62 6c 20 6f 76 65 72 | 66 6c 6f 77 21 5c 6e 22 |tbl over|flow!\n"|
|00004320| 2c 20 63 6d 64 29 3b 0a | 09 09 09 09 65 78 69 74 |, cmd);.|....exit|
|00004330| 20 28 31 29 3b 0a 09 09 | 09 09 7d 0a 09 09 09 7d | (1);...|..}....}|
|00004340| 0a 09 09 7d 0a 0a 0a 09 | 72 65 74 75 72 6e 20 73 |...}....|return s|
|00004350| 69 6e 64 65 78 3b 0a 7d | 0a 0a 0a 2f 2a 0a 20 2a |index;.}|.../*. *|
|00004360| 20 70 61 73 73 20 33 2e | 0a 20 2a 20 50 72 6f 63 | pass 3.|. * Proc|
|00004370| 65 73 73 20 4e 41 20 61 | 72 72 61 79 20 61 6e 64 |ess NA a|rray and|
|00004380| 20 6c 69 6e 6b 20 6c 69 | 6e 65 73 20 75 70 20 77 | link li|nes up w|
|00004390| 68 69 63 68 20 61 70 70 | 65 61 72 20 6f 6e 6c 79 |hich app|ear only|
|000043a0| 20 6f 6e 63 65 0a 20 2a | 20 69 6e 20 62 6f 74 68 | once. *| in both|
|000043b0| 20 66 69 6c 65 73 2e 0a | 20 2a 20 4c 69 6e 6b 20 | files..| * Link |
|000043c0| 76 69 72 74 75 61 6c 20 | 6c 69 6e 65 20 70 6f 69 |virtual |line poi|
|000043d0| 6e 74 65 72 20 61 74 20 | 66 72 6f 6e 74 20 61 6e |nter at |front an|
|000043e0| 64 20 65 6e 64 20 6f 66 | 20 62 6f 74 68 20 66 69 |d end of| both fi|
|000043f0| 6c 65 73 2e 0a 20 2a 2f | 0a 0a 70 61 73 73 33 20 |les.. */|..pass3 |
|00004400| 28 29 0a 7b 0a 09 69 6e | 74 09 6e 65 77 69 2c 09 |().{..in|t.newi,.|
|00004410| 09 2f 2a 20 6c 6f 6f 70 | 20 63 6f 75 6e 74 65 72 |./* loop| counter|
|00004420| 20 74 68 72 75 20 6e 61 | 20 61 72 72 61 79 09 09 | thru na| array..|
|00004430| 2a 2f 0a 09 09 6f 6c 64 | 69 2c 09 09 2f 2a 20 69 |*/...old|i,../* i|
|00004440| 6e 64 65 78 20 69 6e 74 | 6f 20 6f 61 20 61 72 72 |ndex int|o oa arr|
|00004450| 61 79 09 09 09 2a 2f 0a | 09 09 73 79 6d 69 3b 09 |ay...*/.|..symi;.|
|00004460| 09 2f 2a 20 69 6e 64 65 | 78 20 69 6e 74 6f 20 73 |./* inde|x into s|
|00004470| 79 6d 62 6f 6c 20 74 61 | 62 6c 65 20 61 72 72 61 |ymbol ta|ble arra|
|00004480| 79 09 2a 2f 0a 0a 09 2f | 2a 20 6c 6f 6f 70 20 74 |y.*/.../|* loop t|
|00004490| 68 72 75 20 61 6c 6c 20 | 6e 65 77 20 6c 69 6e 65 |hru all |new line|
|000044a0| 73 2e 20 20 54 68 6f 73 | 65 20 74 68 61 74 20 6f |s. Thos|e that o|
|000044b0| 63 63 75 72 20 6f 6e 63 | 65 20 61 72 65 20 6c 69 |ccur onc|e are li|
|000044c0| 6e 6b 65 64 20 74 6f 0a | 09 20 2a 20 65 61 63 68 |nked to.|. * each|
|000044d0| 20 6f 74 68 65 72 20 69 | 6e 73 74 65 61 64 20 6f | other i|nstead o|
|000044e0| 66 20 74 6f 20 74 68 65 | 20 73 79 6d 62 6f 6c 20 |f to the| symbol |
|000044f0| 74 61 62 6c 65 20 61 73 | 20 74 68 65 79 20 75 73 |table as| they us|
|00004500| 65 64 20 74 6f 20 62 65 | 2e 0a 09 20 2a 2f 0a 09 |ed to be|... */..|
|00004510| 66 6f 72 20 28 6e 65 77 | 69 20 3d 20 31 3b 20 6e |for (new|i = 1; n|
|00004520| 65 77 69 20 3c 3d 20 6c | 61 73 74 6e 65 77 3b 20 |ewi <= l|astnew; |
|00004530| 2b 2b 6e 65 77 69 29 0a | 09 09 7b 0a 09 09 73 79 |++newi).|..{...sy|
|00004540| 6d 69 20 3d 20 6e 61 5b | 6e 65 77 69 5d 2e 6c 69 |mi = na[|newi].li|
|00004550| 6e 65 6c 6f 63 3b 09 2f | 2a 20 67 65 74 20 73 79 |neloc;./|* get sy|
|00004560| 6d 62 6f 6c 20 74 62 6c | 20 69 6e 64 65 78 09 2a |mbol tbl| index.*|
|00004570| 2f 0a 09 09 69 66 20 28 | 28 73 79 6d 74 62 6c 5b |/...if (|(symtbl[|
|00004580| 73 79 6d 69 5d 2e 6f 63 | 6f 75 6e 74 20 3d 3d 20 |symi].oc|ount == |
|00004590| 31 29 20 26 26 20 28 73 | 79 6d 74 62 6c 5b 73 79 |1) && (s|ymtbl[sy|
|000045a0| 6d 69 5d 2e 6e 63 6f 75 | 6e 74 20 3d 3d 20 31 29 |mi].ncou|nt == 1)|
|000045b0| 29 0a 09 09 09 7b 0a 09 | 09 09 6f 6c 64 69 20 3d |)....{..|..oldi =|
|000045c0| 20 73 79 6d 74 62 6c 5b | 73 79 6d 69 5d 2e 6f 6c | symtbl[|symi].ol|
|000045d0| 69 6e 65 6e 75 6d 3b 0a | 09 09 09 6c 69 6e 6b 75 |inenum;.|...linku|
|000045e0| 70 20 28 6f 6c 64 69 2c | 20 6e 65 77 69 29 3b 0a |p (oldi,| newi);.|
|000045f0| 09 09 09 7d 0a 09 09 7d | 0a 0a 09 2f 2a 20 6c 69 |...}...}|.../* li|
|00004600| 6e 6b 20 74 68 65 20 76 | 69 72 74 75 61 6c 20 6c |nk the v|irtual l|
|00004610| 69 6e 65 20 27 62 65 67 | 69 6e 27 20 6f 66 20 65 |ine 'beg|in' of e|
|00004620| 61 63 68 20 66 69 6c 65 | 20 74 6f 20 65 61 63 68 |ach file| to each|
|00004630| 20 6f 74 68 65 72 20 2a | 2f 0a 09 6c 69 6e 6b 75 | other *|/..linku|
|00004640| 70 20 28 30 2c 20 30 29 | 3b 0a 0a 09 2f 2a 20 6c |p (0, 0)|;.../* l|
|00004650| 69 6e 65 20 74 68 65 20 | 76 69 72 74 75 61 6c 20 |ine the |virtual |
|00004660| 6c 69 6e 65 20 27 65 6e | 64 27 20 6f 66 20 65 61 |line 'en|d' of ea|
|00004670| 63 68 20 66 69 6c 65 20 | 74 6f 20 65 61 63 68 20 |ch file |to each |
|00004680| 6f 74 68 65 72 20 2a 2f | 0a 09 6c 69 6e 6b 75 70 |other */|..linkup|
|00004690| 20 28 6c 61 73 74 6f 6c | 64 2b 31 2c 20 6c 61 73 | (lastol|d+1, las|
|000046a0| 74 6e 65 77 2b 31 29 3b | 0a 7d 0a 0a 0a 2f 2a 0a |tnew+1);|.}.../*.|
|000046b0| 20 2a 20 70 61 73 73 20 | 34 0a 20 2a 20 6c 6f 6f | * pass |4. * loo|
|000046c0| 70 20 61 73 63 65 6e 64 | 69 6e 67 20 74 68 72 75 |p ascend|ing thru|
|000046d0| 20 6e 65 77 20 6c 69 6e | 65 73 20 69 6e 20 6e 61 | new lin|es in na|
|000046e0| 20 61 72 72 61 79 2e 0a | 20 2a 20 49 66 20 6c 69 | array..| * If li|
|000046f0| 6e 65 20 6e 65 77 69 20 | 69 6e 20 6e 65 77 20 66 |ne newi |in new f|
|00004700| 69 6c 65 20 69 73 20 6c | 69 6e 6b 65 64 20 74 6f |ile is l|inked to|
|00004710| 20 6c 69 6e 65 20 6f 6c | 64 69 20 69 6e 20 6f 6c | line ol|di in ol|
|00004720| 64 20 66 69 6c 65 2c 0a | 20 2a 20 62 75 74 20 74 |d file,.| * but t|
|00004730| 68 65 20 6e 65 78 74 20 | 6c 69 6e 65 73 20 6f 66 |he next |lines of|
|00004740| 20 65 61 63 68 20 63 6f | 6e 74 61 69 6e 20 74 68 | each co|ntain th|
|00004750| 65 20 73 61 6d 65 20 73 | 79 6d 62 6f 6c 20 74 61 |e same s|ymbol ta|
|00004760| 62 6c 65 0a 20 2a 20 70 | 6f 69 6e 74 65 72 2c 20 |ble. * p|ointer, |
|00004770| 74 68 65 6e 20 6c 69 6e | 6b 20 6e 61 5b 6e 65 77 |then lin|k na[new|
|00004780| 69 2b 31 5d 20 74 6f 20 | 6f 61 5b 6f 6c 64 69 2b |i+1] to |oa[oldi+|
|00004790| 31 5d 2e 0a 20 2a 2f 0a | 70 61 73 73 34 20 28 29 |1].. */.|pass4 ()|
|000047a0| 0a 7b 0a 09 69 6e 74 09 | 6e 65 77 69 2c 0a 09 09 |.{..int.|newi,...|
|000047b0| 6f 6c 64 69 3b 0a 0a 09 | 2f 2a 20 70 72 6f 63 65 |oldi;...|/* proce|
|000047c0| 73 73 20 27 62 65 67 69 | 6e 27 2c 20 61 6c 6c 20 |ss 'begi|n', all |
|000047d0| 6c 69 6e 65 73 20 69 6e | 20 6e 65 77 20 66 69 6c |lines in| new fil|
|000047e0| 65 2c 20 62 75 74 20 4e | 4f 54 20 76 69 72 74 75 |e, but N|OT virtu|
|000047f0| 61 6c 20 27 65 6e 64 27 | 20 2a 2f 0a 09 66 6f 72 |al 'end'| */..for|
|00004800| 20 28 6e 65 77 69 20 3d | 20 30 3b 20 6e 65 77 69 | (newi =| 0; newi|
|00004810| 20 3c 3d 20 6c 61 73 74 | 6e 65 77 3b 20 2b 2b 6e | <= last|new; ++n|
|00004820| 65 77 69 29 0a 09 09 7b | 0a 09 09 69 66 20 28 6e |ewi)...{|...if (n|
|00004830| 61 5b 6e 65 77 69 5d 2e | 66 6c 61 67 20 3d 3d 20 |a[newi].|flag == |
|00004840| 4c 5f 4c 49 4e 45 4e 55 | 4d 29 0a 09 09 09 7b 0a |L_LINENU|M)....{.|
|00004850| 09 09 09 6f 6c 64 69 20 | 3d 20 6e 61 5b 6e 65 77 |...oldi |= na[new|
|00004860| 69 5d 2e 6c 69 6e 65 6c | 6f 63 3b 0a 09 09 09 69 |i].linel|oc;....i|
|00004870| 66 20 28 28 6e 61 5b 6e | 65 77 69 2b 31 5d 2e 66 |f ((na[n|ewi+1].f|
|00004880| 6c 61 67 20 3d 3d 20 4c | 5f 53 59 4d 49 4e 44 58 |lag == L|_SYMINDX|
|00004890| 29 20 26 26 0a 09 09 09 | 20 20 20 20 28 6f 61 5b |) &&....| (oa[|
|000048a0| 6f 6c 64 69 2b 31 5d 2e | 66 6c 61 67 20 3d 3d 20 |oldi+1].|flag == |
|000048b0| 4c 5f 53 59 4d 49 4e 44 | 58 29 20 26 26 0a 09 09 |L_SYMIND|X) &&...|
|000048c0| 09 20 20 20 20 28 6e 61 | 5b 6e 65 77 69 2b 31 5d |. (na|[newi+1]|
|000048d0| 2e 6c 69 6e 65 6c 6f 63 | 20 3d 3d 20 6f 61 5b 6f |.lineloc| == oa[o|
|000048e0| 6c 64 69 2b 31 5d 2e 6c | 69 6e 65 6c 6f 63 29 29 |ldi+1].l|ineloc))|
|000048f0| 0a 09 09 09 09 6c 69 6e | 6b 75 70 20 28 6f 6c 64 |.....lin|kup (old|
|00004900| 69 2b 31 2c 20 6e 65 77 | 69 2b 31 29 3b 0a 09 09 |i+1, new|i+1);...|
|00004910| 09 7d 0a 09 09 7d 0a 7d | 0a 0a 0a 2f 2a 0a 20 2a |.}...}.}|.../*. *|
|00004920| 20 70 61 73 73 20 35 0a | 20 2a 20 50 72 6f 63 65 | pass 5.| * Proce|
|00004930| 73 73 20 6e 65 77 20 66 | 69 6c 65 20 69 6e 20 64 |ss new f|ile in d|
|00004940| 65 73 63 65 6e 64 69 6e | 67 20 6f 72 64 65 72 2e |escendin|g order.|
|00004950| 0a 20 2a 20 53 69 6d 69 | 6c 61 72 20 74 6f 20 70 |. * Simi|lar to p|
|00004960| 61 73 73 20 34 2c 20 62 | 75 74 20 69 6e 20 72 65 |ass 4, b|ut in re|
|00004970| 76 65 72 73 65 20 6f 72 | 64 65 72 2e 0a 20 2a 2f |verse or|der.. */|
|00004980| 0a 70 61 73 73 35 20 28 | 29 0a 7b 0a 09 69 6e 74 |.pass5 (|).{..int|
|00004990| 09 6e 65 77 69 2c 0a 09 | 09 6f 6c 64 69 3b 0a 0a |.newi,..|.oldi;..|
|000049a0| 09 2f 2a 20 70 72 6f 63 | 65 73 73 20 27 65 6e 64 |./* proc|ess 'end|
|000049b0| 27 2c 20 61 6c 6c 20 6c | 69 6e 65 73 20 69 6e 20 |', all l|ines in |
|000049c0| 6e 65 77 20 66 69 6c 65 | 2c 20 62 75 74 20 4e 4f |new file|, but NO|
|000049d0| 54 20 76 69 72 74 75 61 | 6c 20 27 62 65 67 69 6e |T virtua|l 'begin|
|000049e0| 27 20 2a 2f 0a 09 66 6f | 72 20 28 6e 65 77 69 20 |' */..fo|r (newi |
|000049f0| 3d 20 6c 61 73 74 6e 65 | 77 2b 31 3b 20 6e 65 77 |= lastne|w+1; new|
|00004a00| 69 20 3e 20 30 3b 20 2d | 2d 6e 65 77 69 29 0a 09 |i > 0; -|-newi)..|
|00004a10| 09 7b 0a 09 09 69 66 20 | 28 6e 61 5b 6e 65 77 69 |.{...if |(na[newi|
|00004a20| 5d 2e 66 6c 61 67 20 3d | 3d 20 4c 5f 4c 49 4e 45 |].flag =|= L_LINE|
|00004a30| 4e 55 4d 29 0a 09 09 09 | 7b 0a 09 09 09 6f 6c 64 |NUM)....|{....old|
|00004a40| 69 20 3d 20 6e 61 5b 6e | 65 77 69 5d 2e 6c 69 6e |i = na[n|ewi].lin|
|00004a50| 65 6c 6f 63 3b 0a 09 09 | 09 69 66 20 28 28 6e 61 |eloc;...|.if ((na|
|00004a60| 5b 6e 65 77 69 2d 31 5d | 2e 66 6c 61 67 20 3d 3d |[newi-1]|.flag ==|
|00004a70| 20 4c 5f 53 59 4d 49 4e | 44 58 29 20 26 26 0a 09 | L_SYMIN|DX) &&..|
|00004a80| 09 09 20 20 20 20 28 6f | 61 5b 6f 6c 64 69 2d 31 |.. (o|a[oldi-1|
|00004a90| 5d 2e 66 6c 61 67 20 3d | 3d 20 4c 5f 53 59 4d 49 |].flag =|= L_SYMI|
|00004aa0| 4e 44 58 29 20 26 26 0a | 09 09 09 20 20 20 20 28 |NDX) &&.|... (|
|00004ab0| 6e 61 5b 6e 65 77 69 2d | 31 5d 2e 6c 69 6e 65 6c |na[newi-|1].linel|
|00004ac0| 6f 63 20 3d 3d 20 6f 61 | 5b 6f 6c 64 69 2d 31 5d |oc == oa|[oldi-1]|
|00004ad0| 2e 6c 69 6e 65 6c 6f 63 | 29 29 0a 09 09 09 09 6c |.lineloc|)).....l|
|00004ae0| 69 6e 6b 75 70 20 28 6f | 6c 64 69 2d 31 2c 20 6e |inkup (o|ldi-1, n|
|00004af0| 65 77 69 2d 31 29 3b 0a | 09 09 09 7d 0a 09 09 7d |ewi-1);.|...}...}|
|00004b00| 0a 0a 0a 7d 0a 0a 0a 2f | 2a 0a 20 2a 20 70 61 73 |...}.../|*. * pas|
|00004b10| 73 20 36 0a 20 2a 20 6f | 75 74 70 75 74 20 74 68 |s 6. * o|utput th|
|00004b20| 65 20 64 69 66 66 65 72 | 65 6e 63 65 73 2e 0a 20 |e differ|ences.. |
|00004b30| 2a 2f 0a 70 61 73 73 36 | 20 28 29 0a 7b 0a 09 69 |*/.pass6| ().{..i|
|00004b40| 6e 74 09 6f 6c 64 69 2c | 09 09 2f 2a 20 63 75 72 |nt.oldi,|../* cur|
|00004b50| 72 65 6e 74 20 6c 69 6e | 65 20 6e 75 6d 62 65 72 |rent lin|e number|
|00004b60| 20 69 6e 20 6f 6c 64 20 | 66 69 6c 65 09 2a 2f 0a | in old |file.*/.|
|00004b70| 09 09 6e 65 77 69 2c 09 | 09 2f 2a 20 63 75 72 72 |..newi,.|./* curr|
|00004b80| 65 6e 74 20 6c 69 6e 65 | 20 6e 75 6d 62 65 72 20 |ent line| number |
|00004b90| 69 6e 20 6e 65 77 20 66 | 69 6c 65 09 2a 2f 0a 09 |in new f|ile.*/..|
|00004ba0| 09 6f 6c 64 6d 61 74 63 | 68 2c 09 2f 2a 20 74 72 |.oldmatc|h,./* tr|
|00004bb0| 75 65 20 69 66 66 20 6f | 6c 64 20 6c 69 6e 65 20 |ue iff o|ld line |
|00004bc0| 6d 61 74 63 68 65 73 20 | 53 4f 4d 45 20 6c 69 6e |matches |SOME lin|
|00004bd0| 65 20 69 6e 20 6e 65 77 | 20 66 69 6c 65 20 2a 2f |e in new| file */|
|00004be0| 0a 09 09 6e 65 77 6d 61 | 74 63 68 2c 09 2f 2a 20 |...newma|tch,./* |
|00004bf0| 74 72 75 65 20 69 66 66 | 20 6e 65 77 20 6c 69 6e |true iff| new lin|
|00004c00| 65 20 6d 61 74 63 68 65 | 73 20 53 4f 4d 45 20 6c |e matche|s SOME l|
|00004c10| 69 6e 65 20 69 6e 20 6f | 6c 64 20 66 69 6c 65 20 |ine in o|ld file |
|00004c20| 2a 2f 0a 09 09 6f 6d 61 | 74 63 6f 75 6e 74 2c 09 |*/...oma|tcount,.|
|00004c30| 2f 2a 20 6d 61 74 63 68 | 20 63 6f 75 6e 74 20 69 |/* match| count i|
|00004c40| 6e 20 6f 6c 64 20 66 69 | 6c 65 09 09 2a 2f 0a 09 |n old fi|le..*/..|
|00004c50| 09 6e 6d 61 74 63 6f 75 | 6e 74 2c 09 2f 2a 20 6d |.nmatcou|nt,./* m|
|00004c60| 61 74 63 68 20 63 6f 75 | 6e 74 20 69 6e 20 6e 65 |atch cou|nt in ne|
|00004c70| 77 20 66 69 6c 65 09 09 | 2a 2f 0a 09 09 6f 64 72 |w file..|*/...odr|
|00004c80| 6f 70 2c 09 09 2f 2a 20 | 6f 6c 64 20 66 69 6c 65 |op,../* |old file|
|00004c90| 20 22 72 65 6c 61 74 69 | 76 65 20 64 72 6f 70 22 | "relati|ve drop"|
|00004ca0| 20 6f 66 20 6e 65 77 20 | 6c 69 6e 65 20 2a 2f 0a | of new |line */.|
|00004cb0| 09 09 6e 64 72 6f 70 2c | 09 09 2f 2a 20 6e 65 77 |..ndrop,|../* new|
|00004cc0| 20 66 69 6c 65 20 22 72 | 65 6c 61 74 69 76 65 20 | file "r|elative |
|00004cd0| 64 72 6f 70 22 20 6f 66 | 20 6f 6c 64 20 6c 69 6e |drop" of| old lin|
|00004ce0| 65 20 2a 2f 0a 09 09 6f | 63 6f 6d 70 2c 09 09 2f |e */...o|comp,../|
|00004cf0| 2a 20 63 6f 6d 70 61 72 | 69 73 6f 6e 20 72 65 73 |* compar|ison res|
|00004d00| 75 6c 74 20 66 6f 72 20 | 6f 6c 64 20 66 69 6c 65 |ult for |old file|
|00004d10| 09 2a 2f 0a 09 09 6e 63 | 6f 6d 70 2c 09 09 2f 2a |.*/...nc|omp,../*|
|00004d20| 20 63 6f 6d 70 61 72 69 | 73 6f 6e 20 72 65 73 75 | compari|son resu|
|00004d30| 6c 74 20 66 6f 72 20 6e | 65 77 20 66 69 6c 65 09 |lt for n|ew file.|
|00004d40| 2a 2f 0a 09 09 6f 73 70 | 61 6e 2c 09 09 2f 2a 20 |*/...osp|an,../* |
|00004d50| 73 69 7a 65 20 6f 66 20 | 6f 6c 64 20 6d 6f 6e 6f |size of |old mono|
|00004d60| 74 6f 6e 69 63 61 6c 20 | 62 6c 6f 63 6b 09 2a 2f |tonical |block.*/|
|00004d70| 0a 09 09 6e 73 70 61 6e | 3b 09 09 2f 2a 20 73 69 |...nspan|;../* si|
|00004d80| 7a 65 20 6f 66 20 6e 65 | 77 20 6d 6f 6e 6f 74 6f |ze of ne|w monoto|
|00004d90| 6e 69 63 61 6c 20 62 6c | 6f 63 6b 09 2a 2f 0a 0a |nical bl|ock.*/..|
|00004da0| 09 66 6f 72 20 28 6f 6c | 64 69 20 3d 20 30 2c 20 |.for (ol|di = 0, |
|00004db0| 6e 65 77 69 20 3d 20 30 | 3b 20 6f 6c 64 69 20 3c |newi = 0|; oldi <|
|00004dc0| 3d 20 6c 61 73 74 6f 6c | 64 2b 31 20 26 26 20 6e |= lastol|d+1 && n|
|00004dd0| 65 77 69 20 3c 3d 20 6c | 61 73 74 6e 65 77 2b 31 |ewi <= l|astnew+1|
|00004de0| 3b 29 0a 09 09 7b 0a 0a | 09 09 2f 2a 20 73 65 74 |;)...{..|../* set|
|00004df0| 20 66 6c 61 67 73 20 74 | 6f 20 69 6e 64 69 63 61 | flags t|o indica|
|00004e00| 74 65 20 69 66 20 65 61 | 63 68 20 6c 69 6e 65 20 |te if ea|ch line |
|00004e10| 69 73 20 6c 69 6e 6b 65 | 64 0a 09 09 20 2a 20 74 |is linke|d... * t|
|00004e20| 6f 20 61 6e 6f 74 68 65 | 72 20 6c 69 6e 65 20 69 |o anothe|r line i|
|00004e30| 6e 20 74 68 65 20 6f 74 | 68 65 72 20 66 69 6c 65 |n the ot|her file|
|00004e40| 2e 0a 09 09 20 2a 2f 0a | 0a 09 09 2f 2a 20 69 73 |.... */.|.../* is|
|00004e50| 20 6f 6c 64 20 6c 69 6e | 65 20 6c 69 6e 6b 65 64 | old lin|e linked|
|00004e60| 20 74 6f 20 61 6e 6f 74 | 68 65 72 20 6c 69 6e 65 | to anot|her line|
|00004e70| 20 69 6e 20 74 68 65 20 | 6e 65 77 20 66 69 6c 65 | in the |new file|
|00004e80| 3f 20 2a 2f 0a 09 09 6f | 6c 64 6d 61 74 63 68 20 |? */...o|ldmatch |
|00004e90| 3d 20 28 6f 61 5b 6f 6c | 64 69 5d 2e 66 6c 61 67 |= (oa[ol|di].flag|
|00004ea0| 20 3d 3d 20 4c 5f 4c 49 | 4e 45 4e 55 4d 29 3b 0a | == L_LI|NENUM);.|
|00004eb0| 0a 09 09 2f 2a 20 69 73 | 20 6e 65 77 20 6c 69 6e |.../* is| new lin|
|00004ec0| 65 20 6c 69 6e 6b 65 64 | 20 74 6f 20 61 6e 6f 74 |e linked| to anot|
|00004ed0| 68 65 72 20 6c 69 6e 65 | 20 69 6e 20 74 68 65 20 |her line| in the |
|00004ee0| 6f 6c 64 20 66 69 6c 65 | 3f 20 2a 2f 0a 09 09 6e |old file|? */...n|
|00004ef0| 65 77 6d 61 74 63 68 20 | 3d 20 28 6e 61 5b 6e 65 |ewmatch |= (na[ne|
|00004f00| 77 69 5d 2e 66 6c 61 67 | 20 3d 3d 20 4c 5f 4c 49 |wi].flag| == L_LI|
|00004f10| 4e 45 4e 55 4d 29 3b 0a | 0a 0a 09 09 2f 2a 20 69 |NENUM);.|..../* i|
|00004f20| 66 20 6f 6c 64 20 6c 69 | 6e 65 20 6d 6f 76 65 64 |f old li|ne moved|
|00004f30| 20 66 72 6f 6d 20 6f 6c | 64 20 66 69 6c 65 20 75 | from ol|d file u|
|00004f40| 70 20 28 74 6f 77 61 72 | 64 20 62 65 67 69 6e 29 |p (towar|d begin)|
|00004f50| 20 69 6e 0a 09 09 20 2a | 20 6e 65 77 20 66 69 6c | in... *| new fil|
|00004f60| 65 2c 20 74 68 65 6e 20 | 77 65 20 68 61 76 65 20 |e, then |we have |
|00004f70| 61 6c 72 65 61 64 79 20 | 70 72 6f 63 65 73 73 65 |already |processe|
|00004f80| 64 20 74 68 65 20 62 6c | 6f 63 6b 0a 09 09 20 2a |d the bl|ock... *|
|00004f90| 20 6d 6f 76 65 20 69 6e | 20 74 68 65 20 6e 65 77 | move in| the new|
|00004fa0| 20 66 69 6c 65 2e 20 20 | 4a 75 73 74 20 73 6b 69 | file. |Just ski|
|00004fb0| 70 20 74 68 65 20 6c 69 | 6e 65 20 69 6e 20 74 68 |p the li|ne in th|
|00004fc0| 65 20 6f 6c 64 20 66 69 | 6c 65 2e 0a 09 09 20 2a |e old fi|le.... *|
|00004fd0| 2f 0a 09 09 69 66 20 28 | 6f 61 5b 6f 6c 64 69 5d |/...if (|oa[oldi]|
|00004fe0| 2e 6c 69 6e 65 6c 6f 63 | 20 3c 20 6e 65 77 69 20 |.lineloc| < newi |
|00004ff0| 26 26 20 6f 6c 64 6d 61 | 74 63 68 29 0a 09 09 09 |&& oldma|tch)....|
|00005000| 7b 0a 09 09 09 2b 2b 6f | 6c 64 69 3b 0a 09 09 09 |{....++o|ldi;....|
|00005010| 63 6f 6e 74 69 6e 75 65 | 3b 0a 09 09 09 7d 0a 0a |continue|;....}..|
|00005020| 09 09 2f 2a 20 69 66 20 | 6f 6c 64 20 6c 69 6e 65 |../* if |old line|
|00005030| 20 6d 6f 76 65 64 20 66 | 72 6f 6d 20 6f 6c 64 20 | moved f|rom old |
|00005040| 66 69 6c 65 20 64 6f 77 | 6e 20 28 74 6f 77 61 72 |file dow|n (towar|
|00005050| 64 20 65 6e 64 29 20 69 | 6e 0a 09 09 20 2a 20 6f |d end) i|n... * o|
|00005060| 6c 64 20 66 69 6c 65 2c | 20 74 68 65 6e 20 77 65 |ld file,| then we|
|00005070| 20 77 65 20 68 61 76 65 | 20 61 6c 72 65 61 64 79 | we have| already|
|00005080| 20 70 72 6f 63 65 73 73 | 65 64 20 74 68 65 20 62 | process|ed the b|
|00005090| 6c 6f 63 6b 0a 09 09 20 | 2a 20 6d 6f 76 65 20 69 |lock... |* move i|
|000050a0| 6e 20 74 68 65 20 6f 6c | 64 20 66 69 6c 65 2e 20 |n the ol|d file. |
|000050b0| 20 4a 75 73 74 20 73 6b | 69 70 20 74 68 65 20 6c | Just sk|ip the l|
|000050c0| 69 6e 65 20 69 6e 20 74 | 68 65 20 6e 65 77 20 66 |ine in t|he new f|
|000050d0| 69 6c 65 2e 0a 09 09 20 | 2a 2f 0a 09 09 65 6c 73 |ile.... |*/...els|
|000050e0| 65 20 69 66 20 28 6e 61 | 5b 6e 65 77 69 5d 2e 6c |e if (na|[newi].l|
|000050f0| 69 6e 65 6c 6f 63 20 3c | 20 6f 6c 64 69 20 26 26 |ineloc <| oldi &&|
|00005100| 20 6e 65 77 6d 61 74 63 | 68 29 0a 09 09 09 7b 0a | newmatc|h)....{.|
|00005110| 09 09 09 2b 2b 6e 65 77 | 69 3b 0a 09 09 09 63 6f |...++new|i;....co|
|00005120| 6e 74 69 6e 75 65 3b 0a | 09 09 09 7d 0a 0a 0a 09 |ntinue;.|...}....|
|00005130| 09 2f 2a 20 74 68 65 72 | 65 20 61 72 65 20 66 6f |./* ther|e are fo|
|00005140| 75 72 20 63 6f 6d 62 69 | 6e 61 74 69 6f 6e 73 20 |ur combi|nations |
|00005150| 6f 66 20 62 6f 6f 6c 65 | 61 6e 73 20 6f 6c 64 6d |of boole|ans oldm|
|00005160| 61 74 63 68 20 61 6e 64 | 20 6e 65 77 6d 61 74 63 |atch and| newmatc|
|00005170| 68 20 2a 2f 0a 0a 09 09 | 2f 2a 20 69 66 20 62 6f |h */....|/* if bo|
|00005180| 74 68 20 6c 69 6e 65 73 | 20 61 72 65 20 6c 69 6e |th lines| are lin|
|00005190| 6b 65 64 20 74 6f 20 53 | 4f 4d 45 20 6c 69 6e 65 |ked to S|OME line|
|000051a0| 20 69 6e 20 74 68 65 20 | 6f 74 68 65 72 20 66 69 | in the |other fi|
|000051b0| 6c 65 20 2a 2f 0a 09 09 | 69 66 20 28 6f 6c 64 6d |le */...|if (oldm|
|000051c0| 61 74 63 68 20 26 26 20 | 6e 65 77 6d 61 74 63 68 |atch && |newmatch|
|000051d0| 29 0a 09 09 09 7b 0a 09 | 09 09 2f 2a 20 69 66 20 |)....{..|../* if |
|000051e0| 62 6f 74 68 20 6c 69 6e | 65 73 20 6d 61 74 63 68 |both lin|es match|
|000051f0| 20 65 61 63 68 20 6f 74 | 68 65 72 2c 20 74 68 65 | each ot|her, the|
|00005200| 6e 20 67 6f 0a 09 09 09 | 20 2a 20 74 6f 20 6e 65 |n go....| * to ne|
|00005210| 78 74 20 6c 69 6e 65 20 | 69 6e 20 62 6f 74 68 20 |xt line |in both |
|00005220| 66 69 6c 65 73 0a 09 09 | 09 20 2a 2f 0a 09 09 09 |files...|. */....|
|00005230| 69 66 20 28 6f 61 5b 6f | 6c 64 69 5d 2e 6c 69 6e |if (oa[o|ldi].lin|
|00005240| 65 6c 6f 63 20 3d 3d 20 | 6e 65 77 69 29 0a 09 09 |eloc == |newi)...|
|00005250| 09 09 7b 0a 09 09 09 09 | 69 66 20 28 64 65 62 75 |..{.....|if (debu|
|00005260| 67 29 0a 09 09 09 09 09 | 70 72 69 6e 74 66 20 28 |g)......|printf (|
|00005270| 22 64 65 62 75 67 3a 20 | 53 61 6d 65 20 6f 6c 64 |"debug: |Same old|
|00005280| 20 6c 69 6e 65 20 25 64 | 20 61 6e 64 20 6e 65 77 | line %d| and new|
|00005290| 20 6c 69 6e 65 20 25 64 | 5c 6e 22 2c 20 6f 6c 64 | line %d|\n", old|
|000052a0| 69 2c 20 6e 65 77 69 29 | 3b 0a 09 09 09 09 2b 2b |i, newi)|;.....++|
|000052b0| 6f 6c 64 69 3b 0a 09 09 | 09 09 2b 2b 6e 65 77 69 |oldi;...|..++newi|
|000052c0| 3b 0a 09 09 09 09 63 6f | 6e 74 69 6e 75 65 3b 0a |;.....co|ntinue;.|
|000052d0| 09 09 09 09 7d 0a 0a 09 | 09 09 2f 2a 20 62 6c 6f |....}...|../* blo|
|000052e0| 63 6b 73 20 6e 6f 74 20 | 6c 69 6e 6b 65 64 20 74 |cks not |linked t|
|000052f0| 6f 20 65 61 63 68 20 6f | 74 68 65 72 2e 0a 09 09 |o each o|ther....|
|00005300| 09 20 2a 20 49 66 20 74 | 68 65 72 65 20 61 72 65 |. * If t|here are|
|00005310| 20 6d 6f 72 65 20 6c 69 | 6e 65 73 20 69 6e 20 6f | more li|nes in o|
|00005320| 6c 64 66 69 6c 65 20 74 | 68 61 74 0a 09 09 09 20 |ldfile t|hat.... |
|00005330| 2a 20 61 72 65 20 6d 6f | 6e 6f 74 6f 6e 69 63 61 |* are mo|notonica|
|00005340| 6c 6c 79 20 69 6e 63 72 | 65 61 73 69 6e 67 20 62 |lly incr|easing b|
|00005350| 79 20 6f 6e 65 20 69 6e | 0a 09 09 09 20 2a 20 74 |y one in|.... * t|
|00005360| 68 65 20 6e 65 77 20 66 | 69 6c 65 2c 20 74 68 65 |he new f|ile, the|
|00005370| 6e 20 74 68 69 73 20 69 | 73 20 6e 6f 72 6d 61 6c |n this i|s normal|
|00005380| 2c 20 61 6e 64 20 74 68 | 65 0a 09 09 09 20 2a 20 |, and th|e.... * |
|00005390| 6e 65 77 20 62 6c 6f 63 | 6b 20 69 73 20 6d 6f 76 |new bloc|k is mov|
|000053a0| 65 64 20 64 6f 77 6e 20 | 69 6e 20 74 68 65 20 6f |ed down |in the o|
|000053b0| 6c 64 20 66 69 6c 65 2e | 0a 09 09 09 20 2a 20 49 |ld file.|.... * I|
|000053c0| 66 20 74 68 65 72 65 20 | 61 72 65 20 6d 6f 72 65 |f there |are more|
|000053d0| 20 6c 69 6e 65 73 20 69 | 6e 20 6e 65 77 66 69 6c | lines i|n newfil|
|000053e0| 65 20 74 68 61 74 0a 09 | 09 09 20 2a 20 61 72 65 |e that..|.. * are|
|000053f0| 20 6d 6f 6e 6f 74 6f 6e | 69 63 61 6c 6c 79 20 69 | monoton|ically i|
|00005400| 6e 63 72 65 61 73 69 6e | 67 20 62 79 20 6f 6e 65 |ncreasin|g by one|
|00005410| 20 69 6e 0a 09 09 09 20 | 2a 20 74 68 65 20 6f 6c | in.... |* the ol|
|00005420| 64 20 66 69 6c 65 2c 20 | 74 68 65 6e 20 74 68 69 |d file, |then thi|
|00005430| 73 20 69 73 20 6e 6f 72 | 6d 61 6c 2c 20 61 6e 64 |s is nor|mal, and|
|00005440| 0a 09 09 09 20 2a 20 74 | 68 65 20 6f 6c 64 20 62 |.... * t|he old b|
|00005450| 6c 6f 63 6b 20 69 73 20 | 6d 6f 76 65 64 20 64 6f |lock is |moved do|
|00005460| 77 6e 20 69 6e 20 74 68 | 65 20 6e 65 77 20 66 69 |wn in th|e new fi|
|00005470| 6c 65 2e 0a 09 09 09 20 | 2a 2f 0a 0a 09 09 09 2f |le..... |*/...../|
|00005480| 2a 20 67 65 74 20 73 69 | 7a 65 20 6f 66 20 6f 6c |* get si|ze of ol|
|00005490| 64 20 62 6c 6f 63 6b 20 | 77 68 69 63 68 20 69 73 |d block |which is|
|000054a0| 20 6d 6f 6e 69 74 6f 6e | 69 63 61 6c 6c 79 0a 09 | moniton|ically..|
|000054b0| 09 09 20 2a 20 69 6e 63 | 72 65 61 73 69 6e 67 20 |.. * inc|reasing |
|000054c0| 62 79 20 6f 6e 65 20 69 | 6e 20 74 68 65 20 6e 65 |by one i|n the ne|
|000054d0| 77 20 66 69 6c 65 2e 0a | 09 09 09 20 2a 2f 0a 09 |w file..|... */..|
|000054e0| 09 09 6f 73 70 61 6e 20 | 3d 20 6f 6c 64 6d 6f 6e |..ospan |= oldmon|
|000054f0| 20 28 6f 6c 64 69 29 3b | 0a 0a 09 09 09 2f 2a 20 | (oldi);|...../* |
|00005500| 67 65 74 20 73 69 7a 65 | 20 6f 66 20 6e 65 77 20 |get size| of new |
|00005510| 62 6c 6f 63 6b 20 77 68 | 69 63 68 20 69 73 20 6d |block wh|ich is m|
|00005520| 6f 6e 69 74 6f 6e 69 63 | 61 6c 6c 79 0a 09 09 09 |onitonic|ally....|
|00005530| 20 2a 20 69 6e 63 72 65 | 61 73 69 6e 67 20 62 79 | * incre|asing by|
|00005540| 20 6f 6e 65 20 69 6e 20 | 74 68 65 20 6f 6c 64 20 | one in |the old |
|00005550| 66 69 6c 65 2e 0a 09 09 | 09 20 2a 2f 0a 09 09 09 |file....|. */....|
|00005560| 6e 73 70 61 6e 20 3d 20 | 6e 65 77 6d 6f 6e 20 28 |nspan = |newmon (|
|00005570| 6e 65 77 69 29 3b 0a 0a | 09 09 09 2f 2a 20 63 6f |newi);..|.../* co|
|00005580| 75 6e 74 20 74 68 65 20 | 6e 75 6d 62 65 72 20 6f |unt the |number o|
|00005590| 66 20 6c 69 6e 65 73 20 | 69 6e 20 74 68 65 20 6f |f lines |in the o|
|000055a0| 6c 64 20 66 69 6c 65 20 | 62 65 74 77 65 65 6e 0a |ld file |between.|
|000055b0| 09 09 09 20 2a 20 74 68 | 65 20 63 75 72 72 65 6e |... * th|e curren|
|000055c0| 74 20 6c 69 6e 65 20 61 | 6e 64 20 74 68 65 20 6c |t line a|nd the l|
|000055d0| 69 6e 65 20 77 68 69 63 | 68 20 63 6f 72 72 65 73 |ine whic|h corres|
|000055e0| 70 6f 6e 64 73 0a 09 09 | 09 20 2a 20 74 6f 20 74 |ponds...|. * to t|
|000055f0| 68 65 20 66 69 72 73 74 | 20 6e 65 77 20 6d 6f 76 |he first| new mov|
|00005600| 65 64 20 6c 69 6e 65 2e | 0a 09 09 09 20 2a 2f 0a |ed line.|.... */.|
|00005610| 09 09 09 6f 6d 61 74 63 | 6f 75 6e 74 20 3d 20 67 |...omatc|ount = g|
|00005620| 6f 6d 61 74 63 68 20 28 | 6f 6c 64 69 2c 20 6e 61 |omatch (|oldi, na|
|00005630| 5b 6e 65 77 69 5d 2e 6c | 69 6e 65 6c 6f 63 29 3b |[newi].l|ineloc);|
|00005640| 0a 0a 09 09 09 2f 2a 20 | 63 6f 75 6e 74 20 74 68 |...../* |count th|
|00005650| 65 20 6e 75 6d 62 65 72 | 20 6f 66 20 6c 69 6e 65 |e number| of line|
|00005660| 73 20 69 6e 20 74 68 65 | 20 6e 65 77 20 66 69 6c |s in the| new fil|
|00005670| 65 20 62 65 74 77 65 65 | 6e 0a 09 09 09 20 2a 20 |e betwee|n.... * |
|00005680| 74 68 65 20 63 75 72 72 | 65 6e 74 20 6c 69 6e 65 |the curr|ent line|
|00005690| 20 61 6e 64 20 74 68 65 | 20 6f 6c 64 20 6d 6f 76 | and the| old mov|
|000056a0| 65 64 20 6c 69 6e 65 20 | 77 68 69 63 68 0a 09 09 |ed line |which...|
|000056b0| 09 20 2a 20 6d 61 74 63 | 68 2e 0a 09 09 09 20 2a |. * matc|h..... *|
|000056c0| 2f 0a 09 09 09 6e 6d 61 | 74 63 6f 75 6e 74 20 3d |/....nma|tcount =|
|000056d0| 20 67 6e 6d 61 74 63 68 | 20 28 6e 65 77 69 2c 20 | gnmatch| (newi, |
|000056e0| 6f 61 5b 6f 6c 64 69 5d | 2e 6c 69 6e 65 6c 6f 63 |oa[oldi]|.lineloc|
|000056f0| 29 3b 0a 0a 09 09 09 2f | 2a 20 67 65 74 20 6e 75 |);...../|* get nu|
|00005700| 6d 62 65 72 20 6f 66 20 | 6f 6c 64 20 6c 69 6e 65 |mber of |old line|
|00005710| 73 20 74 68 65 20 6e 65 | 77 20 62 6c 6f 63 6b 20 |s the ne|w block |
|00005720| 64 72 6f 70 73 20 64 6f | 77 6e 0a 09 09 09 20 2a |drops do|wn.... *|
|00005730| 20 69 6e 74 6f 20 74 68 | 65 20 6f 6c 64 20 66 69 | into th|e old fi|
|00005740| 6c 65 2e 20 20 49 66 20 | 6f 6c 64 20 64 72 6f 70 |le. If |old drop|
|00005750| 20 69 73 20 3c 20 6e 65 | 77 20 64 72 6f 70 0a 09 | is < ne|w drop..|
|00005760| 09 09 20 2a 20 74 68 65 | 6e 20 74 68 65 20 6f 6c |.. * the|n the ol|
|00005770| 64 20 62 6c 6f 63 6b 20 | 68 61 73 20 6d 6f 76 65 |d block |has move|
|00005780| 64 20 64 6f 77 6e 20 66 | 75 72 74 68 65 72 20 69 |d down f|urther i|
|00005790| 6e 74 6f 0a 09 09 09 20 | 2a 20 74 68 65 20 6e 65 |nto.... |* the ne|
|000057a0| 77 20 66 69 6c 65 20 74 | 68 61 6e 20 74 68 65 20 |w file t|han the |
|000057b0| 6e 65 77 20 62 6c 6f 63 | 6b 20 68 61 73 20 6d 6f |new bloc|k has mo|
|000057c0| 76 65 64 20 64 6f 77 6e | 0a 09 09 09 20 2a 20 69 |ved down|.... * i|
|000057d0| 6e 74 6f 20 74 68 65 20 | 6f 6c 64 20 66 69 6c 65 |nto the |old file|
|000057e0| 2e 20 20 54 68 65 20 72 | 65 6c 61 74 69 76 65 20 |. The r|elative |
|000057f0| 73 74 65 65 70 6e 65 73 | 73 20 6f 66 20 74 68 65 |steepnes|s of the|
|00005800| 0a 09 09 09 20 2a 20 73 | 6c 6f 70 65 20 6f 66 20 |.... * s|lope of |
|00005810| 74 68 65 20 6c 69 6e 65 | 20 66 72 6f 6d 20 6f 6c |the line| from ol|
|00005820| 64 69 20 74 6f 20 69 74 | 73 20 6d 61 74 63 68 65 |di to it|s matche|
|00005830| 64 20 6c 69 6e 65 0a 09 | 09 09 20 2a 20 69 73 20 |d line..|.. * is |
|00005840| 6d 6f 72 65 20 74 68 61 | 6e 20 74 68 65 20 73 74 |more tha|n the st|
|00005850| 65 65 70 6e 65 73 20 6f | 66 20 74 68 65 20 6f 74 |eepnes o|f the ot|
|00005860| 68 65 72 20 73 6c 6f 70 | 65 2c 0a 09 09 09 20 2a |her slop|e,.... *|
|00005870| 20 61 6e 64 20 73 69 6e | 63 65 20 6c 69 6e 65 20 | and sin|ce line |
|00005880| 64 6f 6e 27 74 20 75 73 | 75 61 6c 6c 79 20 6d 6f |don't us|ually mo|
|00005890| 76 65 20 66 61 72 2c 20 | 61 73 73 75 6d 65 0a 09 |ve far, |assume..|
|000058a0| 09 09 20 2a 20 74 68 61 | 74 20 74 68 65 20 6e 65 |.. * tha|t the ne|
|000058b0| 77 20 74 6f 20 6f 6c 64 | 20 6d 6f 76 65 20 69 73 |w to old| move is|
|000058c0| 20 61 20 6d 61 74 63 68 | 2c 20 61 6e 64 20 74 68 | a match|, and th|
|000058d0| 65 0a 09 09 09 20 2a 20 | 6f 6c 64 20 74 6f 20 6e |e.... * |old to n|
|000058e0| 65 77 20 69 73 20 61 6e | 20 6f 6c 64 20 62 6c 6f |ew is an| old blo|
|000058f0| 63 6b 20 6d 6f 76 65 64 | 20 64 6f 77 6e 2e 0a 09 |ck moved| down...|
|00005900| 09 09 20 2a 2f 0a 09 09 | 09 6f 64 72 6f 70 20 3d |.. */...|.odrop =|
|00005910| 20 6e 61 20 5b 6e 65 77 | 69 5d 2e 6c 69 6e 65 6c | na [new|i].linel|
|00005920| 6f 63 20 2d 20 6f 6c 64 | 69 3b 0a 0a 09 09 09 2f |oc - old|i;...../|
|00005930| 2a 20 73 61 6d 65 20 66 | 6f 72 20 6e 65 77 20 66 |* same f|or new f|
|00005940| 69 6c 65 20 2a 2f 0a 09 | 09 09 6e 64 72 6f 70 20 |ile */..|..ndrop |
|00005950| 3d 20 6f 61 20 5b 6f 6c | 64 69 5d 2e 6c 69 6e 65 |= oa [ol|di].line|
|00005960| 6c 6f 63 20 2d 20 6e 65 | 77 69 3b 0a 0a 09 09 09 |loc - ne|wi;.....|
|00005970| 2f 2a 20 69 66 20 27 64 | 27 20 66 6c 61 67 20 69 |/* if 'd|' flag i|
|00005980| 73 20 73 65 74 2c 20 75 | 73 65 20 27 64 72 6f 70 |s set, u|se 'drop|
|00005990| 27 20 66 6f 72 20 6d 61 | 74 63 68 20 2a 2f 0a 09 |' for ma|tch */..|
|000059a0| 09 09 69 66 20 28 72 75 | 6e 66 6c 61 67 20 5b 27 |..if (ru|nflag ['|
|000059b0| 64 27 20 2d 20 27 61 27 | 5d 29 0a 09 09 09 09 7b |d' - 'a'|]).....{|
|000059c0| 0a 09 09 09 09 6f 63 6f | 6d 70 20 3d 20 6f 64 72 |.....oco|mp = odr|
|000059d0| 6f 70 3b 0a 09 09 09 09 | 6e 63 6f 6d 70 20 3d 20 |op;.....|ncomp = |
|000059e0| 6e 64 72 6f 70 3b 0a 09 | 09 09 09 7d 0a 09 09 09 |ndrop;..|...}....|
|000059f0| 2f 2a 20 69 66 20 27 6d | 27 20 66 6c 61 67 20 73 |/* if 'm|' flag s|
|00005a00| 65 74 2c 20 75 73 65 20 | 62 69 67 67 65 72 20 6d |et, use |bigger m|
|00005a10| 6f 6e 6f 74 6f 6e 69 63 | 61 6c 6c 79 20 69 6e 63 |onotonic|ally inc|
|00005a20| 72 65 61 73 69 6e 67 0a | 09 09 09 20 2a 20 62 79 |reasing.|... * by|
|00005a30| 20 31 20 73 70 61 6e 0a | 09 09 09 20 2a 2f 0a 09 | 1 span.|... */..|
|00005a40| 09 09 65 6c 73 65 20 69 | 66 20 28 72 75 6e 66 6c |..else i|f (runfl|
|00005a50| 61 67 20 5b 27 6d 27 20 | 2d 20 27 61 27 5d 29 0a |ag ['m' |- 'a']).|
|00005a60| 09 09 09 09 7b 0a 09 09 | 09 09 6f 63 6f 6d 70 20 |....{...|..ocomp |
|00005a70| 3d 20 6f 73 70 61 6e 3b | 0a 09 09 09 09 6e 63 6f |= ospan;|.....nco|
|00005a80| 6d 70 20 3d 20 6e 73 70 | 61 6e 3b 0a 09 09 09 09 |mp = nsp|an;.....|
|00005a90| 7d 0a 09 09 09 2f 2a 20 | 69 66 20 27 63 27 20 66 |}..../* |if 'c' f|
|00005aa0| 6c 61 67 20 74 68 65 6e | 20 75 73 65 20 6d 61 74 |lag then| use mat|
|00005ab0| 63 68 20 63 6f 75 6e 74 | 20 2a 2f 0a 09 09 09 65 |ch count| */....e|
|00005ac0| 6c 73 65 20 69 66 20 28 | 72 75 6e 66 6c 61 67 20 |lse if (|runflag |
|00005ad0| 5b 27 63 27 20 2d 20 27 | 61 27 5d 29 0a 09 09 09 |['c' - '|a'])....|
|00005ae0| 09 7b 0a 09 09 09 09 6f | 63 6f 6d 70 20 3d 20 6f |.{.....o|comp = o|
|00005af0| 6d 61 74 63 6f 75 6e 74 | 3b 0a 09 09 09 09 6e 63 |matcount|;.....nc|
|00005b00| 6f 6d 70 20 3d 20 6e 6d | 61 74 63 6f 75 6e 74 3b |omp = nm|atcount;|
|00005b10| 0a 09 09 09 09 7d 0a 09 | 09 09 2f 2a 20 64 65 66 |.....}..|../* def|
|00005b20| 61 75 6c 74 20 2d 20 62 | 65 73 74 20 6f 6e 65 20 |ault - b|est one |
|00005b30| 2a 2f 0a 09 09 09 65 6c | 73 65 0a 09 09 09 09 7b |*/....el|se.....{|
|00005b40| 0a 09 09 09 09 6f 63 6f | 6d 70 20 3d 20 6f 6d 61 |.....oco|mp = oma|
|00005b50| 74 63 6f 75 6e 74 3b 0a | 09 09 09 09 6e 63 6f 6d |tcount;.|....ncom|
|00005b60| 70 20 3d 20 6e 6d 61 74 | 63 6f 75 6e 74 3b 0a 09 |p = nmat|count;..|
|00005b70| 09 09 09 7d 0a 0a 0a 0a | 09 09 09 69 66 20 28 6f |...}....|...if (o|
|00005b80| 63 6f 6d 70 20 3c 20 6e | 63 6f 6d 70 29 09 09 2f |comp < n|comp)../|
|00005b90| 2a 20 6f 6c 64 20 62 6c | 6f 63 6b 20 6d 6f 76 65 |* old bl|ock move|
|00005ba0| 64 20 64 6f 77 6e 20 2a | 2f 0a 09 09 09 09 65 61 |d down *|/.....ea|
|00005bb0| 74 6f 6c 64 20 28 26 6f | 6c 64 69 2c 20 6f 73 70 |told (&o|ldi, osp|
|00005bc0| 61 6e 29 3b 09 2f 2a 20 | 65 61 74 20 6f 6c 64 20 |an);./* |eat old |
|00005bd0| 6d 76 27 65 64 20 62 6c | 6b 20 2a 2f 0a 09 09 09 |mv'ed bl|k */....|
|00005be0| 65 6c 73 65 09 09 09 09 | 2f 2a 20 6e 65 77 20 62 |else....|/* new b|
|00005bf0| 6c 6f 63 6b 20 6d 6f 76 | 65 64 20 64 6f 77 6e 20 |lock mov|ed down |
|00005c00| 2a 2f 0a 09 09 09 09 65 | 61 74 6e 65 77 20 28 26 |*/.....e|atnew (&|
|00005c10| 6e 65 77 69 2c 20 6e 73 | 70 61 6e 29 3b 09 2f 2a |newi, ns|pan);./*|
|00005c20| 20 65 61 74 20 6e 65 77 | 20 6d 76 27 65 64 20 62 | eat new| mv'ed b|
|00005c30| 6c 6b 20 2a 2f 0a 09 09 | 09 7d 0a 0a 09 09 2f 2a |lk */...|.}..../*|
|00005c40| 20 6e 65 77 20 6c 69 6e | 65 73 20 61 64 64 65 64 | new lin|es added|
|00005c50| 20 28 69 6e 73 65 72 74 | 65 64 29 20 69 6e 74 6f | (insert|ed) into|
|00005c60| 20 6e 65 77 20 66 69 6c | 65 20 2a 2f 0a 09 09 65 | new fil|e */...e|
|00005c70| 6c 73 65 20 69 66 20 28 | 6f 6c 64 6d 61 74 63 68 |lse if (|oldmatch|
|00005c80| 20 26 26 20 21 6e 65 77 | 6d 61 74 63 68 29 0a 09 | && !new|match)..|
|00005c90| 09 09 6e 65 77 69 6e 73 | 65 72 74 20 28 6f 6c 64 |..newins|ert (old|
|00005ca0| 69 2c 20 26 6e 65 77 69 | 29 3b 20 2f 2a 20 73 6b |i, &newi|); /* sk|
|00005cb0| 69 70 20 6e 65 77 20 69 | 6e 73 65 72 74 20 62 6c |ip new i|nsert bl|
|00005cc0| 6b 20 2a 2f 0a 0a 09 09 | 2f 2a 20 6f 6c 64 20 6c |k */....|/* old l|
|00005cd0| 69 6e 65 73 20 64 65 6c | 65 74 65 64 20 66 72 6f |ines del|eted fro|
|00005ce0| 6d 20 6f 6c 64 20 66 69 | 6c 65 20 2a 2f 0a 09 09 |m old fi|le */...|
|00005cf0| 65 6c 73 65 20 69 66 20 | 28 21 6f 6c 64 6d 61 74 |else if |(!oldmat|
|00005d00| 63 68 20 26 26 20 6e 65 | 77 6d 61 74 63 68 29 0a |ch && ne|wmatch).|
|00005d10| 09 09 09 6f 6c 64 64 65 | 6c 65 74 65 20 28 26 6f |...oldde|lete (&o|
|00005d20| 6c 64 69 2c 20 6e 65 77 | 69 29 3b 09 2f 2a 20 73 |ldi, new|i);./* s|
|00005d30| 6b 69 70 20 6f 6c 64 20 | 64 65 6c 65 74 65 20 62 |kip old |delete b|
|00005d40| 6c 6f 63 6b 20 2a 2f 0a | 0a 09 09 2f 2a 20 6f 6c |lock */.|.../* ol|
|00005d50| 64 20 6c 69 6e 65 73 20 | 63 68 61 6e 67 65 64 20 |d lines |changed |
|00005d60| 69 6e 74 6f 20 6e 65 77 | 20 66 69 6c 65 20 2a 2f |into new| file */|
|00005d70| 0a 09 09 65 6c 73 65 09 | 2f 2a 20 21 6f 6c 64 6d |...else.|/* !oldm|
|00005d80| 61 74 63 68 20 26 26 20 | 21 6e 65 77 6d 61 74 63 |atch && |!newmatc|
|00005d90| 68 20 2a 2f 0a 09 09 09 | 6f 6c 64 63 68 61 6e 67 |h */....|oldchang|
|00005da0| 65 20 28 26 6f 6c 64 69 | 2c 20 26 6e 65 77 69 29 |e (&oldi|, &newi)|
|00005db0| 3b 20 2f 2a 20 73 6b 69 | 70 20 6f 6c 64 20 64 65 |; /* ski|p old de|
|00005dc0| 6c 65 74 65 20 62 6c 6f | 63 6b 20 61 6e 64 20 6e |lete blo|ck and n|
|00005dd0| 65 77 20 69 6e 73 65 72 | 74 20 62 6c 6f 63 6b 20 |ew inser|t block |
|00005de0| 2a 2f 0a 09 09 7d 0a 7d | 0a 0a 2f 2a 0a 20 2a 20 |*/...}.}|../*. * |
|00005df0| 62 6c 6f 63 6b 20 6f 66 | 20 6f 6c 64 20 6c 69 6e |block of| old lin|
|00005e00| 65 73 20 62 65 67 69 6e | 6e 69 6e 67 20 61 74 20 |es begin|ning at |
|00005e10| 6c 69 6e 65 6e 75 6d 20 | 27 6f 6c 64 69 27 20 61 |linenum |'oldi' a|
|00005e20| 72 65 20 6d 61 74 63 68 | 65 64 20 77 69 74 68 0a |re match|ed with.|
|00005e30| 20 2a 20 61 20 62 6c 6f | 63 6b 20 6f 66 20 6e 65 | * a blo|ck of ne|
|00005e40| 77 20 6c 69 6e 65 73 2e | 20 20 43 6f 75 6e 74 20 |w lines.| Count |
|00005e50| 74 68 65 20 6e 75 6d 62 | 65 72 20 6f 66 20 6c 69 |the numb|er of li|
|00005e60| 6e 65 73 20 69 6e 20 74 | 68 65 20 6f 6c 64 20 62 |nes in t|he old b|
|00005e70| 6c 6f 63 6b 0a 20 2a 20 | 77 68 69 63 68 20 61 72 |lock. * |which ar|
|00005e80| 65 20 6d 6f 6e 6f 74 6f | 6e 69 63 61 6c 6c 79 20 |e monoto|nically |
|00005e90| 69 6e 63 72 65 61 73 69 | 6e 67 20 62 79 20 6f 6e |increasi|ng by on|
|00005ea0| 65 20 69 6e 20 74 68 65 | 20 6e 65 77 20 66 69 6c |e in the| new fil|
|00005eb0| 65 2e 0a 20 2a 20 72 65 | 74 75 72 6e 73 20 2d 0a |e.. * re|turns -.|
|00005ec0| 20 2a 09 73 69 7a 65 20 | 6f 66 20 6f 6c 64 20 62 | *.size |of old b|
|00005ed0| 6c 6f 63 6b 0a 20 2a 2f | 0a 6f 6c 64 6d 6f 6e 20 |lock. */|.oldmon |
|00005ee0| 28 6f 6c 64 69 29 0a 09 | 69 6e 74 09 6f 6c 64 69 |(oldi)..|int.oldi|
|00005ef0| 3b 0a 7b 0a 09 69 6e 74 | 09 6f 73 69 7a 65 2c 09 |;.{..int|.osize,.|
|00005f00| 09 2f 2a 20 73 69 7a 65 | 20 6f 66 20 6f 6c 64 20 |./* size| of old |
|00005f10| 62 6c 6f 63 6b 09 09 09 | 2a 2f 0a 09 09 65 78 70 |block...|*/...exp|
|00005f20| 6e 65 77 2c 09 09 2f 2a | 20 6c 69 6e 65 20 6e 75 |new,../*| line nu|
|00005f30| 6d 62 65 72 20 65 78 70 | 65 63 74 65 64 20 69 6e |mber exp|ected in|
|00005f40| 20 6e 65 77 20 66 69 6c | 65 09 2a 2f 0a 09 09 63 | new fil|e.*/...c|
|00005f50| 75 72 6f 6c 64 6e 75 6d | 3b 09 2f 2a 20 63 75 72 |uroldnum|;./* cur|
|00005f60| 72 65 6e 74 20 6c 69 6e | 65 20 6e 75 6d 62 65 72 |rent lin|e number|
|00005f70| 20 69 6e 20 6f 6c 64 20 | 66 69 6c 65 09 2a 2f 0a | in old |file.*/.|
|00005f80| 0a 0a 09 63 75 72 6f 6c | 64 6e 75 6d 20 3d 20 6f |...curol|dnum = o|
|00005f90| 6c 64 69 3b 09 2f 2a 20 | 73 61 76 65 20 6f 6c 64 |ldi;./* |save old|
|00005fa0| 20 6c 69 6e 65 20 6e 75 | 6d 62 65 72 20 73 6f 20 | line nu|mber so |
|00005fb0| 63 61 6e 20 74 65 6c 6c | 0a 09 09 09 09 20 2a 20 |can tell|..... * |
|00005fc0| 68 6f 77 20 62 69 67 20 | 74 68 65 20 6f 6c 64 20 |how big |the old |
|00005fd0| 62 6c 6f 63 6b 20 69 73 | 20 61 74 20 74 68 65 20 |block is| at the |
|00005fe0| 65 6e 64 0a 09 09 09 09 | 20 2a 2f 0a 0a 09 64 6f |end.....| */...do|
|00005ff0| 0a 09 09 7b 0a 09 09 65 | 78 70 6e 65 77 20 3d 20 |...{...e|xpnew = |
|00006000| 6f 61 5b 63 75 72 6f 6c | 64 6e 75 6d 5d 2e 6c 69 |oa[curol|dnum].li|
|00006010| 6e 65 6c 6f 63 20 2b 20 | 31 3b 0a 09 09 2b 2b 63 |neloc + |1;...++c|
|00006020| 75 72 6f 6c 64 6e 75 6d | 3b 0a 09 09 7d 0a 09 77 |uroldnum|;...}..w|
|00006030| 68 69 6c 65 20 28 28 63 | 75 72 6f 6c 64 6e 75 6d |hile ((c|uroldnum|
|00006040| 20 3c 3d 20 6c 61 73 74 | 6f 6c 64 2b 31 29 09 09 | <= last|old+1)..|
|00006050| 09 2f 2a 20 69 6e 20 62 | 6f 75 6e 64 73 20 2a 2f |./* in b|ounds */|
|00006060| 0a 09 09 26 26 20 28 65 | 78 70 6e 65 77 20 3d 3d |...&& (e|xpnew ==|
|00006070| 20 6f 61 5b 63 75 72 6f | 6c 64 6e 75 6d 5d 2e 6c | oa[curo|ldnum].l|
|00006080| 69 6e 65 6c 6f 63 29 09 | 2f 2a 20 6d 6f 6e 6f 74 |ineloc).|/* monot|
|00006090| 6f 6e 69 63 61 6c 20 62 | 79 20 31 20 2a 2f 0a 09 |onical b|y 1 */..|
|000060a0| 09 26 26 20 28 6f 61 5b | 63 75 72 6f 6c 64 6e 75 |.&& (oa[|curoldnu|
|000060b0| 6d 5d 2e 66 6c 61 67 20 | 3d 3d 20 4c 5f 4c 49 4e |m].flag |== L_LIN|
|000060c0| 45 4e 55 4d 29 29 3b 09 | 2f 2a 20 6d 61 74 63 68 |ENUM));.|/* match|
|000060d0| 20 2a 2f 0a 0a 09 6f 73 | 69 7a 65 20 3d 20 63 75 | */...os|ize = cu|
|000060e0| 72 6f 6c 64 6e 75 6d 20 | 2d 20 6f 6c 64 69 3b 0a |roldnum |- oldi;.|
|000060f0| 0a 09 69 66 20 28 64 65 | 62 75 67 29 0a 09 09 70 |..if (de|bug)...p|
|00006100| 72 69 6e 74 66 20 28 22 | 64 65 62 75 67 3a 20 6c |rintf ("|debug: l|
|00006110| 69 6e 65 73 20 25 64 2d | 25 64 20 6f 66 20 6f 6c |ines %d-|%d of ol|
|00006120| 64 20 66 69 6c 65 20 61 | 72 65 20 6d 6f 6e 6f 74 |d file a|re monot|
|00006130| 6f 6e 69 63 61 6c 5c 6e | 22 2c 20 6f 6c 64 69 2c |onical\n|", oldi,|
|00006140| 20 63 75 72 6f 6c 64 6e | 75 6d 2d 31 29 3b 0a 0a | curoldn|um-1);..|
|00006150| 09 72 65 74 75 72 6e 20 | 6f 73 69 7a 65 3b 0a 7d |.return |osize;.}|
|00006160| 0a 0a 0a 6e 65 77 6d 6f | 6e 20 28 6e 65 77 69 29 |...newmo|n (newi)|
|00006170| 0a 09 69 6e 74 09 6e 65 | 77 69 3b 0a 7b 0a 09 69 |..int.ne|wi;.{..i|
|00006180| 6e 74 09 6e 73 69 7a 65 | 2c 09 09 2f 2a 20 73 69 |nt.nsize|,../* si|
|00006190| 7a 65 20 6f 66 20 6e 65 | 77 20 62 6c 6f 63 6b 09 |ze of ne|w block.|
|000061a0| 09 09 2a 2f 0a 09 09 65 | 78 70 6f 6c 64 2c 09 09 |..*/...e|xpold,..|
|000061b0| 2f 2a 20 6c 69 6e 65 20 | 6e 75 6d 62 65 72 20 65 |/* line |number e|
|000061c0| 78 70 65 63 74 65 64 20 | 69 6e 20 6f 6c 64 20 66 |xpected |in old f|
|000061d0| 69 6c 65 09 2a 2f 0a 09 | 09 63 75 72 6e 65 77 6e |ile.*/..|.curnewn|
|000061e0| 75 6d 3b 09 2f 2a 20 63 | 75 72 72 65 6e 74 20 6c |um;./* c|urrent l|
|000061f0| 69 6e 65 20 6e 75 6d 62 | 65 72 20 69 6e 20 6e 65 |ine numb|er in ne|
|00006200| 77 20 66 69 6c 65 09 2a | 2f 0a 0a 0a 09 63 75 72 |w file.*|/....cur|
|00006210| 6e 65 77 6e 75 6d 20 3d | 20 6e 65 77 69 3b 09 2f |newnum =| newi;./|
|00006220| 2a 20 73 61 76 65 20 6e | 65 77 20 6c 69 6e 65 20 |* save n|ew line |
|00006230| 6e 75 6d 62 65 72 20 73 | 6f 20 63 61 6e 20 74 65 |number s|o can te|
|00006240| 6c 6c 0a 09 09 09 09 20 | 2a 20 68 6f 77 20 62 69 |ll..... |* how bi|
|00006250| 67 20 74 68 65 20 6e 65 | 77 20 62 6c 6f 63 6b 20 |g the ne|w block |
|00006260| 69 73 20 61 74 20 74 68 | 65 20 65 6e 64 0a 09 09 |is at th|e end...|
|00006270| 09 09 20 2a 2f 0a 0a 09 | 64 6f 0a 09 09 7b 0a 09 |.. */...|do...{..|
|00006280| 09 65 78 70 6f 6c 64 20 | 3d 20 6e 61 5b 63 75 72 |.expold |= na[cur|
|00006290| 6e 65 77 6e 75 6d 5d 2e | 6c 69 6e 65 6c 6f 63 20 |newnum].|lineloc |
|000062a0| 2b 20 31 3b 0a 09 09 2b | 2b 63 75 72 6e 65 77 6e |+ 1;...+|+curnewn|
|000062b0| 75 6d 3b 0a 09 09 7d 0a | 09 77 68 69 6c 65 20 28 |um;...}.|.while (|
|000062c0| 28 63 75 72 6e 65 77 6e | 75 6d 20 3c 3d 20 6c 61 |(curnewn|um <= la|
|000062d0| 73 74 6e 65 77 2b 31 29 | 09 09 09 2f 2a 20 69 6e |stnew+1)|.../* in|
|000062e0| 20 62 6f 75 6e 64 73 20 | 2a 2f 0a 09 09 26 26 20 | bounds |*/...&& |
|000062f0| 28 65 78 70 6f 6c 64 20 | 3d 3d 20 6e 61 5b 63 75 |(expold |== na[cu|
|00006300| 72 6e 65 77 6e 75 6d 5d | 2e 6c 69 6e 65 6c 6f 63 |rnewnum]|.lineloc|
|00006310| 29 09 2f 2a 20 6d 6f 6e | 6f 74 6f 6e 69 63 61 6c |)./* mon|otonical|
|00006320| 20 62 79 20 31 20 2a 2f | 0a 09 09 26 26 20 28 6e | by 1 */|...&& (n|
|00006330| 61 5b 63 75 72 6e 65 77 | 6e 75 6d 5d 2e 66 6c 61 |a[curnew|num].fla|
|00006340| 67 20 3d 3d 20 4c 5f 4c | 49 4e 45 4e 55 4d 29 29 |g == L_L|INENUM))|
|00006350| 3b 09 2f 2a 20 6d 61 74 | 63 68 20 2a 2f 0a 0a 09 |;./* mat|ch */...|
|00006360| 6e 73 69 7a 65 20 3d 20 | 63 75 72 6e 65 77 6e 75 |nsize = |curnewnu|
|00006370| 6d 20 2d 20 6e 65 77 69 | 3b 0a 0a 09 69 66 20 28 |m - newi|;...if (|
|00006380| 64 65 62 75 67 29 0a 09 | 09 70 72 69 6e 74 66 20 |debug)..|.printf |
|00006390| 28 22 64 65 62 75 67 3a | 20 6c 69 6e 65 73 20 25 |("debug:| lines %|
|000063a0| 64 2d 25 64 20 6f 66 20 | 6e 65 77 20 66 69 6c 65 |d-%d of |new file|
|000063b0| 20 61 72 65 20 6d 6f 6e | 6f 74 6f 6e 69 63 61 6c | are mon|otonical|
|000063c0| 5c 6e 22 2c 20 6e 65 77 | 69 2c 20 63 75 72 6e 65 |\n", new|i, curne|
|000063d0| 77 6e 75 6d 2d 31 29 3b | 0a 0a 09 72 65 74 75 72 |wnum-1);|...retur|
|000063e0| 6e 20 6e 73 69 7a 65 3b | 0a 7d 0a 0a 0a 2f 2a 0a |n nsize;|.}.../*.|
|000063f0| 20 2a 20 65 61 74 20 6f | 6c 64 20 62 6c 6f 63 6b | * eat o|ld block|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.