summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/language.c14
-rwxr-xr-xtools/genlang10
2 files changed, 14 insertions, 10 deletions
diff --git a/apps/language.c b/apps/language.c
index 73ed0fe39b..bba1359616 100644
--- a/apps/language.c
+++ b/apps/language.c
@@ -31,10 +31,12 @@
31 language! */ 31 language! */
32#include "max_language_size.h" 32#include "max_language_size.h"
33 33
34/* both these must match the two initial bytes in the binary lang file */ 34/* These defines must match the initial bytes in the binary lang file */
35#define LANGUAGE_COOKIE 0x1a 35/* See tools/genlang (TODO: Use common include for both) */
36#define LANGUAGE_VERSION 0x04 36#define LANGUAGE_COOKIE 0x1a
37#define LANGUAGE_VERSION 0x04
37 38
39#define HEADER_SIZE 3
38 40
39static unsigned char language_buffer[MAX_LANGUAGE_SIZE]; 41static unsigned char language_buffer[MAX_LANGUAGE_SIZE];
40 42
@@ -54,12 +56,12 @@ int lang_load(const char *filename)
54 int fsize; 56 int fsize;
55 int fd = open(filename, O_RDONLY); 57 int fd = open(filename, O_RDONLY);
56 int retcode=0; 58 int retcode=0;
57 unsigned char lang_header[3]; 59 unsigned char lang_header[HEADER_SIZE];
58 if(fd < 0) 60 if(fd < 0)
59 return 1; 61 return 1;
60 fsize = filesize(fd) - 2; 62 fsize = filesize(fd) - HEADER_SIZE;
61 if(fsize <= MAX_LANGUAGE_SIZE) { 63 if(fsize <= MAX_LANGUAGE_SIZE) {
62 read(fd, lang_header, 3); 64 read(fd, lang_header, HEADER_SIZE);
63 if((lang_header[0] == LANGUAGE_COOKIE) && 65 if((lang_header[0] == LANGUAGE_COOKIE) &&
64 (lang_header[1] == LANGUAGE_VERSION) && 66 (lang_header[1] == LANGUAGE_VERSION) &&
65 (lang_header[2] == TARGET_ID)) { 67 (lang_header[2] == TARGET_ID)) {
diff --git a/tools/genlang b/tools/genlang
index 45171290d6..cedd052839 100755
--- a/tools/genlang
+++ b/tools/genlang
@@ -10,8 +10,10 @@
10# Copyright (C) 2006 - 2008 by Daniel Stenberg 10# Copyright (C) 2006 - 2008 by Daniel Stenberg
11# 11#
12 12
13# binary version for the binary lang file 13# See apps/language.c (TODO: Use common include for both)
14my $langversion = 4; # 3 was the latest one used in the v1 format 14# Cookie and binary version for the binary lang file
15my $LANGUAGE_COOKIE = 0x1a;
16my $LANGUAGE_VERSION = 0x04;
15 17
16# A note for future users and readers: The original v1 language system allowed 18# A note for future users and readers: The original v1 language system allowed
17# the build to create and use a different language than english built-in. We 19# the build to create and use a different language than english built-in. We
@@ -26,7 +28,7 @@ my %user2num =
26 28
27if(!$ARGV[0]) { 29if(!$ARGV[0]) {
28 print <<MOO 30 print <<MOO
29Usage: genlang [options] <langv2 file> 31Usage: genlang [options] <langv4 file>
30 32
31 -p=<prefix> 33 -p=<prefix>
32 Make the tool create a [prefix].c and [prefix].h file. 34 Make the tool create a [prefix].c and [prefix].h file.
@@ -659,7 +661,7 @@ elsif($binary) {
659 661
660 open(OUTF, ">$binary") or die "Error: Can't create $binary"; 662 open(OUTF, ">$binary") or die "Error: Can't create $binary";
661 binmode OUTF; 663 binmode OUTF;
662 printf OUTF ("\x1a%c%c", $langversion, $target_id); # magic lang file header 664 printf OUTF ("%c%c%c", $LANGUAGE_COOKIE, $LANGUAGE_VERSION, $target_id); # magic lang file header
663 665
664 # loop over the target phrases 666 # loop over the target phrases
665 for $i (1 .. $idcount) { 667 for $i (1 .. $idcount) {