diff options
author | akshay-c | 2019-01-30 12:23:44 +0530 |
---|---|---|
committer | akshay-c | 2019-01-30 12:23:44 +0530 |
commit | 4196481f74afb84e5cc59cdf00c06c1ca1becab7 (patch) | |
tree | b531deb0466897691f08f9076b7012592f026664 /ldmicro/txt2c.pl | |
download | LDmicroQt-4196481f74afb84e5cc59cdf00c06c1ca1becab7.tar.gz LDmicroQt-4196481f74afb84e5cc59cdf00c06c1ca1becab7.tar.bz2 LDmicroQt-4196481f74afb84e5cc59cdf00c06c1ca1becab7.zip |
First commit
Diffstat (limited to 'ldmicro/txt2c.pl')
-rw-r--r-- | ldmicro/txt2c.pl | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/ldmicro/txt2c.pl b/ldmicro/txt2c.pl new file mode 100644 index 0000000..a2745dc --- /dev/null +++ b/ldmicro/txt2c.pl @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +print <<EOT; +// generated by txt2c.pl from $ARGV[0] +#include <stdlib.h> +EOT + +for $manual (<manual*txt>) { + + if($manual eq 'manual.txt') { + $name = "HelpText"; + # Some languages don't have translated manuals yet, so use English + $ifdef = "#if defined(LDLANG_EN) || defined(LDLANG_ES) || defined(LDLANG_IT) || " . + "defined(LDLANG_PT)"; + } elsif($manual =~ /manual-(.)(.)\.txt/) { + $p = uc($1) . lc($2); + $ifdef = "#ifdef LDLANG_" . uc($1 . $2); + $name = "HelpText$p"; + } else { + die; + } + + print <<EOT; +$ifdef +char *$name\[] = { +EOT + + open(IN, $manual) or die; + while(<IN>) { + chomp; + s/\\/\\\\/g; + s/"/\\"/g; + + print qq{ "$_",\n}; + } + close IN; + + print <<EOT; + NULL +}; +#endif + +EOT + +} |