diff options
author | 2013-03-25 20:06:16 +0000 | |
---|---|---|
committer | 2013-03-25 20:06:16 +0000 | |
commit | 898184e3e61f9129feb5978fad5a8c6865f00b92 (patch) | |
tree | 56f32aefc1eed60b534611007c7856f82697a205 /gnu/usr.bin/perl/ext/SDBM_File | |
parent | PGSHIFT -> PAGE_SHIFT (diff) | |
download | wireguard-openbsd-898184e3e61f9129feb5978fad5a8c6865f00b92.tar.xz wireguard-openbsd-898184e3e61f9129feb5978fad5a8c6865f00b92.zip |
import perl 5.16.3 from CPAN - worked on by Andrew Fresh and myself
Diffstat (limited to 'gnu/usr.bin/perl/ext/SDBM_File')
-rw-r--r-- | gnu/usr.bin/perl/ext/SDBM_File/SDBM_File.xs | 71 | ||||
-rw-r--r-- | gnu/usr.bin/perl/ext/SDBM_File/sdbm/README | 26 | ||||
-rw-r--r-- | gnu/usr.bin/perl/ext/SDBM_File/sdbm/biblio | 2 | ||||
-rw-r--r-- | gnu/usr.bin/perl/ext/SDBM_File/sdbm/dbe.c | 2 |
4 files changed, 36 insertions, 65 deletions
diff --git a/gnu/usr.bin/perl/ext/SDBM_File/SDBM_File.xs b/gnu/usr.bin/perl/ext/SDBM_File/SDBM_File.xs index 6aafb6b99fd..291e41bcd69 100644 --- a/gnu/usr.bin/perl/ext/SDBM_File/SDBM_File.xs +++ b/gnu/usr.bin/perl/ext/SDBM_File/SDBM_File.xs @@ -4,12 +4,14 @@ #include "XSUB.h" #include "sdbm/sdbm.h" +#define fetch_key 0 +#define store_key 1 +#define fetch_value 2 +#define store_value 3 + typedef struct { DBM * dbp ; - SV * filter_fetch_key ; - SV * filter_store_key ; - SV * filter_fetch_value ; - SV * filter_store_value ; + SV * filter[4]; int filtering ; } SDBM_File_type; @@ -40,8 +42,7 @@ sdbm_TIEHASH(dbtype, filename, flags, mode) RETVAL = NULL ; if ((dbp = sdbm_open(filename,flags,mode))) { - RETVAL = (SDBM_File)safemalloc(sizeof(SDBM_File_type)) ; - Zero(RETVAL, 1, SDBM_File_type) ; + RETVAL = (SDBM_File)safecalloc(1, sizeof(SDBM_File_type)); RETVAL->dbp = dbp ; } @@ -54,15 +55,12 @@ sdbm_DESTROY(db) SDBM_File db CODE: if (db) { + int i = store_value; sdbm_close(db->dbp); - if (db->filter_fetch_key) - SvREFCNT_dec(db->filter_fetch_key) ; - if (db->filter_store_key) - SvREFCNT_dec(db->filter_store_key) ; - if (db->filter_fetch_value) - SvREFCNT_dec(db->filter_fetch_value) ; - if (db->filter_store_value) - SvREFCNT_dec(db->filter_store_value) ; + do { + if (db->filter[i]) + SvREFCNT_dec(db->filter[i]); + } while (i-- > 0); safefree(db) ; } @@ -108,49 +106,22 @@ sdbm_NEXTKEY(db, key) int sdbm_error(db) SDBM_File db + ALIAS: + sdbm_clearerr = 1 CODE: - RETVAL = sdbm_error(db->dbp) ; - OUTPUT: - RETVAL - -int -sdbm_clearerr(db) - SDBM_File db - CODE: - RETVAL = sdbm_clearerr(db->dbp) ; + RETVAL = ix ? sdbm_clearerr(db->dbp) : sdbm_error(db->dbp); OUTPUT: RETVAL - SV * filter_fetch_key(db, code) SDBM_File db SV * code SV * RETVAL = &PL_sv_undef ; + ALIAS: + SDBM_File::filter_fetch_key = fetch_key + SDBM_File::filter_store_key = store_key + SDBM_File::filter_fetch_value = fetch_value + SDBM_File::filter_store_value = store_value CODE: - DBM_setFilter(db->filter_fetch_key, code) ; - -SV * -filter_store_key(db, code) - SDBM_File db - SV * code - SV * RETVAL = &PL_sv_undef ; - CODE: - DBM_setFilter(db->filter_store_key, code) ; - -SV * -filter_fetch_value(db, code) - SDBM_File db - SV * code - SV * RETVAL = &PL_sv_undef ; - CODE: - DBM_setFilter(db->filter_fetch_value, code) ; - -SV * -filter_store_value(db, code) - SDBM_File db - SV * code - SV * RETVAL = &PL_sv_undef ; - CODE: - DBM_setFilter(db->filter_store_value, code) ; - + DBM_setFilter(db->filter[ix], code); diff --git a/gnu/usr.bin/perl/ext/SDBM_File/sdbm/README b/gnu/usr.bin/perl/ext/SDBM_File/sdbm/README index cd7312cc575..2659e0fa113 100644 --- a/gnu/usr.bin/perl/ext/SDBM_File/sdbm/README +++ b/gnu/usr.bin/perl/ext/SDBM_File/sdbm/README @@ -32,7 +32,7 @@ derived from any licensed, proprietary or copyrighted software. The sdbm implementation is based on a 1978 algorithm -[Lar78] by P.-A. (Paul) Larson known as ``Dynamic Hashing''. +[Lar78] by P.-A. (Paul) Larson known as "Dynamic Hashing". In the course of searching for a substitute for ndbm, I pro- totyped three different external-hashing algorithms [Lar78, Fag79, Lit80] and ultimately chose Larson's algorithm as a @@ -70,7 +70,7 @@ _________________________ - 2 - -store operation will not ``wander away'' trying to split its +store operation will not "wander away" trying to split its data pages to insert a datum that cannot (due to elaborate worst-case situations) be inserted. (It will fail after a pre-defined number of attempts.) @@ -298,30 +298,30 @@ References [Lar78] - P.-A. Larson, ``Dynamic Hashing'', BIT, vol. 18, pp. + P.-A. Larson, "Dynamic Hashing", BIT, vol. 18, pp. 184-201, 1978. [Tho90] Ken Thompson, private communication, Nov. 1990 [Lit80] - W. Litwin, `` Linear Hashing: A new tool for file and - table addressing'', Proceedings of the 6th Conference on + W. Litwin, "Linear Hashing: A new tool for file and + table addressing", Proceedings of the 6th Conference on Very Large Dabatases (Montreal), pp. 212-223, Very Large Database Foundation, Saratoga, Calif., 1980. [Fag79] R. Fagin, J. Nievergelt, N. Pippinger, and H. R. - Strong, ``Extendible Hashing - A Fast Access Method for - Dynamic Files'', ACM Trans. Database Syst., vol. 4, + Strong, "Extendible Hashing - A Fast Access Method for + Dynamic Files", ACM Trans. Database Syst., vol. 4, no.3, pp. 315-344, Sept. 1979. [Wal84] - Rich Wales, ``Discussion of "dbm" data base system'', + Rich Wales, "Discussion of 'dbm' data base system", USENET newsgroup unix.wizards, Jan. 1984. [Tor87] - Chris Torek, ``Re: dbm.a and ndbm.a archives'', + Chris Torek, "Re: dbm.a and ndbm.a archives", @@ -337,13 +337,13 @@ References USENET newsgroup comp.unix, 1987. [Mar79] - G. N. Martin, ``Spiral Storage: Incrementally Augment- - able Hash Addressed Storage'', Technical Report #27, + G. N. Martin, "Spiral Storage: Incrementally Augment- + able Hash Addressed Storage", Technical Report #27, University of Varwick, Coventry, U.K., 1979. [Enb88] - R. J. Enbody and H. C. Du, ``Dynamic Hashing - Schemes'',ACM Computing Surveys, vol. 20, no. 2, pp. + R. J. Enbody and H. C. Du, "Dynamic Hashing + Schemes",ACM Computing Surveys, vol. 20, no. 2, pp. 85-113, June 1988. diff --git a/gnu/usr.bin/perl/ext/SDBM_File/sdbm/biblio b/gnu/usr.bin/perl/ext/SDBM_File/sdbm/biblio index 0be09fa005b..f2880dc4903 100644 --- a/gnu/usr.bin/perl/ext/SDBM_File/sdbm/biblio +++ b/gnu/usr.bin/perl/ext/SDBM_File/sdbm/biblio @@ -52,7 +52,7 @@ %K torek %A Rich Wales -%T Discusson of "dbm" data base system +%T Discussion of "dbm" data base system %B USENET newsgroup unix.wizards %D Jan. 1984 %K rich diff --git a/gnu/usr.bin/perl/ext/SDBM_File/sdbm/dbe.c b/gnu/usr.bin/perl/ext/SDBM_File/sdbm/dbe.c index 166e64efdf2..f2aa29075a5 100644 --- a/gnu/usr.bin/perl/ext/SDBM_File/sdbm/dbe.c +++ b/gnu/usr.bin/perl/ext/SDBM_File/sdbm/dbe.c @@ -286,7 +286,7 @@ main(int argc, char **argv) } if (giveusage || what == YOW || argn < 1) { - fprintf(stderr, "Usage: %s databse [-m r|w|rw] [-crtx] -a|-d|-f|-F|-s [key [content]]\n", argv[0]); + fprintf(stderr, "Usage: %s database [-m r|w|rw] [-crtx] -a|-d|-f|-F|-s [key [content]]\n", argv[0]); exit(-1); } |