Hex Artifact Content
Not logged in

Artifact c8ec3b63bafeae6f2d90f90038f71b7a84181148:


0000: 23 0a 23 20 43 6f 70 79 72 69 67 68 74 20 28 63  #.# Copyright (c
0010: 29 20 32 30 31 31 20 44 2e 20 52 69 63 68 61 72  ) 2011 D. Richar
0020: 64 20 48 69 70 70 0a 23 0a 23 20 54 68 69 73 20  d Hipp.#.# This 
0030: 70 72 6f 67 72 61 6d 20 69 73 20 66 72 65 65 20  program is free 
0040: 73 6f 66 74 77 61 72 65 3b 20 79 6f 75 20 63 61  software; you ca
0050: 6e 20 72 65 64 69 73 74 72 69 62 75 74 65 20 69  n redistribute i
0060: 74 20 61 6e 64 2f 6f 72 0a 23 20 6d 6f 64 69 66  t and/or.# modif
0070: 79 20 69 74 20 75 6e 64 65 72 20 74 68 65 20 74  y it under the t
0080: 65 72 6d 73 20 6f 66 20 74 68 65 20 53 69 6d 70  erms of the Simp
0090: 6c 69 66 69 65 64 20 42 53 44 20 4c 69 63 65 6e  lified BSD Licen
00a0: 73 65 20 28 61 6c 73 6f 0a 23 20 6b 6e 6f 77 6e  se (also.# known
00b0: 20 61 73 20 74 68 65 20 22 32 2d 43 6c 61 75 73   as the "2-Claus
00c0: 65 20 4c 69 63 65 6e 73 65 22 20 6f 72 20 22 46  e License" or "F
00d0: 72 65 65 42 53 44 20 4c 69 63 65 6e 73 65 22 2e  reeBSD License".
00e0: 29 0a 23 0a 23 20 54 68 69 73 20 70 72 6f 67 72  ).#.# This progr
00f0: 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 74 65  am is distribute
0100: 64 20 69 6e 20 74 68 65 20 68 6f 70 65 20 74 68  d in the hope th
0110: 61 74 20 69 74 20 77 69 6c 6c 20 62 65 20 75 73  at it will be us
0120: 65 66 75 6c 2c 0a 23 20 62 75 74 20 77 69 74 68  eful,.# but with
0130: 6f 75 74 20 61 6e 79 20 77 61 72 72 61 6e 74 79  out any warranty
0140: 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 74  ; without even t
0150: 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 61  he implied warra
0160: 6e 74 79 20 6f 66 0a 23 20 6d 65 72 63 68 61 6e  nty of.# merchan
0170: 74 61 62 69 6c 69 74 79 20 6f 72 20 66 69 74 6e  tability or fitn
0180: 65 73 73 20 66 6f 72 20 61 20 70 61 72 74 69 63  ess for a partic
0190: 75 6c 61 72 20 70 75 72 70 6f 73 65 2e 0a 23 0a  ular purpose..#.
01a0: 23 20 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74  # Author contact
01b0: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 23 20   information:.# 
01c0: 20 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a    drh@hwaci.com.
01d0: 23 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68  #   http://www.h
01e0: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 23 0a  waci.com/drh/.#.
01f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0200: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0210: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0220: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0230: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 0a 23  ############.#.#
0240: 20 46 69 6c 65 20 75 74 69 6c 69 74 69 65 73 0a   File utilities.
0250: 23 0a 0a 70 72 6f 63 20 73 69 6d 70 6c 69 66 79  #..proc simplify
0260: 2d 6e 61 6d 65 20 7b 74 65 73 74 6e 61 6d 65 20  -name {testname 
0270: 61 72 67 73 7d 20 7b 0a 20 20 73 65 74 20 69 20  args} {.  set i 
0280: 31 0a 20 20 66 6f 72 65 61 63 68 20 7b 70 61 74  1.  foreach {pat
0290: 68 20 72 65 73 75 6c 74 7d 20 24 61 72 67 73 20  h result} $args 
02a0: 7b 0a 20 20 20 20 66 6f 73 73 69 6c 20 74 65 73  {.    fossil tes
02b0: 74 2d 73 69 6d 70 6c 69 66 79 2d 6e 61 6d 65 20  t-simplify-name 
02c0: 24 70 61 74 68 0a 20 20 20 20 74 65 73 74 20 73  $path.    test s
02d0: 69 6d 70 6c 69 66 79 2d 6e 61 6d 65 2d 24 74 65  implify-name-$te
02e0: 73 74 6e 61 6d 65 2e 24 69 20 7b 24 3a 3a 52 45  stname.$i {$::RE
02f0: 53 55 4c 54 3d 3d 22 5c 5b 24 70 61 74 68 5c 5d  SULT=="\[$path\]
0300: 20 2d 3e 20 5c 5b 24 72 65 73 75 6c 74 5c 5d 22   -> \[$result\]"
0310: 7d 0a 20 20 20 20 69 6e 63 72 20 69 0a 20 20 7d  }.    incr i.  }
0320: 0a 7d 0a 0a 73 69 6d 70 6c 69 66 79 2d 6e 61 6d  .}..simplify-nam
0330: 65 20 31 30 30 20 2e 20 2e 20 2e 2f 2f 20 2e 20  e 100 . . .// . 
0340: 2e 2e 20 2e 2e 20 2e 2e 2f 2f 2f 2f 2f 20 2e 2e  .. .. ..///// ..
0350: 0a 73 69 6d 70 6c 69 66 79 2d 6e 61 6d 65 20 31  .simplify-name 1
0360: 30 31 20 7b 7d 20 7b 7d 20 2f 20 2f 20 2f 2f 2f  01 {} {} / / ///
0370: 2f 2f 2f 2f 2f 2f 20 2f 20 2e 2f 2e 2f 2e 2f 2e  ////// / ./././.
0380: 2f 20 2e 0a 73 69 6d 70 6c 69 66 79 2d 6e 61 6d  / ..simplify-nam
0390: 65 20 31 30 32 20 78 20 78 20 2f 78 20 2f 78 20  e 102 x x /x /x 
03a0: 2f 2f 2f 78 20 2f 2f 78 0a 73 69 6d 70 6c 69 66  ///x //x.simplif
03b0: 79 2d 6e 61 6d 65 20 31 30 33 20 61 2f 62 20 61  y-name 103 a/b a
03c0: 2f 62 20 2f 61 2f 62 20 2f 61 2f 62 20 61 2f 2f  /b /a/b /a/b a//
03d0: 2f 62 20 61 2f 62 20 2f 2f 2f 61 2f 2f 2f 62 2f  /b a/b ///a///b/
03e0: 2f 2f 2f 2f 20 2f 2f 61 2f 62 0a 73 69 6d 70 6c  //// //a/b.simpl
03f0: 69 66 79 2d 6e 61 6d 65 20 31 30 34 20 61 2f 62  ify-name 104 a/b
0400: 2f 2e 2e 2f 63 2f 20 61 2f 63 20 2f 61 2f 62 2f  /../c/ a/c /a/b/
0410: 2e 2e 2f 63 20 2f 61 2f 63 20 2f 61 2f 62 2f 2f  ../c /a/c /a/b//
0420: 2e 2e 2f 63 20 2f 61 2f 63 20 2f 61 2f 62 2f 2e  ../c /a/c /a/b/.
0430: 2e 2f 2f 2f 63 20 2f 61 2f 63 0a 73 69 6d 70 6c  .///c /a/c.simpl
0440: 69 66 79 2d 6e 61 6d 65 20 31 30 35 20 61 2f 62  ify-name 105 a/b
0450: 2f 2e 2e 2f 2e 2e 2f 78 2f 79 20 78 2f 79 20 2f  /../../x/y x/y /
0460: 61 2f 62 2f 2e 2e 2f 2e 2e 2f 78 2f 79 20 2f 78  a/b/../../x/y /x
0470: 2f 79 0a 73 69 6d 70 6c 69 66 79 2d 6e 61 6d 65  /y.simplify-name
0480: 20 31 30 36 20 61 2f 62 2f 2e 2e 2f 2e 2e 2f 2e   106 a/b/../../.
0490: 2e 2f 78 2f 79 20 2e 2e 2f 78 2f 79 20 2f 61 2f  ./x/y ../x/y /a/
04a0: 62 2f 2e 2e 2f 2e 2e 2f 2e 2e 2f 78 2f 79 20 2f  b/../../../x/y /
04b0: 2e 2e 2f 78 2f 79 0a 73 69 6d 70 6c 69 66 79 2d  ../x/y.simplify-
04c0: 6e 61 6d 65 20 31 30 37 20 61 2f 2e 2f 62 2f 2e  name 107 a/./b/.
04d0: 2e 2f 2e 2f 2e 2e 2f 78 2f 79 20 78 2f 79 20 61  ././../x/y x/y a
04e0: 2f 2f 2e 2f 2f 62 2f 2f 2e 2e 2f 2f 2e 2f 2f 2e  //.//b//..//.//.
04f0: 2e 2f 2f 78 2f 2f 79 2f 2f 2f 20 78 2f 79 0a     .//x//y/// x/y.