[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH]: Allowing embedded newlines in strings.
From: |
Jan Nieuwenhuizen |
Subject: |
[PATCH]: Allowing embedded newlines in strings. |
Date: |
Thu, 13 Jun 2002 18:24:43 +0200 |
User-agent: |
Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-debian-linux-gnu) |
Hi,
Below is a patch that optionally allows xgettext to grok strings that
include raw (unescaped) newlines. Although this is strictly not
allowed for C/C++, gcc/g++ groks these strings, and we find them
especially useful (in LilyPond) for mimicking in-line literate
programming.
If there's anything else I can do to get this merged, please tell me.
Greetings,
Jan.
diff -purN --exclude=*~ --exclude=*.info* --exclude=*.html
../gettext-0.11.2/doc/ChangeLog ./doc/ChangeLog
--- ../gettext-0.11.2/doc/ChangeLog Wed Apr 24 19:50:31 2002
+++ ./doc/ChangeLog Thu Jun 13 18:06:44 2002
@@ -1,3 +1,8 @@
+2002-06-13 Jan Nieuwenhuizen <address@hidden>
+
+ * xgettext.texi: Document --embedded-newlines and
+ --no-embedded-newlines options.
+
2002-04-24 Bruno Haible <address@hidden>
* gettext-0.11.2 released.
diff -purN --exclude=*~ --exclude=*.info* --exclude=*.html
../gettext-0.11.2/doc/xgettext.texi ./doc/xgettext.texi
--- ../gettext-0.11.2/doc/xgettext.texi Tue Apr 23 13:33:34 2002
+++ ./doc/xgettext.texi Thu Jun 13 18:04:37 2002
@@ -107,6 +107,18 @@ POT file.
Place comment block with @var{tag} (or those preceding keyword lines)
in output file.
address@hidden -z
address@hidden --no-embedded-newlines
address@hidden address@hidden, @code{xgettext} option}
address@hidden address@hidden, @code{xgettext} option}
+Do not allow raw newlines embedded in strings.
+
address@hidden -Z
address@hidden --embedded-newlines
address@hidden address@hidden, @code{xgettext} option}
address@hidden address@hidden, @code{xgettext} option}
+Allow raw newlines embedded in strings.
+
@end table
@subsection Language=C/C++ specific options
diff -purN --exclude=*~ --exclude=*.info* --exclude=*.html
../gettext-0.11.2/src/ChangeLog ./src/ChangeLog
--- ../gettext-0.11.2/src/ChangeLog Wed Apr 24 19:50:31 2002
+++ ./src/ChangeLog Thu Jun 13 17:53:21 2002
@@ -1,3 +1,16 @@
+2002-06-13 Jan Nieuwenhuizen <address@hidden>
+
+ * x-python.c (phase7_getuc): Handle --embedded-newlines option.
+
+ * x-c.c (phase5_get): Handle --embedded-newlines option.
+
+ * xgettext.c (embedded_newlines): New variable.
+ (long_options): Add --embedded-newlines, --no-embedded-newlines
+ options.
+ (main): Parse --embedded-newlines, --no-embedded-newlines options.
+
+ * xgettext.h (embedded_newlines): New declaration.
+
2002-04-24 Bruno Haible <address@hidden>
* gettext-0.11.2 released.
diff -purN --exclude=*~ --exclude=*.info* --exclude=*.html
../gettext-0.11.2/src/x-c.c ./src/x-c.c
--- ../gettext-0.11.2/src/x-c.c Tue Feb 12 13:30:34 2002
+++ ./src/x-c.c Thu Jun 13 17:33:42 2002
@@ -971,12 +971,17 @@ phase5_get (tp)
c = phase7_getc ();
if (c == P7_NEWLINE)
{
- error_with_progname = false;
- error (0, 0, _("%s:%d: warning: unterminated string literal"),
- logical_file_name, line_number - 1);
- error_with_progname = true;
- phase7_ungetc ('\n');
- break;
+ if (embedded_newlines)
+ c = '\n';
+ else
+ {
+ error_with_progname = false;
+ error (0, 0, _("%s:%d: warning: unterminated string literal"),
+ logical_file_name, line_number - 1);
+ error_with_progname = true;
+ phase7_ungetc ('\n');
+ break;
+ }
}
if (c == EOF || c == P7_QUOTES)
break;
diff -purN --exclude=*~ --exclude=*.info* --exclude=*.html
../gettext-0.11.2/src/x-python.c ./src/x-python.c
--- ../gettext-0.11.2/src/x-python.c Mon Mar 11 13:17:55 2002
+++ ./src/x-python.c Thu Jun 13 18:20:31 2002
@@ -394,6 +394,8 @@ phase7_getuc (quote_char, triple, interp
*backslash_counter = 0;
return '\n';
}
+ if (embedded_newlines)
+ return '\n';
phase1_ungetc (c);
error_with_progname = false;
error (0, 0, _("%s:%d: warning: unterminated string"),
diff -purN --exclude=*~ --exclude=*.info* --exclude=*.html
../gettext-0.11.2/src/xgettext.c ./src/xgettext.c
--- ../gettext-0.11.2/src/xgettext.c Tue Apr 23 13:33:35 2002
+++ ./src/xgettext.c Thu Jun 13 17:56:00 2002
@@ -81,6 +81,9 @@ static char *comment_tag;
equality. */
bool substring_match;
+/* If true, grok newline characters embedded in a string. */
+bool embedded_newlines;
+
/* Name of default domain file. If not set defaults to messages.po. */
static const char *default_domain;
@@ -119,6 +122,7 @@ static const struct option long_options[
{ "debug", no_argument, &do_debug, 1 },
{ "default-domain", required_argument, NULL, 'd' },
{ "directory", required_argument, NULL, 'D' },
+ { "embedded-newlines", no_argument, NULL, 'Z' },
{ "escape", no_argument, NULL, 'E' },
{ "exclude-file", required_argument, NULL, 'x' },
{ "extract-all", no_argument, NULL, 'a' },
@@ -133,6 +137,7 @@ static const struct option long_options[
{ "language", required_argument, NULL, 'L' },
{ "msgstr-prefix", optional_argument, NULL, 'm' },
{ "msgstr-suffix", optional_argument, NULL, 'M' },
+ { "no-embedded-newlines", no_argument, NULL, 'z' },
{ "no-escape", no_argument, NULL, 'e' },
{ "no-location", no_argument, &line_comment, 0 },
{ "no-wrap", no_argument, NULL, CHAR_MAX + 3 },
@@ -220,7 +225,7 @@ main (argc, argv)
default_domain = MESSAGE_DOMAIN_DEFAULT;
while ((optchar = getopt_long (argc, argv,
- "ac::Cd:D:eEf:Fhijk::l:L:m::M::no:p:sTVw:x:",
+ "ac::Cd:D:eEf:Fhijk::l:L:m::M::no:p:sTVw:x:zZ",
long_options, NULL)) != EOF)
switch (optchar)
{
@@ -356,6 +361,12 @@ main (argc, argv)
case 'x':
read_exclusion_file (optarg);
break;
+ case 'Z':
+ embedded_newlines = true;
+ break;
+ case 'z':
+ embedded_newlines = false;
+ break;
case CHAR_MAX + 1: /* --copyright-holder */
copyright_holder = optarg;
break;
@@ -582,6 +593,8 @@ Operation mode:\n\
-x, --exclude-file=FILE.po entries from FILE.po are not extracted\n\
-c, --add-comments[=TAG] place comment block with TAG (or those\n\
preceding keyword lines) in output file\n\
+ -z, --no-embedded-newlines forbid newlines embedded in strings
(default)\n\
+ -Z, --embedded-newlines allow newlines embedded in strings\n\
"));
printf ("\n");
/* xgettext: no-wrap */
diff -purN --exclude=*~ --exclude=*.info* --exclude=*.html
../gettext-0.11.2/src/xgettext.h ./src/xgettext.h
--- ../gettext-0.11.2/src/xgettext.h Wed Jan 30 14:46:48 2002
+++ ./src/xgettext.h Thu Jun 13 17:25:46 2002
@@ -33,6 +33,8 @@ extern int xgettext_omit_header;
extern bool substring_match;
+extern bool embedded_newlines;
+
/* Split keyword spec into keyword, argnum1, argnum2. */
extern void split_keywordspec PARAMS ((const char *spec, const char **endp,
int *argnum1p, int *argnum2p));
--
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien | http://www.lilypond.org
- [PATCH]: Allowing embedded newlines in strings.,
Jan Nieuwenhuizen <=