|
1 # Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # Wrapper to support the EPOC Resource Compiler |
|
15 # |
|
16 # |
|
17 |
|
18 use warnings; |
|
19 use Cwd; # for cwd |
|
20 use FindBin; # for FindBin::Bin |
|
21 use File::Copy; # for copy() |
|
22 |
|
23 my $curdrive="x"; # will be initialised when first needed |
|
24 my $PerlBinPath; # fully qualified pathname of the directory containing this script |
|
25 |
|
26 # establish the path to the Perl binaries |
|
27 BEGIN { |
|
28 require 5.005_03; # check user has a version of perl that will cope |
|
29 $PerlBinPath = $FindBin::Bin; # X:/epoc32/tools |
|
30 $PerlBinPath =~ s/\//\\/g; # X:\epoc32\tools |
|
31 } |
|
32 use lib $PerlBinPath; |
|
33 use lockit_info; |
|
34 use E32Variant; # for variant specific macros |
|
35 use Pathutl; |
|
36 use Preprocessor; |
|
37 |
|
38 sub print_usage |
|
39 { |
|
40 #........1.........2.........3.........4.........5.........6.........7..... |
|
41 print <<USAGE_EOF; |
|
42 |
|
43 Usage: |
|
44 epocrc [options] srcfile [-ooutputfile] [-hheaderfile] [-l "TargetPath:CWDir"] |
|
45 |
|
46 Compile an EPOC resource file, optionally generating a compiled resource |
|
47 file and an associated header file. |
|
48 |
|
49 The available options are |
|
50 |
|
51 -Dxxx, -Ixxx -- C++ preprocessor arguments |
|
52 -preincludeFILE -- optional FILE to be used as a preinclude file in all preprocessing |
|
53 -u -- compile for use with Unicode EPOC |
|
54 -ttmpdir -- specify a directory for temporary files |
|
55 -nocpp -- do not call C++ preprocessor |
|
56 -l -- if specified, capture all source to \\epoc32\\localisation\\... |
|
57 -uid2 N -- specifies 2nd UID for output file |
|
58 -uid3 N -- specifies 3rd UID for output file |
|
59 -m[nnn](,[nnn])* -- suppress warning nnn in rcomp, can supply multiple |
|
60 comma-separated three digit values |
|
61 -v -- verbose output |
|
62 -vv -- more verbose, -v passed to rcomp |
|
63 |
|
64 See the file epocrc.config for futher usage options. |
|
65 |
|
66 The resource file is first passed through the C++ preprocessor, using any |
|
67 specified preprocessor arguments, and then compiled with RCOMP.EXE to |
|
68 generate a compiled resource and the associated header file. |
|
69 |
|
70 All intermediate files are generated into a temporary directory. |
|
71 |
|
72 Specifying either -uid2 or -uid3 overrides all uids specified in the source file. |
|
73 |
|
74 If -preinclude FILE is not specified, the preinclude file listed in |
|
75 %EPOCROOT%epoc32\\tools\\variant\\variant.cfg is used in all preprocessing. |
|
76 |
|
77 USAGE_EOF |
|
78 } |
|
79 |
|
80 #------------------------------------------------------- |
|
81 # Process commandline arguments |
|
82 # |
|
83 # Can't use the Getopt package because it doesn't like the -D and -I style options |
|
84 # |
|
85 my $opt_uid2=''; |
|
86 my $opt_uid3=''; |
|
87 my $sourcefile=""; |
|
88 my $opt_o=""; |
|
89 my $opt_m=""; |
|
90 my $opt_h=""; |
|
91 my $opt_l=""; |
|
92 my $tmpdir=""; |
|
93 my $unicode=0; |
|
94 my $opt_v=0; |
|
95 my $opt_vmore=0; |
|
96 my $opt_cpp = 1; |
|
97 my $check_rls_items = 0; |
|
98 my $strict_checking = 0; |
|
99 my $test_mode = 0; |
|
100 my $warnings_to_enable = 0; |
|
101 |
|
102 my $variantMacroHRHFile = ""; |
|
103 my $exe = &PreprocessorToUseExe(); |
|
104 my $cpp_spec= "$exe -nostdinc -undef -C "; # preserve comments |
|
105 |
|
106 my $errors = 0; |
|
107 while (@ARGV) |
|
108 { |
|
109 my $arg = shift @ARGV; |
|
110 if ($arg =~ /^-D(.*)$/) |
|
111 { |
|
112 if ($1 eq "") |
|
113 { |
|
114 $arg = shift @ARGV; |
|
115 $cpp_spec .= "-D \"$arg\" "; |
|
116 } |
|
117 else |
|
118 { |
|
119 $cpp_spec .= "$arg "; |
|
120 } |
|
121 next; |
|
122 } |
|
123 if ($arg =~ /^-I-$/) |
|
124 { |
|
125 $cpp_spec .= "-I- "; |
|
126 next; |
|
127 } |
|
128 if ($arg =~ /^-I(.*)$/) |
|
129 { |
|
130 $cpp_spec .= "-I "; |
|
131 if ($1 eq "") |
|
132 { |
|
133 $arg = shift @ARGV; |
|
134 } |
|
135 else |
|
136 { |
|
137 $arg = $1; |
|
138 } |
|
139 $cpp_spec .= quoted_path($arg)." "; |
|
140 next; |
|
141 } |
|
142 if ($arg =~ /^-preinclude(.*)$/) |
|
143 { |
|
144 $variantMacroHRHFile = $1; |
|
145 next; |
|
146 } |
|
147 if ($arg =~ /^-v$/) |
|
148 { |
|
149 $opt_v =1; |
|
150 next; |
|
151 } |
|
152 if ($arg =~ /^-vv$/) |
|
153 { |
|
154 $opt_vmore =1; |
|
155 $opt_v =1; |
|
156 next; |
|
157 } |
|
158 if ($arg =~ /^-nocpp$/) |
|
159 { |
|
160 $opt_cpp =0; |
|
161 next; |
|
162 } |
|
163 |
|
164 if ($arg =~ /^-uid2$/) |
|
165 { |
|
166 $opt_uid2 = shift @ARGV; |
|
167 next; |
|
168 } |
|
169 |
|
170 if ($arg =~ /^-uid3$/) |
|
171 { |
|
172 $opt_uid3 = shift @ARGV; |
|
173 next; |
|
174 } |
|
175 |
|
176 if ($arg =~ /^-u$/) |
|
177 { |
|
178 $unicode =1; |
|
179 next; |
|
180 } |
|
181 if ($arg =~ /^-o(.*)$/) |
|
182 { |
|
183 $opt_o =$1; |
|
184 next; |
|
185 } |
|
186 if ($arg =~ /^-h(.*)$/) |
|
187 { |
|
188 $opt_h =$1; |
|
189 next; |
|
190 } |
|
191 if ($arg =~ /^-t(.*)\\?$/) |
|
192 { |
|
193 $tmpdir ="$1\\"; |
|
194 next; |
|
195 } |
|
196 if ($arg =~ /^-l(.*)$/) |
|
197 { |
|
198 $opt_l =$1; |
|
199 next; |
|
200 } |
|
201 if($arg =~ /^(-m.*)$/) |
|
202 { |
|
203 $opt_m =$1; |
|
204 next; |
|
205 } |
|
206 if ($arg =~ /^-epocrc-test$/) |
|
207 { |
|
208 $test_mode = 1; |
|
209 next; |
|
210 } |
|
211 if ($arg =~ /^-/) |
|
212 { |
|
213 print "Unknown arg: $arg\n"; |
|
214 $errors++; |
|
215 next; |
|
216 } |
|
217 |
|
218 if (($opt_uid3 ne "*") && ($opt_uid2 eq "0")) |
|
219 { |
|
220 print "\n Error: uid3 specified without uid2 \n"; |
|
221 $errors++; |
|
222 exit; |
|
223 } |
|
224 |
|
225 $sourcefile=$arg; |
|
226 } |
|
227 |
|
228 if ($errors || $sourcefile eq "") |
|
229 { |
|
230 print_usage(); |
|
231 exit 1; |
|
232 } |
|
233 |
|
234 my @enabled_warnings = (); |
|
235 my $file_line; |
|
236 my @includes_from_config; |
|
237 my $epocrc_config = $ENV{EPOCROOT}. "epoc32\\tools\\epocrc.config"; |
|
238 |
|
239 if(-e $epocrc_config) |
|
240 { |
|
241 print "Opening configuration file " . $ENV{EPOCROOT} . "epoc32\\tools\\epocrc.config.\n" if ($opt_v); |
|
242 open EPOCRC_CONFIG, $ENV{EPOCROOT}. "epoc32\\tools\\epocrc.config" or die $ENV{EPOCROOT} . "epoc32\\tools\\epocrc.config"; |
|
243 |
|
244 while ($file_line = <EPOCRC_CONFIG>) |
|
245 { |
|
246 if($file_line=~/^\s*check_rls_items\s*=\s*(\d+)\s*;?\s*(\#.*)?$/) |
|
247 { # matches check_rls_items = <digits> followed by optional semi-colon followed by optional perl comment |
|
248 $check_rls_items = $1; |
|
249 } |
|
250 elsif($file_line=~/^\s*strict_checking\s*=\s*(\d+)\s*;?\s*(\#.*)?$/) |
|
251 { # matches strict_checking = <digits> followed by optional semi-colon followed by optional perl comment |
|
252 $strict_checking = $1; |
|
253 } |
|
254 elsif($file_line=~/^\s*\#.*$/) |
|
255 { # matches perl comment on a line by itself |
|
256 } |
|
257 elsif($file_line=~/^\s*$/) |
|
258 { # matches empty lines and lines with only whitespace |
|
259 } |
|
260 elsif($file_line=~/^\s*Include\:\s*(.*)\s*$/i) |
|
261 { # matches Include: followed by a file location |
|
262 push @includes_from_config, $1; |
|
263 } |
|
264 elsif($file_line=~/^\s*warnings_to_enable\s*=\s*(\S+)\s*;?\s*(\#.*)?$/) |
|
265 { # matches warnings_to_enable = <warnings> where <warnings> is a comma separated list of the warning numbers |
|
266 $warnings_to_enable = $1; |
|
267 # Append 0's to the warning numbers to make them 3 digit |
|
268 @enabled_warnings = map (sprintf("%03d",$_), split(/,/, $warnings_to_enable)); |
|
269 } |
|
270 else |
|
271 { |
|
272 print "Error: cannot parse line -- $file_line\n"; |
|
273 exit(1); |
|
274 } |
|
275 } |
|
276 } |
|
277 else |
|
278 { |
|
279 print "No configuration file found at " . $ENV{EPOCROOT} . "epoc32\\tools\\epocrc.config, using default values.\n" if ($opt_v); |
|
280 } |
|
281 |
|
282 unless ($check_rls_items==0 || $check_rls_items==1) |
|
283 { |
|
284 print "* Error: \$check_rls_items must take the value 0 or 1\n"; |
|
285 exit(1); |
|
286 } |
|
287 unless ($strict_checking==0 || $strict_checking==1) |
|
288 { |
|
289 print "* Error: \$strict_checking must take the value 0 or 1\n"; |
|
290 exit(1); |
|
291 } |
|
292 |
|
293 if($check_rls_items==0 && $strict_checking==1) |
|
294 { |
|
295 print "* Error: \$check_rls_items must be set to 1 to allow strict checking of rls comments\n"; |
|
296 exit(1); |
|
297 } |
|
298 |
|
299 print "Values: \$check_rls_items=$check_rls_items ,\$strict_checking=$strict_checking and \$warnings_to_enable=$warnings_to_enable\n" if ($opt_v); |
|
300 |
|
301 # Remove the warnings to be enabled from the warnings to be supressed list |
|
302 if(@enabled_warnings) |
|
303 { |
|
304 foreach my $warnings(@enabled_warnings) |
|
305 { |
|
306 $opt_m =~ s/$warnings,*//g; |
|
307 } |
|
308 } |
|
309 |
|
310 # Remove the last , character from $opt_m, which could have been left by previous processing |
|
311 $opt_m =~ s/,{1}$//; |
|
312 |
|
313 # If all warnings are removed, then $opt_m needs to be blanked |
|
314 if ($opt_m =~/^-m$/) |
|
315 { |
|
316 $opt_m = ""; |
|
317 } |
|
318 use File::Basename; |
|
319 my $outputfile=$opt_o; |
|
320 my $rss_base = basename($sourcefile); |
|
321 my ($rssfile) = split(/\./, $rss_base); # remove extension |
|
322 my $output_base; |
|
323 my $not_used; |
|
324 my $lang; |
|
325 my $rpp_name; |
|
326 |
|
327 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
328 |
|
329 |
|
330 $output_base = basename($outputfile); |
|
331 ($not_used,$lang) = split(/\.r/, $output_base); # get current lang from the filename |
|
332 |
|
333 $rpp_name = $tmpdir . $rssfile . $lang . ".rpp"; |
|
334 |
|
335 } |
|
336 else { |
|
337 |
|
338 $rpp_name = $tmpdir. $rssfile . ".rpp"; |
|
339 |
|
340 } |
|
341 my $headerfile=$opt_h; |
|
342 |
|
343 if ($opt_v) |
|
344 { |
|
345 print "* Source file: $sourcefile\n"; |
|
346 print "* Resource file: $outputfile\n" if ($outputfile ne ""); |
|
347 print "* Header file: $headerfile\n" if ($headerfile ne ""); |
|
348 } |
|
349 |
|
350 $opt_o = "-o\"$outputfile\"" if ($outputfile ne ""); |
|
351 $opt_h = "-h\"$headerfile\"" if ($headerfile ne ""); |
|
352 |
|
353 |
|
354 #------------------------------------------------------- |
|
355 # Run the preprocessor |
|
356 # |
|
357 |
|
358 if($opt_cpp) |
|
359 { |
|
360 $cpp_spec .= "-D_UNICODE " if ($unicode); |
|
361 |
|
362 $cpp_spec .= quoted_path($sourcefile) ." -o ". quoted_path($rpp_name); |
|
363 |
|
364 # get the HRH file containing all the Variant specific Macros, if not specified on the command line |
|
365 $variantMacroHRHFile = Variant_GetMacroHRHFile() if (!$variantMacroHRHFile); |
|
366 if($variantMacroHRHFile) |
|
367 { |
|
368 my $variantFilePath = Path_Split('Path',$variantMacroHRHFile); |
|
369 chop( $variantFilePath ); |
|
370 $cpp_spec .= " -I ".quoted_path($variantFilePath)." -include ".quoted_path($variantMacroHRHFile); |
|
371 } |
|
372 |
|
373 if($check_rls_items) |
|
374 { |
|
375 my $includePath; |
|
376 foreach my $include (@includes_from_config) |
|
377 { |
|
378 my $relInclude = $ENV{EPOCROOT} . $include; |
|
379 $relInclude=~s/^(.*)\\$/$1/; |
|
380 if(-d $relInclude) |
|
381 { |
|
382 $cpp_spec .= " -I ".quoted_path($relInclude); |
|
383 } |
|
384 elsif(-e $relInclude) |
|
385 { |
|
386 $includePath = Path_Split('Path',$include); |
|
387 $includePath=~s/^(.*)\\$/$1/; |
|
388 $cpp_spec .= " -I ".quoted_path($ENV{EPOCROOT}.$includePath)." -include ".quoted_path($relInclude); |
|
389 } |
|
390 else |
|
391 { |
|
392 print "Warning; cannot recognise $include as a valid file or directory.\n"; |
|
393 } |
|
394 } |
|
395 } |
|
396 |
|
397 print "* $cpp_spec\n" if ($opt_v); |
|
398 system($cpp_spec); |
|
399 |
|
400 my $cpp_status = $?; |
|
401 die "* cpp failed\n" if ($cpp_status != 0); |
|
402 } |
|
403 |
|
404 |
|
405 #------------------------------------------------------- |
|
406 # Copy rpp files to epoc32\localisation if not checking |
|
407 # rls items for localisation tags |
|
408 |
|
409 if ($opt_l ne "" && $check_rls_items == 0) |
|
410 { |
|
411 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
412 &Lockit_SrcFile($rssfile, $rpp_name, $opt_l, "RSC", "", $outputfile, $lang); |
|
413 } |
|
414 else { |
|
415 &Lockit_SrcFile($rssfile, $rpp_name, $opt_l, "RSC", "", $outputfile); |
|
416 } |
|
417 } |
|
418 |
|
419 #------------------------------------------------------- |
|
420 # Merge rls strings to rpp if not checking rls items |
|
421 # for localisation tags |
|
422 |
|
423 if($check_rls_items == 0) |
|
424 { |
|
425 &Merge_rls_string($rpp_name); |
|
426 } |
|
427 |
|
428 #------------------------------------------------------- |
|
429 # Test stage if -test_mode has been used |
|
430 # |
|
431 |
|
432 my $rcomp_spec = ""; |
|
433 my $test_number = ""; |
|
434 my $test_dir = ""; |
|
435 my $output_redir = ""; |
|
436 if($test_mode) |
|
437 { |
|
438 my $file_line; |
|
439 open EPOCRC_TEST, "epocrc.test"; |
|
440 while ($file_line = <EPOCRC_TEST>) |
|
441 { |
|
442 if($file_line =~ /^\s*RCOMP:\s*(\S+)\s*$/) |
|
443 { |
|
444 $rcomp_spec = $1; |
|
445 } |
|
446 elsif($file_line =~ /^\s*TEST-NUMBER:\s*(\d+)\s*$/) |
|
447 { |
|
448 $test_number = "$1"; |
|
449 } |
|
450 elsif($file_line =~ /^\s*TEST-DIR:\s*(\S+)\s*$/) |
|
451 { |
|
452 $test_dir = $1; |
|
453 } |
|
454 } |
|
455 if($rcomp_spec eq "" || $test_number eq "" || $test_dir eq "") |
|
456 { |
|
457 print "$rcomp_spec\n"; |
|
458 print "$test_number\n"; |
|
459 print "$test_dir\n"; |
|
460 print "Error: could not extract required information from epocrc.test file\n"; |
|
461 exit(1); |
|
462 } |
|
463 $output_redir = " 1>" . $test_dir . $rcomp_spec . "\.stdout 2>" . $test_dir . $rcomp_spec . "\.stderr"; |
|
464 $rcomp_spec .= " "; |
|
465 } |
|
466 |
|
467 #------------------------------------------------------- |
|
468 # Run the resource compiler |
|
469 # |
|
470 if($rcomp_spec eq "") |
|
471 { |
|
472 $rcomp_spec = "rcomp "; |
|
473 } |
|
474 $rcomp_spec .= "-u " if ($unicode); |
|
475 $rcomp_spec .= "-v " if ($opt_vmore); |
|
476 $rcomp_spec .= "$opt_m " if ($opt_m ne ""); |
|
477 $rcomp_spec .= "-l " if ($check_rls_items); |
|
478 $rcomp_spec .= "-force " if($strict_checking); |
|
479 if ($opt_uid2 ne '' || $opt_uid3 ne '') |
|
480 { |
|
481 $opt_uid2 = "0" if ($opt_uid2 eq ''); # defaults to zero |
|
482 $opt_uid3 = "*" if ($opt_uid3 eq ''); # defaults to * = derived from NAME |
|
483 $rcomp_spec .= "-{$opt_uid2,$opt_uid3} "; |
|
484 } |
|
485 $rcomp_spec .= "$opt_o $opt_h -s\"$rpp_name\" -i\"$sourcefile\""; |
|
486 $rcomp_spec .= "$output_redir"; |
|
487 print "* $rcomp_spec\n" if ($opt_v); |
|
488 system($rcomp_spec); |
|
489 if ($? != 0) |
|
490 { |
|
491 print "* RCOMP failed - deleting output files\n"; |
|
492 unlink $outputfile if ($outputfile ne ""); |
|
493 unlink $headerfile if ($headerfile ne ""); |
|
494 exit 1; |
|
495 } |
|
496 |
|
497 if (-e $outputfile) |
|
498 { |
|
499 use File::stat; |
|
500 if (stat($outputfile)->size > 65535) |
|
501 { |
|
502 # Resource file bigger than 64kB are not supported. |
|
503 print "* Compiled resource file bigger than 64kB\n"; |
|
504 print "* RCOMP failed - deleting output files\n"; |
|
505 unlink $outputfile if ($outputfile ne ""); |
|
506 unlink $headerfile if ($headerfile ne ""); |
|
507 exit 1; |
|
508 } |
|
509 } |
|
510 |
|
511 #------------------------------------------------------- |
|
512 # Copy rpp files to epoc32\localisation if checked |
|
513 # file for localisation tags |
|
514 |
|
515 if ($opt_l ne "" && $check_rls_items == 1) |
|
516 { |
|
517 if (defined $ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} && ($ENV{ABLD_TOOLSMOD_COMPATIBILITY_MODE} eq 'alpha')) { |
|
518 &Lockit_SrcFile($rssfile, $rpp_name, $opt_l, "RSC", "", $outputfile, $lang); |
|
519 } |
|
520 else { |
|
521 &Lockit_SrcFile($rssfile, $rpp_name, $opt_l, "RSC", "", $outputfile); |
|
522 } |
|
523 } |
|
524 |
|
525 # exit cleanly |
|
526 |
|
527 if(!$test_mode) |
|
528 { |
|
529 print "* deleting $rpp_name\n" if ($opt_v); |
|
530 unlink $rpp_name; |
|
531 } |
|
532 exit 0; |
|
533 |
|
534 |
|
535 #------------------------------------------------------- |
|
536 # Subroutine: convert path into something acceptable to CPP.EXE |
|
537 # |
|
538 |
|
539 sub quoted_path |
|
540 { |
|
541 my ($arg) = @_; |
|
542 return "\"$arg\"" if ($arg !~ /^\\[^\\]/); # not an absolute path |
|
543 if ($curdrive eq "x") |
|
544 { |
|
545 $curdrive=""; |
|
546 $curdrive=$1 if (cwd =~ /^(.:)/); |
|
547 } |
|
548 return "\"$curdrive$arg\""; |
|
549 } |
|
550 |
|
551 #------------------------------------------------------- |
|
552 # Subroutine: Merge the rls strings in the rpp file specified |
|
553 # |
|
554 sub Merge_rls_string |
|
555 { |
|
556 my ($rppfile) = @_; |
|
557 |
|
558 my $line; |
|
559 my $StringId; |
|
560 my $key; |
|
561 my $value; |
|
562 my $StringToSubstitute; |
|
563 my %ResourceString; |
|
564 |
|
565 print "* merging text strings to $rppfile\n" if ($opt_v); |
|
566 |
|
567 open NEWRPP, ">$rppfile.new" or die "* Can't write to $rppfile.new"; |
|
568 open RPP, "$rppfile" or die "* Can't open $rppfile"; |
|
569 |
|
570 while ($line = <RPP>) { |
|
571 while (($StringId, $StringToSubstitute)=each %ResourceString) |
|
572 { |
|
573 $line=~s/\b$StringId\b/$StringToSubstitute/g if ($line !~ /^rls_string/); |
|
574 } |
|
575 |
|
576 # find quoted "" strings |
|
577 if($line =~ /^rls_string\s+(\S+)\s+(.*$)/) |
|
578 { |
|
579 my $text = $2; |
|
580 $key = $1; |
|
581 $line=~s/(.*)/\/\/$1/; |
|
582 my $substr_count = 0; |
|
583 if(!exists $ResourceString{$key}) |
|
584 { |
|
585 SUBSTR: while (1) |
|
586 { |
|
587 # find quoted "" strings e.g. "hello" |
|
588 if($text =~ /^(\s*\"(.*?\\.)*.*?\")/) |
|
589 { |
|
590 $value = $1; |
|
591 $text = $'; |
|
592 ++$substr_count; |
|
593 } |
|
594 |
|
595 # find quoted '' strings. e.g. 'world' |
|
596 elsif($text =~ /^(\s*\'(.*?\\.)*.*?\')/) |
|
597 { |
|
598 $value = $1; |
|
599 $text = $'; |
|
600 ++$substr_count; |
|
601 } |
|
602 |
|
603 # find hex strings e.g. <0x34><0x45><0x65> |
|
604 elsif($text =~ /^(\s*(<.*?>)+)/) |
|
605 { |
|
606 $value = $1; |
|
607 $text = $'; |
|
608 ++$substr_count; |
|
609 } |
|
610 |
|
611 # find c comment e.g. /*hello world*/ (may exist between strings) |
|
612 elsif($text =~ /^(\s*\/\*.*?\*\/)/) |
|
613 { |
|
614 $text = $'; |
|
615 next SUBSTR; # ignore embedded comment |
|
616 } |
|
617 |
|
618 # find c++ comment e.g. //hello world (may exist after strings) |
|
619 elsif($text =~ /^(\s*\/\/.*$)/) |
|
620 { |
|
621 $text = $'; |
|
622 next SUBSTR; # ignore trailing comment |
|
623 } |
|
624 |
|
625 # exit search |
|
626 else |
|
627 { |
|
628 if ($substr_count == 0) |
|
629 { |
|
630 warn("WARNING: rls_string $key either has incorrect syntax or no value\n"); |
|
631 } |
|
632 last SUBSTR; |
|
633 } |
|
634 $ResourceString{$key} .= $value; |
|
635 } |
|
636 } |
|
637 } |
|
638 print NEWRPP $line; |
|
639 } |
|
640 |
|
641 close RPP; |
|
642 close NEWRPP; |
|
643 copy ("$rppfile.new", "$rppfile"); |
|
644 unlink ("$rppfile.new"); |
|
645 } |