diff options
author | Andy Dougherty <doughera@lafcol.lafayette.edu> | 1995-05-30 22:59:41 +0000 |
---|---|---|
committer | Andy Dougherty <doughera@lafcol.lafayette.edu> | 1995-05-30 22:59:41 +0000 |
commit | 16d20bd98cd29be76029ebf04027a7edd34d817b (patch) | |
tree | 9ff5dd75c8b63cfd0da63bc9e4d59f464986bc0e /toke.c | |
parent | 3b35bae3d5913952e779006fe378c78297e23080 (diff) | |
download | perl-16d20bd98cd29be76029ebf04027a7edd34d817b.tar.gz |
This is my patch patch.1i for perl5.001.
To apply, change to your perl directory, run the commands above, then
apply with
patch -p1 -N < thispatch.
After you apply this patch, I would recommend:
rm config.sh
sh Configure [whatever options you use]
make depend
make
make test
Here are the highlights:
All pod documentation now installed, along with corresponding man
pages, if possible (Configure allows you to change this).
cppstdin no longer points back to the build directory. This
necessitated two changes to the test suite: comp/cpp.t is now a
front end that punts if cppstdin is not yet available (the old
perl4 trick doesn't work for perl5). The op/misc.t test
./perl -P -e 'use POSIX;' has been dropped since I couldn't think
of an elegant way to bypass it for systems that need the cppstdin
wrapper.
Grand autoload patch included (minus the installperl, lib/, and
ext/ changes). The lib/ changes are in patch.1g, and the
ext/ changes are in patch.1h.
Better detection and use of stdio variants, especially on SVR4.
Sarathy's consolidated patches (for ties) included.
New filter stuff included.
Three patches from Larry (gv.c, toke.c, pp_ctl.c)
Patch and enjoy,
Andy Dougherty doughera@lafcol.lafayette.edu
Dept. of Physics
Lafayette College Easton, PA 18042
Here's the file-by-file breakdown of what's included:
Changes.Conf
Document changes in the Configure & build process.
Configure
Upgrade to metaconfig PL55.
Add /opt hierarchy to paths searched for programs.
Tye McQueen's updated std stdio testing.
Prompting for installation info for perl module pages.
Add possible SITELIB to include site-specific include directories.
By default this is disabled, but it seemed a neat idea now that
the standard perl library is getting so big.
Check that the compiler chosen exists and actually supports the
options the user specified.
Correctly sort multiple shared library version numbers.
Use a compile & link test for gconvert(), dlopen(), and dlerror().
Do not include build directory name in cppstdin wrapper.
MANIFEST
Updated.
Makefile.SH
Reorganized a bit to support separate install.perl and install.man
targets to use the new installman script and to accomodate those who
don't want to install the man pages.
Organize cleanup of .SH files a little better.
No longer automatically make the pod/*.man files. This is done by
installman only if requested.
Include additional error messages and info for regenerating the
automatically maintained header files.
Add 'minitest' target.
README
Updated.
README.vms
Fix perl5-porters subscription info.
config_H
Updated.
config_h.SH
Updated.
configpm
Embedded pod.
configure
GNU configure-like front end to metaconfig's Configure.
Only supports a few options.
doio.c
Updated to use new std stdio testing.
embed.h
Add new symbols for filtering.
global.sym
see embed.h.
gv.c
C<sub method;> patch from lwall.
hints/README.hints
Updated.
hints/aux.sh
Updated.
hints/cxux.sh
Updated.
hints/epix.sh
New file.
hints/freebsd.sh
Updated.
hints/irix_4.sh
Updated.
hints/irix_5.sh
Updated.
hints/irix_6.sh
Updated.
hints/linux.sh
Updated.
hints/powerunix.sh
Updated.
installman
New file to install pod/*.pod and lib/*.p(m|od) man pages.
installperl
Move installation of man pages over to installman script.
Install pod/*.pod files in $privlib/pod/.
Preserve timestamps on .a files.
makedepend.SH
Now includes . and .. in PATH to explicitly find cppstdin wrapper.
opcode.h
opcode.pl
shmwrite fix.
perl.c
Changed unofficial patchlevel message.
Included optional SITELIB directory.
perl.h
#include <memory.h>
cryptswitch gone/filters added.
EUNICE replaced by UNLINK_ALL_VERSIONS. Only matters for VMS.
perldoc.SH
New file.
pod/perl.pod
Describe where modpods are.
pp_ctl.c
sort bug fix from lwall.
pp_hot.c
csh glob bug fix from tchrist.
Sarathy's consolidated "tie" patch for NETaa13753 N 2 trey
pp_sys.c
Emulate flock with lockf, if possible.
Use new std stdio unit.
proto.h
Filters stuff.
prototype for unlnk() is only needed #if UNLINK_ALL_VERSIONS
sv.c
Sarathy's consolidated "tie" patch for NETaa13753 N 2 trey
Sarathy's consolidated patch for nested ties.
Use new std stdio unit.
t/comp/cpp.aux
New file. This only gets called if cppstdin is avaiable.
t/comp/cpp.t
Calls cpp.aux test only if cppstdin is available.
t/op/misc.t
Drop
perl -P -e 'use POSIX;' test.
it couldn't work on systems without the cppstdin wrapper
installed, and is usually misleading when it fails anyway.
toke.c
filter stuff.
fix for NETaa13798 from lwall.
unixish.h
undef UNLINK_ALL_VERSIONS since it's irrelevant for unix.
util.c
s/EUNICE/UNLINK_ALL_VERSIONS/ for the unlnk() function.
vms/config.vms
VMS updates from Charles Bailey.
std stdio updates to match changes in perl sources.
add UNLINK_ALL_VERSIONS constant, but leave it #undef.
vms/ext/MM_VMS.pm
vms/ext/VMS/stdio/stdio.xs
vms/perlvms.pod
vms/vms.c
VMS updates from Charles Bailey.
x2p/Makefile.SH
Updated to match man page Configure questions.
Slight clean-up on .SH targets.
x2p/str.c
Use new std stdio unit.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 153 |
1 files changed, 133 insertions, 20 deletions
@@ -43,6 +43,7 @@ static I32 sublex_start _((void)); #ifdef CRIPPLED_CC static int uni _((I32 f, char *s)); #endif +static char * filter_gets _((SV *sv, FILE *fp)); /* The following are arranged oddly so that the guard on the switch statement * can get by with a single comparison (if the compiler is smart enough). @@ -329,7 +330,7 @@ register char *s; } if (s < bufend || !rsfp || lex_state != LEX_NORMAL) return s; - if ((s = sv_gets(linestr, rsfp, 0)) == Nullch) { + if ((s = filter_gets(linestr, rsfp)) == Nullch) { if (minus_n || minus_p) { sv_setpv(linestr,minus_p ? ";}continue{print" : ""); sv_catpv(linestr,";}"); @@ -982,15 +983,132 @@ incl_perldb() } -/* Encrypted script support: cryptswitch_add() may be called to */ -/* define a function which may manipulate the input stream */ -/* (via popen() etc) to decode the input if required. */ -/* At the moment we only allow one cryptswitch function. */ +/* Encoded script support. filter_add() effectively inserts a + * 'pre-processing' function into the current source input stream. + * Note that the filter function only applies to the current source file + * (e.g., it will not affect files 'require'd or 'use'd by this one). + * + * The datasv parameter (which may be NULL) can be used to pass + * private data to this instance of the filter. The filter function + * can recover the SV using the FILTER_DATA macro and use it to + * store private buffers and state information. + * + * The supplied datasv parameter is upgraded to a PVIO type + * and the IoDIRP field is used to store the function pointer. + * Note that IoTOP_NAME, IoFMT_NAME, IoBOTTOM_NAME, if set for + * private use must be set using malloc'd pointers. + */ +static int filter_debug = 0; + +SV * +filter_add(funcp, datasv) + filter_t funcp; + SV *datasv; +{ + if (!funcp){ /* temporary handy debugging hack to be deleted */ + filter_debug = atoi((char*)datasv); + return NULL; + } + if (!rsfp_filters) + rsfp_filters = newAV(); + if (!datasv) + datasv = newSV(0); + if (!SvUPGRADE(datasv, SVt_PVIO)) + die("Can't upgrade filter_add data to SVt_PVIO"); + IoDIRP(datasv) = (DIR*)funcp; /* stash funcp into spare field */ + if (filter_debug) + warn("filter_add func %lx (%s)", funcp, SvPV(datasv,na)); + av_push(rsfp_filters, datasv); + return(datasv); +} + + +/* Delete most recently added instance of this filter function. */ void -cryptswitch_add(funcp) - cryptswitch_t funcp; +filter_del(funcp) + filter_t funcp; +{ + if (filter_debug) + warn("filter_del func %lx", funcp); + if (!rsfp_filters || AvFILL(rsfp_filters)<0) + return; + /* if filter is on top of stack (usual case) just pop it off */ + if (IoDIRP(FILTER_DATA(AvFILL(rsfp_filters))) == (void*)funcp){ + sv_free(av_pop(rsfp_filters)); + return; + } + /* we need to search for the correct entry and clear it */ + die("filter_del can only delete in reverse order (currently)"); +} + + +/* Invoke the n'th filter function for the current rsfp. */ +I32 +filter_read(idx, buf_sv, maxlen) + int idx; + SV *buf_sv; + int maxlen; /* 0 = read one text line */ { - cryptswitch_fp = funcp; + filter_t funcp; + SV *datasv = NULL; + if (!rsfp_filters) + return -1; + if (idx > AvFILL(rsfp_filters)){ /* Any more filters? */ + /* Provide a default input filter to make life easy. */ + /* Note that we append to the line. This is handy. */ + /* We ignore maxlen here */ + if (filter_debug) + warn("filter_read %d: from rsfp\n", idx); + if (maxlen) { + /* Want a block */ + int len ; + int old_len = SvCUR(buf_sv) ; + + /* ensure buf_sv is large enough */ + SvGROW(buf_sv, old_len + maxlen) ; + if ((len = fread(SvPVX(buf_sv) + old_len, 1, maxlen, rsfp)) <= 0) + return len ; + SvCUR_set(buf_sv, old_len + len) ; + } else { + /* Want a line */ + if (sv_gets(buf_sv, rsfp, (SvCUR(buf_sv)>0) ? 1 : 0) == NULL) + return -1; /* end of file */ + } + return SvCUR(buf_sv); + } + /* Skip this filter slot if filter has been deleted */ + if ( (datasv = FILTER_DATA(idx)) == &sv_undef){ + if (filter_debug) + warn("filter_read %d: skipped (filter deleted)\n", idx); + return FILTER_READ(idx+1, buf_sv, maxlen); /* recurse */ + } + /* Get function pointer hidden within datasv */ + funcp = (filter_t)IoDIRP(datasv); + if (filter_debug) + warn("filter_read %d: via function %lx (%s)\n", + idx, funcp, SvPV(datasv,na)); + /* Call function. The function is expected to */ + /* call "FILTER_READ(idx+1, buf_sv)" first. */ + /* Return: <0:error/eof, >=0:not eof (see yylex()) */ + return (*funcp)(idx, buf_sv, maxlen); +} + +static char * +filter_gets(sv,fp) +register SV *sv; +register FILE *fp; +{ + if (rsfp_filters) { + + SvCUR_set(sv, 0); /* start with empty line */ + if (FILTER_READ(0, sv, 0) > 0) + return ( SvPVX(sv) ) ; + else + return Nullch ; + } + else + return (sv_gets(sv, fp, 0)) ; + } @@ -1236,16 +1354,8 @@ yylex() } goto retry; } - /* Give cryptswitch a chance. Note that cryptswitch_fp may */ - /* be either be called once if it redirects rsfp and unregisters */ - /* itself, or it may be called on every line if it loads linestr. */ - if (cryptswitch_fp && (*cryptswitch_fp)()) { - oldoldbufptr = oldbufptr = s = SvPVX(linestr); - bufend = SvPVX(linestr) + SvCUR(linestr); - goto retry; - } do { - if ((s = sv_gets(linestr, rsfp, 0)) == Nullch) { + if ((s = filter_gets(linestr, rsfp)) == Nullch) { fake_eof: if (rsfp) { if (preprocess && !in_eval) @@ -1560,6 +1670,9 @@ yylex() OPERATOR(tmp); case ')': tmp = *s++; + s = skipspace(s); + if (*s == '{') + PREBLOCK(tmp); TERM(tmp); case ']': s++; @@ -4246,7 +4359,7 @@ register char *s; sv_setpvn(tmpstr,"",0); /* avoid "uninitialized" warning */ while (s >= bufend) { /* multiple line string? */ if (!rsfp || - !(oldoldbufptr = oldbufptr = s = sv_gets(linestr, rsfp, 0))) { + !(oldoldbufptr = oldbufptr = s = filter_gets(linestr, rsfp))) { curcop->cop_line = multi_start; missingterm(tokenbuf); } @@ -4405,7 +4518,7 @@ char *start; if (s < bufend) break; /* string ends on this line? */ if (!rsfp || - !(oldoldbufptr = oldbufptr = s = sv_gets(linestr, rsfp, 0))) { + !(oldoldbufptr = oldbufptr = s = filter_gets(linestr, rsfp))) { curcop->cop_line = multi_start; return Nullch; } @@ -4583,7 +4696,7 @@ register char *s; } s = eol; if (rsfp) { - s = sv_gets(linestr, rsfp, 0); + s = filter_gets(linestr, rsfp); oldoldbufptr = oldbufptr = bufptr = SvPVX(linestr); bufend = bufptr + SvCUR(linestr); if (!s) { |