See patch 5.
-#define PATCHLEVEL 5
+#define PATCHLEVEL 6
-/* $Header: perl.h,v 3.0.1.2 89/11/11 04:39:38 lwall Locked $
+/* $Header: perl.h,v 3.0.1.3 89/11/17 15:28:57 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: perl.h,v $
+ * Revision 3.0.1.3 89/11/17 15:28:57 lwall
+ * patch5: byteorder now is a hex value
+ * patch5: Configure now looks for <time.h> including <sys/time.h>
+ *
* Revision 3.0.1.2 89/11/11 04:39:38 lwall
* patch2: Configure may now set -DDEBUGGING
* patch2: netinet/in.h needed sys/types.h some places
# define vfork fork
#endif
-#if defined(MEMCMP) && defined(mips) && BYTEORDER == 01234
+#if defined(MEMCMP) && defined(mips) && BYTEORDER == 0x1234
#undef MEMCMP
#endif
#if defined(TMINSYS) || defined(I_SYSTIME)
#include <sys/time.h>
-#ifdef TIMETOO
+#ifdef I_TIMETOO
#include <time.h>
#endif
#else
#include <time.h>
+#ifdef I_SYSTIMETOO
+#include <time.h>
+#endif
#endif
#include <sys/times.h>
#define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
#ifndef BYTEORDER
-#define BYTEORDER 01234
+#define BYTEORDER 0x1234
#endif
#if defined(htonl) && !defined(HTONL)
#define NTOHS
#endif
#ifndef HTONL
-#if (BYTEORDER != 04321) && (BYTEORDER != 087654321)
+#if (BYTEORDER != 0x4321) && (BYTEORDER != 0x87654321)
#define HTONS
#define HTONL
#define NTOHS
#define ntohl my_ntohl
#endif
#else
-#if (BYTEORDER == 04321) || (BYTEORDER == 087654321)
+#if (BYTEORDER == 0x4321) || (BYTEORDER == 0x87654321)
#undef HTONS
#undef HTONL
#undef NTOHS
.rn '' }`
-''' $Header: perl.man.1,v 3.0.1.1 89/11/11 04:41:22 lwall Locked $
+''' $Header: perl.man.1,v 3.0.1.2 89/11/17 15:30:03 lwall Locked $
'''
''' $Log: perl.man.1,v $
+''' Revision 3.0.1.2 89/11/17 15:30:03 lwall
+''' patch5: fixed some manual typos and indent problems
+'''
''' Revision 3.0.1.1 89/11/11 04:41:22 lwall
''' patch2: explained about sh and ${1+"$@"}
''' patch2: documented that space must separate word and '' string
as appropriate to the context.
A scalar is interpreted as TRUE in the boolean sense if it is not the null
string or 0.
-Booleans returned by operators are 1 for true and \'0\' or \'\' (the null
+Booleans returned by operators are 1 for true and 0 or \'\' (the null
string) for false.
.PP
There are actually two varieties of null string: defined and undefined.
.I perl
are report formats and subroutines.
See the sections below for more information on those declarations.
-All uninitialized objects user-created objects are assumed to
+All uninitialized user-created objects are assumed to
start with a null or 0 value until they
are defined by some explicit operation such as assignment.
The sequence of commands is executed just once, unlike in
.ne 6
foo: {
- $abc = 1, last foo if /^abc/;
- $def = 1, last foo if /^def/;
- $xyz = 1, last foo if /^xyz/;
+ $abc = 1, last foo if /^abc/;
+ $def = 1, last foo if /^def/;
+ $xyz = 1, last foo if /^xyz/;
$nothing = 1;
}
''' Beginning of part 2
-''' $Header: perl.man.2,v 3.0.1.1 89/11/11 04:43:10 lwall Locked $
+''' $Header: perl.man.2,v 3.0.1.2 89/11/17 15:30:16 lwall Locked $
'''
''' $Log: perl.man.2,v $
+''' Revision 3.0.1.2 89/11/17 15:30:16 lwall
+''' patch5: fixed some manual typos and indent problems
+'''
''' Revision 3.0.1.1 89/11/11 04:43:10 lwall
''' patch2: made some line breaks depend on troff vs. nroff
''' patch2: example of unshift had args backwards
$uid{$login} = $uid;
$gid{$login} = $gid;
}
- @ary = <$pattern>; # get filenames
+ @ary = <${pattern}>; # get filenames
if ($uid{$user} eq \'\') {
die "$user not in passwd file";
}
''' Beginning of part 3
-''' $Header: perl.man.3,v 3.0.1.1 89/11/11 04:45:06 lwall Locked $
+''' $Header: perl.man.3,v 3.0.1.2 89/11/17 15:31:05 lwall Locked $
'''
''' $Log: perl.man.3,v $
+''' Revision 3.0.1.2 89/11/17 15:31:05 lwall
+''' patch5: fixed some manual typos and indent problems
+''' patch5: added warning about print making an array context
+'''
''' Revision 3.0.1.1 89/11/11 04:45:06 lwall
''' patch2: made some line breaks depend on troff vs. nroff
'''
To set the default output channel to something other than
.I STDOUT
use the select operation.
+Note that, because print takes a LIST, anything in the LIST is evaluated
+in an array context, and any subroutine that you call will have one or more
+of its expressions evaluated in an array context.
.Ip "printf(FILEHANDLE LIST)" 8 10
.Ip "printf(LIST)" 8
.Ip "printf FILEHANDLE LIST" 8
.fi
produces the output \*(L'h:i:t:h:e:r:e\*(R'.
-.P
+.Sp
The NUM parameter can be used to partially split a line
.nf
''' Beginning of part 4
-''' $Header: perl.man.4,v 3.0.1.2 89/11/11 04:46:40 lwall Locked $
+''' $Header: perl.man.4,v 3.0.1.3 89/11/17 15:32:25 lwall Locked $
'''
''' $Log: perl.man.4,v $
+''' Revision 3.0.1.3 89/11/17 15:32:25 lwall
+''' patch5: fixed some manual typos and indent problems
+''' patch5: clarified difference between $! and $@
+'''
''' Revision 3.0.1.2 89/11/11 04:46:40 lwall
''' patch2: made some line breaks depend on troff vs. nroff
''' patch2: clarified operation of ^ and $ when $* is false
Examples:
.nf
- chdir $foo || die; # (chdir $foo) || die
- chdir($foo) || die; # (chdir $foo) || die
- chdir ($foo) || die; # (chdir $foo) || die
- chdir +($foo) || die; # (chdir $foo) || die
+ chdir $foo || die;\h'|3i'# (chdir $foo) || die
+ chdir($foo) || die;\h'|3i'# (chdir $foo) || die
+ chdir ($foo) || die;\h'|3i'# (chdir $foo) || die
+ chdir +($foo) || die;\h'|3i'# (chdir $foo) || die
but, because * is higher precedence than ||:
- chdir $foo * 20; # chdir ($foo * 20)
- chdir($foo) * 20; # (chdir $foo) * 20
- chdir ($foo) * 20; # (chdir $foo) * 20
- chdir +($foo) * 20; # chdir ($foo * 20)
+ chdir $foo * 20;\h'|3i'# chdir ($foo * 20)
+ chdir($foo) * 20;\h'|3i'# (chdir $foo) * 20
+ chdir ($foo) * 20;\h'|3i'# (chdir $foo) * 20
+ chdir +($foo) * 20;\h'|3i'# chdir ($foo * 20)
- rand 10 * 20; # rand (10 * 20)
- rand(10) * 20; # (rand 10) * 20
- rand (10) * 20; # (rand 10) * 20
- rand +(10) * 20; # rand (10 * 20)
+ rand 10 * 20;\h'|3i'# rand (10 * 20)
+ rand(10) * 20;\h'|3i'# (rand 10) * 20
+ rand (10) * 20;\h'|3i'# (rand 10) * 20
+ rand +(10) * 20;\h'|3i'# rand (10 * 20)
.fi
In the absence of parentheses,
.Ip $! 8 2
If used in a numeric context, yields the current value of errno, with all the
usual caveats.
+(This means that you shouldn't depend on the value of $! to be anything
+in particular unless you've gotten a specific error return indicating a
+system error.)
If used in a string context, yields the corresponding system error string.
You can assign to $! in order to set errno
if, for instance, you want $! to return the string for error n, or you want
to set the exit value for the die operator.
(Mnemonic: What just went bang?)
.Ip $@ 8 2
-The error message from the last eval command.
-If null, the last eval parsed and executed correctly.
+The perl syntax error message from the last eval command.
+If null, the last eval parsed and executed correctly (although the operations
+you invoked may have failed in the normal fashion).
(Mnemonic: Where was the syntax error \*(L"at\*(R"?)
.Ip $< 8 2
The real uid of this process.
Don't be afraid to use loop labels\*(--they're there to enhance readability as
well as to allow multi-level loop breaks.
See last example.
-.Ip 6. 4 4
+.Ip 4. 4 4
For portability, when using features that may not be implemented on every
machine, test the construct in an eval to see if it fails.
If you know what version or patchlevel a particular feature was implemented,
you can test $] to see if it will be there.
-.Ip 4. 4 4
-Choose mnemonic identifiers.
.Ip 5. 4 4
+Choose mnemonic identifiers.
+.Ip 6. 4 4
Be consistent.
.Sh "Debugging"
If you invoke
-char rcsid[] = "$Header: perly.c,v 3.0.1.1 89/11/11 04:50:04 lwall Locked $\nPatch level: ###\n";
+char rcsid[] = "$Header: perly.c,v 3.0.1.2 89/11/17 15:34:42 lwall Locked $\nPatch level: ###\n";
/*
* Copyright (c) 1989, Larry Wall
*
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: perly.c,v $
+ * Revision 3.0.1.2 89/11/17 15:34:42 lwall
+ * patch5: fixed possible confusion about current effective gid
+ *
* Revision 3.0.1.1 89/11/11 04:50:04 lwall
* patch2: moved yydebug to where its type didn't matter
*
fatal("Can't do setuid\n");
}
- if (statbuf.st_mode & S_ISGID && statbuf.st_gid != getegid())
+ if (statbuf.st_mode & S_ISGID && statbuf.st_gid != egid)
#ifdef SETEGID
(void)setegid(statbuf.st_gid);
#else
setuid((UIDTYPE)uid);
#endif
#endif
+ uid = (int)getuid();
euid = (int)geteuid();
+ gid = (int)getgid();
+ egid = (int)getegid();
if (!cando(S_IEXEC,TRUE,&statbuf))
fatal("Permission denied\n"); /* they can't do this */
}
-/* $Header: stab.c,v 3.0.1.1 89/11/11 04:55:07 lwall Locked $
+/* $Header: stab.c,v 3.0.1.2 89/11/17 15:35:37 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: stab.c,v $
+ * Revision 3.0.1.2 89/11/17 15:35:37 lwall
+ * patch5: sighandler() needed to be static
+ *
* Revision 3.0.1.1 89/11/11 04:55:07 lwall
* patch2: sys_errlist[sys_nerr] is illegal
*
#include <signal.h>
-/* This oughta be generated by Configure. */
-
static char *sig_name[] = {
SIG_NAME,0
};
STAB *stab = mstr->str_u.str_stab;
char *s;
int i;
- int sighandler();
+ static int sighandler();
switch (mstr->str_rare) {
case 'E':
return 0;
}
+static int
sighandler(sig)
int sig;
{
-/* $Header: str.c,v 3.0.1.2 89/11/11 04:56:22 lwall Locked $
+/* $Header: str.c,v 3.0.1.3 89/11/17 15:38:23 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: str.c,v $
+ * Revision 3.0.1.3 89/11/17 15:38:23 lwall
+ * patch5: some machines typedef unchar too
+ * patch5: substitution on leading components occasionally caused <> corruption
+ *
* Revision 3.0.1.2 89/11/11 04:56:22 lwall
* patch2: uchar gives Crays fits
*
bpx = bp - str->str_ptr; /* prepare for possible relocation */
if (get_paragraph && oldbp)
obpx = oldbp - str->str_ptr;
+ str->str_cur = bpx;
STR_GROW(str, bpx + cnt + 2);
bp = str->str_ptr + bpx; /* reconstitute our pointer */
if (get_paragraph && oldbp)
else if (*d == '[' && s[-1] == ']') { /* char class? */
int weight = 2; /* let's weigh the evidence */
char seen[256];
- unsigned char unchar = 0, lastunchar;
+ unsigned char un_char = 0, last_un_char;
Zero(seen,256,char);
*--s = '\0';
weight -= 100;
}
for (d++; d < s; d++) {
- lastunchar = unchar;
- unchar = (unsigned char)*d;
+ last_un_char = un_char;
+ un_char = (unsigned char)*d;
switch (*d) {
case '&':
case '$':
- weight -= seen[unchar] * 10;
+ weight -= seen[un_char] * 10;
if (isalpha(d[1]) || isdigit(d[1]) ||
d[1] == '_') {
d = scanreg(d,s,tokenbuf);
}
break;
case '\\':
- unchar = 254;
+ un_char = 254;
if (d[1]) {
if (index("wds",d[1]))
weight += 100;
weight += 100;
break;
case '-':
- if (lastunchar < d[1] || d[1] == '\\') {
- if (index("aA01! ",lastunchar))
+ if (last_un_char < d[1] || d[1] == '\\') {
+ if (index("aA01! ",last_un_char))
weight += 30;
if (index("zZ79~",d[1]))
weight += 30;
weight -= 150;
d = bufptr;
}
- if (unchar == lastunchar + 1)
+ if (un_char == last_un_char + 1)
weight += 5;
- weight -= seen[unchar];
+ weight -= seen[un_char];
break;
}
- seen[unchar]++;
+ seen[un_char]++;
}
#ifdef DEBUGGING
if (debug & 512)
-/* $Header: toke.c,v 3.0.1.2 89/11/11 05:04:42 lwall Locked $
+/* $Header: toke.c,v 3.0.1.3 89/11/17 15:43:15 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: toke.c,v $
+ * Revision 3.0.1.3 89/11/17 15:43:15 lwall
+ * patch5: IBM PC/RT compiler can't deal with UNI() and LOP() macros
+ * patch5: } misadjusted expection of subsequent term or operator
+ * patch5: y/abcde// didn't work
+ *
* Revision 3.0.1.2 89/11/11 05:04:42 lwall
* patch2: fixed a CLINE macro conflict
*
return s;
}
+#ifdef CRIPPLED_CC
+
+#undef UNI
+#undef LOP
+#define UNI(f) return uni(f,s)
+#define LOP(f) return lop(f,s)
+
+int
+uni(f,s)
+int f;
+char *s;
+{
+ yylval.ival = f;
+ expectterm = TRUE;
+ bufptr = s;
+ if (*s == '(')
+ return FUNC1;
+ s = skipspace(s);
+ if (*s == '(')
+ return FUNC1;
+ else
+ return UNIOP;
+}
+
+int
+lop(f,s)
+int f;
+char *s;
+{
+ if (*s != '(')
+ s = skipspace(s);
+ if (*s == '(') {
+ *s = META('(');
+ bufptr = oldbufptr;
+ return '(';
+ }
+ else {
+ yylval.ival=f;
+ expectterm = TRUE;
+ bufptr = s;
+ return LISTOP;
+ }
+}
+
+#endif /* CRIPPLED_CC */
+
yylex()
{
register char *s = bufptr;
TERM(tmp);
case '}':
tmp = *s++;
- for (d = s; *d == ' ' || *d == '\t'; d++) ;
- if (*d == '\n' || *d == '#')
- OPERATOR(tmp); /* block end */
- else
- TERM(tmp); /* associative array end */
+ RETURN(tmp);
case '&':
s++;
tmp = *s++;
yylval.arg = arg;
if (!*r) {
Safefree(r);
- r = t;
+ r = t; rlen = tlen;
}
for (i = 0, j = 0; i < tlen; i++,j++) {
if (j >= rlen)
-/* $Header: util.c,v 3.0.1.1 89/11/11 05:06:13 lwall Locked $
+/* $Header: util.c,v 3.0.1.2 89/11/17 15:46:35 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: util.c,v $
+ * Revision 3.0.1.2 89/11/17 15:46:35 lwall
+ * patch5: BZERO separate from BCOPY now
+ * patch5: byteorder now is a hex value
+ *
* Revision 3.0.1.1 89/11/11 05:06:13 lwall
* patch2: made dup2 a little better
*
}
#endif
-#ifndef BCOPY
#ifndef MEMCPY
+#ifndef BCOPY
char *
bcopy(from,to,len)
register char *from;
*to++ = *from++;
return retval;
}
+#endif
+#ifndef BZERO
char *
bzero(loc,len)
register char *loc;
#endif /* VARARGS */
#ifdef MYSWAP
-#if BYTEORDER != 04321
+#if BYTEORDER != 0x4321
short
my_swap(s)
short s;
{
union {
long result;
- char c[4];
+ char c[sizeof(long)];
} u;
-#if BYTEORDER == 01234
+#if BYTEORDER == 0x1234
u.c[0] = (l >> 24) & 255;
u.c[1] = (l >> 16) & 255;
u.c[2] = (l >> 8) & 255;
u.c[3] = l & 255;
return u.result;
#else
-#if ((BYTEORDER - 01111) & 0444) || !(BYTEORDER & 7)
+#if ((BYTEORDER - 0x1111) & 0x444) || !(BYTEORDER & 0xf)
fatal("Unknown BYTEORDER\n");
#else
register int o;
register int s;
- for (o = BYTEORDER - 01111, s = 0; s < 32; o >>= 3, s += 8) {
- u.c[o & 7] = (l >> s) & 255;
+ for (o = BYTEORDER - 0x1111, s = 0; s < (sizeof(long)*8); o >>= 4, s += 8) {
+ u.c[o & 0xf] = (l >> s) & 255;
}
return u.result;
#endif
{
union {
long l;
- char c[4];
+ char c[sizeof(long)];
} u;
-#if BYTEORDER == 01234
+#if BYTEORDER == 0x1234
u.c[0] = (l >> 24) & 255;
u.c[1] = (l >> 16) & 255;
u.c[2] = (l >> 8) & 255;
u.c[3] = l & 255;
return u.l;
#else
-#if ((BYTEORDER - 01111) & 0444) || !(BYTEORDER & 7)
+#if ((BYTEORDER - 0x1111) & 0x444) || !(BYTEORDER & 0xf)
fatal("Unknown BYTEORDER\n");
#else
register int o;
u.l = l;
l = 0;
- for (o = BYTEORDER - 01111, s = 0; s < 32; o >>= 3, s += 8) {
- l |= (u.c[o & 7] & 255) << s;
+ for (o = BYTEORDER - 0x1111, s = 0; s < (sizeof(long)*8); o >>= 4, s += 8) {
+ l |= (u.c[o & 0xf] & 255) << s;
}
return l;
#endif
#endif
}
-#endif /* BYTEORDER != 04321 */
+#endif /* BYTEORDER != 0x4321 */
#endif /* HTONS */
FILE *
-/* $Header: util.h,v 3.0.1.1 89/10/26 23:28:25 lwall Locked $
+/* $Header: util.h,v 3.0.1.2 89/11/17 15:48:01 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: util.h,v $
+ * Revision 3.0.1.2 89/11/17 15:48:01 lwall
+ * patch5: BZERO separate from BCOPY now
+ *
* Revision 3.0.1.1 89/10/26 23:28:25 lwall
* patch1: declared bcopy if necessary
*
char *nsavestr();
FILE *mypopen();
int mypclose();
-#ifndef BCOPY
#ifndef MEMCPY
+#ifndef BCOPY
char *bcopy();
#endif
+#ifndef BZERO
+char *bzero();
+#endif
#endif
: In the following dollars and backticks do not need the extra backslash.
$spitshell >>s2p <<'!NO!SUBS!'
-# $Header: s2p.SH,v 3.0.1.1 89/11/11 05:08:25 lwall Locked $
+# $Header: s2p.SH,v 3.0.1.2 89/11/17 15:51:27 lwall Locked $
#
# $Log: s2p.SH,v $
+# Revision 3.0.1.2 89/11/17 15:51:27 lwall
+# patch5: in s2p, line labels without a subsequent statement were done wrong
+# patch5: s2p left residue in /tmp
+#
# Revision 3.0.1.1 89/11/11 05:08:25 lwall
# patch2: in s2p, + within patterns needed backslashing
# patch2: s2p was printing out some debugging info to the output file
$toplabel = $label;
}
$_ = "$label:";
- if ($lastlinewaslabel++) {$_ .= "\t;";}
+ if ($lastlinewaslabel++) {
+ $indent += 4;
+ print body "\t" x ($indent / 8), ' ' x ($indent % 8), ";\n";
+ $indent -= 4;
+ }
if ($indent >= 2) {
$indent -= 2;
$indmod = 2;
redo line;
}
}
+if ($lastlinewaslabel++) {
+ $indent += 4;
+ print body "\t" x ($indent / 8), ' ' x ($indent % 8), ";\n";
+ $indent -= 4;
+}
print body "}\n";
if ($appendseen || $tseen || !$assumen) {
}
}
-unlink "/tmp/sperl$$", "/tmp/sperl2$$";
+unlink "/tmp/sperl$$", "/tmp/sperl2$$", "/tmp/sperl2$$.c";
sub Die {
- unlink "/tmp/sperl$$", "/tmp/sperl2$$";
+ unlink "/tmp/sperl$$", "/tmp/sperl2$$", "/tmp/sperl2$$.c";
die $_[0];
}
sub make_filehandle {
-/* $Header: walk.c,v 3.0.1.1 89/11/11 05:09:33 lwall Locked $
+/* $Header: walk.c,v 3.0.1.2 89/11/17 15:53:00 lwall Locked $
*
* Copyright (c) 1989, Larry Wall
*
* as specified in the README file that comes with the perl 3.0 kit.
*
* $Log: walk.c,v $
+ * Revision 3.0.1.2 89/11/17 15:53:00 lwall
+ * patch5: on Pyramids, index(s, '}' + 128) doesn't find meta-}
+ *
* Revision 3.0.1.1 89/11/11 05:09:33 lwall
* patch2: in a2p, awk script with no line actions still needs main loop
*
if (!s)
fatal("Illegal for loop: %s",d);
*s++ = '\0';
- t = index(s,'}' + 128);
- if (!t)
- t = index(s,']' + 128);
- if (t)
+ for (t = s; i = *t; t++) {
+ i &= 127;
+ if (i == '}' || i == ']')
+ break;
+ }
+ if (*t)
*t = '\0';
str = str_new(0);
str_set(str,d+1);