summaryrefslogtreecommitdiffstats
path: root/tools/genlang
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-04-06 09:08:11 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-04-06 09:08:11 +0000
commit993a20a2ca7627b1517f4843750081b33897e8f1 (patch)
treeb4ae25f9d5f22188b9f0da32fee6c259e75a9a6f /tools/genlang
parent6b7dff6e77423b6a5515948cba311557a4fcce0b (diff)
downloadrockbox-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-xtools/genlang30
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
# 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(<LANG>) {
@@ -329,16 +329,32 @@ while(<LANG>) {
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 <<MOO
/* This file was automatically generated using genlang2 */