o xgettext now assumes source code for Python 3 rather than Python 2.
This affects the interpretation of escape sequences in string literals.
o xgettext now recognizes the f-string syntax.
+ - Scheme: xgettext now supports the option '-L Guile' as an alternative to
+ '-L Scheme'. They are nearly equivalent. They differ in the interpretation
+ of escape sequences in string literals: While 'xgettext -L Scheme' assumes
+ the R6RS and R7RS syntax of string literals, 'xgettext -L Guile' assumes
+ the syntax of string literals understood by Guile 2.x and 3.0 (without
+ command-line option '--r6rs' or '--r7rs', and before a '#!r6rs' directive
+ is seen).
- Java: Improved recognition of format strings when the String.formatted
method is used.
- Vala: Improved recognition of format strings when the string.printf method
@c This file is part of the GNU gettext manual.
-@c Copyright (C) 1995-2020 Free Software Foundation, Inc.
+@c Copyright (C) 1995-2024 Free Software Foundation, Inc.
@c See the file gettext.texi for copying conditions.
@node Scheme
@subsection GNU guile - Scheme
@cindex Scheme
+@cindex Guile
@cindex guile
@table @asis
use
@item Extractor
-@code{xgettext -k_}
+@code{xgettext -L Guile -k_}
+
+@cindex Scheme
+@cindex Guile
+@samp{xgettext -L Scheme} and @samp{xgettext -L Guile} are nearly equivalent.
+They differ in the interpretation of escape sequences in string literals:
+While @samp{xgettext -L Scheme} assumes the
+@uref{https://www.r6rs.org/,,R6RS} and
+@uref{https://standards.scheme.org/corrected-r7rs/r7rs.html,,R7RS}
+syntax of string literals,
+@samp{xgettext -L Guile} assumes the syntax of string literals
+understood by Guile 2.x and 3.0
+(without command-line option @code{--r6rs} or @code{--r7rs},
+and before a @code{#!r6rs} directive is seen).
+After a @code{#!r6rs} directive,
+there is no difference any more
+between @samp{xgettext -L Scheme} and @samp{xgettext -L Guile}
+for the rest of the file.
@item Formatting with positions
@c @code{format "~1@@*~D ~0@@*~D~2@@*"}, requires @code{(use-modules (ice-9 format))}
@c This file is part of the GNU gettext manual.
-@c Copyright (C) 1995-2023 Free Software Foundation, Inc.
+@c Copyright (C) 1995-2024 Free Software Foundation, Inc.
@c See the file gettext.texi for copying conditions.
@pindex xgettext
Specifies the language of the input files. The supported languages
are @code{C}, @code{C++}, @code{ObjectiveC}, @code{PO}, @code{Shell},
@code{Python}, @code{Lisp}, @code{EmacsLisp}, @code{librep}, @code{Scheme},
+@code{Guile},
@code{Smalltalk}, @code{Java}, @code{JavaProperties}, @code{C#}, @code{awk},
@code{YCP}, @code{Tcl}, @code{Perl}, @code{PHP}, @code{Ruby},
@code{GCC-source}, @code{NXStringTable}, @code{RST}, @code{RSJ}, @code{Glade},
For librep: @code{_}.
@item
-For Scheme: @code{gettext}, @code{ngettext:1,2}, @code{gettext-noop}.
+For Scheme and Guile: @code{gettext}, @code{ngettext:1,2}, @code{gettext-noop}.
@item
For Java: @code{GettextResource.gettext:2},
lead to a crash at runtime.
@*
This option has an effect with most languages, namely C, C++, ObjectiveC,
-Shell, Python, Lisp, EmacsLisp, librep, Scheme, Java, C#, awk, YCP, Tcl, Perl, PHP,
-GCC-source, Lua, JavaScript, Vala.
+Shell, Python, Lisp, EmacsLisp, librep, Scheme, Guile, Java, C#, awk,
+YCP, Tcl, Perl, PHP, GCC-source, Lua, JavaScript, Vala.
@item -T
@itemx --trigraphs
#define _(s) gettext(s)
-/* The Scheme syntax is described in R5RS. It is implemented in
- guile-2.0.0/libguile/read.c.
+/* The Scheme syntax is described in R5RS and following standards:
+ - R5RS: https://conservatory.scheme.org/schemers/Documents/Standards/R5RS/HTML/
+ - R6RS: https://www.r6rs.org/
+ - R7RS: https://standards.scheme.org/corrected-r7rs/r7rs.html
+
+ It is implemented in guile-3.0.10/libguile/read.c.
Since we are interested only in strings and in forms similar to
(gettext msgid ...)
or (ngettext msgid msgid_plural ...)
/* ========================== Reading of tokens. ========================== */
+/* True to follow what Guile does (before a '#!r6rs' directive is seen).
+ False to follow R6RS and R7RS. */
+static bool follow_guile;
+
/* A token consists of a sequence of characters. */
struct token
{
}
-void
-extract_scheme (FILE *f,
- const char *real_filename, const char *logical_filename,
- flag_context_list_table_ty *flag_table,
- msgdomain_list_ty *mdlp)
+static void
+extract_whole_file (FILE *f,
+ const char *real_filename, const char *logical_filename,
+ flag_context_list_table_ty *flag_table,
+ msgdomain_list_ty *mdlp)
{
mlp = mdlp->item[0]->messages;
logical_file_name = NULL;
line_number = 0;
}
+
+void
+extract_scheme (FILE *f,
+ const char *real_filename, const char *logical_filename,
+ flag_context_list_table_ty *flag_table,
+ msgdomain_list_ty *mdlp)
+{
+ follow_guile = false;
+ extract_whole_file (f, real_filename, logical_filename, flag_table, mdlp);
+}
+
+void
+extract_guile (FILE *f,
+ const char *real_filename, const char *logical_filename,
+ flag_context_list_table_ty *flag_table,
+ msgdomain_list_ty *mdlp)
+{
+ follow_guile = true;
+ extract_whole_file (f, real_filename, logical_filename, flag_table, mdlp);
+}
/* xgettext Scheme backend.
- Copyright (C) 2004, 2006, 2014, 2018, 2020 Free Software Foundation, Inc.
+ Copyright (C) 2004-2024 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2004.
This program is free software: you can redistribute it and/or modify
#define EXTENSIONS_SCHEME \
- { "scm", "Scheme" }, \
+ { "scm", "Guile" }, \
#define SCANNERS_SCHEME \
{ "Scheme", extract_scheme, NULL, \
&flag_table_scheme, &formatstring_scheme, NULL }, \
+ { "Guile", extract_guile, NULL, \
+ &flag_table_scheme, &formatstring_scheme, NULL }, \
/* Scan a Scheme file and add its translatable strings to mdlp. */
extern void extract_scheme (FILE *fp, const char *real_filename,
flag_context_list_table_ty *flag_table,
msgdomain_list_ty *mdlp);
+/* Scan a Guile file and add its translatable strings to mdlp. */
+extern void extract_guile (FILE *fp, const char *real_filename,
+ const char *logical_filename,
+ flag_context_list_table_ty *flag_table,
+ msgdomain_list_ty *mdlp);
+
/* Handling of options specific to this language. */
printf (_("\
-L, --language=NAME recognise the specified language\n\
(C, C++, ObjectiveC, PO, Shell, Python, Lisp,\n\
- EmacsLisp, librep, Scheme, Smalltalk, Java,\n\
- JavaProperties, C#, awk, YCP, Tcl, Perl, PHP,\n\
- Ruby, GCC-source, NXStringTable, RST, RSJ,\n\
+ EmacsLisp, librep, Scheme, Guile, Smalltalk,\n\
+ Java, JavaProperties, C#, awk, YCP, Tcl, Perl,\n\
+ PHP, Ruby, GCC-source, NXStringTable, RST, RSJ,\n\
Glade, Lua, JavaScript, Vala, Desktop)\n"));
printf (_("\
-C, --c++ shorthand for --language=C++\n"));