[Po4a-commits] "po4a po4a,1.68,1.69 changelog,1.178,1.179"
Nicolas FRANCOIS
nekral-guest at alioth.debian.org
Sat Mar 24 23:19:14 CET 2007
Update of /cvsroot/po4a/po4a
In directory alioth:/tmp/cvs-serv1109
Modified Files:
po4a changelog
Log Message:
Allow quoted arguments in options.
Index: po4a
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- po4a 24 Mar 2007 20:49:41 -0000 1.68
+++ po4a 24 Mar 2007 22:19:12 -0000 1.69
@@ -137,13 +137,14 @@
You can also specify options that will only apply to a specific language
by using the opt_I<lang> keyword.
-There are some known limitations: you can't specify an argument with a
-space or a double quote to a module option.
-
Here is an example:
[type:man] data-05/test2_man.1 $lang:tmp/test2_man.$lang.1 \
opt:"-k 75" opt_it:"-L UTF-8" opt_fr:-v
+Arguments may contain spaces if you use single quotes or escaped double
+quotes:
+ [po4a_alias:man] man opt:"-o \"mdoc=NAME,SEE ALSO\" -k 20"
+
If you want to specify the same options for many documents, you may want
to use an alias (see the B<Specifying aliases> section below).
@@ -671,11 +672,29 @@
die wrap_msg(gettext("po4a_paths not declared. Dunno where to find the pot and po files"))
unless (length $pot_filename);
+sub split_opts {
+ my $options = shift;
+ my @opts = ();
+ $options =~ s/\\"/"/g;
+ while (length $options) {
+ $options =~ s/^(["']) # A quote
+ ((?:\\.|(?!\1)[^\\])*) # quoted text
+ \1 # The same quote
+ |
+ ^((?:\\.|[^\\"'])*?) # unquoted word
+ ([ ]|$) # space is the separator
+ //xs; # extended regex
+ push @opts, (defined $1?$2:$3);
+ }
+
+ return @opts;
+}
+
if (defined $document{''}{"options"}
and defined $document{''}{"options"}{"global"}) {
# Merge the options with the ones specified in the configuration file
%po4a_opts = get_options(@ORIGINAL_ARGV,
- split(/ /, $document{''}{"options"}{"global"}));
+ split_opts($document{''}{"options"}{"global"}));
}
my %splitted_po; # po_files: '$lang','$master' => '$path'
@@ -745,7 +764,7 @@
my $options = $document{$master}{"options"}{"global"};
if (defined $options) {
%file_opts = get_options(@ORIGINAL_ARGV,
- split(/ /, $options));
+ split_opts($options));
}
my $doc=Locale::Po4a::Chooser::new($document{$master}{'format'},
%{$file_opts{"options"}});
@@ -972,7 +991,7 @@
if (defined $options) {
# also use the options provided on the command line
%file_opts = get_options(@ORIGINAL_ARGV,
- split(/ /, $options));
+ split_opts($options));
}
my $doc=Locale::Po4a::Chooser::new($document{$master}{'format'},
%{$file_opts{"options"}});
Index: changelog
===================================================================
RCS file: /cvsroot/po4a/po4a/changelog,v
retrieving revision 1.178
retrieving revision 1.179
diff -u -d -r1.178 -r1.179
--- changelog 24 Mar 2007 20:49:41 -0000 1.178
+++ changelog 24 Mar 2007 22:19:12 -0000 1.179
@@ -1,5 +1,10 @@
2007-03-24 Nicolas François <nicolas.francois at centraliens.net>
+ * po4a: Allow quoted arguments in options. This permits to use
+ spaces in arguments to modules options.
+
+2007-03-24 Nicolas François <nicolas.francois at centraliens.net>
+
* po4a: Fix a typo in the documentation and comments.
* po4a, lib/Locale/Po4a/Po.pm: Add options --msgid-bugs-address
and --copyright-holder. Similar to the xgettext options.
More information about the Po4a-commits
mailing list