r42066 - in /branches/upstream/libdevel-declare-perl/current: Changes Declare.xs MANIFEST META.yml Makefile.PL lib/Devel/Declare.pm stolen_chunk_of_toke.c t/no-bareword.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Tue Aug 18 16:55:46 UTC 2009


Author: ansgar-guest
Date: Tue Aug 18 16:55:40 2009
New Revision: 42066

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=42066
Log:
[svn-upgrade] Integrating new upstream version, libdevel-declare-perl (0.005011)

Added:
    branches/upstream/libdevel-declare-perl/current/t/no-bareword.t
Modified:
    branches/upstream/libdevel-declare-perl/current/Changes
    branches/upstream/libdevel-declare-perl/current/Declare.xs
    branches/upstream/libdevel-declare-perl/current/MANIFEST
    branches/upstream/libdevel-declare-perl/current/META.yml
    branches/upstream/libdevel-declare-perl/current/Makefile.PL
    branches/upstream/libdevel-declare-perl/current/lib/Devel/Declare.pm
    branches/upstream/libdevel-declare-perl/current/stolen_chunk_of_toke.c

Modified: branches/upstream/libdevel-declare-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdevel-declare-perl/current/Changes?rev=42066&op=diff
==============================================================================
--- branches/upstream/libdevel-declare-perl/current/Changes (original)
+++ branches/upstream/libdevel-declare-perl/current/Changes Tue Aug 18 16:55:40 2009
@@ -1,4 +1,10 @@
 Changes for Devel-Declare
+
+0.005011 - 14 Aug 2009
+  - Add tests for not interpreting various things as barewords when they
+    aren't.
+  - Depend on a Test::More with done_testing support.
+  - Don't invoke the const callback for a keyword followed by a fat comma.
 
 0.005010 - 11 Aug 2009
   - Don't invoke the linestr callback if we found a keyword and the bufptr

Modified: branches/upstream/libdevel-declare-perl/current/Declare.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdevel-declare-perl/current/Declare.xs?rev=42066&op=diff
==============================================================================
--- branches/upstream/libdevel-declare-perl/current/Declare.xs (original)
+++ branches/upstream/libdevel-declare-perl/current/Declare.xs Tue Aug 18 16:55:40 2009
@@ -220,7 +220,7 @@
 
 int dd_toke_skipspace(pTHX_ int offset) {
   char* base_s = SvPVX(PL_linestr) + offset;
-  char* s = skipspace(base_s);
+  char* s = skipspace_force(base_s);
   return s - base_s;
 }
 
@@ -381,8 +381,34 @@
       break;
   }
 
-  if (strnEQ (PL_bufptr, "->", 2)) {
-    return o;
+  if (strnEQ(PL_bufptr, "->", 2)) {
+    return o;
+  }
+
+  {
+    char buf[256];
+    STRLEN len;
+    char *s = PL_bufptr;
+    STRLEN old_offset = PL_bufptr - SvPVX(PL_linestr);
+
+    s = scan_word(s, buf, sizeof buf, FALSE, &len);
+    if (strnEQ(buf, name, len)) {
+      char *d;
+      SV *inject = newSVpvn(SvPVX(PL_linestr), PL_bufptr - SvPVX(PL_linestr));
+      sv_catpvn(inject, buf, len);
+
+      d = peekspace(s);
+      sv_catpvn(inject, s, d - s);
+
+      if ((PL_bufend - d) >= 2 && strnEQ(d, "=>", 2)) {
+        return o;
+      }
+
+      sv_catpv(inject, d);
+      dd_set_linestr(aTHX_ SvPV_nolen(inject));
+      PL_bufptr = SvPVX(PL_linestr) + old_offset;
+      SvREFCNT_dec (inject);
+    }
   }
 
   dd_linestr_callback(aTHX_ "const", name);

Modified: branches/upstream/libdevel-declare-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdevel-declare-perl/current/MANIFEST?rev=42066&op=diff
==============================================================================
--- branches/upstream/libdevel-declare-perl/current/MANIFEST (original)
+++ branches/upstream/libdevel-declare-perl/current/MANIFEST Tue Aug 18 16:55:40 2009
@@ -29,6 +29,7 @@
 t/method.t
 t/multiline-proto.t
 t/new.t
+t/no-bareword.t
 t/pack.t
 t/padstuff.t
 t/proto.t

Modified: branches/upstream/libdevel-declare-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdevel-declare-perl/current/META.yml?rev=42066&op=diff
==============================================================================
--- branches/upstream/libdevel-declare-perl/current/META.yml (original)
+++ branches/upstream/libdevel-declare-perl/current/META.yml Tue Aug 18 16:55:40 2009
@@ -5,6 +5,7 @@
 build_requires:
   B::Hooks::OP::Check: 0.18
   ExtUtils::MakeMaker: 6.42
+  Test::More: 0.88
 configure_requires:
   B::Hooks::OP::Check: 0.18
   ExtUtils::Depends: 0.302
@@ -29,4 +30,4 @@
 resources:
   license: http://dev.perl.org/licenses/
   repository: git://github.com/rafl/devel-declare.git
-version: 0.005010
+version: 0.005011

Modified: branches/upstream/libdevel-declare-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdevel-declare-perl/current/Makefile.PL?rev=42066&op=diff
==============================================================================
--- branches/upstream/libdevel-declare-perl/current/Makefile.PL (original)
+++ branches/upstream/libdevel-declare-perl/current/Makefile.PL Tue Aug 18 16:55:40 2009
@@ -20,6 +20,8 @@
 # minimum version that depends on ExtUtils::Depends 0.302
 configure_requires 'B::Hooks::OP::Check' => '0.18';
 
+test_requires 'Test::More' => '0.88';
+
 repository 'git://github.com/rafl/devel-declare.git';
 
 postamble(<<'EOM');

Modified: branches/upstream/libdevel-declare-perl/current/lib/Devel/Declare.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdevel-declare-perl/current/lib/Devel/Declare.pm?rev=42066&op=diff
==============================================================================
--- branches/upstream/libdevel-declare-perl/current/lib/Devel/Declare.pm (original)
+++ branches/upstream/libdevel-declare-perl/current/lib/Devel/Declare.pm Tue Aug 18 16:55:40 2009
@@ -4,7 +4,7 @@
 use warnings;
 use 5.008001;
 
-our $VERSION = '0.005010';
+our $VERSION = '0.005011';
 
 use constant DECLARE_NAME => 1;
 use constant DECLARE_PROTO => 2;

Modified: branches/upstream/libdevel-declare-perl/current/stolen_chunk_of_toke.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdevel-declare-perl/current/stolen_chunk_of_toke.c?rev=42066&op=diff
==============================================================================
--- branches/upstream/libdevel-declare-perl/current/stolen_chunk_of_toke.c (original)
+++ branches/upstream/libdevel-declare-perl/current/stolen_chunk_of_toke.c Tue Aug 18 16:55:40 2009
@@ -19,7 +19,9 @@
 
 /* the following #defines are stolen from assorted headers, not toke.c (mst) */
 
-#define skipspace(a)            S_skipspace(aTHX_ a)
+#define skipspace(a)            S_skipspace(aTHX_ a, 0)
+#define peekspace(a)            S_skipspace(aTHX_ a, 1)
+#define skipspace_force(a)      S_skipspace(aTHX_ a, 2)
 #define incline(a)              S_incline(aTHX_ a)
 #define filter_gets(a,b,c)      S_filter_gets(aTHX_ a,b,c)
 #define scan_str(a,b,c)         S_scan_str(aTHX_ a,b,c)
@@ -27,7 +29,7 @@
 #define scan_ident(a,b,c,d,e)   S_scan_ident(aTHX_ a,b,c,d,e)
 
 STATIC void     S_incline(pTHX_ char *s);
-STATIC char*    S_skipspace(pTHX_ char *s);
+STATIC char*    S_skipspace(pTHX_ char *s, int incline);
 STATIC char *   S_filter_gets(pTHX_ SV *sv, PerlIO *fp, STRLEN append);
 STATIC char*    S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims);
 STATIC char*    S_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STRLEN *slp);
@@ -270,7 +272,7 @@
  */
 
 STATIC char *
-S_skipspace(pTHX_ register char *s)
+S_skipspace(pTHX_ register char *s, int incline)
 {
     if (PL_lex_formbrack && PL_lex_brackets <= PL_lex_formbrack) {
 	while (s < PL_bufend && SPACE_OR_TAB(*s))
@@ -282,7 +284,7 @@
 	SSize_t oldprevlen, oldoldprevlen;
 	SSize_t oldloplen = 0, oldunilen = 0;
 	while (s < PL_bufend && isSPACE(*s)) {
-	    if (*s++ == '\n' && PL_in_eval && !PL_rsfp)
+	    if (*s++ == '\n' && ((incline == 2) || PL_in_eval && !PL_rsfp && !incline))
 		incline(s);
 	}
 
@@ -292,11 +294,19 @@
 		s++;
 	    if (s < PL_bufend) {
 		s++;
-		if (PL_in_eval && !PL_rsfp) {
+		if (PL_in_eval && !PL_rsfp && !incline) {
 		    incline(s);
 		    continue;
 		}
 	    }
+	}
+
+	/* also skip leading whitespace on the beginning of a line before deciding
+	 * whether or not to recharge the linestr. --rafl
+	 */
+	while (s < PL_bufend && isSPACE(*s)) {
+		if (*s++ == '\n' && PL_in_eval && !PL_rsfp && !incline)
+			incline(s);
 	}
 
 	/* only continue to recharge the buffer if we're at the end
@@ -368,7 +378,8 @@
 	    PL_last_uni = s + oldunilen;
 	if (PL_last_lop)
 	    PL_last_lop = s + oldloplen;
-	incline(s);
+	if (!incline)
+		incline(s);
 
 	/* debugger active and we're not compiling the debugger code,
 	 * so store the line into the debugger's array of lines

Added: branches/upstream/libdevel-declare-perl/current/t/no-bareword.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdevel-declare-perl/current/t/no-bareword.t?rev=42066&op=file
==============================================================================
--- branches/upstream/libdevel-declare-perl/current/t/no-bareword.t (added)
+++ branches/upstream/libdevel-declare-perl/current/t/no-bareword.t Tue Aug 18 16:55:40 2009
@@ -1,0 +1,34 @@
+use strict;
+use warnings;
+use Test::More;
+
+our $i;
+BEGIN { $i = 0 };
+
+sub method { }
+BEGIN {
+        require Devel::Declare;
+        Devel::Declare->setup_for(
+                __PACKAGE__,
+                { "method" => { const => sub { $i++ } } },
+        );
+}
+
+{
+    package Foo;
+    sub method { }
+}
+
+Foo->method;
+BEGIN { is($i, 0) }
+
+my @foo = (
+    method
+    =>
+    123
+);
+BEGIN { is($i, 0) }
+
+is_deeply(\@foo, ['method', '123']);
+
+done_testing;




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