diff options
author | Daniel Stenberg <daniel@haxx.se> | 2006-04-06 09:08:11 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2006-04-06 09:08:11 +0000 |
commit | 993a20a2ca7627b1517f4843750081b33897e8f1 (patch) | |
tree | b4ae25f9d5f22188b9f0da32fee6c259e75a9a6f /tools/genlang | |
parent | 6b7dff6e77423b6a5515948cba311557a4fcce0b (diff) | |
download | rockbox-993a20a2ca7627b1517f4843750081b33897e8f1.tar.gz rockbox-993a20a2ca7627b1517f4843750081b33897e8f1.zip |
* added more safety checks for failed open()s
* allow 'deprecated' as a keyword for strings marked as ... deprecated!
* warns on stderr if a given string is given without quotes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9533 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/genlang')
-rwxr-xr-x | tools/genlang | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/tools/genlang b/tools/genlang index 34f0612852..8be9b63d45 100755 --- a/tools/genlang +++ b/tools/genlang | |||
@@ -294,7 +294,7 @@ my $voiceid=0x8000; # counter for voice-only ID numbers | |||
294 | # Now start the scanning of the selected language string | 294 | # Now start the scanning of the selected language string |
295 | # | 295 | # |
296 | 296 | ||
297 | open(LANG, "<$input"); | 297 | open(LANG, "<$input") || die "couldn't read language file named $input\n"; |
298 | my @phrase; | 298 | my @phrase; |
299 | while(<LANG>) { | 299 | while(<LANG>) { |
300 | 300 | ||
@@ -329,16 +329,32 @@ while(<LANG>) { | |||
329 | my $idnum; | 329 | my $idnum; |
330 | 330 | ||
331 | if($dest =~ /^none\z/i) { | 331 | if($dest =~ /^none\z/i) { |
332 | # "none" as dest means that this entire phrase is to be | 332 | # "none" as dest (without quotes) means that this entire |
333 | # ignored | 333 | # phrase is to be ignored |
334 | #print "dest is NONE!\n"; | ||
335 | } | 334 | } |
336 | else { | 335 | else { |
336 | # allow the keyword 'deprecated' to be used on dest and | ||
337 | # voice strings to mark that as deprecated. It will then | ||
338 | # be replaced with "". | ||
339 | |||
340 | $dest =~ s/^deprecate(|d)\z/\"\"/i; | ||
341 | $voice =~ s/^deprecate(|d)\z/\"\"/i; | ||
337 | 342 | ||
338 | # Use the ID name to figure out which id number range we | 343 | # Use the ID name to figure out which id number range we |
339 | # should use for this phrase. Voice-only strings are | 344 | # should use for this phrase. Voice-only strings are |
340 | # separated. | 345 | # separated. |
341 | 346 | ||
347 | # basic syntax error alerts | ||
348 | if($dest != /^\"/) { | ||
349 | print STDERR "dest around line $line lacks quotes!\n"; | ||
350 | } | ||
351 | if($src != /^\"/) { | ||
352 | print STDERR "source around line $line lacks quotes!\n"; | ||
353 | } | ||
354 | if($voice != /^\"/) { | ||
355 | print STDERR "voice around line $line lacks quotes!\n"; | ||
356 | } | ||
357 | |||
342 | if($idstr =~ /^VOICE/) { | 358 | if($idstr =~ /^VOICE/) { |
343 | $idnum = $voiceid++; | 359 | $idnum = $voiceid++; |
344 | } | 360 | } |
@@ -420,8 +436,10 @@ if($update) { | |||
420 | if($prefix) { | 436 | if($prefix) { |
421 | # We create a .c and .h file | 437 | # We create a .c and .h file |
422 | 438 | ||
423 | open(HFILE, ">$prefix.h"); | 439 | open(HFILE, ">$prefix.h") || |
424 | open(CFILE, ">$prefix.c"); | 440 | die "couldn't create file $prefix.h\n"; |
441 | open(CFILE, ">$prefix.c") || | ||
442 | die "couldn't create file $prefix.c\n"; | ||
425 | 443 | ||
426 | print HFILE <<MOO | 444 | print HFILE <<MOO |
427 | /* This file was automatically generated using genlang2 */ | 445 | /* This file was automatically generated using genlang2 */ |