perl 3.0 patch #19
Larry Wall
lwall at jpl-devvax.JPL.NASA.GOV
Sat Aug 11 07:26:38 AEST 1990
System: perl version 3.0
Patch #: 19
Subject: Added support for linked-in C subroutines
Subject: added require operator
Subject: added truncate operator
Subject: Added -c switch to do compilation only
Subject: added -x switch to extract script from input trash
Subject: bare identifiers are now strings if no other interpretation possible
Subject: Added __LINE__ and __FILE__ tokens
Subject: Added __END__ token
Subject: program and data can now both come from STDIN
Subject: `command` in array context now returns array of lines
Subject: empty %array now returns 0 in scalar context
Subject: . is now explicitly in @INC (and last)
Subject: sped up /x+y/ patterns greatly by not retrying on every x
Subject: inhibited backoff on patterns anchored to the end like /\s+$/
Subject: sped up {m,n} on simple items
Subject: optimized /.*whatever/ to /^.*whatever/
Subject: fixed character classes to allow backslashing hyphen
Subject: $ will now only match at end of string if $* == 0
Subject: Added explanation of my interpretation of GPL with respect to Perl
Subject: did preliminary work toward debugging packages and evals
Subject: conditionals now always supply a scalar context to expression
Subject: switch optimizer was confused by negative fractional values
Subject: Configure now checks for chsize, select and truncate
Subject: Configure now asks where you want to put scripts
Subject: Numeric literals are now stored only in floating point
Subject: fixed problem with % of negative number
Subject: fixed double include of <signal.h>
Subject: pack/unpack can now do native float and double
Subject: pack/unpack can now have absolute and negative positioning
Subject: pack/unpack can now have use * to specify all the rest of input
Subject: unpack can do checksumming
Subject: $< and $> better supported on machines without setreuid
Subject: various MSDOS and OS/2 patches folded in
Subject: open(STDOUT,"|command") left wrong descriptor attached to STDOUT
Subject: prints now check error status better
Subject: printing a list with null elements only printed front of list
Subject: on machines with vfork child would allocate memory in parent
Subject: getsockname and getpeername gave bogus warning on error
Subject: MACH doesn't have seekdir or telldir
Subject: certain kinds of matching cause "panic: hint"
Subject: $' broke on embedded nulls
Subject: split on /\s+/, /^/ and ' ' is now special cased for speed
Subject: split on /x/i didn't work
Subject: couldn't unpack an 'A' or 'a' field in a scalar context
Subject: unpack called bcopy on each character of a C/c field
Subject: pack/unpack know about uudecode lines
Subject: fixed sort on undefined strings and sped up slightly
Subject: each and keys returned garbage on null key in DBM file
Subject: added man page for relink and rename
Subject: made ~ do vector operation on strings like &, | and ^
Subject: dbmopen(%name...) didn't work right
Subject: dbmopen(name, 'filename', undef) now refrains from creating
Subject: die with no arguments no longer exits unconditionally
Subject: return outside a subroutine now returns a reasonable message
Subject: rename done with unlink()/link()/unlink() now checks for clobbering
Subject: -s now returns size of file
Subject: passing *name to subroutine now forces filehandle and array creation
Subject: <handle> input is a little more efficient
Subject: dumpvar.pl now fixes weird chars and allows a list of vars to dump
Subject: debugger now allows continuation lines
Subject: debugger can now dump lists of variables
Subject: debugger can now add aliases easily from prompt
Subject: null-label lines threw off line number of next statement
Subject: split; didn't pass correct bufend to scanpat
Subject: added numeric interpretation of $]
Subject: $0, %ENV, @ARGV were wrong in dumped script
Subject: %ENV wasn't forced to be global like it should
Subject: $| didn't work before the filehandle was opened
Subject: $! now returns "" in string context if errno == 0
Subject: the number to string converter wasn't allocating enough space
Subject: tainting didn't work on setgid scripts
Subject: bare @name didn't add array to symbol table
Subject: some support for FPS compiler misfunction
Subject: "\\$foo" not handled right
Subject: "here" strings caused warnings about uninitialized variables
Subject: a2p didn't handle {foo = (bar == 123)}
Subject: a2p didn't emit a chop when NF was referenced though split needs it
Subject: s2p didn't translate \n right
Subject: a2p emited local($_) without a semicolon
Subject: a2p didn't make explicit split on whitespace skip leading whitespace
Subject: foreach on a normal array was iterating on values instead of indexes
Description:
You now have the capability of linking C subroutines into a
special version of perl. See the files in usub/ for an example.
There is now an operator to include library modules with duplicate
suppression and error checking, called "require". (makelib has been
renamed to h2ph, and Tom Christiansen's h2pl stuff has been included
too. Perl .h files are now called .ph files to avoid confusion.)
It's now possible to truncate files if your machines supports any
of ftruncate(fd, size), chsize(fd, size) or fcntl(fd, F_FREESP, size).
Added -c switch to do compilation only, that is, to suppress
execution. Useful in combination with -D1024.
There's now a -x switch to extract a script from the input stream
so you can pipe articles containing Perl scripts directly into perl.
Previously, the only places you could use bare words in Perl were as
filehandles or labels. You can now put bare words (identifiers)
anywhere. If they have no interpretation as filehandles or labels,
they will be treated as if they had single quotes around them.
This works together nicely with the fact that you can use a
symbol name indirectly as a filehandle or to assign to *name.
It basically means you can write subroutines and pass filehandles
without quoting or *-ing them. (It also means the grammar is even
more ambiguous now--59 reduce/reduce conflicts!!! But it seems
to do the Right Thing.)
Added __LINE__ and __FILE__ tokens to let you interpolate the
current line number or filename, such as in a call to an error
routine, or to help you translate eval linenumbers to real
linenumbers.
Added __END__ token to let you mark the end of the program in
the input stream. (^D and ^Z are allowed synonyms.) Program text
and data can now both come from STDIN.
`command` in array context now returns array of lines. Previously
it would return a single element array holding all the lines.
An empty %array now returns 0 in scalar context so that you can
use it profitably in a conditional: &blurfl if %seen;
The include search path (@INC) now includes . explicity at the
end, so you can change it if you wish. Library routines now
have precedence by default.
Several pattern matching optimizations: I sped up /x+y/ patterns
greatly by not retrying on every x, and disabled backoff on
patterns anchored to the end like /\s+$/. This made /\s+$/ run
100 times faster on a string containing 70 spaces followed by an X.
Actual improvements will generally be less than that. I also
sped up {m,n} on simple items by making it a variant of *.
And /.*whatever/ is now optimizaed to /^.*whatever/ to avoid
retrying at every position in the event of failure. I fixed
character classes to allow backslashing hyphen, by popular
request.
In the past, $ in a pattern would sometimes match in the middle
of the string and sometimes not, if $* == 0. Now it will never
match except at the end of the string, or just before a terminating
newline. When $* == 1 behavior is as before.
In the README file, I've expanded on just how I think the GNU
General Public License applies to Perl and to things you might
want to do with Perl.
The interpreter used to set the global variable "line" to be
the current line number. Instead, it now sets a global pointer
to the current Perl statement, which is no more overhead, but
now we will have access to the file name and package name associated
with that statement, so that the debugger soon be upgraded to
allow debugging of evals and packages.
In the past, a conditional construct in an array context passed
the array context on to the conditional expression, causing
general consternation and confusion. Conditionals now always
supply a scalar context to the expression, and if that expression
turns out to be the one whose value is returned, the value is
coerced to an array value of one element.
The switch optimizer was confused by negative fractional values,
and truncating them the wrong direction.
Configure now checks for chsize, select and truncate functions, and
now asks if you want to put scripts into some separate directory
from your binaries. More and more people are establishing a common
directory across architectures for scripts, so this is getting
important.
It used to be that a numeric literal ended up being stored both
as a string and as a double. This could make for lots of wasted
storage if you said things like "$seen{$key} = 1;". So now
numeric literals are now stored only in floating point format,
which saves space, and generates at most one extra conversion per
literal over the life of the script.
The % operator had an off-by-one error if the left argument was
negative.
The pack and unpack functions have been upgraded. You
can now convert native float and double fields using f and d.
You can specify negative relative positions with X<n>, and absolute
positions in the record with @<n>. You can have a length of *
on the final field to indicate that it is to gobble all the rest
of the available fields. In unpack, if you precede a field
spec with %<n>, it does an n-bit checksum on it instead of the
value itself. (Thus "%16C*" will checksum just like the Sys V sum
program.) One totally wacked out evening I hacked a u format
in to pack and unpack uudecode-style strings.
A couple bugs were fixed in unpack--it couldn't unpack an A or a
format field in a scalar context, which is just supposed to
return the first field. The c and C formats were also calling
bcopy to copy each character. Yuck.
Machines without the setreuid() system call couldn't manipulate
$< and $> easily. Now, if you've got setuid(), you can say $< = $>
or $> = $< or even ($<, $>) = ($uid, $uid), as long as it's
something that can be done with setuid(). Similarly for setgid().
I've included various MSDOS and OS/2 patches that people have sent.
There's still more in the hopper...
An open on a pipe for output such as 'open(STDOUT,"|command")' left
STDOUT attached to the wrong file descriptor. This didn't matter
within Perl, but it made subprocesses expecting stdout to be on fd 1
rather irate.
The print command could fail to detect errors such as running out
room on the disk. Now it checks a little better.
Saying "print @foo" might only print out some of the elements
if there undefined elements in the middle of the array, due to
a reversed bit of logic in the print routine.
On machines with vfork the child process would allocate memory
in the parent without the parent knowing about it, or having any way
to free the memory so allocated. The parent now calls a cleanup
routine that knows whether that's what happened.
If the getsockname or getpeername functions returned a normal
Unix error, perl -w would report that you tried I/O on an
unopened socket, even though it was open.
MACH doesn't have seekdir or telldir. Who ever uses them anyway?
Under certain circumstances, an optimized pattern match could
pass a hint into the standard pattern matching routine which
the standard routine would then ignore. The next pattern match
after that would then get a "panic: hint in do_match" because the
hint didn't point into the current string of interest.
The $' variable returned a short string if it contained an
embedded null.
Two common split cases are now special-cased to avoid the regular
expression code. One is /\s+/ (and its cousin ' ', which also
trims leading whitespace). The other is /^/, which is very useful
for splitting a "here-is" quote into lines:
@lines = split(/^/, <<END);
Element 0
Element 1
Element 2
END
You couldn't split on a single case-insensitive letter because
the single character split optimization ignore the case folding
flag.
Sort now handles undefined strings right, and sorts lists
a little more efficiently because it weeds them out before
sorting so it doesn't have to check for them on every comparison.
The each() and keys() functions were returning garbage on null
keys in DBM files because the DBM iterator merely returns a pointer
into the buffer to a string that's not necessarily null terminated.
Internally, Perl keeps a null at the end of every string (though
allowing embedded nulls) and some routines make use of this
to avoid checking for the end of buffer on every comparison. So
this just needed to be treated as a special case.
The &, | and ^ operators will do bitwise operations on two strings,
but for some reason I hadn't implemented ~ to do a complement.
Using an associative array name with a % in dbmopen(%name...)
didn't work right, not because it didn't parse, but because the
dbm opening routine internally did the wrong thing with it.
You can now say dbmopen(name, 'filename', undef) to prevent it
from opening the dbm file if it doesn't exist.
The die operator simply exited if you didn't give an argument,
because that made sense before eval existed. But now it will be
equivalent to "die 'Died';".
Using the return function outside a subroutine returned a cryptic
message about not being able to pop a magical label off the stack.
It's now more informative.
On systems without the rename() system call, it's emulated with
unlink()/link()/unlink(), which could clobber a file if it
happened to unlink it before it linked it. Perl now checks to
make sure the source and destination filenames aren't in fact
the same directory entry.
The -s file test now returns size of file. Why not?
If you tried to write a general subroutine to open files, passing
in the filehandle as *filehandle, it didn't work because nobody
took responsibility to allocate the filehandle structure internally.
Now, passing *name to subroutine forces filehandle and array
creation on that symbol if they're already not created.
Reading input via <HANDLE> is now a little more efficient--it
does one less string copy.
The dumpvar.pl routine now fixes weird chars to be printable, and
allows you to specify a list of varables to display. The debugger
takes advantage of this. The debugger also now allows \ continuation
lines, and has an = command to let you make aliases easily. Line
numbers should now be correct even after lines containing only
a semicolon.
The action code for parsing split; with no arguments didn't
pass correct a corrent value of bufend to the scanpat it was
using to establish the /\s+/ pattern.
The $] variable returned the rcsid string and patchlevel. It still
returns that in a string context, but in a numeric context it
returns the version number (as in 4.0) + patchlevel / 1000.
So these patches are being applied to 3.018.
The variables $0, %ENV, @ARGV were retaining incorrect information
from the previous incarnation in dumped/undumped scripts.
The %ENV array is suppose to be global even inside packages, but
and off-by-one error kept it from being so.
The $| variable couldn't be set on a filehandle before the file
was opened. Now you can.
If errno == 0, the $! variable returned "Error 0" in a string
context, which is, unfortunately, a true string. It now returns ""
in string context if errno == 0, so you can use it reasonable in
a conditional without comparing it to 0: &cleanup if $!;
On some machines, conversion of a number to a string caused
a malloc string to be overrun by 1 character. More memory is
now allocated for such a string.
The tainting mechanism didn't work right on scripts that were setgid
but not setuid.
If you had reference to an array such as @name in a program, but
didn't invoke any of the usual array operations, the array never
got initialized.
The FPS compiler doesn't do default in a switch very well if the
value can be interpreted as a signed character. There's now a
#ifdef BADSWITCH for such machines.
Certain combinations of backslashed backslashes weren't correctly
parsed inside double-quoted strings.
"Here" strings caused warnings about uninitialized variables because
the string used internally to accumulate the lines wasn't initialized
according to the standards of the -w switch.
The a2p translator couldn't parse {foo = (bar == 123)} due to
a hangover from the old awk syntax. It also needed to put a
chop into a program if the program referenced NF so that the
field count would come out right when the split was done.
There was a missing semicolon when local($_) was emitted.
I also didn't realize that an explicity awk split on ' ' trims
leading whitespace just like the implicit split at the beginning
of the loop. The awk for..in loop has to be translated in one
of two ways in a2p, depending on whether the array was produced
by a split or by subscripting. If the array was a normal array,
a2p put out code that iterated over the array values rather than
the numeric indexes, which was wrong.
The s2p didn't translate \n correctly, stripping the backslash.
Fix: From rn, say "| patch -p -N -d DIR", where DIR is your perl source
directory. Outside of rn, say "cd DIR; patch -p -N <thisarticle".
If you don't have the patch program, apply the following by hand,
or get patch (version 2.0, latest patchlevel).
After patching:
*** DO NOTHING--INSTALL ALL PATCHES UP THROUGH #27 FIRST ***
If patch indicates that patchlevel is the wrong version, you may need
to apply one or more previous patches, or the patch may already
have been applied. See the patchlevel.h file to find out what has or
has not been applied. In any event, don't continue with the patch.
If you are missing previous patches they can be obtained from me:
Larry Wall
lwall at jpl-devvax.jpl.nasa.gov
If you send a mail message of the following form it will greatly speed
processing:
Subject: Command
@SH mailpatch PATH perl 3.0 LIST
^ note the c
where PATH is a return path FROM ME TO YOU either in Internet notation,
or in bang notation from some well-known host, and LIST is the number
of one or more patches you need, separated by spaces, commas, and/or
hyphens. Saying 35- says everything from 35 to the end.
You can also get the patches via anonymous FTP from
jpl-devvax.jpl.nasa.gov (128.149.1.143).
Index: patchlevel.h
Prereq: 18
1c1
< #define PATCHLEVEL 18
---
> #define PATCHLEVEL 19
Index: Configure
Prereq: 3.0.1.7
*** Configure.old Thu Aug 9 05:55:27 1990
--- Configure Thu Aug 9 05:55:35 1990
***************
*** 8,23 ****
# and edit it to reflect your system. Some packages may include samples
# of config.h for certain machines, so you might look for one of those.)
#
! # $Header: Configure,v 3.0.1.7 90/03/28 09:14:53 lwall Locked $
!
! : make sure these files are renamed
! test -f config_h.SH || mv -f config.h.SH config_h.SH
! test -f perl_man.1 || mv -f perl.man.1 perl_man.1
! test -f perl_man.2 || mv -f perl.man.2 perl_man.2
! test -f perl_man.3 || mv -f perl.man.3 perl_man.3
! test -f perl_man.4 || mv -f perl.man.4 perl_man.4
! test -f t/op.s || mv -f t/op.subst t/op.s
!
#
# Yes, you may rip this off to use in other distribution packages.
# (Note: this Configure script was generated automatically. Rather than
--- 8,14 ----
# and edit it to reflect your system. Some packages may include samples
# of config.h for certain machines, so you might look for one of those.)
#
! # $Header: Configure,v 3.0.1.8 90/08/09 01:47:24 lwall Locked $
#
# Yes, you may rip this off to use in other distribution packages.
# (Note: this Configure script was generated automatically. Rather than
***************
*** 113,118 ****
--- 104,110 ----
d_bzero=''
d_castneg=''
d_charsprf=''
+ d_chsize=''
d_crypt=''
cryptlib=''
d_csh=''
***************
*** 140,145 ****
--- 132,138 ----
d_readdir=''
d_rename=''
d_rmdir=''
+ d_select=''
d_setegid=''
d_seteuid=''
d_setpgrp=''
***************
*** 161,166 ****
--- 154,160 ----
d_strerror=''
d_symlink=''
d_syscall=''
+ d_truncate=''
d_varargs=''
d_vfork=''
d_voidsig=''
***************
*** 212,217 ****
--- 206,212 ----
c=''
package=''
randbits=''
+ scriptdir=''
sig_name=''
spitshell=''
shsharp=''
***************
*** 1406,1424 ****
else
ans=`loc libc.a blurfl/dyick $libpth`
if test ! -f "$ans"; then
! ans=`loc libc blurfl/dyick $libpth`
fi
if test ! -f "$ans"; then
! ans=`loc clib blurfl/dyick $libpth`
fi
if test ! -f "$ans"; then
! ans=`loc Slibc.a blurfl/dyick $xlibpth`
fi
if test ! -f "$ans"; then
! ans=`loc Mlibc.a blurfl/dyick $xlibpth`
fi
if test ! -f "$ans"; then
! ans=`loc Llibc.a blurfl/dyick $xlibpth`
fi
if test -f "$ans"; then
echo "Your C library is in $ans, of all places."
--- 1401,1421 ----
else
ans=`loc libc.a blurfl/dyick $libpth`
if test ! -f "$ans"; then
! ans=`loc Slibc.a blurfl/dyick $xlibpth`
fi
if test ! -f "$ans"; then
! ans=`loc Mlibc.a blurfl/dyick $xlibpth`
fi
if test ! -f "$ans"; then
! ans=`loc Llibc.a blurfl/dyick $xlibpth`
fi
if test ! -f "$ans"; then
! ans=`loc libc blurfl/dyick $libpth`
fi
if test ! -f "$ans"; then
! ans=`loc clib blurfl/dyick $libpth`
! else
! libnames="$libnames "`loc clib blurfl/dyick $libpth`
fi
if test -f "$ans"; then
echo "Your C library is in $ans, of all places."
***************
*** 1584,1589 ****
--- 1581,1590 ----
d_charvspr="$undef"
fi
+ : see if chsize exists
+ set chsize d_chsize
+ eval $inlibc
+
: see if crypt exists
echo " "
if $contains '^crypt$' libc.list >/dev/null 2>&1; then
***************
*** 1908,1913 ****
--- 1909,1918 ----
set rmdir d_rmdir
eval $inlibc
+ : see if select exists
+ set select d_select
+ eval $inlibc
+
: see if setegid exists
set setegid d_setegid
eval $inlibc
***************
*** 2078,2083 ****
--- 2083,2092 ----
esac
$rm -f try.c try
+ : see if truncate exists
+ set truncate d_truncate
+ eval $inlibc
+
: see if this is a varargs system
echo " "
if $test -r /usr/include/varargs.h ; then
***************
*** 2511,2516 ****
--- 2520,2568 ----
*) mallocsrc=''; mallocobj='';;
esac
+ : determine where public executables go
+ case "$scriptdir" in
+ '')
+ dflt="$bin"
+ : guess some guesses
+ test -d /usr/share/scripts && dflt=/usr/share/scripts
+ test -d /usr/share/bin && dflt=/usr/share/bin
+ ;;
+ *) dflt="$scriptdir"
+ ;;
+ esac
+ cont=true
+ $cat <<EOM
+
+ Some installations have a separate directory just for executable scripts so
+ that they can mount it across multiple architectures but keep the scripts in
+ one spot. You might, for example, have a subdirectory of /usr/share for this.
+ Or you might just lump your scripts in with all your other executables.
+
+ EOM
+ while $test "$cont" ; do
+ rp="Where do you keep publicly executable scripts? (~name ok) [$dflt]"
+ $echo $n "$rp $c"
+ . myread
+ scriptdir="$ans"
+ scriptdir=`./filexp "$scriptdir"`
+ if test -d $scriptdir; then
+ cont=''
+ else
+ case "$fastread" in
+ yes) dflt=y;;
+ *) dflt=n;;
+ esac
+ rp="Directory $scriptdir doesn't exist. Use that name anyway? [$dflt]"
+ $echo $n "$rp $c"
+ . myread
+ dflt=''
+ case "$ans" in
+ y*) cont='';;
+ esac
+ fi
+ done
+
: determine compiler compiler
case "$yacc" in
'') dflt=yacc;;
***************
*** 2607,2612 ****
--- 2659,2665 ----
d_bzero='$d_bzero'
d_castneg='$d_castneg'
d_charsprf='$d_charsprf'
+ d_chsize='$d_chsize'
d_crypt='$d_crypt'
cryptlib='$cryptlib'
d_csh='$d_csh'
***************
*** 2634,2639 ****
--- 2687,2693 ----
d_readdir='$d_readdir'
d_rename='$d_rename'
d_rmdir='$d_rmdir'
+ d_select='$d_select'
d_setegid='$d_setegid'
d_seteuid='$d_seteuid'
d_setpgrp='$d_setpgrp'
***************
*** 2655,2660 ****
--- 2709,2715 ----
d_strerror='$d_strerror'
d_symlink='$d_symlink'
d_syscall='$d_syscall'
+ d_truncate='$d_truncate'
d_varargs='$d_varargs'
d_vfork='$d_vfork'
d_voidsig='$d_voidsig'
***************
*** 2706,2711 ****
--- 2761,2767 ----
c='$c'
package='$package'
randbits='$randbits'
+ scriptdir='$scriptdir'
sig_name='$sig_name'
spitshell='$spitshell'
shsharp='$shsharp'
Index: MANIFEST
*** MANIFEST.old Thu Aug 9 05:55:47 1990
--- MANIFEST Thu Aug 9 05:55:48 1990
***************
*** 40,47 ****
eg/muck.man Manual page for muck
eg/myrup A program to find lightly loaded machines
eg/nih Script to insert #! workaround
- eg/rename A program to rename files
eg/relink A program to change symbolic links
eg/rmfrom A program to feed doomed filenames to
eg/scan/scan_df Scan for filesystem anomalies
eg/scan/scan_last Scan for login anomalies
--- 40,47 ----
eg/muck.man Manual page for muck
eg/myrup A program to find lightly loaded machines
eg/nih Script to insert #! workaround
eg/relink A program to change symbolic links
+ eg/rename A program to rename files
eg/rmfrom A program to feed doomed filenames to
eg/scan/scan_df Scan for filesystem anomalies
eg/scan/scan_last Scan for login anomalies
***************
*** 63,81 ****
form.c Format processing
form.h Public declarations for the above
gettest A little script to test the get* routines
handy.h Handy definitions
hash.c Associative arrays
hash.h Public declarations for the above
ioctl.pl Sample ioctl.pl
lib/abbrev.pl An abbreviation table builder
- lib/look.pl A "look" equivalent
lib/complete.pl A command completion subroutine
lib/ctime.pl A ctime workalike
lib/dumpvar.pl A variable dumper
lib/getopt.pl Perl library supporting option parsing
lib/getopts.pl Perl library supporting option parsing
lib/importenv.pl Perl routine to get environment into variables
lib/perldb.pl Perl debugging routines
lib/stat.pl Perl library supporting stat function
lib/syslog.pl Perl library supporting syslogging
lib/termcap.pl Perl library supporting termcap usage
--- 63,97 ----
form.c Format processing
form.h Public declarations for the above
gettest A little script to test the get* routines
+ h2ph.SH A thing to turn C .h file into perl .ph files
+ h2pl/README How to turn .ph files into .pl files
+ h2pl/cbreak.pl cbreak routines using .ph
+ h2pl/cbreak2.pl cbreak routines using .pl
+ h2pl/eg/sizeof.ph Sample sizeof array initialization
+ h2pl/eg/sys/errno.pl Sample translated errno.pl
+ h2pl/eg/sys/ioctl.pl Sample translated ioctl.pl
+ h2pl/eg/sysexits.pl Sample translated sysexits.pl
+ h2pl/getioctlsizes Program to extract types from ioctl.h
+ h2pl/mksizes Program to make %sizeof array.
+ h2pl/mkvars Program to make .pl from .ph files
+ h2pl/tcbreak cbreak test routine using .ph
+ h2pl/tcbreak2 cbreak test routine using .pl
handy.h Handy definitions
hash.c Associative arrays
hash.h Public declarations for the above
ioctl.pl Sample ioctl.pl
lib/abbrev.pl An abbreviation table builder
lib/complete.pl A command completion subroutine
lib/ctime.pl A ctime workalike
lib/dumpvar.pl A variable dumper
+ lib/flush.pl Routines to do single flush
lib/getopt.pl Perl library supporting option parsing
lib/getopts.pl Perl library supporting option parsing
lib/importenv.pl Perl routine to get environment into variables
+ lib/look.pl A "look" equivalent
+ lib/nsyslog.pl Newer syslog.pl
lib/perldb.pl Perl debugging routines
+ lib/pwd.pl Routines to keep track of PWD environment variable
lib/stat.pl Perl library supporting stat function
lib/syslog.pl Perl library supporting syslogging
lib/termcap.pl Perl library supporting termcap usage
***************
*** 82,88 ****
lib/validate.pl Perl library supporting wholesale file mode validation
makedepend.SH Precursor to makedepend
makedir.SH Precursor to makedir
! makelib.SH A thing to turn C .h file into perl .h files
malloc.c A version of malloc you might not want
msdos/Changes.dds Expanation of MS-DOS patches by Diomidis Spinellis
msdos/Makefile MS-DOS makefile
--- 98,104 ----
lib/validate.pl Perl library supporting wholesale file mode validation
makedepend.SH Precursor to makedepend
makedir.SH Precursor to makedir
! makelib.SH Deprecated (renamed to h2ph)
malloc.c A version of malloc you might not want
msdos/Changes.dds Expanation of MS-DOS patches by Diomidis Spinellis
msdos/Makefile MS-DOS makefile
***************
*** 97,115 ****
msdos/glob.c A command equivalent to csh glob
msdos/msdos.c MS-DOS ioctl, sleep, gete?[gu]if, spawn, aspawn
msdos/popen.c My_popen and my_pclose for MS-DOS
patchlevel.h The current patch level of perl
perl.h Global declarations
perl_man.1 The manual page(s), first fourth
perl_man.2 The manual page(s), second fourth
perl_man.3 The manual page(s), third fourth
perl_man.4 The manual page(s), fourth fourth
- perl.y Yacc grammar for perl
perlsh A poor man's perl shell
perly.c main()
regcomp.c Regular expression compiler
regcomp.h Private declarations for above
- regexp.h Public declarations for the above
regexec.c Regular expression evaluator
server A server to test sockets
spat.h Search pattern declarations
stab.c Symbol table stuff
--- 113,138 ----
msdos/glob.c A command equivalent to csh glob
msdos/msdos.c MS-DOS ioctl, sleep, gete?[gu]if, spawn, aspawn
msdos/popen.c My_popen and my_pclose for MS-DOS
+ os2/Makefile Makefile for OS/2
+ os2/README.OS2 Notes for OS/2
+ os2/config.h Configuration file for OS/2
+ os2/eg/os2.pl Sample script for OS/2
+ os2/eg/syscalls.pl Example of syscall on OS/2
+ os2/popen.c Code for opening pipes
+ os2/suffix.c Code for creating backup filenames
patchlevel.h The current patch level of perl
perl.h Global declarations
+ perl.y Yacc grammar for perl
perl_man.1 The manual page(s), first fourth
perl_man.2 The manual page(s), second fourth
perl_man.3 The manual page(s), third fourth
perl_man.4 The manual page(s), fourth fourth
perlsh A poor man's perl shell
perly.c main()
regcomp.c Regular expression compiler
regcomp.h Private declarations for above
regexec.c Regular expression evaluator
+ regexp.h Public declarations for the above
server A server to test sockets
spat.h Search pattern declarations
stab.c Symbol table stuff
***************
*** 175,180 ****
--- 198,204 ----
t/op.read See if read() works
t/op.regexp See if regular expressions work
t/op.repeat See if x operator works
+ t/op.s See if substitutions work
t/op.sleep See if sleep works
t/op.sort See if sort works
t/op.split See if split works
***************
*** 181,187 ****
t/op.sprintf See if sprintf works
t/op.stat See if stat works
t/op.study See if study works
- t/op.s See if substitutions work
t/op.substr See if substr works
t/op.time See if time functions work
t/op.undef See if undef works
--- 205,210 ----
***************
*** 190,195 ****
--- 213,225 ----
t/op.write See if write works
t/re_tests Input file for op.regexp
toke.c The tokener
+ usersub.c User supplied (possibly proprietary) subroutines
+ usub/Makefile Makefile for curseperl
+ usub/curses.mus Glue routines for BSD curses
+ usub/man2mus A manual page to .mus translator
+ usub/mus A .mus to .c translator
+ usub/pager A sample pager in curseperl
+ usub/usersub.c An initialization file to call curses glue routines
util.c Utility routines
util.h Public declarations for the above
x2p/EXTERN.h Same as above
Index: usub/Makefile
*** usub/Makefile.old Thu Aug 9 06:01:42 1990
--- usub/Makefile Thu Aug 9 06:01:43 1990
***************
*** 0 ****
--- 1,16 ----
+ SRC = /usr/local/src/perl
+ GLOBINCS =
+ LOCINCS =
+ LIBS = -lcurses -ltermlib
+
+ curseperl: $(SRC)/uperl.o usersub.o curses.o
+ cc $(SRC)/uperl.o usersub.o curses.o $(LIBS) -lm -o curseperl
+
+ usersub.o: usersub.c
+ cc -c -I$(SRC) $(GLOBINCS) -DDEBUGGING -g usersub.c
+
+ curses.o: curses.c
+ cc -c -I$(SRC) $(GLOBINCS) -DDEBUGGING -g curses.c
+
+ curses.c: curses.mus
+ mus curses.mus >curses.c
Index: os2/Makefile
*** os2/Makefile.old Thu Aug 9 06:02:12 1990
--- os2/Makefile Thu Aug 9 06:02:14 1990
***************
*** 0 ****
--- 1,124 ----
+ #
+ # Makefile for compiling Perl under OS/2
+ #
+ # Needs a Unix compatible make.
+ # This makefile works for an initial compilation. It does not
+ # include all dependencies and thus is unsuitable for serious
+ # development work. Hey, I'm just inheriting what Diomidis gave me.
+ #
+ # Originally by Diomidis Spinellis, March 1990
+ # Adjusted for OS/2 port by Raymond Chen, June 1990
+ #
+
+ # Source files
+ SRC = array.c cmd.c cons.c consarg.c doarg.c doio.c dolist.c dump.c \
+ eval.c form.c hash.c perl.y perly.c regcomp.c regexec.c \
+ stab.c str.c toke.c util.c os2.c popen.c director.c
+
+ # Object files
+ OBJ = perl.obj array.obj cmd.obj cons.obj consarg.obj doarg.obj doio.obj \
+ dolist.obj dump.obj eval.obj form.obj hash.obj perly.obj regcomp.obj \
+ regexec.obj stab.obj str.obj toke.obj util.obj os2.obj popen.obj \
+ director.obj suffix.obj
+
+ # Files in the OS/2 distribution
+ DOSFILES=config.h director.c makefile os2.c popen.c suffix.c readme.os2
+
+ # Yacc flags
+ YFLAGS=-d
+
+ # Manual pages
+ MAN=perlman.1 perlman.2 perlman.3 perlman.4
+
+ CC=cl
+ # CBASE = flags everybody gets
+ # CPLAIN = flags for modules that give the compiler indigestion
+ # CFLAGS = flags for milder modules
+ # PERL = which version of perl to build
+ #
+ # For preliminary building: No optimization, DEBUGGING set, symbols included.
+ #CBASE=-AL -Zi -G2 -Gs -DDEBUGGING
+ #CPLAIN=$(CBASE) -Od
+ #CFLAGS=$(CBASE) -Od
+ #PERL=perlsym.exe
+
+ # For the final build: Optimization on, no DEBUGGING, symbols stripped.
+ CBASE=-AL -Zi -G2 -Gs
+ CPLAIN=$(CBASE) -Oilt
+ CFLAGS=$(CBASE) -Ox
+ PERL=perl.exe
+
+ # Destination directory for executables
+ DESTDIR=\usr\bin
+
+ # Deliverables
+ #
+ all: $(PERL) glob.exe
+
+ perl.exe: $(OBJ) perl.arp
+ link @perl.arp,perl,nul,/stack:32767 /NOE;
+ exehdr /nologo /newfiles /pmtype:windowcompat perl.exe >nul
+
+ perlsym.exe: $(OBJ) perl.arp
+ link @perl.arp,perlsym,nul,/stack:32767 /NOE /CODE;
+ exehdr /nologo /newfiles /pmtype:windowcompat perlsym.exe >nul
+
+ perl.arp:
+ echo array+cmd+cons+consarg+doarg+doio+dolist+dump+ >perl.arp
+ echo eval+form+hash+perl+perly+regcomp+regexec+stab+suffix+ >>perl.arp
+ echo str+toke+util+os2+popen+director+\c600\lib\setargv >>perl.arp
+
+ glob.exe: glob.c
+ $(CC) glob.c \c600\lib\setargv.obj -link /NOE
+ exehdr /nologo /newfiles /pmtype:windowcompat glob.exe >nul
+
+ array.obj: array.c
+ $(CC) $(CPLAIN) -c array.c
+ cmd.obj: cmd.c
+ cons.obj: cons.c perly.h
+ consarg.obj: consarg.c
+ # $(CC) $(CPLAIN) -c consarg.c
+ doarg.obj: doarg.c
+ doio.obj: doio.c
+ dolist.obj: dolist.c
+ dump.obj: dump.c
+ eval.obj: eval.c evalargs.xc
+ $(CC) /B3 \c600\binp\c3l $(CFLAGS) -c eval.c
+ form.obj: form.c
+ hash.obj: hash.c
+ perl.obj: perl.y
+ perly.obj: perly.c
+ regcomp.obj: regcomp.c
+ regexec.obj: regexec.c
+ stab.obj: stab.c
+ $(CC) $(CPLAIN) -c stab.c
+ str.obj: str.c
+ suffix.obj: suffix.c
+ toke.obj: toke.c
+ $(CC) /B3 \c600\binp\c3l $(CFLAGS) -c toke.c
+ util.obj: util.c
+ # $(CC) $(CPLAIN) -c util.c
+ perly.h: ytab.h
+ cp ytab.h perly.h
+ director.obj: director.c
+ popen.obj: popen.c
+ os2.obj: os2.c
+
+ perl.1: $(MAN)
+ nroff -man $(MAN) >perl.1
+
+ install: all
+ exepack perl.exe $(DESTDIR)\perl.exe
+ exepack glob.exe $(DESTDIR)\glob.exe
+
+ clean:
+ rm -f *.obj *.exe perl.1 perly.h perl.arp
+
+ tags:
+ ctags *.c *.h *.xc
+
+ dosperl:
+ mv $(DOSFILES) ../perl30.new
+
+ doskit:
+ mv $(DOSFILES) ../os2
Index: Makefile.SH
Prereq: 3.0.1.6
*** Makefile.SH.old Thu Aug 9 05:55:56 1990
--- Makefile.SH Thu Aug 9 05:55:58 1990
***************
*** 25,33 ****
echo "Extracting Makefile (with variable substitutions)"
cat >Makefile <<!GROK!THIS!
! # $Header: Makefile.SH,v 3.0.1.6 90/03/27 15:27:15 lwall Locked $
#
# $Log: Makefile.SH,v $
# Revision 3.0.1.6 90/03/27 15:27:15 lwall
# patch16: MSDOS support
#
--- 25,37 ----
echo "Extracting Makefile (with variable substitutions)"
cat >Makefile <<!GROK!THIS!
! # $Header: Makefile.SH,v 3.0.1.7 90/08/09 02:19:56 lwall Locked $
#
# $Log: Makefile.SH,v $
+ # Revision 3.0.1.7 90/08/09 02:19:56 lwall
+ # patch19: Configure now asks where you want to put scripts
+ # patch19: Added support for linked-in C subroutines
+ #
# Revision 3.0.1.6 90/03/27 15:27:15 lwall
# patch16: MSDOS support
#
***************
*** 56,61 ****
--- 60,66 ----
CC = $cc
YACC = $yacc
bin = $bin
+ scriptdir = $scriptdir
privlib = $privlib
mansrc = $mansrc
manext = $manext
***************
*** 76,88 ****
cat >>Makefile <<'!NO!SUBS!'
private =
MAKE = make
! manpages = perl.man
util =
! sh = Makefile.SH makedepend.SH
h1 = EXTERN.h INTERN.h arg.h array.h cmd.h config.h form.h handy.h
h2 = hash.h perl.h regcomp.h regexp.h spat.h stab.h str.h util.h
--- 81,95 ----
cat >>Makefile <<'!NO!SUBS!'
private =
+ scripts = h2ph
+
MAKE = make
! manpages = perl.man h2ph.man
util =
! sh = Makefile.SH makedepend.SH h2ph.SH
h1 = EXTERN.h INTERN.h arg.h array.h cmd.h config.h form.h handy.h
h2 = hash.h perl.h regcomp.h regexp.h spat.h stab.h str.h util.h
***************
*** 117,123 ****
.c.o:
$(CC) -c $(CFLAGS) $(LARGE) $*.c
! all: $(public) $(private) $(util) perl.man
cd x2p; $(MAKE) all
touch all
--- 124,130 ----
.c.o:
$(CC) -c $(CFLAGS) $(LARGE) $*.c
! all: $(public) $(private) $(util) perl.man uperl.o $(scripts)
cd x2p; $(MAKE) all
touch all
***************
*** 124,139 ****
# This is the standard version that contains no "taint" checks and is
# used for all scripts that aren't set-id or running under something set-id.
! perl: perl.o $(obj)
! $(CC) $(LARGE) $(LDFLAGS) $(obj) perl.o $(libs) -o perl
# This version, if specified in Configure, does ONLY those scripts which need
# set-id emulation. Suidperl must be setuid root. It contains the "taint"
# checks as well as the special code to validate that the script in question
# has been invoked correctly.
! suidperl: tperl.o sperly.o $(tobj)
! $(CC) $(LARGE) $(LDFLAGS) sperly.o $(tobj) tperl.o $(libs) -o suidperl
# This version interprets scripts that are already set-id either via a wrapper
# or through the kernel allowing set-id scripts (bad idea). Taintperl must
--- 131,153 ----
# This is the standard version that contains no "taint" checks and is
# used for all scripts that aren't set-id or running under something set-id.
! perl: perl.o $(obj) usersub.o
! $(CC) $(LARGE) $(LDFLAGS) $(obj) perl.o usersub.o $(libs) -o perl
+ uperl.o: perl.o $(obj)
+ ld $(LARGE) $(LDFLAGS) -r $(obj) perl.o $(libs) -o uperl.o
+
+ saber: perl.c
+ # load $(c) perl.c
+
# This version, if specified in Configure, does ONLY those scripts which need
# set-id emulation. Suidperl must be setuid root. It contains the "taint"
# checks as well as the special code to validate that the script in question
# has been invoked correctly.
! suidperl: tperl.o sperly.o $(tobj) usersub.o
! $(CC) $(LARGE) $(LDFLAGS) sperly.o $(tobj) tperl.o usersub.o $(libs) \
! -o suidperl
# This version interprets scripts that are already set-id either via a wrapper
# or through the kernel allowing set-id scripts (bad idea). Taintperl must
***************
*** 140,147 ****
# NOT be setuid to root or anything else. The only difference between it
# and normal perl is the presence of the "taint" checks.
! taintperl: tperl.o tperly.o $(tobj)
! $(CC) $(LARGE) $(LDFLAGS) tperly.o $(tobj) tperl.o $(libs) -o taintperl
# Replicating all this junk is yucky, but I don't see a portable way to fix it.
--- 154,162 ----
# NOT be setuid to root or anything else. The only difference between it
# and normal perl is the presence of the "taint" checks.
! taintperl: tperl.o tperly.o $(tobj) usersub.o
! $(CC) $(LARGE) $(LDFLAGS) tperly.o $(tobj) tperl.o usersub.o $(libs) \
! -o taintperl
# Replicating all this junk is yucky, but I don't see a portable way to fix it.
***************
*** 270,276 ****
touch perly.h
perl.c: perl.y
! @ echo Expect 25 shift/reduce errors...
$(YACC) -d perl.y
mv y.tab.c perl.c
mv y.tab.h perly.h
--- 285,291 ----
touch perly.h
perl.c: perl.y
! @ echo Expect 29 shift/reduce and 59 reduce/reduce conflicts...
$(YACC) -d perl.y
mv y.tab.c perl.c
mv y.tab.h perly.h
***************
*** 308,313 ****
--- 323,330 ----
cat >>Makefile <<'!NO!SUBS!'
- test $(bin) = /usr/bin || rm -f /usr/bin/perl
- test $(bin) = /usr/bin || $(SLN) $(bin)/perl /usr/bin || cp $(bin)/perl /usr/bin
+ - chmod +x $(scripts)
+ - cp $(scripts) $(scriptdir)
- sh ./makedir $(privlib)
- \
if test `pwd` != $(privlib); then \
Index: README
*** README.old Thu Aug 9 05:56:05 1990
--- README Thu Aug 9 05:56:06 1990
***************
*** 17,22 ****
--- 17,42 ----
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ My interpretation of the GNU General Public License is that no Perl
+ script falls under the terms of the License unless you explicitly put
+ said script under the terms of the License yourself. Furthermore, any
+ object code linked with uperl.o does not automatically fall under the
+ terms of the License, provided such object code only adds definitions
+ of subroutines and variables, and does not otherwise impair the
+ resulting interpreter from executing any standard Perl script. I
+ consider linking in C subroutines in this manner to be the moral
+ equivalent of defining subroutines in the Perl language itself. You
+ may sell such an object file as proprietary provided that you provide
+ or offer to provide the Perl source, as specified by the GNU General
+ Public License. (This is merely an alternate way of specifying input
+ to the program.) You may also sell a binary produced by the dumping of
+ a running Perl script that belongs to you, provided that you provide or
+ offer to provide the Perl source as specified by the License. (The
+ fact that a Perl interpreter and your code are in the same binary file
+ is, in this case, a form of mere aggregation.) This is my interpretation
+ of the License. If you still have concerns or difficulties understanding
+ my intent, feel free to contact me.
+
--------------------------------------------------------------------------
Perl is a language that combines some of the features of C, sed, awk and shell.
***************
*** 80,89 ****
--- 100,113 ----
SGI machines may need -Ddouble="long float".
Ultrix (2.3) may need to hand assemble teval.s with a -J switch.
Ultrix on MIPS machines may need -DLANGUAGE_C.
+ MIPS machines may need to turn off -O on perly.c and tperly.c.
SCO Xenix may need -m25000 for yacc.
Xenix 386 needs -Sm10000 for yacc.
Genix needs to use libc rather than libc_s, or #undef VARARGS.
NCR Tower 32 (OS 2.01.01) may need -W2,-Sl,2000 and #undef MKDIR.
+ A/UX may need -ZP -DPOSIX, and -g if big cc is used.
+ FPS machines may need -J and -DBADSWITCH.
+ If you get syntax errors on '(', try -DCRIPPLED_CC or -DBADSWITCH or both.
Machines with half-implemented dbm routines will need to #undef ODBM & NDBM.
C's that don't try to restore registers on longjmp() may need -DJMPCLOBBER.
(Try this if you get random glitches.)
Index: h2pl/README
*** h2pl/README.old Thu Aug 9 05:59:16 1990
--- h2pl/README Thu Aug 9 05:59:17 1990
***************
*** 0 ****
--- 1,71 ----
+ [This file of Tom Christiansen's has been edited to change makelib to h2ph
+ and .h to .ph where appropriate--law.]
+
+ This directory contains files to help you convert the *.ph files generated my
+ h2ph out of the perl source directory into *.pl files with all the
+ indirection of the subroutine calls removed. The .ph version will be more
+ safely portable, because if something isn't defined on the new system, like
+ &TIOCGETP, then you'll get a fatal run-time error on the system lacking that
+ function. Using the .pl version means that the subsequent scripts will give
+ you a 0 $TIOCGETP and God only knows what may then happen. Still, I like the
+ .pl stuff because they're faster to load.
+
+ FIrst, you need to run h2ph on things like sys/ioctl.h to get stuff
+ into the perl library directory, often /usr/local/lib/perl. For example,
+ # h2ph sys/ioctl.h
+ takes /usr/include/sys/ioctl.h as input and writes (without i/o redirection)
+ the file /usr/local/lib/perl/sys/ioctl.ph, which looks like this
+
+ eval 'sub TIOCM_RTS {0004;}';
+ eval 'sub TIOCM_ST {0010;}';
+ eval 'sub TIOCM_SR {0020;}';
+ eval 'sub TIOCM_CTS {0040;}';
+ eval 'sub TIOCM_CAR {0100;}';
+
+ and much worse, rather than what Larry's ioctl.pl from the perl source dir has,
+ which is:
+
+ $TIOCM_RTS = 0004;
+ $TIOCM_ST = 0010;
+ $TIOCM_SR = 0020;
+ $TIOCM_CTS = 0040;
+ $TIOCM_CAR = 0100;
+
+ [Workaround for fixed bug in makedir/h2ph deleted--law.]
+
+ The more complicated ioctl subs look like this:
+
+ eval 'sub TIOCGSIZE {&TIOCGWINSZ;}';
+ eval 'sub TIOCGWINSZ {&_IOR("t", 104, \'struct winsize\');}';
+ eval 'sub TIOCSETD {&_IOW("t", 1, \'int\');}';
+ eval 'sub TIOCGETP {&_IOR("t", 8,\'struct sgttyb\');}';
+
+ The _IO[RW] routines use a %sizeof array, which (presumably)
+ is keyed on the type name with the value being the size in bytes.
+
+ To build %sizeof, try running this in this directory:
+
+ % ./getioctlsizes
+
+ Which will tell you which things the %sizeof array needs
+ to hold. You can try to build a sizeof.ph file with:
+
+ % ./getioctlsizes | ./mksizes > sizeof.ph
+
+ Note that mksizes hardcodes the #include files for all the types, so it will
+ probably require customization. Once you have sizeof.ph, install it in the
+ perl library directory. Run my tcbreak script to see whether you can do
+ ioctls in perl now. You'll get some kind of fatal run-time error if you
+ can't. That script should be included in this directory.
+
+ If this works well, now you can try to convert the *.ph files into
+ *.pl files. Try this:
+
+ foreach file ( sysexits.ph sys/{errno.ph,ioctl.ph} )
+ ./mkvars $file > t/$file:r.pl
+ end
+
+ The last one will be the hardest. If it works, should be able to
+ run tcbreak2 and have it work the same as tcbreak.
+
+ Good luck.
*** End of Patch 19 ***
More information about the Comp.sources.bugs
mailing list