X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f Date: Fri, 31 Oct 2003 09:32:14 +0300 (MSK) From: "Alexander Aganichev" Sender: aaganichev AT yandex DOT ru Message-Id: <3FA201EE.000006.19866@tide.yandex.ru> MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] To: djgpp-workers AT delorie DOT com Subject: Re: locale fixes In-Reply-To: <3FA164AB.EC4594A8@phekda.freeserve.co.uk> References: <3F9E3836 DOT 000008 DOT 02793 AT soapbox DOT yandex DOT ru> <3F9EC775 DOT 41795CD0 AT phekda DOT freeserve DOT co DOT uk> <3F9FD9C8 DOT 000003 DOT 05203 AT ariel DOT yandex DOT ru> <3FA164AB DOT EC4594A8 AT phekda DOT freeserve DOT co DOT uk> X-source-ip: 208.248.82.254 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk >>> I don't have time to review them properly, but they basically >>> look OK to me. I'll review them properly on Sunday, hopefully. >>> >>> Do you have any test programs for these functions? >>> >>> If there are any existing tests, do they still pass, after >>> applying your patches? >> >> In general, without new setlocale() all locale patches should >> do nothing more then all those functions currently do. They >> only add the possibility to modify the behaviour of these >> functions from external modules. > > Sure, it should work the same. ;) But how can you prove it > without some regression tests? Because of they obvious to me? ;) >> For decimal point fixes I'll write the test cases where >> decimal_point is set from the application to some odd character >> (like comma or even ampersend) and test that conversion from >> ASCII and to ASCII still stable. > > Sounds good. Here is the test case: == decimal.c == #include #include #include #include double d; long double ld; char buf[256]; char *end; int main(int ac, char *av[]) { localeconv()->decimal_point[0] = '$'; strcpy(buf, "12$26"); d = strtod(buf, &end); if((d != 12.26) || (end != &buf[5])) { printf("strtod() failed\n"); return -1; } ld = _strtold(buf, &end); if((ld != 12.26L) || (end != &buf[5])) { printf("strtold() failed\n"); return -2; } sprintf(buf, "%.2f", d); if(strcmp(buf, "12$26")) { printf("sprintf failed\n"); return -3; } sscanf(buf, "%Lf", &ld); if(ld != 12.26L) { printf("sscanf failed: %Lf\n", ld); return -4; } printf("all tests passed\n"); return 0; } == end of file == >> For strcoll and strftime it is possible to modify static data >> and test that the result is also changed. I tested it with new >> setlocale() on Russian locale. > >Sounds good. Here are very simple test case for these two: == collate.c == #include #include extern unsigned char __dj_collate_table[256]; int main(int ac, char *av[]) { int c; __dj_collate_table['a'] = 'A'; __dj_collate_table['A'] = 'a'; c = strcoll("a", "A"); printf("strcoll: %s [%s] %s\n", "a", c ? (c > 0) ? ">" : "<" : "==", "A"); c = strcmp("a", "A"); printf("strcmp: %s [%s] %s\n", "a", c ? (c > 0) ? ">" : "<" : "==", "A"); return 0; } == end of file == == xstrftm.c == #include #include #include extern char __dj_date_format[10]; extern char __dj_time_format[16]; int main(int ac, char *av[]) { char buf[99]; time_t t = time(NULL); strcpy(__dj_date_format, "%d|%m|%Y"); strcpy(__dj_time_format, "[%H|%M|%S]"); strftime(buf, sizeof(buf), "%x %X", gmtime(&t)); printf("%s\n", buf); return 0; } == end of file == -- Alexander Aganichev url: http://aaganichev.narod.ru e-mail: aaganichev AT yandex DOT ru gsm: +7-095-786-1339