• R/O
  • SSH
  • HTTPS

svardos: Commit


Commit MetaInfo

Revision610 (tree)
Time2022-02-04 00:11:50
Authormateuszviste

Log Message

memory usage optimizations

Change Summary

Incremental Difference

--- localcfg/trunk/history.txt (revision 609)
+++ localcfg/trunk/history.txt (revision 610)
@@ -2,6 +2,7 @@
22
33 * localcfg ver 20220203
44 - NLS (translations) support through the SvarLANG library
5+ - memory usage optimizations
56
67 * localcfg ver 20220202 (merged into the SvarDOS project)
78 - country.sys path is optional, defaults to %DOSDIR%\CFG\COUNTRY.SYS
--- localcfg/trunk/localcfg.c (revision 609)
+++ localcfg/trunk/localcfg.c (revision 610)
@@ -151,8 +151,7 @@
151151 }
152152
153153
154-static char *datestring(struct country *c) {
155- static char result[16];
154+static char *datestring(char *result, struct country *c) {
156155 switch (c->CTYINFO.datefmt) {
157156 case COUNTRY_DATE_MDY:
158157 sprintf(result, "12%c31%c1990", c->CTYINFO.datesep[0], c->CTYINFO.datesep[0]);
@@ -169,8 +168,7 @@
169168 }
170169
171170
172-static char *timestring(struct country *c) {
173- static char result[16];
171+static char *timestring(char *result, struct country *c) {
174172 if (c->CTYINFO.timefmt == COUNTRY_TIME12) {
175173 sprintf(result, "11%c59%c59 PM", c->CTYINFO.timesep[0], c->CTYINFO.timesep[0]);
176174 } else {
@@ -180,8 +178,7 @@
180178 }
181179
182180
183-static char *currencystring(struct country *c) {
184- static char result[16];
181+static char *currencystring(char *result, struct country *c) {
185182 char decimalpart[16];
186183 char space[2] = {0, 0};
187184 char decsym[8];
@@ -387,8 +384,8 @@
387384 struct country cntdata;
388385 int changedflag;
389386 int x;
390- char fname[130];
391- char buff[128];
387+ static char fname[130];
388+ static char buff[64];
392389
393390 svarlang_autoload("localcfg");
394391
@@ -444,22 +441,23 @@
444441 sprintf(buff, " %c", cntdata.CTYINFO.thousands[0]);
445442 outputnl(buff);
446443 nls_put(NLS_INFO_DATEFMT);
447- sprintf(buff, " %s", datestring(&cntdata));
448- outputnl(buff);
444+ output(" ");
445+ outputnl(datestring(buff, &cntdata));
449446 nls_put(NLS_INFO_TIMEFMT);
450- sprintf(buff, " %s", timestring(&cntdata));
451- outputnl(buff);
447+ output(" ");
448+ outputnl(timestring(buff, &cntdata));
452449 nls_put(NLS_INFO_YESNO);
453450 sprintf(buff, " %c/%c", cntdata.YESNO.yes[0], cntdata.YESNO.no[0]);
454451 outputnl(buff);
455452 nls_put(NLS_INFO_CURREXAMPLE);
456- sprintf(" %s", currencystring(&cntdata));
457- outputnl(buff);
453+ output(" ");
454+ outputnl(currencystring(buff, &cntdata));
458455
459456 crlf();
460457 nls_puts(NLS_MAKESURE);
461- sprintf(buff, "COUNTRY=%03d,%03d,%s", cntdata.CTYINFO.id, cntdata.CTYINFO.codepage, fname);
462- outputnl(buff);
458+ sprintf(buff, "COUNTRY=%03d,%03d,", cntdata.CTYINFO.id, cntdata.CTYINFO.codepage);
459+ output(buff);
460+ outputnl(fname);
463461
464462 /* if anything changed, write the new file */
465463 if (changedflag != 0) country_write(fname, &cntdata);
Show on old repository browser