[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gettext] Bug#641371: xgettext -k_ hello.scm fails if block-comm
From: |
Bruno Haible |
Subject: |
Re: [bug-gettext] Bug#641371: xgettext -k_ hello.scm fails if block-comment are used inside a function (fwd) |
Date: |
Tue, 4 Oct 2011 23:07:49 +0200 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
Hello,
David Pirotte wrote:
> I found that
> xgettext will properly work until it reaches a block-comment inside a
> scheme function [as opposed to a toplevel block-comment which xgettext
> appears to propely manage.
>
> On the modified hello.scm below, if you run:
>
> xgettext -k_ -o hello.pot hello.scm
>
> and cat hello.pot, you'll see that xgettext 'stopped' working properly
> after extracting "let's see: xgettext 1". In case you could not
> reproduce exactly, I'll also attach the hello.pot I got here.
>
> ;; hello.scm [modified] starts here
> address@hidden@ -s
> !#
> ;;; Example for use of GNU gettext.
> ;;; This file is in the public domain.
>
> ;;; Source code of the GNU guile program.
>
> (use-modules (ice-9 format))
>
> (catch #t (lambda () (setlocale LC_ALL "")) (lambda args #f))
> (textdomain "hello-guile")
> (bindtextdomain "hello-guile" "@localedir@")
> (define _ gettext)
>
> (display (_ "Hello, world!"))
> (newline)
> (format #t (_ "This program is running as process number ~D.") (getpid))
> (newline)
>
> #!
> this toplevel block-comment does seem to confuse ngettext
> (_ "this first string should not be extracted")
> !#
>
> (define (further-testing-xgettext)
> (_ "let's see: xgettext 1")
> #!
> then for some reason, i'v noticed that xgettext gets confused if
> block-comment is used inside a function, unlike @ toplevel
> (_ "this second string should not be extracted")
> !#
> (_ "let's see: xgettext 2"))
>
> (display (_ "let's see: xgettext 3"))
> ;; hello.scm [modified] ends here
Thank you. It is perfectly reproducible.
The point is that you are using a syntax which is valid in guile-2.0
but not in guile-1.6.4 or guile-1.7.1. In these older versions, the
!#
had to come on a line of its own, without spaces.
I'm applying this patch to teach xgettext the newer (relaxed)
syntax for the end of block comments.
2011-10-04 Bruno Haible <address@hidden>
xgettext for Scheme: Understand guile 2.0 comment syntax, part 1.
* x-scheme.c (read_object): Understand !# as a block comment terminator
even when not surrounded by newlines.
Reported by David Pirotte <address@hidden>
via Santiago Vila <address@hidden>.
--- gettext-tools/src/x-scheme.c.orig Tue Oct 4 22:58:49 2011
+++ gettext-tools/src/x-scheme.c Tue Oct 4 22:20:11 2011
@@ -1,5 +1,5 @@
/* xgettext Scheme backend.
- Copyright (C) 2004-2009 Free Software Foundation, Inc.
+ Copyright (C) 2004-2009, 2011 Free Software Foundation, Inc.
This file was written by Bruno Haible <address@hidden>, 2004-2005.
@@ -40,7 +40,7 @@
/* The Scheme syntax is described in R5RS. It is implemented in
- guile-1.6.4/libguile/read.c.
+ guile-2.0.0/libguile/read.c.
Since we are interested only in strings and in forms similar to
(gettext msgid ...)
or (ngettext msgid msgid_plural ...)
@@ -60,7 +60,7 @@
- The syntax code assigned to each character, and how tokens are built
up from characters (single escape, multiple escape etc.).
- - Comment syntax: ';' and '#! ... \n!#\n'.
+ - Comment syntax: ';' and '#! ... !#'.
- String syntax: "..." with single escapes.
@@ -935,12 +935,10 @@
}
case '!':
- /* Block comment '#! ... \n!#\n'. We don't extract it
+ /* Block comment '#! ... !#'. We don't extract it
because it's only used to introduce scripts on Unix. */
{
- int last1 = 0;
- int last2 = 0;
- int last3 = 0;
+ int last = 0;
for (;;)
{
@@ -948,12 +946,9 @@
if (c == EOF)
/* EOF is not allowed here. But be tolerant. */
break;
- if (last3 == '\n' && last2 == '!' && last1 == '#'
- && c == '\n')
+ if (last == '!' && c == '#')
break;
- last3 = last2;
- last2 = last1;
- last1 = c;
+ last = c;
}
continue;
}