Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 592 → Rev 593

/localcfg/trunk/TODO
1,10 → 1,5
- fallback to %DOSDIR%\CFG\COUNTRY.SYS if target file not defined
- when file doesn't exist, it should always be created (even if no
modification switch has been used)
- when trying to open a country.sys file that is not localcfg-computed, the
error message should specifically say so
- some more helpful messages when wrong options are inputed (instead of
displaying the about screen over and over)
- the usage instruction (COUNTRY=...) should mention the exact path to the
file that we created, not an example
- translation support (svarlang)
/localcfg/trunk/history.txt
1,9 → 1,11
localcfg history file
 
* localcfg ver 20220202 (merged into the SvarDOS project)
- country.sys path is optional, defaults to %DOSDIR%\CFG\COUNTRY.SYS
- COUNTRY=xxx example contains the actual codepage and path to COUNTRY.SYS
- improved loading/saving routines so they rely on memory structures
- relicensed from BSD 2-clause to MIT
- moved from Turbo C to OpenWatcom
 
* localcfg v0.90 [02 June 2015]
- first public release
/localcfg/trunk/localcfg.c
36,11 → 36,11
 
static void about(void) {
puts("localcfg ver " PVER " - locales configuration for DOS\n"
"Copyright (C) Mateusz Viste " PDATE "\n"
"Copyright (C) " PDATE " Mateusz Viste\n"
"\n"
"localcfg creates a custom COUNTRY.SYS-like file matching your preferences.\n"
"localcfg creates or edits a custom COUNTRY.SYS-like file with your preferences.\n"
"\n"
"usage: localcfg myprefs.sys [options]\n"
"usage: localcfg [COUNTRY.SYS] [options]\n"
"\n"
"options allow to configure country locales to your likening, as follows:\n"
" /country:XX indicates your country code is XX (1 for USA, 33 for France, etc)\n"
58,6 → 58,9
" /currspc:X space between the currency and the value (0=no, 1=yes)\n"
" /currprec:X currency's precision (number of decimal digits, 0..9)\n"
" /yesno:XY sets the 'Yes/No' letter to XY (default: YN)\n"
"\n"
"If COUNTRY.SYS location is not provided, then localcfg tries loading it\n"
"from %DOSDIR%\\CFG\\COUNTRY.SYS\n"
);
}
 
279,6 → 282,21
}
 
 
static void default_country_path(char *s) {
char *dosdir = getenv("DOSDIR");
size_t dosdirlen;
s[0] = 0;
if (dosdir == NULL) return;
dosdirlen = strlen(dosdir);
if (dosdirlen == 0) return;
/* drop trailing backslash if present */
if (dosdir[dosdirlen - 1] == '\\') dosdirlen--;
/* copy dosdir to s and append the rest of the path */
memcpy(s, dosdir, dosdirlen);
strcpy(s + dosdirlen, "\\CFG\\COUNTRY.SYS");
}
 
 
int main(int argc, char **argv) {
struct country cntdata;
int changedflag;
285,15 → 303,26
int x;
static char fname[130];
 
if ((argc < 2) || (argv[1][0] == '/')) {
about();
return(1);
/* scan argv looking for the path to country.sys */
for (x = 1; x < argc; x++) {
if (argv[x][0] != '/') {
if (fname[0] != 0) {
puts("ERROR: file path can be provided only once");
return(1);
}
/* */
if (file_truename(fname, argv[x]) != 0) {
puts("ERROR: bad file path");
return(1);
}
} else if (strcmp(argv[x], "/?") == 0) { /* is it /? */
about();
return(1);
}
}
 
if (file_truename(fname, argv[1]) != 0) {
puts("ERROR: bad file path");
return(1);
}
/* if no file path provided, look into %DOSDIR%\CFG\COUNTRY.SYS */
if (fname[0] == 0) default_country_path(fname);
 
x = country_read(&cntdata, fname);
if (x != 0) {
301,12 → 330,14
return(2);
}
 
changedflag = argc - 2;
changedflag = 0;
 
/* process command line arguments */
while (--argc > 1) {
if (processarg(argv[argc], &cntdata) != 0) {
about();
for (x = 1; x < argc; x++) {
if (argv[x][0] != '/') continue; /* skip country.sys filename (processed earlier) */
changedflag++;
if (processarg(argv[x], &cntdata) != 0) {
puts("ERROR: invalid parameter syntax");
return(3);
}
}
321,8 → 352,7
printf("Currency example......: %s\n", currencystring(&cntdata));
 
printf("\n"
"Please make sure your CONFIG.SYS contains a COUNTRY directive that points to\n"
"your custom preferences file:\n"
"Make sure that your CONFIG.SYS contains this directive:\n"
"COUNTRY=%03d,%03d,%s\n\n", cntdata.CTYINFO.id, cntdata.CTYINFO.codepage, fname);
 
/* if anything changed, write the new file */