From 993a20a2ca7627b1517f4843750081b33897e8f1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 6 Apr 2006 09:08:11 +0000 Subject: * 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 --- tools/genlang | 30 ++++++++++++++++++++++++------ 1 file 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 # Now start the scanning of the selected language string # -open(LANG, "<$input"); +open(LANG, "<$input") || die "couldn't read language file named $input\n"; my @phrase; while() { @@ -329,16 +329,32 @@ while() { my $idnum; if($dest =~ /^none\z/i) { - # "none" as dest means that this entire phrase is to be - # ignored - #print "dest is NONE!\n"; + # "none" as dest (without quotes) means that this entire + # phrase is to be ignored } else { + # allow the keyword 'deprecated' to be used on dest and + # voice strings to mark that as deprecated. It will then + # be replaced with "". + + $dest =~ s/^deprecate(|d)\z/\"\"/i; + $voice =~ s/^deprecate(|d)\z/\"\"/i; # Use the ID name to figure out which id number range we # should use for this phrase. Voice-only strings are # separated. + # basic syntax error alerts + if($dest != /^\"/) { + print STDERR "dest around line $line lacks quotes!\n"; + } + if($src != /^\"/) { + print STDERR "source around line $line lacks quotes!\n"; + } + if($voice != /^\"/) { + print STDERR "voice around line $line lacks quotes!\n"; + } + if($idstr =~ /^VOICE/) { $idnum = $voiceid++; } @@ -420,8 +436,10 @@ if($update) { if($prefix) { # We create a .c and .h file - open(HFILE, ">$prefix.h"); - open(CFILE, ">$prefix.c"); + open(HFILE, ">$prefix.h") || + die "couldn't create file $prefix.h\n"; + open(CFILE, ">$prefix.c") || + die "couldn't create file $prefix.c\n"; print HFILE <