Lines 48-68
use vars qw( $serial );
Link Here
|
48 |
|
48 |
|
49 |
############################################################################### |
49 |
############################################################################### |
50 |
|
50 |
|
51 |
sub FATAL_P () {'fatal-p'} |
51 |
sub FATAL_P {'fatal-p'} |
52 |
sub SYNTAXERROR_P () {'syntaxerror-p'} |
52 |
sub SYNTAXERROR_P {'syntaxerror-p'} |
53 |
|
53 |
|
54 |
sub FILENAME () {'input'} |
54 |
sub FILENAME {'input'} |
55 |
#sub HANDLE () {'handle'} |
55 |
#sub HANDLE {'handle'} |
56 |
|
56 |
|
57 |
#sub READAHEAD () {'readahead'} |
57 |
#sub READAHEAD {'readahead'} |
58 |
sub LINENUM_START () {'lc_0'} |
58 |
sub LINENUM_START {'lc_0'} |
59 |
sub LINENUM () {'lc'} |
59 |
sub LINENUM {'lc'} |
60 |
sub CDATA_MODE_P () {'cdata-mode-p'} |
60 |
sub CDATA_MODE_P {'cdata-mode-p'} |
61 |
sub CDATA_CLOSE () {'cdata-close'} |
61 |
sub CDATA_CLOSE {'cdata-close'} |
62 |
#sub PCDATA_MODE_P () {'pcdata-mode-p'} # additional submode for CDATA |
62 |
#sub PCDATA_MODE_P {'pcdata-mode-p'} # additional submode for CDATA |
63 |
sub JS_MODE_P () {'js-mode-p'} # cdata-mode-p must also be true |
63 |
sub JS_MODE_P {'js-mode-p'} # cdata-mode-p must also be true |
64 |
|
64 |
|
65 |
sub ALLOW_CFORMAT_P () {'allow-cformat-p'} |
65 |
sub ALLOW_CFORMAT_P {'allow-cformat-p'} |
66 |
|
66 |
|
67 |
sub new { |
67 |
sub new { |
68 |
shift; |
68 |
shift; |
Lines 137-146
BEGIN {
Link Here
|
137 |
# Perl quoting is really screwed up, but this common subexp is way too long |
137 |
# Perl quoting is really screwed up, but this common subexp is way too long |
138 |
$js_EscapeSequence = q{\\\\(?:['"\\\\bfnrt]|[^0-7xu]|[0-3]?[0-7]{1,2}|x[\da-fA-F]{2}|u[\da-fA-F]{4})}; |
138 |
$js_EscapeSequence = q{\\\\(?:['"\\\\bfnrt]|[^0-7xu]|[0-3]?[0-7]{1,2}|x[\da-fA-F]{2}|u[\da-fA-F]{4})}; |
139 |
} |
139 |
} |
140 |
sub parenleft () { '(' } |
140 |
sub parenleft { '(' } |
141 |
sub parenright () { ')' } |
141 |
sub parenright { ')' } |
142 |
|
142 |
|
143 |
sub _split_js ($) { |
143 |
sub _split_js { |
144 |
my ($s0) = @_; |
144 |
my ($s0) = @_; |
145 |
my @it = (); |
145 |
my @it = (); |
146 |
while (length $s0) { |
146 |
while (length $s0) { |
Lines 186-198
sub _split_js ($) {
Link Here
|
186 |
return @it; |
186 |
return @it; |
187 |
} |
187 |
} |
188 |
|
188 |
|
189 |
sub STATE_UNDERSCORE () { 1 } |
189 |
sub STATE_UNDERSCORE { 1 } |
190 |
sub STATE_PARENLEFT () { 2 } |
190 |
sub STATE_PARENLEFT { 2 } |
191 |
sub STATE_STRING_LITERAL () { 3 } |
191 |
sub STATE_STRING_LITERAL { 3 } |
192 |
|
192 |
|
193 |
# XXX This is a crazy hack. I don't want to write an ECMAScript parser. |
193 |
# XXX This is a crazy hack. I don't want to write an ECMAScript parser. |
194 |
# XXX A scanner is one thing; a parser another thing. |
194 |
# XXX A scanner is one thing; a parser another thing. |
195 |
sub _identify_js_translatables (@) { |
195 |
sub _identify_js_translatables { |
196 |
my @input = @_; |
196 |
my @input = @_; |
197 |
my @output = (); |
197 |
my @output = (); |
198 |
# We mark a JavaScript translatable string as in C, i.e., _("literal") |
198 |
# We mark a JavaScript translatable string as in C, i.e., _("literal") |
Lines 229-235
sub _identify_js_translatables (@) {
Link Here
|
229 |
|
229 |
|
230 |
############################################################################### |
230 |
############################################################################### |
231 |
|
231 |
|
232 |
sub string_canon ($) { |
232 |
sub string_canon ) { |
233 |
my $s = shift; |
233 |
my $s = shift; |
234 |
# Fold all whitespace into single blanks |
234 |
# Fold all whitespace into single blanks |
235 |
$s =~ s/\s+/ /g; |
235 |
$s =~ s/\s+/ /g; |
Lines 238-244
sub string_canon ($) {
Link Here
|
238 |
} |
238 |
} |
239 |
|
239 |
|
240 |
# safer version used internally, preserves new lines |
240 |
# safer version used internally, preserves new lines |
241 |
sub string_canon_safe ($) { |
241 |
sub string_canon_safe { |
242 |
my $s = shift; |
242 |
my $s = shift; |
243 |
# fold tabs and spaces into single spaces |
243 |
# fold tabs and spaces into single spaces |
244 |
$s =~ s/[\ \t]+/ /gs; |
244 |
$s =~ s/[\ \t]+/ /gs; |
Lines 361-367
sub next_token {
Link Here
|
361 |
|
361 |
|
362 |
# function taken from old version |
362 |
# function taken from old version |
363 |
# used by tmpl_process3 |
363 |
# used by tmpl_process3 |
364 |
sub parametrize ($$$$) { |
364 |
sub parametrize { |
365 |
my($fmt_0, $cformat_p, $t, $f) = @_; |
365 |
my($fmt_0, $cformat_p, $t, $f) = @_; |
366 |
my $it = ''; |
366 |
my $it = ''; |
367 |
if ($cformat_p) { |
367 |
if ($cformat_p) { |
Lines 454-465
sub parametrize ($$$$) {
Link Here
|
454 |
|
454 |
|
455 |
# Other simple functions (These are not methods) |
455 |
# Other simple functions (These are not methods) |
456 |
|
456 |
|
457 |
sub blank_p ($) { |
457 |
sub blank_p { |
458 |
my($s) = @_; |
458 |
my($s) = @_; |
459 |
return $s =~ /^(?:\s|\ $re_end_entity|$re_tmpl_var|$re_xsl)*$/osi; |
459 |
return $s =~ /^(?:\s|\ $re_end_entity|$re_tmpl_var|$re_xsl)*$/osi; |
460 |
} |
460 |
} |
461 |
|
461 |
|
462 |
sub trim ($) { |
462 |
sub trim { |
463 |
my($s0) = @_; |
463 |
my($s0) = @_; |
464 |
my $l0 = length $s0; |
464 |
my $l0 = length $s0; |
465 |
my $s = $s0; |
465 |
my $s = $s0; |
Lines 468-474
sub trim ($) {
Link Here
|
468 |
return wantarray? (substr($s0, 0, $l1), $s, substr($s0, $l0 - $l2)): $s; |
468 |
return wantarray? (substr($s0, 0, $l1), $s, substr($s0, $l0 - $l2)): $s; |
469 |
} |
469 |
} |
470 |
|
470 |
|
471 |
sub quote_po ($) { |
471 |
sub quote_po { |
472 |
my($s) = @_; |
472 |
my($s) = @_; |
473 |
# Locale::PO->quote is buggy, it doesn't quote newlines :-/ |
473 |
# Locale::PO->quote is buggy, it doesn't quote newlines :-/ |
474 |
$s =~ s/([\\"])/\\\1/gs; |
474 |
$s =~ s/([\\"])/\\\1/gs; |
Lines 477-483
sub quote_po ($) {
Link Here
|
477 |
return "\"$s\""; |
477 |
return "\"$s\""; |
478 |
} |
478 |
} |
479 |
|
479 |
|
480 |
sub charset_canon ($) { |
480 |
sub charset_canon { |
481 |
my($charset) = @_; |
481 |
my($charset) = @_; |
482 |
$charset = uc($charset); |
482 |
$charset = uc($charset); |
483 |
$charset = "$1-$2" if $charset =~ /^(ISO|UTF)(\d.*)/i; |
483 |
$charset = "$1-$2" if $charset =~ /^(ISO|UTF)(\d.*)/i; |
Lines 510-516
use vars qw( @latin1_utf8 );
Link Here
|
510 |
"\303\270", "\303\271", "\303\272", "\303\273", "\303\274", "\303\275", |
510 |
"\303\270", "\303\271", "\303\272", "\303\273", "\303\274", "\303\275", |
511 |
"\303\276", "\303\277" ); |
511 |
"\303\276", "\303\277" ); |
512 |
|
512 |
|
513 |
sub charset_convert ($$$) { |
513 |
sub charset_convert { |
514 |
my($s, $charset_in, $charset_out) = @_; |
514 |
my($s, $charset_in, $charset_out) = @_; |
515 |
if ($s !~ /[\200-\377]/s) { # FIXME: don't worry about iso2022 for now |
515 |
if ($s !~ /[\200-\377]/s) { # FIXME: don't worry about iso2022 for now |
516 |
; |
516 |
; |
517 |
- |
|
|