From 9c436ceaaaf6412ca0c943c9eaac254516a727f5 Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Wed, 5 Apr 2006 06:35:42 +0000 Subject: [PATCH] - Added the "setlocale.c" test program. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15089 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- test_programs/GNUmakefile.68k | 11 ++++++++--- test_programs/GNUmakefile.os4 | 10 +++++++--- test_programs/README | 3 +-- test_programs/setlocale.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 8 deletions(-) create mode 100755 test_programs/setlocale.c diff --git a/test_programs/GNUmakefile.68k b/test_programs/GNUmakefile.68k index 419c5a7..130dc2d 100644 --- a/test_programs/GNUmakefile.68k +++ b/test_programs/GNUmakefile.68k @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.68k,v 1.10 2006-01-02 13:11:39 obarthel Exp $ +# $Id: GNUmakefile.68k,v 1.11 2006-04-05 06:35:42 obarthel Exp $ # # :ts=8 # @@ -48,16 +48,21 @@ LIBS = -lm -lc -lgcc all: test fgets_test iotest sscanf_test printf_test sprintf_test \ stack_size_test translate_test strtok_test uname simple \ - fstat_stdout_test simple_sprintf date_test sscanf_64 factorial + fstat_stdout_test simple_sprintf date_test sscanf_64 factorial \ + setlocale clean: $(DELETE) #?.o #?.map test fgets_test iotest sscanf_test printf_test \ sprintf_test stack_size_test translate_test strtok_test uname \ simple fstat_stdout_test simple_sprintf date_test sscanf_64 \ - factorial + factorial setlocale ############################################################################## +setlocale : setlocale.o + @echo "Linking $@" + $(CC) $(CFLAGS) -o $@ setlocale.o $(LIBS) -Wl,--cref,-M,-Map=$@.map + test : test.o @echo "Linking $@" $(CC) $(CFLAGS) -o $@ test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map diff --git a/test_programs/GNUmakefile.os4 b/test_programs/GNUmakefile.os4 index 34534e3..cd766a6 100644 --- a/test_programs/GNUmakefile.os4 +++ b/test_programs/GNUmakefile.os4 @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.os4,v 1.11 2006-01-02 13:11:39 obarthel Exp $ +# $Id: GNUmakefile.os4,v 1.12 2006-04-05 06:35:42 obarthel Exp $ # # :ts=8 # @@ -41,16 +41,20 @@ LIBS = -lm -lc -ldebug -lgcc all: test fgets_test iotest sscanf_test printf_test sprintf_test \ stack_size_test translate_test strtok_test uname simple \ fstat_stdout_test simple_sprintf date_test sscanf_64 \ - factorial + factorial setlocale clean: $(DELETE) *.o *.map test fgets_test iotest sscanf_test printf_test \ sprintf_test stack_size_test translate_test strtok_test \ uname simple fstat_stdout_test simple_sprintf date_test \ - sscanf_64 factorial + sscanf_64 factorial setlocale ############################################################################## +setlocale : setlocale.o + @echo "Linking $@" + $(CC) $(CFLAGS) -o $@ setlocale.o $(LIBS) -Wl,--cref,-M,-Map=$@.map + test : test.o @echo "Linking $@" $(CC) $(CFLAGS) -o $@ test.o $(LIBS) -Wl,--cref,-M,-Map=$@.map diff --git a/test_programs/README b/test_programs/README index be6967b..4010fde 100644 --- a/test_programs/README +++ b/test_programs/README @@ -1,5 +1,4 @@ This is a collection of programs I'm using to test the library. These are functional tests: the library is supposed to do something, and produce a particular result. For example, "printf_test" exercises a bunch of -output formatting rules. Currently, there is only an smakefile for SAS/C -to build these programs with. +output formatting rules. diff --git a/test_programs/setlocale.c b/test_programs/setlocale.c new file mode 100755 index 0000000..ad98e94 --- /dev/null +++ b/test_programs/setlocale.c @@ -0,0 +1,29 @@ +#include +#include + +/* uncomment to fix corruption +#include +BOOL __open_locale = FALSE; +*/ + +int +main(void) +{ + char *loc; + time_t t; + struct tm *m; + char buf[200]; + int len; + + loc = setlocale(LC_ALL, ""); + printf("loc=%p (%s)\n", loc, loc); + + time(&t); + m = gmtime(&t); + + len = strftime(buf, sizeof(buf), "%a %b", m); + + printf("len=%d buf=%s\n", len, buf); + + return 0; +}