From 76c68da3a5fb3eb70cd4029754bc2ba7fd57bb3a Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Sun, 19 Dec 2004 16:42:51 +0000 Subject: [PATCH] - Moved the environment variable cleanup code into a destructor function. - Fixed a typo in the hstrerror() function. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14782 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/changes | 5 +++++ library/macros.h | 4 ++-- library/socket_hstrerror.c | 4 ++-- library/stdlib_headers.h | 14 +------------- library/stdlib_init_exit.c | 16 +--------------- library/stdlib_setenv.c | 33 +++++++++++++++++++++++++++++++-- 6 files changed, 42 insertions(+), 34 deletions(-) diff --git a/library/changes b/library/changes index be42058..b6caa88 100644 --- a/library/changes +++ b/library/changes @@ -1,3 +1,8 @@ +- Moved the environment variable cleanup code into a destructor function. + +- Fixed a typo in the hstrerror() function. + + c.lib 1.184 (28.11.2004) - Added asctime_r(), ctime_r(), gmtime_r(), localtime_r() and strtok_r(). diff --git a/library/macros.h b/library/macros.h index 15c1fac..f0804f0 100644 --- a/library/macros.h +++ b/library/macros.h @@ -1,5 +1,5 @@ /* - * $Id: macros.h,v 1.2 2004-09-29 19:57:57 obarthel Exp $ + * $Id: macros.h,v 1.3 2004-12-19 16:42:51 obarthel Exp $ * * :ts=4 * @@ -172,7 +172,7 @@ #define PROFILE_CONSTRUCTOR(name) static void __attribute__((constructor)) name##_ctor(void) #define PROFILE_DESTRUCTOR(name) static void __attribute__((destructor)) name##_dtor(void) #define CONSTRUCTOR_SUCCEED() return -#define CONSTRUCTOR_FAIL() exit(20) /* ZZZ not a nice thing to do; fix the constructor invocation code! */ +#define CONSTRUCTOR_FAIL() exit(RETURN_FAIL) /* ZZZ not a nice thing to do; fix the constructor invocation code! */ #endif /* __GNUC__ */ /****************************************************************************/ diff --git a/library/socket_hstrerror.c b/library/socket_hstrerror.c index 8da9ba9..7c405fc 100644 --- a/library/socket_hstrerror.c +++ b/library/socket_hstrerror.c @@ -1,5 +1,5 @@ /* - * $Id: socket_hstrerror.c,v 1.2 2004-07-29 08:35:15 obarthel Exp $ + * $Id: socket_hstrerror.c,v 1.3 2004-12-19 16:42:51 obarthel Exp $ * * :ts=4 * @@ -118,7 +118,7 @@ hstrerror(int error_number) case 3: /* NO_RECOVERY */ - result = "Unknown server error_number"; + result = "Unknown server error"; break; default: diff --git a/library/stdlib_headers.h b/library/stdlib_headers.h index d3210fa..6488e28 100644 --- a/library/stdlib_headers.h +++ b/library/stdlib_headers.h @@ -1,5 +1,5 @@ /* - * $Id: stdlib_headers.h,v 1.2 2004-11-14 11:06:27 obarthel Exp $ + * $Id: stdlib_headers.h,v 1.3 2004-12-19 16:42:51 obarthel Exp $ * * :ts=4 * @@ -149,18 +149,6 @@ struct MemoryTree /****************************************************************************/ -struct LocalVariable -{ - struct LocalVariable * lv_Next; - char * lv_Name; -}; - -/****************************************************************************/ - -extern struct LocalVariable * NOCOMMON __lv_root; - -/****************************************************************************/ - extern unsigned NOCOMMON __random_seed; /****************************************************************************/ diff --git a/library/stdlib_init_exit.c b/library/stdlib_init_exit.c index bdf4803..5b32087 100644 --- a/library/stdlib_init_exit.c +++ b/library/stdlib_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_init_exit.c,v 1.1.1.1 2004-07-26 16:31:57 obarthel Exp $ + * $Id: stdlib_init_exit.c,v 1.2 2004-12-19 16:42:51 obarthel Exp $ * * :ts=4 * @@ -60,20 +60,6 @@ __stdlib_exit(void) } #endif /* __MEM_DEBUG */ - /* Now for the local variables that may still be set. */ - if(__lv_root != NULL) - { - /* ZZZ why is this being done here? */ - - do - { - D(("deleting variable '%s'",__lv_root->lv_Name)); - - DeleteVar(__lv_root->lv_Name,0); - } - while((__lv_root = __lv_root->lv_Next) != NULL); - } - /* Clean this up, too, just to be safe. */ NewList((struct List *)&__alloca_memory_list); diff --git a/library/stdlib_setenv.c b/library/stdlib_setenv.c index 6bcd8d1..3465c23 100644 --- a/library/stdlib_setenv.c +++ b/library/stdlib_setenv.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_setenv.c,v 1.2 2004-08-07 09:15:32 obarthel Exp $ + * $Id: stdlib_setenv.c,v 1.3 2004-12-19 16:42:51 obarthel Exp $ * * :ts=4 * @@ -53,7 +53,36 @@ /****************************************************************************/ -struct LocalVariable * __lv_root; +struct LocalVariable +{ + struct LocalVariable * lv_Next; + char * lv_Name; +}; + +/****************************************************************************/ + +STATIC struct LocalVariable * __lv_root; + +/****************************************************************************/ + +CLIB_DESTRUCTOR(__setenv_exit) +{ + ENTER(); + + /* Now for the local variables that may still be set. */ + if(__lv_root != NULL) + { + do + { + D(("deleting variable '%s'",__lv_root->lv_Name)); + + DeleteVar(__lv_root->lv_Name,0); + } + while((__lv_root = __lv_root->lv_Next) != NULL); + } + + LEAVE(); +} /****************************************************************************/