From: Bruno Haible Date: Tue, 4 Oct 2011 22:06:39 +0000 (+0200) Subject: xgettext for Scheme: Understand guile 2.0 comment syntax, part 2. X-Git-Tag: v0.18.2~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78b364a89ad4f8754974eb97872f32dabaa5d85c;p=thirdparty%2Fgettext.git xgettext for Scheme: Understand guile 2.0 comment syntax, part 2. --- diff --git a/NEWS b/NEWS index 9c85882f8..515b4b53e 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ Version 0.18.2 - July 2010 +* xgettext now understands the block comment syntax of Guile 2.0. + * libgettextpo library: - The initial msgstr of a new message is now "", not NULL. - Bug fixes in the functions po_message_is_range, po_file_check_all, diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 8392394b6..e2ed7bb52 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,9 @@ +2011-10-04 Bruno Haible + + xgettext for Scheme: Understand guile 2.0 comment syntax, part 2. + * x-scheme.c (read_object): Extract and don't ignore block comments. + Understand the #|...|# syntax of SRFI-30. (Code copied from x-lisp.c.) + 2011-10-04 Bruno Haible xgettext for Scheme: Understand guile 2.0 comment syntax, part 1. diff --git a/gettext-tools/src/x-scheme.c b/gettext-tools/src/x-scheme.c index 3b7beeb2d..1ddcb2db1 100644 --- a/gettext-tools/src/x-scheme.c +++ b/gettext-tools/src/x-scheme.c @@ -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 '#! ... !#'. + - Comment syntax: ';' and '#! ... !#' and '#| ... |#' (may be nested). - String syntax: "..." with single escapes. @@ -935,21 +935,120 @@ read_object (struct object *op, flag_context_ty outer_context) } case '!': - /* Block comment '#! ... !#'. We don't extract it - because it's only used to introduce scripts on Unix. */ + /* Block comment '#! ... !#'. See + . */ { - int last = 0; + int c; + comment_start (); + c = do_getc (); for (;;) { - c = do_getc (); if (c == EOF) - /* EOF is not allowed here. But be tolerant. */ break; - if (last == '!' && c == '#') + if (c == '!') + { + c = do_getc (); + if (c == EOF) + break; + if (c == '#') + { + comment_line_end (0); + break; + } + else + comment_add ('!'); + } + else + { + /* We skip all leading white space. */ + if (!(buflen == 0 && (c == ' ' || c == '\t'))) + comment_add (c); + if (c == '\n') + { + comment_line_end (1); + comment_start (); + } + c = do_getc (); + } + } + if (c == EOF) + { + /* EOF not allowed here. But be tolerant. */ + op->type = t_eof; + return; + } + last_comment_line = line_number; + continue; + } + + case '|': + /* Block comment '#| ... |#'. See + + and . */ + { + int depth = 0; + int c; + + comment_start (); + c = do_getc (); + for (;;) + { + if (c == EOF) break; - last = c; + if (c == '|') + { + c = do_getc (); + if (c == EOF) + break; + if (c == '#') + { + if (depth == 0) + { + comment_line_end (0); + break; + } + depth--; + comment_add ('|'); + comment_add ('#'); + c = do_getc (); + } + else + comment_add ('|'); + } + else if (c == '#') + { + c = do_getc (); + if (c == EOF) + break; + comment_add ('#'); + if (c == '|') + { + depth++; + comment_add ('|'); + c = do_getc (); + } + } + else + { + /* We skip all leading white space. */ + if (!(buflen == 0 && (c == ' ' || c == '\t'))) + comment_add (c); + if (c == '\n') + { + comment_line_end (1); + comment_start (); + } + c = do_getc (); + } + } + if (c == EOF) + { + /* EOF not allowed here. But be tolerant. */ + op->type = t_eof; + return; } + last_comment_line = line_number; continue; }