🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
7 messages
7 total messages Started by Ian T Zimmerman Tue, 11 Feb 1997 00:00
[slrn] Regexp syntax in rc file?
#31161
Author: Ian T Zimmerman
Date: Tue, 11 Feb 1997 00:00
20 lines
1042 bytes
I tried to customize the ignore_quotes setting in .slrnrc.

This works: 
ignore_quotes "^[ ]*>[ ]*"

But this doesn't:
ignore_quotes "^[ ]*\(>[ ]*\)+"

Because the syntax of slang regexp seems to be undocumented, I cannot
rtfm :-(

JED: WHY not use a native regexp library if one is available?

-- 
Ian T Zimmerman                        <itz@rahul.net>
I fully support the President's proposal to test driver's license
applicants for drugs.  Any plan to reduce driving is worth a try.

Re: [slrn] Regexp syntax in rc file?
#31255
Author: Ian T Zimmerman
Date: Thu, 13 Feb 1997 00:00
35 lines
1703 bytes
In article <slrn5g41sd.rr4.davis@mygir.davis.net>,
John E. Davis <davis@space.mit.edu> writes:
>  On 11 Feb 1997 21:47:41 GMT, Ian T Zimmerman
> <itz@kronstadt.rahul.net> wrote:
> >JED: WHY not use a native regexp library if one is available?
>  Someday I will add support for egrep style expressions but I have
> better things to do at the moment.

Hmmm...I take it this means the \( \) syntax is simply not there
yet...but then, what is the following doing in slregexp.c?

/* ... */

#define OPAREN 7		       /* \( */
#define CPAREN 0x8		       /* \) */

/* ... */


case OPAREN:
        This_Reg->beg_matches[Next_Pos] = (int) (str - This_Str);
        This_Reg->beg_matches[Next_Pos + 1] = -1;
        break;
case CPAREN: 
        This_Reg->end_matches[Next_Pos] = (unsigned int) (str - This_Str) - This_Reg->beg_matches[Next_Pos];
        Next_Pos++;
        break;

-- 
Ian T Zimmerman                        <itz@rahul.net>
I fully support the President's proposal to test driver's license
applicants for drugs.  Any plan to reduce driving is worth a try.

Re: [slrn] Regexp syntax in rc file?
#31269
Author: John E. Davis
Date: Thu, 13 Feb 1997 00:00
16 lines
1165 bytes
On 11 Feb 1997 21:47:41 GMT, Ian T Zimmerman <itz@kronstadt.rahul.net>
wrote:
>JED: WHY not use a native regexp library if one is available?

Such a library is not available on all systems.  There also seems to
be no uniformity among the various regular expression packages that
are available.  The slrn/jed/slang regular expressions must be uniform
across Unix, MSDOS, OS/2, and VMS.  For that reason, as well as
licensing issues, I wrote my own set of routines.  Someday I will add
support for egrep style expressions but I have better things to do at
the moment.

--John

Re: [slrn] Regexp syntax in rc file?
#31310
Author: Ian T Zimmerman
Date: Fri, 14 Feb 1997 00:00
51 lines
2513 bytes
In article <slrn5g81gd.gfg.davis@aluche.mit.edu>,
John E. Davis <davis@space.mit.edu> writes:
> 
> On 13 Feb 1997 16:31:27 GMT, Ian T Zimmerman <itz@nojunk.rahul.net>
> wrote:
> >Hmmm...I take it this means the \( \) syntax is simply not there
> >yet...but then, what is the following doing in slregexp.c?
> >
> >/* ... */
> >
> >#define OPAREN 7		       /* \( */
> >#define CPAREN 0x8		       /* \) */
> 
> S-Lang regular expressions support constructs such as:
> 
> \([a-z]\)\1
> 
> where \1 refers to the text matched by the regular expression enclosed
> in \(...\).  The \| type constructions are not supported.  I wrote the
> S-Lang regular expression package based on an Ultrix man page where there
> was no mention of the \| construct.
> 

In that case, I still don't understand why my setting of

ignore_quotes "^[ ]*\(>[ ]*\)+"

doesn't work.  (Yes, I know it's redundant).  It seems to conform to
the syntax you give.  In particular, it doesn't use any | connectives
(the symbol doesn't even occur in it).

My gut feeling is that the regexp code has a bug.  And the
possibility, probability even, of such bugs is why I'd prefer if my
system's native regex library were used.

Please don't be put off by my comments --- I think slrn is a great
program and I'd like it to be perfect.

And BTW, I'm one of those people who hate courtesy copies like the
plague.  You've managed to invent a new wording of the `posted and
emailed' notice which escaped my filter; but your next emailed copy
will go to /dev/null and waste bandwidth if I did things right.  Just
so that you know :-)

-- 
Ian T Zimmerman                        <itz@rahul.net>
I fully support the President's proposal to test driver's license
applicants for drugs.  Any plan to reduce driving is worth a try.

Re: [slrn] Regexp syntax in rc file?
#31315
Author: John E. Davis
Date: Fri, 14 Feb 1997 00:00
133 lines
6489 bytes
On 13 Feb 1997 16:31:27 GMT, Ian T Zimmerman <itz@nojunk.rahul.net>
wrote:
>Hmmm...I take it this means the \( \) syntax is simply not there
>yet...but then, what is the following doing in slregexp.c?
>
>/* ... */
>
>#define OPAREN 7		       /* \( */
>#define CPAREN 0x8		       /* \) */

S-Lang regular expressions support constructs such as:

    \([a-z]\)\1

where \1 refers to the text matched by the regular expression enclosed
in \(...\).  The \| type constructions are not supported.  I wrote the
S-Lang regular expression package based on an Ultrix man page where there
was no mention of the \| construct.

The S-Lang regular expressions are documented as part of the 'rgrep'
recursive grep program that is distributed with jed.  From its usage:

Usage: rgrep [options..] pattern [files ...]
Options:
  -?        additional help (use '-?' to avoid shell expansion on some systems)
  -c        count matches
  -h        highlight match (ANSI compatable terminal assumed)
  -H        Output match instead of entire line containing match
  -i        ignore case
  -l        list filename only
  -n        print line number of match
  -F        follow links
  -r        recursively scan through directory tree
  -N        Do NOT perform a recursive search
  -B        If file looks like a binary one, skip it.
  -R 'pat'  like '-r' except that only those files matching 'pat' are checked
  -v        print only lines that do NOT match the specified pattern
  -x 'ext'  checks only files with extension given by 'ext'.
  -D        Print all directories that would be searched.  This option is for
             debugging purposes only.  No file is grepped with this option.
  -W'len'   lines are 'len' characters long (not newline terminated).
  --version Print version
  --help    Print this help

'pattern' is a valid 'ex' type of regular expression.  See the man page for ex.
It is best enclosed in single quotes to avoid shell expansion.

Supported Regular Expressions:
   .                  match any character except newline
   \d                match any digit
   \e                match ESC char
   *                  matches zero or more occurences of previous RE
   +                  matches one or more occurences of previous RE
   ?                  matches zero or one occurence of previous RE
   ^                  matches beginning of line
   $                  matches end of line
   [ ... ]            matches any single character between brackets.
                      For example, [-02468] matches `-' or any even digit.
		      and [-0-9a-z] matches `-' and any digit between 0 and 9
		      as well as letters a through z.
   \<                Match the beginning of a word.
   \>                Match the end of a word.
   \{ ... \}
   \( ... \)
   \1, \2, ..., \9    matches match specified by nth \( ... \) expression.
                      For example, '\([ \t][a-zA-Z]+\)\1[ \t]' matches any
		      word repeated consecutively.
Examples:

 Look in all files with a 'c' extension in current directory and all its
 subdirectories looking for matches of 'int ' at the beginning of a line,
 printing the line containing the match with its line number: (two methods)
    rgrep -n -R '*.c' '^int ' .
    rgrep -n -x c '^int ' .

 Highlight all matches of repeated words in file 'paper.tex':
    rgrep -h '\<\(silly\)\>[ \t]+\<\1\>' paper.tex

 Search through all files EXCEPT .o and .a file below /usr/src/linux looking
 for the string 'mouse' without regard to case:
    rgrep -i -R '*.[^ao]' mouse /usr/src/linux

 Search a fixed record length FITS file for the keyword EXTNAME:
    rgrep -W80 ^EXTNAME file.fits
   (Note that the regular expression '^[A-Z]+' will dump all fits headers.)
   
Supported Regular Expressions:
   .                  match any character except newline
   \d                match any digit
   \e                match ESC char
   *                  matches zero or more occurences of previous RE
   +                  matches one or more occurences of previous RE
   ?                  matches zero or one occurence of previous RE
   ^                  matches beginning of line
   $                  matches end of line
   [ ... ]            matches any single character between brackets.
                      For example, [-02468] matches `-' or any even digit.
		      and [-0-9a-z] matches `-' and any digit between 0 and 9
		      as well as letters a through z.
   \<                Match the beginning of a word.
   \>                Match the end of a word.
   \{ ... \}
   \( ... \)
   \1, \2, ..., \9    matches match specified by nth \( ... \) expression.
                      For example, '\([ \t][a-zA-Z]+\)\1[ \t]' matches any
		      word repeated consecutively.
Examples:

 Look in all files with a 'c' extension in current directory and all its
 subdirectories looking for matches of 'int ' at the beginning of a line,
 printing the line containing the match with its line number: (two methods)
    rgrep -n -R '*.c' '^int ' .
    rgrep -n -x c '^int ' .

 Highlight all matches of repeated words in file 'paper.tex':
    rgrep -h '\<\(silly\)\>[ \t]+\<\1\>' paper.tex

 Search through all files EXCEPT .o and .a file below /usr/src/linux looking
 for the string 'mouse' without regard to case:
    rgrep -i -R '*.[^ao]' mouse /usr/src/linux

 Search a fixed record length FITS file for the keyword EXTNAME:
    rgrep -W80 ^EXTNAME file.fits
   (Note that the regular expression '^[A-Z]+' will dump all fits headers.)
   

-- 
John E. Davis                   Center for Space Research/AXAF Science Center
617-258-8119                    MIT 37-662c, Cambridge, MA 02139
http://space.mit.edu/~davis

Re: [slrn] Regexp syntax in rc file?
#31357
Author: John E. Davis
Date: Sat, 15 Feb 1997 00:00
21 lines
1471 bytes
On 14 Feb 1997 10:23:52 GMT, Ian T Zimmerman <itz@nojunk.rahul.net>
wrote:
>In that case, I still don't understand why my setting of
>
>ignore_quotes "^[ ]*\(>[ ]*\)+"
>
>  doesn't work.  (Yes, I know it's redundant).  It seems to conform to
>the syntax you give.  In particular, it doesn't use any | connectives
>(the symbol doesn't even occur in it).

  This syntax might appear to be conforming but it is not.  The \( \)
pair simply serves to define the text matched by the regular
expression it encloses.  That text may be referenced by \1, \2, etc.
However, since you do not have reference in your expression, the
resulting regular expression is just "^[ ]*>[ ]*+" which I do not
think was your intent.

--John

Re: [slrn] Regexp syntax in rc file?
#31489
Author: Ian T Zimmerman
Date: Wed, 19 Feb 1997 00:00
43 lines
2615 bytes
In article <slrn5g9e0e.u6m.davis@mygir.davis.net>,
John E. Davis <davis@space.mit.edu> writes:

>  On 14 Feb 1997 10:23:52 GMT, Ian T Zimmerman <itz@nojunk.rahul.net>
> wrote:
> >In that case, I still don't understand why my setting of
> > ignore_quotes "^[ ]*\(>[ ]*\)+"
> >
> >  doesn't work.  (Yes, I know it's redundant).  It seems to conform
> >  to
> >the syntax you give.  In particular, it doesn't use any |
> >connectives (the symbol doesn't even occur in it).

>  This syntax might appear to be conforming but it is not.  The \( \)
> pair simply serves to define the text matched by the regular
> expression it encloses.  That text may be referenced by \1, \2, etc.
> However, since you do not have reference in your expression, the
> resulting regular expression is just "^[ ]*>[ ]*+" which I do not
> think was your intent.

Aha!  So what you're saying is that the \( \) pair doesn't group stuff
inside it for the purpose of postfixing with * or +.  Sorry, but I
don't think anybody would have guessed this without a hint, because no
other brand of regexps I know of works that way.  Also, the short
syntax summary you posted said something like "+ matches one or more
occurence of the preceding _regular expression_" (emph mine).  So in
the absence of warning to the contrary, it's natural to assume this
means _any_ kind of regexp, including \( ... \).

This really needs to be documented.

On a different subject (please redirect followups if this belongs
somewhere else), how does one actually use embedded S-Lang from C
code?  In the Programmer's Guide, there's not a word on the specifics
of this.

-- 
Ian T Zimmerman                        <itz@rahul.net>
I fully support the President's proposal to test driver's license
applicants for drugs.  Any plan to reduce driving is worth a try.

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads