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/genlang | |
parent | 012e688bf989021a6f0aab63c9fdc908bbcd205e (diff) |
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/genlang')
-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 @@ -#!/usr/bin/perl +#!/usr/bin/perl -s if(!$ARGV[0]) { print <<MOO -Usage: lang.pl <file> +Usage: lang.pl [-p=<prefix>] <language file> + +When running this program. <prefix>.h and <prefix>.c will be created in the +"current directory". <prefix> is "lang" by default. MOO ; exit; } -print <<MOO -/* This file was automaticly generated using genlan */ +my $prefix = $p; +if(!$prefix) { + $prefix="lang"; +} + +my $input = $ARGV[0]; + +open(HFILE, ">$prefix.h"); +open(CFILE, ">$prefix.c"); + +print HFILE <<MOO +/* This file was automaticly generated using genlang */ /* * The str() macro/functions is how to access strings that might be * translated. Use it like str(MACRO) and except a string to be * returned! */ -#define str(x) x +#define str(x) language_strings[x] + +/* this is the array with all the strings */ +extern unsigned char *language_strings[]; + +enum { +MOO + ; + +print CFILE <<MOO +/* This file was automaticly generated using genlang, the strings come + from "$input" */ + +unsigned char *language_strings[]={ MOO ; -open(LANG, "<$ARGV[0]"); +open(LANG, "<$input"); while(<LANG>) { if($_ =~ / *\#/) { # comment @@ -39,7 +65,9 @@ while(<LANG>) { $value = $set{'eng'}; } - print "#define ".$set{'id'}." $value\n"; + print HFILE " ".$set{'id'}.",\n"; + print CFILE " $value,\n"; + undef %set; } @@ -47,3 +75,19 @@ while(<LANG>) { } close(LANG); + + +print HFILE <<MOO +}; +/* end of generated enum list */ +MOO + ; + +print CFILE <<MOO +}; +/* end of generated string list */ +MOO + ; + +close(CFILE); +close(HFILE); |