home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / linux / 21597 < prev    next >
Encoding:
Text File  |  1992-12-24  |  2.2 KB  |  59 lines

  1. Newsgroups: comp.os.linux
  2. Path: sparky!uunet!uunet.ca!xenitec!mongrel!shrdlu!gdm
  3. From: gdm@shrdlu.kwnet.on.ca (Giles D Malet)
  4. Subject: Re: SED is buggy (libc.so.4.2 bug ?)
  5. References: <BzoEwL.6Jr@shrdlu.kwnet.on.ca>
  6. Organization: 3.141592653589793238462643383279502884197169399
  7. Date: Wed, 23 Dec 1992 23:56:27 GMT
  8. Message-ID: <BzqL64.Ev@shrdlu.kwnet.on.ca>
  9. Lines: 48
  10.  
  11. More info, after some email made me look further.
  12. Someone says their sed from SLS 0.99 works fine. I assume this is the same
  13. sed as myself, which again makes me suspicious of the libraries.
  14. Unfortunately this person omitted to tell me what library they are using.
  15.  
  16. I reckon sed must use the `regex' stuff, so I was looking at regex.h and
  17. found this :
  18.  
  19. /* If this bit is not set, then \ inside a bracket expression is literal.
  20.    If set, then such a \ quotes the following character.  */
  21. #define RE_BACKSLASH_ESCAPE_IN_LISTS (1)
  22.  
  23. and
  24.  
  25. /* If this bit is set, (...) defines a group, and \( and \) are literals.
  26.    If not set, \(...\) defines a group, and ( and ) are literals.  */
  27. #define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
  28.  
  29. so I thought perhaps something in here had been changed beween releases
  30. of the libraries. So I tried echo xxxfooyyy | sed 's/x*(foo)y*/\1/'
  31. and it gave `foo'. Aha !
  32.  
  33. I did the following : $ echo 'xxx\foo\yyy' | sed 's/pattern/\1/', pattern
  34. as below, and these are the results :
  35.  
  36.     x*(\\foo\\)y*        =>    \foo\
  37.     x*(\\fo\o\\)y*        =>    \foo\
  38.     x*\\(foo)\\y*        =>    foo
  39.     x*\\(foo\)\\y*        =>    xxx\foo\yyy
  40.     x*\\\(foo)\\y*        =>    xxx\foo\yyy
  41.     x\*\\(foo)\\y*        =>    xxx\foo\yyy
  42.  
  43. Finally, $ echo 'xxx(foo)yyy' | sed 's/x*(\(foo\))y*/\1/' gives (foo).
  44.  
  45. So, all this means, unless I am missing something, that the library is
  46. acting as indicated by the defines in regex.h above. It also means that
  47. RE_NO_BK_PARENS has been flipped recently. Why ?
  48.  
  49. Which is `correct' ?  \(...\) defines a group, as in the old days, or
  50. (...) defines a group, as now. Surely there is a correct and incorrect
  51. way of doing this. One can't expected a script to grep & grope through
  52. regex.h just to see what pattern to use for sed.
  53.  
  54. What do other folks libraries give ?
  55.  
  56. -- 
  57. Giles D Malet                                             gdm@shrdlu.kwnet.on.ca
  58. Waterloo, Ont, Canada       +1 519 725 5726       gdmalet@descartes.uwaterloo.ca
  59.