Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 1292 → Rev 1293

/svarlang.lib/trunk/svarlang.c
70,6 → 70,7
return "";
}
 
 
/* routines below are simplified (dos-based) versions of the libc FILE-related
* functions. Using them avoids a dependency on FILE, hence makes the binary
* smaller if the application does not need to pull fopen() and friends */
164,9 → 165,10
}
#endif
 
 
int svarlang_load(const char *fname, const char *lang) {
unsigned short langid;
char hdr[5];
unsigned long hdr;
unsigned short buff16[2];
FHANDLE fd;
unsigned short string_count;
177,8 → 179,8
fd = FOPEN(fname);
if (!fd) return(-1);
 
/* read hdr, should be "SvL1\x1a" */
if ((FREAD(fd, hdr, 5) != 5) || (memcmp(hdr, "SvL1\x1a", 5) != 0)) {
/* read hdr, should be "SvL\x1a" */
if ((FREAD(fd, &hdr, 4) != 4) || (hdr != 0x1a4c7653L)) { /* 0x1a4c7653 = 'SvL\x1a' */
FCLOSE(fd);
return(-3);
}
/svarlang.lib/trunk/tlumacz.c
16,7 → 16,7
#include "svarlang.h"
 
#define STRINGS_CAP 65000 /* string storage size in characters */
#define DICT_CAP 10000 /* dictionary size in elements */
#define DICT_CAP 10000 /* dictionary size in elements */
 
/* read a single line from fd and fills it into dst, returns line length
* ending CR/LF is trimmed, as well as any trailing spaces */
198,7 → 198,7
l->dict_cap < (l->num_strings + 1) * sizeof(dict_entry_t)) {
return 0;
}
 
/* find dictionary insert position, search backwards in assumption
that in translation files, strings are generally ordered ascending */
for (cursor = l->num_strings; cursor > 0 && l->dict[cursor-1].id > id; cursor--);
294,7 → 294,7
maxid_line = linecount;
}
else {
printf("WARNING:%s[#%u] file unsorted - line %u has higher id %u.%u\r\n", fname, linecount, maxid_line, maxid >> 8, maxid & 0xff);
printf("WARNING:%s[#%u] file unsorted - line %u has higher id %u.%u\r\n", fname, linecount, maxid_line, maxid >> 8, maxid & 0xff);
}
}
else {
302,7 → 302,7
}
}
else {
printf("WARNING: %s[#%u] has a duplicated id (%u.%u)\r\n", fname, linecount, id >> 8, id & 0xff);
printf("WARNING: %s[#%u] has a duplicated id (%u.%u)\r\n", fname, linecount, id >> 8, id & 0xff);
}
}
 
328,7 → 328,7
 
static int svl_write_header(unsigned short num_strings, FILE *fd)
{
return (fwrite("SvL1\x1a", 1, 5, fd) == 5) &&
return (fwrite("SvL\x1a", 1, 4, fd) == 4) &&
(fwrite(&num_strings, 1, 2, fd) == 2);
}
 
457,7 → 457,7
break;
}
}
 
/* write lang ID to file, followed string table size, and then
the dictionary and string table for current language */
if (!svl_write_lang(lang, fd)) {