![]() |
Monday November 22 20:18:57 GMT 1999 Update to my previous message, 04/11/1999. Re HylaFAX Problem: make: *** No rule to make target `/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.../../../sparc-sun-solaris2.7/include/assert.h', needed by `faxcover.o'. Stop. Sorry about this but I whistled out the previous solution quickly before dashing off on holiday and further I'm no sed expert. The first version worked as far was needed and some, but now I would like to offer some changes. Thank you Nico Kadel-Garcia for your words. I am happy if this is of any use. I trust that you (Nico) to be able to incorporated this update in a release. 1. There are a number of simplification changes. These are really only cosmetic/pedantic, the previous works, but as this will (hopefully!) be copied many times I'll offer the changes. 2. I have solved the choice of substitute char and the answer is obvious. UNIX does not offer any spare char, so don't use any! Once the multiple slashes are removed I can know that all ``//'' were ``/../'' 3. There were problems with reducing across spaces where two files appeared on one line. This is a legacy from the original. 4. There were a number of other possible combinations which would fail, eg ``./ABCD'' at start of line, `` ./ABCD/../WXYZ'' (note the leading space), ``ABCD/../WXYZ''. New Changes I Recommend ======================= old line 252 and 253 in ``hylafax-v4.0pl2/port/mkdepend.in'': -e :loop -e 's:[^\./][^\./]*/\.\./::g' -e tloop \ -e 's:\([/ ]\)\./:\1:g' \ new: -e s:///*:/:g -e 's:\(.*\): \1:' -e 's: \([^/^ ]\): ./\1:g' \ -e :a -e 's:/\./:/:' -e 's:/\.\./://:' -e ta \ -e :b -e 's:/[^/^ ][^/^ ]*//:/:' -e tb \ -e :c -e s://:/../: -e tc \ -e 's: \./: :g' -e 's:^ \(.*\):\1:' \ Get that? -- I'll expand and comment: cat > sed.script << EOF # sed won't accept these comments! s:///*:/:g # remove multiple slashes s:\(.*\): \1: # add a leading space so all words begin with space s: \([^/^ ]\): ./\1:g # add "./" to all words except those with absolute path name :a # loop one s:/\./:/: # remove "/./" s:/\.\./://: # remove ".." from "/../" ta # until done, as in "/././" middle "/" is in 2 patterns :b # loop two s:/[^/^ ][^/^ ]*//:/: # match "/" + one or more not slashes or spaces + "//" and sub "/" tb # until done :c # third loop s://:/../: # replace any required ".." tc s: \./: :g # remove all leading "./" s:^ \(.*\):\1: # remove the leading space I added to mark first word start EOF There are a few file names that can be resolved, but will still fail my sed, eg ``ABCD/..'' should be ``.'' and ``ABCD/../'' will disappear. It's fixable, but does it have to be perfect? To answer that I would really need to know from where do these contorted file names come, but this is a game, isn't it? Have you every wondered why there are ``obfuscated C competitions'', but none for sed? Because any sed script is a winner; it needs no further obfuscation!!! [no please don't send me an entry form if you know of one.] James Lee. jameswlee@lineone.net