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