Front page | perl.perl5.porters |
Postings from August 2013
Re: [perl #119095] Empty regular expression does not match in some cases
Thread Previous
|
Thread Next
From:
Aaron Crane
Date:
August 5, 2013 18:09
Subject:
Re: [perl #119095] Empty regular expression does not match in some cases
Message ID:
CACmk_tushTMosT1nfV=VvEY58hWXSRYn9Dno3z05XLB_JwMiNg@mail.gmail.com
Aristotle Pagaltzis <pagaltzis@gmx.de> wrote:
> A lot of the syntax and idioms lore that we think of as “regexps”, at
> least in a Unix-y tradition, is really the regexp vernacular of ed. The
> entire grep utility is an extraction of an ed idiom as a stand-alone
> program.
>
> And even when I say all this, I am almost certainly being ahistorical –
> I do not know in detail the lineage and history of ed and all its next
> of kin (ex/vi, grep, sed, patch etc) and would actually be surprised if
> the story weren’t more intertwined and complex than my portrayal, even
> WRT just this one aspect.
>
> (I expect Aaron to come up behind me and embarrass me now. :-) )
Nope, your summary pretty much covers it. :-)
ed(1) already exists in the First Edition manual (so before November
1971), but neither sed(1) nor grep(1) do:
http://cm.bell-labs.com/cm/cs/who/dmr/man12.pdf
http://cm.bell-labs.com/cm/cs/who/dmr/man13.pdf
grep(1) came next, in Fourth Edition (so between February and November 1973):
http://www.tuhs.org/Archive/PDP-11/Distributions/research/Dennis_v4/v4man.tar.gz
In 1975, George Coulouris at Queen Mary College (in London;
subsequently renamed Queen Mary and Westfield, and then Queen Mary,
University of London) wrote em ("editor for mortals"), an interactive
ed(1)-like editor for cursor-addressed displays. When he visited
Berkeley in 1976, he took it with him, and a certain Bill Joy took it
and morphed it into ex(1), which shipped in 1BSD (March 1978):
http://www.eecs.qmul.ac.uk/~gc/history/
vi(1) was originally (in 2BSD, May 1979) a hard link to ex(1); when it
was launched under that name, it would start in visual mode rather
than normal mode, but ex(1) had all the same abilities.
sed(1) didn't appear till Seventh Edition, in January 1979:
http://plan9.bell-labs.com/7thEdMan/v7vol1.pdf
The original diff(1) appeared in Fifth Edition (June 1974), and
originally generated only "edit scripts" (à la modern `diff -e`) that
could be passed to ed(1):
http://www.tuhs.org/Archive/PDP-11/Distributions/research/Dennis_v5/v5man.pdf
As for patch(1), Larry first wrote it in 1984, and published it in
1985; it already handled context and unified diffs at that point, as
well as the traditional edit scripts:
https://groups.google.com/forum/#!topic/mod.sources/xSQM63e39YY
Now, Ken Thompson wrote the Unix ed(1) in PDP-11 assembler:
https://code.google.com/p/unix-jun72/source/browse/trunk/src/cmd/ed2.s
https://code.google.com/p/unix-jun72/source/browse/trunk/src/cmd/ed3.s
This means it can be dated to some time in 1971, according to Dennis Ritchie:
http://cm.bell-labs.com/who/dmr/hist.html
But it turns out we can rewind a little further. A team at UCB
(including L. Peter Deutsch) wrote an editor called qed in 1968:
http://web.archive.org/web/20120219114658/http://www.computer-refuge.org/bitsavers/pdf/sds/ucbProjectGenie/mcjones/R-15_QED.pdf
It's still possible to see the core of the ed(1) design in that, even
though the details differ quite a lot; for example, the 1968 qed
doesn't have regexes at all.
Ken Thompson ported qed to CTSS circa 1970, and therefore shortly
*before* he wrote ed(1); the manual for his port can be found here:
http://cm.bell-labs.com/cm/cs/who/dmr/qedman.pdf
This is much more similar to the ed(1) we know and (presumably) love,
including regexes strictly more powerful than those in traditional
ed(1), and slashes to delimit them (where the 1968 qed used square
brackets for its search strings). And we find that the manual says
"The null regular expression standing alone is equivalent to the last
regular expression encountered."
So this aspect of Perl can be dated back to code written no later than
1970, for a text editor running on an operating system that I suspect
noone subscribed to this list has ever used.
Enjoy!
--
Aaron Crane ** http://aaroncrane.co.uk/
Thread Previous
|
Thread Next