summaryrefslogtreecommitdiff
path: root/ldmicro/txt2c.pl
blob: 4a8ea3b41f333d3e32448d8aa5e2af003e41e1cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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

}