Permalink
Browse files

perl 3.0 patch #40 patch #38, continued

See patch #38.
  • Loading branch information...
Larry Wall
Larry Wall committed Nov 9, 1990
1 parent 57ebbfd commit 34de22dd6ede167a09e3a3ee571665ba2c647f94
Showing with 339 additions and 77 deletions.
  1. +3 −3 eg/who
  2. +6 −3 lib/perldb.pl
  3. +7 −4 lib/syslog.pl
  4. +52 −0 os2/perldb.dif
  5. +2 −2 os2/perlglob.cs
  6. +0 −1 os2/perlglob.def
  7. +1 −1 patchlevel.h
  8. +40 −12 perl.man.3
  9. +13 −4 perl.man.4
  10. +50 −5 perly.c
  11. +33 −12 regcomp.c
  12. +6 −1 regcomp.h
  13. +9 −4 regexec.c
  14. +7 −3 stab.c
  15. +75 −14 str.c
  16. +5 −1 str.h
  17. +8 −2 toke.c
  18. +22 −5 util.c
View
6 eg/who
@@ -1,8 +1,8 @@
#!/usr/bin/perl
# This assumes your /etc/utmp file looks like ours
-open(utmp,'/etc/utmp');
-@mo = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
-while (read(utmp,$utmp,36)) {
+open(UTMP,'/etc/utmp');
+@mo = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
+while (read(UTMP,$utmp,36)) {
($line,$name,$host,$time) = unpack('A8A8A16l',$utmp);
if ($name) {
$host = "($host)" if $host;
View
@@ -1,6 +1,6 @@
package DB;
-$header = '$Header: perldb.pl,v 3.0.1.4 90/10/15 17:40:38 lwall Locked $';
+$header = '$Header: perldb.pl,v 3.0.1.5 90/11/10 01:40:26 lwall Locked $';
#
# This file is automatically included if you do perl -d.
# It's probably not useful to include this yourself.
@@ -10,6 +10,9 @@ package DB;
# have a breakpoint. It also inserts a do 'perldb.pl' before the first line.
#
# $Log: perldb.pl,v $
+# Revision 3.0.1.5 90/11/10 01:40:26 lwall
+# patch38: the debugger wouldn't stop correctly or do action routines
+#
# Revision 3.0.1.4 90/10/15 17:40:38 lwall
# patch29: added caller
# patch29: the debugger now understands packages and evals
@@ -59,7 +62,7 @@ sub DB {
$signal |= 1;
}
else {
- $signal |= &eval($stop);
+ &eval("\$DB'signal |= do {$stop;}");
$dbline{$line} =~ s/;9($|\0)/$1/;
}
}
@@ -307,7 +310,7 @@ sub DB {
print OUT "Line $i may not have an action.\n";
} else {
$dbline{$i} =~ s/\0[^\0]*//;
- $dbline .= "\0" . do action($3);
+ $dbline{$i} .= "\0" . do action($3);
}
next; };
$cmd =~ /^n$/ && do {
View
@@ -2,9 +2,12 @@
# syslog.pl
#
# $Log: syslog.pl,v $
-Revision 3.0.1.3 90/10/15 17:42:18 lwall
-patch29: various portability fixes
-
+# Revision 3.0.1.4 90/11/10 01:41:11 lwall
+# patch38: syslog.pl was referencing an absolute path
+#
+# Revision 3.0.1.3 90/10/15 17:42:18 lwall
+# patch29: various portability fixes
+#
# Revision 3.0.1.1 90/08/09 03:57:17 lwall
# patch19: Initial revision
#
@@ -54,7 +57,7 @@ package syslog;
$host = 'localhost' unless $host; # set $syslog'host to change
-require '/usr/local/lib/perl/syslog.ph';
+require 'syslog.ph';
$maskpri = &LOG_UPTO(&LOG_DEBUG);
View
@@ -0,0 +1,52 @@
+*** lib/perldb.pl Tue Oct 23 23:14:20 1990
+--- os2/perldb.pl Tue Nov 06 21:13:42 1990
+***************
+*** 36,43 ****
+ #
+ #
+
+! open(IN, "</dev/tty") || open(IN, "<&STDIN"); # so we don't dingle stdin
+! open(OUT,">/dev/tty") || open(OUT, ">&STDOUT"); # so we don't dongle stdout
+ select(OUT);
+ $| = 1; # for DB'OUT
+ select(STDOUT);
+--- 36,43 ----
+ #
+ #
+
+! open(IN, "<con") || open(IN, "<&STDIN"); # so we don't dingle stdin
+! open(OUT,">con") || open(OUT, ">&STDOUT"); # so we don't dongle stdout
+ select(OUT);
+ $| = 1; # for DB'OUT
+ select(STDOUT);
+***************
+*** 517,530 ****
+ s/(.*)/'$1'/ unless /^-?[\d.]+$/;
+ }
+
+! if (-f '.perldb') {
+! do './.perldb';
+ }
+! elsif (-f "$ENV{'LOGDIR'}/.perldb") {
+! do "$ENV{'LOGDIR'}/.perldb";
+ }
+! elsif (-f "$ENV{'HOME'}/.perldb") {
+! do "$ENV{'HOME'}/.perldb";
+ }
+
+ 1;
+--- 517,530 ----
+ s/(.*)/'$1'/ unless /^-?[\d.]+$/;
+ }
+
+! if (-f 'perldb.ini') {
+! do './perldb.ini';
+ }
+! elsif (-f "$ENV{'INIT'}/perldb.ini") {
+! do "$ENV{'INIT'}/perldb.ini";
+ }
+! elsif (-f "$ENV{'HOME'}/perldb.ini") {
+! do "$ENV{'HOME'}/perldb.ini";
+ }
+
+ 1;
View
@@ -1,7 +1,7 @@
-glob.c
+msdos\glob.c
setargv.obj
-perlglob.def
+os2\perlglob.def
perlglob.exe
-AS -LB -S0x1000
View
@@ -1,3 +1,2 @@
NAME PERLGLOB WINDOWCOMPAT NEWFILES
DESCRIPTION 'Filename globbing for PERL - for MS-DOS and OS/2'
-STUB 'REALGLOB.EXE'
View
@@ -1 +1 @@
-#define PATCHLEVEL 39
+#define PATCHLEVEL 40
View
@@ -1,7 +1,11 @@
''' Beginning of part 3
-''' $Header: perl_man.3,v 3.0.1.10 90/10/20 02:15:17 lwall Locked $
+''' $Header: perl_man.3,v 3.0.1.11 90/11/10 01:48:21 lwall Locked $
'''
''' $Log: perl.man.3,v $
+''' Revision 3.0.1.11 90/11/10 01:48:21 lwall
+''' patch38: random cleanup
+''' patch38: documented tr///cds
+'''
''' Revision 3.0.1.10 90/10/20 02:15:17 lwall
''' patch37: patch37: fixed various typos in man page
'''
@@ -298,7 +302,7 @@ The "a" and "A" types gobble just one value, but pack it as a string of length
count,
padding with nulls or spaces as necessary.
(When unpacking, "A" strips trailing spaces and nulls, but "a" does not.)
-Real numbers (floats and doubles) are in the nnativeative machine format
+Real numbers (floats and doubles) are in the native machine format
only; due to the multiplicity of floating formats around, and the lack
of a standard \*(L"network\*(R" representation, no facility for
interchange has been made.
@@ -308,7 +312,7 @@ use IEEE floating point arithmetic (as the endian-ness of the memory
representation is not part of the IEEE spec).
Note that perl uses
doubles internally for all numeric calculation, and converting from
-double -> float -> double will loose precision (i.e. unpack("f",
+double -> float -> double will lose precision (i.e. unpack("f",
pack("f", $foo)) will not in general equal $foo).
.br
Examples:
@@ -382,7 +386,7 @@ in an array context, and any subroutine that you call will have one or more
of its expressions evaluated in an array context.
Also be careful not to follow the print keyword with a left parenthesis
unless you want the corresponding right parenthesis to terminate the
-arguments to the print--interpose a + or put parens around all the arguments.
+arguments to the print\*(--interpose a + or put parens around all the arguments.
.Ip "printf(FILEHANDLE LIST)" 8 10
.Ip "printf(LIST)" 8
.Ip "printf FILEHANDLE LIST" 8
@@ -639,7 +643,7 @@ FILEHANDLE may be an expression whose value gives the name of the filehandle.
Returns 1 upon success, 0 otherwise.
.Ip "seekdir(DIRHANDLE,POS)" 8 3
Sets the current position for the readdir() routine on DIRHANDLE.
-POS must be a value returned by seekdir().
+POS must be a value returned by telldir().
Has the same caveats about possible directory compaction as the corresponding
system library routine.
.Ip "select(FILEHANDLE)" 8 3
@@ -808,7 +812,7 @@ Returns the number of seconds actually slept.
Opens a socket of the specified kind and attaches it to filehandle SOCKET.
DOMAIN, TYPE and PROTOCOL are specified the same as for the system call
of the same name.
-You may need to run makelib on sys/socket.h to get the proper values handy
+You may need to run h2ph on sys/socket.h to get the proper values handy
in a perl library file.
Return true if successful.
See the example in the section on Interprocess Communication.
@@ -1114,7 +1118,7 @@ in a numeric context, you may need to add 0 to them to force them to look
like numbers.
.nf
- require 'syscall.ph'; # may need to run makelib
+ require 'syscall.ph'; # may need to run h2ph
syscall(&SYS_write, fileno(STDOUT), "hi there\en", 9);
.fi
@@ -1162,19 +1166,19 @@ a directory.
Has the same caveats about possible directory compaction as the corresponding
system library routine.
.Ip "time" 8 4
-Returns the number of non-leap seconds since January 1, 1970, UTC.
+Returns the number of non-leap seconds since 00:00:00 UTC, January 1, 1970.
Suitable for feeding to gmtime() and localtime().
.Ip "times" 8 4
Returns a four-element array giving the user and system times, in seconds, for this
process and the children of this process.
.Sp
($user,$system,$cuser,$csystem) = times;
.Sp
-.Ip "tr/SEARCHLIST/REPLACEMENTLIST/" 8 5
-.Ip "y/SEARCHLIST/REPLACEMENTLIST/" 8
+.Ip "tr/SEARCHLIST/REPLACEMENTLIST/cds" 8 5
+.Ip "y/SEARCHLIST/REPLACEMENTLIST/cds" 8
Translates all occurrences of the characters found in the search list with
the corresponding character in the replacement list.
-It returns the number of characters replaced.
+It returns the number of characters replaced or deleted.
If no string is specified via the =~ or !~ operator,
the $_ string is translated.
(The string specified with =~ must be a scalar variable, an array element,
@@ -1185,16 +1189,40 @@ devotees,
.I y
is provided as a synonym for
.IR tr .
+.Sp
+If the c modifier is specified, the SEARCHLIST character set is complemented.
+If the d modifier is specified, any characters specified by SEARCHLIST that
+are not found in REPLACEMENTLIST are deleted.
+(Note that this is slightly more flexible than the behavior of some
+.I tr
+programs, which delete anything they find in the SEARCHLIST, period.)
+If the s modifier is specified, sequences of characters that were translated
+to the same character are squashed down to 1 instance of the character.
+.Sp
+If the d modifier was used, the REPLACEMENTLIST is always interpreted exactly
+as specified.
+Otherwise, if the REPLACEMENTLIST is shorter than the SEARCHLIST,
+the final character is replicated till it is long enough.
+If the REPLACEMENTLIST is null, the SEARCHLIST is replicated.
+This latter is useful for counting characters in a class, or for squashing
+character sequences in a class.
+.Sp
Examples:
.nf
$ARGV[1] \|=~ \|y/A\-Z/a\-z/; \h'|3i'# canonicalize to lower case
$cnt = tr/*/*/; \h'|3i'# count the stars in $_
+ $cnt = tr/0\-9//; \h'|3i'# count the digits in $_
+
+ tr/a\-zA\-Z//s; \h'|3i'# bookkeeper \-> bokeper
+
($HOST = $host) =~ tr/a\-z/A\-Z/;
- y/\e001\-@[\-_{\-\e177/ /; \h'|3i'# change non-alphas to space
+ y/a\-zA\-Z/ /cs; \h'|3i'# change non-alphas to single space
+
+ tr/\e200\-\e377/\e0\-\e177/;\h'|3i'# delete 8th bit
.fi
.Ip "truncate(FILEHANDLE,LENGTH)" 8 4
View
@@ -1,7 +1,10 @@
''' Beginning of part 4
-''' $Header: perl_man.4,v 3.0.1.12 90/10/20 02:15:43 lwall Locked $
+''' $Header: perl_man.4,v 3.0.1.13 90/11/10 01:51:00 lwall Locked $
'''
''' $Log: perl.man.4,v $
+''' Revision 3.0.1.13 90/11/10 01:51:00 lwall
+''' patch38: random cleanup
+'''
''' Revision 3.0.1.12 90/10/20 02:15:43 lwall
''' patch37: patch37: fixed various typos in man page
'''
@@ -60,7 +63,7 @@ left\h'|1i'||
left\h'|1i'&&
left\h'|1i'| ^
left\h'|1i'&
-nonassoc\h'|1i'== != eq ne
+nonassoc\h'|1i'== != <=> eq ne cmp
nonassoc\h'|1i'< > <= >= lt gt le ge
nonassoc\h'|1i'chdir exit eval reset sleep rand umask
nonassoc\h'|1i'\-r \-w \-x etc.
@@ -223,7 +226,7 @@ time of the call is visible to subroutine instead.
do foo(); # pass a null list
&foo(); # the same
- &foo; # pass no arguments--more efficient
+ &foo; # pass no arguments\*(--more efficient
.fi
.Sh "Passing By Reference"
@@ -774,6 +777,8 @@ Pattern matches on strings containing multiple newlines can produce confusing
results when $* is 0.
Default is 0.
(Mnemonic: * matches multiple things.)
+Note that this variable only influences the interpretation of ^ and $.
+A literal newline can be searched for even when $* == 0.
.Ip $0 8
Contains the name of the file containing the
.I perl
@@ -827,7 +832,7 @@ it really means
But don't put
- @foo{$a,$b,$c} # a slice--note the @
+ @foo{$a,$b,$c} # a slice\*(--note the @
which means
@@ -1088,6 +1093,10 @@ omit parentheses in many places doesn't mean that you ought to:
.fi
When in doubt, parenthesize.
At the very least it will let some poor schmuck bounce on the % key in vi.
+.Sp
+Even if you aren't in doubt, consider the mental welfare of the person who
+has to maintain the code after you, and who will probably put parens in
+the wrong place.
.Ip 2. 4 4
Don't go through silly contortions to exit a loop at the top or the
bottom, when
Oops, something went wrong.

0 comments on commit 34de22d

Please sign in to comment.