Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 1060 → Rev 1061

/svarlang.lib/trunk/history.txt
1,3 → 1,7
 
20220309
- static lib buffer is sized to fit the largest lang block +5% of margin
(was: twice the size of the reference language)
 
20220226
- replaced fopen() and friends by direct DOS calls (smaller memory footprint)
/svarlang.lib/trunk/tlumacz.c
124,7 → 124,8
}
 
 
/* opens a CATS-style file and compiles it into a ressources lang block */
/* opens a CATS-style file and compiles it into a ressources lang block
* returns 0 on error, or the size of the generated data block otherwise */
static unsigned short gen_langstrings(unsigned char *buff, const char *langid, struct bitmap *b, const struct bitmap *refb, const unsigned char *refblock) {
unsigned short len = 0, linelen;
FILE *fd;
222,9 → 223,11
FILE *fd;
int ecode = 0;
char *buff, *refblock;
unsigned short refblocksz = 0;
static struct bitmap bufbitmap;
static struct bitmap refbitmap;
unsigned short i;
unsigned short biggest_langsz = 0;
 
if (argc < 2) {
puts("usage: tlumacz en fr pl etc");
271,6 → 274,7
break;
} else {
printf("computed %s lang block of %u bytes\r\n", id, sz);
if (sz > biggest_langsz) biggest_langsz = sz;
}
/* write lang ID to file, followed by block size and then the actual block */
if ((fwrite(id, 1, 2, fd) != 2) ||
280,26 → 284,9
ecode = 1;
break;
}
/* compute the default block for reference language */
/* remember reference data for other languages */
if (i == 1) {
unsigned short x;
FILE *fd2;
fd2 = fopen("DEFLANG.C", "wb");
if (fd2 == NULL) {
puts("ERROR: FAILED TO OPEN OR CREATE DEFLANG.C");
break;
}
fprintf(fd2, "/* THIS FILE HAS BEEN AUTOGENERATE BY TLUMACZ (PART OF THE SVARLANG LIBRARY) */\r\n");
fprintf(fd2, "const unsigned short svarlang_memsz = %uu;\r\n", sz * 2);
fprintf(fd2, "char svarlang_mem[%u] = {\r\n", sz * 2);
for (x = 0; x < sz; x++) {
fprintf(fd2, "%u", buff[x]);
if (x + 1 < sz) fprintf(fd2, ",");
if ((x & 15) == 15) fprintf(fd2, "\r\n");
}
fprintf(fd2, "};\r\n");
fclose(fd2);
/* remember reference data for other languages */
refblocksz = sz;
memcpy(refblock, buff, MEMBLOCKSZ);
memcpy(&refbitmap, &bufbitmap, sizeof(struct bitmap));
}
307,5 → 294,25
 
fclose(fd);
 
/* compute the deflang.c file containing a dump of the reference block */
fd = fopen("DEFLANG.C", "wb");
if (fd == NULL) {
puts("ERROR: FAILED TO OPEN OR CREATE DEFLANG.C");
ecode = 1;
} else {
unsigned short allocsz = biggest_langsz + (biggest_langsz / 20);
printf("biggest lang block is %u bytes -> allocating a %u bytes buffer\n", biggest_langsz, allocsz);
fprintf(fd, "/* THIS FILE HAS BEEN GENERATED BY TLUMACZ (PART OF THE SVARLANG LIBRARY) */\r\n");
fprintf(fd, "const unsigned short svarlang_memsz = %uu;\r\n", allocsz);
fprintf(fd, "char svarlang_mem[%u] = {\r\n", allocsz);
for (i = 0; i < refblocksz; i++) {
fprintf(fd, "%u", buff[i]);
if (i + 1 < refblocksz) fprintf(fd, ",");
if ((i & 15) == 15) fprintf(fd, "\r\n");
}
fprintf(fd, "};\r\n");
fclose(fd);
}
 
return(ecode);
}