On Tue, 1 Jan 2002 22:25, Richard Gooch wrote:
> > Sometime in the last month or two, the syntax of regular expressions in
> > devfsd as packaged in Debian woody has changed. It appears that
> > escaping parentheses for their "special" regex-ish meaning is no longer
> > necessary, ie. a bare paren is the same as in Perl or awk. I assume
> > this change was deliberate and intentional; I certainly think it's the
> > better syntax.
> >
> > However, the docs are lagging. devfsd.conf(5) has this example:
> >
> > LOOKUP
> > ^\(\(ide\|scsi\)/host[0-9]\+/bus[0-9]\+/target[0-9]\+/lun[0-9]\+\)/part[0
> >-9]\+$ EXECUTE /sbin/partx -a $mntpnt/\1/disc
> >
> > and the accompanying text says:
> >
> > Notice the use
> > of regular expression substituation in the command "\1",
> > corresponding to the first set of parentheses in the regu
> > lar expression being matched (yes, the backslashes are
> > syntactically necesary for the special meaning of the
> > parentheses, the vertical bar and the plus sign).
> >
> > I assume this is just a doc bug, and that either Russell or Richard
> > will see this and fix it (if they haven't already).
>
> IIRC, Russell has modified the expression handling code in Debian, to
> support some other feature (I forget the details). This feature is
> available in the mainline code, so I think Russell is planning to
> remove the Debian hacks. In that case, the escaping of parenthesis is
> still required.
I changed exactly one thing, here's the relevant patch against devfsd.c:
- if ( ( err = regcomp (&new->preg, name, 0) ) != 0 )
+ if ( ( err = regcomp (&new->preg, name, REG_EXTENDED) ) != 0 )
This makes it use extended regular expressions not basic regular expressions.
I originally did that because I couldn't get the \1 operator to work without
it. However even after discovering that it's possible to use \1 with basic
regular expressions I did not remove it because it seems generally useful,
and the default config files that currently ship with the Debian packages (of
which many people are using slightly modified versions) take advantage of
extended RE functionality.
I have included below some sections of the relevant man page. Perhaps you
should consider making the default operation of devfsd use extended RE's?
REGEX(7) REGEX(7)
NAME
regex - POSIX 1003.2 regular expressions
DESCRIPTION
Regular expressions (``RE''s), as defined in POSIX 1003.2,
come in two forms: modern REs (roughly those of egrep;
1003.2 calls these ``extended'' REs) and obsolete REs
(roughly those of ed(1); 1003.2 ``basic'' REs). Obsolete
REs mostly exist for backward compatibility in some old
programs; they will be discussed at the end. 1003.2
leaves some aspects of RE syntax and semantics open; `(!)'
marks decisions on these aspects that may not be fully
portable to other 1003.2 implementations.
[...]
Obsolete (``basic'') regular expressions differ in several
respects. `|', `+', and `?' are ordinary characters and
there is no equivalent for their functionality. The
delimiters for bounds are `\{' and `\}', with `{' and `}'
by themselves ordinary characters. The parentheses for
nested subexpressions are `\(' and `\)', with `(' and `)'
by themselves ordinary characters. `^' is an ordinary
character except at the beginning of the RE or(!) the
beginning of a parenthesized subexpression, `$' is an
ordinary character except at the end of the RE or(!) the
end of a parenthesized subexpression, and `*' is an ordi
nary character if it appears at the beginning of the RE or
the beginning of a parenthesized subexpression (after a
possible leading `^'). Finally, there is one new type of
atom, a back reference: `\' followed by a non-zero decimal
digit d matches the same sequence of characters matched by
the dth parenthesized subexpression (numbering subexpres
sions by the positions of their opening parentheses, left
to right), so that (e.g.) `\([bc]\)\1' matches `bb' or
`cc' but not `bc'.
--
http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/ Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/ My home page
|