forked from len0rd/rockbox
* 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
This commit is contained in:
parent
6b7dff6e77
commit
993a20a2ca
1 changed files with 24 additions and 6 deletions
|
|
@ -294,7 +294,7 @@ my $voiceid=0x8000; # counter for voice-only ID numbers
|
||||||
# Now start the scanning of the selected language string
|
# 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;
|
my @phrase;
|
||||||
while(<LANG>) {
|
while(<LANG>) {
|
||||||
|
|
||||||
|
|
@ -329,16 +329,32 @@ while(<LANG>) {
|
||||||
my $idnum;
|
my $idnum;
|
||||||
|
|
||||||
if($dest =~ /^none\z/i) {
|
if($dest =~ /^none\z/i) {
|
||||||
# "none" as dest means that this entire phrase is to be
|
# "none" as dest (without quotes) means that this entire
|
||||||
# ignored
|
# phrase is to be ignored
|
||||||
#print "dest is NONE!\n";
|
|
||||||
}
|
}
|
||||||
else {
|
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
|
# Use the ID name to figure out which id number range we
|
||||||
# should use for this phrase. Voice-only strings are
|
# should use for this phrase. Voice-only strings are
|
||||||
# separated.
|
# 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/) {
|
if($idstr =~ /^VOICE/) {
|
||||||
$idnum = $voiceid++;
|
$idnum = $voiceid++;
|
||||||
}
|
}
|
||||||
|
|
@ -420,8 +436,10 @@ if($update) {
|
||||||
if($prefix) {
|
if($prefix) {
|
||||||
# We create a .c and .h file
|
# We create a .c and .h file
|
||||||
|
|
||||||
open(HFILE, ">$prefix.h");
|
open(HFILE, ">$prefix.h") ||
|
||||||
open(CFILE, ">$prefix.c");
|
die "couldn't create file $prefix.h\n";
|
||||||
|
open(CFILE, ">$prefix.c") ||
|
||||||
|
die "couldn't create file $prefix.c\n";
|
||||||
|
|
||||||
print HFILE <<MOO
|
print HFILE <<MOO
|
||||||
/* This file was automatically generated using genlang2 */
|
/* This file was automatically generated using genlang2 */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue