diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-09-17 07:17:25 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-09-17 07:17:25 +0000 |
commit | 8b06a013e0b8581aeb826a8b395cf8c7886a8946 (patch) | |
tree | 1a0105d78300cc850563c1a380c34661e350707d /tools | |
parent | 012e688bf989021a6f0aab63c9fdc908bbcd205e (diff) | |
download | rockbox-8b06a013e0b8581aeb826a8b395cf8c7886a8946.tar.gz rockbox-8b06a013e0b8581aeb826a8b395cf8c7886a8946.zip |
it now generates one .c file and one .h file, and the strings are all
put in an array
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2310 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/genlang | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/tools/genlang b/tools/genlang index 827ceb3949..2e3f212023 100755 --- a/tools/genlang +++ b/tools/genlang | |||
@@ -1,25 +1,51 @@ | |||
1 | #!/usr/bin/perl | 1 | #!/usr/bin/perl -s |
2 | 2 | ||
3 | if(!$ARGV[0]) { | 3 | if(!$ARGV[0]) { |
4 | print <<MOO | 4 | print <<MOO |
5 | Usage: lang.pl <file> | 5 | Usage: lang.pl [-p=<prefix>] <language file> |
6 | |||
7 | When running this program. <prefix>.h and <prefix>.c will be created in the | ||
8 | "current directory". <prefix> is "lang" by default. | ||
6 | MOO | 9 | MOO |
7 | ; | 10 | ; |
8 | exit; | 11 | exit; |
9 | } | 12 | } |
10 | 13 | ||
11 | print <<MOO | 14 | my $prefix = $p; |
12 | /* This file was automaticly generated using genlan */ | 15 | if(!$prefix) { |
16 | $prefix="lang"; | ||
17 | } | ||
18 | |||
19 | my $input = $ARGV[0]; | ||
20 | |||
21 | open(HFILE, ">$prefix.h"); | ||
22 | open(CFILE, ">$prefix.c"); | ||
23 | |||
24 | print HFILE <<MOO | ||
25 | /* This file was automaticly generated using genlang */ | ||
13 | /* | 26 | /* |
14 | * The str() macro/functions is how to access strings that might be | 27 | * The str() macro/functions is how to access strings that might be |
15 | * translated. Use it like str(MACRO) and except a string to be | 28 | * translated. Use it like str(MACRO) and except a string to be |
16 | * returned! | 29 | * returned! |
17 | */ | 30 | */ |
18 | #define str(x) x | 31 | #define str(x) language_strings[x] |
32 | |||
33 | /* this is the array with all the strings */ | ||
34 | extern unsigned char *language_strings[]; | ||
35 | |||
36 | enum { | ||
37 | MOO | ||
38 | ; | ||
39 | |||
40 | print CFILE <<MOO | ||
41 | /* This file was automaticly generated using genlang, the strings come | ||
42 | from "$input" */ | ||
43 | |||
44 | unsigned char *language_strings[]={ | ||
19 | MOO | 45 | MOO |
20 | ; | 46 | ; |
21 | 47 | ||
22 | open(LANG, "<$ARGV[0]"); | 48 | open(LANG, "<$input"); |
23 | while(<LANG>) { | 49 | while(<LANG>) { |
24 | if($_ =~ / *\#/) { | 50 | if($_ =~ / *\#/) { |
25 | # comment | 51 | # comment |
@@ -39,7 +65,9 @@ while(<LANG>) { | |||
39 | $value = $set{'eng'}; | 65 | $value = $set{'eng'}; |
40 | } | 66 | } |
41 | 67 | ||
42 | print "#define ".$set{'id'}." $value\n"; | 68 | print HFILE " ".$set{'id'}.",\n"; |
69 | print CFILE " $value,\n"; | ||
70 | |||
43 | undef %set; | 71 | undef %set; |
44 | } | 72 | } |
45 | 73 | ||
@@ -47,3 +75,19 @@ while(<LANG>) { | |||
47 | 75 | ||
48 | } | 76 | } |
49 | close(LANG); | 77 | close(LANG); |
78 | |||
79 | |||
80 | print HFILE <<MOO | ||
81 | }; | ||
82 | /* end of generated enum list */ | ||
83 | MOO | ||
84 | ; | ||
85 | |||
86 | print CFILE <<MOO | ||
87 | }; | ||
88 | /* end of generated string list */ | ||
89 | MOO | ||
90 | ; | ||
91 | |||
92 | close(CFILE); | ||
93 | close(HFILE); | ||