home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume02 / duonly < prev    next >
SHell self-extracting ARchive  |  1991-08-27  |  22.0 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

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

You can browse this item here: duonly

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file C source text default
99% file C source, ASCII text default
100% TrID E-Mail message (Var. 2) default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime application/mbox default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 46 72 6f 6d 20 6d 69 70 | 6f 73 33 21 6f 6d 65 70 |From mip|os3!omep|
|00000010| 64 21 75 6f 72 65 67 6f | 6e 21 68 70 2d 70 63 64 |d!uorego|n!hp-pcd|
|00000020| 21 68 70 6c 61 62 73 21 | 64 65 63 77 72 6c 21 6c |!hplabs!|decwrl!l|
|00000030| 61 62 72 65 61 21 61 75 | 72 6f 72 61 21 61 6d 65 |abrea!au|rora!ame|
|00000040| 6c 69 61 21 61 6d 65 73 | 21 6e 65 63 6e 74 63 21 |lia!ames|!necntc!|
|00000050| 6e 63 6f 61 73 74 21 61 | 6c 6c 62 65 72 79 20 57 |ncoast!a|llbery W|
|00000060| 65 64 20 46 65 62 20 32 | 34 20 32 31 3a 31 33 3a |ed Feb 2|4 21:13:|
|00000070| 34 30 20 50 53 54 20 31 | 39 38 38 0a 41 72 74 69 |40 PST 1|988.Arti|
|00000080| 63 6c 65 20 33 30 38 20 | 6f 66 20 63 6f 6d 70 2e |cle 308 |of comp.|
|00000090| 73 6f 75 72 63 65 73 2e | 6d 69 73 63 3a 0a 50 61 |sources.|misc:.Pa|
|000000a0| 74 68 3a 20 74 64 32 63 | 61 64 21 6d 69 70 6f 73 |th: td2c|ad!mipos|
|000000b0| 33 21 6f 6d 65 70 64 21 | 75 6f 72 65 67 6f 6e 21 |3!omepd!|uoregon!|
|000000c0| 68 70 2d 70 63 64 21 68 | 70 6c 61 62 73 21 64 65 |hp-pcd!h|plabs!de|
|000000d0| 63 77 72 6c 21 6c 61 62 | 72 65 61 21 61 75 72 6f |cwrl!lab|rea!auro|
|000000e0| 72 61 21 61 6d 65 6c 69 | 61 21 61 6d 65 73 21 6e |ra!ameli|a!ames!n|
|000000f0| 65 63 6e 74 63 21 6e 63 | 6f 61 73 74 21 61 6c 6c |ecntc!nc|oast!all|
|00000100| 62 65 72 79 0a 46 72 6f | 6d 3a 20 64 65 6e 6e 69 |bery.Fro|m: denni|
|00000110| 73 40 72 6c 67 76 61 78 | 2e 55 55 43 50 20 28 44 |s@rlgvax|.UUCP (D|
|00000120| 65 6e 6e 69 73 2e 42 65 | 64 6e 61 72 29 0a 4e 65 |ennis.Be|dnar).Ne|
|00000130| 77 73 67 72 6f 75 70 73 | 3a 20 63 6f 6d 70 2e 73 |wsgroups|: comp.s|
|00000140| 6f 75 72 63 65 73 2e 6d | 69 73 63 0a 53 75 62 6a |ources.m|isc.Subj|
|00000150| 65 63 74 3a 20 76 30 32 | 69 30 36 30 3a 20 64 75 |ect: v02|i060: du|
|00000160| 6f 6e 6c 79 20 2d 20 50 | 72 6f 67 72 61 6d 20 74 |only - P|rogram t|
|00000170| 6f 20 64 69 73 70 6c 61 | 79 20 64 75 20 6f 75 74 |o displa|y du out|
|00000180| 70 75 74 20 4f 4e 4c 59 | 20 66 6f 72 20 61 20 64 |put ONLY| for a d|
|00000190| 69 72 65 63 74 6f 72 79 | 0a 4b 65 79 77 6f 72 64 |irectory|.Keyword|
|000001a0| 73 3a 20 64 75 2c 20 64 | 69 73 6b 20 75 73 61 67 |s: du, d|isk usag|
|000001b0| 65 2c 20 64 69 73 6b 20 | 48 4f 47 0a 4d 65 73 73 |e, disk |HOG.Mess|
|000001c0| 61 67 65 2d 49 44 3a 20 | 3c 37 34 32 39 40 6e 63 |age-ID: |<7429@nc|
|000001d0| 6f 61 73 74 2e 55 55 43 | 50 3e 0a 44 61 74 65 3a |oast.UUC|P>.Date:|
|000001e0| 20 32 32 20 46 65 62 20 | 38 38 20 30 32 3a 33 34 | 22 Feb |88 02:34|
|000001f0| 3a 33 37 20 47 4d 54 0a | 53 65 6e 64 65 72 3a 20 |:37 GMT.|Sender: |
|00000200| 61 6c 6c 62 65 72 79 40 | 6e 63 6f 61 73 74 2e 55 |allbery@|ncoast.U|
|00000210| 55 43 50 0a 4f 72 67 61 | 6e 69 7a 61 74 69 6f 6e |UCP.Orga|nization|
|00000220| 3a 20 43 6f 6d 70 75 74 | 65 72 20 43 6f 6e 73 6f |: Comput|er Conso|
|00000230| 6c 65 73 20 49 6e 63 2c | 20 52 65 73 74 6f 6e 20 |les Inc,| Reston |
|00000240| 56 41 0a 4c 69 6e 65 73 | 3a 20 37 38 36 0a 41 70 |VA.Lines|: 786.Ap|
|00000250| 70 72 6f 76 65 64 3a 20 | 61 6c 6c 62 65 72 79 40 |proved: |allbery@|
|00000260| 6e 63 6f 61 73 74 2e 55 | 55 43 50 0a 58 2d 41 72 |ncoast.U|UCP.X-Ar|
|00000270| 63 68 69 76 65 3a 20 63 | 6f 6d 70 2e 73 6f 75 72 |chive: c|omp.sour|
|00000280| 63 65 73 2e 6d 69 73 63 | 2f 38 38 30 32 2f 31 38 |ces.misc|/8802/18|
|00000290| 0a 43 6f 6d 70 2e 73 6f | 75 72 63 65 73 2e 6d 69 |.Comp.so|urces.mi|
|000002a0| 73 63 3a 20 56 6f 6c 75 | 6d 65 20 32 2c 20 49 73 |sc: Volu|me 2, Is|
|000002b0| 73 75 65 20 36 30 0a 53 | 75 62 6d 69 74 74 65 64 |sue 60.S|ubmitted|
|000002c0| 2d 42 79 3a 20 22 44 65 | 6e 6e 69 73 2e 42 65 64 |-By: "De|nnis.Bed|
|000002d0| 6e 61 72 22 20 3c 64 65 | 6e 6e 69 73 40 72 6c 67 |nar" <de|nnis@rlg|
|000002e0| 76 61 78 2e 55 55 43 50 | 3e 0a 41 72 63 68 69 76 |vax.UUCP|>.Archiv|
|000002f0| 65 2d 4e 61 6d 65 3a 20 | 64 75 6f 6e 6c 79 0a 0a |e-Name: |duonly..|
|00000300| 43 6f 6d 70 2e 73 6f 75 | 72 63 65 73 2e 6d 69 73 |Comp.sou|rces.mis|
|00000310| 63 3a 20 56 6f 6c 75 6d | 65 20 32 2c 20 49 73 73 |c: Volum|e 2, Iss|
|00000320| 75 65 20 36 30 0a 53 75 | 62 6d 69 74 74 65 64 2d |ue 60.Su|bmitted-|
|00000330| 42 79 3a 20 22 44 65 6e | 6e 69 73 2e 42 65 64 6e |By: "Den|nis.Bedn|
|00000340| 61 72 22 20 3c 64 65 6e | 6e 69 73 40 72 6c 67 76 |ar" <den|nis@rlgv|
|00000350| 61 78 2e 55 55 43 50 3e | 0a 41 72 63 68 69 76 65 |ax.UUCP>|.Archive|
|00000360| 2d 4e 61 6d 65 3a 20 64 | 75 6f 6e 6c 79 0a 0a 53 |-Name: d|uonly..S|
|00000370| 48 4f 52 54 20 62 6c 75 | 72 62 20 66 72 6f 6d 20 |HORT blu|rb from |
|00000380| 74 68 65 20 64 75 6f 6e | 6c 79 2e 68 65 6c 70 20 |the duon|ly.help |
|00000390| 66 69 6c 65 2c 20 6a 75 | 73 74 20 74 6f 20 73 75 |file, ju|st to su|
|000003a0| 6d 6d 61 72 69 7a 65 20 | 77 68 61 74 0a 74 68 69 |mmarize |what.thi|
|000003b0| 73 20 69 73 20 70 72 6f | 67 72 61 6d 20 69 73 20 |s is pro|gram is |
|000003c0| 66 6f 72 3a 0a 0a 50 72 | 69 6e 74 73 20 64 69 73 |for:..Pr|ints dis|
|000003d0| 6b 20 75 73 61 67 65 20 | 62 6c 6f 63 6b 20 73 69 |k usage |block si|
|000003e0| 7a 65 73 20 6f 6e 6c 79 | 20 66 6f 72 20 64 69 72 |zes only| for dir|
|000003f0| 65 63 74 6f 72 69 65 73 | 2c 0a 62 75 74 20 4e 4f |ectories|,.but NO|
|00000400| 54 20 69 6e 63 6c 75 64 | 69 6e 67 20 73 69 7a 65 |T includ|ing size|
|00000410| 73 20 63 6f 6e 74 72 69 | 62 75 74 65 64 20 62 79 |s contri|buted by|
|00000420| 20 73 75 62 2d 64 69 72 | 65 63 74 6f 72 69 65 73 | sub-dir|ectories|
|00000430| 2e 0a 0a 54 68 69 73 20 | 74 6f 6f 6c 20 77 61 73 |...This |tool was|
|00000440| 20 64 65 76 65 6c 6f 70 | 65 64 20 62 65 63 61 75 | develop|ed becau|
|00000450| 73 65 20 77 68 65 6e 20 | 76 69 65 77 69 6e 67 20 |se when |viewing |
|00000460| 74 68 65 20 6f 75 74 70 | 75 74 20 6f 66 20 61 0a |the outp|ut of a.|
|00000470| 72 65 67 75 6c 61 72 20 | 64 75 2c 20 69 74 20 77 |regular |du, it w|
|00000480| 61 73 20 64 69 66 66 69 | 63 75 6c 74 20 74 6f 20 |as diffi|cult to |
|00000490| 73 65 65 20 77 68 69 63 | 68 20 64 69 72 65 63 74 |see whic|h direct|
|000004a0| 6f 72 69 65 73 20 77 65 | 72 65 0a 74 68 65 20 72 |ories we|re.the r|
|000004b0| 65 61 6c 20 63 75 6c 70 | 72 69 74 73 20 66 6f 72 |eal culp|rits for|
|000004c0| 20 6f 63 63 75 70 79 69 | 6e 67 20 74 68 65 20 6d | occupyi|ng the m|
|000004d0| 6f 73 74 20 6e 75 6d 62 | 65 72 20 6f 66 20 64 69 |ost numb|er of di|
|000004e0| 73 6b 20 62 6c 6f 63 6b | 73 2e 0a 0a 23 2d 2d 2d |sk block|s...#---|
|000004f0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 20 43 55 54 |--------|---- CUT|
|00000500| 20 48 45 52 45 20 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d | HERE --|--------|
|00000510| 2d 2d 2d 2d 2d 0a 23 21 | 20 2f 62 69 6e 2f 73 68 |-----.#!| /bin/sh|
|00000520| 0a 23 20 54 68 69 73 20 | 69 73 20 61 20 73 68 65 |.# This |is a she|
|00000530| 6c 6c 20 61 72 63 68 69 | 76 65 2c 20 6d 65 61 6e |ll archi|ve, mean|
|00000540| 69 6e 67 3a 0a 23 20 31 | 2e 20 52 65 6d 6f 76 65 |ing:.# 1|. Remove|
|00000550| 20 65 76 65 72 79 74 68 | 69 6e 67 20 61 62 6f 76 | everyth|ing abov|
|00000560| 65 20 74 68 65 20 23 21 | 20 2f 62 69 6e 2f 73 68 |e the #!| /bin/sh|
|00000570| 20 6c 69 6e 65 2e 0a 23 | 20 32 2e 20 53 61 76 65 | line..#| 2. Save|
|00000580| 20 74 68 65 20 72 65 73 | 75 6c 74 69 6e 67 20 74 | the res|ulting t|
|00000590| 65 78 74 20 69 6e 20 61 | 20 66 69 6c 65 2e 0a 23 |ext in a| file..#|
|000005a0| 20 33 2e 20 45 78 65 63 | 75 74 65 20 74 68 65 20 | 3. Exec|ute the |
|000005b0| 66 69 6c 65 20 77 69 74 | 68 20 2f 62 69 6e 2f 73 |file wit|h /bin/s|
|000005c0| 68 20 28 6e 6f 74 20 63 | 73 68 29 20 74 6f 20 63 |h (not c|sh) to c|
|000005d0| 72 65 61 74 65 20 74 68 | 65 20 66 69 6c 65 73 3a |reate th|e files:|
|000005e0| 0a 23 09 64 75 6f 6e 6c | 79 2e 63 0a 23 09 64 75 |.#.duonl|y.c.#.du|
|000005f0| 6f 6e 6c 79 2e 68 65 6c | 70 0a 23 20 54 68 69 73 |only.hel|p.# This|
|00000600| 20 61 72 63 68 69 76 65 | 20 63 72 65 61 74 65 64 | archive| created|
|00000610| 3a 20 57 65 64 20 46 65 | 62 20 31 37 20 32 30 3a |: Wed Fe|b 17 20:|
|00000620| 33 31 3a 30 34 20 45 53 | 54 20 31 39 38 38 0a 23 |31:04 ES|T 1988.#|
|00000630| 0a 69 66 20 74 65 73 74 | 20 2d 66 20 64 75 6f 6e |.if test| -f duon|
|00000640| 6c 79 2e 63 0a 74 68 65 | 6e 0a 65 63 68 6f 20 73 |ly.c.the|n.echo s|
|00000650| 68 61 72 3a 20 77 69 6c | 6c 20 6e 6f 74 20 6f 76 |har: wil|l not ov|
|00000660| 65 72 2d 77 72 69 74 65 | 20 65 78 69 73 74 69 6e |er-write| existin|
|00000670| 67 20 66 69 6c 65 20 27 | 64 75 6f 6e 6c 79 2e 63 |g file '|duonly.c|
|00000680| 27 0a 65 6c 73 65 0a 65 | 63 68 6f 20 78 20 2d 20 |'.else.e|cho x - |
|00000690| 64 75 6f 6e 6c 79 2e 63 | 0a 23 20 2e 2e 2e 2e 2e |duonly.c|.# .....|
|000006a0| 2e 2e 2e 2e 2e 2e 2e 20 | 20 20 20 46 20 20 49 20 |....... | F I |
|000006b0| 20 20 4c 20 20 20 45 20 | 20 20 20 20 20 42 20 20 | L E | B |
|000006c0| 45 20 20 47 20 20 2e 2e | 2e 2e 2e 2e 2e 2e 2e 2e |E G ..|........|
|000006d0| 20 64 75 6f 6e 6c 79 2e | 63 0a 63 61 74 20 3c 3c | duonly.|c.cat <<|
|000006e0| 20 27 5c 53 48 41 52 5f | 45 4f 46 27 20 3e 20 64 | '\SHAR_|EOF' > d|
|000006f0| 75 6f 6e 6c 79 2e 63 0a | 2f 2a 0a 20 2a 20 64 75 |uonly.c.|/*. * du|
|00000700| 6f 6e 6c 79 2e 63 0a 20 | 2a 20 64 65 6e 6e 69 73 |only.c. |* dennis|
|00000710| 20 62 65 64 6e 61 72 20 | 46 65 62 20 31 37 2c 20 | bednar |Feb 17, |
|00000720| 31 39 38 38 0a 20 2a 0a | 20 2a 20 52 65 61 64 73 |1988. *.| * Reads|
|00000730| 20 73 74 64 69 6e 20 6f | 66 20 64 75 20 6f 75 74 | stdin o|f du out|
|00000740| 70 75 74 2c 20 61 6e 64 | 20 6f 75 74 70 75 74 73 |put, and| outputs|
|00000750| 20 73 69 7a 65 73 20 62 | 61 73 65 64 20 4f 4e 4c | sizes b|ased ONL|
|00000760| 59 20 6f 6e 20 74 68 65 | 0a 20 2a 20 73 70 61 63 |Y on the|. * spac|
|00000770| 65 20 75 73 65 64 20 77 | 69 74 68 69 6e 20 61 20 |e used w|ithin a |
|00000780| 64 69 72 65 63 74 6f 72 | 79 20 6f 6e 6c 79 2e 20 |director|y only. |
|00000790| 20 54 68 65 20 73 69 7a | 65 20 77 69 6c 6c 20 62 | The siz|e will b|
|000007a0| 65 20 74 68 65 0a 20 2a | 20 6e 75 6d 62 65 72 20 |e the. *| number |
|000007b0| 6f 66 20 62 6c 6f 63 6b | 73 20 75 73 65 64 20 62 |of block|s used b|
|000007c0| 79 20 74 68 65 20 64 69 | 72 65 63 74 6f 72 79 20 |y the di|rectory |
|000007d0| 69 74 73 65 6c 66 2c 20 | 70 6c 75 73 20 61 6e 79 |itself, |plus any|
|000007e0| 0a 20 2a 20 66 69 6c 65 | 73 20 63 6f 6e 74 61 69 |. * file|s contai|
|000007f0| 6e 65 64 20 77 69 74 68 | 69 6e 20 74 68 61 74 20 |ned with|in that |
|00000800| 64 69 72 65 63 74 6f 72 | 79 2e 0a 20 2a 0a 20 2a |director|y.. *. *|
|00000810| 20 4e 4f 54 45 3a 0a 20 | 2a 20 4d 75 63 68 20 6f | NOTE:. |* Much o|
|00000820| 66 20 74 68 65 20 73 6f | 75 72 63 65 20 63 6f 64 |f the so|urce cod|
|00000830| 65 20 69 6e 20 64 75 67 | 72 61 70 68 2e 63 20 28 |e in dug|raph.c (|
|00000840| 63 6f 6e 74 72 69 62 75 | 74 65 64 20 74 6f 20 63 |contribu|ted to c|
|00000850| 6f 6d 70 2e 75 6e 69 78 | 2e 6d 69 73 63 29 0a 20 |omp.unix|.misc). |
|00000860| 2a 20 49 20 62 6f 72 72 | 6f 77 65 64 20 22 61 73 |* I borr|owed "as|
|00000870| 20 69 73 22 2e 20 20 57 | 68 61 74 20 66 75 6e 63 | is". W|hat func|
|00000880| 74 69 6f 6e 73 20 49 20 | 61 64 64 65 64 20 61 72 |tions I |added ar|
|00000890| 65 20 61 74 20 74 68 65 | 20 65 6e 64 2e 0a 20 2a |e at the| end.. *|
|000008a0| 20 49 20 61 6c 73 6f 20 | 61 64 64 65 64 20 74 68 | I also |added th|
|000008b0| 65 20 22 66 61 74 68 65 | 72 22 20 6c 69 6e 6b 2e |e "fathe|r" link.|
|000008c0| 20 20 41 6c 6c 20 6f 66 | 20 74 68 65 20 62 72 6f | All of| the bro|
|000008d0| 74 68 65 72 73 20 6f 66 | 20 74 68 65 0a 20 2a 20 |thers of| the. * |
|000008e0| 66 69 72 73 74 20 73 6f | 6e 2c 20 69 6e 63 6c 75 |first so|n, inclu|
|000008f0| 64 69 6e 67 20 74 68 65 | 20 66 69 72 73 74 20 73 |ding the| first s|
|00000900| 6f 6e 2c 20 68 61 76 65 | 20 74 68 65 20 73 61 6d |on, have| the sam|
|00000910| 65 20 66 61 74 68 65 72 | 20 6e 6f 64 65 2e 0a 20 |e father| node.. |
|00000920| 2a 20 54 68 61 74 20 69 | 73 2c 20 69 66 20 77 65 |* That i|s, if we|
|00000930| 20 68 61 76 65 20 2f 61 | 2f 62 2c 20 61 6e 64 20 | have /a|/b, and |
|00000940| 2f 61 2f 63 2c 20 74 68 | 65 6e 20 22 62 22 20 61 |/a/c, th|en "b" a|
|00000950| 6e 64 20 22 63 22 20 61 | 72 65 20 62 72 6f 74 68 |nd "c" a|re broth|
|00000960| 65 72 73 2c 0a 20 2a 20 | 61 6e 64 20 22 62 22 27 |ers,. * |and "b"'|
|00000970| 73 20 61 6e 64 20 22 63 | 22 27 73 20 66 61 74 68 |s and "c|"'s fath|
|00000980| 65 72 20 61 72 65 20 62 | 6f 74 68 20 22 61 22 2e |er are b|oth "a".|
|00000990| 20 20 49 20 61 6c 73 6f | 20 61 64 64 65 64 20 61 | I also| added a|
|000009a0| 20 6e 65 77 0a 20 2a 20 | 76 61 72 69 61 62 6c 65 | new. * |variable|
|000009b0| 20 22 6d 65 5f 73 69 7a | 65 22 20 77 68 69 63 68 | "me_siz|e" which|
|000009c0| 20 69 73 20 74 68 65 20 | 73 69 7a 65 20 6f 66 20 | is the |size of |
|000009d0| 74 68 65 20 64 69 72 65 | 63 74 6f 72 79 2c 20 6e |the dire|ctory, n|
|000009e0| 6f 74 20 69 6e 63 6c 75 | 64 69 6e 67 0a 20 2a 20 |ot inclu|ding. * |
|000009f0| 74 68 65 20 73 69 7a 65 | 73 20 6f 66 20 74 68 65 |the size|s of the|
|00000a00| 20 73 6f 6e 73 20 69 6d | 6d 65 64 69 61 74 65 6c | sons im|mediatel|
|00000a10| 79 20 62 65 6c 6f 77 20 | 69 74 2e 0a 20 2a 0a 20 |y below |it.. *. |
|00000a20| 2a 20 4e 4f 54 45 3a 20 | 49 66 20 79 6f 75 20 64 |* NOTE: |If you d|
|00000a30| 6f 20 22 64 75 20 2f 64 | 69 72 31 2f 64 69 72 32 |o "du /d|ir1/dir2|
|00000a40| 2f 64 69 72 33 7c 20 64 | 75 6f 6e 6c 79 22 2c 20 |/dir3| d|uonly", |
|00000a50| 74 68 65 6e 20 74 68 65 | 20 73 69 7a 65 20 6f 66 |then the| size of|
|00000a60| 0a 20 2a 20 2f 64 69 72 | 31 2c 20 61 6e 64 20 2f |. * /dir|1, and /|
|00000a70| 64 69 72 32 20 77 69 6c | 6c 20 62 65 20 30 2c 20 |dir2 wil|l be 0, |
|00000a80| 73 69 6e 63 65 20 74 68 | 65 79 20 77 65 72 65 20 |since th|ey were |
|00000a90| 4e 4f 54 20 69 6e 63 6c | 75 64 65 64 20 69 6e 0a |NOT incl|uded in.|
|00000aa0| 20 2a 20 74 68 65 20 6f | 72 69 67 69 6e 61 6c 20 | * the o|riginal |
|00000ab0| 6f 75 74 70 75 74 20 6f | 66 20 64 75 21 21 21 0a |output o|f du!!!.|
|00000ac0| 20 2a 0a 20 2a 20 4e 4f | 54 45 3a 20 69 66 20 79 | *. * NO|TE: if y|
|00000ad0| 6f 75 20 64 6f 20 22 64 | 75 20 2f 64 69 72 31 2f |ou do "d|u /dir1/|
|00000ae0| 64 69 72 32 2f 64 69 72 | 33 7c 20 64 75 6f 6e 6c |dir2/dir|3| duonl|
|00000af0| 79 22 2c 20 74 68 65 6e | 20 74 68 65 20 72 6f 6f |y", then| the roo|
|00000b00| 74 0a 20 2a 20 70 6c 61 | 63 65 68 6f 6c 64 65 72 |t. * pla|ceholder|
|00000b10| 20 70 6f 69 6e 74 73 20 | 74 6f 20 61 20 63 65 6c | points |to a cel|
|00000b20| 6c 20 66 6f 72 20 22 22 | 2c 20 61 6e 64 20 4e 4f |l for ""|, and NO|
|00000b30| 54 20 74 6f 20 22 64 69 | 72 31 22 20 61 73 0a 20 |T to "di|r1" as. |
|00000b40| 2a 20 79 6f 75 20 6d 69 | 67 68 74 20 65 78 70 65 |* you mi|ght expe|
|00000b50| 63 74 2e 20 20 54 68 69 | 73 20 69 73 20 62 65 63 |ct. Thi|s is bec|
|00000b60| 61 75 73 65 20 6f 66 20 | 68 6f 77 20 72 65 61 64 |ause of |how read|
|00000b70| 5f 69 6e 70 75 74 28 29 | 20 70 61 72 73 65 73 0a |_input()| parses.|
|00000b80| 20 2a 20 69 74 73 20 69 | 6e 70 75 74 2e 20 20 49 | * its i|nput. I|
|00000b90| 74 20 69 73 20 6e 6f 74 | 20 61 20 70 72 6f 62 6c |t is not| a probl|
|00000ba0| 65 6d 20 70 65 72 20 73 | 65 2c 20 65 78 63 65 70 |em per s|e, excep|
|00000bb0| 74 20 74 68 61 74 20 74 | 68 65 20 6e 6f 64 65 0a |t that t|he node.|
|00000bc0| 20 2a 20 63 6f 6e 74 61 | 69 6e 69 6e 67 20 61 20 | * conta|ining a |
|00000bd0| 62 6c 61 6e 6b 20 6e 61 | 6d 65 20 73 68 6f 75 6c |blank na|me shoul|
|00000be0| 64 20 6e 6f 74 20 62 65 | 20 70 72 69 6e 74 65 64 |d not be| printed|
|00000bf0| 20 69 6e 20 74 68 69 73 | 20 63 61 73 65 2e 0a 20 | in this| case.. |
|00000c00| 2a 20 53 6f 2c 20 74 68 | 65 20 73 6f 6c 75 74 69 |* So, th|e soluti|
|00000c10| 6f 6e 20 69 73 20 74 6f | 20 61 64 64 20 61 6e 20 |on is to| add an |
|00000c20| 65 78 74 72 61 20 63 68 | 65 63 6b 20 61 6e 64 20 |extra ch|eck and |
|00000c30| 61 76 6f 69 64 20 74 68 | 65 20 70 72 69 6e 74 0a |avoid th|e print.|
|00000c40| 20 2a 20 77 68 65 6e 20 | 74 68 65 20 6e 61 6d 65 | * when |the name|
|00000c50| 20 69 73 20 22 22 2e 20 | 20 42 79 20 74 68 65 20 | is "". | By the |
|00000c60| 77 61 79 20 74 68 65 20 | 72 6f 6f 74 20 66 6f 72 |way the |root for|
|00000c70| 20 22 22 20 6f 6e 6c 79 | 20 6f 63 63 75 72 73 0a | "" only| occurs.|
|00000c80| 20 2a 20 62 65 63 61 75 | 73 65 20 74 68 65 20 70 | * becau|se the p|
|00000c90| 61 74 68 6e 61 6d 65 73 | 20 61 72 65 20 61 62 73 |athnames| are abs|
|00000ca0| 6f 6c 75 74 65 20 28 62 | 65 67 69 6e 20 77 69 74 |olute (b|egin wit|
|00000cb0| 68 20 61 20 2f 29 2e 0a | 20 2a 0a 20 2a 20 4e 4f |h a /)..| *. * NO|
|00000cc0| 54 45 3a 20 61 6c 74 68 | 6f 75 67 68 20 6f 75 74 |TE: alth|ough out|
|00000cd0| 70 75 74 20 6f 66 20 64 | 69 72 65 63 74 6f 72 79 |put of d|irectory|
|00000ce0| 20 6e 61 6d 65 73 20 61 | 72 65 20 73 6f 72 74 65 | names a|re sorte|
|00000cf0| 64 20 74 68 65 72 65 20 | 69 73 0a 20 2a 20 6f 6e |d there |is. * on|
|00000d00| 65 20 6d 69 6e 6f 72 20 | 61 6e 6f 6d 6f 6c 79 20 |e minor |anomoly |
|00000d10| 74 68 61 74 20 6f 63 63 | 75 72 73 20 77 68 65 6e |that occ|urs when|
|00000d20| 20 79 6f 75 20 68 61 76 | 65 20 69 6e 70 75 74 20 | you hav|e input |
|00000d30| 61 73 20 66 6f 6c 6c 6f | 77 73 0a 20 2a 20 28 73 |as follo|ws. * (s|
|00000d40| 69 7a 65 73 20 6f 6d 6d | 69 74 65 64 2c 20 73 69 |izes omm|ited, si|
|00000d50| 6e 63 65 20 69 72 72 65 | 6c 65 76 61 6e 74 29 3a |nce irre|levant):|
|00000d60| 0a 20 2a 20 2e 2e 2f 64 | 69 72 0a 20 2a 20 2e 2e |. * ../d|ir. * ..|
|00000d70| 2e 64 69 72 2f 52 43 53 | 0a 20 2a 20 2e 2e 2e 64 |.dir/RCS|. * ...d|
|00000d80| 69 72 2e 65 78 74 0a 20 | 2a 20 54 68 65 20 69 6d |ir.ext. |* The im|
|00000d90| 70 6f 72 74 61 6e 74 20 | 70 6f 69 6e 74 20 69 73 |portant |point is|
|00000da0| 20 74 68 61 74 20 77 65 | 20 68 61 76 65 20 62 6f | that we| have bo|
|00000db0| 74 68 20 61 20 22 2f 22 | 20 61 6e 64 20 61 20 22 |th a "/"| and a "|
|00000dc0| 2e 22 20 61 66 74 65 72 | 20 74 68 65 0a 20 2a 20 |." after| the. * |
|00000dd0| 73 61 6d 65 20 6e 61 6d | 65 20 22 64 69 72 22 2e |same nam|e "dir".|
|00000de0| 0a 20 2a 20 41 20 73 6f | 72 74 20 77 6f 75 6c 64 |. * A so|rt would|
|00000df0| 20 70 6c 61 63 65 20 74 | 68 65 20 22 2e 22 20 62 | place t|he "." b|
|00000e00| 65 66 6f 72 65 20 74 68 | 65 20 22 2f 22 20 28 69 |efore th|e "/" (i|
|00000e10| 65 20 6c 69 6e 65 20 33 | 20 62 65 66 6f 72 65 20 |e line 3| before |
|00000e20| 6c 69 6e 65 20 32 29 2c | 0a 20 2a 20 62 75 74 20 |line 2),|. * but |
|00000e30| 74 68 65 20 73 6f 72 74 | 20 70 65 72 66 6f 72 6d |the sort| perform|
|00000e40| 65 64 20 62 79 20 64 75 | 20 69 73 20 6f 6e 6c 79 |ed by du| is only|
|00000e50| 20 77 69 74 68 69 6e 20 | 65 61 63 68 20 64 69 72 | within |each dir|
|00000e60| 65 63 74 6f 72 79 20 6c | 65 76 65 6c 2c 20 73 6f |ectory l|evel, so|
|00000e70| 0a 20 2a 20 74 68 61 74 | 20 64 75 6f 6e 6c 79 20 |. * that| duonly |
|00000e80| 77 6f 75 6c 64 20 6f 75 | 74 70 75 74 20 6c 69 6e |would ou|tput lin|
|00000e90| 65 20 32 20 62 65 66 6f | 72 65 20 6c 69 6e 65 20 |e 2 befo|re line |
|00000ea0| 33 20 28 73 69 6e 63 65 | 20 2e 2e 2f 64 69 72 20 |3 (since| ../dir |
|00000eb0| 61 6e 64 0a 20 2a 20 2e | 2e 2f 64 69 72 2e 65 78 |and. * .|./dir.ex|
|00000ec0| 74 20 61 72 65 20 73 6f | 72 74 65 64 20 62 72 6f |t are so|rted bro|
|00000ed0| 74 68 65 72 73 2c 20 61 | 6e 64 20 2e 2e 2f 64 69 |thers, a|nd ../di|
|00000ee0| 72 2f 52 43 53 20 69 73 | 20 61 20 73 6f 72 74 65 |r/RCS is| a sorte|
|00000ef0| 64 20 73 6f 6e 20 6f 66 | 0a 20 2a 20 2e 2e 2f 64 |d son of|. * ../d|
|00000f00| 69 72 29 20 21 21 0a 20 | 2a 0a 20 2a 2f 0a 23 69 |ir) !!. |*. */.#i|
|00000f10| 66 20 30 0a 50 61 74 68 | 3a 20 72 6c 67 76 61 78 |f 0.Path|: rlgvax|
|00000f20| 21 73 75 6e 64 63 21 73 | 65 69 73 6d 6f 21 75 75 |!sundc!s|eismo!uu|
|00000f30| 6e 65 74 21 68 75 73 63 | 36 21 74 68 69 6e 6b 21 |net!husc|6!think!|
|00000f40| 61 6d 65 73 21 6e 65 63 | 6e 74 63 21 6e 63 6f 61 |ames!nec|ntc!ncoa|
|00000f50| 73 74 21 61 6c 6c 62 65 | 72 79 0a 46 72 6f 6d 3a |st!allbe|ry.From:|
|00000f60| 20 64 72 77 40 63 75 6c | 64 65 76 31 2e 55 55 43 | drw@cul|dev1.UUC|
|00000f70| 50 20 28 44 61 6c 65 20 | 57 6f 72 6c 65 79 29 0a |P (Dale |Worley).|
|00000f80| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000f90| 2e 73 6f 75 72 63 65 73 | 2e 6d 69 73 63 0a 53 75 |.sources|.misc.Su|
|00000fa0| 62 6a 65 63 74 3a 20 50 | 72 65 74 74 79 70 72 69 |bject: P|rettypri|
|00000fb0| 6e 74 20 61 20 64 75 20 | 6c 69 73 74 69 6e 67 0a |nt a du |listing.|
|00000fc0| 4d 65 73 73 61 67 65 2d | 49 44 3a 20 3c 36 38 30 |Message-|ID: <680|
|00000fd0| 33 40 6e 63 6f 61 73 74 | 2e 55 55 43 50 3e 0a 44 |3@ncoast|.UUCP>.D|
|00000fe0| 61 74 65 3a 20 31 37 20 | 44 65 63 20 38 37 20 30 |ate: 17 |Dec 87 0|
|00000ff0| 32 3a 33 33 3a 35 34 20 | 47 4d 54 0a 53 65 6e 64 |2:33:54 |GMT.Send|
|00001000| 65 72 3a 20 61 6c 6c 62 | 65 72 79 40 6e 63 6f 61 |er: allb|ery@ncoa|
|00001010| 73 74 2e 55 55 43 50 0a | 4f 72 67 61 6e 69 7a 61 |st.UUCP.|Organiza|
|00001020| 74 69 6f 6e 3a 20 43 75 | 6c 6c 69 6e 65 74 20 53 |tion: Cu|llinet S|
|00001030| 6f 66 74 77 61 72 65 2c | 20 57 65 73 74 77 6f 6f |oftware,| Westwoo|
|00001040| 64 2c 20 4d 41 2c 20 55 | 53 41 0a 4c 69 6e 65 73 |d, MA, U|SA.Lines|
|00001050| 3a 20 34 34 37 0a 41 70 | 70 72 6f 76 65 64 3a 20 |: 447.Ap|proved: |
|00001060| 61 6c 6c 62 65 72 79 40 | 6e 63 6f 61 73 74 2e 55 |allbery@|ncoast.U|
|00001070| 55 43 50 0a 58 2d 41 72 | 63 68 69 76 65 3a 20 63 |UCP.X-Ar|chive: c|
|00001080| 6f 6d 70 2e 73 6f 75 72 | 63 65 73 2e 6d 69 73 63 |omp.sour|ces.misc|
|00001090| 2f 38 37 31 32 2f 38 0a | 0a 49 27 76 65 20 61 6c |/8712/8.|.I've al|
|000010a0| 77 61 79 73 20 77 61 6e | 74 65 64 20 74 6f 20 67 |ways wan|ted to g|
|000010b0| 65 74 20 61 20 64 75 20 | 6c 69 73 74 69 6e 67 20 |et a du |listing |
|000010c0| 74 68 61 74 20 73 68 6f | 77 73 20 68 6f 77 20 74 |that sho|ws how t|
|000010d0| 68 65 20 73 70 61 63 65 | 20 69 73 0a 62 65 69 6e |he space| is.bein|
|000010e0| 67 20 75 73 65 64 20 67 | 72 61 70 68 69 63 61 6c |g used g|raphical|
|000010f0| 6c 79 2e 20 20 49 20 66 | 69 6e 61 6c 6c 79 20 77 |ly. I f|inally w|
|00001100| 72 6f 74 65 20 61 20 70 | 72 6f 67 72 61 6d 20 74 |rote a p|rogram t|
|00001110| 6f 20 64 69 67 65 73 74 | 20 61 20 64 75 0a 6c 69 |o digest| a du.li|
|00001120| 73 74 69 6e 67 20 61 6e | 64 20 70 72 69 6e 74 20 |sting an|d print |
|00001130| 6f 75 74 20 61 20 74 72 | 65 65 2c 20 77 68 65 72 |out a tr|ee, wher|
|00001140| 65 20 65 61 63 68 20 64 | 69 72 65 63 74 6f 72 79 |e each d|irectory|
|00001150| 20 6f 63 63 75 70 69 65 | 73 20 6c 69 6e 65 73 0a | occupie|s lines.|
|00001160| 70 72 6f 70 6f 72 74 69 | 6f 6e 61 6c 6c 79 20 74 |proporti|onally t|
|00001170| 6f 20 68 6f 77 20 6d 75 | 63 68 20 73 70 61 63 65 |o how mu|ch space|
|00001180| 20 74 68 65 20 66 69 6c | 65 73 20 69 6e 20 69 74 | the fil|es in it|
|00001190| 20 63 6f 6e 73 75 6d 65 | 2e 0a 0a 54 6f 20 72 75 | consume|...To ru|
|000011a0| 6e 20 69 74 2c 20 74 79 | 70 65 20 22 64 75 20 7c |n it, ty|pe "du ||
|000011b0| 20 64 75 67 72 61 70 68 | 22 20 6f 72 20 73 6f 6d | dugraph|" or som|
|000011c0| 65 20 73 75 63 68 2e 20 | 20 54 68 65 20 6c 69 73 |e such. | The lis|
|000011d0| 74 69 6e 67 20 66 6f 72 | 20 65 61 63 68 0a 64 69 |ting for| each.di|
|000011e0| 72 65 63 74 6f 72 79 20 | 73 74 61 72 74 73 20 77 |rectory |starts w|
|000011f0| 69 74 68 20 61 20 62 6c | 61 6e 6b 20 73 70 61 63 |ith a bl|ank spac|
|00001200| 65 20 73 68 6f 77 69 6e | 67 20 73 70 61 63 65 20 |e showin|g space |
|00001210| 6f 63 63 75 70 69 65 64 | 20 62 79 20 66 69 6c 65 |occupied| by file|
|00001220| 73 0a 64 69 72 65 63 74 | 6c 79 20 69 6e 20 74 68 |s.direct|ly in th|
|00001230| 61 74 20 64 69 72 65 63 | 74 6f 72 79 2c 20 74 68 |at direc|tory, th|
|00001240| 65 6e 20 74 68 65 20 73 | 75 62 74 72 65 65 73 20 |en the s|ubtrees |
|00001250| 66 6f 72 20 65 61 63 68 | 20 73 75 62 64 69 72 65 |for each| subdire|
|00001260| 63 74 6f 72 79 0a 28 69 | 6e 20 64 65 73 63 65 6e |ctory.(i|n descen|
|00001270| 64 69 6e 67 20 6f 72 64 | 65 72 20 6f 66 20 73 69 |ding ord|er of si|
|00001280| 7a 65 29 2e 20 20 49 66 | 20 74 68 65 20 73 75 62 |ze). If| the sub|
|00001290| 64 69 72 65 63 74 6f 72 | 69 65 73 20 61 74 20 74 |director|ies at t|
|000012a0| 68 65 20 62 6f 74 74 6f | 6d 0a 67 65 74 20 73 6f |he botto|m.get so|
|000012b0| 20 73 6d 61 6c 6c 20 74 | 68 61 74 20 74 68 65 79 | small t|hat they|
|000012c0| 20 6f 63 63 75 70 79 20 | 6c 65 73 73 20 74 68 61 | occupy |less tha|
|000012d0| 6e 20 31 20 6c 69 6e 65 | 20 65 61 63 68 2c 20 74 |n 1 line| each, t|
|000012e0| 68 65 79 20 61 72 65 20 | 61 6c 6c 0a 6d 65 72 67 |hey are |all.merg|
|000012f0| 65 64 20 69 6e 74 6f 20 | 61 6e 20 65 6e 74 72 79 |ed into |an entry|
|00001300| 20 22 28 65 74 63 2e 29 | 22 2e 0a 0a 54 68 65 20 | "(etc.)|"...The |
|00001310| 65 6e 74 69 72 65 20 6c | 69 73 74 69 6e 67 20 61 |entire l|isting a|
|00001320| 6c 77 61 79 73 20 6f 63 | 63 75 70 69 65 73 20 36 |lways oc|cupies 6|
|00001330| 30 20 6c 69 6e 65 73 20 | 28 74 68 65 20 76 61 6c |0 lines |(the val|
|00001340| 75 65 20 6f 66 20 27 6c | 65 6e 67 74 68 27 29 2e |ue of 'l|ength').|
|00001350| 0a 54 68 69 73 20 70 72 | 6f 67 72 61 6d 20 68 61 |.This pr|ogram ha|
|00001360| 73 20 74 61 62 2d 77 69 | 64 74 68 20 3d 20 35 2e |s tab-wi|dth = 5.|
|00001370| 0a 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |.-------|--------|
|00001380| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 64 75 67 72 61 |--------|---dugra|
|00001390| 70 68 2e 63 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |ph.c----|--------|
|000013a0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|000013b0| 2d 2d 2d 2d 2d 0a 23 65 | 6e 64 69 66 0a 2f 2a 20 |-----.#e|ndif./* |
|000013c0| 70 72 6f 67 72 61 6d 20 | 74 6f 20 6d 61 6b 65 20 |program |to make |
|000013d0| 61 20 70 72 65 74 74 79 | 20 67 72 61 70 68 20 6f |a pretty| graph o|
|000013e0| 75 74 20 6f 66 20 61 20 | 64 75 20 72 65 70 6f 72 |ut of a |du repor|
|000013f0| 74 20 2a 2f 0a 0a 23 69 | 6e 63 6c 75 64 65 20 3c |t */..#i|nclude <|
|00001400| 73 74 64 69 6f 2e 68 3e | 0a 23 69 6e 63 6c 75 64 |stdio.h>|.#includ|
|00001410| 65 20 3c 73 74 72 69 6e | 67 2e 68 3e 0a 0a 2f 2a |e <strin|g.h>../*|
|00001420| 20 6e 75 6d 62 65 72 20 | 6f 66 20 6c 69 6e 65 73 | number |of lines|
|00001430| 20 74 68 65 20 6c 69 73 | 74 69 6e 67 20 73 68 6f | the lis|ting sho|
|00001440| 75 6c 64 20 6f 63 63 75 | 70 79 20 2a 2f 0a 69 6e |uld occu|py */.in|
|00001450| 74 09 6c 65 6e 67 74 68 | 20 3d 20 36 30 3b 0a 2f |t.length| = 60;./|
|00001460| 2a 20 6d 65 73 73 61 67 | 65 20 66 6f 72 20 73 75 |* messag|e for su|
|00001470| 70 70 72 65 73 73 65 64 | 20 64 69 72 65 63 74 6f |ppressed| directo|
|00001480| 72 69 65 73 20 2a 2f 0a | 23 64 65 66 69 6e 65 09 |ries */.|#define.|
|00001490| 53 55 50 50 52 45 53 53 | 45 44 09 22 28 65 74 63 |SUPPRESS|ED."(etc|
|000014a0| 2e 29 22 0a 0a 2f 2a 20 | 66 6f 72 6d 61 74 20 6f |.)"../* |format o|
|000014b0| 66 20 61 20 74 72 65 65 | 20 6e 6f 64 65 20 2a 2f |f a tree| node */|
|000014c0| 0a 73 74 72 75 63 74 20 | 6e 6f 64 65 20 7b 0a 09 |.struct |node {..|
|000014d0| 09 09 73 74 72 75 63 74 | 20 6e 6f 64 65 09 2a 6c |..struct| node.*l|
|000014e0| 73 6f 6e 3b 09 2f 2a 20 | 6c 65 66 74 20 73 6f 6e |son;./* |left son|
|000014f0| 20 2a 2f 0a 09 09 09 73 | 74 72 75 63 74 20 6e 6f | */....s|truct no|
|00001500| 64 65 09 2a 72 62 72 6f | 74 68 65 72 3b 2f 2a 20 |de.*rbro|ther;/* |
|00001510| 72 69 67 68 74 20 62 72 | 6f 74 68 65 72 20 2a 2f |right br|other */|
|00001520| 0a 09 09 09 73 74 72 75 | 63 74 20 6e 6f 64 65 09 |....stru|ct node.|
|00001530| 2a 66 61 74 68 65 72 3b | 20 2f 2a 20 70 61 72 65 |*father;| /* pare|
|00001540| 6e 74 20 6e 6f 64 65 2c | 20 75 70 20 70 74 72 20 |nt node,| up ptr |
|00001550| 2a 2f 0a 09 09 09 75 6e | 73 69 67 6e 65 64 20 6c |*/....un|signed l|
|00001560| 6f 6e 67 09 73 69 7a 65 | 3b 09 2f 2a 20 73 69 7a |ong.size|;./* siz|
|00001570| 65 20 6f 66 20 64 69 72 | 65 63 74 6f 72 79 20 69 |e of dir|ectory i|
|00001580| 6e 20 6b 62 79 74 65 73 | 20 2a 2f 0a 09 09 09 75 |n kbytes| */....u|
|00001590| 6e 73 69 67 6e 65 64 20 | 6c 6f 6e 67 09 6d 65 5f |nsigned |long.me_|
|000015a0| 73 69 7a 65 3b 09 2f 2a | 20 73 69 7a 65 20 6f 66 |size;./*| size of|
|000015b0| 20 64 69 72 65 63 74 6f | 72 79 20 6f 6e 6c 79 20 | directo|ry only |
|000015c0| 2a 2f 0a 09 09 09 69 6e | 74 09 09 09 6c 6f 63 3b |*/....in|t...loc;|
|000015d0| 09 09 2f 2a 20 6c 6f 63 | 61 74 69 6f 6e 20 77 65 |../* loc|ation we|
|000015e0| 20 77 69 6c 6c 20 70 72 | 69 6e 74 20 69 74 20 61 | will pr|int it a|
|000015f0| 74 20 2a 2f 0a 09 09 09 | 69 6e 74 09 09 09 70 72 |t */....|int...pr|
|00001600| 69 6e 74 5f 63 6f 6c 3b | 2f 2a 20 63 6f 6c 75 6d |int_col;|/* colum|
|00001610| 6e 20 74 6f 20 70 72 69 | 6e 74 20 6e 61 6d 65 20 |n to pri|nt name |
|00001620| 69 6e 20 2a 2f 0a 09 09 | 09 69 6e 74 09 09 09 70 |in */...|.int...p|
|00001630| 72 69 6e 74 5f 6c 69 6d | 69 74 3b 0a 09 09 09 09 |rint_lim|it;.....|
|00001640| 09 09 09 09 2f 2a 20 6c | 6f 63 61 74 69 6f 6e 20 |..../* l|ocation |
|00001650| 77 65 20 63 61 6e 27 74 | 20 70 72 69 6e 74 20 6f |we can't| print o|
|00001660| 6e 20 6f 72 0a 09 09 09 | 09 09 09 09 09 20 2a 20 |n or....|..... * |
|00001670| 61 66 74 65 72 20 2a 2f | 0a 09 09 09 69 6e 74 09 |after */|....int.|
|00001680| 09 09 6c 61 73 74 3b 09 | 2f 2a 20 61 72 65 20 77 |..last;.|/* are w|
|00001690| 65 20 6c 61 73 74 20 73 | 6f 6e 20 6f 66 20 6f 75 |e last s|on of ou|
|000016a0| 72 20 66 61 74 68 65 72 | 3f 20 2a 2f 0a 09 09 09 |r father|? */....|
|000016b0| 63 68 61 72 09 09 09 6e | 61 6d 65 5b 31 5d 3b 09 |char...n|ame[1];.|
|000016c0| 2f 2a 20 6e 61 6d 65 20 | 2a 2f 0a 09 09 20 20 7d |/* name |*/... }|
|000016d0| 3b 0a 0a 2f 2a 20 72 6f | 6f 74 20 6f 66 20 74 68 |;../* ro|ot of th|
|000016e0| 65 20 74 72 65 65 20 2a | 2f 0a 73 74 72 75 63 74 |e tree *|/.struct|
|000016f0| 20 6e 6f 64 65 09 2a 72 | 6f 6f 74 20 3d 20 4e 55 | node.*r|oot = NU|
|00001700| 4c 4c 3b 0a 2f 2a 20 74 | 6f 74 61 6c 20 73 69 7a |LL;./* t|otal siz|
|00001710| 65 20 6f 66 20 74 68 69 | 6e 67 73 20 6c 69 73 74 |e of thi|ngs list|
|00001720| 65 64 20 2a 2f 0a 75 6e | 73 69 67 6e 65 64 20 6c |ed */.un|signed l|
|00001730| 6f 6e 67 09 74 6f 74 61 | 6c 5f 73 69 7a 65 3b 0a |ong.tota|l_size;.|
|00001740| 2f 2a 20 63 75 72 72 65 | 6e 74 20 6c 69 6e 65 20 |/* curre|nt line |
|00001750| 6e 75 6d 62 65 72 20 77 | 65 20 61 72 65 20 6f 6e |number w|e are on|
|00001760| 20 28 30 2d 6f 72 69 67 | 69 6e 29 20 2a 2f 0a 69 | (0-orig|in) */.i|
|00001770| 6e 74 09 09 09 63 75 72 | 72 65 6e 74 5f 6c 69 6e |nt...cur|rent_lin|
|00001780| 65 20 3d 20 30 3b 0a 2f | 2a 20 6c 69 73 74 20 6f |e = 0;./|* list o|
|00001790| 66 20 77 68 65 72 65 20 | 74 6f 20 70 75 74 20 62 |f where |to put b|
|000017a0| 61 72 73 20 2a 2f 0a 69 | 6e 74 09 09 09 62 61 72 |ars */.i|nt...bar|
|000017b0| 5f 6c 69 73 74 5b 35 30 | 5d 3b 0a 2f 2a 20 6e 75 |_list[50|];./* nu|
|000017c0| 6d 62 65 72 20 6f 66 20 | 62 61 72 73 20 69 6e 20 |mber of |bars in |
|000017d0| 74 68 65 20 6c 69 73 74 | 20 2a 2f 0a 69 6e 74 09 |the list| */.int.|
|000017e0| 09 09 62 61 72 5f 63 6f | 75 6e 74 20 3d 20 30 3b |..bar_co|unt = 0;|
|000017f0| 0a 0a 2f 2a 20 64 65 63 | 6c 61 72 65 20 66 75 6e |../* dec|lare fun|
|00001800| 63 74 69 6f 6e 73 20 2a | 2f 0a 76 6f 69 64 09 09 |ctions *|/.void..|
|00001810| 09 72 65 61 64 5f 69 6e | 70 75 74 28 29 3b 0a 73 |.read_in|put();.s|
|00001820| 74 72 75 63 74 20 6e 6f | 64 65 09 2a 69 6e 73 65 |truct no|de.*inse|
|00001830| 72 74 5f 69 6e 5f 74 72 | 65 65 28 29 3b 0a 76 6f |rt_in_tr|ee();.vo|
|00001840| 69 64 09 09 09 64 66 73 | 28 29 3b 0a 76 6f 69 64 |id...dfs|();.void|
|00001850| 09 09 09 64 66 73 31 28 | 29 3b 0a 76 6f 69 64 09 |...dfs1(|);.void.|
|00001860| 09 09 6d 69 73 73 69 6e | 67 5f 73 69 7a 65 73 28 |..missin|g_sizes(|
|00001870| 29 3b 0a 76 6f 69 64 09 | 09 09 73 6f 72 74 5f 73 |);.void.|..sort_s|
|00001880| 69 7a 65 28 29 3b 09 2f | 2a 20 73 6f 72 74 20 74 |ize();./|* sort t|
|00001890| 72 65 65 20 62 79 20 73 | 69 7a 65 20 2a 2f 0a 76 |ree by s|ize */.v|
|000018a0| 6f 69 64 09 09 09 73 6f | 72 74 5f 6e 61 6d 65 28 |oid...so|rt_name(|
|000018b0| 29 3b 09 2f 2a 20 73 6f | 72 74 20 74 72 65 65 20 |);./* so|rt tree |
|000018c0| 61 6c 70 68 61 62 65 74 | 69 63 61 6c 6c 79 20 2a |alphabet|ically *|
|000018d0| 2f 0a 76 6f 69 64 09 09 | 09 63 61 6c 63 5f 6c 6f |/.void..|.calc_lo|
|000018e0| 63 28 29 3b 0a 76 6f 69 | 64 09 09 09 62 6c 61 6e |c();.voi|d...blan|
|000018f0| 6b 28 29 3b 0a 76 6f 69 | 64 09 09 09 6d 61 72 6b |k();.voi|d...mark|
|00001900| 5f 6c 61 73 74 28 29 3b | 0a 76 6f 69 64 09 09 09 |_last();|.void...|
|00001910| 63 61 6c 63 5f 70 63 28 | 29 3b 0a 76 6f 69 64 09 |calc_pc(|);.void.|
|00001920| 09 09 6f 75 74 70 75 74 | 28 29 3b 0a 76 6f 69 64 |..output|();.void|
|00001930| 09 09 09 70 6f 73 69 74 | 69 6f 6e 28 29 3b 0a 76 |...posit|ion();.v|
|00001940| 6f 69 64 09 09 09 73 68 | 6f 77 5f 6e 6f 64 65 28 |oid...sh|ow_node(|
|00001950| 29 3b 0a 76 6f 69 64 09 | 09 09 6d 79 5f 73 70 61 |);.void.|..my_spa|
|00001960| 63 65 28 29 3b 0a 0a 6d | 61 69 6e 28 29 0a 09 7b |ce();..m|ain()..{|
|00001970| 0a 09 73 74 72 75 63 74 | 20 6e 6f 64 65 09 2a 74 |..struct| node.*t|
|00001980| 3b 09 2f 2a 20 73 63 72 | 61 74 63 68 20 2a 2f 0a |;./* scr|atch */.|
|00001990| 0a 09 2f 2a 20 72 65 61 | 64 20 74 68 65 20 69 6e |../* rea|d the in|
|000019a0| 70 75 74 20 61 6e 64 20 | 66 6f 72 6d 20 61 20 74 |put and |form a t|
|000019b0| 72 65 65 20 2a 2f 0a 09 | 72 65 61 64 5f 69 6e 70 |ree */..|read_inp|
|000019c0| 75 74 28 29 3b 0a 09 72 | 6f 6f 74 2d 3e 73 69 7a |ut();..r|oot->siz|
|000019d0| 65 20 3d 20 30 3b 0a 09 | 2f 2a 20 70 75 74 20 73 |e = 0;..|/* put s|
|000019e0| 69 7a 65 73 20 6f 6e 20 | 65 6e 74 72 69 65 73 20 |izes on |entries |
|000019f0| 74 68 61 74 20 68 61 76 | 65 20 6e 6f 6e 65 20 2a |that hav|e none *|
|00001a00| 2f 0a 09 64 66 73 28 4e | 55 4c 4c 2c 20 6d 69 73 |/..dfs(N|ULL, mis|
|00001a10| 73 69 6e 67 5f 73 69 7a | 65 73 29 3b 0a 09 2f 2a |sing_siz|es);../*|
|00001a20| 20 73 6f 72 74 20 65 61 | 63 68 20 64 69 72 65 63 | sort ea|ch direc|
|00001a30| 74 6f 72 79 20 2a 2f 0a | 09 64 66 73 28 73 6f 72 |tory */.|.dfs(sor|
|00001a40| 74 5f 6e 61 6d 65 2c 20 | 4e 55 4c 4c 29 3b 0a 0a |t_name, |NULL);..|
|00001a50| 09 2f 2a 20 66 6f 72 20 | 65 61 63 68 20 64 69 72 |./* for |each dir|
|00001a60| 65 63 74 6f 72 79 2c 20 | 73 75 62 74 72 61 63 74 |ectory, |subtract|
|00001a70| 20 74 68 65 20 73 70 61 | 63 65 20 75 73 65 64 20 | the spa|ce used |
|00001a80| 75 70 20 62 79 0a 09 20 | 2a 20 61 6c 6c 20 63 68 |up by.. |* all ch|
|00001a90| 69 6c 64 72 65 6e 20 6f | 6e 65 20 6c 65 76 65 6c |ildren o|ne level|
|00001aa0| 20 62 65 6c 6f 77 20 6d | 65 2c 20 73 6f 20 74 68 | below m|e, so th|
|00001ab0| 61 74 20 77 65 0a 09 20 | 2a 20 63 61 6e 20 74 65 |at we.. |* can te|
|00001ac0| 6c 6c 20 68 6f 77 20 6d | 75 63 68 20 73 70 61 63 |ll how m|uch spac|
|00001ad0| 65 20 69 73 20 6f 63 63 | 75 70 69 65 64 20 62 79 |e is occ|upied by|
|00001ae0| 20 74 68 69 73 0a 09 20 | 2a 20 64 69 72 65 63 74 | this.. |* direct|
|00001af0| 6f 72 79 20 6f 6e 6c 79 | 2e 0a 09 20 2a 20 49 4d |ory only|... * IM|
|00001b00| 50 4f 52 54 41 4e 54 3a | 20 57 65 20 6e 65 65 64 |PORTANT:| We need|
|00001b10| 20 74 6f 20 63 6f 6d 70 | 75 74 65 20 69 6e 20 70 | to comp|ute in p|
|00001b20| 72 65 2d 6f 72 64 65 72 | 2c 20 6f 72 20 77 65 0a |re-order|, or we.|
|00001b30| 09 20 2a 20 77 6f 6e 27 | 74 20 67 65 74 20 74 68 |. * won'|t get th|
|00001b40| 65 20 72 69 67 68 74 20 | 72 65 73 75 6c 74 73 2e |e right |results.|
|00001b50| 0a 09 20 2a 2f 0a 09 64 | 66 73 28 6d 79 5f 73 70 |.. */..d|fs(my_sp|
|00001b60| 61 63 65 2c 20 4e 55 4c | 4c 29 3b 0a 0a 09 2f 2a |ace, NUL|L);.../*|
|00001b70| 20 70 72 69 6e 74 20 74 | 68 65 20 74 72 65 65 20 | print t|he tree |
|00001b80| 2a 2f 0a 09 64 66 73 28 | 73 68 6f 77 5f 6e 6f 64 |*/..dfs(|show_nod|
|00001b90| 65 2c 20 4e 55 4c 4c 29 | 3b 0a 09 65 78 69 74 28 |e, NULL)|;..exit(|
|00001ba0| 30 29 3b 0a 0a 09 2f 2a | 20 75 6e 75 73 65 64 20 |0);.../*| unused |
|00001bb0| 6c 65 66 74 2d 6f 76 65 | 72 20 63 6f 64 65 20 49 |left-ove|r code I|
|00001bc0| 20 6d 69 67 68 74 20 6e | 65 65 64 20 6c 61 74 65 | might n|eed late|
|00001bd0| 72 2e 20 2a 2f 0a 0a 09 | 2f 2a 20 63 61 6c 63 75 |r. */...|/* calcu|
|00001be0| 6c 61 74 65 20 74 68 65 | 20 74 6f 74 61 6c 20 73 |late the| total s|
|00001bf0| 69 7a 65 20 2a 2f 0a 09 | 74 6f 74 61 6c 5f 73 69 |ize */..|total_si|
|00001c00| 7a 65 20 3d 20 30 3b 0a | 09 66 6f 72 20 28 74 20 |ze = 0;.|.for (t |
|00001c10| 3d 20 72 6f 6f 74 2d 3e | 6c 73 6f 6e 3b 20 74 20 |= root->|lson; t |
|00001c20| 21 3d 20 4e 55 4c 4c 3b | 20 74 20 3d 20 74 2d 3e |!= NULL;| t = t->|
|00001c30| 72 62 72 6f 74 68 65 72 | 29 0a 09 09 74 6f 74 61 |rbrother|)...tota|
|00001c40| 6c 5f 73 69 7a 65 20 2b | 3d 20 74 2d 3e 73 69 7a |l_size +|= t->siz|
|00001c50| 65 3b 0a 09 2f 2a 20 63 | 61 6c 63 75 6c 61 74 65 |e;../* c|alculate|
|00001c60| 20 74 68 65 20 6c 6f 63 | 61 74 69 6f 6e 20 6f 66 | the loc|ation of|
|00001c70| 20 65 61 63 68 20 64 69 | 72 65 63 74 6f 72 79 20 | each di|rectory |
|00001c80| 2a 2f 0a 09 2f 2a 20 62 | 6c 61 6e 6b 20 6f 75 74 |*/../* b|lank out|
|00001c90| 20 73 75 62 64 69 72 65 | 63 74 6f 72 69 65 73 20 | subdire|ctories |
|00001ca0| 74 68 61 74 20 67 65 74 | 20 73 63 72 75 6e 63 68 |that get| scrunch|
|00001cb0| 65 64 20 74 6f 67 65 74 | 68 65 72 20 61 74 20 74 |ed toget|her at t|
|00001cc0| 68 65 20 62 6f 74 74 6f | 6d 20 2a 2f 0a 09 72 6f |he botto|m */..ro|
|00001cd0| 6f 74 2d 3e 70 72 69 6e | 74 5f 6c 69 6d 69 74 20 |ot->prin|t_limit |
|00001ce0| 3d 20 6c 65 6e 67 74 68 | 3b 0a 09 64 66 73 28 63 |= length|;..dfs(c|
|00001cf0| 61 6c 63 5f 6c 6f 63 2c | 20 62 6c 61 6e 6b 29 3b |alc_loc,| blank);|
|00001d00| 0a 09 2f 2a 20 70 72 69 | 6e 74 20 6f 75 74 20 74 |../* pri|nt out t|
|00001d10| 68 65 20 74 72 65 65 20 | 2a 2f 0a 09 66 6f 72 20 |he tree |*/..for |
|00001d20| 28 74 20 3d 20 72 6f 6f | 74 2d 3e 6c 73 6f 6e 3b |(t = roo|t->lson;|
|00001d30| 20 74 20 21 3d 20 4e 55 | 4c 4c 3b 20 74 20 3d 20 | t != NU|LL; t = |
|00001d40| 74 2d 3e 72 62 72 6f 74 | 68 65 72 29 0a 09 09 7b |t->rbrot|her)...{|
|00001d50| 0a 09 09 2f 2a 20 6d 61 | 72 6b 20 74 68 65 20 6c |.../* ma|rk the l|
|00001d60| 61 73 74 20 73 6f 6e 20 | 6f 66 20 65 61 63 68 20 |ast son |of each |
|00001d70| 64 69 72 65 63 74 6f 72 | 79 20 2a 2f 0a 09 09 2f |director|y */.../|
|00001d80| 2a 20 66 69 67 75 72 65 | 20 6f 75 74 20 74 68 65 |* figure| out the|
|00001d90| 20 70 72 69 6e 74 20 63 | 6f 6c 75 6d 6e 73 20 2a | print c|olumns *|
|00001da0| 2f 0a 09 09 74 2d 3e 70 | 72 69 6e 74 5f 63 6f 6c |/...t->p|rint_col|
|00001db0| 20 3d 20 30 3b 0a 09 09 | 64 66 73 31 28 63 61 6c | = 0;...|dfs1(cal|
|00001dc0| 63 5f 70 63 2c 20 6d 61 | 72 6b 5f 6c 61 73 74 2c |c_pc, ma|rk_last,|
|00001dd0| 20 74 29 3b 0a 09 09 64 | 66 73 31 28 6f 75 74 70 | t);...d|fs1(outp|
|00001de0| 75 74 2c 20 4e 55 4c 4c | 2c 20 74 29 3b 0a 09 09 |ut, NULL|, t);...|
|00001df0| 7d 0a 09 2f 2a 20 70 75 | 74 20 62 6c 61 6e 6b 20 |}../* pu|t blank |
|00001e00| 73 70 61 63 65 20 61 74 | 20 65 6e 64 20 2a 2f 0a |space at| end */.|
|00001e10| 09 70 6f 73 69 74 69 6f | 6e 28 6c 65 6e 67 74 68 |.positio|n(length|
|00001e20| 29 3b 0a 09 7d 0a 0a 2f | 2a 20 72 65 61 64 20 69 |);..}../|* read i|
|00001e30| 6e 70 75 74 20 61 6e 64 | 20 66 6f 72 6d 20 61 20 |nput and| form a |
|00001e40| 74 72 65 65 20 2a 2f 0a | 76 6f 69 64 20 72 65 61 |tree */.|void rea|
|00001e50| 64 5f 69 6e 70 75 74 28 | 29 0a 09 7b 0a 09 75 6e |d_input(|)..{..un|
|00001e60| 73 69 67 6e 65 64 20 6c | 6f 6e 67 09 73 69 7a 65 |signed l|ong.size|
|00001e70| 3b 09 09 2f 2a 20 73 69 | 7a 65 20 72 65 61 64 20 |;../* si|ze read |
|00001e80| 66 72 6f 6d 20 69 6e 70 | 75 74 20 2a 2f 0a 09 63 |from inp|ut */..c|
|00001e90| 68 61 72 09 09 09 6e 61 | 6d 65 5b 31 30 30 5d 3b |har...na|me[100];|
|00001ea0| 09 2f 2a 20 64 69 72 65 | 63 74 6f 72 79 20 6e 61 |./* dire|ctory na|
|00001eb0| 6d 65 20 72 65 61 64 20 | 66 72 6f 6d 20 69 6e 70 |me read |from inp|
|00001ec0| 75 74 20 2a 2f 0a 0a 09 | 2f 2a 20 6d 61 6b 65 20 |ut */...|/* make |
|00001ed0| 74 68 65 20 64 75 6d 6d | 79 20 6e 6f 64 65 20 61 |the dumm|y node a|
|00001ee0| 74 20 74 68 65 20 74 6f | 70 20 6f 66 20 74 68 65 |t the to|p of the|
|00001ef0| 20 74 72 65 65 20 2a 2f | 0a 09 72 6f 6f 74 20 3d | tree */|..root =|
|00001f00| 20 28 73 74 72 75 63 74 | 20 6e 6f 64 65 20 2a 29 | (struct| node *)|
|00001f10| 6d 61 6c 6c 6f 63 28 73 | 69 7a 65 6f 66 20 28 73 |malloc(s|izeof (s|
|00001f20| 74 72 75 63 74 20 6e 6f | 64 65 29 29 3b 0a 09 72 |truct no|de));..r|
|00001f30| 6f 6f 74 2d 3e 6e 61 6d | 65 5b 30 5d 20 3d 20 27 |oot->nam|e[0] = '|
|00001f40| 5c 30 27 3b 0a 09 72 6f | 6f 74 2d 3e 6c 73 6f 6e |\0';..ro|ot->lson|
|00001f50| 20 3d 20 4e 55 4c 4c 3b | 0a 09 72 6f 6f 74 2d 3e | = NULL;|..root->|
|00001f60| 66 61 74 68 65 72 20 3d | 20 4e 55 4c 4c 3b 09 2f |father =| NULL;./|
|00001f70| 2a 20 69 66 20 77 61 6c | 6b 69 6e 67 20 75 70 20 |* if wal|king up |
|00001f80| 74 68 65 20 6c 61 64 64 | 65 72 2c 20 64 6f 6e 27 |the ladd|er, don'|
|00001f90| 74 20 66 61 6c 6c 20 6f | 66 66 20 21 20 2a 2f 0a |t fall o|ff ! */.|
|00001fa0| 09 2f 2a 20 72 65 61 64 | 20 74 68 65 20 6e 65 78 |./* read| the nex|
|00001fb0| 74 20 6c 69 6e 65 20 6f | 66 20 69 6e 70 75 74 20 |t line o|f input |
|00001fc0| 2a 2f 0a 09 77 68 69 6c | 65 20 28 66 73 63 61 6e |*/..whil|e (fscan|
|00001fd0| 66 28 73 74 64 69 6e 2c | 20 22 25 6c 75 20 25 73 |f(stdin,| "%lu %s|
|00001fe0| 5c 6e 22 2c 20 26 73 69 | 7a 65 2c 20 6e 61 6d 65 |\n", &si|ze, name|
|00001ff0| 29 20 21 3d 20 45 4f 46 | 29 0a 09 09 7b 0a 09 09 |) != EOF|)...{...|
|00002000| 2f 2a 20 69 6e 73 65 72 | 74 20 28 6f 72 20 66 69 |/* inser|t (or fi|
|00002010| 6e 64 29 20 74 68 65 20 | 64 69 72 65 63 74 6f 72 |nd) the |director|
|00002020| 79 20 69 6e 20 74 68 65 | 20 74 72 65 65 20 61 6e |y in the| tree an|
|00002030| 64 20 73 61 76 65 20 69 | 74 73 20 73 69 7a 65 20 |d save i|ts size |
|00002040| 2a 2f 0a 09 09 69 6e 73 | 65 72 74 5f 69 6e 5f 74 |*/...ins|ert_in_t|
|00002050| 72 65 65 28 6e 61 6d 65 | 29 2d 3e 73 69 7a 65 20 |ree(name|)->size |
|00002060| 3d 20 73 69 7a 65 3b 0a | 09 09 7d 0a 09 7d 0a 0a |= size;.|..}..}..|
|00002070| 2f 2a 20 69 6e 73 65 72 | 74 20 28 6f 72 20 66 69 |/* inser|t (or fi|
|00002080| 6e 64 29 20 61 20 64 69 | 72 65 63 74 6f 72 79 20 |nd) a di|rectory |
|00002090| 69 6e 20 74 68 65 20 74 | 72 65 65 20 2a 2f 0a 73 |in the t|ree */.s|
|000020a0| 74 72 75 63 74 20 6e 6f | 64 65 20 2a 69 6e 73 65 |truct no|de *inse|
|000020b0| 72 74 5f 69 6e 5f 74 72 | 65 65 28 6e 61 6d 65 29 |rt_in_tr|ee(name)|
|000020c0| 0a 09 63 68 61 72 09 2a | 6e 61 6d 65 3b 09 09 2f |..char.*|name;../|
|000020d0| 2a 20 6e 61 6d 65 20 6f | 66 20 74 68 65 20 64 69 |* name o|f the di|
|000020e0| 72 65 63 74 6f 72 79 20 | 2a 2f 0a 09 7b 0a 09 73 |rectory |*/..{..s|
|000020f0| 74 72 75 63 74 20 6e 6f | 64 65 09 2a 74 3b 09 2f |truct no|de.*t;./|
|00002100| 2a 20 70 6f 69 6e 74 65 | 72 20 66 6f 72 20 73 65 |* pointe|r for se|
|00002110| 61 72 63 68 69 6e 67 20 | 64 6f 77 6e 20 74 68 72 |arching |down thr|
|00002120| 6f 75 67 68 20 74 72 65 | 65 20 2a 2f 0a 09 63 68 |ough tre|e */..ch|
|00002130| 61 72 09 09 09 2a 6e 70 | 3b 09 2f 2a 20 70 6f 69 |ar...*np|;./* poi|
|00002140| 6e 74 73 20 74 6f 20 6e | 65 78 74 20 70 61 72 74 |nts to n|ext part|
|00002150| 20 6f 66 20 64 69 72 65 | 63 74 6f 72 79 20 6e 61 | of dire|ctory na|
|00002160| 6d 65 20 74 6f 20 62 65 | 0a 09 09 09 09 09 20 2a |me to be|...... *|
|00002170| 20 65 78 61 6d 69 6e 65 | 64 20 2a 2f 0a 09 73 74 | examine|d */..st|
|00002180| 72 75 63 74 20 6e 6f 64 | 65 09 2a 74 31 3b 09 2f |ruct nod|e.*t1;./|
|00002190| 2a 20 73 63 72 61 74 63 | 68 20 70 6f 69 6e 74 65 |* scratc|h pointe|
|000021a0| 72 20 2a 2f 0a 09 63 68 | 61 72 09 09 09 2a 6e 70 |r */..ch|ar...*np|
|000021b0| 31 3b 2f 2a 20 73 63 72 | 61 74 63 68 20 70 6f 69 |1;/* scr|atch poi|
|000021c0| 6e 74 65 72 20 2a 2f 0a | 0a 09 2f 2a 20 72 65 61 |nter */.|../* rea|
|000021d0| 64 20 74 68 72 6f 75 67 | 68 20 74 68 65 20 6e 61 |d throug|h the na|
|000021e0| 6d 65 2c 20 6f 6e 65 20 | 64 69 72 65 63 74 6f 72 |me, one |director|
|000021f0| 79 2d 70 61 72 74 20 61 | 74 20 61 20 74 69 6d 65 |y-part a|t a time|
|00002200| 2c 20 61 6e 64 20 68 75 | 6e 74 0a 09 20 2a 20 64 |, and hu|nt.. * d|
|00002210| 6f 77 6e 20 74 68 65 20 | 74 72 65 65 2c 20 63 6f |own the |tree, co|
|00002220| 6e 73 74 72 75 63 74 69 | 6e 67 20 6e 6f 64 65 73 |nstructi|ng nodes|
|00002230| 20 61 73 20 6e 65 65 64 | 65 64 20 2a 2f 0a 09 66 | as need|ed */..f|
|00002240| 6f 72 20 28 74 20 3d 20 | 72 6f 6f 74 2c 20 6e 70 |or (t = |root, np|
|00002250| 20 3d 20 6e 61 6d 65 3b | 20 6e 70 20 21 3d 20 4e | = name;| np != N|
|00002260| 55 4c 4c 3b 20 6e 70 20 | 3d 20 6e 70 31 29 0a 09 |ULL; np |= np1)..|
|00002270| 09 7b 0a 09 09 2f 2a 20 | 65 78 74 72 61 63 74 20 |.{.../* |extract |
|00002280| 74 68 65 20 6e 65 78 74 | 20 64 69 72 65 63 74 6f |the next| directo|
|00002290| 72 79 2d 70 61 72 74 20 | 2a 2f 0a 09 09 69 66 20 |ry-part |*/...if |
|000022a0| 28 28 6e 70 31 20 3d 20 | 73 74 72 63 68 72 28 6e |((np1 = |strchr(n|
|000022b0| 70 2c 20 27 2f 27 29 29 | 20 21 3d 20 4e 55 4c 4c |p, '/'))| != NULL|
|000022c0| 29 0a 09 09 09 7b 0a 09 | 09 09 2f 2a 20 77 65 20 |)....{..|../* we |
|000022d0| 66 6f 75 6e 64 20 61 20 | 73 6c 61 73 68 2c 20 72 |found a |slash, r|
|000022e0| 65 70 6c 61 63 65 20 69 | 74 20 77 69 74 68 20 61 |eplace i|t with a|
|000022f0| 20 6e 75 6c 6c 2c 20 61 | 6e 64 20 70 6f 73 69 74 | null, a|nd posit|
|00002300| 69 6f 6e 0a 09 09 09 20 | 2a 20 6e 70 31 20 74 6f |ion.... |* np1 to|
|00002310| 20 70 6f 69 6e 74 20 74 | 6f 20 74 68 65 20 72 65 | point t|o the re|
|00002320| 6d 61 69 6e 64 65 72 20 | 6f 66 20 74 68 65 20 6e |mainder |of the n|
|00002330| 61 6d 65 20 2a 2f 0a 09 | 09 09 2f 2a 20 63 61 6e |ame */..|../* can|
|00002340| 20 73 74 6f 72 65 20 6e | 6f 64 65 2e 6e 61 6d 65 | store n|ode.name|
|00002350| 3d 3d 22 22 20 77 68 65 | 6e 20 6e 61 6d 65 20 62 |=="" whe|n name b|
|00002360| 65 67 69 6e 73 20 77 69 | 74 68 20 2f 20 2a 2f 0a |egins wi|th / */.|
|00002370| 09 09 09 2a 6e 70 31 2b | 2b 20 3d 20 27 5c 30 27 |...*np1+|+ = '\0'|
|00002380| 3b 0a 09 09 09 7d 0a 09 | 09 2f 2a 20 65 6c 73 65 |;....}..|./* else|
|00002390| 20 2a 2f 0a 09 09 09 2f | 2a 20 77 65 20 66 6f 75 | */..../|* we fou|
|000023a0| 6e 64 20 6e 6f 20 73 68 | 61 73 68 2c 20 73 6f 20 |nd no sh|ash, so |
|000023b0| 77 65 20 61 72 65 20 61 | 74 20 74 68 65 20 65 6e |we are a|t the en|
|000023c0| 64 20 6f 66 20 74 68 65 | 20 6e 61 6d 65 0a 09 09 |d of the| name...|
|000023d0| 09 20 2a 20 6e 70 31 20 | 68 61 73 20 62 65 65 6e |. * np1 |has been|
|000023e0| 20 73 65 74 20 74 6f 20 | 4e 55 4c 4c 20 66 6f 72 | set to |NULL for|
|000023f0| 20 75 73 20 62 79 20 73 | 74 72 63 68 72 20 2a 2f | us by s|trchr */|
|00002400| 0a 09 09 2f 2a 20 73 65 | 61 72 63 68 20 74 68 65 |.../* se|arch the|
|00002410| 20 73 6f 6e 73 20 6f 66 | 20 74 68 69 73 20 6e 6f | sons of| this no|
|00002420| 64 65 20 66 6f 72 20 61 | 20 6e 6f 64 65 20 77 69 |de for a| node wi|
|00002430| 74 68 20 74 68 65 20 70 | 72 6f 70 65 72 20 6e 61 |th the p|roper na|
|00002440| 6d 65 20 2a 2f 0a 09 09 | 66 6f 72 20 28 74 31 20 |me */...|for (t1 |
|00002450| 3d 20 74 2d 3e 6c 73 6f | 6e 3b 20 74 31 20 21 3d |= t->lso|n; t1 !=|
|00002460| 20 4e 55 4c 4c 20 26 26 | 20 73 74 72 63 6d 70 28 | NULL &&| strcmp(|
|00002470| 74 31 2d 3e 6e 61 6d 65 | 2c 20 6e 70 29 20 21 3d |t1->name|, np) !=|
|00002480| 20 30 3b 0a 09 09 09 09 | 74 31 20 3d 20 74 31 2d | 0;.....|t1 = t1-|
|00002490| 3e 72 62 72 6f 74 68 65 | 72 29 0a 09 09 09 3b 0a |>rbrothe|r)....;.|
|000024a0| 09 09 2f 2a 20 64 69 64 | 20 77 65 20 66 69 6e 64 |../* did| we find|
|000024b0| 20 6f 6e 65 3f 20 2a 2f | 0a 09 09 69 66 20 28 74 | one? */|...if (t|
|000024c0| 31 20 21 3d 20 4e 55 4c | 4c 29 0a 09 09 09 2f 2a |1 != NUL|L)..../*|
|000024d0| 20 79 65 73 2c 20 67 6f | 20 74 6f 20 69 74 20 2a | yes, go| to it *|
|000024e0| 2f 0a 09 09 09 74 20 3d | 20 74 31 3b 0a 09 09 65 |/....t =| t1;...e|
|000024f0| 6c 73 65 0a 09 09 09 7b | 0a 09 09 09 2f 2a 20 6e |lse....{|..../* n|
|00002500| 6f 2c 20 6d 61 6b 65 20 | 6f 6e 65 20 2a 2f 0a 09 |o, make |one */..|
|00002510| 09 09 74 31 20 3d 20 28 | 73 74 72 75 63 74 20 6e |..t1 = (|struct n|
|00002520| 6f 64 65 20 2a 29 6d 61 | 6c 6c 6f 63 28 73 69 7a |ode *)ma|lloc(siz|
|00002530| 65 6f 66 28 73 74 72 75 | 63 74 20 6e 6f 64 65 29 |eof(stru|ct node)|
|00002540| 20 2b 20 73 74 72 6c 65 | 6e 28 6e 70 29 29 3b 0a | + strle|n(np));.|
|00002550| 09 09 09 73 74 72 63 70 | 79 28 74 31 2d 3e 6e 61 |...strcp|y(t1->na|
|00002560| 6d 65 2c 20 6e 70 29 3b | 0a 09 09 09 74 31 2d 3e |me, np);|....t1->|
|00002570| 6c 73 6f 6e 20 3d 20 4e | 55 4c 4c 3b 0a 09 09 09 |lson = N|ULL;....|
|00002580| 74 31 2d 3e 72 62 72 6f | 74 68 65 72 20 3d 20 4e |t1->rbro|ther = N|
|00002590| 55 4c 4c 3b 0a 09 09 09 | 74 31 2d 3e 66 61 74 68 |ULL;....|t1->fath|
|000025a0| 65 72 20 3d 20 74 3b 0a | 09 09 09 74 31 2d 3e 73 |er = t;.|...t1->s|
|000025b0| 69 7a 65 20 3d 20 30 3b | 0a 09 09 09 2f 2a 20 69 |ize = 0;|..../* i|
|000025c0| 6e 73 65 72 74 20 69 74 | 20 69 6e 20 74 72 65 65 |nsert it| in tree|
|000025d0| 20 2a 2f 0a 09 09 09 74 | 31 2d 3e 72 62 72 6f 74 | */....t|1->rbrot|
|000025e0| 68 65 72 20 3d 20 74 2d | 3e 6c 73 6f 6e 3b 0a 09 |her = t-|>lson;..|
|000025f0| 09 09 74 2d 3e 6c 73 6f | 6e 20 3d 20 74 31 3b 0a |..t->lso|n = t1;.|
|00002600| 09 09 09 74 20 3d 20 74 | 31 3b 0a 09 09 09 7d 0a |...t = t|1;....}.|
|00002610| 09 09 7d 0a 09 72 65 74 | 75 72 6e 20 74 3b 0a 09 |..}..ret|urn t;..|
|00002620| 7d 0a 0a 2f 2a 20 64 65 | 70 74 68 2d 66 69 72 73 |}../* de|pth-firs|
|00002630| 74 2d 73 65 61 72 63 68 | 20 72 6f 75 74 69 6e 65 |t-search| routine|
|00002640| 20 2a 2f 0a 76 6f 69 64 | 20 64 66 73 28 70 72 65 | */.void| dfs(pre|
|00002650| 5f 72 6f 75 74 69 6e 65 | 2c 20 70 6f 73 74 5f 72 |_routine|, post_r|
|00002660| 6f 75 74 69 6e 65 29 0a | 09 76 6f 69 64 09 28 2a |outine).|.void.(*|
|00002670| 70 72 65 5f 72 6f 75 74 | 69 6e 65 29 28 29 3b 09 |pre_rout|ine)();.|
|00002680| 2f 2a 20 72 6f 75 74 69 | 6e 65 20 74 6f 20 65 78 |/* routi|ne to ex|
|00002690| 65 63 75 74 65 20 62 65 | 66 6f 72 65 20 73 63 61 |ecute be|fore sca|
|000026a0| 6e 6e 69 6e 67 0a 09 09 | 09 09 09 09 20 2a 20 64 |nning...|.... * d|
|000026b0| 65 73 63 65 6e 64 61 6e | 74 73 20 2a 2f 0a 09 76 |escendan|ts */..v|
|000026c0| 6f 69 64 09 28 2a 70 6f | 73 74 5f 72 6f 75 74 69 |oid.(*po|st_routi|
|000026d0| 6e 65 29 28 29 3b 09 2f | 2a 20 72 6f 75 74 69 6e |ne)();./|* routin|
|000026e0| 65 20 74 6f 20 65 78 65 | 63 75 74 65 20 61 66 74 |e to exe|cute aft|
|000026f0| 65 72 20 73 63 61 6e 6e | 69 6e 67 0a 09 09 09 09 |er scann|ing.....|
|00002700| 09 09 20 2a 20 64 65 73 | 63 65 6e 64 61 6e 74 73 |.. * des|cendants|
|00002710| 20 2a 2f 0a 09 7b 0a 09 | 64 66 73 31 28 70 72 65 | */..{..|dfs1(pre|
|00002720| 5f 72 6f 75 74 69 6e 65 | 2c 20 70 6f 73 74 5f 72 |_routine|, post_r|
|00002730| 6f 75 74 69 6e 65 2c 20 | 72 6f 6f 74 29 3b 0a 09 |outine, |root);..|
|00002740| 7d 0a 0a 2f 2a 20 64 65 | 70 74 68 2d 66 69 72 73 |}../* de|pth-firs|
|00002750| 74 2d 73 65 61 72 63 68 | 20 73 65 72 76 69 63 65 |t-search| service|
|00002760| 20 72 6f 75 74 69 6e 65 | 20 2a 2f 0a 76 6f 69 64 | routine| */.void|
|00002770| 20 64 66 73 31 28 70 72 | 65 5f 72 6f 75 74 69 6e | dfs1(pr|e_routin|
|00002780| 65 2c 20 70 6f 73 74 5f | 72 6f 75 74 69 6e 65 2c |e, post_|routine,|
|00002790| 20 74 29 0a 09 76 6f 69 | 64 09 28 2a 70 72 65 5f | t)..voi|d.(*pre_|
|000027a0| 72 6f 75 74 69 6e 65 29 | 28 29 3b 09 2f 2a 20 72 |routine)|();./* r|
|000027b0| 6f 75 74 69 6e 65 20 74 | 6f 20 65 78 65 63 75 74 |outine t|o execut|
|000027c0| 65 20 62 65 66 6f 72 65 | 20 73 63 61 6e 6e 69 6e |e before| scannin|
|000027d0| 67 0a 09 09 09 09 09 09 | 20 2a 20 64 65 73 63 65 |g.......| * desce|
|000027e0| 6e 64 61 6e 74 73 20 2a | 2f 0a 09 76 6f 69 64 09 |ndants *|/..void.|
|000027f0| 28 2a 70 6f 73 74 5f 72 | 6f 75 74 69 6e 65 29 28 |(*post_r|outine)(|
|00002800| 29 3b 09 2f 2a 20 72 6f | 75 74 69 6e 65 20 74 6f |);./* ro|utine to|
|00002810| 20 65 78 65 63 75 74 65 | 20 61 66 74 65 72 20 73 | execute| after s|
|00002820| 63 61 6e 6e 69 6e 67 0a | 09 09 09 09 09 09 20 2a |canning.|...... *|
|00002830| 20 64 65 73 63 65 6e 64 | 61 6e 74 73 20 2a 2f 0a | descend|ants */.|
|00002840| 09 73 74 72 75 63 74 20 | 6e 6f 64 65 20 2a 74 3b |.struct |node *t;|
|00002850| 09 09 2f 2a 20 6e 6f 64 | 65 20 74 6f 20 6f 70 65 |../* nod|e to ope|
|00002860| 72 61 74 65 20 6f 6e 20 | 2a 2f 0a 09 7b 0a 09 73 |rate on |*/..{..s|
|00002870| 74 72 75 63 74 20 6e 6f | 64 65 20 2a 74 31 3b 09 |truct no|de *t1;.|
|00002880| 09 2f 2a 20 73 63 72 61 | 74 63 68 20 70 6f 69 6e |./* scra|tch poin|
|00002890| 74 65 72 20 2a 2f 0a 0a | 09 2f 2a 20 69 66 20 69 |ter */..|./* if i|
|000028a0| 74 20 65 78 69 73 74 73 | 2c 20 65 78 65 63 75 74 |t exists|, execut|
|000028b0| 65 20 74 68 65 20 70 72 | 65 2d 72 6f 75 74 69 6e |e the pr|e-routin|
|000028c0| 65 20 2a 2f 0a 09 69 66 | 20 28 70 72 65 5f 72 6f |e */..if| (pre_ro|
|000028d0| 75 74 69 6e 65 20 21 3d | 20 4e 55 4c 4c 29 0a 09 |utine !=| NULL)..|
|000028e0| 09 70 72 65 5f 72 6f 75 | 74 69 6e 65 28 74 29 3b |.pre_rou|tine(t);|
|000028f0| 0a 09 2f 2a 20 63 61 6c | 6c 20 73 65 6c 66 20 6f |../* cal|l self o|
|00002900| 6e 20 73 6f 6e 73 20 6f | 66 20 74 68 69 73 20 6e |n sons o|f this n|
|00002910| 6f 64 65 20 2a 2f 0a 09 | 66 6f 72 20 28 74 31 20 |ode */..|for (t1 |
|00002920| 3d 20 74 2d 3e 6c 73 6f | 6e 3b 20 74 31 20 21 3d |= t->lso|n; t1 !=|
|00002930| 20 4e 55 4c 4c 3b 20 74 | 31 20 3d 20 74 31 2d 3e | NULL; t|1 = t1->|
|00002940| 72 62 72 6f 74 68 65 72 | 29 0a 09 09 64 66 73 31 |rbrother|)...dfs1|
|00002950| 28 70 72 65 5f 72 6f 75 | 74 69 6e 65 2c 20 70 6f |(pre_rou|tine, po|
|00002960| 73 74 5f 72 6f 75 74 69 | 6e 65 2c 20 74 31 29 3b |st_routi|ne, t1);|
|00002970| 0a 09 2f 2a 20 69 66 20 | 69 74 20 65 78 69 73 74 |../* if |it exist|
|00002980| 73 2c 20 65 78 65 63 75 | 74 65 20 74 68 65 20 70 |s, execu|te the p|
|00002990| 6f 73 74 2d 72 6f 75 74 | 69 6e 65 20 2a 2f 0a 09 |ost-rout|ine */..|
|000029a0| 69 66 20 28 70 6f 73 74 | 5f 72 6f 75 74 69 6e 65 |if (post|_routine|
|000029b0| 20 21 3d 20 4e 55 4c 4c | 29 0a 09 09 70 6f 73 74 | != NULL|)...post|
|000029c0| 5f 72 6f 75 74 69 6e 65 | 28 74 29 3b 0a 09 7d 0a |_routine|(t);..}.|
|000029d0| 0a 2f 2a 20 61 64 64 20 | 6d 69 73 73 69 6e 67 20 |./* add |missing |
|000029e0| 73 69 7a 65 73 20 2a 2f | 0a 76 6f 69 64 20 6d 69 |sizes */|.void mi|
|000029f0| 73 73 69 6e 67 5f 73 69 | 7a 65 73 28 74 29 0a 09 |ssing_si|zes(t)..|
|00002a00| 73 74 72 75 63 74 20 6e | 6f 64 65 09 2a 74 3b 0a |struct n|ode.*t;.|
|00002a10| 09 7b 0a 09 73 74 72 75 | 63 74 20 6e 6f 64 65 09 |.{..stru|ct node.|
|00002a20| 2a 74 31 3b 09 09 2f 2a | 20 73 63 72 61 74 63 68 |*t1;../*| scratch|
|00002a30| 20 70 6f 69 6e 74 65 72 | 20 2a 2f 0a 09 75 6e 73 | pointer| */..uns|
|00002a40| 69 67 6e 65 64 20 6c 6f | 6e 67 09 73 3b 09 09 2f |igned lo|ng.s;../|
|00002a50| 2a 20 73 63 72 61 74 63 | 68 20 2a 2f 0a 0a 09 69 |* scratc|h */...i|
|00002a60| 66 20 28 74 2d 3e 73 69 | 7a 65 20 3d 3d 20 30 29 |f (t->si|ze == 0)|
|00002a70| 0a 09 09 7b 0a 09 09 2f | 2a 20 73 69 7a 65 20 69 |...{.../|* size i|
|00002a80| 73 20 6d 69 73 73 69 6e | 67 2c 20 77 65 20 68 61 |s missin|g, we ha|
|00002a90| 76 65 20 74 6f 20 63 61 | 6c 63 75 61 74 65 20 69 |ve to ca|lcuate i|
|00002aa0| 74 20 2a 2f 0a 09 09 73 | 20 3d 20 30 3b 0a 09 09 |t */...s| = 0;...|
|00002ab0| 66 6f 72 20 28 74 31 20 | 3d 20 74 2d 3e 6c 73 6f |for (t1 |= t->lso|
|00002ac0| 6e 3b 20 74 31 20 21 3d | 20 4e 55 4c 4c 3b 20 74 |n; t1 !=| NULL; t|
|00002ad0| 31 20 3d 20 74 31 2d 3e | 72 62 72 6f 74 68 65 72 |1 = t1->|rbrother|
|00002ae0| 29 0a 09 09 09 73 20 2b | 3d 20 74 31 2d 3e 73 69 |)....s +|= t1->si|
|00002af0| 7a 65 3b 0a 09 09 74 2d | 3e 73 69 7a 65 20 3d 20 |ze;...t-|>size = |
|00002b00| 73 3b 0a 09 09 7d 0a 09 | 7d 0a 0a 2f 2a 20 73 6f |s;...}..|}../* so|
|00002b10| 72 74 20 74 68 65 20 64 | 69 72 65 63 74 6f 72 69 |rt the d|irectori|
|00002b20| 65 73 20 75 6e 64 65 72 | 20 61 20 64 69 72 65 63 |es under| a direc|
|00002b30| 74 6f 72 79 20 62 79 20 | 73 69 7a 65 20 2a 2f 0a |tory by |size */.|
|00002b40| 76 6f 69 64 20 73 6f 72 | 74 5f 73 69 7a 65 28 74 |void sor|t_size(t|
|00002b50| 29 0a 09 73 74 72 75 63 | 74 20 6e 6f 64 65 09 2a |)..struc|t node.*|
|00002b60| 74 3b 0a 09 7b 0a 09 73 | 74 72 75 63 74 20 6e 6f |t;..{..s|truct no|
|00002b70| 64 65 09 2a 70 31 2c 20 | 2a 70 32 2c 20 2a 70 33 |de.*p1, |*p2, *p3|
|00002b80| 2c 20 2a 70 70 3b 09 09 | 2f 2a 20 73 63 72 61 74 |, *pp;..|/* scrat|
|00002b90| 63 68 20 70 6f 69 6e 74 | 65 72 73 20 2a 2f 0a 09 |ch point|ers */..|
|00002ba0| 69 6e 74 09 09 09 6e 6f | 64 65 73 2c 20 6e 3b 09 |int...no|des, n;.|
|00002bb0| 09 09 09 2f 2a 20 73 63 | 72 61 74 63 68 20 2a 2f |.../* sc|ratch */|
|00002bc0| 0a 0a 09 2f 2a 20 63 6f | 75 6e 74 20 74 68 65 20 |.../* co|unt the |
|00002bd0| 6e 75 6d 62 65 72 20 6f | 66 20 6e 6f 64 65 73 20 |number o|f nodes |
|00002be0| 2a 2f 0a 09 6e 6f 64 65 | 73 20 3d 20 30 3b 0a 09 |*/..node|s = 0;..|
|00002bf0| 66 6f 72 20 28 70 31 20 | 3d 20 74 2d 3e 6c 73 6f |for (p1 |= t->lso|
|00002c00| 6e 3b 20 70 31 20 21 3d | 20 4e 55 4c 4c 3b 20 70 |n; p1 !=| NULL; p|
|00002c10| 31 20 3d 20 70 31 2d 3e | 72 62 72 6f 74 68 65 72 |1 = p1->|rbrother|
|00002c20| 29 0a 09 09 6e 6f 64 65 | 73 2b 2b 3b 0a 09 2f 2a |)...node|s++;../*|
|00002c30| 20 6a 75 73 74 20 61 20 | 73 69 6d 70 6c 65 20 61 | just a |simple a|
|00002c40| 6e 64 20 69 6e 65 66 66 | 69 63 69 65 6e 74 20 62 |nd ineff|icient b|
|00002c50| 75 62 62 6c 65 20 73 6f | 72 74 20 2a 2f 0a 09 66 |ubble so|rt */..f|
|00002c60| 6f 72 20 28 6e 20 3d 20 | 31 3b 20 6e 20 3c 20 6e |or (n = |1; n < n|
|00002c70| 6f 64 65 73 3b 20 6e 2b | 2b 29 0a 09 09 66 6f 72 |odes; n+|+)...for|
|00002c80| 20 28 70 31 20 3d 20 4e | 55 4c 4c 2c 20 70 32 20 | (p1 = N|ULL, p2 |
|00002c90| 3d 20 74 2d 3e 6c 73 6f | 6e 2c 20 70 33 20 3d 20 |= t->lso|n, p3 = |
|00002ca0| 70 32 2d 3e 72 62 72 6f | 74 68 65 72 3b 20 70 33 |p2->rbro|ther; p3|
|00002cb0| 20 21 3d 20 4e 55 4c 4c | 3b 0a 09 09 09 09 70 31 | != NULL|;.....p1|
|00002cc0| 20 3d 20 70 32 2c 20 70 | 32 20 3d 20 70 33 2c 20 | = p2, p|2 = p3, |
|00002cd0| 70 33 20 3d 20 70 33 2d | 3e 72 62 72 6f 74 68 65 |p3 = p3-|>rbrothe|
|00002ce0| 72 29 0a 09 09 09 7b 0a | 09 09 09 69 66 20 28 70 |r)....{.|...if (p|
|00002cf0| 32 2d 3e 73 69 7a 65 20 | 3c 20 70 33 2d 3e 73 69 |2->size |< p3->si|
|00002d00| 7a 65 29 0a 09 09 09 09 | 7b 0a 09 09 09 09 2f 2a |ze).....|{...../*|
|00002d10| 20 65 78 63 68 61 6e 67 | 65 20 74 68 65 20 6e 6f | exchang|e the no|
|00002d20| 64 65 73 20 70 32 20 61 | 6e 64 20 70 33 20 2a 2f |des p2 a|nd p3 */|
|00002d30| 0a 09 09 09 09 70 70 20 | 3d 20 70 33 2d 3e 72 62 |.....pp |= p3->rb|
|00002d40| 72 6f 74 68 65 72 3b 0a | 09 09 09 09 70 33 2d 3e |rother;.|....p3->|
|00002d50| 72 62 72 6f 74 68 65 72 | 20 3d 20 70 32 3b 0a 09 |rbrother| = p2;..|
|00002d60| 09 09 09 70 32 2d 3e 72 | 62 72 6f 74 68 65 72 20 |...p2->r|brother |
|00002d70| 3d 20 70 70 3b 0a 09 09 | 09 09 69 66 20 28 70 31 |= pp;...|..if (p1|
|00002d80| 20 21 3d 20 4e 55 4c 4c | 29 0a 09 09 09 09 09 70 | != NULL|)......p|
|00002d90| 31 2d 3e 72 62 72 6f 74 | 68 65 72 20 3d 20 70 33 |1->rbrot|her = p3|
|00002da0| 3b 0a 09 09 09 09 65 6c | 73 65 0a 09 09 09 09 09 |;.....el|se......|
|00002db0| 74 2d 3e 6c 73 6f 6e 20 | 3d 20 70 33 3b 0a 09 09 |t->lson |= p3;...|
|00002dc0| 09 09 2f 2a 20 65 78 63 | 68 61 6e 67 65 20 74 68 |../* exc|hange th|
|00002dd0| 65 20 76 61 6c 75 65 73 | 20 6f 66 20 70 32 20 61 |e values| of p2 a|
|00002de0| 6e 64 20 70 33 20 2a 2f | 0a 09 09 09 09 70 70 20 |nd p3 */|.....pp |
|00002df0| 3d 20 70 32 3b 0a 09 09 | 09 09 70 32 20 3d 20 70 |= p2;...|..p2 = p|
|00002e00| 33 3b 0a 09 09 09 09 70 | 33 20 3d 20 70 70 3b 0a |3;.....p|3 = pp;.|
|00002e10| 09 09 09 09 7d 0a 09 09 | 09 7d 0a 09 7d 0a 0a 2f |....}...|.}..}../|
|00002e20| 2a 20 63 61 6c 63 75 6c | 61 74 65 20 74 68 65 20 |* calcul|ate the |
|00002e30| 70 72 69 6e 74 20 6c 6f | 63 61 74 69 6f 6e 20 2a |print lo|cation *|
|00002e40| 2f 0a 76 6f 69 64 20 63 | 61 6c 63 5f 6c 6f 63 28 |/.void c|alc_loc(|
|00002e50| 74 29 0a 09 73 74 72 75 | 63 74 20 6e 6f 64 65 09 |t)..stru|ct node.|
|00002e60| 2a 74 3b 0a 09 7b 0a 09 | 75 6e 73 69 67 6e 65 64 |*t;..{..|unsigned|
|00002e70| 20 6c 6f 6e 67 09 63 73 | 3b 09 09 2f 2a 20 73 63 | long.cs|;../* sc|
|00002e80| 72 61 74 63 68 20 2a 2f | 0a 09 73 74 72 75 63 74 |ratch */|..struct|
|00002e90| 20 6e 6f 64 65 09 2a 74 | 31 2c 20 2a 74 32 3b 09 | node.*t|1, *t2;.|
|00002ea0| 2f 2a 20 73 63 72 61 74 | 63 68 20 70 6f 69 6e 74 |/* scrat|ch point|
|00002eb0| 65 72 73 20 2a 2f 0a 09 | 69 6e 74 09 09 09 70 72 |ers */..|int...pr|
|00002ec0| 69 6e 74 5f 6c 69 6d 69 | 74 3b 0a 09 09 09 09 09 |int_limi|t;......|
|00002ed0| 09 2f 2a 20 6c 6f 63 61 | 74 69 6f 6e 20 6e 65 78 |./* loca|tion nex|
|00002ee0| 74 20 64 69 72 65 63 74 | 6f 72 79 20 61 66 74 65 |t direct|ory afte|
|00002ef0| 72 20 74 20 77 69 6c 6c | 0a 09 09 09 09 09 09 20 |r t will|....... |
|00002f00| 2a 20 62 65 20 70 72 69 | 6e 74 65 64 20 2a 2f 0a |* be pri|nted */.|
|00002f10| 0a 09 69 66 20 28 74 20 | 3d 3d 20 72 6f 6f 74 29 |..if (t |== root)|
|00002f20| 0a 09 09 63 73 20 3d 20 | 30 3b 0a 09 65 6c 73 65 |...cs = |0;..else|
|00002f30| 0a 09 09 7b 0a 09 09 2f | 2a 20 66 69 67 75 72 65 |...{.../|* figure|
|00002f40| 20 6f 75 74 20 68 6f 77 | 20 6d 75 63 68 20 69 73 | out how| much is|
|00002f50| 20 69 6e 20 74 68 65 20 | 64 69 72 65 63 74 6f 72 | in the |director|
|00002f60| 79 20 69 74 73 65 6c 66 | 20 2a 2f 0a 09 09 66 6f |y itself| */...fo|
|00002f70| 72 20 28 74 31 20 3d 20 | 74 2d 3e 6c 73 6f 6e 2c |r (t1 = |t->lson,|
|00002f80| 20 63 73 20 3d 20 30 3b | 20 74 31 20 21 3d 20 4e | cs = 0;| t1 != N|
|00002f90| 55 4c 4c 3b 20 74 31 20 | 3d 20 74 31 2d 3e 72 62 |ULL; t1 |= t1->rb|
|00002fa0| 72 6f 74 68 65 72 29 0a | 09 09 09 7b 0a 09 09 09 |rother).|...{....|
|00002fb0| 63 73 20 2b 3d 20 74 31 | 2d 3e 73 69 7a 65 3b 0a |cs += t1|->size;.|
|00002fc0| 09 09 09 7d 0a 09 09 2f | 2a 20 63 73 20 69 73 20 |...}.../|* cs is |
|00002fd0| 74 68 65 20 73 69 7a 65 | 20 61 63 63 6f 75 6e 74 |the size| account|
|00002fe0| 65 64 20 66 6f 72 20 62 | 79 20 73 75 62 64 69 72 |ed for b|y subdir|
|00002ff0| 65 63 74 6f 72 69 65 73 | 20 2a 2f 0a 09 09 63 73 |ectories| */...cs|
|00003000| 20 3d 20 74 2d 3e 73 69 | 7a 65 20 2d 20 63 73 3b | = t->si|ze - cs;|
|00003010| 0a 09 09 7d 0a 09 2f 2a | 20 63 73 20 69 73 20 74 |...}../*| cs is t|
|00003020| 68 65 20 73 69 7a 65 20 | 6f 66 20 74 68 65 20 66 |he size |of the f|
|00003030| 69 6c 65 73 20 69 6e 20 | 74 68 65 20 64 69 72 65 |iles in |the dire|
|00003040| 63 74 6f 72 79 20 69 74 | 73 65 6c 66 20 2a 2f 0a |ctory it|self */.|
|00003050| 09 2f 2a 20 63 6f 6e 76 | 65 72 74 20 63 73 20 74 |./* conv|ert cs t|
|00003060| 6f 20 6c 69 6e 65 73 20 | 2a 2f 0a 09 63 73 20 3d |o lines |*/..cs =|
|00003070| 20 63 73 2a 6c 65 6e 67 | 74 68 2f 74 6f 74 61 6c | cs*leng|th/total|
|00003080| 5f 73 69 7a 65 20 2b 20 | 74 2d 3e 6c 6f 63 3b 0a |_size + |t->loc;.|
|00003090| 09 2f 2a 20 63 61 6c 63 | 75 6c 61 74 65 20 77 68 |./* calc|ulate wh|
|000030a0| 65 72 65 20 6e 65 78 74 | 20 64 69 72 65 63 74 6f |ere next| directo|
|000030b0| 72 79 20 61 66 74 65 72 | 20 74 20 77 69 6c 6c 20 |ry after| t will |
|000030c0| 62 65 20 2a 2f 0a 09 70 | 72 69 6e 74 5f 6c 69 6d |be */..p|rint_lim|
|000030d0| 69 74 20 3d 20 74 2d 3e | 70 72 69 6e 74 5f 6c 69 |it = t->|print_li|
|000030e0| 6d 69 74 3b 0a 09 2f 2a | 20 61 73 73 69 67 6e 20 |mit;../*| assign |
|000030f0| 6c 6f 63 61 74 69 6f 6e | 73 20 2a 2f 0a 09 66 6f |location|s */..fo|
|00003100| 72 20 28 74 31 20 3d 20 | 74 2d 3e 6c 73 6f 6e 2c |r (t1 = |t->lson,|
|00003110| 20 74 32 20 3d 20 4e 55 | 4c 4c 3b 20 74 31 20 21 | t2 = NU|LL; t1 !|
|00003120| 3d 20 4e 55 4c 4c 3b 20 | 74 32 20 3d 20 74 31 2c |= NULL; |t2 = t1,|
|00003130| 20 74 31 20 3d 20 74 31 | 2d 3e 72 62 72 6f 74 68 | t1 = t1|->rbroth|
|00003140| 65 72 29 0a 09 09 7b 0a | 09 09 2f 2a 20 6d 61 6b |er)...{.|../* mak|
|00003150| 65 20 73 75 72 65 20 77 | 65 20 64 6f 6e 27 74 20 |e sure w|e don't |
|00003160| 72 75 6e 20 69 6e 74 6f | 20 6e 65 78 74 20 64 69 |run into| next di|
|00003170| 72 65 63 74 6f 72 79 20 | 2a 2f 0a 09 09 69 66 20 |rectory |*/...if |
|00003180| 28 63 73 20 3e 3d 20 70 | 72 69 6e 74 5f 6c 69 6d |(cs >= p|rint_lim|
|00003190| 69 74 29 0a 09 09 09 7b | 0a 09 09 09 63 73 20 3d |it)....{|....cs =|
|000031a0| 20 70 72 69 6e 74 5f 6c | 69 6d 69 74 2d 31 3b 0a | print_l|imit-1;.|
|000031b0| 09 09 09 7d 0a 09 09 74 | 31 2d 3e 6c 6f 63 20 3d |...}...t|1->loc =|
|000031c0| 20 63 73 3b 0a 09 09 69 | 66 20 28 74 32 20 21 3d | cs;...i|f (t2 !=|
|000031d0| 20 4e 55 4c 4c 29 0a 09 | 09 09 74 32 2d 3e 70 72 | NULL)..|..t2->pr|
|000031e0| 69 6e 74 5f 6c 69 6d 69 | 74 20 3d 20 63 73 3b 0a |int_limi|t = cs;.|
|000031f0| 09 09 63 73 20 2b 3d 20 | 74 31 2d 3e 73 69 7a 65 |..cs += |t1->size|
|00003200| 2a 6c 65 6e 67 74 68 2f | 74 6f 74 61 6c 5f 73 69 |*length/|total_si|
|00003210| 7a 65 3b 0a 09 09 7d 0a | 09 69 66 20 28 74 32 20 |ze;...}.|.if (t2 |
|00003220| 21 3d 20 4e 55 4c 4c 29 | 0a 09 09 74 32 2d 3e 70 |!= NULL)|...t2->p|
|00003230| 72 69 6e 74 5f 6c 69 6d | 69 74 20 3d 20 70 72 69 |rint_lim|it = pri|
|00003240| 6e 74 5f 6c 69 6d 69 74 | 3b 0a 09 7d 0a 0a 2f 2a |nt_limit|;..}../*|
|00003250| 20 66 69 67 75 72 65 20 | 6f 75 74 20 77 68 69 63 | figure |out whic|
|00003260| 68 20 64 69 72 65 63 74 | 6f 72 69 65 73 20 74 6f |h direct|ories to|
|00003270| 20 62 6c 61 6e 6b 20 6f | 75 74 20 2a 2f 0a 76 6f | blank o|ut */.vo|
|00003280| 69 64 20 62 6c 61 6e 6b | 28 74 29 0a 09 73 74 72 |id blank|(t)..str|
|00003290| 75 63 74 20 6e 6f 64 65 | 09 2a 74 3b 0a 09 7b 0a |uct node|.*t;..{.|
|000032a0| 09 73 74 72 75 63 74 20 | 6e 6f 64 65 09 2a 74 31 |.struct |node.*t1|
|000032b0| 2c 20 2a 74 32 2c 20 2a | 74 33 3b 09 09 2f 2a 20 |, *t2, *|t3;../* |
|000032c0| 6c 6f 6f 70 20 70 6f 69 | 6e 74 65 72 73 20 2a 2f |loop poi|nters */|
|000032d0| 0a 0a 09 2f 2a 20 72 65 | 74 75 72 6e 20 69 66 20 |.../* re|turn if |
|000032e0| 74 68 65 72 65 20 61 72 | 65 6e 27 74 20 61 74 20 |there ar|en't at |
|000032f0| 6c 65 61 73 74 20 74 77 | 6f 20 73 6f 6e 73 20 2a |least tw|o sons *|
|00003300| 2f 0a 09 69 66 20 28 74 | 2d 3e 6c 73 6f 6e 20 3d |/..if (t|->lson =|
|00003310| 3d 20 4e 55 4c 4c 20 7c | 7c 20 74 2d 3e 6c 73 6f |= NULL ||| t->lso|
|00003320| 6e 2d 3e 72 62 72 6f 74 | 68 65 72 20 3d 3d 20 4e |n->rbrot|her == N|
|00003330| 55 4c 4c 29 0a 09 09 72 | 65 74 75 72 6e 3b 0a 09 |ULL)...r|eturn;..|
|00003340| 66 6f 72 20 28 74 31 20 | 3d 20 4e 55 4c 4c 2c 20 |for (t1 |= NULL, |
|00003350| 74 32 20 3d 20 74 2d 3e | 6c 73 6f 6e 2c 20 74 33 |t2 = t->|lson, t3|
|00003360| 20 3d 20 74 32 2d 3e 72 | 62 72 6f 74 68 65 72 3b | = t2->r|brother;|
|00003370| 20 74 33 20 21 3d 20 4e | 55 4c 4c 3b 0a 09 09 09 | t3 != N|ULL;....|
|00003380| 74 31 20 3d 20 74 32 2c | 20 74 32 20 3d 20 74 33 |t1 = t2,| t2 = t3|
|00003390| 2c 20 74 33 20 3d 20 74 | 33 2d 3e 72 62 72 6f 74 |, t3 = t|3->rbrot|
|000033a0| 68 65 72 29 0a 09 09 69 | 66 20 28 74 32 2d 3e 6c |her)...i|f (t2->l|
|000033b0| 6f 63 20 3d 3d 20 74 33 | 2d 3e 6c 6f 63 29 0a 09 |oc == t3|->loc)..|
|000033c0| 09 09 7b 0a 09 09 09 2f | 2a 20 72 65 70 6c 61 63 |..{..../|* replac|
|000033d0| 65 20 74 31 20 61 6e 64 | 20 73 75 63 63 65 65 64 |e t1 and| succeed|
|000033e0| 69 6e 67 20 6e 6f 64 65 | 73 20 77 69 74 68 20 22 |ing node|s with "|
|000033f0| 28 65 74 63 2e 29 22 20 | 2a 2f 0a 09 09 09 74 33 |(etc.)" |*/....t3|
|00003400| 20 3d 20 28 73 74 72 75 | 63 74 20 6e 6f 64 65 20 | = (stru|ct node |
|00003410| 2a 29 6d 61 6c 6c 6f 63 | 28 73 69 7a 65 6f 66 20 |*)malloc|(sizeof |
|00003420| 28 73 74 72 75 63 74 20 | 6e 6f 64 65 29 20 2b 0a |(struct |node) +.|
|00003430| 09 09 09 09 73 69 7a 65 | 6f 66 20 28 53 55 50 50 |....size|of (SUPP|
|00003440| 52 45 53 53 45 44 29 20 | 2d 20 31 29 3b 0a 09 09 |RESSED) |- 1);...|
|00003450| 09 73 74 72 63 70 79 28 | 74 33 2d 3e 6e 61 6d 65 |.strcpy(|t3->name|
|00003460| 2c 20 53 55 50 50 52 45 | 53 53 45 44 29 3b 0a 09 |, SUPPRE|SSED);..|
|00003470| 09 09 74 33 2d 3e 6c 73 | 6f 6e 20 3d 20 74 33 2d |..t3->ls|on = t3-|
|00003480| 3e 72 62 72 6f 74 68 65 | 72 20 3d 20 4e 55 4c 4c |>rbrothe|r = NULL|
|00003490| 3b 0a 09 09 09 74 33 2d | 3e 6c 6f 63 20 3d 20 74 |;....t3-|>loc = t|
|000034a0| 32 2d 3e 6c 6f 63 3b 0a | 09 09 09 69 66 20 28 74 |2->loc;.|...if (t|
|000034b0| 31 20 3d 3d 20 4e 55 4c | 4c 29 0a 09 09 09 09 74 |1 == NUL|L).....t|
|000034c0| 2d 3e 6c 73 6f 6e 20 3d | 20 74 33 3b 0a 09 09 09 |->lson =| t3;....|
|000034d0| 65 6c 73 65 0a 09 09 09 | 09 74 31 2d 3e 72 62 72 |else....|.t1->rbr|
|000034e0| 6f 74 68 65 72 20 3d 20 | 74 33 3b 0a 09 09 09 7d |other = |t3;....}|
|000034f0| 0a 09 7d 0a 0a 2f 2a 20 | 6d 61 72 6b 20 74 68 65 |..}../* |mark the|
|00003500| 20 6c 61 73 74 20 73 6f | 6e 20 6f 66 20 65 61 63 | last so|n of eac|
|00003510| 68 20 64 69 72 65 63 74 | 6f 72 79 20 2a 2f 0a 76 |h direct|ory */.v|
|00003520| 6f 69 64 20 6d 61 72 6b | 5f 6c 61 73 74 28 74 29 |oid mark|_last(t)|
|00003530| 0a 09 73 74 72 75 63 74 | 20 6e 6f 64 65 09 2a 74 |..struct| node.*t|
|00003540| 3b 0a 09 7b 0a 09 73 74 | 72 75 63 74 20 6e 6f 64 |;..{..st|ruct nod|
|00003550| 65 09 2a 74 31 2c 20 2a | 74 32 3b 09 2f 2a 20 73 |e.*t1, *|t2;./* s|
|00003560| 63 72 61 74 63 68 20 70 | 6f 69 6e 74 65 72 73 20 |cratch p|ointers |
|00003570| 2a 2f 0a 09 74 2d 3e 6c | 61 73 74 20 3d 20 30 3b |*/..t->l|ast = 0;|
|00003580| 0a 09 66 6f 72 20 28 74 | 31 20 3d 20 74 2d 3e 6c |..for (t|1 = t->l|
|00003590| 73 6f 6e 2c 20 74 32 20 | 3d 20 4e 55 4c 4c 3b 20 |son, t2 |= NULL; |
|000035a0| 74 31 20 21 3d 20 4e 55 | 4c 4c 3b 20 74 32 20 3d |t1 != NU|LL; t2 =|
|000035b0| 20 74 31 2c 20 74 31 20 | 3d 20 74 31 2d 3e 72 62 | t1, t1 |= t1->rb|
|000035c0| 72 6f 74 68 65 72 29 0a | 09 09 3b 0a 09 69 66 20 |rother).|..;..if |
|000035d0| 28 74 32 20 21 3d 20 4e | 55 4c 4c 29 0a 09 09 74 |(t2 != N|ULL)...t|
|000035e0| 32 2d 3e 6c 61 73 74 20 | 3d 20 31 3b 0a 09 7d 0a |2->last |= 1;..}.|
|000035f0| 0a 2f 2a 20 63 61 6c 63 | 75 6c 61 74 65 20 74 68 |./* calc|ulate th|
|00003600| 65 20 70 72 69 6e 74 20 | 63 6f 6c 75 6d 6e 73 20 |e print |columns |
|00003610| 2a 2f 0a 76 6f 69 64 20 | 63 61 6c 63 5f 70 63 28 |*/.void |calc_pc(|
|00003620| 74 29 0a 09 73 74 72 75 | 63 74 20 6e 6f 64 65 09 |t)..stru|ct node.|
|00003630| 2a 74 3b 0a 09 7b 0a 09 | 73 74 72 75 63 74 20 6e |*t;..{..|struct n|
|00003640| 6f 64 65 09 2a 74 31 3b | 09 09 2f 2a 20 73 63 72 |ode.*t1;|../* scr|
|00003650| 61 74 63 68 20 70 6f 69 | 6e 74 65 72 20 2a 2f 0a |atch poi|nter */.|
|00003660| 09 69 6e 74 09 09 09 63 | 3b 09 09 2f 2a 20 63 6f |.int...c|;../* co|
|00003670| 6c 75 6d 6e 20 73 75 6e | 73 20 77 69 6c 6c 20 62 |lumn sun|s will b|
|00003680| 65 20 70 72 69 6e 74 65 | 64 20 69 6e 20 2a 2f 0a |e printe|d in */.|
|00003690| 0a 09 63 20 3d 20 74 2d | 3e 70 72 69 6e 74 5f 63 |..c = t-|>print_c|
|000036a0| 6f 6c 20 2b 20 73 74 72 | 6c 65 6e 28 74 2d 3e 6e |ol + str|len(t->n|
|000036b0| 61 6d 65 29 20 2b 20 35 | 3b 0a 09 66 6f 72 20 28 |ame) + 5|;..for (|
|000036c0| 74 31 20 3d 20 74 2d 3e | 6c 73 6f 6e 3b 20 74 31 |t1 = t->|lson; t1|
|000036d0| 20 21 3d 20 4e 55 4c 4c | 3b 20 74 31 20 3d 20 74 | != NULL|; t1 = t|
|000036e0| 31 2d 3e 72 62 72 6f 74 | 68 65 72 29 09 0a 09 09 |1->rbrot|her)....|
|000036f0| 74 31 2d 3e 70 72 69 6e | 74 5f 63 6f 6c 20 3d 20 |t1->prin|t_col = |
|00003700| 63 3b 0a 09 7d 0a 0a 2f | 2a 20 77 72 69 74 65 20 |c;..}../|* write |
|00003710| 74 68 65 20 6f 75 74 70 | 75 74 20 2a 2f 0a 76 6f |the outp|ut */.vo|
|00003720| 69 64 20 6f 75 74 70 75 | 74 28 74 29 0a 09 73 74 |id outpu|t(t)..st|
|00003730| 72 75 63 74 20 6e 6f 64 | 65 09 2a 74 3b 0a 09 7b |ruct nod|e.*t;..{|
|00003740| 0a 09 70 6f 73 69 74 69 | 6f 6e 28 74 2d 3e 6c 6f |..positi|on(t->lo|
|00003750| 63 29 3b 0a 09 70 72 69 | 6e 74 66 28 22 2d 2d 25 |c);..pri|ntf("--%|
|00003760| 73 25 73 22 2c 20 74 2d | 3e 6e 61 6d 65 2c 20 28 |s%s", t-|>name, (|
|00003770| 74 2d 3e 6c 73 6f 6e 20 | 21 3d 20 4e 55 4c 4c 20 |t->lson |!= NULL |
|00003780| 3f 20 22 2d 2d 2b 22 20 | 3a 20 22 22 29 29 3b 0a |? "--+" |: ""));.|
|00003790| 09 2f 2a 20 72 65 6d 6f | 76 65 20 74 68 65 20 62 |./* remo|ve the b|
|000037a0| 61 72 20 66 6f 72 20 6f | 75 72 20 66 61 74 68 65 |ar for o|ur fathe|
|000037b0| 72 20 69 66 20 77 65 20 | 61 72 65 20 74 68 65 20 |r if we |are the |
|000037c0| 6c 61 73 74 20 73 6f 6e | 20 2a 2f 0a 09 69 66 20 |last son| */..if |
|000037d0| 28 74 2d 3e 6c 61 73 74 | 29 0a 09 09 62 61 72 5f |(t->last|)...bar_|
|000037e0| 63 6f 75 6e 74 2d 2d 3b | 0a 09 2f 2a 20 61 64 64 |count--;|../* add|
|000037f0| 20 74 68 65 20 6c 6f 63 | 61 74 69 6f 6e 20 6f 66 | the loc|ation of|
|00003800| 20 74 68 65 20 62 61 72 | 20 74 6f 20 74 68 65 20 | the bar| to the |
|00003810| 62 61 72 20 6c 69 73 74 | 20 69 66 20 77 65 20 68 |bar list| if we h|
|00003820| 61 76 65 20 61 20 73 6f | 6e 20 2a 2f 0a 09 69 66 |ave a so|n */..if|
|00003830| 20 28 74 2d 3e 6c 73 6f | 6e 20 21 3d 20 4e 55 4c | (t->lso|n != NUL|
|00003840| 4c 29 0a 09 09 7b 0a 09 | 09 62 61 72 5f 6c 69 73 |L)...{..|.bar_lis|
|00003850| 74 5b 62 61 72 5f 63 6f | 75 6e 74 5d 20 3d 20 74 |t[bar_co|unt] = t|
|00003860| 2d 3e 70 72 69 6e 74 5f | 63 6f 6c 20 2b 20 73 74 |->print_|col + st|
|00003870| 72 6c 65 6e 28 74 2d 3e | 6e 61 6d 65 29 20 2b 20 |rlen(t->|name) + |
|00003880| 35 20 2d 20 31 3b 0a 09 | 09 62 61 72 5f 63 6f 75 |5 - 1;..|.bar_cou|
|00003890| 6e 74 2b 2b 3b 0a 09 09 | 7d 0a 09 7d 0a 0a 2f 2a |nt++;...|}..}../*|
|000038a0| 20 70 6f 73 69 74 69 6f | 6e 20 74 6f 20 61 20 73 | positio|n to a s|
|000038b0| 70 65 63 69 66 69 63 20 | 6c 69 6e 65 20 2a 2f 0a |pecific |line */.|
|000038c0| 76 6f 69 64 20 70 6f 73 | 69 74 69 6f 6e 28 6c 69 |void pos|ition(li|
|000038d0| 6e 65 29 0a 09 69 6e 74 | 09 6c 69 6e 65 3b 09 09 |ne)..int|.line;..|
|000038e0| 2f 2a 20 6c 69 6e 65 20 | 6e 75 6d 62 65 72 20 2a |/* line |number *|
|000038f0| 2f 0a 09 7b 0a 09 69 6e | 74 09 69 3b 09 09 09 2f |/..{..in|t.i;.../|
|00003900| 2a 20 63 6f 75 6e 74 73 | 20 74 68 72 6f 75 67 68 |* counts| through|
|00003910| 20 74 68 65 20 62 61 72 | 20 6c 69 73 74 20 2a 2f | the bar| list */|
|00003920| 0a 09 69 6e 74 09 6a 3b | 09 09 09 2f 2a 20 63 75 |..int.j;|.../* cu|
|00003930| 72 72 65 6e 74 20 63 6f | 6c 75 6d 6e 20 6e 75 6d |rrent co|lumn num|
|00003940| 62 65 72 20 2a 2f 0a 0a | 09 2f 2a 20 66 6f 72 20 |ber */..|./* for |
|00003950| 65 76 65 72 79 20 6c 69 | 6e 65 20 77 65 20 6e 65 |every li|ne we ne|
|00003960| 65 64 20 74 6f 20 67 6f | 20 64 6f 77 6e 20 2a 2f |ed to go| down */|
|00003970| 0a 09 66 6f 72 20 28 3b | 20 63 75 72 72 65 6e 74 |..for (;| current|
|00003980| 5f 6c 69 6e 65 20 3c 20 | 6c 69 6e 65 3b 20 63 75 |_line < |line; cu|
|00003990| 72 72 65 6e 74 5f 6c 69 | 6e 65 2b 2b 29 0a 09 09 |rrent_li|ne++)...|
|000039a0| 7b 0a 09 09 70 75 74 63 | 68 61 72 28 27 5c 6e 27 |{...putc|har('\n'|
|000039b0| 29 3b 0a 09 09 2f 2a 20 | 70 72 69 6e 74 20 74 68 |);.../* |print th|
|000039c0| 65 20 62 61 72 73 20 66 | 6f 72 20 74 68 69 73 20 |e bars f|or this |
|000039d0| 6c 69 6e 65 20 2a 2f 0a | 09 09 6a 20 3d 20 30 3b |line */.|..j = 0;|
|000039e0| 0a 09 09 66 6f 72 20 28 | 69 20 3d 20 30 3b 20 69 |...for (|i = 0; i|
|000039f0| 20 3c 20 62 61 72 5f 63 | 6f 75 6e 74 3b 20 69 2b | < bar_c|ount; i+|
|00003a00| 2b 29 0a 09 09 09 7b 0a | 09 09 09 66 6f 72 20 28 |+)....{.|...for (|
|00003a10| 3b 20 6a 20 3c 20 62 61 | 72 5f 6c 69 73 74 5b 69 |; j < ba|r_list[i|
|00003a20| 5d 3b 20 6a 2b 2b 29 0a | 09 09 09 09 70 75 74 63 |]; j++).|....putc|
|00003a30| 68 61 72 28 27 20 27 29 | 3b 0a 09 09 09 69 66 20 |har(' ')|;....if |
|00003a40| 28 63 75 72 72 65 6e 74 | 5f 6c 69 6e 65 20 3d 3d |(current|_line ==|
|00003a50| 20 6c 69 6e 65 2d 31 20 | 26 26 20 69 20 3d 3d 20 | line-1 |&& i == |
|00003a60| 62 61 72 5f 63 6f 75 6e | 74 2d 31 29 0a 09 09 09 |bar_coun|t-1)....|
|00003a70| 09 70 75 74 63 68 61 72 | 28 27 2b 27 29 3b 0a 09 |.putchar|('+');..|
|00003a80| 09 09 65 6c 73 65 0a 09 | 09 09 09 70 75 74 63 68 |..else..|...putch|
|00003a90| 61 72 28 27 7c 27 29 3b | 0a 09 09 09 6a 2b 2b 3b |ar('|');|....j++;|
|00003aa0| 0a 09 09 09 7d 0a 09 09 | 7d 0a 09 7d 0a 23 69 66 |....}...|}..}.#if|
|00003ab0| 20 30 0a 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d | 0.-----|--------|
|00003ac0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00003ad0| 2d 2d 2d 2d 2d 2d 65 78 | 61 6d 70 6c 65 2d 2d 2d |------ex|ample---|
|00003ae0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00003af0| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00003b00| 0a 2d 2d 2e 2d 2d 2b 0a | 20 20 20 20 20 7c 0a 20 |.--.--+.| |. |
|00003b10| 20 20 20 20 7c 0a 20 20 | 20 20 20 7c 0a 20 20 20 | |. | |. |
|00003b20| 20 20 7c 0a 20 20 20 20 | 20 7c 0a 20 20 20 20 20 | |. | |. |
|00003b30| 7c 0a 20 20 20 20 20 7c | 0a 20 20 20 20 20 2b 2d ||. ||. +-|
|00003b40| 2d 73 63 70 70 2d 2d 2b | 2d 2d 66 74 70 73 2d 2d |-scpp--+|--ftps--|
|00003b50| 2b 0a 20 20 20 20 20 7c | 20 20 20 20 20 20 20 20 |+. || |
|00003b60| 7c 20 20 20 20 20 20 20 | 20 2b 2d 2d 73 63 70 70 || | +--scpp|
|00003b70| 2d 2d 2b 2d 2d 74 65 6d | 70 0a 20 20 20 20 20 7c |--+--tem|p. ||
|00003b80| 20 20 20 20 20 20 20 20 | 2b 2d 2d 65 72 72 6f 72 | |+--error|
|00003b90| 0a 20 20 20 20 20 7c 20 | 20 20 20 20 20 20 20 7c |. | | ||
|00003ba0| 0a 20 20 20 20 20 7c 20 | 20 20 20 20 20 20 20 2b |. | | +|
|00003bb0| 2d 2d 73 68 61 72 2d 2d | 2b 0a 20 20 20 20 20 7c |--shar--|+. ||
|00003bc0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00003bd0| 20 7c 0a 20 20 20 20 20 | 7c 20 20 20 20 20 20 20 | |. || |
|00003be0| 20 20 20 20 20 20 20 20 | 20 20 2b 2d 2d 74 65 6d | | +--tem|
|00003bf0| 70 0a 20 20 20 20 20 2b | 2d 2d 75 65 6d 61 63 73 |p. +|--uemacs|
|00003c00| 2d 2d 2b 2d 2d 75 65 6d | 61 63 73 33 2e 39 0a 20 |--+--uem|acs3.9. |
|00003c10| 20 20 20 20 7c 0a 20 20 | 20 20 20 7c 0a 20 20 20 | |. | |. |
|00003c20| 20 20 7c 0a 20 20 20 20 | 20 7c 0a 20 20 20 20 20 | |. | |. |
|00003c30| 7c 0a 20 20 20 20 20 7c | 0a 20 20 20 20 20 2b 2d ||. ||. +-|
|00003c40| 2d 70 61 74 63 68 2d 2d | 2b 2d 2d 64 69 73 74 0a |-patch--|+--dist.|
|00003c50| 20 20 20 20 20 7c 20 20 | 20 20 20 20 20 20 20 7c | | | ||
|00003c60| 0a 20 20 20 20 20 7c 20 | 20 20 20 20 20 20 20 20 |. | | |
|00003c70| 7c 0a 20 20 20 20 20 7c | 20 20 20 20 20 20 20 20 ||. || |
|00003c80| 20 2b 2d 2d 62 75 69 6c | 64 0a 20 20 20 20 20 7c | +--buil|d. ||
|00003c90| 0a 20 20 20 20 20 7c 0a | 20 20 20 20 20 7c 0a 20 |. |.| |. |
|00003ca0| 20 20 20 20 2b 2d 2d 73 | 63 63 73 2d 2d 2b 2d 2d | +--s|ccs--+--|
|00003cb0| 61 6c 6c 0a 20 20 20 20 | 20 7c 20 20 20 20 20 20 |all. | | |
|00003cc0| 20 20 7c 0a 20 20 20 20 | 20 7c 20 20 20 20 20 20 | |. | | |
|00003cd0| 20 20 7c 0a 20 20 20 20 | 20 7c 20 20 20 20 20 20 | |. | | |
|00003ce0| 20 20 7c 0a 20 20 20 20 | 20 7c 20 20 20 20 20 20 | |. | | |
|00003cf0| 20 20 2b 2d 2d 28 65 74 | 63 2e 29 0a 20 20 20 20 | +--(et|c.). |
|00003d00| 20 2b 2d 2d 79 61 63 63 | 74 65 73 74 0a 20 20 20 | +--yacc|test. |
|00003d10| 20 20 7c 0a 20 20 20 20 | 20 7c 0a 20 20 20 20 20 | |. | |. |
|00003d20| 7c 0a 20 20 20 20 20 2b | 2d 2d 79 61 63 63 0a 20 ||. +|--yacc. |
|00003d30| 20 20 20 20 7c 0a 20 20 | 20 20 20 7c 0a 20 20 20 | |. | |. |
|00003d40| 20 20 7c 0a 20 20 20 20 | 20 2b 2d 2d 72 6e 73 65 | |. | +--rnse|
|00003d50| 6e 64 2d 2d 2b 2d 2d 64 | 69 73 74 31 0a 20 20 20 |nd--+--d|ist1. |
|00003d60| 20 20 7c 20 20 20 20 20 | 20 20 20 20 20 2b 2d 2d | | | +--|
|00003d70| 64 69 73 74 33 0a 20 20 | 20 20 20 7c 20 20 20 20 |dist3. | | |
|00003d80| 20 20 20 20 20 20 2b 2d | 2d 64 69 73 74 32 0a 20 | +-|-dist2. |
|00003d90| 20 20 20 20 2b 2d 2d 62 | 69 6e 2d 2d 2b 0a 20 20 | +--b|in--+. |
|00003da0| 20 20 20 7c 20 20 20 20 | 20 20 20 2b 2d 2d 73 6f | | | +--so|
|00003db0| 75 72 63 65 0a 20 20 20 | 20 20 2b 2d 2d 73 6f 75 |urce. | +--sou|
|00003dc0| 72 63 65 73 0a 20 20 20 | 20 20 7c 0a 20 20 20 20 |rces. | |. |
|00003dd0| 20 2b 2d 2d 6b 77 66 72 | 6f 62 0a 20 20 20 20 20 | +--kwfr|ob. |
|00003de0| 2b 2d 2d 72 73 74 73 2e | 74 61 70 65 0a 20 20 20 |+--rsts.|tape. |
|00003df0| 20 20 2b 2d 2d 72 6e 65 | 77 73 0a 20 20 20 20 20 | +--rne|ws. |
|00003e00| 2b 2d 2d 66 74 70 2d 73 | 65 72 76 65 72 0a 20 20 |+--ftp-s|erver. |
|00003e10| 20 20 20 2b 2d 2d 28 65 | 74 63 2e 29 0a 0a 0a 0a | +--(e|tc.)....|
|00003e20| 0a 0a 0a 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |...-----|--------|
|00003e30| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00003e40| 2d 65 6e 64 20 6f 66 20 | 65 78 61 6d 70 6c 65 2d |-end of |example-|
|00003e50| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00003e60| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 0a 2d 2d |--------|-----.--|
|00003e70| 20 0a 44 61 6c 65 20 57 | 6f 72 6c 65 79 20 20 20 | .Dale W|orley |
|00003e80| 20 43 75 6c 6c 69 6e 65 | 74 20 53 6f 66 74 77 61 | Culline|t Softwa|
|00003e90| 72 65 20 20 20 20 20 20 | 41 52 50 41 3a 20 63 75 |re |ARPA: cu|
|00003ea0| 6c 64 65 76 31 21 64 72 | 77 40 65 64 64 69 65 2e |ldev1!dr|w@eddie.|
|00003eb0| 6d 69 74 2e 65 64 75 0a | 55 55 43 50 3a 20 2e 2e |mit.edu.|UUCP: ..|
|00003ec0| 2e 21 73 65 69 73 6d 6f | 21 68 61 72 76 61 72 64 |.!seismo|!harvard|
|00003ed0| 21 6d 69 74 2d 65 64 64 | 69 65 21 63 75 6c 64 65 |!mit-edd|ie!culde|
|00003ee0| 76 31 21 64 72 77 0a 4e | 6f 74 68 69 6e 67 20 73 |v1!drw.N|othing s|
|00003ef0| 68 6f 63 6b 73 20 6d 65 | 20 2d 2d 20 49 27 6d 20 |hocks me| -- I'm |
|00003f00| 61 20 73 63 69 65 6e 74 | 69 73 74 2e 0a 23 65 6e |a scient|ist..#en|
|00003f10| 64 69 66 0a 0a 0a 2f 2a | 20 62 65 67 69 6e 20 6f |dif.../*| begin o|
|00003f20| 66 20 6e 65 77 20 63 6f | 64 65 20 61 64 64 65 64 |f new co|de added|
|00003f30| 20 62 79 20 64 65 6e 6e | 69 73 20 62 65 64 6e 61 | by denn|is bedna|
|00003f40| 72 20 2a 2f 0a 2f 2a 0a | 20 2a 20 50 72 69 6e 74 |r */./*.| * Print|
|00003f50| 20 74 68 65 20 66 75 6c | 6c 20 6e 61 6d 65 20 61 | the ful|l name a|
|00003f60| 73 73 6f 63 69 61 74 65 | 64 20 77 69 74 68 20 74 |ssociate|d with t|
|00003f70| 68 65 20 70 61 74 68 20 | 74 6f 20 74 68 69 73 20 |he path |to this |
|00003f80| 63 6f 6d 70 6f 6e 65 6e | 74 2e 0a 20 2a 20 53 69 |componen|t.. * Si|
|00003f90| 6e 63 65 20 65 61 63 68 | 20 6e 6f 64 65 20 63 6f |nce each| node co|
|00003fa0| 6e 74 61 69 6e 73 20 6f | 6e 6c 79 20 6f 6e 65 20 |ntains o|nly one |
|00003fb0| 63 6f 6d 70 6f 6e 65 6e | 74 20 6f 66 20 74 68 65 |componen|t of the|
|00003fc0| 20 66 75 6c 6c 20 70 61 | 74 68 20 6e 61 6d 65 2c | full pa|th name,|
|00003fd0| 0a 20 2a 20 69 6e 20 6f | 72 64 65 72 20 74 6f 20 |. * in o|rder to |
|00003fe0| 70 72 69 6e 74 20 6f 75 | 74 20 74 68 65 20 65 6e |print ou|t the en|
|00003ff0| 74 69 72 65 20 6e 61 6d | 65 2c 20 77 65 20 68 61 |tire nam|e, we ha|
|00004000| 76 65 20 74 6f 20 70 72 | 69 6e 74 20 74 68 65 0a |ve to pr|int the.|
|00004010| 20 2a 20 22 66 61 74 68 | 65 72 20 70 61 72 74 20 | * "fath|er part |
|00004020| 6f 66 20 74 68 65 20 63 | 6f 6d 70 6f 6e 65 6e 74 |of the c|omponent|
|00004030| 22 2c 20 66 6f 6c 6c 6f | 77 65 64 20 62 79 20 74 |", follo|wed by t|
|00004040| 68 65 20 63 6f 6d 70 6f | 6e 65 6e 74 2e 0a 20 2a |he compo|nent.. *|
|00004050| 20 54 68 69 73 20 69 73 | 20 77 68 79 20 49 20 69 | This is| why I i|
|00004060| 6e 76 65 6e 74 65 64 20 | 74 68 65 20 22 66 61 74 |nvented |the "fat|
|00004070| 68 65 72 22 20 75 70 20 | 70 6f 69 6e 74 65 72 2e |her" up |pointer.|
|00004080| 0a 20 2a 20 54 68 69 73 | 20 69 73 20 64 6f 6e 65 |. * This| is done|
|00004090| 20 72 65 63 75 72 73 69 | 76 65 6c 79 2c 20 49 20 | recursi|vely, I |
|000040a0| 6d 69 67 68 74 20 61 64 | 64 2e 0a 20 2a 0a 20 2a |might ad|d.. *. *|
|000040b0| 20 74 68 65 20 72 6f 6f | 74 20 69 73 20 61 20 64 | the roo|t is a d|
|000040c0| 75 6d 6d 79 20 68 6f 6c | 64 65 72 2c 20 69 74 20 |ummy hol|der, it |
|000040d0| 63 6f 6e 74 61 69 6e 73 | 20 6e 6f 20 72 65 61 6c |contains| no real|
|000040e0| 20 6e 61 6d 65 2e 0a 20 | 2a 20 54 68 65 20 74 6f | name.. |* The to|
|000040f0| 70 20 6e 6f 64 65 20 77 | 68 69 63 68 20 63 6f 6e |p node w|hich con|
|00004100| 74 61 69 6e 73 20 74 68 | 65 20 66 69 72 73 74 20 |tains th|e first |
|00004110| 72 65 61 6c 20 6e 61 6d | 65 20 77 69 6c 6c 20 68 |real nam|e will h|
|00004120| 61 76 65 0a 20 2a 20 61 | 20 66 61 74 68 65 72 20 |ave. * a| father |
|00004130| 70 6f 69 6e 74 65 72 20 | 74 6f 20 72 6f 6f 74 2e |pointer |to root.|
|00004140| 0a 20 2a 20 52 61 74 68 | 65 72 2c 20 72 6f 6f 74 |. * Rath|er, root|
|00004150| 20 2d 3e 20 6c 73 6f 6e | 20 63 6f 6e 74 61 69 6e | -> lson| contain|
|00004160| 73 20 74 68 65 20 66 69 | 72 73 74 20 72 65 61 6c |s the fi|rst real|
|00004170| 20 72 6f 6f 74 20 6f 66 | 20 74 68 65 20 74 72 65 | root of| the tre|
|00004180| 65 2e 0a 20 2a 20 54 68 | 69 73 20 69 73 20 77 68 |e.. * Th|is is wh|
|00004190| 79 20 72 6f 6f 74 2d 3e | 72 62 72 6f 74 68 65 72 |y root->|rbrother|
|000041a0| 20 69 73 20 4e 55 4c 4c | 2e 0a 20 2a 0a 20 2a 20 | is NULL|.. *. * |
|000041b0| 53 6f 20 64 6f 20 4e 4f | 54 20 70 72 69 6e 74 20 |So do NO|T print |
|000041c0| 74 68 65 20 72 6f 6f 74 | 20 6e 6f 64 65 27 73 20 |the root| node's |
|000041d0| 6e 61 6d 65 2e 0a 20 2a | 20 41 6c 73 6f 2c 20 77 |name.. *| Also, w|
|000041e0| 68 65 6e 20 70 72 69 6e | 74 69 6e 67 20 72 6f 6f |hen prin|ting roo|
|000041f0| 74 2d 3e 6c 73 6f 6e 27 | 73 20 66 61 74 68 65 72 |t->lson'|s father|
|00004200| 2c 20 69 74 20 77 69 6c | 6c 20 62 65 20 22 22 2e |, it wil|l be "".|
|00004210| 0a 20 2a 2f 0a 76 6f 69 | 64 0a 73 68 6f 77 5f 6e |. */.voi|d.show_n|
|00004220| 6f 64 65 28 20 70 20 29 | 0a 09 73 74 72 75 63 74 |ode( p )|..struct|
|00004230| 09 6e 6f 64 65 09 2a 70 | 3b 0a 7b 0a 09 69 66 20 |.node.*p|;.{..if |
|00004240| 28 70 20 3d 3d 20 72 6f | 6f 74 29 09 2f 2a 20 6a |(p == ro|ot)./* j|
|00004250| 75 73 74 20 61 20 70 6c | 61 63 65 68 6f 6c 64 65 |ust a pl|aceholde|
|00004260| 72 2c 20 69 74 73 20 6c | 73 6f 6e 20 69 73 20 74 |r, its l|son is t|
|00004270| 68 65 20 72 65 61 6c 20 | 72 6f 6f 74 20 2a 2f 0a |he real |root */.|
|00004280| 09 09 72 65 74 75 72 6e | 3b 09 2f 2a 20 64 6f 6e |..return|;./* don|
|00004290| 27 74 20 70 72 69 6e 74 | 20 6a 69 62 62 65 72 69 |'t print| jibberi|
|000042a0| 73 68 20 2a 2f 0a 0a 09 | 2f 2a 20 61 76 6f 69 64 |sh */...|/* avoid|
|000042b0| 20 70 72 69 6e 74 69 6e | 67 20 72 6f 6f 74 27 73 | printin|g root's|
|000042c0| 20 6c 73 6f 6e 20 6e 6f | 64 65 20 77 68 6f 73 65 | lson no|de whose|
|000042d0| 20 6e 61 6d 65 20 69 73 | 20 22 22 2e 0a 09 20 2a | name is| ""... *|
|000042e0| 20 54 68 69 73 20 6f 63 | 63 75 72 73 20 77 68 65 | This oc|curs whe|
|000042f0| 6e 20 66 69 72 73 74 20 | 6c 69 6e 65 20 6f 66 20 |n first |line of |
|00004300| 73 74 64 69 6e 20 63 6f | 6e 74 61 69 6e 73 20 61 |stdin co|ntains a|
|00004310| 0a 09 20 2a 20 64 69 72 | 65 63 74 6f 72 79 20 6e |.. * dir|ectory n|
|00004320| 61 6d 65 20 62 65 67 69 | 6e 6e 69 6e 67 20 77 69 |ame begi|nning wi|
|00004330| 74 68 20 61 20 6c 65 61 | 64 69 6e 67 20 2f 2e 0a |th a lea|ding /..|
|00004340| 09 20 2a 20 50 53 2c 20 | 73 69 6e 63 65 20 72 6f |. * PS, |since ro|
|00004350| 6f 74 20 6e 6f 64 65 27 | 73 20 6e 61 6d 65 20 69 |ot node'|s name i|
|00004360| 73 20 61 6c 73 6f 20 22 | 22 2c 20 49 20 70 72 6f |s also "|", I pro|
|00004370| 62 61 62 6c 79 20 63 6f | 75 6c 64 20 72 65 6d 6f |bably co|uld remo|
|00004380| 76 65 0a 09 20 2a 20 74 | 68 65 20 22 69 66 22 20 |ve.. * t|he "if" |
|00004390| 63 68 65 63 6b 20 61 62 | 6f 76 65 2c 20 61 6e 64 |check ab|ove, and|
|000043a0| 20 6c 65 74 20 74 68 69 | 73 20 69 66 20 73 74 6d | let thi|s if stm|
|000043b0| 74 20 64 6f 20 74 68 65 | 20 77 6f 72 6b 20 6f 66 |t do the| work of|
|000043c0| 0a 09 20 2a 20 62 6f 74 | 68 2c 20 62 75 74 20 49 |.. * bot|h, but I|
|000043d0| 20 64 69 64 6e 27 74 20 | 66 65 65 6c 20 6c 69 6b | didn't |feel lik|
|000043e0| 65 20 69 74 2e 0a 09 20 | 2a 2f 0a 09 69 66 20 28 |e it... |*/..if (|
|000043f0| 70 20 2d 3e 20 6e 61 6d | 65 5b 30 5d 20 3d 3d 20 |p -> nam|e[0] == |
|00004400| 27 5c 30 27 29 0a 09 09 | 72 65 74 75 72 6e 3b 0a |'\0')...|return;.|
|00004410| 0a 09 2f 2a 20 61 76 6f | 69 64 20 70 72 69 6e 74 |../* avo|id print|
|00004420| 69 6e 67 20 2f 61 20 61 | 6e 64 20 2f 62 20 77 68 |ing /a a|nd /b wh|
|00004430| 6f 73 65 20 73 69 7a 65 | 20 69 73 20 7a 65 72 6f |ose size| is zero|
|00004440| 2c 20 6a 75 73 74 0a 09 | 20 2a 20 62 65 63 61 75 |, just..| * becau|
|00004450| 73 65 20 77 65 20 64 69 | 64 20 61 20 22 64 75 20 |se we di|d a "du |
|00004460| 2f 61 2f 62 2f 63 20 7c | 20 64 75 6f 6e 6c 79 22 |/a/b/c || duonly"|
|00004470| 2e 0a 09 20 2a 2f 0a 09 | 69 66 20 28 70 20 2d 3e |... */..|if (p ->|
|00004480| 20 6d 65 5f 73 69 7a 65 | 20 3d 3d 20 30 4c 29 0a | me_size| == 0L).|
|00004490| 09 09 72 65 74 75 72 6e | 3b 0a 0a 2f 2a 09 70 72 |..return|;../*.pr|
|000044a0| 69 6e 74 66 28 22 27 25 | 73 27 20 61 6e 64 20 6d |intf("'%|s' and m|
|000044b0| 79 20 66 61 74 68 65 72 | 20 69 73 20 3c 25 73 3e |y father| is <%s>|
|000044c0| 5c 6e 22 2c 20 70 20 2d | 3e 20 6e 61 6d 65 2c 20 |\n", p -|> name, |
|000044d0| 70 20 2d 3e 20 66 61 74 | 68 65 72 20 2d 3e 20 6e |p -> fat|her -> n|
|000044e0| 61 6d 65 29 3b 20 2a 2f | 0a 09 70 72 69 6e 74 66 |ame); */|..printf|
|000044f0| 28 22 25 6c 64 5c 74 22 | 2c 20 70 20 2d 3e 20 6d |("%ld\t"|, p -> m|
|00004500| 65 5f 73 69 7a 65 29 3b | 0a 09 70 61 74 68 5f 70 |e_size);|..path_p|
|00004510| 72 69 6e 74 28 70 29 3b | 0a 09 70 75 74 63 68 61 |rint(p);|..putcha|
|00004520| 72 28 20 27 5c 6e 27 20 | 29 3b 09 2f 2a 20 74 65 |r( '\n' |);./* te|
|00004530| 72 6d 69 6e 61 74 65 20 | 6c 69 6e 65 20 2a 2f 0a |rminate |line */.|
|00004540| 7d 0a 0a 2f 2a 0a 20 2a | 20 72 65 63 75 72 73 69 |}../*. *| recursi|
|00004550| 76 65 6c 79 20 70 72 69 | 6e 74 20 74 68 65 20 66 |vely pri|nt the f|
|00004560| 75 6c 6c 20 70 61 74 68 | 20 62 79 20 70 72 69 6e |ull path| by prin|
|00004570| 74 69 6e 67 20 74 68 65 | 20 22 70 61 72 74 20 62 |ting the| "part b|
|00004580| 65 66 6f 72 65 20 6d 65 | 22 2c 0a 20 2a 20 74 68 |efore me|",. * th|
|00004590| 65 6e 20 70 72 69 6e 74 | 69 6e 67 20 6d 79 20 63 |en print|ing my c|
|000045a0| 6f 6d 70 6f 6e 65 6e 74 | 20 6e 61 6d 65 2e 0a 20 |omponent| name.. |
|000045b0| 2a 2f 0a 70 61 74 68 5f | 70 72 69 6e 74 28 20 70 |*/.path_|print( p|
|000045c0| 20 29 0a 09 73 74 72 75 | 63 74 09 6e 6f 64 65 09 | )..stru|ct.node.|
|000045d0| 2a 70 3b 0a 7b 0a 09 2f | 2a 20 74 68 69 73 20 73 |*p;.{../|* this s|
|000045e0| 68 6f 75 6c 64 20 6e 6f | 74 20 65 76 65 72 20 68 |hould no|t ever h|
|000045f0| 61 70 70 65 6e 2c 20 62 | 65 63 61 75 73 65 20 6f |appen, b|ecause o|
|00004600| 66 20 68 6f 77 20 70 61 | 74 68 5f 70 72 69 6e 74 |f how pa|th_print|
|00004610| 28 29 20 69 73 20 77 72 | 69 74 74 65 6e 20 2a 2f |() is wr|itten */|
|00004620| 0a 09 69 66 20 28 70 20 | 3d 3d 20 4e 55 4c 4c 29 |..if (p |== NULL)|
|00004630| 0a 09 09 72 65 74 75 72 | 6e 3b 09 09 2f 2a 20 70 |...retur|n;../* p|
|00004640| 61 72 61 6e 65 6e 6f 69 | 64 20 2a 2f 0a 0a 09 2f |aranenoi|d */.../|
|00004650| 2a 20 74 68 69 73 20 63 | 6f 64 65 20 69 73 20 73 |* this c|ode is s|
|00004660| 74 72 75 63 74 75 72 65 | 64 20 73 6f 20 74 68 61 |tructure|d so tha|
|00004670| 74 20 61 20 6c 65 61 64 | 69 6e 67 20 73 6c 61 73 |t a lead|ing slas|
|00004680| 68 20 77 69 6c 6c 20 4e | 4f 54 0a 09 20 2a 20 62 |h will N|OT.. * b|
|00004690| 65 20 70 72 69 6e 74 65 | 64 20 62 65 66 6f 72 65 |e printe|d before|
|000046a0| 20 74 68 65 20 66 69 72 | 73 74 20 63 6f 6d 70 6f | the fir|st compo|
|000046b0| 6e 65 6e 74 2c 20 62 75 | 74 20 72 61 74 68 65 72 |nent, bu|t rather|
|000046c0| 20 4f 4e 4c 59 0a 09 20 | 2a 20 62 65 74 77 65 65 | ONLY.. |* betwee|
|000046d0| 6e 20 61 6c 6c 20 63 6f | 6d 70 6f 6e 65 6e 74 73 |n all co|mponents|
|000046e0| 2c 20 61 6e 64 20 4e 4f | 54 20 61 66 74 65 72 20 |, and NO|T after |
|000046f0| 74 68 65 20 6c 61 73 74 | 20 63 6f 6d 70 6f 6e 65 |the last| compone|
|00004700| 6e 74 2e 0a 09 20 2a 2f | 0a 09 69 66 20 28 70 20 |nt... */|..if (p |
|00004710| 2d 3e 20 66 61 74 68 65 | 72 20 3d 3d 20 72 6f 6f |-> fathe|r == roo|
|00004720| 74 29 0a 09 09 7b 0a 09 | 09 70 72 69 6e 74 66 28 |t)...{..|.printf(|
|00004730| 22 25 73 22 2c 20 70 20 | 2d 3e 6e 61 6d 65 20 29 |"%s", p |->name )|
|00004740| 3b 0a 09 09 72 65 74 75 | 72 6e 3b 0a 09 09 7d 0a |;...retu|rn;...}.|
|00004750| 09 65 6c 73 65 0a 09 09 | 7b 0a 09 09 2f 2a 20 72 |.else...|{.../* r|
|00004760| 65 63 75 72 73 69 6f 6e | 20 2a 2f 0a 09 09 70 61 |ecursion| */...pa|
|00004770| 74 68 5f 70 72 69 6e 74 | 28 20 70 20 2d 3e 20 66 |th_print|( p -> f|
|00004780| 61 74 68 65 72 20 29 3b | 09 2f 2a 20 70 72 69 6e |ather );|./* prin|
|00004790| 74 20 63 6f 6d 70 6f 6e | 65 6e 74 73 20 62 65 66 |t compon|ents bef|
|000047a0| 6f 72 65 20 6d 65 20 2a | 2f 0a 09 09 70 72 69 6e |ore me *|/...prin|
|000047b0| 74 66 28 20 22 2f 25 73 | 22 2c 20 70 20 2d 3e 20 |tf( "/%s|", p -> |
|000047c0| 6e 61 6d 65 20 29 3b 09 | 2f 2a 20 70 72 69 6e 74 |name );.|/* print|
|000047d0| 20 6d 79 20 63 6f 6d 70 | 6f 6e 65 6e 74 20 2a 2f | my comp|onent */|
|000047e0| 0a 09 09 7d 0a 7d 0a 0a | 2f 2a 0a 20 2a 20 63 6f |...}.}..|/*. * co|
|000047f0| 6d 70 75 74 65 20 73 69 | 7a 65 20 6f 66 20 74 68 |mpute si|ze of th|
|00004800| 69 73 20 64 69 72 65 63 | 74 6f 72 79 20 6f 6e 6c |is direc|tory onl|
|00004810| 79 2c 20 69 65 20 64 6f | 6e 27 74 20 69 6e 63 6c |y, ie do|n't incl|
|00004820| 75 64 65 0a 20 2a 20 73 | 69 7a 65 20 6f 66 20 63 |ude. * s|ize of c|
|00004830| 68 69 6c 64 72 65 6e 20 | 64 69 72 65 63 74 6f 72 |hildren |director|
|00004840| 69 65 73 2e 20 20 54 68 | 69 73 20 6c 65 61 76 65 |ies. Th|is leave|
|00004850| 73 20 73 70 61 63 65 20 | 6f 6e 6c 79 0a 20 2a 20 |s space |only. * |
|00004860| 6f 63 63 75 70 69 65 64 | 20 62 79 20 74 68 69 73 |occupied| by this|
|00004870| 20 64 69 72 65 63 74 6f | 72 79 20 72 65 6d 61 69 | directo|ry remai|
|00004880| 6e 69 6e 67 20 69 6e 20 | 74 68 65 20 22 6d 65 5f |ning in |the "me_|
|00004890| 73 69 7a 65 22 2e 0a 20 | 2a 2f 0a 76 6f 69 64 0a |size".. |*/.void.|
|000048a0| 6d 79 5f 73 70 61 63 65 | 28 20 70 20 29 0a 09 73 |my_space|( p )..s|
|000048b0| 74 72 75 63 74 09 6e 6f | 64 65 09 2a 70 3b 0a 7b |truct.no|de.*p;.{|
|000048c0| 0a 09 6c 6f 6e 67 09 74 | 6f 74 61 6c 20 3d 20 30 |..long.t|otal = 0|
|000048d0| 3b 0a 09 73 74 72 75 63 | 74 09 6e 6f 64 65 09 2a |;..struc|t.node.*|
|000048e0| 73 3b 09 2f 2a 20 65 61 | 63 68 20 73 6f 6e 20 6f |s;./* ea|ch son o|
|000048f0| 66 20 74 68 65 20 70 61 | 72 65 6e 74 20 70 20 2a |f the pa|rent p *|
|00004900| 2f 0a 0a 09 74 6f 74 61 | 6c 20 3d 20 70 20 2d 3e |/...tota|l = p ->|
|00004910| 20 73 69 7a 65 3b 09 2f | 2a 20 62 6c 6f 63 6b 73 | size;./|* blocks|
|00004920| 20 75 73 65 64 20 62 79 | 20 74 68 69 73 20 64 69 | used by| this di|
|00004930| 72 65 63 74 6f 72 79 20 | 2a 2f 0a 0a 09 2f 2a 20 |rectory |*/.../* |
|00004940| 73 75 62 74 72 61 63 74 | 20 62 6c 6f 63 6b 73 20 |subtract| blocks |
|00004950| 75 73 65 64 20 62 79 20 | 69 6d 6d 65 64 69 61 74 |used by |immediat|
|00004960| 65 20 63 68 69 6c 64 72 | 65 6e 20 64 69 72 65 63 |e childr|en direc|
|00004970| 74 6f 72 69 65 73 2e 0a | 09 20 2a 20 57 49 4c 4c |tories..|. * WILL|
|00004980| 20 4e 4f 54 20 57 4f 52 | 4b 20 43 4f 52 52 45 43 | NOT WOR|K CORREC|
|00004990| 54 4c 59 20 69 66 20 61 | 20 63 68 69 6c 64 20 69 |TLY if a| child i|
|000049a0| 73 20 61 20 66 69 6c 65 | 20 21 21 21 21 21 0a 09 |s a file| !!!!!..|
|000049b0| 20 2a 20 74 68 69 73 20 | 77 69 6c 6c 20 6c 65 61 | * this |will lea|
|000049c0| 76 65 20 74 6f 74 61 6c | 20 63 6f 6e 74 61 69 6e |ve total| contain|
|000049d0| 69 6e 67 20 6f 6e 6c 79 | 20 74 68 65 20 6e 75 6d |ing only| the num|
|000049e0| 62 65 72 20 6f 66 20 62 | 6c 6f 63 6b 73 0a 09 20 |ber of b|locks.. |
|000049f0| 2a 20 69 6e 20 74 68 69 | 73 20 64 69 72 65 63 74 |* in thi|s direct|
|00004a00| 6f 72 79 2e 0a 09 20 2a | 2f 0a 09 66 6f 72 20 28 |ory... *|/..for (|
|00004a10| 20 73 20 3d 20 70 20 2d | 3e 20 6c 73 6f 6e 3b 20 | s = p -|> lson; |
|00004a20| 73 3b 20 73 20 3d 20 73 | 20 2d 3e 20 72 62 72 6f |s; s = s| -> rbro|
|00004a30| 74 68 65 72 29 0a 09 09 | 74 6f 74 61 6c 20 2d 3d |ther)...|total -=|
|00004a40| 20 73 20 2d 3e 20 73 69 | 7a 65 3b 0a 0a 09 2f 2a | s -> si|ze;.../*|
|00004a50| 20 73 74 6f 72 65 20 6d | 79 20 73 69 7a 65 20 6f | store m|y size o|
|00004a60| 6e 6c 79 20 66 6f 72 20 | 74 68 69 73 20 70 61 72 |nly for |this par|
|00004a70| 65 6e 74 20 2a 2f 0a 09 | 70 20 2d 3e 20 6d 65 5f |ent */..|p -> me_|
|00004a80| 73 69 7a 65 20 3d 20 74 | 6f 74 61 6c 3b 0a 7d 0a |size = t|otal;.}.|
|00004a90| 0a 2f 2a 0a 20 2a 20 73 | 6f 72 74 20 74 68 65 20 |./*. * s|ort the |
|00004aa0| 64 69 72 65 63 74 6f 72 | 69 65 73 20 75 6e 64 65 |director|ies unde|
|00004ab0| 72 20 61 20 64 69 72 65 | 63 74 6f 72 79 20 62 79 |r a dire|ctory by|
|00004ac0| 20 6e 61 6d 65 2e 0a 20 | 2a 0a 20 2a 20 74 68 69 | name.. |*. * thi|
|00004ad0| 73 20 69 73 20 6a 75 73 | 74 20 74 68 65 20 6f 6c |s is jus|t the ol|
|00004ae0| 64 20 22 73 6f 72 74 28 | 29 22 20 72 6f 75 74 69 |d "sort(|)" routi|
|00004af0| 6e 65 20 5b 73 6f 72 74 | 28 29 20 72 65 6e 61 6d |ne [sort|() renam|
|00004b00| 65 64 20 74 6f 0a 20 2a | 20 73 6f 72 74 5f 73 69 |ed to. *| sort_si|
|00004b10| 7a 65 28 29 20 66 6f 72 | 20 63 6c 61 72 69 74 79 |ze() for| clarity|
|00004b20| 5d 20 77 69 74 68 20 61 | 20 6d 69 6e 6f 72 20 63 |] with a| minor c|
|00004b30| 68 61 6e 67 65 2c 20 77 | 68 65 72 65 0a 20 2a 20 |hange, w|here. * |
|00004b40| 77 65 20 6e 6f 77 20 63 | 6f 6d 70 61 72 65 20 6e |we now c|ompare n|
|00004b50| 61 6d 65 73 2c 20 6e 6f | 74 20 73 69 7a 65 2e 20 |ames, no|t size. |
|00004b60| 20 54 68 61 74 20 69 73 | 2c 20 77 65 20 73 6f 72 | That is|, we sor|
|00004b70| 74 0a 20 2a 20 74 68 65 | 20 62 72 6f 74 68 65 72 |t. * the| brother|
|00004b80| 73 20 6f 72 20 70 65 65 | 72 73 20 61 74 20 65 61 |s or pee|rs at ea|
|00004b90| 63 68 20 6c 65 76 65 6c | 2e 0a 20 2a 20 53 45 45 |ch level|.. * SEE|
|00004ba0| 20 41 4c 53 4f 20 74 68 | 65 20 61 6e 6f 6d 6f 6c | ALSO th|e anomol|
|00004bb0| 79 20 63 6f 6e 63 65 72 | 6e 69 6e 67 20 22 2e 22 |y concer|ning "."|
|00004bc0| 20 61 6e 64 20 22 2f 22 | 20 77 69 74 68 20 72 65 | and "/"| with re|
|00004bd0| 67 61 72 64 73 0a 20 2a | 20 74 6f 20 73 6f 72 74 |gards. *| to sort|
|00004be0| 69 6e 67 2c 20 64 65 73 | 63 72 69 62 65 64 20 61 |ing, des|cribed a|
|00004bf0| 74 20 74 68 65 20 74 6f | 70 20 6f 66 20 74 68 69 |t the to|p of thi|
|00004c00| 73 20 66 69 6c 65 2e 0a | 20 2a 2f 0a 76 6f 69 64 |s file..| */.void|
|00004c10| 20 73 6f 72 74 5f 6e 61 | 6d 65 28 74 29 0a 09 73 | sort_na|me(t)..s|
|00004c20| 74 72 75 63 74 20 6e 6f | 64 65 09 2a 74 3b 0a 09 |truct no|de.*t;..|
|00004c30| 7b 0a 09 73 74 72 75 63 | 74 20 6e 6f 64 65 09 2a |{..struc|t node.*|
|00004c40| 70 31 2c 20 2a 70 32 2c | 20 2a 70 33 2c 20 2a 70 |p1, *p2,| *p3, *p|
|00004c50| 70 3b 09 09 2f 2a 20 73 | 63 72 61 74 63 68 20 70 |p;../* s|cratch p|
|00004c60| 6f 69 6e 74 65 72 73 20 | 2a 2f 0a 09 69 6e 74 09 |ointers |*/..int.|
|00004c70| 09 09 6e 6f 64 65 73 2c | 20 6e 3b 09 09 09 09 2f |..nodes,| n;..../|
|00004c80| 2a 20 73 63 72 61 74 63 | 68 20 2a 2f 0a 09 69 6e |* scratc|h */..in|
|00004c90| 74 09 63 6d 70 3b 0a 0a | 09 2f 2a 20 63 6f 75 6e |t.cmp;..|./* coun|
|00004ca0| 74 20 74 68 65 20 6e 75 | 6d 62 65 72 20 6f 66 20 |t the nu|mber of |
|00004cb0| 6e 6f 64 65 73 20 2a 2f | 0a 09 6e 6f 64 65 73 20 |nodes */|..nodes |
|00004cc0| 3d 20 30 3b 0a 09 66 6f | 72 20 28 70 31 20 3d 20 |= 0;..fo|r (p1 = |
|00004cd0| 74 2d 3e 6c 73 6f 6e 3b | 20 70 31 20 21 3d 20 4e |t->lson;| p1 != N|
|00004ce0| 55 4c 4c 3b 20 70 31 20 | 3d 20 70 31 2d 3e 72 62 |ULL; p1 |= p1->rb|
|00004cf0| 72 6f 74 68 65 72 29 0a | 09 09 6e 6f 64 65 73 2b |rother).|..nodes+|
|00004d00| 2b 3b 0a 09 2f 2a 20 6a | 75 73 74 20 61 20 73 69 |+;../* j|ust a si|
|00004d10| 6d 70 6c 65 20 61 6e 64 | 20 69 6e 65 66 66 69 63 |mple and| ineffic|
|00004d20| 69 65 6e 74 20 62 75 62 | 62 6c 65 20 73 6f 72 74 |ient bub|ble sort|
|00004d30| 20 2a 2f 0a 09 66 6f 72 | 20 28 6e 20 3d 20 31 3b | */..for| (n = 1;|
|00004d40| 20 6e 20 3c 20 6e 6f 64 | 65 73 3b 20 6e 2b 2b 29 | n < nod|es; n++)|
|00004d50| 0a 09 09 66 6f 72 20 28 | 70 31 20 3d 20 4e 55 4c |...for (|p1 = NUL|
|00004d60| 4c 2c 20 70 32 20 3d 20 | 74 2d 3e 6c 73 6f 6e 2c |L, p2 = |t->lson,|
|00004d70| 20 70 33 20 3d 20 70 32 | 2d 3e 72 62 72 6f 74 68 | p3 = p2|->rbroth|
|00004d80| 65 72 3b 20 70 33 20 21 | 3d 20 4e 55 4c 4c 3b 0a |er; p3 !|= NULL;.|
|00004d90| 09 09 09 09 70 31 20 3d | 20 70 32 2c 20 70 32 20 |....p1 =| p2, p2 |
|00004da0| 3d 20 70 33 2c 20 70 33 | 20 3d 20 70 33 2d 3e 72 |= p3, p3| = p3->r|
|00004db0| 62 72 6f 74 68 65 72 29 | 0a 09 09 09 7b 0a 09 09 |brother)|....{...|
|00004dc0| 09 63 6d 70 20 3d 20 73 | 74 72 63 6d 70 28 20 70 |.cmp = s|trcmp( p|
|00004dd0| 32 20 2d 3e 20 6e 61 6d | 65 2c 20 70 33 20 2d 3e |2 -> nam|e, p3 ->|
|00004de0| 20 6e 61 6d 65 20 29 3b | 0a 09 09 09 69 66 20 28 | name );|....if (|
|00004df0| 63 6d 70 20 3e 20 30 29 | 09 2f 2a 20 6e 6f 74 20 |cmp > 0)|./* not |
|00004e00| 61 6c 70 68 61 62 65 74 | 69 7a 65 64 2c 20 70 33 |alphabet|ized, p3|
|00004e10| 20 31 73 74 2c 20 70 32 | 20 32 6e 64 20 2a 2f 0a | 1st, p2| 2nd */.|
|00004e20| 09 09 09 09 7b 0a 09 09 | 09 09 2f 2a 20 65 78 63 |....{...|../* exc|
|00004e30| 68 61 6e 67 65 20 74 68 | 65 20 6e 6f 64 65 73 20 |hange th|e nodes |
|00004e40| 70 32 20 61 6e 64 20 70 | 33 20 2a 2f 0a 09 09 09 |p2 and p|3 */....|
|00004e50| 09 70 70 20 3d 20 70 33 | 2d 3e 72 62 72 6f 74 68 |.pp = p3|->rbroth|
|00004e60| 65 72 3b 0a 09 09 09 09 | 70 33 2d 3e 72 62 72 6f |er;.....|p3->rbro|
|00004e70| 74 68 65 72 20 3d 20 70 | 32 3b 0a 09 09 09 09 70 |ther = p|2;.....p|
|00004e80| 32 2d 3e 72 62 72 6f 74 | 68 65 72 20 3d 20 70 70 |2->rbrot|her = pp|
|00004e90| 3b 0a 09 09 09 09 69 66 | 20 28 70 31 20 21 3d 20 |;.....if| (p1 != |
|00004ea0| 4e 55 4c 4c 29 0a 09 09 | 09 09 09 70 31 2d 3e 72 |NULL)...|...p1->r|
|00004eb0| 62 72 6f 74 68 65 72 20 | 3d 20 70 33 3b 0a 09 09 |brother |= p3;...|
|00004ec0| 09 09 65 6c 73 65 0a 09 | 09 09 09 09 74 2d 3e 6c |..else..|....t->l|
|00004ed0| 73 6f 6e 20 3d 20 70 33 | 3b 0a 09 09 09 09 2f 2a |son = p3|;...../*|
|00004ee0| 20 65 78 63 68 61 6e 67 | 65 20 74 68 65 20 76 61 | exchang|e the va|
|00004ef0| 6c 75 65 73 20 6f 66 20 | 70 32 20 61 6e 64 20 70 |lues of |p2 and p|
|00004f00| 33 20 2a 2f 0a 09 09 09 | 09 70 70 20 3d 20 70 32 |3 */....|.pp = p2|
|00004f10| 3b 0a 09 09 09 09 70 32 | 20 3d 20 70 33 3b 0a 09 |;.....p2| = p3;..|
|00004f20| 09 09 09 70 33 20 3d 20 | 70 70 3b 0a 09 09 09 09 |...p3 = |pp;.....|
|00004f30| 7d 0a 09 09 09 7d 0a 09 | 7d 0a 0a 5c 53 48 41 52 |}....}..|}..\SHAR|
|00004f40| 5f 45 4f 46 0a 23 20 2e | 2e 2e 2e 2e 2e 2e 2e 2e |_EOF.# .|........|
|00004f50| 2e 2e 2e 20 20 20 20 46 | 20 20 49 20 20 20 4c 20 |... F| I L |
|00004f60| 20 20 45 20 20 20 20 20 | 20 45 20 20 4e 20 20 44 | E | E N D|
|00004f70| 20 20 2e 2e 2e 2e 2e 2e | 2e 2e 2e 2e 20 64 75 6f | ......|.... duo|
|00004f80| 6e 6c 79 2e 63 0a 66 69 | 20 23 20 65 6e 64 20 6f |nly.c.fi| # end o|
|00004f90| 66 20 6f 76 65 72 77 72 | 69 74 69 6e 67 20 63 68 |f overwr|iting ch|
|00004fa0| 65 63 6b 0a 69 66 20 74 | 65 73 74 20 2d 66 20 64 |eck.if t|est -f d|
|00004fb0| 75 6f 6e 6c 79 2e 68 65 | 6c 70 0a 74 68 65 6e 0a |uonly.he|lp.then.|
|00004fc0| 65 63 68 6f 20 73 68 61 | 72 3a 20 77 69 6c 6c 20 |echo sha|r: will |
|00004fd0| 6e 6f 74 20 6f 76 65 72 | 2d 77 72 69 74 65 20 65 |not over|-write e|
|00004fe0| 78 69 73 74 69 6e 67 20 | 66 69 6c 65 20 27 64 75 |xisting |file 'du|
|00004ff0| 6f 6e 6c 79 2e 68 65 6c | 70 27 0a 65 6c 73 65 0a |only.hel|p'.else.|
|00005000| 65 63 68 6f 20 78 20 2d | 20 64 75 6f 6e 6c 79 2e |echo x -| duonly.|
|00005010| 68 65 6c 70 0a 23 20 2e | 2e 2e 2e 2e 2e 2e 2e 2e |help.# .|........|
|00005020| 2e 2e 2e 20 20 20 20 46 | 20 20 49 20 20 20 4c 20 |... F| I L |
|00005030| 20 20 45 20 20 20 20 20 | 20 42 20 20 45 20 20 47 | E | B E G|
|00005040| 20 20 2e 2e 2e 2e 2e 2e | 2e 2e 2e 2e 20 64 75 6f | ......|.... duo|
|00005050| 6e 6c 79 2e 68 65 6c 70 | 0a 63 61 74 20 3c 3c 20 |nly.help|.cat << |
|00005060| 27 5c 53 48 41 52 5f 45 | 4f 46 27 20 3e 20 64 75 |'\SHAR_E|OF' > du|
|00005070| 6f 6e 6c 79 2e 68 65 6c | 70 0a 64 75 6f 6e 6c 79 |only.hel|p.duonly|
|00005080| 0a 0a 50 72 69 6e 74 73 | 20 64 69 73 6b 20 75 73 |..Prints| disk us|
|00005090| 61 67 65 20 62 6c 6f 63 | 6b 20 73 69 7a 65 73 20 |age bloc|k sizes |
|000050a0| 6f 6e 6c 79 20 66 6f 72 | 20 64 69 72 65 63 74 6f |only for| directo|
|000050b0| 72 69 65 73 2c 0a 62 75 | 74 20 4e 4f 54 20 69 6e |ries,.bu|t NOT in|
|000050c0| 63 6c 75 64 69 6e 67 20 | 73 69 7a 65 73 20 63 6f |cluding |sizes co|
|000050d0| 6e 74 72 69 62 75 74 65 | 64 20 62 79 20 73 75 62 |ntribute|d by sub|
|000050e0| 2d 64 69 72 65 63 74 6f | 72 69 65 73 2e 0a 0a 54 |-directo|ries...T|
|000050f0| 68 69 73 20 74 6f 6f 6c | 20 77 61 73 20 64 65 76 |his tool| was dev|
|00005100| 65 6c 6f 70 65 64 20 62 | 65 63 61 75 73 65 20 77 |eloped b|ecause w|
|00005110| 68 65 6e 20 76 69 65 77 | 69 6e 67 20 74 68 65 20 |hen view|ing the |
|00005120| 6f 75 74 70 75 74 20 6f | 66 20 61 0a 72 65 67 75 |output o|f a.regu|
|00005130| 6c 61 72 20 64 75 2c 20 | 69 74 20 77 61 73 20 64 |lar du, |it was d|
|00005140| 69 66 66 69 63 75 6c 74 | 20 74 6f 20 73 65 65 20 |ifficult| to see |
|00005150| 77 68 69 63 68 20 64 69 | 72 65 63 74 6f 72 69 65 |which di|rectorie|
|00005160| 73 20 77 65 72 65 0a 74 | 68 65 20 72 65 61 6c 20 |s were.t|he real |
|00005170| 63 75 6c 70 72 69 74 73 | 20 66 6f 72 20 6f 63 63 |culprits| for occ|
|00005180| 75 70 79 69 6e 67 20 74 | 68 65 20 6d 6f 73 74 20 |upying t|he most |
|00005190| 6e 75 6d 62 65 72 20 6f | 66 20 64 69 73 6b 20 62 |number o|f disk b|
|000051a0| 6c 6f 63 6b 73 2e 0a 46 | 6f 72 20 65 78 61 6d 70 |locks..F|or examp|
|000051b0| 6c 65 2c 20 69 66 20 79 | 6f 75 20 64 69 64 20 61 |le, if y|ou did a|
|000051c0| 20 22 64 75 20 2f 75 73 | 72 22 2c 20 74 68 65 20 | "du /us|r", the |
|000051d0| 6c 61 73 74 20 6c 69 6e | 65 20 77 6f 75 6c 64 20 |last lin|e would |
|000051e0| 62 65 0a 73 6f 6d 65 74 | 68 69 6e 67 20 6c 69 6b |be.somet|hing lik|
|000051f0| 65 3a 0a 0a 31 38 31 31 | 32 09 2f 75 73 72 0a 0a |e:..1811|2./usr..|
|00005200| 65 76 65 6e 20 74 68 6f | 75 67 68 20 2f 75 73 72 |even tho|ugh /usr|
|00005210| 20 6d 69 67 68 74 20 6f | 6e 6c 79 20 63 6f 6e 74 | might o|nly cont|
|00005220| 61 69 6e 20 73 75 62 2d | 64 69 72 65 63 74 6f 72 |ain sub-|director|
|00005230| 69 65 73 2c 20 62 75 74 | 20 6e 6f 20 66 69 6c 65 |ies, but| no file|
|00005240| 73 2e 0a 48 65 6e 63 65 | 2c 20 69 74 20 6d 69 67 |s..Hence|, it mig|
|00005250| 68 74 20 62 65 20 74 68 | 61 74 20 61 20 73 75 62 |ht be th|at a sub|
|00005260| 2d 64 69 72 65 63 74 6f | 72 79 20 6f 66 20 2f 75 |-directo|ry of /u|
|00005270| 73 72 20 77 61 73 20 74 | 68 65 20 72 65 61 6c 0a |sr was t|he real.|
|00005280| 63 75 6c 70 72 69 74 20 | 66 6f 72 20 62 65 69 6e |culprit |for bein|
|00005290| 67 20 61 20 64 69 73 6b | 20 68 6f 67 2c 20 61 6e |g a disk| hog, an|
|000052a0| 64 20 6e 6f 74 20 2f 75 | 73 72 20 28 6f 72 20 61 |d not /u|sr (or a|
|000052b0| 20 73 75 62 2d 73 75 62 | 2d 64 69 72 65 63 74 6f | sub-sub|-directo|
|000052c0| 72 79 2c 0a 65 74 63 2e | 2c 20 6f 66 20 2f 75 73 |ry,.etc.|, of /us|
|000052d0| 72 20 6d 69 67 68 74 20 | 62 65 20 74 68 65 20 63 |r might |be the c|
|000052e0| 75 6c 70 72 69 74 29 2e | 0a 0a 44 75 6f 6e 6c 79 |ulprit).|..Duonly|
|000052f0| 20 69 73 20 64 65 73 69 | 67 6e 65 64 20 74 6f 20 | is desi|gned to |
|00005300| 72 65 61 64 20 73 74 61 | 6e 64 61 72 64 20 69 6e |read sta|ndard in|
|00005310| 70 75 74 20 67 65 6e 65 | 72 61 74 65 64 20 62 79 |put gene|rated by|
|00005320| 20 22 64 75 22 2c 20 61 | 6e 64 20 70 72 69 6e 74 | "du", a|nd print|
|00005330| 0a 69 6e 66 6f 72 6d 61 | 74 69 6f 6e 20 69 6e 20 |.informa|tion in |
|00005340| 74 68 65 20 73 61 6d 65 | 20 73 74 79 6c 65 20 61 |the same| style a|
|00005350| 73 20 64 75 3a 0a 0a 73 | 69 7a 65 09 64 69 72 65 |s du:..s|ize.dire|
|00005360| 63 74 6f 72 79 5f 6e 61 | 6d 65 0a 0a 48 6f 77 65 |ctory_na|me..Howe|
|00005370| 76 65 72 2c 20 74 68 65 | 20 73 69 7a 65 20 72 65 |ver, the| size re|
|00005380| 70 6f 72 74 65 64 20 62 | 79 20 64 75 6f 6e 6c 79 |ported b|y duonly|
|00005390| 20 69 73 20 74 68 65 20 | 73 69 7a 65 20 69 6e 20 | is the |size in |
|000053a0| 62 6c 6f 63 6b 73 0a 63 | 6f 6e 74 72 69 62 75 74 |blocks.c|ontribut|
|000053b0| 65 64 20 22 4f 4e 4c 59 | 20 62 79 20 74 68 65 20 |ed "ONLY| by the |
|000053c0| 64 69 72 65 63 74 6f 72 | 79 5f 6e 61 6d 65 20 69 |director|y_name i|
|000053d0| 74 73 65 6c 66 2c 20 69 | 6e 63 6c 75 64 69 6e 67 |tself, i|ncluding|
|000053e0| 0a 74 68 65 20 73 75 6d | 20 6f 66 20 74 68 65 20 |.the sum| of the |
|000053f0| 73 69 7a 65 73 20 6f 66 | 20 61 6c 6c 20 72 65 67 |sizes of| all reg|
|00005400| 75 6c 61 72 20 66 69 6c | 65 73 20 64 69 72 65 63 |ular fil|es direc|
|00005410| 74 6c 79 20 62 65 6e 65 | 61 74 68 0a 64 69 72 65 |tly bene|ath.dire|
|00005420| 63 74 6f 72 79 5f 6e 61 | 6d 65 22 2e 20 20 49 74 |ctory_na|me". It|
|00005430| 20 64 6f 65 73 20 4e 4f | 54 20 69 6e 63 6c 75 64 | does NO|T includ|
|00005440| 65 20 74 68 65 20 73 69 | 7a 65 73 20 69 6e 68 65 |e the si|zes inhe|
|00005450| 72 69 74 65 64 0a 62 79 | 20 41 4e 59 20 6f 66 20 |rited.by| ANY of |
|00005460| 74 68 65 20 63 68 69 6c | 64 72 65 6e 20 64 69 72 |the chil|dren dir|
|00005470| 65 63 74 6f 72 69 65 73 | 2e 20 20 54 68 75 73 20 |ectories|. Thus |
|00005480| 74 68 65 20 73 69 7a 65 | 20 72 65 70 6f 72 74 65 |the size| reporte|
|00005490| 64 0a 62 79 20 64 75 6f | 6e 6c 79 20 6d 69 67 68 |d.by duo|nly migh|
|000054a0| 74 20 62 65 20 74 68 6f | 75 67 68 74 20 6f 66 20 |t be tho|ught of |
|000054b0| 61 73 20 4f 4e 4c 59 20 | 66 6f 72 20 74 68 61 74 |as ONLY |for that|
|000054c0| 20 64 69 72 65 63 74 6f | 72 79 2e 0a 0a 0a 53 41 | directo|ry....SA|
|000054d0| 4d 50 4c 45 20 55 53 41 | 47 45 0a 0a 09 64 75 20 |MPLE USA|GE...du |
|000054e0| 7c 20 64 75 6f 6e 6c 79 | 0a 09 64 75 20 2f 75 73 || duonly|..du /us|
|000054f0| 72 20 7c 20 64 75 6f 6e | 6c 79 0a 0a 0a 4e 4f 54 |r | duon|ly...NOT|
|00005500| 45 53 0a 0a 54 68 65 20 | 64 69 72 65 63 74 6f 72 |ES..The |director|
|00005510| 79 20 6e 61 6d 65 73 20 | 61 72 65 20 73 6f 72 74 |y names |are sort|
|00005520| 65 64 20 61 6c 70 68 61 | 62 65 74 69 63 61 6c 6c |ed alpha|beticall|
|00005530| 79 20 62 79 20 65 61 63 | 68 20 6c 65 76 65 6c 2e |y by eac|h level.|
|00005540| 0a 54 68 65 72 65 20 69 | 73 20 6f 6e 65 20 6d 69 |.There i|s one mi|
|00005550| 6e 6f 72 20 61 6e 6f 6d | 6f 6c 79 20 61 62 6f 75 |nor anom|oly abou|
|00005560| 74 20 74 68 65 20 73 6f | 72 74 65 64 20 6f 72 64 |t the so|rted ord|
|00005570| 65 72 20 6f 66 20 64 69 | 72 65 63 74 6f 72 79 0a |er of di|rectory.|
|00005580| 6e 61 6d 65 73 2e 20 44 | 75 6f 6e 6c 79 20 77 69 |names. D|uonly wi|
|00005590| 6c 6c 20 6f 75 74 70 75 | 74 20 74 68 69 73 20 6f |ll outpu|t this o|
|000055a0| 72 64 65 72 3a 0a 09 31 | 30 09 64 69 72 0a 09 35 |rder:..1|0.dir..5|
|000055b0| 09 64 69 72 2f 73 75 62 | 64 69 72 0a 09 33 09 64 |.dir/sub|dir..3.d|
|000055c0| 69 72 2e 32 0a 62 75 74 | 20 61 20 74 72 75 65 20 |ir.2.but| a true |
|000055d0| 22 64 75 20 7c 20 64 75 | 6f 6e 6c 79 20 7c 20 73 |"du | du|only | s|
|000055e0| 6f 72 74 20 2b 31 22 2c | 20 77 69 74 68 20 73 6f |ort +1",| with so|
|000055f0| 72 74 69 6e 67 20 61 70 | 70 6c 69 65 64 20 74 6f |rting ap|plied to|
|00005600| 0a 74 68 65 20 73 65 63 | 6f 6e 64 20 63 6f 6c 75 |.the sec|ond colu|
|00005610| 6d 6e 20 77 6f 75 6c 64 | 20 72 65 61 6c 6c 79 20 |mn would| really |
|00005620| 6f 75 74 70 75 74 3a 0a | 09 31 30 09 64 69 72 0a |output:.|.10.dir.|
|00005630| 09 33 09 64 69 72 2e 32 | 0a 09 35 09 64 69 72 2f |.3.dir.2|..5.dir/|
|00005640| 73 75 62 64 69 72 0a 73 | 69 6e 63 65 20 22 2e 22 |subdir.s|ince "."|
|00005650| 20 6c 65 78 69 63 61 6c | 6c 79 20 70 72 65 63 65 | lexical|ly prece|
|00005660| 65 64 73 20 22 2f 22 2e | 0a 57 69 74 68 20 74 68 |eds "/".|.With th|
|00005670| 65 20 65 78 63 65 70 74 | 69 6f 6e 20 6e 6f 74 65 |e except|ion note|
|00005680| 64 2c 20 74 68 65 20 72 | 65 73 74 20 6f 66 20 74 |d, the r|est of t|
|00005690| 68 65 20 6f 75 74 70 75 | 74 20 67 65 6e 65 72 61 |he outpu|t genera|
|000056a0| 74 65 64 20 62 79 20 64 | 75 0a 69 73 20 69 6e 20 |ted by d|u.is in |
|000056b0| 74 68 65 20 63 6f 72 72 | 65 63 74 20 6f 72 64 65 |the corr|ect orde|
|000056c0| 72 2e 0a 5c 53 48 41 52 | 5f 45 4f 46 0a 23 20 2e |r..\SHAR|_EOF.# .|
|000056d0| 2e 2e 2e 2e 2e 2e 2e 2e | 2e 2e 2e 20 20 20 20 46 |........|... F|
|000056e0| 20 20 49 20 20 20 4c 20 | 20 20 45 20 20 20 20 20 | I L | E |
|000056f0| 20 45 20 20 4e 20 20 44 | 20 20 2e 2e 2e 2e 2e 2e | E N D| ......|
|00005700| 2e 2e 2e 2e 20 64 75 6f | 6e 6c 79 2e 68 65 6c 70 |.... duo|nly.help|
|00005710| 0a 66 69 20 23 20 65 6e | 64 20 6f 66 20 6f 76 65 |.fi # en|d of ove|
|00005720| 72 77 72 69 74 69 6e 67 | 20 63 68 65 63 6b 0a 23 |rwriting| check.#|
|00005730| 20 65 6e 64 20 6f 66 20 | 73 68 65 6c 6c 20 61 72 | end of |shell ar|
|00005740| 63 68 69 76 65 0a 65 78 | 69 74 20 30 0a 2d 2d 20 |chive.ex|it 0.-- |
|00005750| 0a 46 75 6c 6c 4e 61 6d | 65 3a 09 44 65 6e 6e 69 |.FullNam|e:.Denni|
|00005760| 73 20 42 65 64 6e 61 72 | 0a 55 55 43 50 3a 09 09 |s Bednar|.UUCP:..|
|00005770| 7b 75 75 6e 65 74 7c 73 | 75 6e 64 63 7d 21 72 6c |{uunet|s|undc}!rl|
|00005780| 67 76 61 78 21 64 65 6e | 6e 69 73 0a 55 53 4d 61 |gvax!den|nis.USMa|
|00005790| 69 6c 3a 09 09 43 43 49 | 3b 20 31 31 34 39 30 20 |il:..CCI|; 11490 |
|000057a0| 43 6f 6d 6d 65 72 63 65 | 20 50 61 72 6b 20 44 72 |Commerce| Park Dr|
|000057b0| 2e 3b 20 52 65 73 74 6f | 6e 20 56 41 20 32 32 30 |.; Resto|n VA 220|
|000057c0| 39 31 0a 54 65 6c 65 70 | 68 6f 6e 65 3a 09 2b 31 |91.Telep|hone:.+1|
|000057d0| 20 37 30 33 20 36 34 38 | 20 33 33 30 30 0a 0a 0a | 703 648| 3300...|
+--------+-------------------------+-------------------------+--------+--------+