home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Programming Contest / MacHack Contest.sit / MacHack Contest / Test Code Folder / Shared Test Code / ProblemUtils.cp < prev    next >
MacBinary  |  1998-06-07  |  9.8 KB  |  [TEXT/CWIE]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert MS-DOS Code Page Info (other/dosCodePage) ext Unsupported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Sun Jun 7 18:02:34 1998, modified Sun Jun 7 18:02:34 1998, creator 'CWIE', type ASCII, 9327 bytes "ProblemUtils.cp" , at 0x24ef 410 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[CWIE]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0f 50 72 6f 62 6c 65 | 6d 55 74 69 6c 73 2e 63 |..Proble|mUtils.c|
|00000010| 70 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |p.......|........|
|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 54 45 58 54 43 57 49 | 45 00 00 00 00 00 00 00 |.TEXTCWI|E.......|
|00000050| 00 00 00 00 00 24 6f 00 | 00 01 9a b1 a0 be 7a b1 |.....$o.|......z.|
|00000060| a0 be 7a 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |..z.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 56 89 00 00 |........|....V...|
|00000080| 23 69 6e 63 6c 75 64 65 | 20 22 50 72 6f 62 6c 65 |#include| "Proble|
|00000090| 6d 55 74 69 6c 73 2e 68 | 22 0d 0d 23 69 6e 63 6c |mUtils.h|"..#incl|
|000000a0| 75 64 65 20 3c 73 74 64 | 69 6f 2e 68 3e 0d 23 69 |ude <std|io.h>.#i|
|000000b0| 6e 63 6c 75 64 65 20 3c | 73 74 72 69 6e 67 2e 68 |nclude <|string.h|
|000000c0| 3e 0d 0d 63 6f 6e 73 74 | 20 69 6e 74 20 62 75 66 |>..const| int buf|
|000000d0| 66 65 72 5f 73 69 7a 65 | 20 3d 20 32 30 30 30 3b |fer_size| = 2000;|
|000000e0| 0d 73 74 61 74 69 63 20 | 63 68 61 72 20 62 75 66 |.static |char buf|
|000000f0| 66 65 72 5b 62 75 66 66 | 65 72 5f 73 69 7a 65 5d |fer[buff|er_size]|
|00000100| 3b 0d 73 74 61 74 69 63 | 20 63 68 61 72 20 62 75 |;.static| char bu|
|00000110| 66 66 65 72 32 5b 62 75 | 66 66 65 72 5f 73 69 7a |ffer2[bu|ffer_siz|
|00000120| 65 5d 3b 0d 0d 70 61 73 | 63 61 6c 20 4f 53 45 72 |e];..pas|cal OSEr|
|00000130| 72 20 50 72 6f 62 6c 65 | 6d 46 53 52 65 61 64 28 |r Proble|mFSRead(|
|00000140| 20 73 68 6f 72 74 20 72 | 6e 2c 20 6c 6f 6e 67 20 | short r|n, long |
|00000150| 72 65 71 73 69 7a 65 2c | 20 6c 6f 6e 67 20 2a 72 |reqsize,| long *r|
|00000160| 65 73 75 6c 74 73 69 7a | 65 2c 20 63 68 61 72 20 |esultsiz|e, char |
|00000170| 2a 64 61 74 61 20 29 0d | 7b 0d 09 4f 53 45 72 72 |*data ).|{..OSErr|
|00000180| 20 65 72 72 3b 0d 09 2a | 72 65 73 75 6c 74 73 69 | err;..*|resultsi|
|00000190| 7a 65 20 3d 20 72 65 71 | 73 69 7a 65 3b 0d 09 0d |ze = req|size;...|
|000001a0| 09 65 72 72 20 3d 20 46 | 53 52 65 61 64 28 20 72 |.err = F|SRead( r|
|000001b0| 6e 2c 20 72 65 73 75 6c | 74 73 69 7a 65 2c 20 64 |n, resul|tsize, d|
|000001c0| 61 74 61 20 29 3b 0d 09 | 69 66 20 28 20 65 72 72 |ata );..|if ( err|
|000001d0| 20 3d 3d 20 65 6f 66 45 | 72 72 20 26 26 20 2a 72 | == eofE|rr && *r|
|000001e0| 65 73 75 6c 74 73 69 7a | 65 20 3e 20 30 20 29 20 |esultsiz|e > 0 ) |
|000001f0| 7b 0d 09 09 65 72 72 20 | 3d 20 6e 6f 45 72 72 3b |{...err |= noErr;|
|00000200| 0d 09 7d 0d 09 72 65 74 | 75 72 6e 20 65 72 72 3b |..}..ret|urn err;|
|00000210| 0d 7d 0d 0d 70 61 73 63 | 61 6c 20 4f 53 45 72 72 |.}..pasc|al OSErr|
|00000220| 20 50 72 6f 62 6c 65 6d | 46 53 4d 75 73 74 52 65 | Problem|FSMustRe|
|00000230| 61 64 28 20 73 68 6f 72 | 74 20 72 6e 2c 20 6c 6f |ad( shor|t rn, lo|
|00000240| 6e 67 20 72 65 71 73 69 | 7a 65 2c 20 63 68 61 72 |ng reqsi|ze, char|
|00000250| 20 2a 64 61 74 61 20 29 | 0d 7b 0d 09 4f 53 45 72 | *data )|.{..OSEr|
|00000260| 72 20 65 72 72 3b 0d 09 | 6c 6f 6e 67 20 72 65 73 |r err;..|long res|
|00000270| 75 6c 74 73 69 7a 65 20 | 3d 20 72 65 71 73 69 7a |ultsize |= reqsiz|
|00000280| 65 3b 0d 09 0d 09 65 72 | 72 20 3d 20 46 53 52 65 |e;....er|r = FSRe|
|00000290| 61 64 28 20 72 6e 2c 20 | 26 72 65 73 75 6c 74 73 |ad( rn, |&results|
|000002a0| 69 7a 65 2c 20 64 61 74 | 61 20 29 3b 0d 09 69 66 |ize, dat|a );..if|
|000002b0| 20 28 20 65 72 72 20 3d | 3d 20 6e 6f 45 72 72 20 | ( err =|= noErr |
|000002c0| 26 26 20 72 65 73 75 6c | 74 73 69 7a 65 20 3c 20 |&& resul|tsize < |
|000002d0| 72 65 71 73 69 7a 65 20 | 29 20 7b 0d 09 09 65 72 |reqsize |) {...er|
|000002e0| 72 20 3d 20 65 6f 66 45 | 72 72 3b 0d 09 7d 0d 09 |r = eofE|rr;..}..|
|000002f0| 72 65 74 75 72 6e 20 65 | 72 72 3b 0d 7d 0d 0d 70 |return e|rr;.}..p|
|00000300| 61 73 63 61 6c 20 4f 53 | 45 72 72 20 50 72 6f 62 |ascal OS|Err Prob|
|00000310| 6c 65 6d 46 53 57 72 69 | 74 65 28 20 73 68 6f 72 |lemFSWri|te( shor|
|00000320| 74 20 72 6e 2c 20 6c 6f | 6e 67 20 72 65 71 73 69 |t rn, lo|ng reqsi|
|00000330| 7a 65 2c 20 63 68 61 72 | 20 2a 64 61 74 61 20 29 |ze, char| *data )|
|00000340| 0d 7b 0d 09 4f 53 45 72 | 72 20 65 72 72 3b 0d 09 |.{..OSEr|r err;..|
|00000350| 6c 6f 6e 67 20 73 61 76 | 65 64 73 69 7a 65 3b 0d |long sav|edsize;.|
|00000360| 09 0d 09 73 61 76 65 64 | 73 69 7a 65 20 3d 20 72 |...saved|size = r|
|00000370| 65 71 73 69 7a 65 3b 0d | 09 65 72 72 20 3d 20 46 |eqsize;.|.err = F|
|00000380| 53 57 72 69 74 65 28 20 | 72 6e 2c 20 26 72 65 71 |SWrite( |rn, &req|
|00000390| 73 69 7a 65 2c 20 64 61 | 74 61 20 29 3b 0d 09 69 |size, da|ta );..i|
|000003a0| 66 20 28 20 65 72 72 20 | 3d 3d 20 6e 6f 45 72 72 |f ( err |== noErr|
|000003b0| 20 26 26 20 72 65 71 73 | 69 7a 65 20 21 3d 20 73 | && reqs|ize != s|
|000003c0| 61 76 65 64 73 69 7a 65 | 20 29 20 7b 09 0d 09 09 |avedsize| ) {....|
|000003d0| 65 72 72 20 3d 20 2d 31 | 3b 0d 09 7d 0d 09 72 65 |err = -1|;..}..re|
|000003e0| 74 75 72 6e 20 65 72 72 | 3b 0d 7d 0d 0d 70 61 73 |turn err|;.}..pas|
|000003f0| 63 61 6c 20 4f 53 45 72 | 72 20 50 72 6f 62 6c 65 |cal OSEr|r Proble|
|00000400| 6d 43 6f 70 79 44 61 74 | 61 28 20 73 68 6f 72 74 |mCopyDat|a( short|
|00000410| 20 66 72 6e 2c 20 73 68 | 6f 72 74 20 74 72 6e 20 | frn, sh|ort trn |
|00000420| 29 0d 7b 0d 09 4f 53 45 | 72 72 20 65 72 72 3b 0d |).{..OSE|rr err;.|
|00000430| 09 6c 6f 6e 67 20 6c 65 | 6e 3b 0d 09 0d 09 65 72 |.long le|n;....er|
|00000440| 72 20 3d 20 6e 6f 45 72 | 72 3b 0d 09 77 68 69 6c |r = noEr|r;..whil|
|00000450| 65 20 28 20 65 72 72 20 | 3d 3d 20 6e 6f 45 72 72 |e ( err |== noErr|
|00000460| 20 29 20 7b 0d 09 09 65 | 72 72 20 3d 20 50 72 6f | ) {...e|rr = Pro|
|00000470| 62 6c 65 6d 46 53 52 65 | 61 64 28 20 66 72 6e 2c |blemFSRe|ad( frn,|
|00000480| 20 62 75 66 66 65 72 5f | 73 69 7a 65 2c 20 26 6c | buffer_|size, &l|
|00000490| 65 6e 2c 20 62 75 66 66 | 65 72 20 29 3b 0d 09 09 |en, buff|er );...|
|000004a0| 69 66 20 28 20 65 72 72 | 20 3d 3d 20 65 6f 66 45 |if ( err| == eofE|
|000004b0| 72 72 20 29 20 7b 0d 09 | 09 09 65 72 72 20 3d 20 |rr ) {..|..err = |
|000004c0| 6e 6f 45 72 72 3b 0d 09 | 09 09 62 72 65 61 6b 3b |noErr;..|..break;|
|000004d0| 0d 09 09 7d 0d 09 09 69 | 66 20 28 20 65 72 72 20 |...}...i|f ( err |
|000004e0| 3d 3d 20 6e 6f 45 72 72 | 20 29 20 7b 0d 09 09 09 |== noErr| ) {....|
|000004f0| 65 72 72 20 3d 20 50 72 | 6f 62 6c 65 6d 46 53 57 |err = Pr|oblemFSW|
|00000500| 72 69 74 65 28 20 74 72 | 6e 2c 20 6c 65 6e 2c 20 |rite( tr|n, len, |
|00000510| 62 75 66 66 65 72 20 29 | 3b 0d 09 09 7d 0d 09 7d |buffer )|;...}..}|
|00000520| 0d 09 72 65 74 75 72 6e | 20 65 72 72 3b 0d 7d 0d |..return| err;.}.|
|00000530| 0d 70 61 73 63 61 6c 20 | 4f 53 45 72 72 20 50 72 |.pascal |OSErr Pr|
|00000540| 6f 62 6c 65 6d 44 75 70 | 6c 69 63 61 74 65 46 69 |oblemDup|licateFi|
|00000550| 6c 65 28 20 63 6f 6e 73 | 74 20 46 53 53 70 65 63 |le( cons|t FSSpec|
|00000560| 20 2a 66 72 6f 6d 2c 20 | 63 6f 6e 73 74 20 46 53 | *from, |const FS|
|00000570| 53 70 65 63 20 2a 74 6f | 20 29 0d 7b 0d 09 4f 53 |Spec *to| ).{..OS|
|00000580| 45 72 72 20 65 72 72 2c | 20 65 72 72 32 3b 0d 09 |Err err,| err2;..|
|00000590| 73 68 6f 72 74 20 66 72 | 6e 2c 20 74 72 6e 3b 0d |short fr|n, trn;.|
|000005a0| 09 0d 09 28 76 6f 69 64 | 29 20 46 53 70 44 65 6c |...(void|) FSpDel|
|000005b0| 65 74 65 28 20 74 6f 20 | 29 3b 0d 09 65 72 72 20 |ete( to |);..err |
|000005c0| 3d 20 46 53 70 43 72 65 | 61 74 65 28 20 74 6f 2c |= FSpCre|ate( to,|
|000005d0| 20 27 43 57 49 45 27 2c | 20 27 54 45 58 54 27 2c | 'CWIE',| 'TEXT',|
|000005e0| 20 30 20 29 3b 0d 09 69 | 66 20 28 20 65 72 72 20 | 0 );..i|f ( err |
|000005f0| 3d 3d 20 6e 6f 45 72 72 | 20 29 20 7b 0d 09 09 65 |== noErr| ) {...e|
|00000600| 72 72 20 3d 20 46 53 70 | 4f 70 65 6e 44 46 28 20 |rr = FSp|OpenDF( |
|00000610| 66 72 6f 6d 2c 20 66 73 | 52 64 50 65 72 6d 2c 20 |from, fs|RdPerm, |
|00000620| 26 66 72 6e 20 29 3b 0d | 09 09 69 66 20 28 20 65 |&frn );.|..if ( e|
|00000630| 72 72 20 3d 3d 20 6e 6f | 45 72 72 20 29 20 7b 0d |rr == no|Err ) {.|
|00000640| 09 09 09 65 72 72 20 3d | 20 46 53 70 4f 70 65 6e |...err =| FSpOpen|
|00000650| 44 46 28 20 74 6f 2c 20 | 66 73 57 72 50 65 72 6d |DF( to, |fsWrPerm|
|00000660| 2c 20 26 74 72 6e 20 29 | 3b 0d 09 09 09 69 66 20 |, &trn )|;....if |
|00000670| 28 20 65 72 72 20 3d 3d | 20 6e 6f 45 72 72 20 29 |( err ==| noErr )|
|00000680| 20 7b 0d 09 09 09 09 65 | 72 72 20 3d 20 50 72 6f | {.....e|rr = Pro|
|00000690| 62 6c 65 6d 43 6f 70 79 | 44 61 74 61 28 20 66 72 |blemCopy|Data( fr|
|000006a0| 6e 2c 20 74 72 6e 20 29 | 3b 0d 09 09 09 09 65 72 |n, trn )|;.....er|
|000006b0| 72 32 20 3d 20 46 53 43 | 6c 6f 73 65 28 20 74 72 |r2 = FSC|lose( tr|
|000006c0| 6e 20 29 3b 0d 09 09 09 | 09 69 66 20 28 20 65 72 |n );....|.if ( er|
|000006d0| 72 20 3d 3d 20 6e 6f 45 | 72 72 20 29 20 7b 0d 09 |r == noE|rr ) {..|
|000006e0| 09 09 09 09 65 72 72 20 | 3d 20 65 72 72 32 3b 0d |....err |= err2;.|
|000006f0| 09 09 09 09 7d 0d 09 09 | 09 7d 0d 09 09 09 28 76 |....}...|.}....(v|
|00000700| 6f 69 64 29 20 46 53 43 | 6c 6f 73 65 28 20 66 72 |oid) FSC|lose( fr|
|00000710| 6e 20 29 3b 0d 09 09 7d | 0d 09 7d 0d 09 69 66 20 |n );...}|..}..if |
|00000720| 28 20 65 72 72 20 21 3d | 20 6e 6f 45 72 72 20 29 |( err !=| noErr )|
|00000730| 20 7b 0d 09 09 28 76 6f | 69 64 29 20 46 53 70 44 | {...(vo|id) FSpD|
|00000740| 65 6c 65 74 65 28 20 74 | 6f 20 29 3b 0d 09 7d 0d |elete( t|o );..}.|
|00000750| 09 72 65 74 75 72 6e 20 | 65 72 72 3b 0d 7d 0d 0d |.return |err;.}..|
|00000760| 70 61 73 63 61 6c 20 4f | 53 45 72 72 20 50 72 6f |pascal O|SErr Pro|
|00000770| 62 6c 65 6d 44 69 66 66 | 44 61 74 61 28 20 73 68 |blemDiff|Data( sh|
|00000780| 6f 72 74 20 72 6e 31 2c | 20 73 68 6f 72 74 20 72 |ort rn1,| short r|
|00000790| 6e 32 20 29 0d 7b 0d 09 | 4f 53 45 72 72 20 65 72 |n2 ).{..|OSErr er|
|000007a0| 72 2c 20 65 72 72 31 2c | 20 65 72 72 32 3b 0d 09 |r, err1,| err2;..|
|000007b0| 6c 6f 6e 67 20 6c 65 6e | 31 2c 20 6c 65 6e 32 2c |long len|1, len2,|
|000007c0| 20 69 3b 0d 09 0d 09 65 | 72 72 20 3d 20 6e 6f 45 | i;....e|rr = noE|
|000007d0| 72 72 3b 0d 09 77 68 69 | 6c 65 20 28 20 65 72 72 |rr;..whi|le ( err|
|000007e0| 20 3d 3d 20 6e 6f 45 72 | 72 20 29 20 7b 0d 09 0d | == noEr|r ) {...|
|000007f0| 09 09 65 72 72 31 20 3d | 20 50 72 6f 62 6c 65 6d |..err1 =| Problem|
|00000800| 46 53 52 65 61 64 28 20 | 72 6e 31 2c 20 62 75 66 |FSRead( |rn1, buf|
|00000810| 66 65 72 5f 73 69 7a 65 | 2c 20 26 6c 65 6e 31 2c |fer_size|, &len1,|
|00000820| 20 62 75 66 66 65 72 20 | 29 3b 0d 09 09 65 72 72 | buffer |);...err|
|00000830| 32 20 3d 20 50 72 6f 62 | 6c 65 6d 46 53 52 65 61 |2 = Prob|lemFSRea|
|00000840| 64 28 20 72 6e 32 2c 20 | 62 75 66 66 65 72 5f 73 |d( rn2, |buffer_s|
|00000850| 69 7a 65 2c 20 26 6c 65 | 6e 32 2c 20 62 75 66 66 |ize, &le|n2, buff|
|00000860| 65 72 32 20 29 3b 0d 09 | 09 0d 09 09 69 66 20 28 |er2 );..|....if (|
|00000870| 20 65 72 72 31 20 3d 3d | 20 65 6f 66 45 72 72 20 | err1 ==| eofErr |
|00000880| 26 26 20 65 72 72 32 20 | 3d 3d 20 65 6f 66 45 72 |&& err2 |== eofEr|
|00000890| 72 20 29 20 7b 0d 09 09 | 09 62 72 65 61 6b 3b 0d |r ) {...|.break;.|
|000008a0| 09 09 7d 0d 09 09 69 66 | 20 28 20 65 72 72 31 20 |..}...if| ( err1 |
|000008b0| 21 3d 20 6e 6f 45 72 72 | 20 29 20 7b 0d 09 09 09 |!= noErr| ) {....|
|000008c0| 65 72 72 20 3d 20 65 72 | 72 31 3b 0d 09 09 09 62 |err = er|r1;....b|
|000008d0| 72 65 61 6b 3b 0d 09 09 | 7d 0d 09 09 69 66 20 28 |reak;...|}...if (|
|000008e0| 20 65 72 72 32 20 21 3d | 20 6e 6f 45 72 72 20 29 | err2 !=| noErr )|
|000008f0| 20 7b 0d 09 09 09 65 72 | 72 20 3d 20 65 72 72 32 | {....er|r = err2|
|00000900| 3b 0d 09 09 09 62 72 65 | 61 6b 3b 0d 09 09 7d 0d |;....bre|ak;...}.|
|00000910| 09 09 69 66 20 28 20 6c | 65 6e 31 20 21 3d 20 6c |..if ( l|en1 != l|
|00000920| 65 6e 32 20 29 20 7b 0d | 09 09 09 65 72 72 20 3d |en2 ) {.|...err =|
|00000930| 20 65 6f 66 45 72 72 3b | 0d 09 09 09 62 72 65 61 | eofErr;|....brea|
|00000940| 6b 3b 0d 09 09 7d 0d 09 | 09 0d 09 09 66 6f 72 28 |k;...}..|....for(|
|00000950| 20 69 20 3d 20 30 3b 20 | 69 20 3c 20 6c 65 6e 31 | i = 0; |i < len1|
|00000960| 3b 20 69 2b 2b 20 29 20 | 7b 0d 09 09 09 69 66 20 |; i++ ) |{....if |
|00000970| 28 20 62 75 66 66 65 72 | 5b 69 5d 20 21 3d 20 62 |( buffer|[i] != b|
|00000980| 75 66 66 65 72 32 5b 69 | 5d 20 29 20 7b 0d 09 09 |uffer2[i|] ) {...|
|00000990| 09 09 62 72 65 61 6b 3b | 0d 09 09 09 7d 0d 09 09 |..break;|....}...|
|000009a0| 7d 0d 09 09 69 66 20 28 | 20 69 20 21 3d 20 6c 65 |}...if (| i != le|
|000009b0| 6e 31 20 29 20 7b 0d 09 | 09 09 65 72 72 20 3d 20 |n1 ) {..|..err = |
|000009c0| 62 61 64 46 69 6c 65 46 | 6f 72 6d 61 74 3b 0d 09 |badFileF|ormat;..|
|000009d0| 09 09 62 72 65 61 6b 3b | 0d 09 09 7d 0d 09 7d 0d |..break;|...}..}.|
|000009e0| 09 72 65 74 75 72 6e 20 | 65 72 72 3b 0d 7d 0d 0d |.return |err;.}..|
|000009f0| 70 61 73 63 61 6c 20 42 | 6f 6f 6c 65 61 6e 20 50 |pascal B|oolean P|
|00000a00| 72 6f 62 6c 65 6d 44 69 | 66 66 46 69 6c 65 73 28 |roblemDi|ffFiles(|
|00000a10| 20 63 6f 6e 73 74 20 46 | 53 53 70 65 63 20 2a 66 | const F|SSpec *f|
|00000a20| 69 6c 65 31 2c 20 63 6f | 6e 73 74 20 46 53 53 70 |ile1, co|nst FSSp|
|00000a30| 65 63 20 2a 66 69 6c 65 | 32 20 29 0d 7b 0d 09 4f |ec *file|2 ).{..O|
|00000a40| 53 45 72 72 20 65 72 72 | 3b 0d 09 73 68 6f 72 74 |SErr err|;..short|
|00000a50| 20 72 6e 31 2c 20 72 6e | 32 3b 0d 09 0d 09 65 72 | rn1, rn|2;....er|
|00000a60| 72 20 3d 20 46 53 70 4f | 70 65 6e 44 46 28 20 66 |r = FSpO|penDF( f|
|00000a70| 69 6c 65 31 2c 20 66 73 | 52 64 50 65 72 6d 2c 20 |ile1, fs|RdPerm, |
|00000a80| 26 72 6e 31 20 29 3b 0d | 09 69 66 20 28 20 65 72 |&rn1 );.|.if ( er|
|00000a90| 72 20 3d 3d 20 6e 6f 45 | 72 72 20 29 20 7b 0d 09 |r == noE|rr ) {..|
|00000aa0| 09 65 72 72 20 3d 20 46 | 53 70 4f 70 65 6e 44 46 |.err = F|SpOpenDF|
|00000ab0| 28 20 66 69 6c 65 32 2c | 20 66 73 52 64 50 65 72 |( file2,| fsRdPer|
|00000ac0| 6d 2c 20 26 72 6e 32 20 | 29 3b 0d 09 09 69 66 20 |m, &rn2 |);...if |
|00000ad0| 28 20 65 72 72 20 3d 3d | 20 6e 6f 45 72 72 20 29 |( err ==| noErr )|
|00000ae0| 20 7b 0d 09 09 09 65 72 | 72 20 3d 20 50 72 6f 62 | {....er|r = Prob|
|00000af0| 6c 65 6d 44 69 66 66 44 | 61 74 61 28 20 72 6e 31 |lemDiffD|ata( rn1|
|00000b00| 2c 20 72 6e 32 20 29 3b | 0d 09 09 09 28 76 6f 69 |, rn2 );|....(voi|
|00000b10| 64 29 20 46 53 43 6c 6f | 73 65 28 20 72 6e 32 20 |d) FSClo|se( rn2 |
|00000b20| 29 3b 0d 09 09 7d 0d 09 | 09 28 76 6f 69 64 29 20 |);...}..|.(void) |
|00000b30| 46 53 43 6c 6f 73 65 28 | 20 72 6e 31 20 29 3b 0d |FSClose(| rn1 );.|
|00000b40| 09 7d 0d 09 72 65 74 75 | 72 6e 20 65 72 72 20 21 |.}..retu|rn err !|
|00000b50| 3d 20 6e 6f 45 72 72 3b | 0d 7d 0d 0d 70 61 73 63 |= noErr;|.}..pasc|
|00000b60| 61 6c 20 4f 53 45 72 72 | 20 50 72 6f 62 6c 65 6d |al OSErr| Problem|
|00000b70| 47 65 74 54 65 73 74 44 | 69 72 65 63 74 6f 72 79 |GetTestD|irectory|
|00000b80| 46 53 53 70 65 63 28 20 | 46 53 53 70 65 63 20 2a |FSSpec( |FSSpec *|
|00000b90| 73 70 65 63 20 29 0d 7b | 0d 09 4f 53 45 72 72 20 |spec ).{|..OSErr |
|00000ba0| 65 72 72 3b 0d 09 46 43 | 42 50 42 52 65 63 20 66 |err;..FC|BPBRec f|
|00000bb0| 70 62 3b 0d 09 43 49 6e | 66 6f 50 42 52 65 63 20 |pb;..CIn|foPBRec |
|00000bc0| 70 62 3b 0d 09 53 74 72 | 32 35 35 20 6e 61 6d 65 |pb;..Str|255 name|
|00000bd0| 3b 0d 09 53 74 72 31 35 | 20 6e 75 6d 62 65 72 3b |;..Str15| number;|
|00000be0| 0d 09 0d 09 66 70 62 2e | 69 6f 4e 61 6d 65 50 74 |....fpb.|ioNamePt|
|00000bf0| 72 20 3d 20 6e 61 6d 65 | 3b 0d 09 66 70 62 2e 69 |r = name|;..fpb.i|
|00000c00| 6f 56 52 65 66 4e 75 6d | 20 3d 20 30 3b 0d 09 66 |oVRefNum| = 0;..f|
|00000c10| 70 62 2e 69 6f 52 65 66 | 4e 75 6d 20 3d 20 43 75 |pb.ioRef|Num = Cu|
|00000c20| 72 52 65 73 46 69 6c 65 | 28 29 3b 0d 09 66 70 62 |rResFile|();..fpb|
|00000c30| 2e 69 6f 46 43 42 49 6e | 64 78 20 3d 20 30 3b 0d |.ioFCBIn|dx = 0;.|
|00000c40| 09 65 72 72 20 3d 20 50 | 42 47 65 74 46 43 42 49 |.err = P|BGetFCBI|
|00000c50| 6e 66 6f 53 79 6e 63 28 | 20 26 66 70 62 20 29 3b |nfoSync(| &fpb );|
|00000c60| 0d 09 69 66 20 28 20 65 | 72 72 20 3d 3d 20 6e 6f |..if ( e|rr == no|
|00000c70| 45 72 72 20 29 20 7b 0d | 09 09 70 62 2e 68 46 69 |Err ) {.|..pb.hFi|
|00000c80| 6c 65 49 6e 66 6f 2e 69 | 6f 4e 61 6d 65 50 74 72 |leInfo.i|oNamePtr|
|00000c90| 20 3d 20 6e 61 6d 65 3b | 0d 09 09 70 62 2e 68 46 | = name;|...pb.hF|
|00000ca0| 69 6c 65 49 6e 66 6f 2e | 69 6f 56 52 65 66 4e 75 |ileInfo.|ioVRefNu|
|00000cb0| 6d 20 3d 20 66 70 62 2e | 69 6f 46 43 42 56 52 65 |m = fpb.|ioFCBVRe|
|00000cc0| 66 4e 75 6d 3b 0d 09 09 | 70 62 2e 68 46 69 6c 65 |fNum;...|pb.hFile|
|00000cd0| 49 6e 66 6f 2e 69 6f 44 | 69 72 49 44 20 3d 20 66 |Info.ioD|irID = f|
|00000ce0| 70 62 2e 69 6f 46 43 42 | 50 61 72 49 44 3b 0d 09 |pb.ioFCB|ParID;..|
|00000cf0| 09 70 62 2e 68 46 69 6c | 65 49 6e 66 6f 2e 69 6f |.pb.hFil|eInfo.io|
|00000d00| 46 44 69 72 49 6e 64 65 | 78 20 3d 20 2d 31 3b 0d |FDirInde|x = -1;.|
|00000d10| 09 09 65 72 72 20 3d 20 | 50 42 47 65 74 43 61 74 |..err = |PBGetCat|
|00000d20| 49 6e 66 6f 53 79 6e 63 | 28 20 26 70 62 20 29 3b |InfoSync|( &pb );|
|00000d30| 0d 09 7d 0d 09 0d 09 69 | 66 20 28 20 65 72 72 20 |..}....i|f ( err |
|00000d40| 3d 3d 20 6e 6f 45 72 72 | 20 29 20 7b 0d 09 09 6e |== noErr| ) {...n|
|00000d50| 75 6d 62 65 72 5b 30 5d | 20 3d 20 32 3b 0d 09 09 |umber[0]| = 2;...|
|00000d60| 6e 75 6d 62 65 72 5b 31 | 5d 20 3d 20 6e 61 6d 65 |number[1|] = name|
|00000d70| 5b 39 5d 3b 0d 09 09 6e | 75 6d 62 65 72 5b 32 5d |[9];...n|umber[2]|
|00000d80| 20 3d 20 6e 61 6d 65 5b | 31 30 5d 3b 0d 09 09 50 | = name[|10];...P|
|00000d90| 4c 73 74 72 63 70 79 28 | 20 6e 61 6d 65 2c 20 22 |Lstrcpy(| name, "|
|00000da0| 5c 70 3a 3a 3a 54 65 73 | 74 20 44 61 74 61 20 46 |\p:::Tes|t Data F|
|00000db0| 6f 6c 64 65 72 3a 50 72 | 6f 62 6c 65 6d 20 22 20 |older:Pr|oblem " |
|00000dc0| 29 3b 0d 09 09 50 4c 73 | 74 72 63 61 74 28 20 6e |);...PLs|trcat( n|
|00000dd0| 61 6d 65 2c 20 6e 75 6d | 62 65 72 20 29 3b 0d 09 |ame, num|ber );..|
|00000de0| 09 50 4c 73 74 72 63 61 | 74 28 20 6e 61 6d 65 2c |.PLstrca|t( name,|
|00000df0| 20 22 5c 70 20 54 65 73 | 74 20 44 61 74 61 3a 58 | "\p Tes|t Data:X|
|00000e00| 58 58 22 20 29 3b 0d 09 | 09 65 72 72 20 3d 20 46 |XX" );..|.err = F|
|00000e10| 53 4d 61 6b 65 46 53 53 | 70 65 63 28 20 66 70 62 |SMakeFSS|pec( fpb|
|00000e20| 2e 69 6f 46 43 42 56 52 | 65 66 4e 75 6d 2c 20 66 |.ioFCBVR|efNum, f|
|00000e30| 70 62 2e 69 6f 46 43 42 | 50 61 72 49 44 2c 20 6e |pb.ioFCB|ParID, n|
|00000e40| 61 6d 65 2c 20 73 70 65 | 63 20 29 3b 0d 09 09 69 |ame, spe|c );...i|
|00000e50| 66 20 28 20 65 72 72 20 | 3d 3d 20 66 6e 66 45 72 |f ( err |== fnfEr|
|00000e60| 72 20 29 20 7b 0d 09 09 | 09 65 72 72 20 3d 20 6e |r ) {...|.err = n|
|00000e70| 6f 45 72 72 3b 0d 09 09 | 7d 0d 09 09 73 70 65 63 |oErr;...|}...spec|
|00000e80| 2d 3e 6e 61 6d 65 5b 30 | 5d 20 3d 20 30 3b 0d 09 |->name[0|] = 0;..|
|00000e90| 7d 0d 09 72 65 74 75 72 | 6e 20 65 72 72 3b 0d 7d |}..retur|n err;.}|
|00000ea0| 0d 0d 70 61 73 63 61 6c | 20 4f 53 45 72 72 20 50 |..pascal| OSErr P|
|00000eb0| 72 6f 62 6c 65 6d 47 65 | 74 54 65 73 74 53 70 65 |roblemGe|tTestSpe|
|00000ec0| 63 73 28 20 63 6f 6e 73 | 74 20 46 53 53 70 65 63 |cs( cons|t FSSpec|
|00000ed0| 20 2a 74 65 73 74 73 70 | 65 63 2c 20 6c 6f 6e 67 | *testsp|ec, long|
|00000ee0| 20 74 65 73 74 2c 20 0d | 09 46 53 53 70 65 63 20 | test, .|.FSSpec |
|00000ef0| 2a 69 6e 70 75 74 73 70 | 65 63 2c 20 46 53 53 70 |*inputsp|ec, FSSp|
|00000f00| 65 63 20 2a 63 6f 72 72 | 65 63 74 73 70 65 63 2c |ec *corr|ectspec,|
|00000f10| 20 46 53 53 70 65 63 20 | 2a 73 61 76 65 64 73 70 | FSSpec |*savedsp|
|00000f20| 65 63 2c 20 46 53 53 70 | 65 63 20 2a 6f 75 74 70 |ec, FSSp|ec *outp|
|00000f30| 75 74 73 70 65 63 20 29 | 0d 7b 0d 09 4f 53 45 72 |utspec )|.{..OSEr|
|00000f40| 72 20 65 72 72 3b 0d 09 | 53 74 72 31 35 20 6e 75 |r err;..|Str15 nu|
|00000f50| 6d 62 65 72 3b 0d 09 46 | 53 53 70 65 63 20 69 72 |mber;..F|SSpec ir|
|00000f60| 72 65 6c 65 76 65 6e 74 | 3b 0d 09 0d 09 6e 75 6d |relevent|;....num|
|00000f70| 62 65 72 5b 30 5d 20 3d | 20 32 3b 0d 09 6e 75 6d |ber[0] =| 2;..num|
|00000f80| 62 65 72 5b 31 5d 20 3d | 20 27 30 27 20 2b 20 74 |ber[1] =| '0' + t|
|00000f90| 65 73 74 20 2f 20 31 30 | 3b 0d 09 6e 75 6d 62 65 |est / 10|;..numbe|
|00000fa0| 72 5b 32 5d 20 3d 20 27 | 30 27 20 2b 20 74 65 73 |r[2] = '|0' + tes|
|00000fb0| 74 20 25 20 31 30 3b 0d | 09 0d 09 2a 69 6e 70 75 |t % 10;.|...*inpu|
|00000fc0| 74 73 70 65 63 20 3d 20 | 2a 74 65 73 74 73 70 65 |tspec = |*testspe|
|00000fd0| 63 3b 0d 09 50 4c 73 74 | 72 63 70 79 28 20 69 6e |c;..PLst|rcpy( in|
|00000fe0| 70 75 74 73 70 65 63 2d | 3e 6e 61 6d 65 2c 20 22 |putspec-|>name, "|
|00000ff0| 5c 70 54 65 73 74 22 20 | 29 3b 0d 09 50 4c 73 74 |\pTest" |);..PLst|
|00001000| 72 63 61 74 28 20 69 6e | 70 75 74 73 70 65 63 2d |rcat( in|putspec-|
|00001010| 3e 6e 61 6d 65 2c 20 6e | 75 6d 62 65 72 20 29 3b |>name, n|umber );|
|00001020| 0d 09 2a 63 6f 72 72 65 | 63 74 73 70 65 63 20 3d |..*corre|ctspec =|
|00001030| 20 2a 69 6e 70 75 74 73 | 70 65 63 3b 0d 09 2a 73 | *inputs|pec;..*s|
|00001040| 61 76 65 64 73 70 65 63 | 20 3d 20 2a 69 6e 70 75 |avedspec| = *inpu|
|00001050| 74 73 70 65 63 3b 0d 09 | 2a 6f 75 74 70 75 74 73 |tspec;..|*outputs|
|00001060| 70 65 63 20 3d 20 2a 69 | 6e 70 75 74 73 70 65 63 |pec = *i|nputspec|
|00001070| 3b 0d 0d 09 50 4c 73 74 | 72 63 61 74 28 20 69 6e |;...PLst|rcat( in|
|00001080| 70 75 74 73 70 65 63 2d | 3e 6e 61 6d 65 2c 20 22 |putspec-|>name, "|
|00001090| 5c 70 2e 69 6e 70 75 74 | 22 20 29 3b 0d 09 50 4c |\p.input|" );..PL|
|000010a0| 73 74 72 63 61 74 28 20 | 63 6f 72 72 65 63 74 73 |strcat( |corrects|
|000010b0| 70 65 63 2d 3e 6e 61 6d | 65 2c 20 22 5c 70 2e 63 |pec->nam|e, "\p.c|
|000010c0| 6f 72 72 65 63 74 22 20 | 29 3b 0d 09 50 4c 73 74 |orrect" |);..PLst|
|000010d0| 72 63 61 74 28 73 61 76 | 65 64 73 70 65 63 2d 3e |rcat(sav|edspec->|
|000010e0| 6e 61 6d 65 2c 20 22 5c | 70 2e 73 61 76 65 64 22 |name, "\|p.saved"|
|000010f0| 20 29 3b 0d 09 50 4c 73 | 74 72 63 61 74 28 20 6f | );..PLs|trcat( o|
|00001100| 75 74 70 75 74 73 70 65 | 63 2d 3e 6e 61 6d 65 2c |utputspe|c->name,|
|00001110| 20 22 5c 70 2e 6f 75 74 | 70 75 74 22 20 29 3b 0d | "\p.out|put" );.|
|00001120| 09 0d 09 28 76 6f 69 64 | 29 20 46 53 70 44 65 6c |...(void|) FSpDel|
|00001130| 65 74 65 28 20 6f 75 74 | 70 75 74 73 70 65 63 20 |ete( out|putspec |
|00001140| 29 3b 0d 09 28 76 6f 69 | 64 29 20 46 53 70 44 65 |);..(voi|d) FSpDe|
|00001150| 6c 65 74 65 28 20 73 61 | 76 65 64 73 70 65 63 20 |lete( sa|vedspec |
|00001160| 29 3b 0d 09 65 72 72 20 | 3d 20 46 53 4d 61 6b 65 |);..err |= FSMake|
|00001170| 46 53 53 70 65 63 28 20 | 69 6e 70 75 74 73 70 65 |FSSpec( |inputspe|
|00001180| 63 2d 3e 76 52 65 66 4e | 75 6d 2c 20 69 6e 70 75 |c->vRefN|um, inpu|
|00001190| 74 73 70 65 63 2d 3e 70 | 61 72 49 44 2c 20 69 6e |tspec->p|arID, in|
|000011a0| 70 75 74 73 70 65 63 2d | 3e 6e 61 6d 65 2c 20 26 |putspec-|>name, &|
|000011b0| 69 72 72 65 6c 65 76 65 | 6e 74 20 29 3b 0d 09 69 |irreleve|nt );..i|
|000011c0| 66 20 28 20 65 72 72 20 | 3d 3d 20 6e 6f 45 72 72 |f ( err |== noErr|
|000011d0| 20 29 20 7b 0d 09 09 65 | 72 72 20 3d 20 50 72 6f | ) {...e|rr = Pro|
|000011e0| 62 6c 65 6d 44 75 70 6c | 69 63 61 74 65 46 69 6c |blemDupl|icateFil|
|000011f0| 65 28 20 69 6e 70 75 74 | 73 70 65 63 2c 20 73 61 |e( input|spec, sa|
|00001200| 76 65 64 73 70 65 63 20 | 29 3b 0d 09 7d 0d 09 72 |vedspec |);..}..r|
|00001210| 65 74 75 72 6e 20 65 72 | 72 3b 0d 7d 0d 0d 70 61 |eturn er|r;.}..pa|
|00001220| 73 63 61 6c 20 76 6f 69 | 64 20 50 72 6f 62 6c 65 |scal voi|d Proble|
|00001230| 6d 4c 6f 67 45 72 72 6f | 72 28 20 4f 53 45 72 72 |mLogErro|r( OSErr|
|00001240| 20 65 72 72 2c 20 63 6f | 6e 73 74 20 63 68 61 72 | err, co|nst char|
|00001250| 20 2a 66 75 6e 63 74 69 | 6f 6e 20 29 0d 7b 0d 09 | *functi|on ).{..|
|00001260| 69 66 20 28 20 65 72 72 | 20 21 3d 20 6e 6f 45 72 |if ( err| != noEr|
|00001270| 72 20 29 20 7b 0d 09 09 | 70 72 69 6e 74 66 28 20 |r ) {...|printf( |
|00001280| 22 25 73 20 67 6f 74 20 | 65 72 72 6f 72 20 25 64 |"%s got |error %d|
|00001290| 5c 6e 22 2c 20 66 75 6e | 63 74 69 6f 6e 2c 20 65 |\n", fun|ction, e|
|000012a0| 72 72 20 29 3b 0d 09 7d | 0d 7d 0d 0d 70 61 73 63 |rr );..}|.}..pasc|
|000012b0| 61 6c 20 76 6f 69 64 20 | 50 72 6f 62 6c 65 6d 52 |al void |ProblemR|
|000012c0| 75 6e 45 69 74 68 65 72 | 46 69 6c 65 54 65 73 74 |unEither|FileTest|
|000012d0| 73 28 20 52 75 6e 46 69 | 6c 65 54 65 73 74 50 72 |s( RunFi|leTestPr|
|000012e0| 6f 63 20 72 75 6e 74 65 | 73 74 2c 20 52 75 6e 53 |oc runte|st, RunS|
|000012f0| 69 6e 67 6c 65 46 69 6c | 65 54 65 73 74 50 72 6f |ingleFil|eTestPro|
|00001300| 63 20 73 69 6e 67 6c 65 | 72 75 6e 74 65 73 74 20 |c single|runtest |
|00001310| 29 0d 7b 0d 09 4f 53 45 | 72 72 20 65 72 72 3b 0d |).{..OSE|rr err;.|
|00001320| 09 46 53 53 70 65 63 20 | 74 65 73 74 73 70 65 63 |.FSSpec |testspec|
|00001330| 2c 20 69 6e 70 75 74 73 | 70 65 63 2c 20 63 6f 72 |, inputs|pec, cor|
|00001340| 72 65 63 74 73 70 65 63 | 2c 20 73 61 76 65 64 73 |rectspec|, saveds|
|00001350| 70 65 63 2c 20 6f 75 74 | 70 75 74 73 70 65 63 3b |pec, out|putspec;|
|00001360| 0d 09 6c 6f 6e 67 20 74 | 65 73 74 3b 0d 09 42 6f |..long t|est;..Bo|
|00001370| 6f 6c 65 61 6e 20 63 6f | 72 72 65 63 74 3b 0d 09 |olean co|rrect;..|
|00001380| 0d 09 65 72 72 20 3d 20 | 50 72 6f 62 6c 65 6d 47 |..err = |ProblemG|
|00001390| 65 74 54 65 73 74 44 69 | 72 65 63 74 6f 72 79 46 |etTestDi|rectoryF|
|000013a0| 53 53 70 65 63 28 20 26 | 74 65 73 74 73 70 65 63 |SSpec( &|testspec|
|000013b0| 20 29 3b 0d 09 50 72 6f | 62 6c 65 6d 4c 6f 67 45 | );..Pro|blemLogE|
|000013c0| 72 72 6f 72 28 20 65 72 | 72 2c 20 22 47 65 74 54 |rror( er|r, "GetT|
|000013d0| 65 73 74 44 69 72 65 63 | 74 6f 72 79 46 53 53 70 |estDirec|toryFSSp|
|000013e0| 65 63 22 20 29 3b 0d 09 | 0d 09 69 66 20 28 20 65 |ec" );..|..if ( e|
|000013f0| 72 72 20 3d 3d 20 6e 6f | 45 72 72 20 29 20 7b 0d |rr == no|Err ) {.|
|00001400| 09 09 74 65 73 74 20 3d | 20 31 3b 0d 09 09 77 68 |..test =| 1;...wh|
|00001410| 69 6c 65 20 28 20 31 20 | 29 20 7b 0d 09 09 09 65 |ile ( 1 |) {....e|
|00001420| 72 72 20 3d 20 50 72 6f | 62 6c 65 6d 47 65 74 54 |rr = Pro|blemGetT|
|00001430| 65 73 74 53 70 65 63 73 | 28 20 26 74 65 73 74 73 |estSpecs|( &tests|
|00001440| 70 65 63 2c 20 74 65 73 | 74 2c 20 26 69 6e 70 75 |pec, tes|t, &inpu|
|00001450| 74 73 70 65 63 2c 20 26 | 63 6f 72 72 65 63 74 73 |tspec, &|corrects|
|00001460| 70 65 63 2c 20 26 73 61 | 76 65 64 73 70 65 63 2c |pec, &sa|vedspec,|
|00001470| 20 26 6f 75 74 70 75 74 | 73 70 65 63 20 29 3b 0d | &output|spec );.|
|00001480| 09 09 09 69 66 20 28 20 | 65 72 72 20 21 3d 20 6e |...if ( |err != n|
|00001490| 6f 45 72 72 20 29 20 7b | 0d 09 09 09 09 69 66 20 |oErr ) {|.....if |
|000014a0| 28 20 65 72 72 20 21 3d | 20 66 6e 66 45 72 72 20 |( err !=| fnfErr |
|000014b0| 29 20 7b 0d 09 09 09 09 | 09 50 72 6f 62 6c 65 6d |) {.....|.Problem|
|000014c0| 4c 6f 67 45 72 72 6f 72 | 28 20 65 72 72 2c 20 22 |LogError|( err, "|
|000014d0| 47 65 74 54 65 73 74 53 | 70 65 63 73 22 20 29 3b |GetTestS|pecs" );|
|000014e0| 0d 09 09 09 09 7d 0d 09 | 09 09 09 62 72 65 61 6b |.....}..|...break|
|000014f0| 3b 0d 09 09 09 7d 0d 09 | 09 09 0d 09 09 09 70 72 |;....}..|......pr|
|00001500| 69 6e 74 66 28 20 22 54 | 65 73 74 20 25 64 5c 6e |intf( "T|est %d\n|
|00001510| 22 2c 20 74 65 73 74 20 | 29 3b 0d 09 09 09 2f 2f |", test |);....//|
|00001520| 20 54 65 73 74 0d 0d 09 | 09 09 69 66 20 28 20 72 | Test...|..if ( r|
|00001530| 75 6e 74 65 73 74 20 21 | 3d 20 4e 55 4c 4c 20 29 |untest !|= NULL )|
|00001540| 20 7b 0d 09 09 09 09 65 | 72 72 20 3d 20 72 75 6e | {.....e|rr = run|
|00001550| 74 65 73 74 28 20 26 73 | 61 76 65 64 73 70 65 63 |test( &s|avedspec|
|00001560| 2c 20 26 6f 75 74 70 75 | 74 73 70 65 63 20 29 3b |, &outpu|tspec );|
|00001570| 0d 09 09 09 09 69 66 20 | 28 20 65 72 72 20 3d 3d |.....if |( err ==|
|00001580| 20 6e 6f 45 72 72 20 29 | 20 7b 0d 09 09 09 09 09 | noErr )| {......|
|00001590| 63 6f 72 72 65 63 74 20 | 3d 20 21 50 72 6f 62 6c |correct |= !Probl|
|000015a0| 65 6d 44 69 66 66 46 69 | 6c 65 73 28 20 26 63 6f |emDiffFi|les( &co|
|000015b0| 72 72 65 63 74 73 70 65 | 63 2c 20 26 6f 75 74 70 |rrectspe|c, &outp|
|000015c0| 75 74 73 70 65 63 20 29 | 3b 0d 09 09 09 09 7d 0d |utspec )|;.....}.|
|000015d0| 09 09 09 7d 20 65 6c 73 | 65 20 7b 0d 09 09 09 09 |...} els|e {.....|
|000015e0| 65 72 72 20 3d 20 73 69 | 6e 67 6c 65 72 75 6e 74 |err = si|nglerunt|
|000015f0| 65 73 74 28 20 26 73 61 | 76 65 64 73 70 65 63 2c |est( &sa|vedspec,|
|00001600| 20 26 6f 75 74 70 75 74 | 73 70 65 63 2c 20 26 63 | &output|spec, &c|
|00001610| 6f 72 72 65 63 74 20 29 | 3b 0d 09 09 09 7d 0d 09 |orrect )|;....}..|
|00001620| 09 09 69 66 20 28 20 65 | 72 72 20 21 3d 20 6e 6f |..if ( e|rr != no|
|00001630| 45 72 72 20 29 20 7b 0d | 09 09 09 09 70 72 69 6e |Err ) {.|....prin|
|00001640| 74 66 28 20 22 46 41 49 | 4c 45 44 3a 20 52 65 73 |tf( "FAI|LED: Res|
|00001650| 75 6c 74 20 72 65 74 75 | 72 6e 65 64 20 25 64 21 |ult retu|rned %d!|
|00001660| 5c 6e 22 2c 20 65 72 72 | 20 29 3b 0d 09 09 09 7d |\n", err| );....}|
|00001670| 20 65 6c 73 65 20 69 66 | 20 28 20 50 72 6f 62 6c | else if| ( Probl|
|00001680| 65 6d 44 69 66 66 46 69 | 6c 65 73 28 20 26 69 6e |emDiffFi|les( &in|
|00001690| 70 75 74 73 70 65 63 2c | 20 26 73 61 76 65 64 73 |putspec,| &saveds|
|000016a0| 70 65 63 20 29 20 29 20 | 7b 0d 09 09 09 09 70 72 |pec ) ) |{.....pr|
|000016b0| 69 6e 74 66 28 20 22 46 | 41 49 4c 45 44 3a 20 4d |intf( "F|AILED: M|
|000016c0| 6f 64 69 66 69 65 64 20 | 49 6e 70 75 74 20 46 69 |odified |Input Fi|
|000016d0| 6c 65 73 21 5c 6e 22 20 | 29 3b 0d 09 09 09 7d 20 |les!\n" |);....} |
|000016e0| 65 6c 73 65 20 69 66 20 | 28 20 21 63 6f 72 72 65 |else if |( !corre|
|000016f0| 63 74 20 29 20 7b 0d 09 | 09 09 09 70 72 69 6e 74 |ct ) {..|...print|
|00001700| 66 28 20 22 46 41 49 4c | 45 44 3a 20 49 6e 63 6f |f( "FAIL|ED: Inco|
|00001710| 72 72 65 63 74 20 72 65 | 73 75 6c 74 21 5c 6e 22 |rrect re|sult!\n"|
|00001720| 20 29 3b 0d 09 09 09 7d | 20 65 6c 73 65 20 7b 0d | );....}| else {.|
|00001730| 09 09 09 09 70 72 69 6e | 74 66 28 20 22 53 55 43 |....prin|tf( "SUC|
|00001740| 43 45 53 53 21 5c 6e 22 | 20 29 3b 0d 09 09 09 7d |CESS!\n"| );....}|
|00001750| 0d 09 09 09 69 66 20 28 | 20 50 72 6f 62 6c 65 6d |....if (| Problem|
|00001760| 44 69 66 66 46 69 6c 65 | 73 28 20 26 69 6e 70 75 |DiffFile|s( &inpu|
|00001770| 74 73 70 65 63 2c 20 26 | 73 61 76 65 64 73 70 65 |tspec, &|savedspe|
|00001780| 63 20 29 20 29 20 7b 0d | 09 09 09 09 65 72 72 20 |c ) ) {.|....err |
|00001790| 3d 20 50 72 6f 62 6c 65 | 6d 44 75 70 6c 69 63 61 |= Proble|mDuplica|
|000017a0| 74 65 46 69 6c 65 28 20 | 26 73 61 76 65 64 73 70 |teFile( |&savedsp|
|000017b0| 65 63 2c 20 26 69 6e 70 | 75 74 73 70 65 63 20 29 |ec, &inp|utspec )|
|000017c0| 3b 0d 09 09 09 7d 0d 09 | 09 09 28 76 6f 69 64 29 |;....}..|..(void)|
|000017d0| 20 46 53 70 44 65 6c 65 | 74 65 28 20 26 73 61 76 | FSpDele|te( &sav|
|000017e0| 65 64 73 70 65 63 20 29 | 3b 0d 09 09 09 0d 09 09 |edspec )|;.......|
|000017f0| 09 74 65 73 74 2b 2b 3b | 0d 09 09 7d 0d 09 7d 0d |.test++;|...}..}.|
|00001800| 7d 0d 0d 70 61 73 63 61 | 6c 20 76 6f 69 64 20 50 |}..pasca|l void P|
|00001810| 72 6f 62 6c 65 6d 52 75 | 6e 46 69 6c 65 54 65 73 |roblemRu|nFileTes|
|00001820| 74 73 28 20 52 75 6e 46 | 69 6c 65 54 65 73 74 50 |ts( RunF|ileTestP|
|00001830| 72 6f 63 20 72 75 6e 74 | 65 73 74 20 29 0d 7b 0d |roc runt|est ).{.|
|00001840| 09 50 72 6f 62 6c 65 6d | 52 75 6e 45 69 74 68 65 |.Problem|RunEithe|
|00001850| 72 46 69 6c 65 54 65 73 | 74 73 28 20 72 75 6e 74 |rFileTes|ts( runt|
|00001860| 65 73 74 2c 20 4e 55 4c | 4c 20 29 3b 0d 7d 0d 0d |est, NUL|L );.}..|
|00001870| 70 61 73 63 61 6c 20 76 | 6f 69 64 20 50 72 6f 62 |pascal v|oid Prob|
|00001880| 6c 65 6d 52 75 6e 53 69 | 6e 67 6c 65 46 69 6c 65 |lemRunSi|ngleFile|
|00001890| 54 65 73 74 73 28 20 52 | 75 6e 53 69 6e 67 6c 65 |Tests( R|unSingle|
|000018a0| 46 69 6c 65 54 65 73 74 | 50 72 6f 63 20 72 75 6e |FileTest|Proc run|
|000018b0| 74 65 73 74 20 29 0d 7b | 0d 09 50 72 6f 62 6c 65 |test ).{|..Proble|
|000018c0| 6d 52 75 6e 45 69 74 68 | 65 72 46 69 6c 65 54 65 |mRunEith|erFileTe|
|000018d0| 73 74 73 28 20 4e 55 4c | 4c 2c 20 72 75 6e 74 65 |sts( NUL|L, runte|
|000018e0| 73 74 20 29 3b 0d 7d 0d | 0d 70 61 73 63 61 6c 20 |st );.}.|.pascal |
|000018f0| 4f 53 45 72 72 20 50 72 | 6f 62 6c 65 6d 46 69 6c |OSErr Pr|oblemFil|
|00001900| 65 52 65 61 64 28 20 63 | 6f 6e 73 74 20 46 53 53 |eRead( c|onst FSS|
|00001910| 70 65 63 2a 20 69 6e 66 | 69 6c 65 2c 20 48 61 6e |pec* inf|ile, Han|
|00001920| 64 6c 65 20 2a 64 61 74 | 61 20 29 0d 7b 0d 09 4f |dle *dat|a ).{..O|
|00001930| 53 45 72 72 20 65 72 72 | 3b 0d 09 73 68 6f 72 74 |SErr err|;..short|
|00001940| 20 72 6e 3b 0d 09 6c 6f | 6e 67 20 66 69 6c 65 6c | rn;..lo|ng filel|
|00001950| 65 6e 3b 0d 09 0d 09 2a | 64 61 74 61 20 3d 20 6e |en;....*|data = n|
|00001960| 69 6c 3b 0d 09 65 72 72 | 20 3d 20 46 53 70 4f 70 |il;..err| = FSpOp|
|00001970| 65 6e 44 46 28 20 69 6e | 66 69 6c 65 2c 20 66 73 |enDF( in|file, fs|
|00001980| 52 64 50 65 72 6d 2c 20 | 26 72 6e 20 29 3b 0d 09 |RdPerm, |&rn );..|
|00001990| 69 66 20 28 20 65 72 72 | 20 3d 3d 20 6e 6f 45 72 |if ( err| == noEr|
|000019a0| 72 20 29 20 7b 0d 09 09 | 65 72 72 20 3d 20 47 65 |r ) {...|err = Ge|
|000019b0| 74 45 4f 46 28 20 72 6e | 2c 20 20 26 66 69 6c 65 |tEOF( rn|, &file|
|000019c0| 6c 65 6e 20 29 3b 0d 09 | 09 69 66 20 28 20 65 72 |len );..|.if ( er|
|000019d0| 72 20 3d 3d 20 6e 6f 45 | 72 72 20 29 20 7b 0d 09 |r == noE|rr ) {..|
|000019e0| 09 09 2a 64 61 74 61 20 | 3d 20 4e 65 77 48 61 6e |..*data |= NewHan|
|000019f0| 64 6c 65 28 20 66 69 6c | 65 6c 65 6e 20 29 3b 0d |dle( fil|elen );.|
|00001a00| 09 09 09 65 72 72 20 3d | 20 4d 65 6d 45 72 72 6f |...err =| MemErro|
|00001a10| 72 28 29 3b 0d 09 09 09 | 69 66 20 28 20 65 72 72 |r();....|if ( err|
|00001a20| 20 3d 3d 20 6e 6f 45 72 | 72 20 29 20 7b 0d 09 09 | == noEr|r ) {...|
|00001a30| 09 09 48 4c 6f 63 6b 28 | 20 2a 64 61 74 61 20 29 |..HLock(| *data )|
|00001a40| 3b 0d 09 09 09 09 65 72 | 72 20 3d 20 50 72 6f 62 |;.....er|r = Prob|
|00001a50| 6c 65 6d 46 53 4d 75 73 | 74 52 65 61 64 28 20 72 |lemFSMus|tRead( r|
|00001a60| 6e 2c 20 66 69 6c 65 6c | 65 6e 2c 20 2a 2a 64 61 |n, filel|en, **da|
|00001a70| 74 61 20 29 3b 0d 09 09 | 09 09 48 55 6e 6c 6f 63 |ta );...|..HUnloc|
|00001a80| 6b 28 20 2a 64 61 74 61 | 20 29 3b 0d 09 09 09 7d |k( *data| );....}|
|00001a90| 0d 09 09 7d 0d 09 09 28 | 76 6f 69 64 20 29 46 53 |...}...(|void )FS|
|00001aa0| 43 6c 6f 73 65 28 20 72 | 6e 20 29 3b 0d 09 7d 0d |Close( r|n );..}.|
|00001ab0| 09 69 66 20 28 20 65 72 | 72 20 21 3d 20 6e 6f 45 |.if ( er|r != noE|
|00001ac0| 72 72 20 29 20 7b 0d 09 | 09 44 69 73 70 6f 73 65 |rr ) {..|.Dispose|
|00001ad0| 48 61 6e 64 6c 65 28 20 | 2a 64 61 74 61 20 29 3b |Handle( |*data );|
|00001ae0| 0d 09 7d 0d 09 72 65 74 | 75 72 6e 20 65 72 72 3b |..}..ret|urn err;|
|00001af0| 0d 7d 0d 0d 70 61 73 63 | 61 6c 20 4f 53 45 72 72 |.}..pasc|al OSErr|
|00001b00| 20 50 72 6f 62 6c 65 6d | 46 69 6c 65 57 72 69 74 | Problem|FileWrit|
|00001b10| 65 28 20 63 6f 6e 73 74 | 20 46 53 53 70 65 63 2a |e( const| FSSpec*|
|00001b20| 20 6f 75 74 66 69 6c 65 | 2c 20 48 61 6e 64 6c 65 | outfile|, Handle|
|00001b30| 20 64 61 74 61 20 29 0d | 7b 0d 09 4f 53 45 72 72 | data ).|{..OSErr|
|00001b40| 20 65 72 72 2c 20 65 72 | 72 32 3b 0d 09 73 68 6f | err, er|r2;..sho|
|00001b50| 72 74 20 72 6e 3b 0d 09 | 0d 09 28 76 6f 69 64 29 |rt rn;..|..(void)|
|00001b60| 20 46 53 70 44 65 6c 65 | 74 65 28 20 6f 75 74 66 | FSpDele|te( outf|
|00001b70| 69 6c 65 20 29 3b 0d 09 | 28 76 6f 69 64 29 20 46 |ile );..|(void) F|
|00001b80| 53 70 43 72 65 61 74 65 | 28 20 6f 75 74 66 69 6c |SpCreate|( outfil|
|00001b90| 65 2c 20 27 43 57 49 45 | 27 2c 20 27 54 45 58 54 |e, 'CWIE|', 'TEXT|
|00001ba0| 27 2c 20 30 20 29 3b 0d | 09 65 72 72 20 3d 20 46 |', 0 );.|.err = F|
|00001bb0| 53 70 4f 70 65 6e 44 46 | 28 20 6f 75 74 66 69 6c |SpOpenDF|( outfil|
|00001bc0| 65 2c 20 66 73 57 72 50 | 65 72 6d 2c 20 26 72 6e |e, fsWrP|erm, &rn|
|00001bd0| 20 29 3b 0d 09 69 66 20 | 28 20 65 72 72 20 3d 3d | );..if |( err ==|
|00001be0| 20 6e 6f 45 72 72 20 29 | 20 7b 0d 09 09 48 4c 6f | noErr )| {...HLo|
|00001bf0| 63 6b 28 20 64 61 74 61 | 20 29 3b 0d 09 09 65 72 |ck( data| );...er|
|00001c00| 72 20 3d 20 50 72 6f 62 | 6c 65 6d 46 53 57 72 69 |r = Prob|lemFSWri|
|00001c10| 74 65 28 20 72 6e 2c 20 | 47 65 74 48 61 6e 64 6c |te( rn, |GetHandl|
|00001c20| 65 53 69 7a 65 28 20 64 | 61 74 61 20 29 2c 20 2a |eSize( d|ata ), *|
|00001c30| 64 61 74 61 20 29 3b 0d | 09 09 48 55 6e 6c 6f 63 |data );.|..HUnloc|
|00001c40| 6b 28 20 64 61 74 61 20 | 29 3b 0d 09 09 65 72 72 |k( data |);...err|
|00001c50| 32 20 3d 20 46 53 43 6c | 6f 73 65 28 20 72 6e 20 |2 = FSCl|ose( rn |
|00001c60| 29 3b 0d 09 09 69 66 20 | 28 20 65 72 72 20 3d 3d |);...if |( err ==|
|00001c70| 20 6e 6f 45 72 72 20 29 | 20 7b 0d 09 09 09 65 72 | noErr )| {....er|
|00001c80| 72 20 3d 20 65 72 72 32 | 3b 0d 09 09 7d 0d 09 7d |r = err2|;...}..}|
|00001c90| 0d 09 72 65 74 75 72 6e | 20 65 72 72 3b 0d 7d 0d |..return| err;.}.|
|00001ca0| 0d 70 61 73 63 61 6c 20 | 42 6f 6f 6c 65 61 6e 20 |.pascal |Boolean |
|00001cb0| 50 72 6f 62 6c 65 6d 52 | 65 61 64 4c 69 6e 65 46 |ProblemR|eadLineF|
|00001cc0| 72 6f 6d 48 61 6e 64 6c | 65 28 20 48 61 6e 64 6c |romHandl|e( Handl|
|00001cd0| 65 20 64 61 74 61 2c 20 | 63 68 61 72 20 2a 6c 69 |e data, |char *li|
|00001ce0| 6e 65 2c 20 6c 6f 6e 67 | 20 6c 69 6e 65 6c 65 6e |ne, long| linelen|
|00001cf0| 20 29 0d 7b 0d 09 6c 6f | 6e 67 20 64 61 74 61 6c | ).{..lo|ng datal|
|00001d00| 65 6e 20 3d 20 47 65 74 | 48 61 6e 64 6c 65 53 69 |en = Get|HandleSi|
|00001d10| 7a 65 28 20 64 61 74 61 | 20 29 3b 0d 09 63 68 61 |ze( data| );..cha|
|00001d20| 72 20 2a 70 20 3d 20 2a | 64 61 74 61 3b 0d 09 63 |r *p = *|data;..c|
|00001d30| 68 61 72 20 2a 64 61 74 | 61 66 69 6e 20 3d 20 70 |har *dat|afin = p|
|00001d40| 20 2b 20 64 61 74 61 6c | 65 6e 3b 0d 09 6c 6f 6e | + datal|en;..lon|
|00001d50| 67 20 61 63 74 6c 69 6e | 65 6c 65 6e 3b 0d 09 0d |g actlin|elen;...|
|00001d60| 09 69 66 20 28 20 64 61 | 74 61 6c 65 6e 20 3d 3d |.if ( da|talen ==|
|00001d70| 20 30 20 29 20 72 65 74 | 75 72 6e 20 66 61 6c 73 | 0 ) ret|urn fals|
|00001d80| 65 3b 0d 09 0d 09 77 68 | 69 6c 65 20 28 20 2a 70 |e;....wh|ile ( *p|
|00001d90| 20 21 3d 20 27 5c 72 27 | 20 26 26 20 70 20 3c 20 | != '\r'| && p < |
|00001da0| 64 61 74 61 66 69 6e 20 | 29 20 70 2b 2b 3b 0d 09 |datafin |) p++;..|
|00001db0| 61 63 74 6c 69 6e 65 6c | 65 6e 20 3d 20 70 20 2d |actlinel|en = p -|
|00001dc0| 20 2a 64 61 74 61 3b 0d | 09 61 63 74 6c 69 6e 65 | *data;.|.actline|
|00001dd0| 6c 65 6e 20 3d 20 61 63 | 74 6c 69 6e 65 6c 65 6e |len = ac|tlinelen|
|00001de0| 20 3c 20 6c 69 6e 65 6c | 65 6e 20 3f 20 61 63 74 | < linel|en ? act|
|00001df0| 6c 69 6e 65 6c 65 6e 20 | 3a 20 6c 69 6e 65 6c 65 |linelen |: linele|
|00001e00| 6e 20 2d 20 31 3b 0d 09 | 42 6c 6f 63 6b 4d 6f 76 |n - 1;..|BlockMov|
|00001e10| 65 44 61 74 61 28 20 2a | 64 61 74 61 2c 20 6c 69 |eData( *|data, li|
|00001e20| 6e 65 2c 20 61 63 74 6c | 69 6e 65 6c 65 6e 20 29 |ne, actl|inelen )|
|00001e30| 3b 0d 09 6c 69 6e 65 5b | 61 63 74 6c 69 6e 65 6c |;..line[|actlinel|
|00001e40| 65 6e 5d 20 3d 20 30 3b | 0d 09 69 66 20 28 20 70 |en] = 0;|..if ( p|
|00001e50| 20 3c 20 64 61 74 61 66 | 69 6e 20 29 20 70 2b 2b | < dataf|in ) p++|
|00001e60| 3b 0d 09 28 76 6f 69 64 | 29 20 4d 75 6e 67 65 72 |;..(void|) Munger|
|00001e70| 28 20 64 61 74 61 2c 20 | 30 2c 20 6e 69 6c 2c 20 |( data, |0, nil, |
|00001e80| 70 20 2d 20 2a 64 61 74 | 61 2c 20 26 64 61 74 61 |p - *dat|a, &data|
|00001e90| 2c 20 30 29 3b 20 2f 2f | 20 44 65 6c 65 74 65 20 |, 0); //| Delete |
|00001ea0| 6c 69 6e 65 20 66 72 6f | 6d 20 73 74 61 72 74 20 |line fro|m start |
|00001eb0| 6f 66 20 68 61 6e 64 6c | 65 0d 09 72 65 74 75 72 |of handl|e..retur|
|00001ec0| 6e 20 74 72 75 65 3b 0d | 7d 0d 0d 70 61 73 63 61 |n true;.|}..pasca|
|00001ed0| 6c 20 4f 53 45 72 72 20 | 50 72 6f 62 6c 65 6d 57 |l OSErr |ProblemW|
|00001ee0| 72 69 74 65 4c 69 6e 65 | 54 6f 48 61 6e 64 6c 65 |riteLine|ToHandle|
|00001ef0| 28 20 48 61 6e 64 6c 65 | 20 64 61 74 61 2c 20 63 |( Handle| data, c|
|00001f00| 68 61 72 20 2a 6c 69 6e | 65 20 29 0d 7b 0d 09 4f |har *lin|e ).{..O|
|00001f10| 53 45 72 72 20 65 72 72 | 3b 0d 09 0d 09 65 72 72 |SErr err|;....err|
|00001f20| 20 3d 20 50 72 6f 62 6c | 65 6d 57 72 69 74 65 53 | = Probl|emWriteS|
|00001f30| 74 72 69 6e 67 54 6f 48 | 61 6e 64 6c 65 28 20 64 |tringToH|andle( d|
|00001f40| 61 74 61 2c 20 6c 69 6e | 65 20 29 3b 0d 09 69 66 |ata, lin|e );..if|
|00001f50| 20 28 20 65 72 72 20 3d | 3d 20 6e 6f 45 72 72 20 | ( err =|= noErr |
|00001f60| 29 20 7b 0d 09 09 65 72 | 72 20 3d 20 50 72 6f 62 |) {...er|r = Prob|
|00001f70| 6c 65 6d 57 72 69 74 65 | 53 74 72 69 6e 67 54 6f |lemWrite|StringTo|
|00001f80| 48 61 6e 64 6c 65 28 20 | 64 61 74 61 2c 20 22 5c |Handle( |data, "\|
|00001f90| 72 22 20 29 3b 0d 09 7d | 0d 09 72 65 74 75 72 6e |r" );..}|..return|
|00001fa0| 20 65 72 72 3b 0d 7d 0d | 0d 70 61 73 63 61 6c 20 | err;.}.|.pascal |
|00001fb0| 4f 53 45 72 72 20 50 72 | 6f 62 6c 65 6d 57 72 69 |OSErr Pr|oblemWri|
|00001fc0| 74 65 53 74 72 69 6e 67 | 54 6f 48 61 6e 64 6c 65 |teString|ToHandle|
|00001fd0| 28 20 48 61 6e 64 6c 65 | 20 64 61 74 61 2c 20 63 |( Handle| data, c|
|00001fe0| 68 61 72 20 2a 6c 69 6e | 65 20 29 0d 7b 0d 09 4f |har *lin|e ).{..O|
|00001ff0| 53 45 72 72 20 65 72 72 | 3b 0d 09 0d 09 65 72 72 |SErr err|;....err|
|00002000| 20 3d 20 50 74 72 41 6e | 64 48 61 6e 64 28 20 6c | = PtrAn|dHand( l|
|00002010| 69 6e 65 2c 20 64 61 74 | 61 2c 20 73 74 72 6c 65 |ine, dat|a, strle|
|00002020| 6e 28 6c 69 6e 65 29 20 | 29 3b 0d 09 72 65 74 75 |n(line) |);..retu|
|00002030| 72 6e 20 65 72 72 3b 0d | 7d 0d 0d 70 61 73 63 61 |rn err;.|}..pasca|
|00002040| 6c 20 76 6f 69 64 20 50 | 72 6f 62 6c 65 6d 50 32 |l void P|roblemP2|
|00002050| 43 53 74 72 69 6e 67 28 | 20 76 6f 69 64 20 2a 6c |CString(| void *l|
|00002060| 69 6e 65 20 29 0d 7b 0d | 09 75 6e 73 69 67 6e 65 |ine ).{.|.unsigne|
|00002070| 64 20 63 68 61 72 20 2a | 70 20 3d 20 28 75 6e 73 |d char *|p = (uns|
|00002080| 69 67 6e 65 64 20 63 68 | 61 72 20 2a 29 6c 69 6e |igned ch|ar *)lin|
|00002090| 65 3b 0d 09 6c 6f 6e 67 | 20 6c 65 6e 20 3d 20 2a |e;..long| len = *|
|000020a0| 70 3b 0d 09 0d 09 42 6c | 6f 63 6b 4d 6f 76 65 44 |p;....Bl|ockMoveD|
|000020b0| 61 74 61 28 20 70 20 2b | 20 31 2c 20 70 2c 20 6c |ata( p +| 1, p, l|
|000020c0| 65 6e 20 29 3b 0d 09 70 | 5b 6c 65 6e 5d 20 3d 20 |en );..p|[len] = |
|000020d0| 30 3b 0d 7d 0d 0d 70 61 | 73 63 61 6c 20 76 6f 69 |0;.}..pa|scal voi|
|000020e0| 64 20 50 72 6f 62 6c 65 | 6d 43 32 50 53 74 72 69 |d Proble|mC2PStri|
|000020f0| 6e 67 28 20 76 6f 69 64 | 20 2a 6c 69 6e 65 20 29 |ng( void| *line )|
|00002100| 0d 7b 0d 09 63 68 61 72 | 20 2a 70 20 3d 20 28 63 |.{..char| *p = (c|
|00002110| 68 61 72 20 2a 29 6c 69 | 6e 65 3b 0d 09 6c 6f 6e |har *)li|ne;..lon|
|00002120| 67 20 6c 65 6e 20 3d 20 | 73 74 72 6c 65 6e 28 70 |g len = |strlen(p|
|00002130| 29 3b 0d 09 0d 09 6c 65 | 6e 20 3d 20 6c 65 6e 20 |);....le|n = len |
|00002140| 3c 3d 20 32 35 35 20 3f | 20 6c 65 6e 20 3a 20 32 |<= 255 ?| len : 2|
|00002150| 35 35 3b 0d 09 0d 09 42 | 6c 6f 63 6b 4d 6f 76 65 |55;....B|lockMove|
|00002160| 44 61 74 61 28 20 70 2c | 20 70 20 2b 20 31 2c 20 |Data( p,| p + 1, |
|00002170| 6c 65 6e 20 29 3b 0d 09 | 70 5b 30 5d 20 3d 20 6c |len );..|p[0] = l|
|00002180| 65 6e 3b 0d 7d 0d 0d 70 | 61 73 63 61 6c 20 42 6f |en;.}..p|ascal Bo|
|00002190| 6f 6c 65 61 6e 20 50 72 | 6f 62 6c 65 6d 47 65 74 |olean Pr|oblemGet|
|000021a0| 55 49 6e 74 33 32 28 20 | 63 68 61 72 20 2a 2a 6c |UInt32( |char **l|
|000021b0| 69 6e 65 2c 20 55 49 6e | 74 33 32 20 2a 6e 75 6d |ine, UIn|t32 *num|
|000021c0| 62 65 72 20 29 0d 7b 0d | 09 63 68 61 72 20 6e 75 |ber ).{.|.char nu|
|000021d0| 6d 62 65 72 73 5b 32 30 | 5d 3b 0d 09 0d 09 50 72 |mbers[20|];....Pr|
|000021e0| 6f 62 6c 65 6d 47 65 74 | 43 53 74 72 69 6e 67 28 |oblemGet|CString(|
|000021f0| 20 6c 69 6e 65 2c 20 6e | 75 6d 62 65 72 73 2c 20 | line, n|umbers, |
|00002200| 32 30 20 29 3b 0d 09 72 | 65 74 75 72 6e 20 73 73 |20 );..r|eturn ss|
|00002210| 63 61 6e 66 28 20 6e 75 | 6d 62 65 72 73 2c 20 22 |canf( nu|mbers, "|
|00002220| 25 6c 64 22 2c 20 6e 75 | 6d 62 65 72 20 29 20 3d |%ld", nu|mber ) =|
|00002230| 3d 20 31 3b 0d 7d 0d 0d | 70 61 73 63 61 6c 20 42 |= 1;.}..|pascal B|
|00002240| 6f 6f 6c 65 61 6e 20 50 | 72 6f 62 6c 65 6d 47 65 |oolean P|roblemGe|
|00002250| 74 53 49 6e 74 33 32 28 | 20 63 68 61 72 20 2a 2a |tSInt32(| char **|
|00002260| 6c 69 6e 65 2c 20 53 49 | 6e 74 33 32 20 2a 6e 75 |line, SI|nt32 *nu|
|00002270| 6d 62 65 72 20 29 0d 7b | 0d 09 63 68 61 72 20 6e |mber ).{|..char n|
|00002280| 75 6d 62 65 72 73 5b 32 | 30 5d 3b 0d 09 0d 09 50 |umbers[2|0];....P|
|00002290| 72 6f 62 6c 65 6d 47 65 | 74 43 53 74 72 69 6e 67 |roblemGe|tCString|
|000022a0| 28 20 6c 69 6e 65 2c 20 | 6e 75 6d 62 65 72 73 2c |( line, |numbers,|
|000022b0| 20 32 30 20 29 3b 0d 09 | 72 65 74 75 72 6e 20 73 | 20 );..|return s|
|000022c0| 73 63 61 6e 66 28 20 6e | 75 6d 62 65 72 73 2c 20 |scanf( n|umbers, |
|000022d0| 22 25 6c 64 22 2c 20 6e | 75 6d 62 65 72 20 29 20 |"%ld", n|umber ) |
|000022e0| 3d 3d 20 31 3b 0d 7d 0d | 0d 70 61 73 63 61 6c 20 |== 1;.}.|.pascal |
|000022f0| 76 6f 69 64 20 50 72 6f | 62 6c 65 6d 47 65 74 53 |void Pro|blemGetS|
|00002300| 74 72 69 6e 67 28 20 63 | 68 61 72 20 2a 2a 6c 69 |tring( c|har **li|
|00002310| 6e 65 2c 20 53 74 72 69 | 6e 67 50 74 72 20 66 69 |ne, Stri|ngPtr fi|
|00002320| 65 6c 64 20 29 0d 7b 0d | 09 63 68 61 72 20 2a 70 |eld ).{.|.char *p|
|00002330| 3b 0d 09 0d 09 70 20 3d | 20 2a 6c 69 6e 65 3b 0d |;....p =| *line;.|
|00002340| 09 77 68 69 6c 65 20 28 | 20 2a 70 20 21 3d 20 30 |.while (| *p != 0|
|00002350| 20 26 26 20 2a 70 20 21 | 3d 20 27 2c 27 20 29 20 | && *p !|= ',' ) |
|00002360| 70 2b 2b 3b 0d 09 66 69 | 65 6c 64 5b 30 5d 20 3d |p++;..fi|eld[0] =|
|00002370| 20 70 20 2d 20 2a 6c 69 | 6e 65 3b 0d 09 42 6c 6f | p - *li|ne;..Blo|
|00002380| 63 6b 4d 6f 76 65 44 61 | 74 61 28 20 2a 6c 69 6e |ckMoveDa|ta( *lin|
|00002390| 65 2c 20 26 66 69 65 6c | 64 5b 31 5d 2c 20 66 69 |e, &fiel|d[1], fi|
|000023a0| 65 6c 64 5b 30 5d 20 29 | 3b 0d 09 69 66 20 28 20 |eld[0] )|;..if ( |
|000023b0| 2a 70 20 29 20 70 2b 2b | 3b 0d 09 2a 6c 69 6e 65 |*p ) p++|;..*line|
|000023c0| 20 3d 20 70 3b 0d 7d 0d | 0d 70 61 73 63 61 6c 20 | = p;.}.|.pascal |
|000023d0| 76 6f 69 64 20 50 72 6f | 62 6c 65 6d 47 65 74 43 |void Pro|blemGetC|
|000023e0| 53 74 72 69 6e 67 28 20 | 63 68 61 72 20 2a 2a 6c |String( |char **l|
|000023f0| 69 6e 65 2c 20 63 68 61 | 72 20 2a 66 69 65 6c 64 |ine, cha|r *field|
|00002400| 2c 20 6c 6f 6e 67 20 66 | 69 65 6c 64 6c 65 6e 20 |, long f|ieldlen |
|00002410| 29 0d 7b 0d 09 63 68 61 | 72 20 2a 70 3b 0d 09 6c |).{..cha|r *p;..l|
|00002420| 6f 6e 67 20 6c 65 6e 3b | 0d 09 0d 09 70 20 3d 20 |ong len;|....p = |
|00002430| 2a 6c 69 6e 65 3b 0d 09 | 77 68 69 6c 65 20 28 20 |*line;..|while ( |
|00002440| 2a 70 20 21 3d 20 30 20 | 26 26 20 2a 70 20 21 3d |*p != 0 |&& *p !=|
|00002450| 20 27 2c 27 20 29 20 70 | 2b 2b 3b 0d 09 6c 65 6e | ',' ) p|++;..len|
|00002460| 20 3d 20 70 20 2d 20 2a | 6c 69 6e 65 3b 0d 09 6c | = p - *|line;..l|
|00002470| 65 6e 20 3d 20 6c 65 6e | 20 3c 20 66 69 65 6c 64 |en = len| < field|
|00002480| 6c 65 6e 20 3f 20 6c 65 | 6e 20 3a 20 66 69 65 6c |len ? le|n : fiel|
|00002490| 64 6c 65 6e 20 2d 20 31 | 3b 0d 09 42 6c 6f 63 6b |dlen - 1|;..Block|
|000024a0| 4d 6f 76 65 44 61 74 61 | 28 20 2a 6c 69 6e 65 2c |MoveData|( *line,|
|000024b0| 20 66 69 65 6c 64 2c 20 | 6c 65 6e 20 29 3b 0d 09 | field, |len );..|
|000024c0| 66 69 65 6c 64 5b 6c 65 | 6e 5d 20 3d 20 30 3b 0d |field[le|n] = 0;.|
|000024d0| 09 69 66 20 28 20 2a 70 | 20 29 20 70 2b 2b 3b 0d |.if ( *p| ) p++;.|
|000024e0| 09 2a 6c 69 6e 65 20 3d | 20 70 3b 0d 7d 0d 0d 00 |.*line =| p;.}...|
|000024f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002500| 00 00 01 00 00 00 01 54 | 00 00 00 54 00 00 00 46 |.......T|...T...F|
|00002510| 2b 30 38 30 30 31 35 3a | 35 35 3a 33 32 20 31 39 |+080015:|55:32 19|
|00002520| 39 38 00 00 00 00 00 00 | 00 00 b1 78 6a 77 00 00 |98......|...xjw..|
|00002530| 0f 50 72 6f 62 6c 65 6d | 55 74 69 6c 73 2e 63 70 |.Problem|Utils.cp|
|00002540| 63 6b 20 43 6f 6e 74 65 | 73 74 31 2e 73 69 74 69 |ck Conte|st1.siti|
|00002550| 02 4a 50 61 72 74 53 49 | 54 21 00 00 00 00 00 00 |.JPartSI|T!......|
|00002560| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002570| 00 00 b1 b0 40 92 00 00 | 00 00 00 00 01 9a 00 00 |....@...|........|
|00002580| 00 00 29 bc 7f 92 00 00 | 00 00 20 52 65 3a 20 46 |..).....|.. Re: F|
|00002590| 6f 6c 64 65 72 20 48 69 | 65 72 61 72 63 68 79 20 |older Hi|erarchy |
|000025a0| 44 75 70 6c 69 63 61 74 | 69 6f 6e 0d 00 00 00 00 |Duplicat|ion.....|
|000025b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000025c0| 00 00 00 00 00 00 00 00 | 00 04 36 35 37 a4 00 00 |........|..657...|
|000025d0| 00 00 00 00 00 00 00 00 | 00 01 be ab 00 00 05 f2 |........|........|
|000025e0| 00 00 02 90 02 07 31 32 | 2f 35 2f 39 38 34 30 30 |......12|/5/98400|
|000025f0| 30 32 31 3a 30 31 3a 35 | 36 20 31 39 39 38 00 00 |021:01:5|6 1998..|
|00002600| 00 00 00 48 00 0a 47 65 | 6e 65 76 61 00 00 00 00 |...H..Ge|neva....|
|00002610| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002620| 00 00 00 00 00 00 00 02 | 00 02 00 3e 00 0d 02 43 |........|...>...C|
|00002630| 02 63 00 3e 00 0d 02 43 | 02 63 b1 a0 78 2a 00 00 |.c.>...C|.c..x*..|
|00002640| 00 a4 00 00 00 a4 00 00 | 00 00 01 00 00 00 00 04 |........|........|
|00002650| 00 01 00 01 00 00 01 00 | 00 00 01 54 00 00 00 54 |........|...T...T|
|00002660| 00 00 00 46 05 70 6f c8 | 3e cc 00 00 00 1c 00 46 |...F.po.|>......F|
|00002670| 00 01 4d 50 53 52 00 00 | 00 12 4d 57 42 42 00 00 |..MPSR..|..MWBB..|
|00002680| 00 1e 03 ed ff ff 00 00 | 00 00 00 00 00 00 03 f0 |........|........|
|00002690| ff ff 00 00 00 4c 00 00 | 00 00 00 00 00 00 00 00 |.....L..|........|
|000026a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000026b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000026c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000026d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000026e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000026f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+