home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.linux
- Path: sparky!uunet!uunet.ca!xenitec!mongrel!shrdlu!gdm
- From: gdm@shrdlu.kwnet.on.ca (Giles D Malet)
- Subject: Re: SED is buggy (libc.so.4.2 bug ?)
- References: <BzoEwL.6Jr@shrdlu.kwnet.on.ca>
- Organization: 3.141592653589793238462643383279502884197169399
- Date: Wed, 23 Dec 1992 23:56:27 GMT
- Message-ID: <BzqL64.Ev@shrdlu.kwnet.on.ca>
- Lines: 48
-
- More info, after some email made me look further.
- Someone says their sed from SLS 0.99 works fine. I assume this is the same
- sed as myself, which again makes me suspicious of the libraries.
- Unfortunately this person omitted to tell me what library they are using.
-
- I reckon sed must use the `regex' stuff, so I was looking at regex.h and
- found this :
-
- /* If this bit is not set, then \ inside a bracket expression is literal.
- If set, then such a \ quotes the following character. */
- #define RE_BACKSLASH_ESCAPE_IN_LISTS (1)
-
- and
-
- /* If this bit is set, (...) defines a group, and \( and \) are literals.
- If not set, \(...\) defines a group, and ( and ) are literals. */
- #define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
-
- so I thought perhaps something in here had been changed beween releases
- of the libraries. So I tried echo xxxfooyyy | sed 's/x*(foo)y*/\1/'
- and it gave `foo'. Aha !
-
- I did the following : $ echo 'xxx\foo\yyy' | sed 's/pattern/\1/', pattern
- as below, and these are the results :
-
- x*(\\foo\\)y* => \foo\
- x*(\\fo\o\\)y* => \foo\
- x*\\(foo)\\y* => foo
- x*\\(foo\)\\y* => xxx\foo\yyy
- x*\\\(foo)\\y* => xxx\foo\yyy
- x\*\\(foo)\\y* => xxx\foo\yyy
-
- Finally, $ echo 'xxx(foo)yyy' | sed 's/x*(\(foo\))y*/\1/' gives (foo).
-
- So, all this means, unless I am missing something, that the library is
- acting as indicated by the defines in regex.h above. It also means that
- RE_NO_BK_PARENS has been flipped recently. Why ?
-
- Which is `correct' ? \(...\) defines a group, as in the old days, or
- (...) defines a group, as now. Surely there is a correct and incorrect
- way of doing this. One can't expected a script to grep & grope through
- regex.h just to see what pattern to use for sed.
-
- What do other folks libraries give ?
-
- --
- Giles D Malet gdm@shrdlu.kwnet.on.ca
- Waterloo, Ont, Canada +1 519 725 5726 gdmalet@descartes.uwaterloo.ca
-