r50435 - in /trunk/libvariable-magic-perl: Changes META.yml Magic.xs README debian/changelog debian/copyright lib/Variable/Magic.pm ptable.h

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Thu Jan 7 04:50:57 UTC 2010


Author: jawnsy-guest
Date: Thu Jan  7 04:50:49 2010
New Revision: 50435

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=50435
Log:
* New upstream release
* Update copyright information

Modified:
    trunk/libvariable-magic-perl/Changes
    trunk/libvariable-magic-perl/META.yml
    trunk/libvariable-magic-perl/Magic.xs
    trunk/libvariable-magic-perl/README
    trunk/libvariable-magic-perl/debian/changelog
    trunk/libvariable-magic-perl/debian/copyright
    trunk/libvariable-magic-perl/lib/Variable/Magic.pm
    trunk/libvariable-magic-perl/ptable.h

Modified: trunk/libvariable-magic-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/Changes?rev=50435&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/Changes (original)
+++ trunk/libvariable-magic-perl/Changes Thu Jan  7 04:50:49 2010
@@ -1,4 +1,8 @@
 Revision history for Variable-Magic
+
+0.40    2010-01-06 23:20 UTC
+        + Fix : Possible memory miswrites when passing data arguments to cast().
+        + Fix : Minor C portability tweaks.
 
 0.39    2009-12-01 00:05 UTC
         + Add : You can use a function name as a callback by passing a string

Modified: trunk/libvariable-magic-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/META.yml?rev=50435&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/META.yml (original)
+++ trunk/libvariable-magic-perl/META.yml Thu Jan  7 04:50:49 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Variable-Magic
-version:            0.39
+version:            0.40
 abstract:           Associate user-defined magic to variables from Perl.
 author:
     - Vincent Pit <perl at profvince.com>
@@ -32,7 +32,7 @@
     directory:
         - t
         - inc
-generated_by:       ExtUtils::MakeMaker version 6.55_02
+generated_by:       ExtUtils::MakeMaker version 6.56
 meta-spec:
     url:      http://module-build.sourceforge.net/META-spec-v1.4.html
     version:  1.4

Modified: trunk/libvariable-magic-perl/Magic.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/Magic.xs?rev=50435&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/Magic.xs (original)
+++ trunk/libvariable-magic-perl/Magic.xs Thu Jan  7 04:50:49 2010
@@ -100,12 +100,16 @@
 # define SvMAGIC_set(sv, val) (SvMAGIC(sv) = (val))
 #endif
 
+#ifndef SvRV_const
+# define SvRV_const(sv) SvRV((SV *) sv)
+#endif
+
+#ifndef SvREFCNT_inc_simple_void
+# define SvREFCNT_inc_simple_void(sv) SvREFCNT_inc(sv)
+#endif
+
 #ifndef mPUSHu
 # define mPUSHu(U) PUSHs(sv_2mortal(newSVuv(U)))
-#endif
-
-#ifndef SvPV_const
-# define SvPV_const SvPV
 #endif
 
 #ifndef PERL_MAGIC_ext
@@ -335,8 +339,8 @@
 typedef struct {
  MGVTBL *vtbl;
 
+ U8 opinfo;
  U8 uvar;
- U8 opinfo;
 
  SV *cb_data;
  SV *cb_get, *cb_set, *cb_len, *cb_clear, *cb_free;
@@ -530,7 +534,7 @@
 STATIC const SV *vmg_wizard_validate(pTHX_ const SV *wiz) {
 #define vmg_wizard_validate(W) vmg_wizard_validate(aTHX_ (W))
  if (SvROK(wiz)) {
-  wiz = SvRV(wiz);
+  wiz = SvRV_const(wiz);
   if (SvIOK(wiz))
    return wiz;
  }
@@ -591,7 +595,7 @@
 
 STATIC const MAGIC *vmg_find(const SV *sv, const SV *wiz) {
  const MAGIC *mg, *moremagic;
- UV wid;
+ IV wid;
 
  if (SvTYPE(sv) < SVt_PVMG)
   return NULL;
@@ -600,7 +604,7 @@
  for (mg = SvMAGIC(sv); mg; mg = moremagic) {
   moremagic = mg->mg_moremagic;
   if (mg->mg_type == PERL_MAGIC_ext && mg->mg_private == SIG_WIZ) {
-   UV zid = vmg_wizard_id(mg->mg_ptr);
+   IV zid = vmg_wizard_id(mg->mg_ptr);
    if (zid == wid)
     return mg;
   }
@@ -633,9 +637,9 @@
  SPAGAIN;
  nsv = POPs;
 #if VMG_HAS_PERL(5, 8, 3)
- SvREFCNT_inc(nsv);    /* Or it will be destroyed in FREETMPS */
+ SvREFCNT_inc_simple_void(nsv); /* Or it will be destroyed in FREETMPS */
 #else
- nsv = sv_newref(nsv); /* Workaround some bug in SvREFCNT_inc() */
+ nsv = sv_newref(nsv);          /* Workaround some bug in SvREFCNT_inc() */
 #endif
  PUTBACK;
 
@@ -757,7 +761,7 @@
  U32 uvars = 0;
 #endif /* VMG_UVAR */
  MAGIC *mg, *prevmagic, *moremagic = NULL;
- UV wid = vmg_wizard_id(wiz);
+ IV wid = vmg_wizard_id(wiz);
 
  if (SvTYPE(sv) < SVt_PVMG)
   return 0;
@@ -766,7 +770,7 @@
   moremagic = mg->mg_moremagic;
   if (mg->mg_type == PERL_MAGIC_ext && mg->mg_private == SIG_WIZ) {
    const MGWIZ *z   = vmg_wizard_mgwiz(mg->mg_ptr);
-   UV           zid = vmg_wizard_id(mg->mg_ptr);
+   IV           zid = vmg_wizard_id(mg->mg_ptr);
    if (zid == wid) {
 #if VMG_UVAR
     /* If the current has no uvar, short-circuit uvar deletion. */
@@ -907,23 +911,15 @@
 
 /* ... svt callbacks ....................................................... */
 
-#define VMG_CB_CALL_SET_RET(D) \
- {            \
-  SV *svr;    \
-  SPAGAIN;    \
-  svr = POPs; \
-  ret = SvOK(svr) ? SvIV(svr) : (D); \
-  PUTBACK;    \
- }
-
 #define VMG_CB_CALL_ARGS_MASK  15
 #define VMG_CB_CALL_ARGS_SHIFT 4
 #define VMG_CB_CALL_OPINFO     (VMG_OP_INFO_NAME|VMG_OP_INFO_OBJECT)
 
 STATIC int vmg_cb_call(pTHX_ SV *cb, unsigned int flags, SV *sv, ...) {
  va_list ap;
- int ret;
+ int ret = 0;
  unsigned int i, args, opinfo;
+ SV *svr;
 
  dSP;
 
@@ -949,7 +945,11 @@
 
  call_sv(cb, G_SCALAR);
 
- VMG_CB_CALL_SET_RET(0);
+ SPAGAIN;
+ svr = POPs;
+ if (SvOK(svr))
+  ret = (int) SvIV(svr);
+ PUTBACK;
 
  FREETMPS;
  LEAVE;
@@ -957,12 +957,15 @@
  return ret;
 }
 
-#define vmg_cb_call1(I, F, S, A1) \
-        vmg_cb_call(aTHX_ (I), (((F) << VMG_CB_CALL_ARGS_SHIFT) | 1), (S), (A1))
-#define vmg_cb_call2(I, F, S, A1, A2) \
-        vmg_cb_call(aTHX_ (I), (((F) << VMG_CB_CALL_ARGS_SHIFT) | 2), (S), (A1), (A2))
-#define vmg_cb_call3(I, F, S, A1, A2, A3) \
-        vmg_cb_call(aTHX_ (I), (((F) << VMG_CB_CALL_ARGS_SHIFT) | 3), (S), (A1), (A2), (A3))
+#define VMG_CB_FLAGS(OI, A) \
+        ((((unsigned int) (OI)) << VMG_CB_CALL_ARGS_SHIFT) | (A))
+
+#define vmg_cb_call1(I, OI, S, A1) \
+        vmg_cb_call(aTHX_ (I), VMG_CB_FLAGS((OI), 1), (S), (A1))
+#define vmg_cb_call2(I, OI, S, A1, A2) \
+        vmg_cb_call(aTHX_ (I), VMG_CB_FLAGS((OI), 2), (S), (A1), (A2))
+#define vmg_cb_call3(I, OI, S, A1, A2, A3) \
+        vmg_cb_call(aTHX_ (I), VMG_CB_FLAGS((OI), 3), (S), (A1), (A2), (A3))
 
 STATIC int vmg_svt_get(pTHX_ SV *sv, MAGIC *mg) {
  const MGWIZ *w = vmg_wizard_mgwiz(mg->mg_ptr);
@@ -978,6 +981,7 @@
  const MGWIZ *w = vmg_wizard_mgwiz(mg->mg_ptr);
  unsigned int opinfo = w->opinfo;
  U32 len, ret;
+ SV *svr;
  svtype t = SvTYPE(sv);
 
  dSP;
@@ -991,7 +995,11 @@
  PUSHs(mg->mg_obj ? mg->mg_obj : &PL_sv_undef);
  if (t < SVt_PVAV) {
   STRLEN l;
-  const U8 *s = (const U8 *) SvPV_const(sv, l);
+#if VMG_HAS_PERL(5, 9, 3)
+  const U8 *s = SvPV_const(sv, l);
+#else
+  U8 *s = SvPV(sv, l);
+#endif
   if (DO_UTF8(sv))
    len = utf8_length(s, s + l);
   else
@@ -1010,12 +1018,17 @@
 
  call_sv(w->cb_len, G_SCALAR);
 
- VMG_CB_CALL_SET_RET(len);
+ SPAGAIN;
+ svr = POPs;
+ ret = SvOK(svr) ? (U32) SvUV(svr) : len;
+ if (t == SVt_PVAV)
+  --ret;
+ PUTBACK;
 
  FREETMPS;
  LEAVE;
 
- return t == SVt_PVAV ? ret - 1 : ret;
+ return ret;
 }
 
 STATIC int vmg_svt_clear(pTHX_ SV *sv, MAGIC *mg) {
@@ -1029,8 +1042,9 @@
  PERL_CONTEXT saved_cx;
  I32 cxix;
 #endif
- unsigned int had_err, has_err, flags = G_SCALAR | G_EVAL;
+ I32 had_err, has_err, flags = G_SCALAR | G_EVAL;
  int ret = 0;
+ SV *svr;
 
  dSP;
 
@@ -1042,7 +1056,7 @@
  w = vmg_wizard_mgwiz(mg->mg_ptr);
 
  /* So that it survives the temp cleanup below */
- SvREFCNT_inc(sv);
+ SvREFCNT_inc_simple_void(sv);
 
 #if !VMG_HAS_PERL_MAINT(5, 11, 0, 32686)
  /* The previous magic tokens were freed but the magic chain wasn't updated, so
@@ -1087,7 +1101,11 @@
  if (IN_PERL_COMPILETIME && !had_err && has_err)
   ++PL_error_count;
 
- VMG_CB_CALL_SET_RET(0);
+ SPAGAIN;
+ svr = POPs;
+ if (SvOK(svr))
+  ret = (int) SvIV(svr);
+ PUTBACK;
 
  FREETMPS;
  LEAVE;
@@ -1340,6 +1358,7 @@
 PROTOTYPE: DISABLE
 PREINIT:
  I32 i = 0;
+ UV opinfo;
  MGWIZ *w;
  MGVTBL *t;
  SV *cb;
@@ -1365,10 +1384,13 @@
  Newx(w, 1, MGWIZ);
 
  VMG_SET_CB(ST(i++), data);
+
  cb = ST(i++);
- w->opinfo = SvOK(cb) ? SvUV(cb) : 0;
+ opinfo = SvOK(cb) ? SvUV(cb) : 0;
+ w->opinfo = (U8) ((opinfo < 255) ? opinfo : 255);
  if (w->opinfo)
   vmg_op_info_init(w->opinfo);
+
  VMG_SET_SVT_CB(ST(i++), get);
  VMG_SET_SVT_CB(ST(i++), set);
  VMG_SET_SVT_CB(ST(i++), len);
@@ -1414,15 +1436,12 @@
 PREINIT:
  SV **args = NULL;
  I32 i = 0;
- SV *ret;
 CODE:
  if (items > 2) {
   i = items - 2;
   args = &ST(2);
  }
- ret = newSVuv(vmg_cast(SvRV(sv), vmg_wizard_validate(wiz), args, i));
- SvREFCNT_dec(args);
- RETVAL = ret;
+ RETVAL = newSVuv(vmg_cast(SvRV(sv), vmg_wizard_validate(wiz), args, i));
 OUTPUT:
  RETVAL
 

Modified: trunk/libvariable-magic-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/README?rev=50435&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/README (original)
+++ trunk/libvariable-magic-perl/README Thu Jan  7 04:50:49 2010
@@ -2,7 +2,7 @@
     Variable::Magic - Associate user-defined magic to variables from Perl.
 
 VERSION
-    Version 0.39
+    Version 0.40
 
 SYNOPSIS
         use Variable::Magic qw/wizard cast VMG_OP_INFO_NAME/;
@@ -531,7 +531,7 @@
     <http://www.profvince.com/perl/cover/Variable-Magic>.
 
 COPYRIGHT & LICENSE
-    Copyright 2007-2009 Vincent Pit, all rights reserved.
+    Copyright 2007,2008,2009,2010 Vincent Pit, all rights reserved.
 
     This program is free software; you can redistribute it and/or modify it
     under the same terms as Perl itself.

Modified: trunk/libvariable-magic-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/debian/changelog?rev=50435&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/debian/changelog (original)
+++ trunk/libvariable-magic-perl/debian/changelog Thu Jan  7 04:50:49 2010
@@ -1,3 +1,10 @@
+libvariable-magic-perl (0.40-1) UNRELEASED; urgency=low
+
+  * New upstream release
+  * Update copyright information
+
+ -- Jonathan Yu <jawnsy at cpan.org>  Wed, 06 Jan 2010 23:52:23 -0500
+
 libvariable-magic-perl (0.39-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/libvariable-magic-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/debian/copyright?rev=50435&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/debian/copyright (original)
+++ trunk/libvariable-magic-perl/debian/copyright Thu Jan  7 04:50:49 2010
@@ -4,15 +4,15 @@
 Name: Variable-Magic
 
 Files: *
-Copyright: 2007-2009, Vincent Pit <perl at profvince.com>
+Copyright: 2007-2010, Vincent Pit <perl at profvince.com>
 License-Alias: Perl
 License: Artistic or GPL-1+
 
 Files: debian/*
-Copyright: 2009, Angel Abad (Ikusnet SLL) <angel at grupoikusnet.com>
+Copyright: 2009-2010, Jonathan Yu <jawnsy at cpan.org>
+ 2009, Angel Abad (Ikusnet SLL) <angel at grupoikusnet.com>
  2009, Ansgar Burchardt <ansgar at 43-1.org>
  2009, Antonio Radici <antonio at dyne.org>
- 2009, Jonathan Yu <frequency at cpan.org>
  2009, Nathan Handler <nhandler at ubuntu.com>
  2009, Ryan Niebur <ryanryan52 at gmail.com>
 License: Artistic or GPL-1+

Modified: trunk/libvariable-magic-perl/lib/Variable/Magic.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/lib/Variable/Magic.pm?rev=50435&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/lib/Variable/Magic.pm (original)
+++ trunk/libvariable-magic-perl/lib/Variable/Magic.pm Thu Jan  7 04:50:49 2010
@@ -13,13 +13,13 @@
 
 =head1 VERSION
 
-Version 0.39
+Version 0.40
 
 =cut
 
 our $VERSION;
 BEGIN {
- $VERSION = '0.39';
+ $VERSION = '0.40';
 }
 
 =head1 SYNOPSIS
@@ -623,7 +623,7 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2007-2009 Vincent Pit, all rights reserved.
+Copyright 2007,2008,2009,2010 Vincent Pit, all rights reserved.
 
 This program is free software; you can redistribute it and/or modify it
 under the same terms as Perl itself.

Modified: trunk/libvariable-magic-perl/ptable.h
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libvariable-magic-perl/ptable.h?rev=50435&op=diff
==============================================================================
--- trunk/libvariable-magic-perl/ptable.h (original)
+++ trunk/libvariable-magic-perl/ptable.h Thu Jan  7 04:50:49 2010
@@ -70,8 +70,8 @@
 #ifndef ptable
 typedef struct ptable {
  ptable_ent **ary;
- UV           max;
- UV           items;
+ size_t       max;
+ size_t       items;
 } ptable;
 #define ptable ptable
 #endif /* !ptable */
@@ -121,9 +121,9 @@
 STATIC void ptable_split(pPTBLMS_ ptable * const t) {
 #define ptable_split(T) ptable_split(aPTBLMS_ (T))
  ptable_ent **ary = t->ary;
- const UV oldsize = t->max + 1;
- UV newsize = oldsize * 2;
- UV i;
+ const size_t oldsize = t->max + 1;
+ size_t newsize = oldsize * 2;
+ size_t i;
 
  ary = PerlMemShared_realloc(ary, newsize * sizeof(*ary));
  Zero(&ary[oldsize], newsize - oldsize, sizeof(*ary));
@@ -156,7 +156,7 @@
   PTABLE_VAL_FREE(oldval);
   ent->val = val;
  } else if (val) {
-  const UV i = PTABLE_HASH(key) & t->max;
+  const size_t i = PTABLE_HASH(key) & t->max;
   ent = PerlMemShared_malloc(sizeof *ent);
   ent->key  = key;
   ent->val  = val;
@@ -173,7 +173,7 @@
 #define ptable_walk(T, CB, UD) ptable_walk(aTHX_ (T), (CB), (UD))
  if (t && t->items) {
   register ptable_ent ** const array = t->ary;
-  UV i = t->max;
+  size_t i = t->max;
   do {
    ptable_ent *entry;
    for (entry = array[i]; entry; entry = entry->next)
@@ -186,7 +186,7 @@
 STATIC void PTABLE_PREFIX(_clear)(pPTBL_ ptable * const t) {
  if (t && t->items) {
   register ptable_ent ** const array = t->ary;
-  UV i = t->max;
+  size_t i = t->max;
 
   do {
    ptable_ent *entry = array[i];




More information about the Pkg-perl-cvs-commits mailing list