bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xgettext parse of new perl // operator


From: Bruno Haible
Subject: Re: xgettext parse of new perl // operator
Date: Sat, 6 Jun 2009 15:23:15 +0200
User-agent: KMail/1.9.9

Kevin Ryde wrote:
> I mentioned this in passing to Guido the other day.  Here's an actual
> bug report.
> 
> A file foo.pl containing
> 
>     print gettext('hello');
>     $foo // 'undef';
>     print gettext('world');
> 
> processed as
> 
>     xgettext --output=- --language=Perl foo.pl
> 
> prints only the first message
> 
>     #: foo.pl:1
>     msgid "hello"
>     msgstr ""
> 
> where I hoped it would give the "world" one too.
> 
> It might be related to the // defined-or operator, new in perl 5.10.
> If it's instead a plain || or similar then the "world" string is
> printed.

Thanks for the report. This patch fixes it.


2009-06-06  Bruno Haible  <address@hidden>

        * x-perl.c (x_perl_prelex): Recognize the perl 5.10 operator '//'.
        Reported by Kevin Ryde <address@hidden>.

Index: gettext-tools/src/x-perl.c
===================================================================
RCS file: /sources/gettext/gettext/gettext-tools/src/x-perl.c,v
retrieving revision 1.53
diff -c -3 -r1.53 x-perl.c
*** gettext-tools/src/x-perl.c  16 May 2009 21:09:41 -0000      1.53
--- gettext-tools/src/x-perl.c  6 Jun 2009 13:19:24 -0000
***************
*** 44,50 ****
  /* The Perl syntax is defined in perlsyn.pod.  Try the command
     "man perlsyn" or "perldoc perlsyn".
     Also, the syntax after the 'sub' keyword is specified in perlsub.pod.
!    Try the command "man perlsub" or "perldoc perlsub".  */
  
  #define DEBUG_PERL 0
  
--- 44,52 ----
  /* The Perl syntax is defined in perlsyn.pod.  Try the command
     "man perlsyn" or "perldoc perlsyn".
     Also, the syntax after the 'sub' keyword is specified in perlsub.pod.
!    Try the command "man perlsub" or "perldoc perlsub".
!    Perl 5.10 has new operators '//' and '//=', see
!    <http://perldoc.perl.org/perldelta.html#Defined-or-operator>.  */
  
  #define DEBUG_PERL 0
  
***************
*** 2524,2535 ****
              phase1_ungetc (c);
              return;
            }
          /* FALLTHROUGH */
  
        default:
          /* We could carefully recognize each of the 2 and 3 character
!            operators, but it is not necessary, as we only need to recognize
!            gettext invocations.  Don't bother.  */
          tp->type = token_type_other;
          prefer_division_over_regexp = false;
          return;
--- 2526,2545 ----
              phase1_ungetc (c);
              return;
            }
+         /* Recognize operator '//'.  */
+         if (c == '/')
+           {
+             c = phase1_getc ();
+             if (c != '/')
+               phase1_ungetc (c);
+           }
          /* FALLTHROUGH */
  
        default:
          /* We could carefully recognize each of the 2 and 3 character
!            operators, but it is not necessary, except for the '//' operator,
!            as we only need to recognize gettext invocations.  Don't
!            bother.  */
          tp->type = token_type_other;
          prefer_division_over_regexp = false;
          return;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]