home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: Tape Archive
(archive/tar).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| Tape Archive (archive/tar)
| magic
| Supported |
100%
| file
| POSIX tar archive (GNU)
| default
| |
99%
| file
| POSIX tar archive (GNU), directory diff/, mode 777 , uid 21623 , gid 0 , size 0 , seconds 4741735507, user mib
| default
| |
98%
| file
| data
| default
| |
41%
| TrID
| Sybase iAnywhere database files
| default (weak)
| |
36%
| TrID
| TAR - Tape ARchive (GNU)
| default
| |
21%
| TrID
| TAR - Tape ARchive (directory)
| default
| |
100%
| lsar
| Tar
| default
| |
100%
| gt2
| TAR Archiv gefunden (Auflistung ist deaktiviert)
| default
| |
100%
| disktype
| GNU tar archive
| default
| |
100%
| detectItEasy
| Archive: tar
| default
| |
100%
| binwalkID
| POSIX tar archive (GNU)
| default
| |
100%
| xdgMime
| application/x-tar
| default
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 64 69 66 66 2f 00 00 00 | 00 00 00 00 00 00 00 00 |diff/...|........|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000050| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000060| 00 00 00 00 20 20 20 37 | 37 37 20 00 20 32 31 36 |.... 7|77 . 216|
|00000070| 32 33 20 00 20 20 20 20 | 20 30 20 00 20 20 20 20 |23 . | 0 . |
|00000080| 20 20 20 20 20 20 30 20 | 20 34 37 34 31 37 33 35 | 0 | 4741735|
|00000090| 35 30 37 20 20 20 36 37 | 32 32 00 20 35 00 00 00 |507 67|22. 5...|
|000000a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000000f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000100| 00 75 73 74 61 72 20 20 | 00 6d 69 62 00 00 00 00 |.ustar |.mib....|
|00000110| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000120| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000130| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000140| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000150| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000160| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000170| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000180| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000190| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000200| 64 69 66 66 2f 64 69 66 | 66 2e 63 00 00 00 00 00 |diff/dif|f.c.....|
|00000210| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000220| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000230| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000240| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000250| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000260| 00 00 00 00 20 20 20 36 | 36 36 20 00 20 32 31 36 |.... 6|66 . 216|
|00000270| 32 33 20 00 20 20 20 20 | 20 30 20 00 20 20 20 20 |23 . | 0 . |
|00000280| 20 20 34 32 37 35 35 20 | 20 34 37 34 31 37 33 34 | 42755 | 4741734|
|00000290| 31 36 35 20 20 31 30 31 | 31 32 00 20 30 00 00 00 |165 101|12. 0...|
|000002a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000002f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000300| 00 75 73 74 61 72 20 20 | 00 6d 69 62 00 00 00 00 |.ustar |.mib....|
|00000310| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000320| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000330| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000340| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000350| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000360| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000370| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000380| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000390| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000400| 2f 2a 20 47 4e 55 20 44 | 49 46 46 20 6d 61 69 6e |/* GNU D|IFF main|
|00000410| 20 72 6f 75 74 69 6e 65 | 2e 0a 20 20 20 43 6f 70 | routine|.. Cop|
|00000420| 79 72 69 67 68 74 20 28 | 43 29 20 31 39 38 38 2c |yright (|C) 1988,|
|00000430| 20 31 39 38 39 20 46 72 | 65 65 20 53 6f 66 74 77 | 1989 Fr|ee Softw|
|00000440| 61 72 65 20 46 6f 75 6e | 64 61 74 69 6f 6e 2c 20 |are Foun|dation, |
|00000450| 49 6e 63 2e 0a 0a 54 68 | 69 73 20 66 69 6c 65 20 |Inc...Th|is file |
|00000460| 69 73 20 70 61 72 74 20 | 6f 66 20 47 4e 55 20 44 |is part |of GNU D|
|00000470| 49 46 46 2e 0a 0a 47 4e | 55 20 44 49 46 46 20 69 |IFF...GN|U DIFF i|
|00000480| 73 20 66 72 65 65 20 73 | 6f 66 74 77 61 72 65 3b |s free s|oftware;|
|00000490| 20 79 6f 75 20 63 61 6e | 20 72 65 64 69 73 74 72 | you can| redistr|
|000004a0| 69 62 75 74 65 20 69 74 | 20 61 6e 64 2f 6f 72 20 |ibute it| and/or |
|000004b0| 6d 6f 64 69 66 79 0a 69 | 74 20 75 6e 64 65 72 20 |modify.i|t under |
|000004c0| 74 68 65 20 74 65 72 6d | 73 20 6f 66 20 74 68 65 |the term|s of the|
|000004d0| 20 47 4e 55 20 47 65 6e | 65 72 61 6c 20 50 75 62 | GNU Gen|eral Pub|
|000004e0| 6c 69 63 20 4c 69 63 65 | 6e 73 65 20 61 73 20 70 |lic Lice|nse as p|
|000004f0| 75 62 6c 69 73 68 65 64 | 20 62 79 0a 74 68 65 20 |ublished| by.the |
|00000500| 46 72 65 65 20 53 6f 66 | 74 77 61 72 65 20 46 6f |Free Sof|tware Fo|
|00000510| 75 6e 64 61 74 69 6f 6e | 3b 20 65 69 74 68 65 72 |undation|; either|
|00000520| 20 76 65 72 73 69 6f 6e | 20 31 2c 20 6f 72 20 28 | version| 1, or (|
|00000530| 61 74 20 79 6f 75 72 20 | 6f 70 74 69 6f 6e 29 0a |at your |option).|
|00000540| 61 6e 79 20 6c 61 74 65 | 72 20 76 65 72 73 69 6f |any late|r versio|
|00000550| 6e 2e 0a 0a 47 4e 55 20 | 44 49 46 46 20 69 73 20 |n...GNU |DIFF is |
|00000560| 64 69 73 74 72 69 62 75 | 74 65 64 20 69 6e 20 74 |distribu|ted in t|
|00000570| 68 65 20 68 6f 70 65 20 | 74 68 61 74 20 69 74 20 |he hope |that it |
|00000580| 77 69 6c 6c 20 62 65 20 | 75 73 65 66 75 6c 2c 0a |will be |useful,.|
|00000590| 62 75 74 20 57 49 54 48 | 4f 55 54 20 41 4e 59 20 |but WITH|OUT ANY |
|000005a0| 57 41 52 52 41 4e 54 59 | 3b 20 77 69 74 68 6f 75 |WARRANTY|; withou|
|000005b0| 74 20 65 76 65 6e 20 74 | 68 65 20 69 6d 70 6c 69 |t even t|he impli|
|000005c0| 65 64 20 77 61 72 72 61 | 6e 74 79 20 6f 66 0a 4d |ed warra|nty of.M|
|000005d0| 45 52 43 48 41 4e 54 41 | 42 49 4c 49 54 59 20 6f |ERCHANTA|BILITY o|
|000005e0| 72 20 46 49 54 4e 45 53 | 53 20 46 4f 52 20 41 20 |r FITNES|S FOR A |
|000005f0| 50 41 52 54 49 43 55 4c | 41 52 20 50 55 52 50 4f |PARTICUL|AR PURPO|
|00000600| 53 45 2e 20 20 53 65 65 | 20 74 68 65 0a 47 4e 55 |SE. See| the.GNU|
|00000610| 20 47 65 6e 65 72 61 6c | 20 50 75 62 6c 69 63 20 | General| Public |
|00000620| 4c 69 63 65 6e 73 65 20 | 66 6f 72 20 6d 6f 72 65 |License |for more|
|00000630| 20 64 65 74 61 69 6c 73 | 2e 0a 0a 59 6f 75 20 73 | details|...You s|
|00000640| 68 6f 75 6c 64 20 68 61 | 76 65 20 72 65 63 65 69 |hould ha|ve recei|
|00000650| 76 65 64 20 61 20 63 6f | 70 79 20 6f 66 20 74 68 |ved a co|py of th|
|00000660| 65 20 47 4e 55 20 47 65 | 6e 65 72 61 6c 20 50 75 |e GNU Ge|neral Pu|
|00000670| 62 6c 69 63 20 4c 69 63 | 65 6e 73 65 0a 61 6c 6f |blic Lic|ense.alo|
|00000680| 6e 67 20 77 69 74 68 20 | 47 4e 55 20 44 49 46 46 |ng with |GNU DIFF|
|00000690| 3b 20 73 65 65 20 74 68 | 65 20 66 69 6c 65 20 43 |; see th|e file C|
|000006a0| 4f 50 59 49 4e 47 2e 20 | 20 49 66 20 6e 6f 74 2c |OPYING. | If not,|
|000006b0| 20 77 72 69 74 65 20 74 | 6f 0a 74 68 65 20 46 72 | write t|o.the Fr|
|000006c0| 65 65 20 53 6f 66 74 77 | 61 72 65 20 46 6f 75 6e |ee Softw|are Foun|
|000006d0| 64 61 74 69 6f 6e 2c 20 | 36 37 35 20 4d 61 73 73 |dation, |675 Mass|
|000006e0| 20 41 76 65 2c 20 43 61 | 6d 62 72 69 64 67 65 2c | Ave, Ca|mbridge,|
|000006f0| 20 4d 41 20 30 32 31 33 | 39 2c 20 55 53 41 2e 20 | MA 0213|9, USA. |
|00000700| 20 2a 2f 0a 0a 2f 2a 20 | 47 4e 55 20 44 49 46 46 | */../* |GNU DIFF|
|00000710| 20 77 61 73 20 77 72 69 | 74 74 65 6e 20 62 79 20 | was wri|tten by |
|00000720| 4d 69 6b 65 20 48 61 65 | 72 74 65 6c 2c 20 44 61 |Mike Hae|rtel, Da|
|00000730| 76 69 64 20 48 61 79 65 | 73 2c 0a 20 20 20 52 69 |vid Haye|s,. Ri|
|00000740| 63 68 61 72 64 20 53 74 | 61 6c 6c 6d 61 6e 20 61 |chard St|allman a|
|00000750| 6e 64 20 4c 65 6e 20 54 | 6f 77 65 72 2e 20 20 2a |nd Len T|ower. *|
|00000760| 2f 0a 0a 23 64 65 66 69 | 6e 65 20 47 44 49 46 46 |/..#defi|ne GDIFF|
|00000770| 5f 4d 41 49 4e 0a 23 69 | 6e 63 6c 75 64 65 20 22 |_MAIN.#i|nclude "|
|00000780| 72 65 67 65 78 2e 68 22 | 0a 23 69 6e 63 6c 75 64 |regex.h"|.#includ|
|00000790| 65 20 22 64 69 66 66 2e | 68 22 0a 23 69 6e 63 6c |e "diff.|h".#incl|
|000007a0| 75 64 65 20 22 67 65 74 | 6f 70 74 2e 68 22 0a 0a |ude "get|opt.h"..|
|000007b0| 0a 2f 2a 20 4e 6f 6e 7a | 65 72 6f 20 66 6f 72 20 |./* Nonz|ero for |
|000007c0| 2d 72 3a 20 69 66 20 63 | 6f 6d 70 61 72 69 6e 67 |-r: if c|omparing|
|000007d0| 20 74 77 6f 20 64 69 72 | 65 63 74 6f 72 69 65 73 | two dir|ectories|
|000007e0| 2c 0a 20 20 20 63 6f 6d | 70 61 72 65 20 74 68 65 |,. com|pare the|
|000007f0| 69 72 20 63 6f 6d 6d 6f | 6e 20 73 75 62 64 69 72 |ir commo|n subdir|
|00000800| 65 63 74 6f 72 69 65 73 | 20 72 65 63 75 72 73 69 |ectories| recursi|
|00000810| 76 65 6c 79 2e 20 20 2a | 2f 0a 0a 69 6e 74 20 72 |vely. *|/..int r|
|00000820| 65 63 75 72 73 69 76 65 | 3b 0a 0a 2f 2a 20 46 6f |ecursive|;../* Fo|
|00000830| 72 20 64 65 62 75 67 67 | 69 6e 67 3a 20 64 6f 6e |r debugg|ing: don|
|00000840| 27 74 20 64 6f 20 64 69 | 73 63 61 72 64 5f 63 6f |'t do di|scard_co|
|00000850| 6e 66 75 73 69 6e 67 5f | 6c 69 6e 65 73 2e 20 20 |nfusing_|lines. |
|00000860| 2a 2f 0a 0a 69 6e 74 20 | 6e 6f 5f 64 69 73 63 61 |*/..int |no_disca|
|00000870| 72 64 73 3b 0a 0a 2f 2a | 20 52 65 74 75 72 6e 20 |rds;../*| Return |
|00000880| 61 20 73 74 72 69 6e 67 | 20 63 6f 6e 74 61 69 6e |a string| contain|
|00000890| 69 6e 67 20 74 68 65 20 | 63 6f 6d 6d 61 6e 64 20 |ing the |command |
|000008a0| 6f 70 74 69 6f 6e 73 20 | 77 69 74 68 20 77 68 69 |options |with whi|
|000008b0| 63 68 20 64 69 66 66 20 | 77 61 73 20 69 6e 76 6f |ch diff |was invo|
|000008c0| 6b 65 64 2e 0a 20 20 20 | 53 70 61 63 65 73 20 61 |ked.. |Spaces a|
|000008d0| 70 70 65 61 72 20 62 65 | 74 77 65 65 6e 20 77 68 |ppear be|tween wh|
|000008e0| 61 74 20 77 65 72 65 20 | 73 65 70 61 72 61 74 65 |at were |separate|
|000008f0| 20 41 52 47 56 2d 65 6c | 65 6d 65 6e 74 73 2e 0a | ARGV-el|ements..|
|00000900| 20 20 20 54 68 65 72 65 | 20 69 73 20 61 20 73 70 | There| is a sp|
|00000910| 61 63 65 20 61 74 20 74 | 68 65 20 62 65 67 69 6e |ace at t|he begin|
|00000920| 6e 69 6e 67 20 62 75 74 | 20 6e 6f 6e 65 20 61 74 |ning but| none at|
|00000930| 20 74 68 65 20 65 6e 64 | 2e 0a 20 20 20 49 66 20 | the end|.. If |
|00000940| 74 68 65 72 65 20 77 65 | 72 65 20 6e 6f 20 6f 70 |there we|re no op|
|00000950| 74 69 6f 6e 73 2c 20 74 | 68 65 20 72 65 73 75 6c |tions, t|he resul|
|00000960| 74 20 69 73 20 61 6e 20 | 65 6d 70 74 79 20 73 74 |t is an |empty st|
|00000970| 72 69 6e 67 2e 0a 0a 20 | 20 20 41 72 67 75 6d 65 |ring... | Argume|
|00000980| 6e 74 73 3a 20 4f 50 54 | 49 4f 4e 56 45 43 2c 20 |nts: OPT|IONVEC, |
|00000990| 61 20 76 65 63 74 6f 72 | 20 63 6f 6e 74 61 69 6e |a vector| contain|
|000009a0| 69 6e 67 20 73 65 70 61 | 72 61 74 65 20 41 52 47 |ing sepa|rate ARG|
|000009b0| 56 2d 65 6c 65 6d 65 6e | 74 73 2c 20 61 6e 64 20 |V-elemen|ts, and |
|000009c0| 43 4f 55 4e 54 2c 0a 20 | 20 20 74 68 65 20 6c 65 |COUNT,. | the le|
|000009d0| 6e 67 74 68 20 6f 66 20 | 74 68 61 74 20 76 65 63 |ngth of |that vec|
|000009e0| 74 6f 72 2e 20 20 2a 2f | 0a 0a 73 74 61 74 69 63 |tor. */|..static|
|000009f0| 20 63 68 61 72 20 2a 0a | 6f 70 74 69 6f 6e 5f 6c | char *.|option_l|
|00000a00| 69 73 74 20 28 6f 70 74 | 69 6f 6e 76 65 63 2c 20 |ist (opt|ionvec, |
|00000a10| 63 6f 75 6e 74 29 0a 20 | 20 20 20 20 63 68 61 72 |count). | char|
|00000a20| 20 2a 2a 6f 70 74 69 6f | 6e 76 65 63 3b 20 20 2f | **optio|nvec; /|
|00000a30| 2a 20 57 61 73 20 60 76 | 65 63 74 6f 72 27 2c 20 |* Was `v|ector', |
|00000a40| 62 75 74 20 74 68 61 74 | 20 63 6f 6c 6c 69 64 65 |but that| collide|
|00000a50| 73 20 6f 6e 20 41 6c 6c | 69 61 6e 74 2e 20 20 2a |s on All|iant. *|
|00000a60| 2f 0a 20 20 20 20 20 69 | 6e 74 20 63 6f 75 6e 74 |/. i|nt count|
|00000a70| 3b 0a 7b 0a 20 20 69 6e | 74 20 69 3b 0a 20 20 69 |;.{. in|t i;. i|
|00000a80| 6e 74 20 6c 65 6e 67 74 | 68 20 3d 20 30 3b 0a 20 |nt lengt|h = 0;. |
|00000a90| 20 63 68 61 72 20 2a 72 | 65 73 75 6c 74 3b 0a 0a | char *r|esult;..|
|00000aa0| 20 20 66 6f 72 20 28 69 | 20 3d 20 30 3b 20 69 20 | for (i| = 0; i |
|00000ab0| 3c 20 63 6f 75 6e 74 3b | 20 69 2b 2b 29 0a 20 20 |< count;| i++). |
|00000ac0| 20 20 6c 65 6e 67 74 68 | 20 2b 3d 20 73 74 72 6c | length| += strl|
|00000ad0| 65 6e 20 28 6f 70 74 69 | 6f 6e 76 65 63 5b 69 5d |en (opti|onvec[i]|
|00000ae0| 29 20 2b 20 31 3b 0a 0a | 20 20 72 65 73 75 6c 74 |) + 1;..| result|
|00000af0| 20 3d 20 28 63 68 61 72 | 20 2a 29 20 78 6d 61 6c | = (char| *) xmal|
|00000b00| 6c 6f 63 20 28 6c 65 6e | 67 74 68 20 2b 20 31 29 |loc (len|gth + 1)|
|00000b10| 3b 0a 20 20 72 65 73 75 | 6c 74 5b 30 5d 20 3d 20 |;. resu|lt[0] = |
|00000b20| 30 3b 0a 0a 20 20 66 6f | 72 20 28 69 20 3d 20 30 |0;.. fo|r (i = 0|
|00000b30| 3b 20 69 20 3c 20 63 6f | 75 6e 74 3b 20 69 2b 2b |; i < co|unt; i++|
|00000b40| 29 0a 20 20 20 20 7b 0a | 20 20 20 20 20 20 73 74 |). {.| st|
|00000b50| 72 63 61 74 20 28 72 65 | 73 75 6c 74 2c 20 22 20 |rcat (re|sult, " |
|00000b60| 22 29 3b 0a 20 20 20 20 | 20 20 73 74 72 63 61 74 |");. | strcat|
|00000b70| 20 28 72 65 73 75 6c 74 | 2c 20 6f 70 74 69 6f 6e | (result|, option|
|00000b80| 76 65 63 5b 69 5d 29 3b | 0a 20 20 20 20 7d 0a 0a |vec[i]);|. }..|
|00000b90| 20 20 72 65 74 75 72 6e | 20 72 65 73 75 6c 74 3b | return| result;|
|00000ba0| 0a 7d 0a 0c 0a 2f 2a 20 | 54 68 65 20 6e 75 6d 62 |.}.../* |The numb|
|00000bb0| 65 72 73 20 31 32 39 20 | 61 6e 64 20 31 33 30 20 |ers 129 |and 130 |
|00000bc0| 74 68 61 74 20 61 70 70 | 65 61 72 20 69 6e 20 74 |that app|ear in t|
|00000bd0| 68 65 20 66 6f 75 72 74 | 68 20 65 6c 65 6d 65 6e |he fourt|h elemen|
|00000be0| 74 0a 20 20 20 66 6f 72 | 20 74 68 65 20 63 6f 6e |t. for| the con|
|00000bf0| 74 65 78 74 20 61 6e 64 | 20 75 6e 69 64 69 66 66 |text and| unidiff|
|00000c00| 20 65 6e 74 72 69 65 73 | 20 61 72 65 20 75 73 65 | entries| are use|
|00000c10| 64 20 61 73 20 61 20 77 | 61 79 20 6f 66 0a 20 20 |d as a w|ay of. |
|00000c20| 20 74 65 6c 6c 69 6e 67 | 20 74 68 65 20 62 69 67 | telling| the big|
|00000c30| 20 73 77 69 74 63 68 20 | 69 6e 20 60 6d 61 69 6e | switch |in `main|
|00000c40| 27 20 68 6f 77 20 74 6f | 20 70 72 6f 63 65 73 73 |' how to| process|
|00000c50| 20 74 68 6f 73 65 20 6f | 70 74 69 6f 6e 73 2e 20 | those o|ptions. |
|00000c60| 20 2a 2f 0a 0a 73 74 61 | 74 69 63 20 73 74 72 75 | */..sta|tic stru|
|00000c70| 63 74 20 6f 70 74 69 6f | 6e 20 6c 6f 6e 67 6f 70 |ct optio|n longop|
|00000c80| 74 73 5b 5d 20 3d 0a 7b | 0a 20 20 7b 22 69 67 6e |ts[] =.{|. {"ign|
|00000c90| 6f 72 65 2d 62 6c 61 6e | 6b 2d 6c 69 6e 65 73 22 |ore-blan|k-lines"|
|00000ca0| 2c 20 30 2c 20 30 2c 20 | 27 42 27 7d 2c 0a 20 20 |, 0, 0, |'B'},. |
|00000cb0| 7b 22 63 6f 6e 74 65 78 | 74 22 2c 20 32 2c 20 30 |{"contex|t", 2, 0|
|00000cc0| 2c 20 31 32 39 7d 2c 0a | 20 20 7b 22 69 66 64 65 |, 129},.| {"ifde|
|00000cd0| 66 22 2c 20 31 2c 20 30 | 2c 20 27 44 27 7d 2c 0a |f", 1, 0|, 'D'},.|
|00000ce0| 20 20 7b 22 73 68 6f 77 | 2d 66 75 6e 63 74 69 6f | {"show|-functio|
|00000cf0| 6e 2d 6c 69 6e 65 22 2c | 20 31 2c 20 30 2c 20 27 |n-line",| 1, 0, '|
|00000d00| 46 27 7d 2c 0a 20 20 7b | 22 73 70 65 65 64 2d 6c |F'},. {|"speed-l|
|00000d10| 61 72 67 65 2d 66 69 6c | 65 73 22 2c 20 30 2c 20 |arge-fil|es", 0, |
|00000d20| 30 2c 20 27 48 27 7d 2c | 0a 20 20 7b 22 69 67 6e |0, 'H'},|. {"ign|
|00000d30| 6f 72 65 2d 6d 61 74 63 | 68 69 6e 67 2d 6c 69 6e |ore-matc|hing-lin|
|00000d40| 65 73 22 2c 20 31 2c 20 | 30 2c 20 27 49 27 7d 2c |es", 1, |0, 'I'},|
|00000d50| 0a 20 20 7b 22 66 69 6c | 65 2d 6c 61 62 65 6c 22 |. {"fil|e-label"|
|00000d60| 2c 20 31 2c 20 30 2c 20 | 27 4c 27 7d 2c 0a 20 20 |, 1, 0, |'L'},. |
|00000d70| 7b 22 65 6e 74 69 72 65 | 2d 6e 65 77 2d 66 69 6c |{"entire|-new-fil|
|00000d80| 65 73 22 2c 20 30 2c 20 | 30 2c 20 27 4e 27 7d 2c |es", 0, |0, 'N'},|
|00000d90| 0a 20 20 7b 22 6e 65 77 | 2d 66 69 6c 65 73 22 2c |. {"new|-files",|
|00000da0| 20 30 2c 20 30 2c 20 27 | 4e 27 7d 2c 0a 20 20 7b | 0, 0, '|N'},. {|
|00000db0| 22 73 74 61 72 74 69 6e | 67 2d 66 69 6c 65 22 2c |"startin|g-file",|
|00000dc0| 20 31 2c 20 30 2c 20 27 | 53 27 7d 2c 0a 20 20 7b | 1, 0, '|S'},. {|
|00000dd0| 22 69 6e 69 74 69 61 6c | 2d 74 61 62 22 2c 20 30 |"initial|-tab", 0|
|00000de0| 2c 20 30 2c 20 27 54 27 | 7d 2c 0a 20 20 7b 22 74 |, 0, 'T'|},. {"t|
|00000df0| 65 78 74 22 2c 20 30 2c | 20 30 2c 20 27 61 27 7d |ext", 0,| 0, 'a'}|
|00000e00| 2c 0a 20 20 7b 22 61 6c | 6c 2d 74 65 78 74 22 2c |,. {"al|l-text",|
|00000e10| 20 30 2c 20 30 2c 20 27 | 61 27 7d 2c 0a 20 20 7b | 0, 0, '|a'},. {|
|00000e20| 22 61 73 63 69 69 22 2c | 20 30 2c 20 30 2c 20 27 |"ascii",| 0, 0, '|
|00000e30| 61 27 7d 2c 0a 20 20 7b | 22 69 67 6e 6f 72 65 2d |a'},. {|"ignore-|
|00000e40| 73 70 61 63 65 2d 63 68 | 61 6e 67 65 22 2c 20 30 |space-ch|ange", 0|
|00000e50| 2c 20 30 2c 20 27 62 27 | 7d 2c 0a 20 20 7b 22 6d |, 0, 'b'|},. {"m|
|00000e60| 69 6e 69 6d 61 6c 22 2c | 20 30 2c 20 30 2c 20 27 |inimal",| 0, 0, '|
|00000e70| 64 27 7d 2c 0a 20 20 7b | 22 65 64 22 2c 20 30 2c |d'},. {|"ed", 0,|
|00000e80| 20 30 2c 20 27 65 27 7d | 2c 0a 20 20 7b 22 72 65 | 0, 'e'}|,. {"re|
|00000e90| 76 65 72 73 65 64 2d 65 | 64 22 2c 20 30 2c 20 30 |versed-e|d", 0, 0|
|00000ea0| 2c 20 27 66 27 7d 2c 0a | 20 20 7b 22 69 67 6e 6f |, 'f'},.| {"igno|
|00000eb0| 72 65 2d 63 61 73 65 22 | 2c 20 30 2c 20 30 2c 20 |re-case"|, 0, 0, |
|00000ec0| 27 69 27 7d 2c 0a 20 20 | 7b 22 70 72 69 6e 74 22 |'i'},. |{"print"|
|00000ed0| 2c 20 30 2c 20 30 2c 20 | 27 6c 27 7d 2c 0a 20 20 |, 0, 0, |'l'},. |
|00000ee0| 7b 22 72 63 73 22 2c 20 | 30 2c 20 30 2c 20 27 6e |{"rcs", |0, 0, 'n|
|00000ef0| 27 7d 2c 0a 20 20 7b 22 | 73 68 6f 77 2d 63 2d 66 |'},. {"|show-c-f|
|00000f00| 75 6e 63 74 69 6f 6e 22 | 2c 20 30 2c 20 30 2c 20 |unction"|, 0, 0, |
|00000f10| 27 70 27 7d 2c 0a 20 20 | 7b 22 62 69 6e 61 72 79 |'p'},. |{"binary|
|00000f20| 22 2c 20 30 2c 20 30 2c | 20 27 71 27 7d 2c 0a 20 |", 0, 0,| 'q'},. |
|00000f30| 20 7b 22 62 72 69 65 66 | 22 2c 20 30 2c 20 30 2c | {"brief|", 0, 0,|
|00000f40| 20 27 71 27 7d 2c 0a 20 | 20 7b 22 72 65 63 75 72 | 'q'},. | {"recur|
|00000f50| 73 69 76 65 22 2c 20 30 | 2c 20 30 2c 20 27 72 27 |sive", 0|, 0, 'r'|
|00000f60| 7d 2c 0a 20 20 7b 22 72 | 65 70 6f 72 74 2d 69 64 |},. {"r|eport-id|
|00000f70| 65 6e 74 69 63 61 6c 2d | 66 69 6c 65 73 22 2c 20 |entical-|files", |
|00000f80| 30 2c 20 30 2c 20 27 73 | 27 7d 2c 0a 20 20 7b 22 |0, 0, 's|'},. {"|
|00000f90| 65 78 70 61 6e 64 2d 74 | 61 62 73 22 2c 20 30 2c |expand-t|abs", 0,|
|00000fa0| 20 30 2c 20 27 74 27 7d | 2c 0a 20 20 7b 22 69 67 | 0, 't'}|,. {"ig|
|00000fb0| 6e 6f 72 65 2d 61 6c 6c | 2d 73 70 61 63 65 22 2c |nore-all|-space",|
|00000fc0| 20 30 2c 20 30 2c 20 27 | 77 27 7d 2c 0a 20 20 7b | 0, 0, '|w'},. {|
|00000fd0| 22 75 6e 69 66 69 65 64 | 22 2c 20 32 2c 20 30 2c |"unified|", 2, 0,|
|00000fe0| 20 31 33 30 7d 2c 0a 20 | 20 7b 22 76 65 72 73 69 | 130},. | {"versi|
|00000ff0| 6f 6e 22 2c 20 30 2c 20 | 30 2c 20 27 76 27 7d 2c |on", 0, |0, 'v'},|
|00001000| 0a 20 20 7b 30 2c 20 30 | 2c 20 30 2c 20 30 7d 0a |. {0, 0|, 0, 0}.|
|00001010| 7d 3b 0a 0a 6d 61 69 6e | 20 28 61 72 67 63 2c 20 |};..main| (argc, |
|00001020| 61 72 67 76 29 0a 20 20 | 20 20 20 69 6e 74 20 61 |argv). | int a|
|00001030| 72 67 63 3b 0a 20 20 20 | 20 20 63 68 61 72 20 2a |rgc;. | char *|
|00001040| 61 72 67 76 5b 5d 3b 0a | 7b 0a 20 20 69 6e 74 20 |argv[];.|{. int |
|00001050| 76 61 6c 3b 0a 20 20 69 | 6e 74 20 63 3b 0a 20 20 |val;. i|nt c;. |
|00001060| 69 6e 74 20 70 72 65 76 | 20 3d 20 2d 31 3b 0a 20 |int prev| = -1;. |
|00001070| 20 69 6e 74 20 6c 6f 6e | 67 69 6e 64 3b 0a 20 20 | int lon|gind;. |
|00001080| 65 78 74 65 72 6e 20 63 | 68 61 72 20 2a 76 65 72 |extern c|har *ver|
|00001090| 73 69 6f 6e 5f 73 74 72 | 69 6e 67 3b 0a 0a 20 20 |sion_str|ing;.. |
|000010a0| 70 72 6f 67 72 61 6d 20 | 3d 20 61 72 67 76 5b 30 |program |= argv[0|
|000010b0| 5d 3b 0a 0a 20 20 2f 2a | 20 44 6f 20 6f 75 72 20 |];.. /*| Do our |
|000010c0| 69 6e 69 74 69 61 6c 69 | 7a 61 74 69 6f 6e 73 2e |initiali|zations.|
|000010d0| 20 2a 2f 0a 20 20 6f 75 | 74 70 75 74 5f 73 74 79 | */. ou|tput_sty|
|000010e0| 6c 65 20 3d 20 4f 55 54 | 50 55 54 5f 4e 4f 52 4d |le = OUT|PUT_NORM|
|000010f0| 41 4c 3b 0a 20 20 61 6c | 77 61 79 73 5f 74 65 78 |AL;. al|ways_tex|
|00001100| 74 5f 66 6c 61 67 20 3d | 20 46 41 4c 53 45 3b 0a |t_flag =| FALSE;.|
|00001110| 20 20 69 67 6e 6f 72 65 | 5f 73 70 61 63 65 5f 63 | ignore|_space_c|
|00001120| 68 61 6e 67 65 5f 66 6c | 61 67 20 3d 20 46 41 4c |hange_fl|ag = FAL|
|00001130| 53 45 3b 0a 20 20 69 67 | 6e 6f 72 65 5f 61 6c 6c |SE;. ig|nore_all|
|00001140| 5f 73 70 61 63 65 5f 66 | 6c 61 67 20 3d 20 46 41 |_space_f|lag = FA|
|00001150| 4c 53 45 3b 0a 20 20 6c | 65 6e 67 74 68 5f 76 61 |LSE;. l|ength_va|
|00001160| 72 69 65 73 20 3d 20 46 | 41 4c 53 45 3b 0a 20 20 |ries = F|ALSE;. |
|00001170| 69 67 6e 6f 72 65 5f 63 | 61 73 65 5f 66 6c 61 67 |ignore_c|ase_flag|
|00001180| 20 3d 20 46 41 4c 53 45 | 3b 0a 20 20 69 67 6e 6f | = FALSE|;. igno|
|00001190| 72 65 5f 62 6c 61 6e 6b | 5f 6c 69 6e 65 73 5f 66 |re_blank|_lines_f|
|000011a0| 6c 61 67 20 3d 20 46 41 | 4c 53 45 3b 0a 20 20 69 |lag = FA|LSE;. i|
|000011b0| 67 6e 6f 72 65 5f 72 65 | 67 65 78 70 20 3d 20 30 |gnore_re|gexp = 0|
|000011c0| 3b 0a 20 20 66 75 6e 63 | 74 69 6f 6e 5f 72 65 67 |;. func|tion_reg|
|000011d0| 65 78 70 20 3d 20 30 3b | 0a 20 20 70 72 69 6e 74 |exp = 0;|. print|
|000011e0| 5f 66 69 6c 65 5f 73 61 | 6d 65 5f 66 6c 61 67 20 |_file_sa|me_flag |
|000011f0| 3d 20 46 41 4c 53 45 3b | 0a 20 20 65 6e 74 69 72 |= FALSE;|. entir|
|00001200| 65 5f 6e 65 77 5f 66 69 | 6c 65 5f 66 6c 61 67 20 |e_new_fi|le_flag |
|00001210| 3d 20 46 41 4c 53 45 3b | 0a 20 20 6e 6f 5f 64 65 |= FALSE;|. no_de|
|00001220| 74 61 69 6c 73 5f 66 6c | 61 67 20 3d 20 46 41 4c |tails_fl|ag = FAL|
|00001230| 53 45 3b 0a 20 20 63 6f | 6e 74 65 78 74 20 3d 20 |SE;. co|ntext = |
|00001240| 2d 31 3b 0a 20 20 6c 69 | 6e 65 5f 65 6e 64 5f 63 |-1;. li|ne_end_c|
|00001250| 68 61 72 20 3d 20 27 5c | 6e 27 3b 0a 20 20 74 61 |har = '\|n';. ta|
|00001260| 62 5f 61 6c 69 67 6e 5f | 66 6c 61 67 20 3d 20 46 |b_align_|flag = F|
|00001270| 41 4c 53 45 3b 0a 20 20 | 74 61 62 5f 65 78 70 61 |ALSE;. |tab_expa|
|00001280| 6e 64 5f 66 6c 61 67 20 | 3d 20 46 41 4c 53 45 3b |nd_flag |= FALSE;|
|00001290| 0a 20 20 72 65 63 75 72 | 73 69 76 65 20 3d 20 46 |. recur|sive = F|
|000012a0| 41 4c 53 45 3b 0a 20 20 | 70 61 67 69 6e 61 74 65 |ALSE;. |paginate|
|000012b0| 5f 66 6c 61 67 20 3d 20 | 46 41 4c 53 45 3b 0a 20 |_flag = |FALSE;. |
|000012c0| 20 69 66 64 65 66 5f 73 | 74 72 69 6e 67 20 3d 20 | ifdef_s|tring = |
|000012d0| 4e 55 4c 4c 3b 0a 20 20 | 68 65 75 72 69 73 74 69 |NULL;. |heuristi|
|000012e0| 63 20 3d 20 46 41 4c 53 | 45 3b 0a 20 20 64 69 72 |c = FALS|E;. dir|
|000012f0| 5f 73 74 61 72 74 5f 66 | 69 6c 65 20 3d 20 4e 55 |_start_f|ile = NU|
|00001300| 4c 4c 3b 0a 20 20 6d 73 | 67 5f 63 68 61 69 6e 20 |LL;. ms|g_chain |
|00001310| 3d 20 4e 55 4c 4c 3b 0a | 20 20 6d 73 67 5f 63 68 |= NULL;.| msg_ch|
|00001320| 61 69 6e 5f 65 6e 64 20 | 3d 20 4e 55 4c 4c 3b 0a |ain_end |= NULL;.|
|00001330| 20 20 6e 6f 5f 64 69 73 | 63 61 72 64 73 20 3d 20 | no_dis|cards = |
|00001340| 30 3b 0a 0a 20 20 2f 2a | 20 44 65 63 6f 64 65 20 |0;.. /*| Decode |
|00001350| 74 68 65 20 6f 70 74 69 | 6f 6e 73 2e 20 20 2a 2f |the opti|ons. */|
|00001360| 0a 0a 20 20 77 68 69 6c | 65 20 28 28 63 20 3d 20 |.. whil|e ((c = |
|00001370| 67 65 74 6f 70 74 5f 6c | 6f 6e 67 20 28 61 72 67 |getopt_l|ong (arg|
|00001380| 63 2c 20 61 72 67 76 2c | 0a 09 09 09 20 20 20 22 |c, argv,|.... "|
|00001390| 30 31 32 33 34 35 36 37 | 38 39 61 62 42 63 43 3a |01234567|89abBcC:|
|000013a0| 64 44 3a 65 66 46 3a 68 | 48 69 49 3a 6c 4c 3a 6e |dD:efF:h|HiI:lL:n|
|000013b0| 4e 70 71 72 73 53 3a 74 | 54 75 76 77 22 2c 0a 09 |NpqrsS:t|Tuvw",..|
|000013c0| 09 09 20 20 20 6c 6f 6e | 67 6f 70 74 73 2c 20 26 |.. lon|gopts, &|
|000013d0| 6c 6f 6e 67 69 6e 64 29 | 29 20 21 3d 20 45 4f 46 |longind)|) != EOF|
|000013e0| 29 0a 20 20 20 20 7b 0a | 20 20 20 20 20 20 69 66 |). {.| if|
|000013f0| 20 28 63 20 3d 3d 20 30 | 29 09 09 2f 2a 20 4c 6f | (c == 0|)../* Lo|
|00001400| 6e 67 20 6f 70 74 69 6f | 6e 2e 20 2a 2f 0a 09 63 |ng optio|n. */..c|
|00001410| 20 3d 20 6c 6f 6e 67 6f | 70 74 73 5b 6c 6f 6e 67 | = longo|pts[long|
|00001420| 69 6e 64 5d 2e 76 61 6c | 3b 0a 20 20 20 20 20 20 |ind].val|;. |
|00001430| 73 77 69 74 63 68 20 28 | 63 29 0a 09 7b 0a 09 20 |switch (|c)..{.. |
|00001440| 20 2f 2a 20 41 6c 6c 20 | 64 69 67 69 74 73 20 63 | /* All |digits c|
|00001450| 6f 6d 62 69 6e 65 20 69 | 6e 20 64 65 63 69 6d 61 |ombine i|n decima|
|00001460| 6c 20 74 6f 20 73 70 65 | 63 69 66 79 20 74 68 65 |l to spe|cify the|
|00001470| 20 63 6f 6e 74 65 78 74 | 2d 73 69 7a 65 2e 20 20 | context|-size. |
|00001480| 2a 2f 0a 09 63 61 73 65 | 20 27 31 27 3a 0a 09 63 |*/..case| '1':..c|
|00001490| 61 73 65 20 27 32 27 3a | 0a 09 63 61 73 65 20 27 |ase '2':|..case '|
|000014a0| 33 27 3a 0a 09 63 61 73 | 65 20 27 34 27 3a 0a 09 |3':..cas|e '4':..|
|000014b0| 63 61 73 65 20 27 35 27 | 3a 0a 09 63 61 73 65 20 |case '5'|:..case |
|000014c0| 27 36 27 3a 0a 09 63 61 | 73 65 20 27 37 27 3a 0a |'6':..ca|se '7':.|
|000014d0| 09 63 61 73 65 20 27 38 | 27 3a 0a 09 63 61 73 65 |.case '8|':..case|
|000014e0| 20 27 39 27 3a 0a 09 63 | 61 73 65 20 27 30 27 3a | '9':..c|ase '0':|
|000014f0| 0a 09 20 20 69 66 20 28 | 63 6f 6e 74 65 78 74 20 |.. if (|context |
|00001500| 3d 3d 20 2d 31 29 0a 09 | 20 20 20 20 63 6f 6e 74 |== -1)..| cont|
|00001510| 65 78 74 20 3d 20 30 3b | 0a 09 20 20 2f 2a 20 49 |ext = 0;|.. /* I|
|00001520| 66 20 61 20 63 6f 6e 74 | 65 78 74 20 6c 65 6e 67 |f a cont|ext leng|
|00001530| 74 68 20 68 61 73 20 61 | 6c 72 65 61 64 79 20 62 |th has a|lready b|
|00001540| 65 65 6e 20 73 70 65 63 | 69 66 69 65 64 2c 0a 09 |een spec|ified,..|
|00001550| 20 20 20 20 20 6d 6f 72 | 65 20 64 69 67 69 74 73 | mor|e digits|
|00001560| 20 61 6c 6c 6f 77 65 64 | 20 6f 6e 6c 79 20 69 66 | allowed| only if|
|00001570| 20 74 68 65 79 20 66 6f | 6c 6c 6f 77 20 72 69 67 | they fo|llow rig|
|00001580| 68 74 20 61 66 74 65 72 | 20 74 68 65 20 6f 74 68 |ht after| the oth|
|00001590| 65 72 73 2e 0a 09 20 20 | 20 20 20 52 65 6a 65 63 |ers... | Rejec|
|000015a0| 74 20 74 77 6f 20 73 65 | 70 61 72 61 74 65 20 72 |t two se|parate r|
|000015b0| 75 6e 73 20 6f 66 20 64 | 69 67 69 74 73 2c 20 6f |uns of d|igits, o|
|000015c0| 72 20 64 69 67 69 74 73 | 20 61 66 74 65 72 20 2d |r digits| after -|
|000015d0| 43 2e 20 20 2a 2f 0a 09 | 20 20 65 6c 73 65 20 69 |C. */..| else i|
|000015e0| 66 20 28 70 72 65 76 20 | 3c 20 27 30 27 20 7c 7c |f (prev |< '0' |||
|000015f0| 20 70 72 65 76 20 3e 20 | 27 39 27 29 0a 09 20 20 | prev > |'9').. |
|00001600| 20 20 66 61 74 61 6c 20 | 28 22 63 6f 6e 74 65 78 | fatal |("contex|
|00001610| 74 20 6c 65 6e 67 74 68 | 20 73 70 65 63 69 66 69 |t length| specifi|
|00001620| 65 64 20 74 77 69 63 65 | 22 29 3b 0a 0a 09 20 20 |ed twice|");... |
|00001630| 63 6f 6e 74 65 78 74 20 | 3d 20 63 6f 6e 74 65 78 |context |= contex|
|00001640| 74 20 2a 20 31 30 20 2b | 20 63 20 2d 20 27 30 27 |t * 10 +| c - '0'|
|00001650| 3b 0a 09 20 20 62 72 65 | 61 6b 3b 0a 0a 09 63 61 |;.. bre|ak;...ca|
|00001660| 73 65 20 27 61 27 3a 0a | 09 20 20 2f 2a 20 54 72 |se 'a':.|. /* Tr|
|00001670| 65 61 74 20 61 6c 6c 20 | 66 69 6c 65 73 20 61 73 |eat all |files as|
|00001680| 20 74 65 78 74 20 66 69 | 6c 65 73 3b 20 6e 65 76 | text fi|les; nev|
|00001690| 65 72 20 74 72 65 61 74 | 20 61 73 20 62 69 6e 61 |er treat| as bina|
|000016a0| 72 79 2e 20 20 2a 2f 0a | 09 20 20 61 6c 77 61 79 |ry. */.|. alway|
|000016b0| 73 5f 74 65 78 74 5f 66 | 6c 61 67 20 3d 20 31 3b |s_text_f|lag = 1;|
|000016c0| 0a 09 20 20 62 72 65 61 | 6b 3b 0a 0a 09 63 61 73 |.. brea|k;...cas|
|000016d0| 65 20 27 62 27 3a 0a 09 | 20 20 2f 2a 20 49 67 6e |e 'b':..| /* Ign|
|000016e0| 6f 72 65 20 63 68 61 6e | 67 65 73 20 69 6e 20 61 |ore chan|ges in a|
|000016f0| 6d 6f 75 6e 74 20 6f 66 | 20 77 68 69 74 65 73 70 |mount of| whitesp|
|00001700| 61 63 65 2e 20 20 2a 2f | 0a 09 20 20 69 67 6e 6f |ace. */|.. igno|
|00001710| 72 65 5f 73 70 61 63 65 | 5f 63 68 61 6e 67 65 5f |re_space|_change_|
|00001720| 66 6c 61 67 20 3d 20 31 | 3b 0a 09 20 20 6c 65 6e |flag = 1|;.. len|
|00001730| 67 74 68 5f 76 61 72 69 | 65 73 20 3d 20 31 3b 0a |gth_vari|es = 1;.|
|00001740| 09 20 20 62 72 65 61 6b | 3b 0a 0a 09 63 61 73 65 |. break|;...case|
|00001750| 20 27 42 27 3a 0a 09 20 | 20 2f 2a 20 49 67 6e 6f | 'B':.. | /* Igno|
|00001760| 72 65 20 63 68 61 6e 67 | 65 73 20 61 66 66 65 63 |re chang|es affec|
|00001770| 74 69 6e 67 20 6f 6e 6c | 79 20 62 6c 61 6e 6b 20 |ting onl|y blank |
|00001780| 6c 69 6e 65 73 2e 20 20 | 2a 2f 0a 09 20 20 69 67 |lines. |*/.. ig|
|00001790| 6e 6f 72 65 5f 62 6c 61 | 6e 6b 5f 6c 69 6e 65 73 |nore_bla|nk_lines|
|000017a0| 5f 66 6c 61 67 20 3d 20 | 31 3b 0a 09 20 20 62 72 |_flag = |1;.. br|
|000017b0| 65 61 6b 3b 0a 0a 09 63 | 61 73 65 20 27 43 27 3a |eak;...c|ase 'C':|
|000017c0| 0a 09 63 61 73 65 20 31 | 32 39 3a 09 09 2f 2a 20 |..case 1|29:../* |
|000017d0| 2b 63 6f 6e 74 65 78 74 | 5b 3d 6c 69 6e 65 73 5d |+context|[=lines]|
|000017e0| 20 2a 2f 0a 09 63 61 73 | 65 20 31 33 30 3a 09 09 | */..cas|e 130:..|
|000017f0| 2f 2a 20 2b 75 6e 69 66 | 69 65 64 5b 3d 6c 69 6e |/* +unif|ied[=lin|
|00001800| 65 73 5d 20 2a 2f 0a 09 | 20 20 69 66 20 28 6f 70 |es] */..| if (op|
|00001810| 74 61 72 67 29 0a 09 20 | 20 20 20 7b 0a 09 20 20 |targ).. | {.. |
|00001820| 20 20 20 20 69 66 20 28 | 63 6f 6e 74 65 78 74 20 | if (|context |
|00001830| 3e 3d 20 30 29 0a 09 09 | 66 61 74 61 6c 20 28 22 |>= 0)...|fatal ("|
|00001840| 63 6f 6e 74 65 78 74 20 | 6c 65 6e 67 74 68 20 73 |context |length s|
|00001850| 70 65 63 69 66 69 65 64 | 20 74 77 69 63 65 22 29 |pecified| twice")|
|00001860| 3b 0a 09 20 20 20 20 20 | 20 7b 0a 09 09 63 68 61 |;.. | {...cha|
|00001870| 72 20 2a 70 3b 0a 09 09 | 66 6f 72 20 28 70 20 3d |r *p;...|for (p =|
|00001880| 20 6f 70 74 61 72 67 3b | 20 2a 70 3b 20 70 2b 2b | optarg;| *p; p++|
|00001890| 29 0a 09 09 20 20 69 66 | 20 28 2a 70 20 3c 20 27 |)... if| (*p < '|
|000018a0| 30 27 20 7c 7c 20 2a 70 | 20 3e 20 27 39 27 29 0a |0' || *p| > '9').|
|000018b0| 09 09 20 20 20 20 66 61 | 74 61 6c 20 28 22 69 6e |.. fa|tal ("in|
|000018c0| 76 61 6c 69 64 20 63 6f | 6e 74 65 78 74 20 6c 65 |valid co|ntext le|
|000018d0| 6e 67 74 68 20 61 72 67 | 75 6d 65 6e 74 22 29 3b |ngth arg|ument");|
|000018e0| 0a 09 20 20 20 20 20 20 | 7d 0a 09 20 20 20 20 20 |.. |}.. |
|000018f0| 20 63 6f 6e 74 65 78 74 | 20 3d 20 61 74 6f 69 20 | context| = atoi |
|00001900| 28 6f 70 74 61 72 67 29 | 3b 0a 09 20 20 20 20 7d |(optarg)|;.. }|
|00001910| 0a 0a 09 20 20 2f 2a 20 | 46 61 6c 6c 73 20 74 68 |... /* |Falls th|
|00001920| 72 6f 75 67 68 2e 20 20 | 2a 2f 0a 09 63 61 73 65 |rough. |*/..case|
|00001930| 20 27 63 27 3a 0a 09 20 | 20 2f 2a 20 4d 61 6b 65 | 'c':.. | /* Make|
|00001940| 20 63 6f 6e 74 65 78 74 | 2d 73 74 79 6c 65 20 6f | context|-style o|
|00001950| 75 74 70 75 74 2e 20 20 | 2a 2f 0a 09 20 20 73 70 |utput. |*/.. sp|
|00001960| 65 63 69 66 79 5f 73 74 | 79 6c 65 20 28 63 20 3d |ecify_st|yle (c =|
|00001970| 3d 20 31 33 30 20 3f 20 | 4f 55 54 50 55 54 5f 55 |= 130 ? |OUTPUT_U|
|00001980| 4e 49 46 49 45 44 20 3a | 20 4f 55 54 50 55 54 5f |NIFIED :| OUTPUT_|
|00001990| 43 4f 4e 54 45 58 54 29 | 3b 0a 09 20 20 62 72 65 |CONTEXT)|;.. bre|
|000019a0| 61 6b 3b 0a 0a 09 63 61 | 73 65 20 27 64 27 3a 0a |ak;...ca|se 'd':.|
|000019b0| 09 20 20 2f 2a 20 44 6f | 6e 27 74 20 64 69 73 63 |. /* Do|n't disc|
|000019c0| 61 72 64 20 6c 69 6e 65 | 73 2e 20 20 54 68 69 73 |ard line|s. This|
|000019d0| 20 6d 61 6b 65 73 20 74 | 68 69 6e 67 73 20 73 6c | makes t|hings sl|
|000019e0| 6f 77 65 72 20 28 73 6f | 6d 65 74 69 6d 65 73 20 |ower (so|metimes |
|000019f0| 6d 75 63 68 0a 09 20 20 | 20 20 20 73 6c 6f 77 65 |much.. | slowe|
|00001a00| 72 29 20 62 75 74 20 77 | 69 6c 6c 20 66 69 6e 64 |r) but w|ill find|
|00001a10| 20 61 20 67 75 61 72 61 | 6e 74 65 65 64 20 6d 69 | a guara|nteed mi|
|00001a20| 6e 69 6d 61 6c 20 73 65 | 74 20 6f 66 20 63 68 61 |nimal se|t of cha|
|00001a30| 6e 67 65 73 2e 20 20 2a | 2f 0a 09 20 20 6e 6f 5f |nges. *|/.. no_|
|00001a40| 64 69 73 63 61 72 64 73 | 20 3d 20 31 3b 0a 09 20 |discards| = 1;.. |
|00001a50| 20 62 72 65 61 6b 3b 0a | 0a 09 63 61 73 65 20 27 | break;.|..case '|
|00001a60| 44 27 3a 0a 09 20 20 2f | 2a 20 4d 61 6b 65 20 6d |D':.. /|* Make m|
|00001a70| 65 72 67 65 64 20 23 69 | 66 64 65 66 20 6f 75 74 |erged #i|fdef out|
|00001a80| 70 75 74 2e 20 20 2a 2f | 0a 09 20 20 73 70 65 63 |put. */|.. spec|
|00001a90| 69 66 79 5f 73 74 79 6c | 65 20 28 4f 55 54 50 55 |ify_styl|e (OUTPU|
|00001aa0| 54 5f 49 46 44 45 46 29 | 3b 0a 09 20 20 69 66 64 |T_IFDEF)|;.. ifd|
|00001ab0| 65 66 5f 73 74 72 69 6e | 67 20 3d 20 6f 70 74 61 |ef_strin|g = opta|
|00001ac0| 72 67 3b 0a 09 20 20 62 | 72 65 61 6b 3b 0a 0a 09 |rg;.. b|reak;...|
|00001ad0| 63 61 73 65 20 27 65 27 | 3a 0a 09 20 20 2f 2a 20 |case 'e'|:.. /* |
|00001ae0| 4d 61 6b 65 20 6f 75 74 | 70 75 74 20 74 68 61 74 |Make out|put that|
|00001af0| 20 69 73 20 61 20 76 61 | 6c 69 64 20 60 65 64 27 | is a va|lid `ed'|
|00001b00| 20 73 63 72 69 70 74 2e | 20 20 2a 2f 0a 09 20 20 | script.| */.. |
|00001b10| 73 70 65 63 69 66 79 5f | 73 74 79 6c 65 20 28 4f |specify_|style (O|
|00001b20| 55 54 50 55 54 5f 45 44 | 29 3b 0a 09 20 20 62 72 |UTPUT_ED|);.. br|
|00001b30| 65 61 6b 3b 0a 0a 09 63 | 61 73 65 20 27 66 27 3a |eak;...c|ase 'f':|
|00001b40| 0a 09 20 20 2f 2a 20 4d | 61 6b 65 20 6f 75 74 70 |.. /* M|ake outp|
|00001b50| 75 74 20 74 68 61 74 20 | 6c 6f 6f 6b 73 20 76 61 |ut that |looks va|
|00001b60| 67 75 65 6c 79 20 6c 69 | 6b 65 20 61 6e 20 60 65 |guely li|ke an `e|
|00001b70| 64 27 20 73 63 72 69 70 | 74 0a 09 20 20 20 20 20 |d' scrip|t.. |
|00001b80| 62 75 74 20 68 61 73 20 | 63 68 61 6e 67 65 73 20 |but has |changes |
|00001b90| 69 6e 20 74 68 65 20 6f | 72 64 65 72 20 74 68 65 |in the o|rder the|
|00001ba0| 79 20 61 70 70 65 61 72 | 20 69 6e 20 74 68 65 20 |y appear| in the |
|00001bb0| 66 69 6c 65 2e 20 20 2a | 2f 0a 09 20 20 73 70 65 |file. *|/.. spe|
|00001bc0| 63 69 66 79 5f 73 74 79 | 6c 65 20 28 4f 55 54 50 |cify_sty|le (OUTP|
|00001bd0| 55 54 5f 46 4f 52 57 41 | 52 44 5f 45 44 29 3b 0a |UT_FORWA|RD_ED);.|
|00001be0| 09 20 20 62 72 65 61 6b | 3b 0a 0a 09 63 61 73 65 |. break|;...case|
|00001bf0| 20 27 46 27 3a 0a 09 20 | 20 2f 2a 20 53 68 6f 77 | 'F':.. | /* Show|
|00001c00| 2c 20 66 6f 72 20 65 61 | 63 68 20 73 65 74 20 6f |, for ea|ch set o|
|00001c10| 66 20 63 68 61 6e 67 65 | 73 2c 20 74 68 65 20 70 |f change|s, the p|
|00001c20| 72 65 76 69 6f 75 73 20 | 6c 69 6e 65 20 74 68 61 |revious |line tha|
|00001c30| 74 0a 09 20 20 20 20 20 | 6d 61 74 63 68 65 73 20 |t.. |matches |
|00001c40| 74 68 65 20 73 70 65 63 | 69 66 69 65 64 20 72 65 |the spec|ified re|
|00001c50| 67 65 78 70 2e 20 20 43 | 75 72 72 65 6e 74 6c 79 |gexp. C|urrently|
|00001c60| 20 61 66 66 65 63 74 73 | 20 6f 6e 6c 79 0a 09 20 | affects| only.. |
|00001c70| 20 20 20 20 63 6f 6e 74 | 65 78 74 2d 73 74 79 6c | cont|ext-styl|
|00001c80| 65 20 6f 75 74 70 75 74 | 2e 20 20 2a 2f 0a 09 20 |e output|. */.. |
|00001c90| 20 66 75 6e 63 74 69 6f | 6e 5f 72 65 67 65 78 70 | functio|n_regexp|
|00001ca0| 20 3d 20 6f 70 74 61 72 | 67 3b 0a 09 20 20 62 72 | = optar|g;.. br|
|00001cb0| 65 61 6b 3b 0a 0a 09 63 | 61 73 65 20 27 68 27 3a |eak;...c|ase 'h':|
|00001cc0| 0a 09 20 20 2f 2a 20 53 | 70 6c 69 74 20 74 68 65 |.. /* S|plit the|
|00001cd0| 20 66 69 6c 65 73 20 69 | 6e 74 6f 20 63 68 75 6e | files i|nto chun|
|00001ce0| 6b 73 20 6f 66 20 61 72 | 6f 75 6e 64 20 31 35 30 |ks of ar|ound 150|
|00001cf0| 30 20 6c 69 6e 65 73 0a | 09 20 20 20 20 20 66 6f |0 lines.|. fo|
|00001d00| 72 20 66 61 73 74 65 72 | 20 70 72 6f 63 65 73 73 |r faster| process|
|00001d10| 69 6e 67 2e 20 20 55 73 | 75 61 6c 6c 79 20 64 6f |ing. Us|ually do|
|00001d20| 65 73 20 6e 6f 74 20 63 | 68 61 6e 67 65 20 74 68 |es not c|hange th|
|00001d30| 65 20 72 65 73 75 6c 74 | 2e 0a 0a 09 20 20 20 20 |e result|.... |
|00001d40| 20 54 68 69 73 20 63 75 | 72 72 65 6e 74 6c 79 20 | This cu|rrently |
|00001d50| 68 61 73 20 6e 6f 20 65 | 66 66 65 63 74 2e 20 20 |has no e|ffect. |
|00001d60| 2a 2f 0a 09 20 20 62 72 | 65 61 6b 3b 0a 0a 09 63 |*/.. br|eak;...c|
|00001d70| 61 73 65 20 27 48 27 3a | 0a 09 20 20 2f 2a 20 54 |ase 'H':|.. /* T|
|00001d80| 75 72 6e 20 6f 6e 20 68 | 65 75 72 69 73 74 69 63 |urn on h|euristic|
|00001d90| 73 20 74 68 61 74 20 73 | 70 65 65 64 20 70 72 6f |s that s|peed pro|
|00001da0| 63 65 73 73 69 6e 67 20 | 6f 66 20 6c 61 72 67 65 |cessing |of large|
|00001db0| 20 66 69 6c 65 73 0a 09 | 20 20 20 20 20 77 69 74 | files..| wit|
|00001dc0| 68 20 61 20 73 6d 61 6c | 6c 20 64 65 6e 73 69 74 |h a smal|l densit|
|00001dd0| 79 20 6f 66 20 63 68 61 | 6e 67 65 73 2e 20 20 2a |y of cha|nges. *|
|00001de0| 2f 0a 09 20 20 68 65 75 | 72 69 73 74 69 63 20 3d |/.. heu|ristic =|
|00001df0| 20 31 3b 0a 09 20 20 62 | 72 65 61 6b 3b 0a 0a 09 | 1;.. b|reak;...|
|00001e00| 63 61 73 65 20 27 69 27 | 3a 0a 09 20 20 2f 2a 20 |case 'i'|:.. /* |
|00001e10| 49 67 6e 6f 72 65 20 63 | 68 61 6e 67 65 73 20 69 |Ignore c|hanges i|
|00001e20| 6e 20 63 61 73 65 2e 20 | 20 2a 2f 0a 09 20 20 69 |n case. | */.. i|
|00001e30| 67 6e 6f 72 65 5f 63 61 | 73 65 5f 66 6c 61 67 20 |gnore_ca|se_flag |
|00001e40| 3d 20 31 3b 0a 09 20 20 | 62 72 65 61 6b 3b 0a 0a |= 1;.. |break;..|
|00001e50| 09 63 61 73 65 20 27 49 | 27 3a 0a 09 20 20 2f 2a |.case 'I|':.. /*|
|00001e60| 20 49 67 6e 6f 72 65 20 | 63 68 61 6e 67 65 73 20 | Ignore |changes |
|00001e70| 61 66 66 65 63 74 69 6e | 67 20 6f 6e 6c 79 20 6c |affectin|g only l|
|00001e80| 69 6e 65 73 20 74 68 61 | 74 20 6d 61 74 63 68 20 |ines tha|t match |
|00001e90| 74 68 65 0a 09 20 20 20 | 20 20 73 70 65 63 69 66 |the.. | specif|
|00001ea0| 69 65 64 20 72 65 67 65 | 78 70 2e 20 20 2a 2f 0a |ied rege|xp. */.|
|00001eb0| 09 20 20 69 67 6e 6f 72 | 65 5f 72 65 67 65 78 70 |. ignor|e_regexp|
|00001ec0| 20 3d 20 6f 70 74 61 72 | 67 3b 0a 09 20 20 62 72 | = optar|g;.. br|
|00001ed0| 65 61 6b 3b 0a 0a 09 63 | 61 73 65 20 27 6c 27 3a |eak;...c|ase 'l':|
|00001ee0| 0a 09 20 20 2f 2a 20 50 | 61 73 73 20 74 68 65 20 |.. /* P|ass the |
|00001ef0| 6f 75 74 70 75 74 20 74 | 68 72 6f 75 67 68 20 60 |output t|hrough `|
|00001f00| 70 72 27 20 74 6f 20 70 | 61 67 69 6e 61 74 65 20 |pr' to p|aginate |
|00001f10| 69 74 2e 20 20 2a 2f 0a | 09 20 20 70 61 67 69 6e |it. */.|. pagin|
|00001f20| 61 74 65 5f 66 6c 61 67 | 20 3d 20 31 3b 0a 09 20 |ate_flag| = 1;.. |
|00001f30| 20 62 72 65 61 6b 3b 0a | 0a 09 63 61 73 65 20 27 | break;.|..case '|
|00001f40| 4c 27 3a 0a 09 20 20 2f | 2a 20 53 70 65 63 69 66 |L':.. /|* Specif|
|00001f50| 79 20 66 69 6c 65 20 6c | 61 62 65 6c 73 20 66 6f |y file l|abels fo|
|00001f60| 72 20 60 2d 63 27 20 6f | 75 74 70 75 74 20 68 65 |r `-c' o|utput he|
|00001f70| 61 64 65 72 73 2e 20 20 | 2a 2f 0a 09 20 20 69 66 |aders. |*/.. if|
|00001f80| 20 28 21 66 69 6c 65 5f | 6c 61 62 65 6c 5b 30 5d | (!file_|label[0]|
|00001f90| 29 0a 09 20 20 20 20 66 | 69 6c 65 5f 6c 61 62 65 |).. f|ile_labe|
|00001fa0| 6c 5b 30 5d 20 3d 20 6f | 70 74 61 72 67 3b 0a 09 |l[0] = o|ptarg;..|
|00001fb0| 20 20 65 6c 73 65 20 69 | 66 20 28 21 66 69 6c 65 | else i|f (!file|
|00001fc0| 5f 6c 61 62 65 6c 5b 31 | 5d 29 0a 09 20 20 20 20 |_label[1|]).. |
|00001fd0| 66 69 6c 65 5f 6c 61 62 | 65 6c 5b 31 5d 20 3d 20 |file_lab|el[1] = |
|00001fe0| 6f 70 74 61 72 67 3b 0a | 09 20 20 65 6c 73 65 0a |optarg;.|. else.|
|00001ff0| 09 20 20 20 20 66 61 74 | 61 6c 20 28 22 74 6f 6f |. fat|al ("too|
|00002000| 20 6d 61 6e 79 20 66 69 | 6c 65 20 6c 61 62 65 6c | many fi|le label|
|00002010| 20 6f 70 74 69 6f 6e 73 | 22 29 3b 0a 09 20 20 62 | options|");.. b|
|00002020| 72 65 61 6b 3b 0a 0a 09 | 63 61 73 65 20 27 6e 27 |reak;...|case 'n'|
|00002030| 3a 0a 09 20 20 2f 2a 20 | 4f 75 74 70 75 74 20 52 |:.. /* |Output R|
|00002040| 43 53 2d 73 74 79 6c 65 | 20 64 69 66 66 73 2c 20 |CS-style| diffs, |
|00002050| 6c 69 6b 65 20 60 2d 66 | 27 20 65 78 63 65 70 74 |like `-f|' except|
|00002060| 20 74 68 61 74 20 65 61 | 63 68 20 63 6f 6d 6d 61 | that ea|ch comma|
|00002070| 6e 64 0a 09 20 20 20 20 | 20 73 70 65 63 69 66 69 |nd.. | specifi|
|00002080| 65 73 20 74 68 65 20 6e | 75 6d 62 65 72 20 6f 66 |es the n|umber of|
|00002090| 20 6c 69 6e 65 73 20 61 | 66 66 65 63 74 65 64 2e | lines a|ffected.|
|000020a0| 20 20 2a 2f 0a 09 20 20 | 73 70 65 63 69 66 79 5f | */.. |specify_|
|000020b0| 73 74 79 6c 65 20 28 4f | 55 54 50 55 54 5f 52 43 |style (O|UTPUT_RC|
|000020c0| 53 29 3b 0a 09 20 20 62 | 72 65 61 6b 3b 0a 0a 09 |S);.. b|reak;...|
|000020d0| 63 61 73 65 20 27 4e 27 | 3a 0a 09 20 20 2f 2a 20 |case 'N'|:.. /* |
|000020e0| 57 68 65 6e 20 63 6f 6d | 70 61 72 69 6e 67 20 64 |When com|paring d|
|000020f0| 69 72 65 63 74 6f 72 69 | 65 73 2c 20 69 66 20 61 |irectori|es, if a|
|00002100| 20 66 69 6c 65 20 61 70 | 70 65 61 72 73 20 6f 6e | file ap|pears on|
|00002110| 6c 79 20 69 6e 20 6f 6e | 65 0a 09 20 20 20 20 20 |ly in on|e.. |
|00002120| 64 69 72 65 63 74 6f 72 | 79 2c 20 74 72 65 61 74 |director|y, treat|
|00002130| 20 69 74 20 61 73 20 70 | 72 65 73 65 6e 74 20 62 | it as p|resent b|
|00002140| 75 74 20 65 6d 70 74 79 | 20 69 6e 20 74 68 65 20 |ut empty| in the |
|00002150| 6f 74 68 65 72 2e 20 20 | 2a 2f 0a 09 20 20 65 6e |other. |*/.. en|
|00002160| 74 69 72 65 5f 6e 65 77 | 5f 66 69 6c 65 5f 66 6c |tire_new|_file_fl|
|00002170| 61 67 20 3d 20 31 3b 0a | 09 20 20 62 72 65 61 6b |ag = 1;.|. break|
|00002180| 3b 0a 0a 09 63 61 73 65 | 20 27 70 27 3a 0a 09 20 |;...case| 'p':.. |
|00002190| 20 2f 2a 20 4d 61 6b 65 | 20 63 6f 6e 74 65 78 74 | /* Make| context|
|000021a0| 2d 73 74 79 6c 65 20 6f | 75 74 70 75 74 20 61 6e |-style o|utput an|
|000021b0| 64 20 73 68 6f 77 20 6e | 61 6d 65 20 6f 66 20 6c |d show n|ame of l|
|000021c0| 61 73 74 20 43 20 66 75 | 6e 63 74 69 6f 6e 2e 20 |ast C fu|nction. |
|000021d0| 20 2a 2f 0a 09 20 20 73 | 70 65 63 69 66 79 5f 73 | */.. s|pecify_s|
|000021e0| 74 79 6c 65 20 28 4f 55 | 54 50 55 54 5f 43 4f 4e |tyle (OU|TPUT_CON|
|000021f0| 54 45 58 54 29 3b 0a 09 | 20 20 66 75 6e 63 74 69 |TEXT);..| functi|
|00002200| 6f 6e 5f 72 65 67 65 78 | 70 20 3d 20 22 5e 5b 5f |on_regex|p = "^[_|
|00002210| 61 2d 7a 41 2d 5a 5d 22 | 3b 0a 09 20 20 62 72 65 |a-zA-Z]"|;.. bre|
|00002220| 61 6b 3b 0a 0a 09 63 61 | 73 65 20 27 71 27 3a 0a |ak;...ca|se 'q':.|
|00002230| 09 20 20 6e 6f 5f 64 65 | 74 61 69 6c 73 5f 66 6c |. no_de|tails_fl|
|00002240| 61 67 20 3d 20 31 3b 0a | 09 20 20 62 72 65 61 6b |ag = 1;.|. break|
|00002250| 3b 0a 0a 09 63 61 73 65 | 20 27 72 27 3a 0a 09 20 |;...case| 'r':.. |
|00002260| 20 2f 2a 20 57 68 65 6e | 20 63 6f 6d 70 61 72 69 | /* When| compari|
|00002270| 6e 67 20 64 69 72 65 63 | 74 6f 72 69 65 73 2c 20 |ng direc|tories, |
|00002280| 0a 09 20 20 20 20 20 72 | 65 63 75 72 73 69 76 65 |.. r|ecursive|
|00002290| 6c 79 20 63 6f 6d 70 61 | 72 65 20 61 6e 79 20 73 |ly compa|re any s|
|000022a0| 75 62 64 69 72 65 63 74 | 6f 72 69 65 73 20 66 6f |ubdirect|ories fo|
|000022b0| 75 6e 64 2e 20 20 2a 2f | 0a 09 20 20 72 65 63 75 |und. */|.. recu|
|000022c0| 72 73 69 76 65 20 3d 20 | 31 3b 0a 09 20 20 62 72 |rsive = |1;.. br|
|000022d0| 65 61 6b 3b 0a 0a 09 63 | 61 73 65 20 27 73 27 3a |eak;...c|ase 's':|
|000022e0| 0a 09 20 20 2f 2a 20 50 | 72 69 6e 74 20 61 20 6d |.. /* P|rint a m|
|000022f0| 65 73 73 61 67 65 20 69 | 66 20 74 68 65 20 66 69 |essage i|f the fi|
|00002300| 6c 65 73 20 61 72 65 20 | 74 68 65 20 73 61 6d 65 |les are |the same|
|00002310| 2e 20 20 2a 2f 0a 09 20 | 20 70 72 69 6e 74 5f 66 |. */.. | print_f|
|00002320| 69 6c 65 5f 73 61 6d 65 | 5f 66 6c 61 67 20 3d 20 |ile_same|_flag = |
|00002330| 31 3b 0a 09 20 20 62 72 | 65 61 6b 3b 0a 0a 09 63 |1;.. br|eak;...c|
|00002340| 61 73 65 20 27 53 27 3a | 0a 09 20 20 2f 2a 20 57 |ase 'S':|.. /* W|
|00002350| 68 65 6e 20 63 6f 6d 70 | 61 72 69 6e 67 20 64 69 |hen comp|aring di|
|00002360| 72 65 63 74 6f 72 69 65 | 73 2c 20 73 74 61 72 74 |rectorie|s, start|
|00002370| 20 77 69 74 68 20 74 68 | 65 20 73 70 65 63 69 66 | with th|e specif|
|00002380| 69 65 64 0a 09 20 20 20 | 20 20 66 69 6c 65 20 6e |ied.. | file n|
|00002390| 61 6d 65 2e 20 20 54 68 | 69 73 20 69 73 20 75 73 |ame. Th|is is us|
|000023a0| 65 64 20 66 6f 72 20 72 | 65 73 75 6d 69 6e 67 20 |ed for r|esuming |
|000023b0| 61 6e 20 61 62 6f 72 74 | 65 64 20 63 6f 6d 70 61 |an abort|ed compa|
|000023c0| 72 69 73 6f 6e 2e 20 20 | 2a 2f 0a 09 20 20 64 69 |rison. |*/.. di|
|000023d0| 72 5f 73 74 61 72 74 5f | 66 69 6c 65 20 3d 20 6f |r_start_|file = o|
|000023e0| 70 74 61 72 67 3b 0a 09 | 20 20 62 72 65 61 6b 3b |ptarg;..| break;|
|000023f0| 0a 0a 09 63 61 73 65 20 | 27 74 27 3a 0a 09 20 20 |...case |'t':.. |
|00002400| 2f 2a 20 45 78 70 61 6e | 64 20 74 61 62 73 20 74 |/* Expan|d tabs t|
|00002410| 6f 20 73 70 61 63 65 73 | 20 69 6e 20 74 68 65 20 |o spaces| in the |
|00002420| 6f 75 74 70 75 74 20 73 | 6f 20 74 68 61 74 20 69 |output s|o that i|
|00002430| 74 20 70 72 65 73 65 72 | 76 65 73 0a 09 20 20 20 |t preser|ves.. |
|00002440| 20 20 74 68 65 20 61 6c | 69 67 6e 6d 65 6e 74 20 | the al|ignment |
|00002450| 6f 66 20 74 68 65 20 69 | 6e 70 75 74 20 66 69 6c |of the i|nput fil|
|00002460| 65 73 2e 20 20 2a 2f 0a | 09 20 20 74 61 62 5f 65 |es. */.|. tab_e|
|00002470| 78 70 61 6e 64 5f 66 6c | 61 67 20 3d 20 31 3b 0a |xpand_fl|ag = 1;.|
|00002480| 09 20 20 62 72 65 61 6b | 3b 0a 0a 09 63 61 73 65 |. break|;...case|
|00002490| 20 27 54 27 3a 0a 09 20 | 20 2f 2a 20 55 73 65 20 | 'T':.. | /* Use |
|000024a0| 61 20 74 61 62 20 69 6e | 20 74 68 65 20 6f 75 74 |a tab in| the out|
|000024b0| 70 75 74 2c 20 72 61 74 | 68 65 72 20 74 68 61 6e |put, rat|her than|
|000024c0| 20 61 20 73 70 61 63 65 | 2c 20 62 65 66 6f 72 65 | a space|, before|
|000024d0| 20 74 68 65 0a 09 20 20 | 20 20 20 74 65 78 74 20 | the.. | text |
|000024e0| 6f 66 20 61 6e 20 69 6e | 70 75 74 20 6c 69 6e 65 |of an in|put line|
|000024f0| 2c 20 73 6f 20 61 73 20 | 74 6f 20 6b 65 65 70 20 |, so as |to keep |
|00002500| 74 68 65 20 70 72 6f 70 | 65 72 20 61 6c 69 67 6e |the prop|er align|
|00002510| 6d 65 6e 74 0a 09 20 20 | 20 20 20 69 6e 20 74 68 |ment.. | in th|
|00002520| 65 20 69 6e 70 75 74 20 | 6c 69 6e 65 20 77 69 74 |e input |line wit|
|00002530| 68 6f 75 74 20 63 68 61 | 6e 67 69 6e 67 20 74 68 |hout cha|nging th|
|00002540| 65 20 63 68 61 72 61 63 | 74 65 72 73 20 69 6e 20 |e charac|ters in |
|00002550| 69 74 2e 20 20 2a 2f 0a | 09 20 20 74 61 62 5f 61 |it. */.|. tab_a|
|00002560| 6c 69 67 6e 5f 66 6c 61 | 67 20 3d 20 31 3b 0a 09 |lign_fla|g = 1;..|
|00002570| 20 20 62 72 65 61 6b 3b | 0a 0a 09 63 61 73 65 20 | break;|...case |
|00002580| 27 76 27 3a 0a 09 20 20 | 70 72 69 6e 74 66 20 28 |'v':.. |printf (|
|00002590| 22 47 4e 55 20 64 69 66 | 66 20 76 65 72 73 69 6f |"GNU dif|f versio|
|000025a0| 6e 20 25 73 5c 6e 22 2c | 20 76 65 72 73 69 6f 6e |n %s\n",| version|
|000025b0| 5f 73 74 72 69 6e 67 29 | 3b 0a 09 20 20 62 72 65 |_string)|;.. bre|
|000025c0| 61 6b 3b 0a 0a 09 63 61 | 73 65 20 27 75 27 3a 0a |ak;...ca|se 'u':.|
|000025d0| 09 20 20 2f 2a 20 4f 75 | 74 70 75 74 20 74 68 65 |. /* Ou|tput the|
|000025e0| 20 63 6f 6e 74 65 78 74 | 20 64 69 66 66 20 69 6e | context| diff in|
|000025f0| 20 75 6e 69 64 69 66 66 | 20 66 6f 72 6d 61 74 2e | unidiff| format.|
|00002600| 20 20 2a 2f 0a 09 20 20 | 73 70 65 63 69 66 79 5f | */.. |specify_|
|00002610| 73 74 79 6c 65 20 28 4f | 55 54 50 55 54 5f 55 4e |style (O|UTPUT_UN|
|00002620| 49 46 49 45 44 29 3b 0a | 09 20 20 62 72 65 61 6b |IFIED);.|. break|
|00002630| 3b 0a 0a 09 63 61 73 65 | 20 27 77 27 3a 0a 09 20 |;...case| 'w':.. |
|00002640| 20 2f 2a 20 49 67 6e 6f | 72 65 20 68 6f 72 69 7a | /* Igno|re horiz|
|00002650| 6f 6e 74 61 6c 20 77 68 | 69 74 65 73 70 61 63 65 |ontal wh|itespace|
|00002660| 20 77 68 65 6e 20 63 6f | 6d 70 61 72 69 6e 67 20 | when co|mparing |
|00002670| 6c 69 6e 65 73 2e 20 20 | 2a 2f 0a 09 20 20 69 67 |lines. |*/.. ig|
|00002680| 6e 6f 72 65 5f 61 6c 6c | 5f 73 70 61 63 65 5f 66 |nore_all|_space_f|
|00002690| 6c 61 67 20 3d 20 31 3b | 0a 09 20 20 6c 65 6e 67 |lag = 1;|.. leng|
|000026a0| 74 68 5f 76 61 72 69 65 | 73 20 3d 20 31 3b 0a 09 |th_varie|s = 1;..|
|000026b0| 20 20 62 72 65 61 6b 3b | 0a 0a 09 64 65 66 61 75 | break;|...defau|
|000026c0| 6c 74 3a 0a 09 20 20 75 | 73 61 67 65 20 28 29 3b |lt:.. u|sage ();|
|000026d0| 0a 09 7d 0a 20 20 20 20 | 20 20 70 72 65 76 20 3d |..}. | prev =|
|000026e0| 20 63 3b 0a 20 20 20 20 | 7d 0a 0a 20 20 69 66 20 | c;. |}.. if |
|000026f0| 28 6f 70 74 69 6e 64 20 | 21 3d 20 61 72 67 63 20 |(optind |!= argc |
|00002700| 2d 20 32 29 0a 20 20 20 | 20 75 73 61 67 65 20 28 |- 2). | usage (|
|00002710| 29 3b 0a 0a 20 20 69 66 | 20 28 69 67 6e 6f 72 65 |);.. if| (ignore|
|00002720| 5f 72 65 67 65 78 70 29 | 0a 20 20 20 20 7b 0a 20 |_regexp)|. {. |
|00002730| 20 20 20 20 20 63 68 61 | 72 20 2a 76 61 6c 3b 0a | cha|r *val;.|
|00002740| 20 20 20 20 20 20 62 7a | 65 72 6f 20 28 26 69 67 | bz|ero (&ig|
|00002750| 6e 6f 72 65 5f 72 65 67 | 65 78 70 5f 63 6f 6d 70 |nore_reg|exp_comp|
|00002760| 69 6c 65 64 2c 20 73 69 | 7a 65 6f 66 20 69 67 6e |iled, si|zeof ign|
|00002770| 6f 72 65 5f 72 65 67 65 | 78 70 5f 63 6f 6d 70 69 |ore_rege|xp_compi|
|00002780| 6c 65 64 29 3b 0a 20 20 | 20 20 20 20 76 61 6c 20 |led);. | val |
|00002790| 3d 20 72 65 5f 63 6f 6d | 70 69 6c 65 5f 70 61 74 |= re_com|pile_pat|
|000027a0| 74 65 72 6e 20 28 69 67 | 6e 6f 72 65 5f 72 65 67 |tern (ig|nore_reg|
|000027b0| 65 78 70 2c 20 73 74 72 | 6c 65 6e 20 28 69 67 6e |exp, str|len (ign|
|000027c0| 6f 72 65 5f 72 65 67 65 | 78 70 29 2c 0a 09 09 09 |ore_rege|xp),....|
|000027d0| 09 26 69 67 6e 6f 72 65 | 5f 72 65 67 65 78 70 5f |.&ignore|_regexp_|
|000027e0| 63 6f 6d 70 69 6c 65 64 | 29 3b 0a 20 20 20 20 20 |compiled|);. |
|000027f0| 20 69 66 20 28 76 61 6c | 20 21 3d 20 30 29 0a 09 | if (val| != 0)..|
|00002800| 65 72 72 6f 72 20 28 22 | 25 73 3a 20 25 73 22 2c |error ("|%s: %s",|
|00002810| 20 69 67 6e 6f 72 65 5f | 72 65 67 65 78 70 2c 20 | ignore_|regexp, |
|00002820| 76 61 6c 29 3b 0a 20 20 | 20 20 20 20 69 67 6e 6f |val);. | igno|
|00002830| 72 65 5f 72 65 67 65 78 | 70 5f 63 6f 6d 70 69 6c |re_regex|p_compil|
|00002840| 65 64 2e 66 61 73 74 6d | 61 70 20 3d 20 28 63 68 |ed.fastm|ap = (ch|
|00002850| 61 72 20 2a 29 20 78 6d | 61 6c 6c 6f 63 20 28 32 |ar *) xm|alloc (2|
|00002860| 35 36 29 3b 0a 20 20 20 | 20 7d 0a 0a 20 20 69 66 |56);. | }.. if|
|00002870| 20 28 66 75 6e 63 74 69 | 6f 6e 5f 72 65 67 65 78 | (functi|on_regex|
|00002880| 70 29 0a 20 20 20 20 7b | 0a 20 20 20 20 20 20 63 |p). {|. c|
|00002890| 68 61 72 20 2a 76 61 6c | 3b 0a 20 20 20 20 20 20 |har *val|;. |
|000028a0| 62 7a 65 72 6f 20 28 26 | 66 75 6e 63 74 69 6f 6e |bzero (&|function|
|000028b0| 5f 72 65 67 65 78 70 5f | 63 6f 6d 70 69 6c 65 64 |_regexp_|compiled|
|000028c0| 2c 20 73 69 7a 65 6f 66 | 20 66 75 6e 63 74 69 6f |, sizeof| functio|
|000028d0| 6e 5f 72 65 67 65 78 70 | 5f 63 6f 6d 70 69 6c 65 |n_regexp|_compile|
|000028e0| 64 29 3b 0a 20 20 20 20 | 20 20 76 61 6c 20 3d 20 |d);. | val = |
|000028f0| 72 65 5f 63 6f 6d 70 69 | 6c 65 5f 70 61 74 74 65 |re_compi|le_patte|
|00002900| 72 6e 20 28 66 75 6e 63 | 74 69 6f 6e 5f 72 65 67 |rn (func|tion_reg|
|00002910| 65 78 70 2c 20 73 74 72 | 6c 65 6e 20 28 66 75 6e |exp, str|len (fun|
|00002920| 63 74 69 6f 6e 5f 72 65 | 67 65 78 70 29 2c 0a 09 |ction_re|gexp),..|
|00002930| 09 09 09 26 66 75 6e 63 | 74 69 6f 6e 5f 72 65 67 |...&func|tion_reg|
|00002940| 65 78 70 5f 63 6f 6d 70 | 69 6c 65 64 29 3b 0a 20 |exp_comp|iled);. |
|00002950| 20 20 20 20 20 69 66 20 | 28 76 61 6c 20 21 3d 20 | if |(val != |
|00002960| 30 29 0a 09 65 72 72 6f | 72 20 28 22 25 73 3a 20 |0)..erro|r ("%s: |
|00002970| 25 73 22 2c 20 66 75 6e | 63 74 69 6f 6e 5f 72 65 |%s", fun|ction_re|
|00002980| 67 65 78 70 2c 20 76 61 | 6c 29 3b 0a 20 20 20 20 |gexp, va|l);. |
|00002990| 20 20 66 75 6e 63 74 69 | 6f 6e 5f 72 65 67 65 78 | functi|on_regex|
|000029a0| 70 5f 63 6f 6d 70 69 6c | 65 64 2e 66 61 73 74 6d |p_compil|ed.fastm|
|000029b0| 61 70 20 3d 20 28 63 68 | 61 72 20 2a 29 20 78 6d |ap = (ch|ar *) xm|
|000029c0| 61 6c 6c 6f 63 20 28 32 | 35 36 29 3b 0a 20 20 20 |alloc (2|56);. |
|000029d0| 20 7d 0a 0a 20 20 69 66 | 20 28 6f 75 74 70 75 74 | }.. if| (output|
|000029e0| 5f 73 74 79 6c 65 20 21 | 3d 20 4f 55 54 50 55 54 |_style !|= OUTPUT|
|000029f0| 5f 43 4f 4e 54 45 58 54 | 20 26 26 20 6f 75 74 70 |_CONTEXT| && outp|
|00002a00| 75 74 5f 73 74 79 6c 65 | 20 21 3d 20 4f 55 54 50 |ut_style| != OUTP|
|00002a10| 55 54 5f 55 4e 49 46 49 | 45 44 29 0a 20 20 20 20 |UT_UNIFI|ED). |
|00002a20| 63 6f 6e 74 65 78 74 20 | 3d 20 30 3b 0a 20 20 65 |context |= 0;. e|
|00002a30| 6c 73 65 20 69 66 20 28 | 63 6f 6e 74 65 78 74 20 |lse if (|context |
|00002a40| 3d 3d 20 2d 31 29 0a 20 | 20 20 20 2f 2a 20 44 65 |== -1). | /* De|
|00002a50| 66 61 75 6c 74 20 61 6d | 6f 75 6e 74 20 6f 66 20 |fault am|ount of |
|00002a60| 63 6f 6e 74 65 78 74 20 | 66 6f 72 20 2d 63 2e 20 |context |for -c. |
|00002a70| 20 2a 2f 0a 20 20 20 20 | 63 6f 6e 74 65 78 74 20 | */. |context |
|00002a80| 3d 20 33 3b 0a 0a 20 20 | 73 77 69 74 63 68 5f 73 |= 3;.. |switch_s|
|00002a90| 74 72 69 6e 67 20 3d 20 | 6f 70 74 69 6f 6e 5f 6c |tring = |option_l|
|00002aa0| 69 73 74 20 28 61 72 67 | 76 20 2b 20 31 2c 20 6f |ist (arg|v + 1, o|
|00002ab0| 70 74 69 6e 64 20 2d 20 | 31 29 3b 0a 0a 20 20 76 |ptind - |1);.. v|
|00002ac0| 61 6c 20 3d 20 63 6f 6d | 70 61 72 65 5f 66 69 6c |al = com|pare_fil|
|00002ad0| 65 73 20 28 30 2c 20 61 | 72 67 76 5b 6f 70 74 69 |es (0, a|rgv[opti|
|00002ae0| 6e 64 5d 2c 20 30 2c 20 | 61 72 67 76 5b 6f 70 74 |nd], 0, |argv[opt|
|00002af0| 69 6e 64 20 2b 20 31 5d | 2c 20 30 29 3b 0a 0a 20 |ind + 1]|, 0);.. |
|00002b00| 20 2f 2a 20 50 72 69 6e | 74 20 61 6e 79 20 6d 65 | /* Prin|t any me|
|00002b10| 73 73 61 67 65 73 20 74 | 68 61 74 20 77 65 72 65 |ssages t|hat were|
|00002b20| 20 73 61 76 65 64 20 75 | 70 20 66 6f 72 20 6c 61 | saved u|p for la|
|00002b30| 73 74 2e 20 20 2a 2f 0a | 20 20 70 72 69 6e 74 5f |st. */.| print_|
|00002b40| 6d 65 73 73 61 67 65 5f | 71 75 65 75 65 20 28 29 |message_|queue ()|
|00002b50| 3b 0a 0a 20 20 69 66 20 | 28 66 65 72 72 6f 72 20 |;.. if |(ferror |
|00002b60| 28 73 74 64 6f 75 74 29 | 20 7c 7c 20 66 63 6c 6f |(stdout)| || fclo|
|00002b70| 73 65 20 28 73 74 64 6f | 75 74 29 20 21 3d 20 30 |se (stdo|ut) != 0|
|00002b80| 29 0a 20 20 20 20 66 61 | 74 61 6c 20 28 22 77 72 |). fa|tal ("wr|
|00002b90| 69 74 65 20 65 72 72 6f | 72 22 29 3b 0a 20 20 65 |ite erro|r");. e|
|00002ba0| 78 69 74 20 28 76 61 6c | 29 3b 0a 7d 0a 0a 75 73 |xit (val|);.}..us|
|00002bb0| 61 67 65 20 28 29 0a 7b | 0a 20 20 66 70 72 69 6e |age ().{|. fprin|
|00002bc0| 74 66 20 28 73 74 64 65 | 72 72 2c 20 22 5c 0a 55 |tf (stde|rr, "\.U|
|00002bd0| 73 61 67 65 3a 20 64 69 | 66 66 20 5b 2d 23 5d 20 |sage: di|ff [-#] |
|00002be0| 5b 2d 61 62 42 63 64 65 | 66 68 48 69 6c 6e 4e 70 |[-abBcde|fhHilnNp|
|00002bf0| 72 73 74 54 75 76 77 5d | 20 5b 2d 43 20 6c 69 6e |rstTuvw]| [-C lin|
|00002c00| 65 73 5d 20 5b 2d 46 20 | 72 65 67 65 78 70 5d 20 |es] [-F |regexp] |
|00002c10| 5b 2d 49 20 72 65 67 65 | 78 70 5d 5c 6e 5c 0a 20 |[-I rege|xp]\n\. |
|00002c20| 20 20 20 20 20 20 5b 2d | 4c 20 6c 61 62 65 6c 20 | [-|L label |
|00002c30| 5b 2d 4c 20 6c 61 62 65 | 6c 5d 5d 20 5b 2d 53 20 |[-L labe|l]] [-S |
|00002c40| 66 69 6c 65 5d 20 5b 2d | 44 20 73 79 6d 62 6f 6c |file] [-|D symbol|
|00002c50| 5d 20 5b 2b 69 67 6e 6f | 72 65 2d 62 6c 61 6e 6b |] [+igno|re-blank|
|00002c60| 2d 6c 69 6e 65 73 5d 5c | 6e 5c 0a 20 20 20 20 20 |-lines]\|n\. |
|00002c70| 20 20 5b 2b 63 6f 6e 74 | 65 78 74 5b 3d 6c 69 6e | [+cont|ext[=lin|
|00002c80| 65 73 5d 5d 20 5b 2b 75 | 6e 69 66 69 65 64 5b 3d |es]] [+u|nified[=|
|00002c90| 6c 69 6e 65 73 5d 5d 20 | 5b 2b 69 66 64 65 66 3d |lines]] |[+ifdef=|
|00002ca0| 73 79 6d 62 6f 6c 5d 5c | 6e 5c 0a 20 20 20 20 20 |symbol]\|n\. |
|00002cb0| 20 20 5b 2b 73 68 6f 77 | 2d 66 75 6e 63 74 69 6f | [+show|-functio|
|00002cc0| 6e 2d 6c 69 6e 65 3d 72 | 65 67 65 78 70 5d 5c 6e |n-line=r|egexp]\n|
|00002cd0| 22 29 3b 0a 20 20 66 70 | 72 69 6e 74 66 20 28 73 |");. fp|rintf (s|
|00002ce0| 74 64 65 72 72 2c 20 22 | 5c 0a 20 20 20 20 20 20 |tderr, "|\. |
|00002cf0| 20 5b 2b 73 70 65 65 64 | 2d 6c 61 72 67 65 2d 66 | [+speed|-large-f|
|00002d00| 69 6c 65 73 5d 20 5b 2b | 69 67 6e 6f 72 65 2d 6d |iles] [+|ignore-m|
|00002d10| 61 74 63 68 69 6e 67 2d | 6c 69 6e 65 73 3d 72 65 |atching-|lines=re|
|00002d20| 67 65 78 70 5d 20 5b 2b | 6e 65 77 2d 66 69 6c 65 |gexp] [+|new-file|
|00002d30| 5d 5c 6e 5c 0a 20 20 20 | 20 20 20 20 5b 2b 69 6e |]\n\. | [+in|
|00002d40| 69 74 69 61 6c 2d 74 61 | 62 5d 20 5b 2b 73 74 61 |itial-ta|b] [+sta|
|00002d50| 72 74 69 6e 67 2d 66 69 | 6c 65 3d 66 69 6c 65 5d |rting-fi|le=file]|
|00002d60| 20 5b 2b 74 65 78 74 5d | 20 5b 2b 61 6c 6c 2d 74 | [+text]| [+all-t|
|00002d70| 65 78 74 5d 20 5b 2b 61 | 73 63 69 69 5d 5c 6e 5c |ext] [+a|scii]\n\|
|00002d80| 0a 20 20 20 20 20 20 20 | 5b 2b 6d 69 6e 69 6d 61 |. |[+minima|
|00002d90| 6c 5d 20 5b 2b 69 67 6e | 6f 72 65 2d 73 70 61 63 |l] [+ign|ore-spac|
|00002da0| 65 2d 63 68 61 6e 67 65 | 5d 20 5b 2b 65 64 5d 20 |e-change|] [+ed] |
|00002db0| 5b 2b 72 65 76 65 72 73 | 65 64 2d 65 64 5d 20 5b |[+revers|ed-ed] [|
|00002dc0| 2b 69 67 6e 6f 72 65 2d | 63 61 73 65 5d 5c 6e 22 |+ignore-|case]\n"|
|00002dd0| 29 3b 0a 20 20 66 70 72 | 69 6e 74 66 20 28 73 74 |);. fpr|intf (st|
|00002de0| 64 65 72 72 2c 20 22 5c | 0a 20 20 20 20 20 20 20 |derr, "\|. |
|00002df0| 5b 2b 70 72 69 6e 74 5d | 20 5b 2b 72 63 73 5d 20 |[+print]| [+rcs] |
|00002e00| 5b 2b 73 68 6f 77 2d 63 | 2d 66 75 6e 63 74 69 6f |[+show-c|-functio|
|00002e10| 6e 5d 20 5b 2b 62 69 6e | 61 72 79 5d 20 5b 2b 62 |n] [+bin|ary] [+b|
|00002e20| 72 69 65 66 5d 20 5b 2b | 72 65 63 75 72 73 69 76 |rief] [+|recursiv|
|00002e30| 65 5d 5c 6e 5c 0a 20 20 | 20 20 20 20 20 5b 2b 72 |e]\n\. | [+r|
|00002e40| 65 70 6f 72 74 2d 69 64 | 65 6e 74 69 63 61 6c 2d |eport-id|entical-|
|00002e50| 66 69 6c 65 73 5d 20 5b | 2b 65 78 70 61 6e 64 2d |files] [|+expand-|
|00002e60| 74 61 62 73 5d 20 5b 2b | 69 67 6e 6f 72 65 2d 61 |tabs] [+|ignore-a|
|00002e70| 6c 6c 2d 73 70 61 63 65 | 5d 5c 6e 5c 0a 20 20 20 |ll-space|]\n\. |
|00002e80| 20 20 20 20 5b 2b 66 69 | 6c 65 2d 6c 61 62 65 6c | [+fi|le-label|
|00002e90| 3d 6c 61 62 65 6c 20 5b | 2b 66 69 6c 65 2d 6c 61 |=label [|+file-la|
|00002ea0| 62 65 6c 3d 6c 61 62 65 | 6c 5d 5d 20 5b 2b 76 65 |bel=labe|l]] [+ve|
|00002eb0| 72 73 69 6f 6e 5d 20 70 | 61 74 68 31 20 70 61 74 |rsion] p|ath1 pat|
|00002ec0| 68 32 5c 6e 22 29 3b 0a | 20 20 65 78 69 74 20 28 |h2\n");.| exit (|
|00002ed0| 32 29 3b 0a 7d 20 0a 0a | 73 70 65 63 69 66 79 5f |2);.} ..|specify_|
|00002ee0| 73 74 79 6c 65 20 28 73 | 74 79 6c 65 29 0a 20 20 |style (s|tyle). |
|00002ef0| 20 20 20 65 6e 75 6d 20 | 6f 75 74 70 75 74 5f 73 | enum |output_s|
|00002f00| 74 79 6c 65 20 73 74 79 | 6c 65 3b 0a 7b 0a 20 20 |tyle sty|le;.{. |
|00002f10| 69 66 20 28 6f 75 74 70 | 75 74 5f 73 74 79 6c 65 |if (outp|ut_style|
|00002f20| 20 21 3d 20 4f 55 54 50 | 55 54 5f 4e 4f 52 4d 41 | != OUTP|UT_NORMA|
|00002f30| 4c 0a 20 20 20 20 20 20 | 26 26 20 6f 75 74 70 75 |L. |&& outpu|
|00002f40| 74 5f 73 74 79 6c 65 20 | 21 3d 20 73 74 79 6c 65 |t_style |!= style|
|00002f50| 29 0a 20 20 20 20 65 72 | 72 6f 72 20 28 22 63 6f |). er|ror ("co|
|00002f60| 6e 66 6c 69 63 74 69 6e | 67 20 73 70 65 63 69 66 |nflictin|g specif|
|00002f70| 69 63 61 74 69 6f 6e 73 | 20 6f 66 20 6f 75 74 70 |ications| of outp|
|00002f80| 75 74 20 73 74 79 6c 65 | 22 29 3b 0a 20 20 6f 75 |ut style|");. ou|
|00002f90| 74 70 75 74 5f 73 74 79 | 6c 65 20 3d 20 73 74 79 |tput_sty|le = sty|
|00002fa0| 6c 65 3b 0a 7d 0a 0c 0a | 2f 2a 20 43 6f 6d 70 61 |le;.}...|/* Compa|
|00002fb0| 72 65 20 74 77 6f 20 66 | 69 6c 65 73 20 28 6f 72 |re two f|iles (or|
|00002fc0| 20 64 69 72 73 29 20 77 | 69 74 68 20 73 70 65 63 | dirs) w|ith spec|
|00002fd0| 69 66 69 65 64 20 6e 61 | 6d 65 73 0a 20 20 20 44 |ified na|mes. D|
|00002fe0| 49 52 30 2f 4e 41 4d 45 | 30 20 61 6e 64 20 44 49 |IR0/NAME|0 and DI|
|00002ff0| 52 31 2f 4e 41 4d 45 31 | 2c 20 61 74 20 6c 65 76 |R1/NAME1|, at lev|
|00003000| 65 6c 20 44 45 50 54 48 | 20 69 6e 20 64 69 72 65 |el DEPTH| in dire|
|00003010| 63 74 6f 72 79 20 72 65 | 63 75 72 73 69 6f 6e 2e |ctory re|cursion.|
|00003020| 0a 20 20 20 28 69 66 20 | 44 49 52 30 20 69 73 20 |. (if |DIR0 is |
|00003030| 30 2c 20 74 68 65 6e 20 | 74 68 65 20 6e 61 6d 65 |0, then |the name|
|00003040| 20 69 73 20 6a 75 73 74 | 20 4e 41 4d 45 30 2c 20 | is just| NAME0, |
|00003050| 65 74 63 2e 29 0a 20 20 | 20 54 68 69 73 20 69 73 |etc.). | This is|
|00003060| 20 73 65 6c 66 2d 63 6f | 6e 74 61 69 6e 65 64 3b | self-co|ntained;|
|00003070| 20 69 74 20 6f 70 65 6e | 73 20 74 68 65 20 66 69 | it open|s the fi|
|00003080| 6c 65 73 20 61 6e 64 20 | 63 6c 6f 73 65 73 20 74 |les and |closes t|
|00003090| 68 65 6d 2e 0a 0a 20 20 | 20 56 61 6c 75 65 20 69 |hem... | Value i|
|000030a0| 73 20 30 20 69 66 20 66 | 69 6c 65 73 20 61 72 65 |s 0 if f|iles are|
|000030b0| 20 69 64 65 6e 74 69 63 | 61 6c 2c 20 31 20 69 66 | identic|al, 1 if|
|000030c0| 20 64 69 66 66 65 72 65 | 6e 74 2c 0a 20 20 20 32 | differe|nt,. 2|
|000030d0| 20 69 66 20 74 68 65 72 | 65 20 69 73 20 61 20 70 | if ther|e is a p|
|000030e0| 72 6f 62 6c 65 6d 20 6f | 70 65 6e 69 6e 67 20 74 |roblem o|pening t|
|000030f0| 68 65 6d 2e 20 20 2a 2f | 0a 0a 69 6e 74 0a 63 6f |hem. */|..int.co|
|00003100| 6d 70 61 72 65 5f 66 69 | 6c 65 73 20 28 64 69 72 |mpare_fi|les (dir|
|00003110| 30 2c 20 6e 61 6d 65 30 | 2c 20 64 69 72 31 2c 20 |0, name0|, dir1, |
|00003120| 6e 61 6d 65 31 2c 20 64 | 65 70 74 68 29 0a 20 20 |name1, d|epth). |
|00003130| 20 20 20 63 68 61 72 20 | 2a 64 69 72 30 2c 20 2a | char |*dir0, *|
|00003140| 64 69 72 31 3b 0a 20 20 | 20 20 20 63 68 61 72 20 |dir1;. | char |
|00003150| 2a 6e 61 6d 65 30 2c 20 | 2a 6e 61 6d 65 31 3b 0a |*name0, |*name1;.|
|00003160| 20 20 20 20 20 69 6e 74 | 20 64 65 70 74 68 3b 0a | int| depth;.|
|00003170| 7b 0a 20 20 73 74 61 74 | 69 63 20 63 68 61 72 20 |{. stat|ic char |
|00003180| 53 74 61 6e 64 61 72 64 | 5f 49 6e 70 75 74 5b 5d |Standard|_Input[]|
|00003190| 20 3d 20 22 53 74 61 6e | 64 61 72 64 20 49 6e 70 | = "Stan|dard Inp|
|000031a0| 75 74 22 3b 0a 20 20 73 | 74 72 75 63 74 20 66 69 |ut";. s|truct fi|
|000031b0| 6c 65 5f 64 61 74 61 20 | 69 6e 66 5b 32 5d 3b 0a |le_data |inf[2];.|
|000031c0| 20 20 72 65 67 69 73 74 | 65 72 20 69 6e 74 20 69 | regist|er int i|
|000031d0| 3b 0a 20 20 69 6e 74 20 | 76 61 6c 3b 0a 20 20 69 |;. int |val;. i|
|000031e0| 6e 74 20 65 72 72 6f 72 | 63 6f 75 6e 74 20 3d 20 |nt error|count = |
|000031f0| 30 3b 0a 20 20 69 6e 74 | 20 73 74 61 74 5f 72 65 |0;. int| stat_re|
|00003200| 73 75 6c 74 5b 32 5d 3b | 0a 0a 20 20 2f 2a 20 49 |sult[2];|.. /* I|
|00003210| 66 20 74 68 69 73 20 69 | 73 20 64 69 72 65 63 74 |f this i|s direct|
|00003220| 6f 72 79 20 63 6f 6d 70 | 61 72 69 73 6f 6e 2c 20 |ory comp|arison, |
|00003230| 70 65 72 68 61 70 73 20 | 77 65 20 68 61 76 65 20 |perhaps |we have |
|00003240| 61 20 66 69 6c 65 0a 20 | 20 20 20 20 74 68 61 74 |a file. | that|
|00003250| 20 65 78 69 73 74 73 20 | 6f 6e 6c 79 20 69 6e 20 | exists |only in |
|00003260| 6f 6e 65 20 6f 66 20 74 | 68 65 20 64 69 72 65 63 |one of t|he direc|
|00003270| 74 6f 72 69 65 73 2e 0a | 20 20 20 20 20 49 66 20 |tories..| If |
|00003280| 73 6f 2c 20 6a 75 73 74 | 20 70 72 69 6e 74 20 61 |so, just| print a|
|00003290| 20 6d 65 73 73 61 67 65 | 20 74 6f 20 74 68 61 74 | message| to that|
|000032a0| 20 65 66 66 65 63 74 2e | 20 20 2a 2f 0a 0a 20 20 | effect.| */.. |
|000032b0| 69 66 20 28 21 20 65 6e | 74 69 72 65 5f 6e 65 77 |if (! en|tire_new|
|000032c0| 5f 66 69 6c 65 5f 66 6c | 61 67 20 26 26 20 28 6e |_file_fl|ag && (n|
|000032d0| 61 6d 65 30 20 3d 3d 20 | 30 20 7c 7c 20 6e 61 6d |ame0 == |0 || nam|
|000032e0| 65 31 20 3d 3d 20 30 29 | 29 0a 20 20 20 20 7b 0a |e1 == 0)|). {.|
|000032f0| 20 20 20 20 20 20 63 68 | 61 72 20 2a 6e 61 6d 65 | ch|ar *name|
|00003300| 20 3d 20 6e 61 6d 65 30 | 20 3d 3d 20 30 20 3f 20 | = name0| == 0 ? |
|00003310| 6e 61 6d 65 31 20 3a 20 | 6e 61 6d 65 30 3b 0a 20 |name1 : |name0;. |
|00003320| 20 20 20 20 20 63 68 61 | 72 20 2a 64 69 72 20 3d | cha|r *dir =|
|00003330| 20 6e 61 6d 65 30 20 3d | 3d 20 30 20 3f 20 64 69 | name0 =|= 0 ? di|
|00003340| 72 31 20 3a 20 64 69 72 | 30 3b 0a 20 20 20 20 20 |r1 : dir|0;. |
|00003350| 20 6d 65 73 73 61 67 65 | 20 28 22 4f 6e 6c 79 20 | message| ("Only |
|00003360| 69 6e 20 25 73 3a 20 25 | 73 5c 6e 22 2c 20 64 69 |in %s: %|s\n", di|
|00003370| 72 2c 20 6e 61 6d 65 29 | 3b 0a 20 20 20 20 20 20 |r, name)|;. |
|00003380| 2f 2a 20 52 65 74 75 72 | 6e 20 31 20 73 6f 20 74 |/* Retur|n 1 so t|
|00003390| 68 61 74 20 64 69 66 66 | 5f 64 69 72 73 20 77 69 |hat diff|_dirs wi|
|000033a0| 6c 6c 20 72 65 74 75 72 | 6e 20 31 20 28 22 73 6f |ll retur|n 1 ("so|
|000033b0| 6d 65 20 66 69 6c 65 73 | 20 64 69 66 66 65 72 22 |me files| differ"|
|000033c0| 29 2e 20 20 2a 2f 0a 20 | 20 20 20 20 20 72 65 74 |). */. | ret|
|000033d0| 75 72 6e 20 31 3b 0a 20 | 20 20 20 7d 0a 0a 20 20 |urn 1;. | }.. |
|000033e0| 2f 2a 20 4d 61 72 6b 20 | 61 6e 79 20 6e 6f 6e 65 |/* Mark |any none|
|000033f0| 78 69 73 74 65 6e 74 20 | 66 69 6c 65 20 77 69 74 |xistent |file wit|
|00003400| 68 20 2d 31 20 69 6e 20 | 74 68 65 20 64 65 73 63 |h -1 in |the desc|
|00003410| 20 66 69 65 6c 64 2e 20 | 20 2a 2f 0a 20 20 2f 2a | field. | */. /*|
|00003420| 20 4d 61 72 6b 20 75 6e | 6f 70 65 6e 65 64 20 66 | Mark un|opened f|
|00003430| 69 6c 65 73 20 28 69 2e | 65 2e 20 64 69 72 65 63 |iles (i.|e. direc|
|00003440| 74 6f 72 69 65 73 29 20 | 77 69 74 68 20 2d 32 2e |tories) |with -2.|
|00003450| 20 2a 2f 0a 0a 20 20 69 | 6e 66 5b 30 5d 2e 64 65 | */.. i|nf[0].de|
|00003460| 73 63 20 3d 20 6e 61 6d | 65 30 20 3d 3d 20 30 20 |sc = nam|e0 == 0 |
|00003470| 3f 20 2d 31 20 3a 20 2d | 32 3b 0a 20 20 69 6e 66 |? -1 : -|2;. inf|
|00003480| 5b 31 5d 2e 64 65 73 63 | 20 3d 20 6e 61 6d 65 31 |[1].desc| = name1|
|00003490| 20 3d 3d 20 30 20 3f 20 | 2d 31 20 3a 20 2d 32 3b | == 0 ? |-1 : -2;|
|000034a0| 0a 0a 20 20 2f 2a 20 4e | 6f 77 20 72 65 63 6f 72 |.. /* N|ow recor|
|000034b0| 64 20 74 68 65 20 66 75 | 6c 6c 20 6e 61 6d 65 20 |d the fu|ll name |
|000034c0| 6f 66 20 65 61 63 68 20 | 66 69 6c 65 2c 20 69 6e |of each |file, in|
|000034d0| 63 6c 75 64 69 6e 67 20 | 6e 6f 6e 65 78 69 73 74 |cluding |nonexist|
|000034e0| 65 6e 74 20 6f 6e 65 73 | 2e 20 20 2a 2f 0a 0a 20 |ent ones|. */.. |
|000034f0| 20 69 66 20 28 6e 61 6d | 65 30 20 3d 3d 20 30 29 | if (nam|e0 == 0)|
|00003500| 0a 20 20 20 20 6e 61 6d | 65 30 20 3d 20 6e 61 6d |. nam|e0 = nam|
|00003510| 65 31 3b 0a 20 20 69 66 | 20 28 6e 61 6d 65 31 20 |e1;. if| (name1 |
|00003520| 3d 3d 20 30 29 0a 20 20 | 20 20 6e 61 6d 65 31 20 |== 0). | name1 |
|00003530| 3d 20 6e 61 6d 65 30 3b | 0a 0a 20 20 69 6e 66 5b |= name0;|.. inf[|
|00003540| 30 5d 2e 6e 61 6d 65 20 | 3d 20 64 69 72 30 20 3d |0].name |= dir0 =|
|00003550| 3d 20 30 20 3f 20 6e 61 | 6d 65 30 20 3a 20 63 6f |= 0 ? na|me0 : co|
|00003560| 6e 63 61 74 20 28 64 69 | 72 30 2c 20 22 2f 22 2c |ncat (di|r0, "/",|
|00003570| 20 6e 61 6d 65 30 29 3b | 0a 20 20 69 6e 66 5b 31 | name0);|. inf[1|
|00003580| 5d 2e 6e 61 6d 65 20 3d | 20 64 69 72 31 20 3d 3d |].name =| dir1 ==|
|00003590| 20 30 20 3f 20 6e 61 6d | 65 31 20 3a 20 63 6f 6e | 0 ? nam|e1 : con|
|000035a0| 63 61 74 20 28 64 69 72 | 31 2c 20 22 2f 22 2c 20 |cat (dir|1, "/", |
|000035b0| 6e 61 6d 65 31 29 3b 0a | 0a 20 20 2f 2a 20 53 74 |name1);.|. /* St|
|000035c0| 61 74 20 74 68 65 20 66 | 69 6c 65 73 2e 20 20 52 |at the f|iles. R|
|000035d0| 65 63 6f 72 64 20 77 68 | 65 74 68 65 72 20 74 68 |ecord wh|ether th|
|000035e0| 65 79 20 61 72 65 20 64 | 69 72 65 63 74 6f 72 69 |ey are d|irectori|
|000035f0| 65 73 2e 0a 20 20 20 20 | 20 52 65 63 6f 72 64 20 |es.. | Record |
|00003600| 69 6e 20 73 74 61 74 5f | 72 65 73 75 6c 74 20 77 |in stat_|result w|
|00003610| 68 65 74 68 65 72 20 73 | 74 61 74 20 66 61 69 6c |hether s|tat fail|
|00003620| 73 2e 20 20 2a 2f 0a 0a | 20 20 66 6f 72 20 28 69 |s. */..| for (i|
|00003630| 20 3d 20 30 3b 20 69 20 | 3c 3d 20 31 3b 20 69 2b | = 0; i |<= 1; i+|
|00003640| 2b 29 0a 20 20 20 20 7b | 0a 20 20 20 20 20 20 62 |+). {|. b|
|00003650| 7a 65 72 6f 20 28 26 69 | 6e 66 5b 69 5d 2e 73 74 |zero (&i|nf[i].st|
|00003660| 61 74 2c 20 73 69 7a 65 | 6f 66 28 73 74 72 75 63 |at, size|of(struc|
|00003670| 74 20 73 74 61 74 29 29 | 3b 0a 20 20 20 20 20 20 |t stat))|;. |
|00003680| 69 6e 66 5b 69 5d 2e 64 | 69 72 5f 70 20 3d 20 30 |inf[i].d|ir_p = 0|
|00003690| 3b 0a 20 20 20 20 20 20 | 73 74 61 74 5f 72 65 73 |;. |stat_res|
|000036a0| 75 6c 74 5b 69 5d 20 3d | 20 30 3b 0a 0a 20 20 20 |ult[i] =| 0;.. |
|000036b0| 20 20 20 69 66 20 28 69 | 6e 66 5b 69 5d 2e 64 65 | if (i|nf[i].de|
|000036c0| 73 63 20 21 3d 20 2d 31 | 29 0a 09 7b 0a 09 20 20 |sc != -1|)..{.. |
|000036d0| 63 68 61 72 20 2a 66 69 | 6c 65 6e 61 6d 65 20 3d |char *fi|lename =|
|000036e0| 20 69 6e 66 5b 69 5d 2e | 6e 61 6d 65 3b 0a 0a 09 | inf[i].|name;...|
|000036f0| 20 20 73 74 61 74 5f 72 | 65 73 75 6c 74 5b 69 5d | stat_r|esult[i]|
|00003700| 20 3d 20 0a 09 20 20 20 | 20 73 74 72 63 6d 70 20 | = .. | strcmp |
|00003710| 28 66 69 6c 65 6e 61 6d | 65 2c 20 22 2d 22 29 0a |(filenam|e, "-").|
|00003720| 09 20 20 20 20 20 20 3f | 20 73 74 61 74 20 28 66 |. ?| stat (f|
|00003730| 69 6c 65 6e 61 6d 65 2c | 20 26 69 6e 66 5b 69 5d |ilename,| &inf[i]|
|00003740| 2e 73 74 61 74 29 0a 09 | 20 20 20 20 20 20 3a 20 |.stat)..| : |
|00003750| 66 73 74 61 74 20 28 30 | 2c 20 26 69 6e 66 5b 69 |fstat (0|, &inf[i|
|00003760| 5d 2e 73 74 61 74 29 3b | 0a 09 09 20 20 0a 09 20 |].stat);|... .. |
|00003770| 20 69 66 20 28 73 74 61 | 74 5f 72 65 73 75 6c 74 | if (sta|t_result|
|00003780| 5b 69 5d 20 3c 20 30 29 | 0a 09 20 20 20 20 7b 0a |[i] < 0)|.. {.|
|00003790| 09 20 20 20 20 20 20 70 | 65 72 72 6f 72 5f 77 69 |. p|error_wi|
|000037a0| 74 68 5f 6e 61 6d 65 20 | 28 66 69 6c 65 6e 61 6d |th_name |(filenam|
|000037b0| 65 29 3b 0a 09 20 20 20 | 20 20 20 65 72 72 6f 72 |e);.. | error|
|000037c0| 63 6f 75 6e 74 20 3d 20 | 31 3b 0a 09 20 20 20 20 |count = |1;.. |
|000037d0| 7d 0a 09 20 20 65 6c 73 | 65 0a 09 20 20 20 20 69 |}.. els|e.. i|
|000037e0| 6e 66 5b 69 5d 2e 64 69 | 72 5f 70 20 3d 20 0a 09 |nf[i].di|r_p = ..|
|000037f0| 20 20 20 20 20 20 53 5f | 49 46 44 49 52 20 3d 3d | S_|IFDIR ==|
|00003800| 20 28 69 6e 66 5b 69 5d | 2e 73 74 61 74 2e 73 74 | (inf[i]|.stat.st|
|00003810| 5f 6d 6f 64 65 20 26 20 | 53 5f 49 46 4d 54 29 0a |_mode & |S_IFMT).|
|00003820| 09 20 20 20 20 20 20 26 | 26 20 73 74 72 63 6d 70 |. &|& strcmp|
|00003830| 20 28 66 69 6c 65 6e 61 | 6d 65 2c 20 22 2d 22 29 | (filena|me, "-")|
|00003840| 3b 0a 09 7d 0a 20 20 20 | 20 7d 0a 0a 20 20 2f 2a |;..}. | }.. /*|
|00003850| 20 53 65 65 20 69 66 20 | 74 68 65 20 74 77 6f 20 | See if |the two |
|00003860| 6e 61 6d 65 64 20 66 69 | 6c 65 73 20 61 72 65 20 |named fi|les are |
|00003870| 61 63 74 75 61 6c 6c 79 | 20 74 68 65 20 73 61 6d |actually| the sam|
|00003880| 65 20 70 68 79 73 69 63 | 61 6c 20 66 69 6c 65 2e |e physic|al file.|
|00003890| 0a 20 20 20 20 20 49 66 | 20 73 6f 2c 20 77 65 20 |. If| so, we |
|000038a0| 6b 6e 6f 77 20 74 68 65 | 79 20 61 72 65 20 69 64 |know the|y are id|
|000038b0| 65 6e 74 69 63 61 6c 20 | 77 69 74 68 6f 75 74 20 |entical |without |
|000038c0| 61 63 74 75 61 6c 6c 79 | 20 72 65 61 64 69 6e 67 |actually| reading|
|000038d0| 20 74 68 65 6d 2e 20 20 | 2a 2f 0a 0a 20 20 69 66 | them. |*/.. if|
|000038e0| 20 28 6f 75 74 70 75 74 | 5f 73 74 79 6c 65 20 21 | (output|_style !|
|000038f0| 3d 20 4f 55 54 50 55 54 | 5f 49 46 44 45 46 0a 20 |= OUTPUT|_IFDEF. |
|00003900| 20 20 20 20 20 26 26 20 | 69 6e 66 5b 30 5d 2e 73 | && |inf[0].s|
|00003910| 74 61 74 2e 73 74 5f 69 | 6e 6f 20 3d 3d 20 69 6e |tat.st_i|no == in|
|00003920| 66 5b 31 5d 2e 73 74 61 | 74 2e 73 74 5f 69 6e 6f |f[1].sta|t.st_ino|
|00003930| 0a 20 20 20 20 20 20 26 | 26 20 69 6e 66 5b 30 5d |. &|& inf[0]|
|00003940| 2e 73 74 61 74 2e 73 74 | 5f 64 65 76 20 3d 3d 20 |.stat.st|_dev == |
|00003950| 69 6e 66 5b 31 5d 2e 73 | 74 61 74 2e 73 74 5f 64 |inf[1].s|tat.st_d|
|00003960| 65 76 0a 20 20 20 20 20 | 20 26 26 20 73 74 61 74 |ev. | && stat|
|00003970| 5f 72 65 73 75 6c 74 5b | 30 5d 20 3d 3d 20 30 0a |_result[|0] == 0.|
|00003980| 20 20 20 20 20 20 26 26 | 20 73 74 61 74 5f 72 65 | &&| stat_re|
|00003990| 73 75 6c 74 5b 31 5d 20 | 3d 3d 20 30 29 0a 20 20 |sult[1] |== 0). |
|000039a0| 20 20 7b 0a 20 20 20 20 | 20 20 76 61 6c 20 3d 20 | {. | val = |
|000039b0| 30 3b 0a 20 20 20 20 20 | 20 67 6f 74 6f 20 64 6f |0;. | goto do|
|000039c0| 6e 65 3b 0a 20 20 20 20 | 7d 0a 0a 20 20 69 66 20 |ne;. |}.. if |
|000039d0| 28 6e 61 6d 65 30 20 3d | 3d 20 30 29 0a 20 20 20 |(name0 =|= 0). |
|000039e0| 20 69 6e 66 5b 30 5d 2e | 64 69 72 5f 70 20 3d 20 | inf[0].|dir_p = |
|000039f0| 69 6e 66 5b 31 5d 2e 64 | 69 72 5f 70 3b 0a 20 20 |inf[1].d|ir_p;. |
|00003a00| 69 66 20 28 6e 61 6d 65 | 31 20 3d 3d 20 30 29 0a |if (name|1 == 0).|
|00003a10| 20 20 20 20 69 6e 66 5b | 31 5d 2e 64 69 72 5f 70 | inf[|1].dir_p|
|00003a20| 20 3d 20 69 6e 66 5b 30 | 5d 2e 64 69 72 5f 70 3b | = inf[0|].dir_p;|
|00003a30| 0a 0a 20 20 2f 2a 20 4f | 70 65 6e 20 74 68 65 20 |.. /* O|pen the |
|00003a40| 66 69 6c 65 73 20 61 6e | 64 20 72 65 63 6f 72 64 |files an|d record|
|00003a50| 20 74 68 65 69 72 20 64 | 65 73 63 72 69 70 74 6f | their d|escripto|
|00003a60| 72 73 2e 20 20 2a 2f 0a | 0a 20 20 66 6f 72 20 28 |rs. */.|. for (|
|00003a70| 69 20 3d 20 30 3b 20 69 | 20 3c 3d 20 31 3b 20 69 |i = 0; i| <= 1; i|
|00003a80| 2b 2b 29 0a 20 20 20 20 | 7b 0a 20 20 20 20 20 20 |++). |{. |
|00003a90| 69 66 20 28 69 6e 66 5b | 69 5d 2e 64 65 73 63 20 |if (inf[|i].desc |
|00003aa0| 3d 3d 20 2d 31 29 0a 09 | 3b 0a 20 20 20 20 20 20 |== -1)..|;. |
|00003ab0| 65 6c 73 65 20 69 66 20 | 28 21 73 74 72 63 6d 70 |else if |(!strcmp|
|00003ac0| 20 28 69 6e 66 5b 69 5d | 2e 6e 61 6d 65 2c 20 22 | (inf[i]|.name, "|
|00003ad0| 2d 22 29 29 0a 09 7b 0a | 09 20 20 69 6e 66 5b 69 |-"))..{.|. inf[i|
|00003ae0| 5d 2e 64 65 73 63 20 3d | 20 30 3b 0a 09 20 20 69 |].desc =| 0;.. i|
|00003af0| 6e 66 5b 69 5d 2e 6e 61 | 6d 65 20 3d 20 53 74 61 |nf[i].na|me = Sta|
|00003b00| 6e 64 61 72 64 5f 49 6e | 70 75 74 3b 0a 09 7d 0a |ndard_In|put;..}.|
|00003b10| 20 20 20 20 20 20 2f 2a | 20 44 6f 6e 27 74 20 62 | /*| Don't b|
|00003b20| 6f 74 68 65 72 20 6f 70 | 65 6e 69 6e 67 20 69 66 |other op|ening if|
|00003b30| 20 73 74 61 74 20 61 6c | 72 65 61 64 79 20 66 61 | stat al|ready fa|
|00003b40| 69 6c 65 64 2e 20 20 2a | 2f 0a 20 20 20 20 20 20 |iled. *|/. |
|00003b50| 65 6c 73 65 20 69 66 20 | 28 73 74 61 74 5f 72 65 |else if |(stat_re|
|00003b60| 73 75 6c 74 5b 69 5d 20 | 3d 3d 20 30 20 26 26 20 |sult[i] |== 0 && |
|00003b70| 21 20 69 6e 66 5b 69 5d | 2e 64 69 72 5f 70 29 0a |! inf[i]|.dir_p).|
|00003b80| 09 7b 0a 09 20 20 63 68 | 61 72 20 2a 66 69 6c 65 |.{.. ch|ar *file|
|00003b90| 6e 61 6d 65 20 3d 20 69 | 6e 66 5b 69 5d 2e 6e 61 |name = i|nf[i].na|
|00003ba0| 6d 65 3b 0a 0a 09 20 20 | 69 6e 66 5b 69 5d 2e 64 |me;... |inf[i].d|
|00003bb0| 65 73 63 20 3d 20 6f 70 | 65 6e 20 28 66 69 6c 65 |esc = op|en (file|
|00003bc0| 6e 61 6d 65 2c 20 4f 5f | 52 44 4f 4e 4c 59 2c 20 |name, O_|RDONLY, |
|00003bd0| 30 29 3b 0a 09 20 20 69 | 66 20 28 30 20 3e 20 69 |0);.. i|f (0 > i|
|00003be0| 6e 66 5b 69 5d 2e 64 65 | 73 63 29 0a 09 20 20 20 |nf[i].de|sc).. |
|00003bf0| 20 7b 0a 09 20 20 20 20 | 20 20 70 65 72 72 6f 72 | {.. | perror|
|00003c00| 5f 77 69 74 68 5f 6e 61 | 6d 65 20 28 66 69 6c 65 |_with_na|me (file|
|00003c10| 6e 61 6d 65 29 3b 0a 09 | 20 20 20 20 20 20 65 72 |name);..| er|
|00003c20| 72 6f 72 63 6f 75 6e 74 | 20 3d 20 31 3b 0a 09 20 |rorcount| = 1;.. |
|00003c30| 20 20 20 7d 0a 09 7d 0a | 20 20 20 20 7d 0a 0a 20 | }..}.| }.. |
|00003c40| 20 69 66 20 28 65 72 72 | 6f 72 63 6f 75 6e 74 29 | if (err|orcount)|
|00003c50| 0a 20 20 20 20 7b 0a 0a | 20 20 20 20 20 20 2f 2a |. {..| /*|
|00003c60| 20 49 66 20 65 69 74 68 | 65 72 20 66 69 6c 65 20 | If eith|er file |
|00003c70| 73 68 6f 75 6c 64 20 65 | 78 69 73 74 20 62 75 74 |should e|xist but|
|00003c80| 20 66 61 69 6c 73 20 74 | 6f 20 62 65 20 6f 70 65 | fails t|o be ope|
|00003c90| 6e 65 64 2c 20 72 65 74 | 75 72 6e 20 32 2e 20 20 |ned, ret|urn 2. |
|00003ca0| 2a 2f 0a 0a 20 20 20 20 | 20 20 76 61 6c 20 3d 20 |*/.. | val = |
|00003cb0| 32 3b 0a 0a 20 20 20 20 | 7d 0a 20 20 65 6c 73 65 |2;.. |}. else|
|00003cc0| 20 69 66 20 28 69 6e 66 | 5b 30 5d 2e 64 69 72 5f | if (inf|[0].dir_|
|00003cd0| 70 20 26 26 20 69 6e 66 | 5b 31 5d 2e 64 69 72 5f |p && inf|[1].dir_|
|00003ce0| 70 29 0a 20 20 20 20 7b | 0a 20 20 20 20 20 20 69 |p). {|. i|
|00003cf0| 66 20 28 6f 75 74 70 75 | 74 5f 73 74 79 6c 65 20 |f (outpu|t_style |
|00003d00| 3d 3d 20 4f 55 54 50 55 | 54 5f 49 46 44 45 46 29 |== OUTPU|T_IFDEF)|
|00003d10| 0a 09 66 61 74 61 6c 20 | 28 22 2d 44 20 6f 70 74 |..fatal |("-D opt|
|00003d20| 69 6f 6e 20 6e 6f 74 20 | 73 75 70 70 6f 72 74 65 |ion not |supporte|
|00003d30| 64 20 77 69 74 68 20 64 | 69 72 65 63 74 6f 72 69 |d with d|irectori|
|00003d40| 65 73 22 29 3b 0a 0a 20 | 20 20 20 20 20 2f 2a 20 |es");.. | /* |
|00003d50| 49 66 20 62 6f 74 68 20 | 61 72 65 20 64 69 72 65 |If both |are dire|
|00003d60| 63 74 6f 72 69 65 73 2c | 20 63 6f 6d 70 61 72 65 |ctories,| compare|
|00003d70| 20 74 68 65 20 66 69 6c | 65 73 20 69 6e 20 74 68 | the fil|es in th|
|00003d80| 65 6d 2e 20 20 2a 2f 0a | 0a 20 20 20 20 20 20 69 |em. */.|. i|
|00003d90| 66 20 28 64 65 70 74 68 | 20 3e 20 30 20 26 26 20 |f (depth| > 0 && |
|00003da0| 21 72 65 63 75 72 73 69 | 76 65 29 0a 09 7b 0a 09 |!recursi|ve)..{..|
|00003db0| 20 20 2f 2a 20 42 75 74 | 20 64 6f 6e 27 74 20 63 | /* But| don't c|
|00003dc0| 6f 6d 70 61 72 65 20 64 | 69 72 20 63 6f 6e 74 65 |ompare d|ir conte|
|00003dd0| 6e 74 73 20 6f 6e 65 20 | 6c 65 76 65 6c 20 64 6f |nts one |level do|
|00003de0| 77 6e 0a 09 20 20 20 20 | 20 75 6e 6c 65 73 73 20 |wn.. | unless |
|00003df0| 2d 72 20 77 61 73 20 73 | 70 65 63 69 66 69 65 64 |-r was s|pecified|
|00003e00| 2e 20 20 2a 2f 0a 09 20 | 20 6d 65 73 73 61 67 65 |. */.. | message|
|00003e10| 20 28 22 43 6f 6d 6d 6f | 6e 20 73 75 62 64 69 72 | ("Commo|n subdir|
|00003e20| 65 63 74 6f 72 69 65 73 | 3a 20 25 73 20 61 6e 64 |ectories|: %s and|
|00003e30| 20 25 73 5c 6e 22 2c 0a | 09 09 20 20 20 69 6e 66 | %s\n",.|.. inf|
|00003e40| 5b 30 5d 2e 6e 61 6d 65 | 2c 20 69 6e 66 5b 31 5d |[0].name|, inf[1]|
|00003e50| 2e 6e 61 6d 65 29 3b 0a | 09 20 20 76 61 6c 20 3d |.name);.|. val =|
|00003e60| 20 30 3b 0a 09 7d 0a 20 | 20 20 20 20 20 65 6c 73 | 0;..}. | els|
|00003e70| 65 0a 09 7b 0a 09 20 20 | 76 61 6c 20 3d 20 64 69 |e..{.. |val = di|
|00003e80| 66 66 5f 64 69 72 73 20 | 28 69 6e 66 5b 30 5d 2e |ff_dirs |(inf[0].|
|00003e90| 6e 61 6d 65 2c 20 69 6e | 66 5b 31 5d 2e 6e 61 6d |name, in|f[1].nam|
|00003ea0| 65 2c 20 0a 09 09 09 20 | 20 20 63 6f 6d 70 61 72 |e, .... | compar|
|00003eb0| 65 5f 66 69 6c 65 73 2c | 20 64 65 70 74 68 2c 20 |e_files,| depth, |
|00003ec0| 30 2c 20 30 29 3b 0a 09 | 7d 0a 0a 20 20 20 20 7d |0, 0);..|}.. }|
|00003ed0| 0a 20 20 65 6c 73 65 20 | 69 66 20 28 64 65 70 74 |. else |if (dept|
|00003ee0| 68 20 3d 3d 20 30 20 26 | 26 20 28 69 6e 66 5b 30 |h == 0 &|& (inf[0|
|00003ef0| 5d 2e 64 69 72 5f 70 20 | 7c 7c 20 69 6e 66 5b 31 |].dir_p ||| inf[1|
|00003f00| 5d 2e 64 69 72 5f 70 29 | 29 0a 20 20 20 20 7b 0a |].dir_p)|). {.|
|00003f10| 0a 20 20 20 20 20 20 2f | 2a 20 49 66 20 6f 6e 6c |. /|* If onl|
|00003f20| 79 20 6f 6e 65 20 69 73 | 20 61 20 64 69 72 65 63 |y one is| a direc|
|00003f30| 74 6f 72 79 2c 20 61 6e | 64 20 69 74 20 77 61 73 |tory, an|d it was|
|00003f40| 20 73 70 65 63 69 66 69 | 65 64 20 69 6e 20 74 68 | specifi|ed in th|
|00003f50| 65 20 63 6f 6d 6d 61 6e | 64 20 6c 69 6e 65 2c 0a |e comman|d line,.|
|00003f60| 09 20 75 73 65 20 74 68 | 65 20 66 69 6c 65 20 69 |. use th|e file i|
|00003f70| 6e 20 74 68 61 74 20 64 | 69 72 20 77 68 6f 73 65 |n that d|ir whose|
|00003f80| 20 62 61 73 65 6e 61 6d | 65 20 6d 61 74 63 68 65 | basenam|e matche|
|00003f90| 73 20 74 68 65 20 6f 74 | 68 65 72 20 66 69 6c 65 |s the ot|her file|
|00003fa0| 2e 20 20 2a 2f 0a 0a 20 | 20 20 20 20 20 69 6e 74 |. */.. | int|
|00003fb0| 20 64 69 72 5f 61 72 67 | 20 3d 20 28 69 6e 66 5b | dir_arg| = (inf[|
|00003fc0| 30 5d 2e 64 69 72 5f 70 | 20 3f 20 30 20 3a 20 31 |0].dir_p| ? 0 : 1|
|00003fd0| 29 3b 0a 20 20 20 20 20 | 20 69 6e 74 20 66 6e 6d |);. | int fnm|
|00003fe0| 5f 61 72 67 20 3d 20 28 | 69 6e 66 5b 30 5d 2e 64 |_arg = (|inf[0].d|
|00003ff0| 69 72 5f 70 20 3f 20 31 | 20 3a 20 30 29 3b 0a 20 |ir_p ? 1| : 0);. |
|00004000| 20 20 20 20 20 63 68 61 | 72 20 2a 70 20 3d 20 72 | cha|r *p = r|
|00004010| 69 6e 64 65 78 20 28 69 | 6e 66 5b 66 6e 6d 5f 61 |index (i|nf[fnm_a|
|00004020| 72 67 5d 2e 6e 61 6d 65 | 2c 20 27 2f 27 29 3b 0a |rg].name|, '/');.|
|00004030| 20 20 20 20 20 20 63 68 | 61 72 20 2a 66 69 6c 65 | ch|ar *file|
|00004040| 6e 61 6d 65 20 3d 20 63 | 6f 6e 63 61 74 20 28 69 |name = c|oncat (i|
|00004050| 6e 66 5b 64 69 72 5f 61 | 72 67 5d 2e 6e 61 6d 65 |nf[dir_a|rg].name|
|00004060| 2c 20 20 22 2f 22 2c 0a | 09 09 09 20 20 20 20 20 |, "/",.|... |
|00004070| 20 20 28 70 20 3f 20 70 | 2b 31 20 3a 20 69 6e 66 | (p ? p|+1 : inf|
|00004080| 5b 66 6e 6d 5f 61 72 67 | 5d 2e 6e 61 6d 65 29 29 |[fnm_arg|].name))|
|00004090| 3b 0a 0a 20 20 20 20 20 | 20 69 66 20 28 69 6e 66 |;.. | if (inf|
|000040a0| 5b 66 6e 6d 5f 61 72 67 | 5d 2e 6e 61 6d 65 20 3d |[fnm_arg|].name =|
|000040b0| 3d 20 53 74 61 6e 64 61 | 72 64 5f 49 6e 70 75 74 |= Standa|rd_Input|
|000040c0| 29 0a 09 66 61 74 61 6c | 20 28 22 63 61 6e 27 74 |)..fatal| ("can't|
|000040d0| 20 63 6f 6d 70 61 72 65 | 20 2d 20 74 6f 20 61 20 | compare| - to a |
|000040e0| 64 69 72 65 63 74 6f 72 | 79 22 29 3b 0a 0a 20 20 |director|y");.. |
|000040f0| 20 20 20 20 69 6e 66 5b | 64 69 72 5f 61 72 67 5d | inf[|dir_arg]|
|00004100| 2e 64 65 73 63 20 3d 20 | 6f 70 65 6e 20 28 66 69 |.desc = |open (fi|
|00004110| 6c 65 6e 61 6d 65 2c 20 | 4f 5f 52 44 4f 4e 4c 59 |lename, |O_RDONLY|
|00004120| 2c 20 30 29 3b 0a 0a 20 | 20 20 20 20 20 69 66 20 |, 0);.. | if |
|00004130| 28 30 20 3e 20 69 6e 66 | 5b 64 69 72 5f 61 72 67 |(0 > inf|[dir_arg|
|00004140| 5d 2e 64 65 73 63 29 0a | 09 7b 0a 09 20 20 70 65 |].desc).|.{.. pe|
|00004150| 72 72 6f 72 5f 77 69 74 | 68 5f 6e 61 6d 65 20 28 |rror_wit|h_name (|
|00004160| 66 69 6c 65 6e 61 6d 65 | 29 3b 0a 09 20 20 76 61 |filename|);.. va|
|00004170| 6c 20 3d 20 32 3b 0a 09 | 7d 0a 20 20 20 20 20 20 |l = 2;..|}. |
|00004180| 65 6c 73 65 0a 09 7b 0a | 09 20 20 2f 2a 20 4a 46 |else..{.|. /* JF|
|00004190| 3a 20 70 61 74 63 68 20 | 66 72 6f 6d 20 74 68 65 |: patch |from the|
|000041a0| 20 6e 65 74 20 74 6f 20 | 63 68 65 63 6b 20 61 6e | net to |check an|
|000041b0| 64 20 6d 61 6b 65 20 73 | 75 72 65 20 77 65 20 63 |d make s|ure we c|
|000041c0| 61 6e 20 72 65 61 6c 6c | 79 20 66 72 65 65 0a 09 |an reall|y free..|
|000041d0| 20 20 20 20 20 74 68 69 | 73 2e 20 20 49 66 20 69 | thi|s. If i|
|000041e0| 74 27 73 20 66 72 6f 6d | 20 61 72 67 76 5b 5d 2c |t's from| argv[],|
|000041f0| 20 66 72 65 65 69 6e 67 | 20 69 74 20 69 73 20 61 | freeing| it is a|
|00004200| 20 2a 72 65 61 6c 6c 79 | 2a 20 62 61 64 20 69 64 | *really|* bad id|
|00004210| 65 61 20 2a 2f 0a 09 20 | 20 69 66 20 28 30 20 21 |ea */.. | if (0 !|
|00004220| 3d 20 28 64 69 72 5f 61 | 72 67 20 3f 20 64 69 72 |= (dir_a|rg ? dir|
|00004230| 31 20 3a 20 64 69 72 30 | 29 29 0a 09 20 20 20 20 |1 : dir0|)).. |
|00004240| 66 72 65 65 20 28 69 6e | 66 5b 64 69 72 5f 61 72 |free (in|f[dir_ar|
|00004250| 67 5d 2e 6e 61 6d 65 29 | 3b 0a 09 20 20 69 6e 66 |g].name)|;.. inf|
|00004260| 5b 64 69 72 5f 61 72 67 | 5d 2e 6e 61 6d 65 20 3d |[dir_arg|].name =|
|00004270| 20 66 69 6c 65 6e 61 6d | 65 3b 0a 09 20 20 69 66 | filenam|e;.. if|
|00004280| 20 28 66 73 74 61 74 20 | 28 69 6e 66 5b 64 69 72 | (fstat |(inf[dir|
|00004290| 5f 61 72 67 5d 2e 64 65 | 73 63 2c 20 26 69 6e 66 |_arg].de|sc, &inf|
|000042a0| 5b 64 69 72 5f 61 72 67 | 5d 2e 73 74 61 74 29 20 |[dir_arg|].stat) |
|000042b0| 3c 20 30 29 0a 09 20 20 | 20 20 70 66 61 74 61 6c |< 0).. | pfatal|
|000042c0| 5f 77 69 74 68 5f 6e 61 | 6d 65 20 28 69 6e 66 5b |_with_na|me (inf[|
|000042d0| 64 69 72 5f 61 72 67 5d | 2e 6e 61 6d 65 29 3b 0a |dir_arg]|.name);.|
|000042e0| 0a 09 20 20 69 6e 66 5b | 64 69 72 5f 61 72 67 5d |.. inf[|dir_arg]|
|000042f0| 2e 64 69 72 5f 70 0a 09 | 20 20 20 20 3d 20 28 53 |.dir_p..| = (S|
|00004300| 5f 49 46 44 49 52 20 3d | 3d 20 28 69 6e 66 5b 64 |_IFDIR =|= (inf[d|
|00004310| 69 72 5f 61 72 67 5d 2e | 73 74 61 74 2e 73 74 5f |ir_arg].|stat.st_|
|00004320| 6d 6f 64 65 20 26 20 53 | 5f 49 46 4d 54 29 29 3b |mode & S|_IFMT));|
|00004330| 0a 09 20 20 69 66 20 28 | 69 6e 66 5b 64 69 72 5f |.. if (|inf[dir_|
|00004340| 61 72 67 5d 2e 64 69 72 | 5f 70 29 0a 09 20 20 20 |arg].dir|_p).. |
|00004350| 20 7b 0a 09 20 20 20 20 | 20 20 65 72 72 6f 72 20 | {.. | error |
|00004360| 28 22 25 73 20 69 73 20 | 61 20 64 69 72 65 63 74 |("%s is |a direct|
|00004370| 6f 72 79 20 62 75 74 20 | 25 73 20 69 73 20 6e 6f |ory but |%s is no|
|00004380| 74 22 2c 0a 09 09 20 20 | 20 20 20 69 6e 66 5b 64 |t",... | inf[d|
|00004390| 69 72 5f 61 72 67 5d 2e | 6e 61 6d 65 2c 20 69 6e |ir_arg].|name, in|
|000043a0| 66 5b 66 6e 6d 5f 61 72 | 67 5d 2e 6e 61 6d 65 29 |f[fnm_ar|g].name)|
|000043b0| 3b 0a 09 20 20 20 20 20 | 20 76 61 6c 20 3d 20 31 |;.. | val = 1|
|000043c0| 3b 0a 09 20 20 20 20 7d | 0a 09 20 20 65 6c 73 65 |;.. }|.. else|
|000043d0| 0a 09 20 20 20 20 76 61 | 6c 20 3d 20 64 69 66 66 |.. va|l = diff|
|000043e0| 5f 32 5f 66 69 6c 65 73 | 20 28 69 6e 66 2c 20 64 |_2_files| (inf, d|
|000043f0| 65 70 74 68 29 3b 0a 09 | 7d 0a 0a 20 20 20 20 7d |epth);..|}.. }|
|00004400| 0a 20 20 65 6c 73 65 20 | 69 66 20 28 64 65 70 74 |. else |if (dept|
|00004410| 68 20 3e 20 30 20 26 26 | 20 28 69 6e 66 5b 30 5d |h > 0 &&| (inf[0]|
|00004420| 2e 64 69 72 5f 70 20 7c | 7c 20 69 6e 66 5b 31 5d |.dir_p ||| inf[1]|
|00004430| 2e 64 69 72 5f 70 29 29 | 0a 20 20 20 20 7b 0a 20 |.dir_p))|. {. |
|00004440| 20 20 20 20 20 2f 2a 20 | 50 65 72 68 61 70 73 20 | /* |Perhaps |
|00004450| 77 65 20 68 61 76 65 20 | 61 20 73 75 62 64 69 72 |we have |a subdir|
|00004460| 65 63 74 6f 72 79 20 74 | 68 61 74 20 65 78 69 73 |ectory t|hat exis|
|00004470| 74 73 20 6f 6e 6c 79 20 | 69 6e 20 6f 6e 65 20 64 |ts only |in one d|
|00004480| 69 72 65 63 74 6f 72 79 | 2e 0a 09 20 49 66 20 73 |irectory|... If s|
|00004490| 6f 2c 20 6a 75 73 74 20 | 70 72 69 6e 74 20 61 20 |o, just |print a |
|000044a0| 6d 65 73 73 61 67 65 20 | 74 6f 20 74 68 61 74 20 |message |to that |
|000044b0| 65 66 66 65 63 74 2e 20 | 20 2a 2f 0a 0a 20 20 20 |effect. | */.. |
|000044c0| 20 20 20 69 66 20 28 69 | 6e 66 5b 30 5d 2e 64 65 | if (i|nf[0].de|
|000044d0| 73 63 20 3d 3d 20 2d 31 | 20 7c 7c 20 69 6e 66 5b |sc == -1| || inf[|
|000044e0| 31 5d 2e 64 65 73 63 20 | 3d 3d 20 2d 31 29 0a 09 |1].desc |== -1)..|
|000044f0| 7b 0a 09 20 20 69 66 20 | 28 65 6e 74 69 72 65 5f |{.. if |(entire_|
|00004500| 6e 65 77 5f 66 69 6c 65 | 5f 66 6c 61 67 20 26 26 |new_file|_flag &&|
|00004510| 20 72 65 63 75 72 73 69 | 76 65 29 0a 09 20 20 20 | recursi|ve).. |
|00004520| 20 76 61 6c 20 3d 20 64 | 69 66 66 5f 64 69 72 73 | val = d|iff_dirs|
|00004530| 20 28 69 6e 66 5b 30 5d | 2e 6e 61 6d 65 2c 20 69 | (inf[0]|.name, i|
|00004540| 6e 66 5b 31 5d 2e 6e 61 | 6d 65 2c 20 63 6f 6d 70 |nf[1].na|me, comp|
|00004550| 61 72 65 5f 66 69 6c 65 | 73 2c 20 64 65 70 74 68 |are_file|s, depth|
|00004560| 2c 0a 09 09 09 20 20 20 | 20 20 69 6e 66 5b 30 5d |,.... | inf[0]|
|00004570| 2e 64 65 73 63 20 3d 3d | 20 2d 31 2c 20 69 6e 66 |.desc ==| -1, inf|
|00004580| 5b 31 5d 2e 64 65 73 63 | 20 3d 3d 20 2d 31 29 3b |[1].desc| == -1);|
|00004590| 0a 09 20 20 65 6c 73 65 | 0a 09 20 20 20 20 7b 0a |.. else|.. {.|
|000045a0| 09 20 20 20 20 20 20 63 | 68 61 72 20 2a 64 69 72 |. c|har *dir|
|000045b0| 20 3d 20 28 69 6e 66 5b | 30 5d 2e 64 65 73 63 20 | = (inf[|0].desc |
|000045c0| 3d 3d 20 2d 31 29 20 3f | 20 64 69 72 31 20 3a 20 |== -1) ?| dir1 : |
|000045d0| 64 69 72 30 3b 0a 09 20 | 20 20 20 20 20 6d 65 73 |dir0;.. | mes|
|000045e0| 73 61 67 65 20 28 22 4f | 6e 6c 79 20 69 6e 20 25 |sage ("O|nly in %|
|000045f0| 73 3a 20 25 73 5c 6e 22 | 2c 20 64 69 72 2c 20 6e |s: %s\n"|, dir, n|
|00004600| 61 6d 65 30 29 3b 0a 09 | 20 20 20 20 20 20 76 61 |ame0);..| va|
|00004610| 6c 20 3d 20 31 3b 0a 09 | 20 20 20 20 7d 0a 09 7d |l = 1;..| }..}|
|00004620| 0a 20 20 20 20 20 20 65 | 6c 73 65 0a 09 7b 0a 09 |. e|lse..{..|
|00004630| 20 20 2f 2a 20 57 65 20 | 68 61 76 65 20 61 20 73 | /* We |have a s|
|00004640| 75 62 64 69 72 65 63 74 | 6f 72 79 20 69 6e 20 6f |ubdirect|ory in o|
|00004650| 6e 65 20 64 69 72 65 63 | 74 6f 72 79 0a 09 20 20 |ne direc|tory.. |
|00004660| 20 20 20 61 6e 64 20 61 | 20 66 69 6c 65 20 69 6e | and a| file in|
|00004670| 20 74 68 65 20 6f 74 68 | 65 72 2e 20 20 2a 2f 0a | the oth|er. */.|
|00004680| 0a 09 20 20 69 66 20 28 | 69 6e 66 5b 30 5d 2e 64 |.. if (|inf[0].d|
|00004690| 69 72 5f 70 29 0a 09 20 | 20 20 20 6d 65 73 73 61 |ir_p).. | messa|
|000046a0| 67 65 20 28 22 25 73 20 | 69 73 20 61 20 64 69 72 |ge ("%s |is a dir|
|000046b0| 65 63 74 6f 72 79 20 62 | 75 74 20 25 73 20 69 73 |ectory b|ut %s is|
|000046c0| 20 6e 6f 74 5c 6e 22 2c | 0a 09 09 20 20 20 20 20 | not\n",|... |
|000046d0| 69 6e 66 5b 30 5d 2e 6e | 61 6d 65 2c 20 69 6e 66 |inf[0].n|ame, inf|
|000046e0| 5b 31 5d 2e 6e 61 6d 65 | 29 3b 0a 09 20 20 65 6c |[1].name|);.. el|
|000046f0| 73 65 0a 09 20 20 20 20 | 6d 65 73 73 61 67 65 20 |se.. |message |
|00004700| 28 22 25 73 20 69 73 20 | 61 20 64 69 72 65 63 74 |("%s is |a direct|
|00004710| 6f 72 79 20 62 75 74 20 | 25 73 20 69 73 20 6e 6f |ory but |%s is no|
|00004720| 74 5c 6e 22 2c 0a 09 09 | 20 20 20 20 20 69 6e 66 |t\n",...| inf|
|00004730| 5b 31 5d 2e 6e 61 6d 65 | 2c 20 69 6e 66 5b 30 5d |[1].name|, inf[0]|
|00004740| 2e 6e 61 6d 65 29 3b 0a | 09 20 20 2f 2a 20 54 68 |.name);.|. /* Th|
|00004750| 69 73 20 69 73 20 61 20 | 64 69 66 66 65 72 65 6e |is is a |differen|
|00004760| 63 65 2e 20 20 2a 2f 0a | 09 20 20 76 61 6c 20 3d |ce. */.|. val =|
|00004770| 20 31 3b 0a 09 7d 0a 20 | 20 20 20 7d 0a 20 20 65 | 1;..}. | }. e|
|00004780| 6c 73 65 0a 20 20 20 20 | 7b 0a 0a 20 20 20 20 20 |lse. |{.. |
|00004790| 20 2f 2a 20 42 6f 74 68 | 20 65 78 69 73 74 20 61 | /* Both| exist a|
|000047a0| 6e 64 20 62 6f 74 68 20 | 61 72 65 20 6f 72 64 69 |nd both |are ordi|
|000047b0| 6e 61 72 79 20 66 69 6c | 65 73 2e 20 20 2a 2f 0a |nary fil|es. */.|
|000047c0| 0a 20 20 20 20 20 20 76 | 61 6c 20 3d 20 64 69 66 |. v|al = dif|
|000047d0| 66 5f 32 5f 66 69 6c 65 | 73 20 28 69 6e 66 2c 20 |f_2_file|s (inf, |
|000047e0| 64 65 70 74 68 29 3b 0a | 0a 20 20 20 20 7d 0a 0a |depth);.|. }..|
|000047f0| 20 20 2f 2a 20 4e 6f 77 | 20 74 68 65 20 63 6f 6d | /* Now| the com|
|00004800| 70 61 72 69 73 6f 6e 20 | 68 61 73 20 62 65 65 6e |parison |has been|
|00004810| 20 64 6f 6e 65 2c 20 69 | 66 20 6e 6f 20 65 72 72 | done, i|f no err|
|00004820| 6f 72 20 70 72 65 76 65 | 6e 74 65 64 20 69 74 2c |or preve|nted it,|
|00004830| 0a 20 20 20 20 20 61 6e | 64 20 56 41 4c 20 69 73 |. an|d VAL is|
|00004840| 20 74 68 65 20 76 61 6c | 75 65 20 74 68 69 73 20 | the val|ue this |
|00004850| 66 75 6e 63 74 69 6f 6e | 20 77 69 6c 6c 20 72 65 |function| will re|
|00004860| 74 75 72 6e 2e 20 20 2a | 2f 0a 0a 20 20 69 66 20 |turn. *|/.. if |
|00004870| 28 69 6e 66 5b 30 5d 2e | 64 65 73 63 20 3e 3d 20 |(inf[0].|desc >= |
|00004880| 30 29 0a 20 20 20 20 63 | 6c 6f 73 65 20 28 69 6e |0). c|lose (in|
|00004890| 66 5b 30 5d 2e 64 65 73 | 63 29 3b 0a 20 20 69 66 |f[0].des|c);. if|
|000048a0| 20 28 69 6e 66 5b 31 5d | 2e 64 65 73 63 20 3e 3d | (inf[1]|.desc >=|
|000048b0| 20 30 29 0a 20 20 20 20 | 63 6c 6f 73 65 20 28 69 | 0). |close (i|
|000048c0| 6e 66 5b 31 5d 2e 64 65 | 73 63 29 3b 0a 0a 20 64 |nf[1].de|sc);.. d|
|000048d0| 6f 6e 65 3a 0a 20 20 69 | 66 20 28 76 61 6c 20 3d |one:. i|f (val =|
|000048e0| 3d 20 30 20 26 26 20 21 | 69 6e 66 5b 30 5d 2e 64 |= 0 && !|inf[0].d|
|000048f0| 69 72 5f 70 29 0a 20 20 | 20 20 7b 0a 20 20 20 20 |ir_p). | {. |
|00004900| 20 20 69 66 20 28 70 72 | 69 6e 74 5f 66 69 6c 65 | if (pr|int_file|
|00004910| 5f 73 61 6d 65 5f 66 6c | 61 67 29 0a 09 6d 65 73 |_same_fl|ag)..mes|
|00004920| 73 61 67 65 20 28 22 46 | 69 6c 65 73 20 25 73 20 |sage ("F|iles %s |
|00004930| 61 6e 64 20 25 73 20 61 | 72 65 20 69 64 65 6e 74 |and %s a|re ident|
|00004940| 69 63 61 6c 5c 6e 22 2c | 0a 09 09 20 69 6e 66 5b |ical\n",|... inf[|
|00004950| 30 5d 2e 6e 61 6d 65 2c | 20 69 6e 66 5b 31 5d 2e |0].name,| inf[1].|
|00004960| 6e 61 6d 65 29 3b 0a 20 | 20 20 20 7d 0a 20 20 65 |name);. | }. e|
|00004970| 6c 73 65 0a 20 20 20 20 | 66 66 6c 75 73 68 20 28 |lse. |fflush (|
|00004980| 73 74 64 6f 75 74 29 3b | 0a 0a 20 20 69 66 20 28 |stdout);|.. if (|
|00004990| 64 69 72 30 20 21 3d 20 | 30 29 0a 20 20 20 20 66 |dir0 != |0). f|
|000049a0| 72 65 65 20 28 69 6e 66 | 5b 30 5d 2e 6e 61 6d 65 |ree (inf|[0].name|
|000049b0| 29 3b 0a 20 20 69 66 20 | 28 64 69 72 31 20 21 3d |);. if |(dir1 !=|
|000049c0| 20 30 29 0a 20 20 20 20 | 66 72 65 65 20 28 69 6e | 0). |free (in|
|000049d0| 66 5b 31 5d 2e 6e 61 6d | 65 29 3b 0a 0a 20 20 72 |f[1].nam|e);.. r|
|000049e0| 65 74 75 72 6e 20 76 61 | 6c 3b 0a 7d 0a 00 00 00 |eturn va|l;.}....|
|000049f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a00| 64 69 66 66 2f 61 6e 61 | 6c 79 7a 65 2e 63 00 00 |diff/ana|lyze.c..|
|00004a10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a20| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004a60| 00 00 00 00 20 20 20 36 | 36 36 20 00 20 32 31 36 |.... 6|66 . 216|
|00004a70| 32 33 20 00 20 20 20 20 | 20 30 20 00 20 20 20 20 |23 . | 0 . |
|00004a80| 20 20 36 33 32 36 37 20 | 20 34 37 34 31 37 32 36 | 63267 | 4741726|
|00004a90| 34 34 37 20 20 31 30 36 | 35 32 00 20 30 00 00 00 |447 106|52. 0...|
|00004aa0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004ab0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004ac0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004ad0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004ae0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004af0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b00| 00 75 73 74 61 72 20 20 | 00 6d 69 62 00 00 00 00 |.ustar |.mib....|
|00004b10| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b20| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b30| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b80| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004b90| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004ba0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004bb0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004bc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004bd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004be0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004bf0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00004c00| 2f 2a 20 41 6e 61 6c 79 | 7a 65 20 66 69 6c 65 20 |/* Analy|ze file |
|00004c10| 64 69 66 66 65 72 65 6e | 63 65 73 20 66 6f 72 20 |differen|ces for |
|00004c20| 47 4e 55 20 44 49 46 46 | 2e 0a 20 20 20 43 6f 70 |GNU DIFF|.. Cop|
|00004c30| 79 72 69 67 68 74 20 28 | 43 29 20 31 39 38 38 2c |yright (|C) 1988,|
|00004c40| 20 31 39 38 39 20 46 72 | 65 65 20 53 6f 66 74 77 | 1989 Fr|ee Softw|
|00004c50| 61 72 65 20 46 6f 75 6e | 64 61 74 69 6f 6e 2c 20 |are Foun|dation, |
|00004c60| 49 6e 63 2e 0a 0a 54 68 | 69 73 20 66 69 6c 65 20 |Inc...Th|is file |
|00004c70| 69 73 20 70 61 72 74 20 | 6f 66 20 47 4e 55 20 44 |is part |of GNU D|
|00004c80| 49 46 46 2e 0a 0a 47 4e | 55 20 44 49 46 46 20 69 |IFF...GN|U DIFF i|
|00004c90| 73 20 66 72 65 65 20 73 | 6f 66 74 77 61 72 65 3b |s free s|oftware;|
|00004ca0| 20 79 6f 75 20 63 61 6e | 20 72 65 64 69 73 74 72 | you can| redistr|
|00004cb0| 69 62 75 74 65 20 69 74 | 20 61 6e 64 2f 6f 72 20 |ibute it| and/or |
|00004cc0| 6d 6f 64 69 66 79 0a 69 | 74 20 75 6e 64 65 72 20 |modify.i|t under |
|00004cd0| 74 68 65 20 74 65 72 6d | 73 20 6f 66 20 74 68 65 |the term|s of the|
|00004ce0| 20 47 4e 55 20 47 65 6e | 65 72 61 6c 20 50 75 62 | GNU Gen|eral Pub|
|00004cf0| 6c 69 63 20 4c 69 63 65 | 6e 73 65 20 61 73 20 70 |lic Lice|nse as p|
|00004d00| 75 62 6c 69 73 68 65 64 | 20 62 79 0a 74 68 65 20 |ublished| by.the |
|00004d10| 46 72 65 65 20 53 6f 66 | 74 77 61 72 65 20 46 6f |Free Sof|tware Fo|
|00004d20| 75 6e 64 61 74 69 6f 6e | 3b 20 65 69 74 68 65 72 |undation|; either|
|00004d30| 20 76 65 72 73 69 6f 6e | 20 31 2c 20 6f 72 20 28 | version| 1, or (|
|00004d40| 61 74 20 79 6f 75 72 20 | 6f 70 74 69 6f 6e 29 0a |at your |option).|
|00004d50| 61 6e 79 20 6c 61 74 65 | 72 20 76 65 72 73 69 6f |any late|r versio|
|00004d60| 6e 2e 0a 0a 47 4e 55 20 | 44 49 46 46 20 69 73 20 |n...GNU |DIFF is |
|00004d70| 64 69 73 74 72 69 62 75 | 74 65 64 20 69 6e 20 74 |distribu|ted in t|
|00004d80| 68 65 20 68 6f 70 65 20 | 74 68 61 74 20 69 74 20 |he hope |that it |
|00004d90| 77 69 6c 6c 20 62 65 20 | 75 73 65 66 75 6c 2c 0a |will be |useful,.|
|00004da0| 62 75 74 20 57 49 54 48 | 4f 55 54 20 41 4e 59 20 |but WITH|OUT ANY |
|00004db0| 57 41 52 52 41 4e 54 59 | 3b 20 77 69 74 68 6f 75 |WARRANTY|; withou|
|00004dc0| 74 20 65 76 65 6e 20 74 | 68 65 20 69 6d 70 6c 69 |t even t|he impli|
|00004dd0| 65 64 20 77 61 72 72 61 | 6e 74 79 20 6f 66 0a 4d |ed warra|nty of.M|
|00004de0| 45 52 43 48 41 4e 54 41 | 42 49 4c 49 54 59 20 6f |ERCHANTA|BILITY o|
|00004df0| 72 20 46 49 54 4e 45 53 | 53 20 46 4f 52 20 41 20 |r FITNES|S FOR A |
|00004e00| 50 41 52 54 49 43 55 4c | 41 52 20 50 55 52 50 4f |PARTICUL|AR PURPO|
|00004e10| 53 45 2e 20 20 53 65 65 | 20 74 68 65 0a 47 4e 55 |SE. See| the.GNU|
|00004e20| 20 47 65 6e 65 72 61 6c | 20 50 75 62 6c 69 63 20 | General| Public |
|00004e30| 4c 69 63 65 6e 73 65 20 | 66 6f 72 20 6d 6f 72 65 |License |for more|
|00004e40| 20 64 65 74 61 69 6c 73 | 2e 0a 0a 59 6f 75 20 73 | details|...You s|
|00004e50| 68 6f 75 6c 64 20 68 61 | 76 65 20 72 65 63 65 69 |hould ha|ve recei|
|00004e60| 76 65 64 20 61 20 63 6f | 70 79 20 6f 66 20 74 68 |ved a co|py of th|
|00004e70| 65 20 47 4e 55 20 47 65 | 6e 65 72 61 6c 20 50 75 |e GNU Ge|neral Pu|
|00004e80| 62 6c 69 63 20 4c 69 63 | 65 6e 73 65 0a 61 6c 6f |blic Lic|ense.alo|
|00004e90| 6e 67 20 77 69 74 68 20 | 47 4e 55 20 44 49 46 46 |ng with |GNU DIFF|
|00004ea0| 3b 20 73 65 65 20 74 68 | 65 20 66 69 6c 65 20 43 |; see th|e file C|
|00004eb0| 4f 50 59 49 4e 47 2e 20 | 20 49 66 20 6e 6f 74 2c |OPYING. | If not,|
|00004ec0| 20 77 72 69 74 65 20 74 | 6f 0a 74 68 65 20 46 72 | write t|o.the Fr|
|00004ed0| 65 65 20 53 6f 66 74 77 | 61 72 65 20 46 6f 75 6e |ee Softw|are Foun|
|00004ee0| 64 61 74 69 6f 6e 2c 20 | 36 37 35 20 4d 61 73 73 |dation, |675 Mass|
|00004ef0| 20 41 76 65 2c 20 43 61 | 6d 62 72 69 64 67 65 2c | Ave, Ca|mbridge,|
|00004f00| 20 4d 41 20 30 32 31 33 | 39 2c 20 55 53 41 2e 20 | MA 0213|9, USA. |
|00004f10| 20 2a 2f 0a 0a 2f 2a 20 | 54 68 65 20 62 61 73 69 | */../* |The basi|
|00004f20| 63 20 61 6c 67 6f 72 69 | 74 68 6d 20 69 73 20 64 |c algori|thm is d|
|00004f30| 65 73 63 72 69 62 65 64 | 20 69 6e 3a 20 0a 20 20 |escribed| in: . |
|00004f40| 20 22 41 6e 20 4f 28 4e | 44 29 20 44 69 66 66 65 | "An O(N|D) Diffe|
|00004f50| 72 65 6e 63 65 20 41 6c | 67 6f 72 69 74 68 6d 20 |rence Al|gorithm |
|00004f60| 61 6e 64 20 69 74 73 20 | 56 61 72 69 61 74 69 6f |and its |Variatio|
|00004f70| 6e 73 22 2c 20 45 75 67 | 65 6e 65 20 4d 79 65 72 |ns", Eug|ene Myer|
|00004f80| 73 2c 0a 20 20 20 41 6c | 67 6f 72 69 74 68 6d 69 |s,. Al|gorithmi|
|00004f90| 63 61 20 56 6f 6c 2e 20 | 31 20 4e 6f 2e 20 32 2c |ca Vol. |1 No. 2,|
|00004fa0| 20 31 39 38 36 2c 20 70 | 20 32 35 31 2e 20 20 2a | 1986, p| 251. *|
|00004fb0| 2f 0a 0a 23 69 6e 63 6c | 75 64 65 20 22 64 69 66 |/..#incl|ude "dif|
|00004fc0| 66 2e 68 22 0a 0a 73 74 | 72 75 63 74 20 63 68 61 |f.h"..st|ruct cha|
|00004fd0| 6e 67 65 20 2a 66 69 6e | 64 5f 63 68 61 6e 67 65 |nge *fin|d_change|
|00004fe0| 20 28 29 3b 0a 76 6f 69 | 64 20 66 69 6e 69 73 68 | ();.voi|d finish|
|00004ff0| 5f 6f 75 74 70 75 74 20 | 28 29 3b 0a 76 6f 69 64 |_output |();.void|
|00005000| 20 70 72 69 6e 74 5f 63 | 6f 6e 74 65 78 74 5f 68 | print_c|ontext_h|
|00005010| 65 61 64 65 72 20 28 29 | 3b 0a 76 6f 69 64 20 70 |eader ()|;.void p|
|00005020| 72 69 6e 74 5f 63 6f 6e | 74 65 78 74 5f 73 63 72 |rint_con|text_scr|
|00005030| 69 70 74 20 28 29 3b 0a | 76 6f 69 64 20 70 72 69 |ipt ();.|void pri|
|00005040| 6e 74 5f 65 64 5f 73 63 | 72 69 70 74 20 28 29 3b |nt_ed_sc|ript ();|
|00005050| 0a 76 6f 69 64 20 70 72 | 69 6e 74 5f 69 66 64 65 |.void pr|int_ifde|
|00005060| 66 5f 73 63 72 69 70 74 | 20 28 29 3b 0a 76 6f 69 |f_script| ();.voi|
|00005070| 64 20 70 72 69 6e 74 5f | 6e 6f 72 6d 61 6c 5f 73 |d print_|normal_s|
|00005080| 63 72 69 70 74 20 28 29 | 3b 0a 76 6f 69 64 20 70 |cript ()|;.void p|
|00005090| 72 69 6e 74 5f 72 63 73 | 5f 73 63 72 69 70 74 20 |rint_rcs|_script |
|000050a0| 28 29 3b 0a 76 6f 69 64 | 20 70 72 5f 66 6f 72 77 |();.void| pr_forw|
|000050b0| 61 72 64 5f 65 64 5f 73 | 63 72 69 70 74 20 28 29 |ard_ed_s|cript ()|
|000050c0| 3b 0a 76 6f 69 64 20 73 | 65 74 75 70 5f 6f 75 74 |;.void s|etup_out|
|000050d0| 70 75 74 20 28 29 3b 0a | 0a 65 78 74 65 72 6e 20 |put ();.|.extern |
|000050e0| 69 6e 74 20 6e 6f 5f 64 | 69 73 63 61 72 64 73 3b |int no_d|iscards;|
|000050f0| 0a 0a 73 74 61 74 69 63 | 20 69 6e 74 20 2a 78 76 |..static| int *xv|
|00005100| 65 63 2c 20 2a 79 76 65 | 63 3b 09 2f 2a 20 56 65 |ec, *yve|c;./* Ve|
|00005110| 63 74 6f 72 73 20 62 65 | 69 6e 67 20 63 6f 6d 70 |ctors be|ing comp|
|00005120| 61 72 65 64 2e 20 2a 2f | 0a 73 74 61 74 69 63 20 |ared. */|.static |
|00005130| 69 6e 74 20 2a 66 64 69 | 61 67 3b 09 09 2f 2a 20 |int *fdi|ag;../* |
|00005140| 56 65 63 74 6f 72 2c 20 | 69 6e 64 65 78 65 64 20 |Vector, |indexed |
|00005150| 62 79 20 64 69 61 67 6f | 6e 61 6c 2c 20 63 6f 6e |by diago|nal, con|
|00005160| 74 61 69 6e 69 6e 67 0a | 09 09 09 09 20 20 20 74 |taining.|.... t|
|00005170| 68 65 20 58 20 63 6f 6f | 72 64 69 6e 61 74 65 20 |he X coo|rdinate |
|00005180| 6f 66 20 74 68 65 20 70 | 6f 69 6e 74 20 66 75 72 |of the p|oint fur|
|00005190| 74 68 65 73 74 0a 09 09 | 09 09 20 20 20 61 6c 6f |thest...|.. alo|
|000051a0| 6e 67 20 74 68 65 20 67 | 69 76 65 6e 20 64 69 61 |ng the g|iven dia|
|000051b0| 67 6f 6e 61 6c 20 69 6e | 20 74 68 65 20 66 6f 72 |gonal in| the for|
|000051c0| 77 61 72 64 0a 09 09 09 | 09 20 20 20 73 65 61 72 |ward....|. sear|
|000051d0| 63 68 20 6f 66 20 74 68 | 65 20 65 64 69 74 20 6d |ch of th|e edit m|
|000051e0| 61 74 72 69 78 2e 20 2a | 2f 0a 73 74 61 74 69 63 |atrix. *|/.static|
|000051f0| 20 69 6e 74 20 2a 62 64 | 69 61 67 3b 09 09 2f 2a | int *bd|iag;../*|
|00005200| 20 56 65 63 74 6f 72 2c | 20 69 6e 64 65 78 65 64 | Vector,| indexed|
|00005210| 20 62 79 20 64 69 61 67 | 6f 6e 61 6c 2c 20 63 6f | by diag|onal, co|
|00005220| 6e 74 61 69 6e 69 6e 67 | 0a 09 09 09 09 20 20 20 |ntaining|..... |
|00005230| 74 68 65 20 58 20 63 6f | 6f 72 64 69 6e 61 74 65 |the X co|ordinate|
|00005240| 20 6f 66 20 74 68 65 20 | 70 6f 69 6e 74 20 66 75 | of the |point fu|
|00005250| 72 74 68 65 73 74 0a 09 | 09 09 09 20 20 20 61 6c |rthest..|... al|
|00005260| 6f 6e 67 20 74 68 65 20 | 67 69 76 65 6e 20 64 69 |ong the |given di|
|00005270| 61 67 6f 6e 61 6c 20 69 | 6e 20 74 68 65 20 62 61 |agonal i|n the ba|
|00005280| 63 6b 77 61 72 64 0a 09 | 09 09 09 20 20 20 73 65 |ckward..|... se|
|00005290| 61 72 63 68 20 6f 66 20 | 74 68 65 20 65 64 69 74 |arch of |the edit|
|000052a0| 20 6d 61 74 72 69 78 2e | 20 2a 2f 0a 0a 2f 2a 20 | matrix.| */../* |
|000052b0| 46 69 6e 64 20 74 68 65 | 20 6d 69 64 70 6f 69 6e |Find the| midpoin|
|000052c0| 74 20 6f 66 20 74 68 65 | 20 73 68 6f 72 74 65 73 |t of the| shortes|
|000052d0| 74 20 65 64 69 74 20 73 | 63 72 69 70 74 20 66 6f |t edit s|cript fo|
|000052e0| 72 20 61 20 73 70 65 63 | 69 66 69 65 64 0a 20 20 |r a spec|ified. |
|000052f0| 20 70 6f 72 74 69 6f 6e | 20 6f 66 20 74 68 65 20 | portion| of the |
|00005300| 74 77 6f 20 66 69 6c 65 | 73 2e 0a 0a 20 20 20 57 |two file|s... W|
|00005310| 65 20 73 63 61 6e 20 66 | 72 6f 6d 20 74 68 65 20 |e scan f|rom the |
|00005320| 62 65 67 69 6e 6e 69 6e | 67 73 20 6f 66 20 74 68 |beginnin|gs of th|
|00005330| 65 20 66 69 6c 65 73 2c | 20 61 6e 64 20 73 69 6d |e files,| and sim|
|00005340| 75 6c 74 61 6e 65 6f 75 | 73 6c 79 20 66 72 6f 6d |ultaneou|sly from|
|00005350| 20 74 68 65 20 65 6e 64 | 73 2c 0a 20 20 20 64 6f | the end|s,. do|
|00005360| 69 6e 67 20 61 20 62 72 | 65 61 64 74 68 2d 66 69 |ing a br|eadth-fi|
|00005370| 72 73 74 20 73 65 61 72 | 63 68 20 74 68 72 6f 75 |rst sear|ch throu|
|00005380| 67 68 20 74 68 65 20 73 | 70 61 63 65 20 6f 66 20 |gh the s|pace of |
|00005390| 65 64 69 74 2d 73 65 71 | 75 65 6e 63 65 2e 0a 20 |edit-seq|uence.. |
|000053a0| 20 20 57 68 65 6e 20 74 | 68 65 20 74 77 6f 20 73 | When t|he two s|
|000053b0| 65 61 72 63 68 65 73 20 | 6d 65 65 74 2c 20 77 65 |earches |meet, we|
|000053c0| 20 68 61 76 65 20 66 6f | 75 6e 64 20 74 68 65 20 | have fo|und the |
|000053d0| 6d 69 64 70 6f 69 6e 74 | 20 6f 66 20 74 68 65 20 |midpoint| of the |
|000053e0| 73 68 6f 72 74 65 73 74 | 0a 20 20 20 65 64 69 74 |shortest|. edit|
|000053f0| 20 73 65 71 75 65 6e 63 | 65 2e 0a 0a 20 20 20 54 | sequenc|e... T|
|00005400| 68 65 20 76 61 6c 75 65 | 20 72 65 74 75 72 6e 65 |he value| returne|
|00005410| 64 20 69 73 20 74 68 65 | 20 6e 75 6d 62 65 72 20 |d is the| number |
|00005420| 6f 66 20 74 68 65 20 64 | 69 61 67 6f 6e 61 6c 20 |of the d|iagonal |
|00005430| 6f 6e 20 77 68 69 63 68 | 20 74 68 65 20 6d 69 64 |on which| the mid|
|00005440| 70 6f 69 6e 74 20 6c 69 | 65 73 2e 0a 20 20 20 54 |point li|es.. T|
|00005450| 68 65 20 64 69 61 67 6f | 6e 61 6c 20 6e 75 6d 62 |he diago|nal numb|
|00005460| 65 72 20 65 71 75 61 6c | 73 20 74 68 65 20 6e 75 |er equal|s the nu|
|00005470| 6d 62 65 72 20 6f 66 20 | 69 6e 73 65 72 74 65 64 |mber of |inserted|
|00005480| 20 6c 69 6e 65 73 20 6d | 69 6e 75 73 20 74 68 65 | lines m|inus the|
|00005490| 20 6e 75 6d 62 65 72 0a | 20 20 20 6f 66 20 64 65 | number.| of de|
|000054a0| 6c 65 74 65 64 20 6c 69 | 6e 65 73 20 28 63 6f 75 |leted li|nes (cou|
|000054b0| 6e 74 69 6e 67 20 6f 6e | 6c 79 20 6c 69 6e 65 73 |nting on|ly lines|
|000054c0| 20 62 65 66 6f 72 65 20 | 74 68 65 20 6d 69 64 70 | before |the midp|
|000054d0| 6f 69 6e 74 29 2e 0a 20 | 20 20 54 68 65 20 65 64 |oint).. | The ed|
|000054e0| 69 74 20 63 6f 73 74 20 | 69 73 20 73 74 6f 72 65 |it cost |is store|
|000054f0| 64 20 69 6e 74 6f 20 2a | 43 4f 53 54 3b 20 74 68 |d into *|COST; th|
|00005500| 69 73 20 69 73 20 74 68 | 65 20 74 6f 74 61 6c 20 |is is th|e total |
|00005510| 6e 75 6d 62 65 72 20 6f | 66 0a 20 20 20 6c 69 6e |number o|f. lin|
|00005520| 65 73 20 69 6e 73 65 72 | 74 65 64 20 6f 72 20 64 |es inser|ted or d|
|00005530| 65 6c 65 74 65 64 20 28 | 63 6f 75 6e 74 69 6e 67 |eleted (|counting|
|00005540| 20 6f 6e 6c 79 20 6c 69 | 6e 65 73 20 62 65 66 6f | only li|nes befo|
|00005550| 72 65 20 74 68 65 20 6d | 69 64 70 6f 69 6e 74 29 |re the m|idpoint)|
|00005560| 2e 0a 0a 20 20 20 54 68 | 69 73 20 66 75 6e 63 74 |... Th|is funct|
|00005570| 69 6f 6e 20 61 73 73 75 | 6d 65 73 20 74 68 61 74 |ion assu|mes that|
|00005580| 20 74 68 65 20 66 69 72 | 73 74 20 6c 69 6e 65 73 | the fir|st lines|
|00005590| 20 6f 66 20 74 68 65 20 | 73 70 65 63 69 66 69 65 | of the |specifie|
|000055a0| 64 20 70 6f 72 74 69 6f | 6e 73 0a 20 20 20 6f 66 |d portio|ns. of|
|000055b0| 20 74 68 65 20 74 77 6f | 20 66 69 6c 65 73 20 64 | the two| files d|
|000055c0| 6f 20 6e 6f 74 20 6d 61 | 74 63 68 2c 20 61 6e 64 |o not ma|tch, and|
|000055d0| 20 6c 69 6b 65 77 69 73 | 65 20 74 68 61 74 20 74 | likewis|e that t|
|000055e0| 68 65 20 6c 61 73 74 20 | 6c 69 6e 65 73 20 64 6f |he last |lines do|
|000055f0| 20 6e 6f 74 0a 20 20 20 | 6d 61 74 63 68 2e 20 20 | not. |match. |
|00005600| 54 68 65 20 63 61 6c 6c | 65 72 20 6d 75 73 74 20 |The call|er must |
|00005610| 74 72 69 6d 20 6d 61 74 | 63 68 69 6e 67 20 6c 69 |trim mat|ching li|
|00005620| 6e 65 73 20 66 72 6f 6d | 20 74 68 65 20 62 65 67 |nes from| the beg|
|00005630| 69 6e 6e 69 6e 67 20 61 | 6e 64 20 65 6e 64 0a 20 |inning a|nd end. |
|00005640| 20 20 6f 66 20 74 68 65 | 20 70 6f 72 74 69 6f 6e | of the| portion|
|00005650| 73 20 69 74 20 69 73 20 | 67 6f 69 6e 67 20 74 6f |s it is |going to|
|00005660| 20 73 70 65 63 69 66 79 | 2e 0a 0a 20 20 20 4e 6f | specify|... No|
|00005670| 74 65 20 74 68 61 74 20 | 69 66 20 77 65 20 72 65 |te that |if we re|
|00005680| 74 75 72 6e 20 74 68 65 | 20 22 77 72 6f 6e 67 22 |turn the| "wrong"|
|00005690| 20 64 69 61 67 6f 6e 61 | 6c 20 76 61 6c 75 65 2c | diagona|l value,|
|000056a0| 20 6f 72 20 69 66 0a 20 | 20 20 74 68 65 20 76 61 | or if. | the va|
|000056b0| 6c 75 65 20 6f 66 20 62 | 64 69 61 67 20 61 74 20 |lue of b|diag at |
|000056c0| 74 68 61 74 20 64 69 61 | 67 6f 6e 61 6c 20 69 73 |that dia|gonal is|
|000056d0| 20 22 77 72 6f 6e 67 22 | 2c 0a 20 20 20 74 68 65 | "wrong"|,. the|
|000056e0| 20 77 6f 72 73 74 20 74 | 68 69 73 20 63 61 6e 20 | worst t|his can |
|000056f0| 64 6f 20 69 73 20 63 61 | 75 73 65 20 73 75 62 6f |do is ca|use subo|
|00005700| 70 74 69 6d 61 6c 20 64 | 69 66 66 20 6f 75 74 70 |ptimal d|iff outp|
|00005710| 75 74 2e 0a 20 20 20 49 | 74 20 63 61 6e 6e 6f 74 |ut.. I|t cannot|
|00005720| 20 63 61 75 73 65 20 69 | 6e 63 6f 72 72 65 63 74 | cause i|ncorrect|
|00005730| 20 64 69 66 66 20 6f 75 | 74 70 75 74 2e 20 20 2a | diff ou|tput. *|
|00005740| 2f 0a 0a 73 74 61 74 69 | 63 20 69 6e 74 0a 64 69 |/..stati|c int.di|
|00005750| 61 67 20 28 78 6f 66 66 | 2c 20 78 6c 69 6d 2c 20 |ag (xoff|, xlim, |
|00005760| 79 6f 66 66 2c 20 79 6c | 69 6d 2c 20 63 6f 73 74 |yoff, yl|im, cost|
|00005770| 29 0a 20 20 20 20 20 69 | 6e 74 20 78 6f 66 66 2c |). i|nt xoff,|
|00005780| 20 78 6c 69 6d 2c 20 79 | 6f 66 66 2c 20 79 6c 69 | xlim, y|off, yli|
|00005790| 6d 3b 0a 20 20 20 20 20 | 69 6e 74 20 2a 63 6f 73 |m;. |int *cos|
|000057a0| 74 3b 0a 7b 0a 20 20 69 | 6e 74 20 2a 63 6f 6e 73 |t;.{. i|nt *cons|
|000057b0| 74 20 66 64 20 3d 20 66 | 64 69 61 67 3b 09 2f 2a |t fd = f|diag;./*|
|000057c0| 20 47 69 76 65 20 74 68 | 65 20 63 6f 6d 70 69 6c | Give th|e compil|
|000057d0| 65 72 20 61 20 63 68 61 | 6e 63 65 2e 20 2a 2f 0a |er a cha|nce. */.|
|000057e0| 20 20 69 6e 74 20 2a 63 | 6f 6e 73 74 20 62 64 20 | int *c|onst bd |
|000057f0| 3d 20 62 64 69 61 67 3b | 09 2f 2a 20 41 64 64 69 |= bdiag;|./* Addi|
|00005800| 74 69 6f 6e 61 6c 20 68 | 65 6c 70 20 66 6f 72 20 |tional h|elp for |
|00005810| 74 68 65 20 63 6f 6d 70 | 69 6c 65 72 2e 20 2a 2f |the comp|iler. */|
|00005820| 0a 20 20 69 6e 74 20 2a | 63 6f 6e 73 74 20 78 76 |. int *|const xv|
|00005830| 20 3d 20 78 76 65 63 3b | 09 09 2f 2a 20 53 74 69 | = xvec;|../* Sti|
|00005840| 6c 6c 20 6d 6f 72 65 20 | 68 65 6c 70 20 66 6f 72 |ll more |help for|
|00005850| 20 74 68 65 20 63 6f 6d | 70 69 6c 65 72 2e 20 2a | the com|piler. *|
|00005860| 2f 0a 20 20 69 6e 74 20 | 2a 63 6f 6e 73 74 20 79 |/. int |*const y|
|00005870| 76 20 3d 20 79 76 65 63 | 3b 09 09 2f 2a 20 41 6e |v = yvec|;../* An|
|00005880| 64 20 6d 6f 72 65 20 61 | 6e 64 20 6d 6f 72 65 20 |d more a|nd more |
|00005890| 2e 20 2e 20 2e 20 2a 2f | 0a 20 20 63 6f 6e 73 74 |. . . */|. const|
|000058a0| 20 69 6e 74 20 64 6d 69 | 6e 20 3d 20 78 6f 66 66 | int dmi|n = xoff|
|000058b0| 20 2d 20 79 6c 69 6d 3b | 09 2f 2a 20 4d 69 6e 69 | - ylim;|./* Mini|
|000058c0| 6d 75 6d 20 76 61 6c 69 | 64 20 64 69 61 67 6f 6e |mum vali|d diagon|
|000058d0| 61 6c 2e 20 2a 2f 0a 20 | 20 63 6f 6e 73 74 20 69 |al. */. | const i|
|000058e0| 6e 74 20 64 6d 61 78 20 | 3d 20 78 6c 69 6d 20 2d |nt dmax |= xlim -|
|000058f0| 20 79 6f 66 66 3b 09 2f | 2a 20 4d 61 78 69 6d 75 | yoff;./|* Maximu|
|00005900| 6d 20 76 61 6c 69 64 20 | 64 69 61 67 6f 6e 61 6c |m valid |diagonal|
|00005910| 2e 20 2a 2f 0a 20 20 63 | 6f 6e 73 74 20 69 6e 74 |. */. c|onst int|
|00005920| 20 66 6d 69 64 20 3d 20 | 78 6f 66 66 20 2d 20 79 | fmid = |xoff - y|
|00005930| 6f 66 66 3b 09 2f 2a 20 | 43 65 6e 74 65 72 20 64 |off;./* |Center d|
|00005940| 69 61 67 6f 6e 61 6c 20 | 6f 66 20 74 6f 70 2d 64 |iagonal |of top-d|
|00005950| 6f 77 6e 20 73 65 61 72 | 63 68 2e 20 2a 2f 0a 20 |own sear|ch. */. |
|00005960| 20 63 6f 6e 73 74 20 69 | 6e 74 20 62 6d 69 64 20 | const i|nt bmid |
|00005970| 3d 20 78 6c 69 6d 20 2d | 20 79 6c 69 6d 3b 09 2f |= xlim -| ylim;./|
|00005980| 2a 20 43 65 6e 74 65 72 | 20 64 69 61 67 6f 6e 61 |* Center| diagona|
|00005990| 6c 20 6f 66 20 62 6f 74 | 74 6f 6d 2d 75 70 20 73 |l of bot|tom-up s|
|000059a0| 65 61 72 63 68 2e 20 2a | 2f 0a 20 20 69 6e 74 20 |earch. *|/. int |
|000059b0| 66 6d 69 6e 20 3d 20 66 | 6d 69 64 2c 20 66 6d 61 |fmin = f|mid, fma|
|000059c0| 78 20 3d 20 66 6d 69 64 | 3b 09 2f 2a 20 4c 69 6d |x = fmid|;./* Lim|
|000059d0| 69 74 73 20 6f 66 20 74 | 6f 70 2d 64 6f 77 6e 20 |its of t|op-down |
|000059e0| 73 65 61 72 63 68 2e 20 | 2a 2f 0a 20 20 69 6e 74 |search. |*/. int|
|000059f0| 20 62 6d 69 6e 20 3d 20 | 62 6d 69 64 2c 20 62 6d | bmin = |bmid, bm|
|00005a00| 61 78 20 3d 20 62 6d 69 | 64 3b 09 2f 2a 20 4c 69 |ax = bmi|d;./* Li|
|00005a10| 6d 69 74 73 20 6f 66 20 | 62 6f 74 74 6f 6d 2d 75 |mits of |bottom-u|
|00005a20| 70 20 73 65 61 72 63 68 | 2e 20 2a 2f 0a 20 20 69 |p search|. */. i|
|00005a30| 6e 74 20 63 3b 09 09 09 | 2f 2a 20 43 6f 73 74 2e |nt c;...|/* Cost.|
|00005a40| 20 2a 2f 0a 20 20 69 6e | 74 20 6f 64 64 20 3d 20 | */. in|t odd = |
|00005a50| 66 6d 69 64 20 2d 20 62 | 6d 69 64 20 26 20 31 3b |fmid - b|mid & 1;|
|00005a60| 09 2f 2a 20 54 72 75 65 | 20 69 66 20 73 6f 75 74 |./* True| if sout|
|00005a70| 68 65 61 73 74 20 63 6f | 72 6e 65 72 20 69 73 20 |heast co|rner is |
|00005a80| 6f 6e 20 61 6e 20 6f 64 | 64 0a 09 09 09 09 20 20 |on an od|d..... |
|00005a90| 20 64 69 61 67 6f 6e 61 | 6c 20 77 69 74 68 20 72 | diagona|l with r|
|00005aa0| 65 73 70 65 63 74 20 74 | 6f 20 74 68 65 20 6e 6f |espect t|o the no|
|00005ab0| 72 74 68 77 65 73 74 2e | 20 2a 2f 0a 0a 20 20 66 |rthwest.| */.. f|
|00005ac0| 64 5b 66 6d 69 64 5d 20 | 3d 20 78 6f 66 66 3b 0a |d[fmid] |= xoff;.|
|00005ad0| 20 20 62 64 5b 62 6d 69 | 64 5d 20 3d 20 78 6c 69 | bd[bmi|d] = xli|
|00005ae0| 6d 3b 0a 0a 20 20 66 6f | 72 20 28 63 20 3d 20 31 |m;.. fo|r (c = 1|
|00005af0| 3b 3b 20 2b 2b 63 29 0a | 20 20 20 20 7b 0a 20 20 |;; ++c).| {. |
|00005b00| 20 20 20 20 69 6e 74 20 | 64 3b 09 09 09 2f 2a 20 | int |d;.../* |
|00005b10| 41 63 74 69 76 65 20 64 | 69 61 67 6f 6e 61 6c 2e |Active d|iagonal.|
|00005b20| 20 2a 2f 0a 20 20 20 20 | 20 20 69 6e 74 20 62 69 | */. | int bi|
|00005b30| 67 5f 73 6e 61 6b 65 20 | 3d 20 30 3b 0a 0a 20 20 |g_snake |= 0;.. |
|00005b40| 20 20 20 20 2f 2a 20 45 | 78 74 65 6e 64 20 74 68 | /* E|xtend th|
|00005b50| 65 20 74 6f 70 2d 64 6f | 77 6e 20 73 65 61 72 63 |e top-do|wn searc|
|00005b60| 68 20 62 79 20 61 6e 20 | 65 64 69 74 20 73 74 65 |h by an |edit ste|
|00005b70| 70 20 69 6e 20 65 61 63 | 68 20 64 69 61 67 6f 6e |p in eac|h diagon|
|00005b80| 61 6c 2e 20 2a 2f 0a 20 | 20 20 20 20 20 66 6d 69 |al. */. | fmi|
|00005b90| 6e 20 3e 20 64 6d 69 6e | 20 3f 20 66 64 5b 2d 2d |n > dmin| ? fd[--|
|00005ba0| 66 6d 69 6e 20 2d 20 31 | 5d 20 3d 20 2d 31 20 3a |fmin - 1|] = -1 :|
|00005bb0| 20 2b 2b 66 6d 69 6e 3b | 0a 20 20 20 20 20 20 66 | ++fmin;|. f|
|00005bc0| 6d 61 78 20 3c 20 64 6d | 61 78 20 3f 20 66 64 5b |max < dm|ax ? fd[|
|00005bd0| 2b 2b 66 6d 61 78 20 2b | 20 31 5d 20 3d 20 2d 31 |++fmax +| 1] = -1|
|00005be0| 20 3a 20 2d 2d 66 6d 61 | 78 3b 0a 20 20 20 20 20 | : --fma|x;. |
|00005bf0| 20 66 6f 72 20 28 64 20 | 3d 20 66 6d 61 78 3b 20 | for (d |= fmax; |
|00005c00| 64 20 3e 3d 20 66 6d 69 | 6e 3b 20 64 20 2d 3d 20 |d >= fmi|n; d -= |
|00005c10| 32 29 0a 09 7b 0a 09 20 | 20 69 6e 74 20 78 2c 20 |2)..{.. | int x, |
|00005c20| 79 2c 20 6f 6c 64 78 2c | 20 74 6c 6f 20 3d 20 66 |y, oldx,| tlo = f|
|00005c30| 64 5b 64 20 2d 20 31 5d | 2c 20 74 68 69 20 3d 20 |d[d - 1]|, thi = |
|00005c40| 66 64 5b 64 20 2b 20 31 | 5d 3b 0a 0a 09 20 20 69 |fd[d + 1|];... i|
|00005c50| 66 20 28 74 6c 6f 20 3e | 3d 20 74 68 69 29 0a 09 |f (tlo >|= thi)..|
|00005c60| 20 20 20 20 78 20 3d 20 | 74 6c 6f 20 2b 20 31 3b | x = |tlo + 1;|
|00005c70| 0a 09 20 20 65 6c 73 65 | 0a 09 20 20 20 20 78 20 |.. else|.. x |
|00005c80| 3d 20 74 68 69 3b 0a 09 | 20 20 6f 6c 64 78 20 3d |= thi;..| oldx =|
|00005c90| 20 78 3b 0a 09 20 20 79 | 20 3d 20 78 20 2d 20 64 | x;.. y| = x - d|
|00005ca0| 3b 0a 09 20 20 77 68 69 | 6c 65 20 28 78 20 3c 20 |;.. whi|le (x < |
|00005cb0| 78 6c 69 6d 20 26 26 20 | 79 20 3c 20 79 6c 69 6d |xlim && |y < ylim|
|00005cc0| 20 26 26 20 78 76 5b 78 | 5d 20 3d 3d 20 79 76 5b | && xv[x|] == yv[|
|00005cd0| 79 5d 29 0a 09 20 20 20 | 20 2b 2b 78 2c 20 2b 2b |y]).. | ++x, ++|
|00005ce0| 79 3b 0a 09 20 20 69 66 | 20 28 78 20 2d 20 6f 6c |y;.. if| (x - ol|
|00005cf0| 64 78 20 3e 20 32 30 29 | 0a 09 20 20 20 20 62 69 |dx > 20)|.. bi|
|00005d00| 67 5f 73 6e 61 6b 65 20 | 3d 20 31 3b 0a 09 20 20 |g_snake |= 1;.. |
|00005d10| 66 64 5b 64 5d 20 3d 20 | 78 3b 0a 09 20 20 69 66 |fd[d] = |x;.. if|
|00005d20| 20 28 6f 64 64 20 26 26 | 20 62 6d 69 6e 20 3c 3d | (odd &&| bmin <=|
|00005d30| 20 64 20 26 26 20 64 20 | 3c 3d 20 62 6d 61 78 20 | d && d |<= bmax |
|00005d40| 26 26 20 62 64 5b 64 5d | 20 3c 3d 20 66 64 5b 64 |&& bd[d]| <= fd[d|
|00005d50| 5d 29 0a 09 20 20 20 20 | 7b 0a 09 20 20 20 20 20 |]).. |{.. |
|00005d60| 20 2a 63 6f 73 74 20 3d | 20 32 20 2a 20 63 20 2d | *cost =| 2 * c -|
|00005d70| 20 31 3b 0a 09 20 20 20 | 20 20 20 72 65 74 75 72 | 1;.. | retur|
|00005d80| 6e 20 64 3b 0a 09 20 20 | 20 20 7d 0a 09 7d 0a 0a |n d;.. | }..}..|
|00005d90| 20 20 20 20 20 20 2f 2a | 20 53 69 6d 69 6c 61 72 | /*| Similar|
|00005da0| 20 65 78 74 65 6e 64 20 | 74 68 65 20 62 6f 74 74 | extend |the bott|
|00005db0| 6f 6d 2d 75 70 20 73 65 | 61 72 63 68 2e 20 2a 2f |om-up se|arch. */|
|00005dc0| 0a 20 20 20 20 20 20 62 | 6d 69 6e 20 3e 20 64 6d |. b|min > dm|
|00005dd0| 69 6e 20 3f 20 62 64 5b | 2d 2d 62 6d 69 6e 20 2d |in ? bd[|--bmin -|
|00005de0| 20 31 5d 20 3d 20 49 4e | 54 5f 4d 41 58 20 3a 20 | 1] = IN|T_MAX : |
|00005df0| 2b 2b 62 6d 69 6e 3b 0a | 20 20 20 20 20 20 62 6d |++bmin;.| bm|
|00005e00| 61 78 20 3c 20 64 6d 61 | 78 20 3f 20 62 64 5b 2b |ax < dma|x ? bd[+|
|00005e10| 2b 62 6d 61 78 20 2b 20 | 31 5d 20 3d 20 49 4e 54 |+bmax + |1] = INT|
|00005e20| 5f 4d 41 58 20 3a 20 2d | 2d 62 6d 61 78 3b 0a 20 |_MAX : -|-bmax;. |
|00005e30| 20 20 20 20 20 66 6f 72 | 20 28 64 20 3d 20 62 6d | for| (d = bm|
|00005e40| 61 78 3b 20 64 20 3e 3d | 20 62 6d 69 6e 3b 20 64 |ax; d >=| bmin; d|
|00005e50| 20 2d 3d 20 32 29 0a 09 | 7b 0a 09 20 20 69 6e 74 | -= 2)..|{.. int|
|00005e60| 20 78 2c 20 79 2c 20 6f | 6c 64 78 2c 20 74 6c 6f | x, y, o|ldx, tlo|
|00005e70| 20 3d 20 62 64 5b 64 20 | 2d 20 31 5d 2c 20 74 68 | = bd[d |- 1], th|
|00005e80| 69 20 3d 20 62 64 5b 64 | 20 2b 20 31 5d 3b 0a 0a |i = bd[d| + 1];..|
|00005e90| 09 20 20 69 66 20 28 74 | 6c 6f 20 3c 20 74 68 69 |. if (t|lo < thi|
|00005ea0| 29 0a 09 20 20 20 20 78 | 20 3d 20 74 6c 6f 3b 0a |).. x| = tlo;.|
|00005eb0| 09 20 20 65 6c 73 65 0a | 09 20 20 20 20 78 20 3d |. else.|. x =|
|00005ec0| 20 74 68 69 20 2d 20 31 | 3b 0a 09 20 20 6f 6c 64 | thi - 1|;.. old|
|00005ed0| 78 20 3d 20 78 3b 0a 09 | 20 20 79 20 3d 20 78 20 |x = x;..| y = x |
|00005ee0| 2d 20 64 3b 0a 09 20 20 | 77 68 69 6c 65 20 28 78 |- d;.. |while (x|
|00005ef0| 20 3e 20 78 6f 66 66 20 | 26 26 20 79 20 3e 20 79 | > xoff |&& y > y|
|00005f00| 6f 66 66 20 26 26 20 78 | 76 5b 78 20 2d 20 31 5d |off && x|v[x - 1]|
|00005f10| 20 3d 3d 20 79 76 5b 79 | 20 2d 20 31 5d 29 0a 09 | == yv[y| - 1])..|
|00005f20| 20 20 20 20 2d 2d 78 2c | 20 2d 2d 79 3b 0a 09 20 | --x,| --y;.. |
|00005f30| 20 69 66 20 28 6f 6c 64 | 78 20 2d 20 78 20 3e 20 | if (old|x - x > |
|00005f40| 32 30 29 0a 09 20 20 20 | 20 62 69 67 5f 73 6e 61 |20).. | big_sna|
|00005f50| 6b 65 20 3d 20 31 3b 0a | 09 20 20 62 64 5b 64 5d |ke = 1;.|. bd[d]|
|00005f60| 20 3d 20 78 3b 0a 09 20 | 20 69 66 20 28 21 6f 64 | = x;.. | if (!od|
|00005f70| 64 20 26 26 20 66 6d 69 | 6e 20 3c 3d 20 64 20 26 |d && fmi|n <= d &|
|00005f80| 26 20 64 20 3c 3d 20 66 | 6d 61 78 20 26 26 20 62 |& d <= f|max && b|
|00005f90| 64 5b 64 5d 20 3c 3d 20 | 66 64 5b 64 5d 29 0a 09 |d[d] <= |fd[d])..|
|00005fa0| 20 20 20 20 7b 0a 09 20 | 20 20 20 20 20 2a 63 6f | {.. | *co|
|00005fb0| 73 74 20 3d 20 32 20 2a | 20 63 3b 0a 09 20 20 20 |st = 2 *| c;.. |
|00005fc0| 20 20 20 72 65 74 75 72 | 6e 20 64 3b 0a 09 20 20 | retur|n d;.. |
|00005fd0| 20 20 7d 0a 09 7d 0a 0a | 20 20 20 20 20 20 2f 2a | }..}..| /*|
|00005fe0| 20 48 65 75 72 69 73 74 | 69 63 3a 20 63 68 65 63 | Heurist|ic: chec|
|00005ff0| 6b 20 6f 63 63 61 73 69 | 6f 6e 61 6c 6c 79 20 66 |k occasi|onally f|
|00006000| 6f 72 20 61 20 64 69 61 | 67 6f 6e 61 6c 20 74 68 |or a dia|gonal th|
|00006010| 61 74 20 68 61 73 20 6d | 61 64 65 0a 09 20 6c 6f |at has m|ade.. lo|
|00006020| 74 73 20 6f 66 20 70 72 | 6f 67 72 65 73 73 20 63 |ts of pr|ogress c|
|00006030| 6f 6d 70 61 72 65 64 20 | 77 69 74 68 20 74 68 65 |ompared |with the|
|00006040| 20 65 64 69 74 20 64 69 | 73 74 61 6e 63 65 2e 0a | edit di|stance..|
|00006050| 09 20 49 66 20 77 65 20 | 68 61 76 65 20 61 6e 79 |. If we |have any|
|00006060| 20 73 75 63 68 2c 20 66 | 69 6e 64 20 74 68 65 20 | such, f|ind the |
|00006070| 6f 6e 65 20 74 68 61 74 | 20 68 61 73 20 6d 61 64 |one that| has mad|
|00006080| 65 20 74 68 65 20 6d 6f | 73 74 0a 09 20 70 72 6f |e the mo|st.. pro|
|00006090| 67 72 65 73 73 20 61 6e | 64 20 72 65 74 75 72 6e |gress an|d return|
|000060a0| 20 69 74 20 61 73 20 69 | 66 20 69 74 20 68 61 64 | it as i|f it had|
|000060b0| 20 73 75 63 63 65 65 64 | 65 64 2e 0a 0a 09 20 57 | succeed|ed.... W|
|000060c0| 69 74 68 20 74 68 69 73 | 20 68 65 75 72 69 73 74 |ith this| heurist|
|000060d0| 69 63 2c 20 66 6f 72 20 | 66 69 6c 65 73 20 77 69 |ic, for |files wi|
|000060e0| 74 68 20 61 20 63 6f 6e | 73 74 61 6e 74 20 73 6d |th a con|stant sm|
|000060f0| 61 6c 6c 20 64 65 6e 73 | 69 74 79 0a 09 20 6f 66 |all dens|ity.. of|
|00006100| 20 63 68 61 6e 67 65 73 | 2c 20 74 68 65 20 61 6c | changes|, the al|
|00006110| 67 6f 72 69 74 68 6d 20 | 69 73 20 6c 69 6e 65 61 |gorithm |is linea|
|00006120| 72 20 69 6e 20 74 68 65 | 20 66 69 6c 65 20 73 69 |r in the| file si|
|00006130| 7a 65 2e 20 20 2a 2f 0a | 0a 20 20 20 20 20 20 69 |ze. */.|. i|
|00006140| 66 20 28 63 20 3e 20 32 | 30 30 20 26 26 20 62 69 |f (c > 2|00 && bi|
|00006150| 67 5f 73 6e 61 6b 65 20 | 26 26 20 68 65 75 72 69 |g_snake |&& heuri|
|00006160| 73 74 69 63 29 0a 09 7b | 0a 09 20 20 69 6e 74 20 |stic)..{|.. int |
|00006170| 62 65 73 74 3b 0a 09 20 | 20 69 6e 74 20 62 65 73 |best;.. | int bes|
|00006180| 74 70 6f 73 3b 0a 0a 09 | 20 20 62 65 73 74 20 3d |tpos;...| best =|
|00006190| 20 30 3b 0a 09 20 20 66 | 6f 72 20 28 64 20 3d 20 | 0;.. f|or (d = |
|000061a0| 66 6d 61 78 3b 20 64 20 | 3e 3d 20 66 6d 69 6e 3b |fmax; d |>= fmin;|
|000061b0| 20 64 20 2d 3d 20 32 29 | 0a 09 20 20 20 20 7b 0a | d -= 2)|.. {.|
|000061c0| 09 20 20 20 20 20 20 69 | 6e 74 20 64 64 20 3d 20 |. i|nt dd = |
|000061d0| 64 20 2d 20 66 6d 69 64 | 3b 0a 09 20 20 20 20 20 |d - fmid|;.. |
|000061e0| 20 69 66 20 28 28 66 64 | 5b 64 5d 20 2d 20 78 6f | if ((fd|[d] - xo|
|000061f0| 66 66 29 2a 32 20 2d 20 | 64 64 20 3e 20 31 32 20 |ff)*2 - |dd > 12 |
|00006200| 2a 20 28 63 20 2b 20 28 | 64 64 20 3e 20 30 20 3f |* (c + (|dd > 0 ?|
|00006210| 20 64 64 20 3a 20 2d 64 | 64 29 29 29 0a 09 09 7b | dd : -d|d)))...{|
|00006220| 0a 09 09 20 20 69 66 20 | 28 66 64 5b 64 5d 20 2a |... if |(fd[d] *|
|00006230| 20 32 20 2d 20 64 64 20 | 3e 20 62 65 73 74 0a 09 | 2 - dd |> best..|
|00006240| 09 20 20 20 20 20 20 26 | 26 20 66 64 5b 64 5d 20 |. &|& fd[d] |
|00006250| 2d 20 78 6f 66 66 20 3e | 20 32 30 0a 09 09 20 20 |- xoff >| 20... |
|00006260| 20 20 20 20 26 26 20 66 | 64 5b 64 5d 20 2d 20 64 | && f|d[d] - d|
|00006270| 20 2d 20 79 6f 66 66 20 | 3e 20 32 30 29 0a 09 09 | - yoff |> 20)...|
|00006280| 20 20 20 20 7b 0a 09 09 | 20 20 20 20 20 20 69 6e | {...| in|
|00006290| 74 20 6b 3b 0a 09 09 20 | 20 20 20 20 20 69 6e 74 |t k;... | int|
|000062a0| 20 78 20 3d 20 66 64 5b | 64 5d 3b 0a 0a 09 09 20 | x = fd[|d];.... |
|000062b0| 20 20 20 20 20 2f 2a 20 | 57 65 20 68 61 76 65 20 | /* |We have |
|000062c0| 61 20 67 6f 6f 64 20 65 | 6e 6f 75 67 68 20 62 65 |a good e|nough be|
|000062d0| 73 74 20 64 69 61 67 6f | 6e 61 6c 3b 0a 09 09 09 |st diago|nal;....|
|000062e0| 20 6e 6f 77 20 69 6e 73 | 69 73 74 20 74 68 61 74 | now ins|ist that|
|000062f0| 20 69 74 20 65 6e 64 20 | 77 69 74 68 20 61 20 73 | it end |with a s|
|00006300| 69 67 6e 69 66 69 63 61 | 6e 74 20 73 6e 61 6b 65 |ignifica|nt snake|
|00006310| 2e 20 20 2a 2f 0a 09 09 | 20 20 20 20 20 20 66 6f |. */...| fo|
|00006320| 72 20 28 6b 20 3d 20 31 | 3b 20 6b 20 3c 3d 20 32 |r (k = 1|; k <= 2|
|00006330| 30 3b 20 6b 2b 2b 29 0a | 09 09 09 69 66 20 28 78 |0; k++).|...if (x|
|00006340| 76 65 63 5b 78 20 2d 20 | 6b 5d 20 21 3d 20 79 76 |vec[x - |k] != yv|
|00006350| 65 63 5b 78 20 2d 20 64 | 20 2d 20 6b 5d 29 0a 09 |ec[x - d| - k])..|
|00006360| 09 09 20 20 62 72 65 61 | 6b 3b 0a 0a 09 09 20 20 |.. brea|k;.... |
|00006370| 20 20 20 20 69 66 20 28 | 6b 20 3d 3d 20 32 31 29 | if (|k == 21)|
|00006380| 0a 09 09 09 7b 0a 09 09 | 09 20 20 62 65 73 74 20 |....{...|. best |
|00006390| 3d 20 66 64 5b 64 5d 20 | 2a 20 32 20 2d 20 64 64 |= fd[d] |* 2 - dd|
|000063a0| 3b 0a 09 09 09 20 20 62 | 65 73 74 70 6f 73 20 3d |;.... b|estpos =|
|000063b0| 20 64 3b 0a 09 09 09 7d | 0a 09 09 20 20 20 20 7d | d;....}|... }|
|000063c0| 0a 09 09 7d 0a 09 20 20 | 20 20 7d 0a 09 20 20 69 |...}.. | }.. i|
|000063d0| 66 20 28 62 65 73 74 20 | 3e 20 30 29 0a 09 20 20 |f (best |> 0).. |
|000063e0| 20 20 7b 0a 09 20 20 20 | 20 20 20 2a 63 6f 73 74 | {.. | *cost|
|000063f0| 20 3d 20 32 20 2a 20 63 | 20 2d 20 31 3b 0a 09 20 | = 2 * c| - 1;.. |
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.