Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update.
1997-11-24 03:01  Ulrich Drepper  <drepper@cygnus.com>

	* elf/dl-support.c: Call __libc_init_secure to make sure
	__libc_enable_secure is defined early.
	* sysdeps/generic/enbl-secure.c: Change function name to
	__libc_init_secure and make it global instead of a constructor.

	* iconv/gconv.c: Fix lots of bugs.
	* iconv/gconv.h: Likewise.
	* iconv/gconv_builtin.h: Likewise.
	* iconv/gconv_close.c: Likewise.
	* iconv/gconv_conf.c: Likewise.
	* iconv/gconv_db.c: Likewise.
	* iconv/gconv_dl.c: Likewise.
	* iconv/gconv_open.c: Likewise.
	* iconv/gconv_simple.c: Likewise.
	* iconv/iconv.c: Likewise.
	* iconv/iconv_close.c: Likewise.
	* iconv/iconv_open.c: Likewise.

	* wcsmbs/Makefile (routines): Add wmemrtowcs and wmemrtombs.
	* wcsmbs/wchar.h: Add prototypes for wmemrtowcs and wmemrtombs.
	* wcsmbs/wmemrtombs.c: New file.
	* wcsmbs/wmemrtowcs.c: New file.
  • Loading branch information
Ulrich Drepper committed Nov 24, 1997
1 parent f43ce63 commit e34b0f2
Show file tree
Hide file tree
Showing 19 changed files with 520 additions and 131 deletions.
25 changes: 25 additions & 0 deletions ChangeLog
@@ -1,3 +1,28 @@
1997-11-24 03:01 Ulrich Drepper <drepper@cygnus.com>

* elf/dl-support.c: Call __libc_init_secure to make sure
__libc_enable_secure is defined early.
* sysdeps/generic/enbl-secure.c: Change function name to
__libc_init_secure and make it global instead of a constructor.

* iconv/gconv.c: Fix lots of bugs.
* iconv/gconv.h: Likewise.
* iconv/gconv_builtin.h: Likewise.
* iconv/gconv_close.c: Likewise.
* iconv/gconv_conf.c: Likewise.
* iconv/gconv_db.c: Likewise.
* iconv/gconv_dl.c: Likewise.
* iconv/gconv_open.c: Likewise.
* iconv/gconv_simple.c: Likewise.
* iconv/iconv.c: Likewise.
* iconv/iconv_close.c: Likewise.
* iconv/iconv_open.c: Likewise.

* wcsmbs/Makefile (routines): Add wmemrtowcs and wmemrtombs.
* wcsmbs/wchar.h: Add prototypes for wmemrtowcs and wmemrtombs.
* wcsmbs/wmemrtombs.c: New file.
* wcsmbs/wmemrtowcs.c: New file.

1997-11-22 19:28 Ulrich Drepper <drepper@cygnus.com>

* iconv/gconv_simple.c: Fix lots of bugs.
Expand Down
8 changes: 6 additions & 2 deletions elf/dl-support.c
Expand Up @@ -46,6 +46,8 @@ struct r_search_path *_dl_search_paths;
const char *_dl_profile;
struct link_map *_dl_profile_map;

extern void __libc_init_secure (void);


static void non_dynamic_init (void) __attribute__ ((unused));

Expand All @@ -54,6 +56,10 @@ non_dynamic_init (void)
{
_dl_verbose = *(getenv ("LD_WARN") ?: "") == '\0' ? 0 : 1;

_dl_pagesize = __getpagesize ();

__libc_init_secure ();

/* Initialize the data structures for the search paths for shared
objects. */
_dl_init_paths ();
Expand All @@ -65,7 +71,5 @@ non_dynamic_init (void)
/* Now determine the length of the platform string. */
if (_dl_platform != NULL)
_dl_platformlen = strlen (_dl_platform);

_dl_pagesize = __getpagesize ();
}
text_set_element (__libc_subinit, non_dynamic_init);
3 changes: 3 additions & 0 deletions iconv/gconv.c
Expand Up @@ -30,6 +30,9 @@ __gconv (gconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
size_t oldinbytes = *inbytesleft;
int result;

if (cd == (gconv_t) -1L)
return GCONV_ILLEGAL_DESCRIPTOR;

cd->data[last_step].outbuf = *outbuf;
cd->data[last_step].outbufavail = 0;
cd->data[last_step].outbufsize = *outbytesleft;
Expand Down
1 change: 1 addition & 0 deletions iconv/gconv.h
Expand Up @@ -37,6 +37,7 @@ enum
GCONV_EMPTY_INPUT,
GCONV_FULL_OUTPUT,
GCONV_ILLEGAL_INPUT,
GCONV_INCOMPLETE_INPUT,

GCONV_ILLEGAL_DESCRIPTOR,
GCONV_INTERNAL_ERROR
Expand Down
6 changes: 3 additions & 3 deletions iconv/gconv_builtin.h
Expand Up @@ -18,17 +18,17 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */

BUILTIN_TRANSFORMATION ("\\([^/]+\\)/UCS4/\\([^/]*\\)", NULL, 0,
BUILTIN_TRANSFORMATION ("([^/]+)/UCS4/([^/]*)", NULL, 0,
"\\1/UTF8/\\2", 1, "=ucs4->utf8",
__gconv_transform_ucs4_utf8,
__gconv_transform_init_rstate,
__gconv_transform_end_rstate)

BUILTIN_TRANSFORMATION ("\\([^/]+\\)/UTF8/\\([^/]*\\)", NULL, 0,
BUILTIN_TRANSFORMATION ("([^/]+)/UTF8/([^/]*)", NULL, 0,
"\\1/UCS4/\\2", 1, "=utf8->ucs4",
__gconv_transform_utf8_ucs4,
__gconv_transform_init_rstate,
__gconv_transform_end_rstate)

BUILTIN_TRANSFORMATION ("\\(.*\\)", NULL, 0, "\\1", 1, "=dummy",
BUILTIN_TRANSFORMATION ("(.*)", NULL, 0, "\\1", 1, "=dummy",
__gconv_transform_dummy, NULL, NULL)
3 changes: 1 addition & 2 deletions iconv/gconv_close.c
Expand Up @@ -48,9 +48,8 @@ __gconv_close (gconv_t cd)

/* Next step. */
++srunp;
++drunp;
}
while (!drunp->is_last);
while (!(drunp++)->is_last);

/* Save the pointer, we need it below. */
srunp = cd->steps;
Expand Down
158 changes: 87 additions & 71 deletions iconv/gconv_conf.c
Expand Up @@ -19,6 +19,7 @@
Boston, MA 02111-1307, USA. */

#include <ctype.h>
#include <errno.h>
#include <gconv.h>
#include <search.h>
#include <stdio.h>
Expand All @@ -35,6 +36,12 @@ static const char default_gconv_path[] = GCONV_PATH;
along the path. */
static const char gconv_conf_filename[] = "gconv-modules";

/* Filename extension for the modules. */
#ifndef MODULE_EXT
# define MODULE_EXT ".so"
#endif
static const char gconv_module_ext[] = MODULE_EXT;

/* We have a few builtin transformations. */
static struct gconv_module builtin_modules[] =
{
Expand Down Expand Up @@ -111,15 +118,18 @@ add_alias (char *rp)

new_alias = (struct gconv_alias *)
malloc (sizeof (struct gconv_alias) + (wp - from));
new_alias->fromname = memcpy ((char *) new_alias
+ sizeof (struct gconv_alias),
from, to - from);
new_alias->toname = memcpy ((char *) new_alias + sizeof (struct gconv_alias)
+ (to - from), to, wp - to);

if (__tsearch (new_alias, &__gconv_alias_db, __gconv_alias_compare) == NULL)
/* Something went wrong, free this entry. */
free (new_alias);
if (new_alias != NULL)
{
new_alias->fromname = memcpy ((char *) new_alias
+ sizeof (struct gconv_alias),
from, wp - from);
new_alias->toname = new_alias->fromname + (to - from);

if (__tsearch (new_alias, &__gconv_alias_db, __gconv_alias_compare)
== NULL)
/* Something went wrong, free this entry. */
free (new_alias);
}
}


Expand All @@ -138,6 +148,7 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
char *from, *to, *module, *wp;
size_t const_len;
int from_is_regex;
int need_ext;
int cost;

while (isspace (*rp))
Expand Down Expand Up @@ -195,65 +206,68 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
/* Increment by one for the slash. */
++dir_len;

/* See whether we must add the ending. */
need_ext = 0;
if (wp - module < sizeof (gconv_module_ext)
|| memcmp (wp - sizeof (gconv_module_ext), gconv_module_ext,
sizeof (gconv_module_ext)) != 0)
/* We must add the module extension. */
need_ext = sizeof (gconv_module_ext) - 1;

/* We've collected all the information, now create an entry. */

const_len = 0;
if (from_is_regex)
do
++const_len;
while (isalnum (from[const_len]) || from[const_len] == '-'
|| from[const_len] == '/' || from[const_len] == '.'
|| from[const_len] == '_');
{
const_len = 0;
while (isalnum (from[const_len]) || from[const_len] == '-'
|| from[const_len] == '/' || from[const_len] == '.'
|| from[const_len] == '_')
++const_len;
}
else
const_len = to - from - 1;

new_module = (struct gconv_module *) malloc (sizeof (struct gconv_module)
+ (wp - from) + const_len
+ dir_len);
+ (wp - from)
+ dir_len + need_ext);
if (new_module != NULL)
{
char *tmp;

new_module->from_constpfx = memcpy ((char *) new_module
+ sizeof (struct gconv_module),
from, to - from);
if (from_is_regex)
{
new_module->from_pattern = memcpy ((char *) new_module
+ sizeof (struct gconv_module),
from, to - from);
new_module->from_constpfx = memcpy ((char *) new_module->from_pattern
+ (to - from),
from, const_len);
((char *) new_module->from_constpfx)[const_len] = '\0';
new_module->from_constpfx_len = const_len;
++const_len;
}
new_module->from_pattern = new_module->from_constpfx;
else
{
new_module->from_pattern = NULL;
new_module->from_constpfx = memcpy ((char *) new_module
+ sizeof (struct gconv_module),
from, to - from);
new_module->from_constpfx_len = to - from - 1;
const_len = to - from;
}
new_module->from_pattern = NULL;

new_module->from_constpfx_len = const_len;

new_module->from_regex = NULL;

new_module->to_string = memcpy ((char *) new_module->from_constpfx
+ const_len + 1, to, module - to);
+ (to - from), to, module - to);

new_module->cost = cost;

new_module->module_name = (char *) new_module->to_string + (module - to);

if (dir_len == 0)
new_module->module_name = memcpy ((char *) new_module->to_string
+ (module - to),
module, wp - module);
tmp = (char *) new_module->module_name;
else
{
char *tmp;
new_module->module_name = ((char *) new_module->to_string
+ (module - to));
tmp = __mempcpy ((char *) new_module->module_name,
directory, dir_len - 1);
*tmp++ = '/';
memcpy (tmp, module, wp - module);
}

if (__tfind (new_module, *modules, module_compare) != NULL)
tmp = __mempcpy (tmp, module, wp - module);

if (need_ext)
memcpy (tmp - 1, gconv_module_ext, sizeof (gconv_module_ext));

if (__tfind (new_module, modules, module_compare) == NULL)
if (__tsearch (new_module, modules, module_compare) == NULL)
/* Something went wrong while inserting the new module. */
free (new_module);
Expand All @@ -267,7 +281,7 @@ static void
insert_module (const void *nodep, VISIT value, int level)
{
if (value == preorder || value == leaf)
__gconv_modules_db[__gconv_nmodules++] = (struct gconv_module *) nodep;
__gconv_modules_db[__gconv_nmodules++] = *(struct gconv_module **) nodep;
}

static void
Expand Down Expand Up @@ -302,8 +316,6 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
break;

rp = line;
while (isspace (*rp))
++rp;
/* Terminate the line (excluding comments or newline) by an NUL byte
to simplify the following code. */
endp = strchr (rp, '#');
Expand All @@ -316,6 +328,9 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
*endp = '\0';
}

while (isspace (*rp))
++rp;

/* If this is an empty line go on with the next one. */
if (rp == endp)
continue;
Expand All @@ -325,10 +340,10 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
++rp;

if (rp - word == sizeof ("alias") - 1
&& memcpy (word, "alias", sizeof ("alias") - 1) == 0)
&& memcmp (word, "alias", sizeof ("alias") - 1) == 0)
add_alias (rp);
else if (rp - word == sizeof ("module") - 1
&& memcpy (word, "module", sizeof ("module") - 1) == 0)
&& memcmp (word, "module", sizeof ("module") - 1) == 0)
add_module (rp, directory, dir_len, modules, nmodules);
/* else */
/* Otherwise ignore the line. */
Expand All @@ -349,6 +364,7 @@ __gconv_read_conf (void)
char *gconv_path, *elem;
void *modules = NULL;
size_t nmodules = 0;
int save_errno = errno;

if (user_path == NULL)
/* No user-defined path. Make a modifiable copy of the default path. */
Expand Down Expand Up @@ -390,31 +406,31 @@ __gconv_read_conf (void)

/* If the configuration files do not contain any valid module specification
remember this by setting the pointer to the module array to NULL. */
nmodules = sizeof (builtin_modules) / sizeof (struct gconv_module);
nmodules += sizeof (builtin_modules) / sizeof (builtin_modules[0]);
if (nmodules == 0)
__gconv_modules_db = NULL;
else
{
__gconv_modules_db = NULL;
return;
}
__gconv_modules_db =
(struct gconv_module **) malloc (nmodules
* sizeof (struct gconv_module));
if (__gconv_modules_db != NULL)
{
size_t cnt;

__gconv_modules_db =
(struct gconv_module **) malloc (nmodules * sizeof (struct gconv_module));
if (__gconv_modules_db == NULL)
/* We cannot do anything. */
return;
/* Insert all module entries into the array. */
__twalk (modules, insert_module);

/* First insert the builtin transformations. */
while (__gconv_nmodules < (sizeof (builtin_modules)
/ sizeof (struct gconv_module)))
{
__gconv_modules_db[__gconv_nmodules] =
&builtin_modules[__gconv_nmodules];
++__gconv_nmodules;
}
/* No remove the tree data structure. */
__tdestroy (modules, nothing);

/* Insert all module entries into the array. */
__twalk (modules, insert_module);
/* Finally insert the builtin transformations. */
for (cnt = 0; cnt < (sizeof (builtin_modules)
/ sizeof (struct gconv_module)); ++cnt)
__gconv_modules_db[__gconv_nmodules++] = &builtin_modules[cnt];
}
}

/* No remove the tree data structure. */
__tdestroy (modules, nothing);
/* Restore the error number. */
__set_errno (save_errno);
}

0 comments on commit e34b0f2

Please sign in to comment.