diff options
author | Charles Bailey <bailey@newman.upenn.edu> | 2000-01-20 00:25:30 +0000 |
---|---|---|
committer | bailey <bailey@newman.upenn.edu> | 2000-01-20 00:25:30 +0000 |
commit | 146174a91a192983720a158796dc066226ad0e55 (patch) | |
tree | 6e7f2035aae6d864035ea40ad9821bab4d0bad93 /av.c | |
parent | c529f79d594c53d3968d464c57ac24a21137dd09 (diff) | |
download | perl-146174a91a192983720a158796dc066226ad0e55.tar.gz |
Quick integration of mainline changes to date
p4raw-id: //depot/vmsperl@4821
p4raw-branched: from //depot/perl@4249 'branch in'
eg/cgi/dna_small_gif.uu eg/cgi/wilogo_gif.uu epoc/config.sh
epoc/epocish.c epoc/link.pl ext/DB_File/hints/sco.pl
ext/DynaLoader/XSLoader_pm.PL ext/DynaLoader/hints/aix.pl
ext/DynaLoader/hints/openbsd.pl ext/File/Glob/Makefile.PL
ext/File/Glob/TODO ext/IPC/SysV/hints/cygwin.pl
ext/NDBM_File/hints/cygwin.pl ext/NDBM_File/hints/sco.pl
ext/ODBM_File/hints/cygwin.pl lib/byte.pm lib/byte_heavy.pl
lib/unicode/Jamo.txt lib/unicode/NamesList.html
lib/unicode/UCD300.html lib/unicode/Unicode.300
lib/unicode/Unicode3.html os2/OS2/REXX/DLL/Changes
os2/OS2/REXX/DLL/DLL.pm os2/OS2/REXX/DLL/DLL.xs
os2/OS2/REXX/DLL/MANIFEST os2/OS2/REXX/DLL/Makefile.PL
os2/OS2/REXX/t/rx_emxrv.t t/lib/glob-case.t t/lib/glob-taint.t
t/pod/multiline_items.xr t/pod/pod2usage.xr t/pod/podselect.xr
win32/vmem.h t/pod/multiline_items.t t/pod/pod2usage.t
t/pod/podselect.t (@4280..) pod/perlhack.pod (@4340..)
ext/File/Glob/Changes ext/File/Glob/Glob.xs t/lib/glob-global.t
(@4356..) t/lib/glob-basic.t (@4393..) lib/Pod/Man.pm (@4404..)
pod/perlfilter.pod (@4406..) t/io/nargv.t (@4503..)
ext/File/Glob/bsd_glob.c ext/File/Glob/bsd_glob.h (@4514..)
epoc/createpkg.pl epoc/epoc_stubs.c (@4556..)
lib/unicode/Eq/Latin1.pl lib/unicode/Eq/Unicode.pl
lib/unicode/In/BopomofoExtended.pl
lib/unicode/In/BraillePatterns.pl
lib/unicode/In/CJKRadicalsSupplement.pl
lib/unicode/In/CJKUnifiedIdeographsExtensionA.pl
lib/unicode/In/Cherokee.pl
lib/unicode/In/IdeographicDescriptionCharacters.pl
lib/unicode/In/KangxiRadicals.pl lib/unicode/In/Khmer.pl
lib/unicode/In/Mongolian.pl lib/unicode/In/Myanmar.pl
lib/unicode/In/Ogham.pl lib/unicode/In/Runic.pl
lib/unicode/In/Sinhala.pl lib/unicode/In/Syriac.pl
lib/unicode/In/Thaana.pl
lib/unicode/In/UnifiedCanadianAboriginalSyllabics.pl
lib/unicode/In/YiRadicals.pl lib/unicode/In/YiSyllables.pl
(@4573..) pod/perlfork.pod (@4602..) ext/File/Glob/Glob.pm
(@4615..) win32/genmk95.pl (@4653..) win32/vdir.h (@4702..)
win32/perlhost.h (@4789..)
p4raw-deleted: from //depot/perl@4249 'delete in'
eg/cgi/dna.small.gif.uu eg/cgi/wilogo.gif.uu (@2830..)
os2/POSIX.mkfifo (@3518..) lib/warning.pm warning.h (@4008..)
lib/unicode/Jamo-2.txt lib/unicode/UnicodeData-Latest.txt
(@4184..) lib/unicode/Unicode.html (@4209..)
lib/unicode/Eq/Latin1 lib/unicode/Eq/Unicode (@4228..)
lib/Pod/PlainText.pm (@4280..) ext/DynaLoader/dl_cygwin.xs
(@4302..) epoc/config.h (@4475..) epoc/perl.mmp epoc/perl.pkg
(@4556..)
p4raw-integrated: from //depot/perl@4249 'copy in' ext/B/NOTES
ext/B/ramblings/runtime.porting (@562..) hints/amigaos.sh
(@575..) lib/Net/Ping.pm (@854..) lib/strict.pm (@988..)
ext/Thread/Thread/Queue.pm (@1085..)
ext/Thread/Thread/Semaphore.pm (@1086..)
lib/ExtUtils/Installed.pm (@1315..) plan9/plan9ish.h (@1451..)
mpeix/mpeixish.h (@1478..) Porting/p4d2p (@1485..)
ext/ODBM_File/hints/sco.pl ext/Thread/sync.t ext/Thread/sync2.t
hints/lynxos.sh lib/Text/Tabs.pm os2/OS2/REXX/Changes
os2/OS2/REXX/t/rx_dllld.t os2/OS2/REXX/t/rx_objcall.t
os2/OS2/REXX/t/rx_tievar.t os2/OS2/REXX/t/rx_tieydb.t
os2/OS2/REXX/t/rx_vrexx.t os2/dl_os2.c t/comp/term.t
t/io/print.t t/op/glob.t util.h win32/bin/perlglob.pl (@1575..)
ext/B/O.pm (@1617..) ext/Thread/typemap lib/File/DosGlob.pm
(@1760..) t/op/substr.t (@1780..) vos/vosish.h (@1838..)
lib/ExtUtils/Mkbootstrap.pm (@1932..) Porting/genlog (@1978..)
lib/constant.pm (@2029..) t/op/array.t (@2210..)
lib/Math/Complex.pm (@2219..) hints/dynixptx.sh (@2318..)
ext/IO/IO.pm (@2354..) hints/mint.sh lib/Tie/Array.pm
lib/Tie/Hash.pm (@2620..) os2/Changes (@2695..) globvar.sym
(@2746..) t/comp/bproto.t (@2817..) lib/DB.pm (@2820..)
hints/mpeix.sh lib/FindBin.pm (@2830..) ext/IO/lib/IO/Select.pm
(@2882..) t/lib/english.t (@2891..) t/op/subst.t (@2892..)
t/op/range.t (@2923..) pod/perl5005delta.pod (@2929..)
hints/next_3.sh hints/next_3_0.sh (@3023..) lib/Getopt/Std.pm
(@3034..) lib/File/Spec.pm (@3042..) t/pragma/warn/1global
(@3096..) t/pod/emptycmd.t t/pod/for.t t/pod/for.xr
t/pod/headings.t t/pod/headings.xr t/pod/include.t
t/pod/include.xr t/pod/included.t t/pod/included.xr
t/pod/lref.t t/pod/lref.xr t/pod/nested_items.t
t/pod/nested_items.xr t/pod/nested_seqs.t t/pod/nested_seqs.xr
t/pod/oneline_cmds.t t/pod/oneline_cmds.xr t/pod/testcmp.pl
(@3129..) README.hurd (@3148..) ext/re/re.pm (@3152..)
lib/ExtUtils/Liblist.pm t/comp/require.t (@3153..)
Porting/p4desc (@3183..) Porting/pumpkin.pod hints/linux.sh
myconfig.SH (@3267..) t/op/readdir.t (@3299..)
t/pod/special_seqs.t t/pod/special_seqs.xr (@3304..)
t/lib/fields.t (@3335..) t/op/taint.t (@3357..)
lib/File/Copy.pm (@3362..) installhtml (@3371..)
ext/Socket/Socket.pm (@3391..) t/lib/ipc_sysv.t t/op/nothread.t
(@3399..) lib/CPAN/FirstTime.pm (@3458..) pod/perlfaq8.pod
(@3459..) pod/perlcall.pod pod/perlipc.pod pod/perltie.pod
pod/perlxs.pod (@3460..) t/pragma/strict-subs (@3514..)
ext/ByteLoader/ByteLoader.pm lib/Math/BigFloat.pm (@3516..)
x2p/walk.c (@3518..) win32/win32thread.c win32/win32thread.h
(@3525..) os2/OS2/REXX/REXX.xs (@3531..) utf8.h (@3537..)
lib/ExtUtils/Embed.pm (@3553..) ext/Thread/Thread/Specific.pm
(@3564..) ext/POSIX/Makefile.PL lib/Cwd.pm (@3582..) hv.h
(@3602..) ext/NDBM_File/NDBM_File.pm ext/ODBM_File/ODBM_File.pm
ext/SDBM_File/SDBM_File.pm (@3603..) lib/Sys/Hostname.pm
(@3631..) os2/os2.c (@3640..) emacs/ptags miniperlmain.c
(@3660..) ext/IO/IO.xs win32/config_h.PL win32/dl_win32.xs
win32/runperl.c win32/win32sck.c (@3667..) pod/Win32.pod
pod/perlfaq4.pod pod/perltodo.pod (@3676..) lib/vars.pm
(@3686..) lib/ExtUtils/Manifest.pm (@3693..) hints/README.hints
hints/epix.sh hints/esix4.sh hints/next_4.sh (@3753..)
ext/GDBM_File/GDBM_File.pm lib/CPAN.pm pod/perllocale.pod
(@3754..) lib/bigfloat.pl (@3759..) lib/Pod/Text/Color.pm
lib/Pod/Text/Termcap.pm pod/pod2text.PL (@3788..)
ext/POSIX/POSIX.pm lib/AutoLoader.pm (@3794..) Porting/makerel
(@3797..) t/lib/io_unix.t (@3825..) EXTERN.h Porting/patchls
ext/SDBM_File/sdbm/pair.c makedepend.SH (@3852..)
lib/File/Spec/Unix.pm unixish.h (@3855..)
lib/ExtUtils/Mksymlists.pm (@3856..) t/pragma/utf8.t (@3892..)
README (@3901..) t/op/eval.t (@3988..) MAINTAIN
ext/B/B/Stash.pm ext/ByteLoader/ByteLoader.xs
ext/Fcntl/Fcntl.xs ext/SDBM_File/Makefile.PL lib/Math/Trig.pm
os2/OS2/REXX/Makefile.PL perlsdio.h regnodes.h utils/perlbug.PL
(@4008..) epoc/epoc.c pod/perltoc.pod pod/perlvar.pod regexp.h
t/lib/attrs.t t/op/time.t t/pragma/warn/2use
t/pragma/warn/3both t/pragma/warn/7fatal universal.c warnings.h
warnings.pl (@4076..) ext/Opcode/Opcode.pm ext/attrs/attrs.xs
t/pragma/warn/pp_ctl (@4081..) t/pragma/warn/pp_sys (@4088..)
t/pragma/sub_lval.t (@4090..) t/TEST (@4092..) xsutils.c
(@4101..) pod/buildtoc (@4120..) djgpp/config.over
djgpp/djgppsed.sh pod/pod2usage.PL pod/podselect.PL (@4121..)
lib/Pod/Html.pm (@4122..) av.h (@4123..) t/pragma/locale.t
(@4130..) pod/perldata.pod (@4131..) pod/perllexwarn.pod
(@4132..) ext/B/typemap ext/DB_File/DB_File.pm
lib/ExtUtils/typemap (@4142..) ext/B/Makefile.PL
t/lib/bigfltpm.t (@4149..) lib/ExtUtils/MM_VMS.pm
vms/descrip_mms.template (@4182..) ext/DynaLoader/dl_vmesa.xs
ext/DynaLoader/dl_vms.xs lib/unicode/ReadMe.txt pod/perlsyn.pod
t/op/groups.t (@4184..) t/pragma/warn/op (@4189..) thrdvar.h
(@4197..) ext/B/B/Terse.pm (@4199..) t/lib/posix.t (@4223..)
keywords.h keywords.pl pod/perlfaq3.pod pod/perlsub.pod
t/pragma/strict-vars (@4227..) pod/perlfaq9.pod (@4228..)
djgpp/configure.bat lib/Exporter/Heavy.pm (@4242..)
Porting/findvars lib/ExtUtils/xsubpp pod/perlguts.pod
t/lib/filecopy.t (@4271..) ext/attrs/attrs.pm (@4278..)
t/op/avhv.t (@4279..) lib/Pod/Checker.pm
lib/Pod/InputObjects.pm t/pod/testp2pt.pl (@4280..)
lib/Pod/Usage.pm pod/podchecker.PL t/pod/poderrs.t
t/pod/poderrs.xr t/pod/testpchk.pl (@4281..) lib/Pod/Text.pm
pod/pod2man.PL (@4282..) ext/Devel/Peek/Peek.xs
ext/DynaLoader/dl_beos.xs ext/DynaLoader/dl_dld.xs
ext/DynaLoader/dl_mpeix.xs ext/DynaLoader/dlutils.c perlio.c
(@4302..) ext/B/defsubs_h.PL t/pragma/constant.t (@4303..)
ext/Thread/Thread.xs (@4316..) ext/Thread/Thread.pm (@4328..)
lib/Exporter.pm (@4331..) ext/DynaLoader/dl_aix.xs (@4336..)
pod/Makefile pod/roffitall (@4340..) lib/lib.pm (@4343..)
pod/perlref.pod (@4345..) perly.y perly_c.diff (@4350..)
t/lib/safe2.t (@4353..) hints/svr5.sh (@4377..)
pod/perlfaq2.pod (@4383..) lib/Benchmark.pm (@4384..)
win32/include/dirent.h (@4385..) pod/perlopentut.pod (@4390..)
hints/os2.sh os2/Makefile.SHs (@4393..) lib/Pod/Parser.pm
lib/Pod/Select.pm (@4400..) malloc.c (@4402..)
pod/perlmodlib.pod (@4404..) perlvars.h (@4409..) t/op/sort.t
(@4418..) t/op/int.t (@4430..) os2/OS2/REXX/REXX.pm t/io/fs.t
t/op/magic.t (@4432..) lib/File/Path.pm (@4433..)
t/op/lex_assign.t (@4436..) lib/attributes.pm (@4437..)
pod/perlop.pod (@4438..) ext/POSIX/POSIX.xs (@4448..)
Policy_sh.SH ext/Data/Dumper/Dumper.xs hints/dec_osf.sh
t/lib/charnames.t (@4475..) lib/Time/Local.pm (@4481..) cv.h
ext/B/B/Xref.pm (@4485..) doop.c handy.h hints/irix_6.sh pp.h
taint.c (@4496..) deb.c (@4505..) dosish.h os2/os2ish.h perly.c
vms/perly_c.vms (@4511..) ext/B/B/Lint.pm pod/perlmod.pod
pod/perlrun.pod (@4515..) bytecode.pl ext/B/B.pm
ext/B/B/Asmdata.pm ext/B/B/CC.pm ext/B/B/Debug.pm
ext/B/B/Deparse.pm ext/ByteLoader/bytecode.h
ext/ByteLoader/byterun.c ext/ByteLoader/byterun.h
ext/Devel/Peek/Peek.pm gv.h (@4545..) README.epoc
epoc/epocish.h ext/B/B.xs ext/Fcntl/Fcntl.pm hints/hpux.sh
t/lib/syslfs.t t/op/lfs.t t/op/pat.t (@4556..)
ext/DynaLoader/DynaLoader_pm.PL hints/solaris_2.sh
lib/unicode/Is/SylA.pl lib/unicode/Is/SylC.pl
lib/unicode/Is/SylE.pl lib/unicode/Is/SylI.pl
lib/unicode/Is/SylO.pl lib/unicode/Is/SylU.pl
lib/unicode/Is/SylV.pl lib/unicode/Is/SylWA.pl
lib/unicode/Is/SylWC.pl lib/unicode/Is/SylWE.pl
lib/unicode/Is/SylWI.pl lib/unicode/Is/SylWV.pl
lib/unicode/mktables.PL t/op/pack.t t/op/regexp.t utils/h2xs.PL
utils/perldoc.PL vms/vms.c vms/vmsish.h win32/win32iop.h
(@4573..) t/lib/dumper.t t/pragma/overload.t (@4574..)
ext/Errno/Errno_pm.PL ext/IO/lib/IO/Socket.pm (@4575..)
t/op/misc.t (@4578..) ext/Opcode/Opcode.xs (@4579..) cop.h
(@4588..) lib/perl5db.pl (@4601..) XSUB.h globals.c
pod/perl.pod run.c scope.c (@4602..) op.h win32/perllib.c
(@4603..) AUTHORS pod/perlport.pod t/op/runlevel.t (@4604..)
scope.h (@4605..) README.vms hints/aix.sh vms/subconfigure.com
(@4606..) pod/perlxstut.pod (@4620..) regcomp.h (@4622..)
ext/Devel/DProf/DProf.pm ext/DynaLoader/Makefile.PL (@4623..)
pod/perltrap.pod (@4630..) ext/B/B/Bytecode.pm (@4631..)
opcode.h opcode.pl t/pragma/warn/4lint t/pragma/warn/doio
t/pragma/warn/pp_hot (@4641..) mg.c (@4658..) iperlsys.h
(@4660..) ext/B/B/C.pm (@4662..) pod/perlre.pod (@4666..)
embedvar.h (@4668..) t/lib/filefind.t (@4671..) intrpvar.h
(@4672..) ext/DynaLoader/dl_hpux.xs ext/DynaLoader/dl_next.xs
ext/DynaLoader/dl_rhapsody.xs (@4686..) lib/File/Find.pm
(@4687..) cygwin/Makefile.SHs (@4688..) t/op/re_tests (@4693..)
hv.c (@4694..) t/op/delete.t (@4695..) utf8.c (@4698..)
thread.h (@4704..) pod/perldiag.pod pp_sys.c (@4709..)
Makefile.SH (@4712..) hints/cygwin.sh t/op/stat.t (@4717..)
README.os2 lib/ExtUtils/Install.pm (@4720..) t/pragma/warn/doop
t/pragma/warn/pp t/pragma/warn/regcomp t/pragma/warn/sv
t/pragma/warn/toke t/pragma/warn/utf8 (@4721..)
lib/diagnostics.pm (@4722..) regcomp.c (@4724..) configpm
pp_ctl.c sv.h (@4726..) global.sym (@4727..) INTERN.h
README.win32 lib/ExtUtils/MM_Win32.pm makedef.pl (@4729..)
t/io/argv.t (@4732..) doio.c pp_hot.c (@4736..) toke.c
(@4740..) gv.c (@4742..) win32/win32.h (@4743..)
ext/Devel/DProf/DProf.xs objXSUB.h (@4744..)
ext/Data/Dumper/Dumper.pm (@4745..) embed.h embed.pl
ext/DynaLoader/dl_dlopen.xs proto.h (@4746..) pp.c (@4747..)
sv.c (@4749..) lib/ExtUtils/MM_Unix.pm
lib/ExtUtils/MakeMaker.pm (@4754..) util.c utils/perlcc.PL
(@4755..) t/io/open.t (@4757..) regexec.c (@4759..) MANIFEST
installman (@4769..) Porting/Glossary (@4771..) t/lib/thread.t
(@4772..) Changes INSTALL Porting/config.sh Porting/config_H
config_h.SH installperl patchlevel.h win32/config.bc
win32/config.gc win32/config.vc win32/config_sh.PL
win32/win32.c (@4773..) win32/Makefile win32/config_H.bc
win32/config_H.gc win32/config_H.vc win32/makefile.mk (@4774..)
perl.c (@4779..) t/op/fork.t (@4791..) av.c pod/perldelta.pod
(@4796..) pod/perlfunc.pod (@4799..) dump.c (@4800..) op.c
(@4801..) perl.h (@4805..) Configure (@4814..) 'merge in'
configure.com (@4767..)
Diffstat (limited to 'av.c')
-rw-r--r-- | av.c | 109 |
1 files changed, 106 insertions, 3 deletions
@@ -591,6 +591,86 @@ Perl_av_fill(pTHX_ register AV *av, I32 fill) (void)av_store(av,fill,&PL_sv_undef); } +SV * +Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags) +{ + SV *sv; + + if (!av) + return Nullsv; + if (SvREADONLY(av)) + Perl_croak(aTHX_ PL_no_modify); + if (key < 0) { + key += AvFILL(av) + 1; + if (key < 0) + return Nullsv; + } + if (SvRMAGICAL(av)) { + SV **svp; + if ((mg_find((SV*)av,'P') || mg_find((SV*)av,'D')) + && (svp = av_fetch(av, key, TRUE))) + { + sv = *svp; + mg_clear(sv); + if (mg_find(sv, 'p')) { + sv_unmagic(sv, 'p'); /* No longer an element */ + return sv; + } + return Nullsv; /* element cannot be deleted */ + } + } + if (key > AvFILLp(av)) + return Nullsv; + else { + sv = AvARRAY(av)[key]; + if (key == AvFILLp(av)) { + do { + AvFILLp(av)--; + } while (--key >= 0 && AvARRAY(av)[key] == &PL_sv_undef); + } + else + AvARRAY(av)[key] = &PL_sv_undef; + if (SvSMAGICAL(av)) + mg_set((SV*)av); + } + if (flags & G_DISCARD) { + SvREFCNT_dec(sv); + sv = Nullsv; + } + return sv; +} + +/* + * This relies on the fact that uninitialized array elements + * are set to &PL_sv_undef. + */ + +bool +Perl_av_exists(pTHX_ AV *av, I32 key) +{ + if (!av) + return FALSE; + if (key < 0) { + key += AvFILL(av) + 1; + if (key < 0) + return FALSE; + } + if (SvRMAGICAL(av)) { + if (mg_find((SV*)av,'P') || mg_find((SV*)av,'D')) { + SV *sv = sv_newmortal(); + mg_copy((SV*)av, sv, 0, key); + magic_existspack(sv, mg_find(sv, 'p')); + return SvTRUE(sv); + } + } + if (key <= AvFILLp(av) && AvARRAY(av)[key] != &PL_sv_undef + && AvARRAY(av)[key]) + { + return TRUE; + } + else + return FALSE; +} /* AVHV: Support for treating arrays as if they were hashes. The * first element of the array should be a hash reference that maps @@ -630,18 +710,41 @@ Perl_avhv_fetch_ent(pTHX_ AV *av, SV *keysv, I32 lval, U32 hash) SV **indsvp; HV *keys = avhv_keys(av); HE *he; - + STRLEN n_a; + he = hv_fetch_ent(keys, keysv, FALSE, hash); if (!he) - Perl_croak(aTHX_ "No such array field"); + Perl_croak(aTHX_ "No such pseudo-hash field \"%s\"", SvPV(keysv,n_a)); return av_fetch(av, avhv_index_sv(HeVAL(he)), lval); } +SV * +Perl_avhv_delete_ent(pTHX_ AV *av, SV *keysv, I32 flags, U32 hash) +{ + HV *keys = avhv_keys(av); + HE *he; + + he = hv_fetch_ent(keys, keysv, FALSE, hash); + if (!he || !SvOK(HeVAL(he))) + return Nullsv; + + return av_delete(av, avhv_index_sv(HeVAL(he)), flags); +} + +/* Check for the existence of an element named by a given key. + * + */ bool Perl_avhv_exists_ent(pTHX_ AV *av, SV *keysv, U32 hash) { HV *keys = avhv_keys(av); - return hv_exists_ent(keys, keysv, hash); + HE *he; + + he = hv_fetch_ent(keys, keysv, FALSE, hash); + if (!he || !SvOK(HeVAL(he))) + return FALSE; + + return av_exists(av, avhv_index_sv(HeVAL(he))); } HE * |