Hello Bruno,
Santiago,

        I am not sure I should reopen or if reply-all as I am doing now is the 
right
        thing to do, please inform me if you prefer a new bug report...

Whereas the patch you sent - here below - did solve the problem I originally
submitted, it still does not handle properly all modes of commenting code in 
scheme.
The following 2 other ways fail:

        #| ... |#       [and nested 'friends']
        #;

Here is a modified hello.scm to help you as much as I can. I was actually happy
since I so far only used #! !# and ; to comment my code, but after some talking 
on
guile iirc, others did ask, then I tried and found out ...

I am not sure if xgettext uses libguile/read.c or not, but in case it does, 
please
note that I did see your bug report and Andy's correction and I did a git pull 
to
get the very latest guile  [guile (GNU Guile) 2.0.2.59-eddd8 as of
yesterday] before to try xgettext on the attached hello.scm

Many thanks again,
David

;; --

> 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
> > #!@GUILE@ -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  <br...@clisp.org>
> 
>       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 <da...@altosw.be>
>       via Santiago Vila <sanv...@unex.es>.
> 
> --- 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 <br...@clisp.org>, 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;
>                  }
#!@GUILE@ -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))
#;(format #t (_ "This program is not ~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")
  (+ #| (_ "this is third") #| (_ " and fourth") |# (_ " should not either") |# 2))

#|
(_ "this string should not be extracted either")
|#


(display (_ "let's see: xgettext 3"))

Reply via email to