From: Ulrich Drepper Date: Tue, 15 Aug 2000 06:12:25 +0000 (+0000) Subject: Update. X-Git-Tag: upstream/2.30~24853 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b8fd550293431d4df42b281fc868ef0ab80e822b;p=external%2Fglibc.git Update. * sysdeps/posix/ttyname.c: Make name variable from getttyname function global (with file scope). Add __libc_subfreeres function to free the string. * sysdeps/unix/sysv/linux/ttyname.c: Likewise. Also for buf variable in ttyname function. * sysdeps/generic/strtok.c: Remove initializer for olds variable. * crypt/md5-crypt.c: Let destructor deallocate static buffer. * iconvdata/sjis.c (from_ucs4_lat1): Handle U005C and U007E by mapping them to /x5c and /x7e respectively. --- diff --git a/ChangeLog b/ChangeLog index ce0fc36..8fcc19e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2000-08-14 Ulrich Drepper + * sysdeps/posix/ttyname.c: Make name variable from getttyname function + global (with file scope). Add __libc_subfreeres function to free the + string. + * sysdeps/unix/sysv/linux/ttyname.c: Likewise. Also for buf variable + in ttyname function. + + * sysdeps/generic/strtok.c: Remove initializer for olds variable. + + * crypt/md5-crypt.c: Let destructor deallocate static buffer. + + * iconvdata/sjis.c (from_ucs4_lat1): Handle U005C and U007E by + mapping them to /x5c and /x7e respectively. + * locale/programs/ld-ctype.c: Add support for more definitions after copy statement. diff --git a/crypt/md5-crypt.c b/crypt/md5-crypt.c index e99f8ca..66eda28 100644 --- a/crypt/md5-crypt.c +++ b/crypt/md5-crypt.c @@ -234,14 +234,15 @@ __md5_crypt_r (key, salt, buffer, buflen) } +static char *buffer; + char * __md5_crypt (const char *key, const char *salt) { /* We don't want to have an arbitrary limit in the size of the password. We can compute the size of the result in advance and so we can prepare the buffer we pass to `md5_crypt_r'. */ - static char *buffer = NULL; - static int buflen = 0; + static int buflen; int needed = 3 + strlen (salt) + 1 + 26 + 1; if (buflen < needed) @@ -253,3 +254,11 @@ __md5_crypt (const char *key, const char *salt) return __md5_crypt_r (key, salt, buffer, buflen); } + + +static void +__attribute__ ((__constructor__)) +free_mem (void) +{ + free (buffer); +} diff --git a/iconvdata/sjis.c b/iconvdata/sjis.c index 60d1e28..8d907b8 100644 --- a/iconvdata/sjis.c +++ b/iconvdata/sjis.c @@ -1891,6 +1891,11 @@ static const uint16_t cjk_block4[2021] = The only problem is that the shiftjis.txt file does not contain the mapping for the characters 0x00 to 0x1f. We add them ourself. + + A much bigger problem is that mapping of the tilde and the backslash + character. There are no such characters in SJIS. The proposed + handling is to simply map the two input values to the corresponding + byte values of ASCII. Things fall more or less in place this way. */ static const char from_ucs4_lat1[0xf8][2] = { @@ -1924,7 +1929,7 @@ static const char from_ucs4_lat1[0xf8][2] = [0x0051] = "\x51\x00", [0x0052] = "\x52\x00", [0x0053] = "\x53\x00", [0x0054] = "\x54\x00", [0x0055] = "\x55\x00", [0x0056] = "\x56\x00", [0x0057] = "\x57\x00", [0x0058] = "\x58\x00", [0x0059] = "\x59\x00", - [0x005a] = "\x5a\x00", [0x005b] = "\x5b\x00", [0x005c] = "\x81\x5c", + [0x005a] = "\x5a\x00", [0x005b] = "\x5b\x00", [0x005c] = "\x5c\x00", [0x005d] = "\x5d\x00", [0x005e] = "\x5e\x00", [0x005f] = "\x5f\x00", [0x0060] = "\x60\x00", [0x0061] = "\x61\x00", [0x0062] = "\x62\x00", [0x0063] = "\x63\x00", [0x0064] = "\x64\x00", [0x0065] = "\x65\x00", @@ -1936,7 +1941,7 @@ static const char from_ucs4_lat1[0xf8][2] = [0x0075] = "\x75\x00", [0x0076] = "\x76\x00", [0x0077] = "\x77\x00", [0x0078] = "\x78\x00", [0x0079] = "\x79\x00", [0x007a] = "\x7a\x00", [0x007b] = "\x7b\x00", [0x007c] = "\x7c\x00", [0x007d] = "\x7d\x00", - [0x007e] = "\x00\x00", + [0x007e] = "\x7e\x00", [0x00a2] = "\x81\x91", [0x00a3] = "\x81\x92", [0x00a5] = "\x5c\x00", [0x00a7] = "\x81\x98", [0x00a8] = "\x81\x4e", [0x00ac] = "\x81\xca", [0x00b0] = "\x81\x8b", [0x00b1] = "\x81\x7d", [0x00b4] = "\x81\x4c", @@ -4388,8 +4393,7 @@ static const char from_ucs4_extra[0x100][2] = \ ch2 = inptr[1]; \ idx = ch * 256 + ch2; \ - if (__builtin_expect (ch < 0x81, 0) \ - || __builtin_expect (ch2 < 0x40, 0) \ + if (__builtin_expect (ch2 < 0x40, 0) \ || (__builtin_expect (idx, 0x8140) > 0x84be && idx < 0x889f) \ || (__builtin_expect (idx, 0x8140) > 0x88fc && idx < 0x8940) \ || (__builtin_expect (idx, 0x8140) > 0x9ffc && idx < 0xe040) \ diff --git a/localedata/locales/iso14651_t1 b/localedata/locales/iso14651_t1 index a9468d2..6a41e8b 100644 --- a/localedata/locales/iso14651_t1 +++ b/localedata/locales/iso14651_t1 @@ -1276,196 +1276,196 @@ order_start ;forward;forward;forward;forward,position order_start ;forward;backward;forward;forward,position ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE # digamma copte ;;;IGNORE - ;;;IGNORE ;;;IGNORE # GANGIA COPTE - ;;;IGNORE # gangia copte ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE # HORI COPTE - ;;;IGNORE # hori copte ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # koppa copte + ;;;IGNORE # KHEI COPTE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # STIGMA ARCH. + ;;;IGNORE # SHIMA COPTE + ;;;IGNORE + ;;;IGNORE # DEI COPTE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # FEI COPTE + ;;;IGNORE + ;;;IGNORE # sampi copte + ;;;IGNORE + ;;;IGNORE # SHEI COPTE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # gangia copte + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE # hori copte + ;;;IGNORE + ;;;IGNORE ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE # yot - ;;;IGNORE ;;;IGNORE - ;;;IGNORE # koppa copte ;;;IGNORE - ;;;IGNORE # KHEI COPTE ;;;IGNORE # khei copte - ;;;IGNORE - ;;;IGNORE - ;;;IGNORE + ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE ;;;IGNORE - ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE ;;;IGNORE - ;;;IGNORE # STIGMA ARCH. - ;;;IGNORE # SHIMA COPTE ;;;IGNORE # shima copte ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE # DEI COPTE ;;;IGNORE # dei copte - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE ;;;IGNORE - ;;;IGNORE - ;;;IGNORE - ;;;IGNORE - ;;;IGNORE ;;;IGNORE ;;;IGNORE - ;;;IGNORE # FEI COPTE ;;;IGNORE # fei copte - ;;;IGNORE ;;;IGNORE - ;;;IGNORE # sampi copte - ;;;IGNORE ;;;IGNORE - ;;;IGNORE # SHEI COPTE ;;;IGNORE # shei copte - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE order_start ;forward;forward;forward;forward,position ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE - ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE + ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE - ;;;IGNORE ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE + ;;;IGNORE ;;;IGNORE # order_start ;forward;forward;forward;forward,position diff --git a/sysdeps/generic/strtok.c b/sysdeps/generic/strtok.c index 6aeeb5a..b6f9523 100644 --- a/sysdeps/generic/strtok.c +++ b/sysdeps/generic/strtok.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1996, 1997, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1996, 1997, 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -19,7 +19,7 @@ #include -static char *olds = NULL; +static char *olds; #undef strtok diff --git a/sysdeps/posix/ttyname.c b/sysdeps/posix/ttyname.c index a865ded..fe132a3 100644 --- a/sysdeps/posix/ttyname.c +++ b/sysdeps/posix/ttyname.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 92, 93, 96, 97, 98 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 96, 97, 98, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -26,10 +26,13 @@ #include #include -char *__ttyname = NULL; +char *__ttyname; -static char * getttyname __P ((int fd, dev_t mydev, ino_t myino, - int save, int *dostat)) internal_function; +static char *getttyname (int fd, dev_t mydev, ino_t myino, + int save, int *dostat) internal_function; + + +static char *getttyname_name; static char * internal_function @@ -41,8 +44,7 @@ getttyname (fd, mydev, myino, save, dostat) int *dostat; { static const char dev[] = "/dev"; - static char *name; - static size_t namelen = 0; + static size_t namelen; struct stat st; DIR *dirstream; struct dirent *d; @@ -63,20 +65,21 @@ getttyname (fd, mydev, myino, save, dostat) size_t dlen = _D_ALLOC_NAMLEN (d); if (sizeof (dev) + dlen > namelen) { - free (name); + free (getttyname_name); namelen = 2 * (sizeof (dev) + dlen); /* Big enough. */ - name = malloc (namelen); - if (! name) + getttyname_name = malloc (namelen); + if (! getttyname_name) { *dostat = -1; /* Perhaps it helps to free the directory stream buffer. */ (void) __closedir (dirstream); return NULL; } - *((char *) __mempcpy (name, dev, sizeof (dev) - 1)) = '/'; + *((char *) __mempcpy (getttyname_name, dev, sizeof (dev) - 1)) + = '/'; } - (void) __mempcpy (&name[sizeof (dev)], d->d_name, dlen); - if (stat (name, &st) == 0 + (void) __mempcpy (&getttyname_name[sizeof (dev)], d->d_name, dlen); + if (stat (getttyname_name, &st) == 0 #ifdef _STATBUF_ST_RDEV && S_ISCHR (st.st_mode) && st.st_rdev == mydev #else @@ -85,9 +88,9 @@ getttyname (fd, mydev, myino, save, dostat) ) { (void) __closedir (dirstream); - __ttyname = name; + __ttyname = getttyname_name; __set_errno (save); - return name; + return getttyname_name; } } @@ -131,3 +134,11 @@ ttyname (fd) return name; } + + +static void +free_mem (void) +{ + free (getttyname_name); +} +text_set_element (__libc_subfreeres, free_mem); diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c index 33587a3..0973925 100644 --- a/sysdeps/unix/sysv/linux/ttyname.c +++ b/sysdeps/unix/sysv/linux/ttyname.c @@ -30,15 +30,17 @@ char *__ttyname; -static char * getttyname (const char *dev, dev_t mydev, - ino_t myino, int save, int *dostat) +static char *getttyname (const char *dev, dev_t mydev, + ino_t myino, int save, int *dostat) internal_function; + +static char *getttyname_name; + static char * internal_function getttyname (const char *dev, dev_t mydev, ino_t myino, int save, int *dostat) { - static char *name; static size_t namelen; struct stat st; DIR *dirstream; @@ -61,20 +63,20 @@ getttyname (const char *dev, dev_t mydev, ino_t myino, int save, int *dostat) size_t dlen = _D_ALLOC_NAMLEN (d); if (devlen + dlen > namelen) { - free (name); + free (getttyname_name); namelen = 2 * (devlen + dlen); /* Big enough. */ - name = malloc (namelen); - if (! name) + getttyname_name = malloc (namelen); + if (! getttyname_name) { *dostat = -1; /* Perhaps it helps to free the directory stream buffer. */ (void) __closedir (dirstream); return NULL; } - *((char *) __mempcpy (name, dev, devlen - 1)) = '/'; + *((char *) __mempcpy (getttyname_name, dev, devlen - 1)) = '/'; } - memcpy (&name[devlen], d->d_name, dlen); - if (__xstat (_STAT_VER, name, &st) == 0 + memcpy (&getttyname_name[devlen], d->d_name, dlen); + if (__xstat (_STAT_VER, getttyname_name, &st) == 0 #ifdef _STATBUF_ST_RDEV && S_ISCHR (st.st_mode) && st.st_rdev == mydev #else @@ -83,9 +85,9 @@ getttyname (const char *dev, dev_t mydev, ino_t myino, int save, int *dostat) ) { (void) __closedir (dirstream); - __ttyname = name; + __ttyname = getttyname_name; __set_errno (save); - return name; + return getttyname_name; } } @@ -94,12 +96,16 @@ getttyname (const char *dev, dev_t mydev, ino_t myino, int save, int *dostat) return NULL; } + +/* Static buffer in `ttyname'. */ +static char *ttyname_buf; + + /* Return the pathname of the terminal FD is open on, or NULL on errors. The returned storage is good only until the next call to this function. */ char * ttyname (int fd) { - static char *buf; static size_t buflen; char procname[30]; struct stat st, st1; @@ -117,24 +123,24 @@ ttyname (int fd) if (buflen == 0) { buflen = 4095; - buf = (char *) malloc (buflen + 1); - if (buf == NULL) + ttyname_buf = (char *) malloc (buflen + 1); + if (ttyname_buf == NULL) { buflen = 0; return NULL; } } - len = __readlink (procname, buf, buflen); + len = __readlink (procname, ttyname_buf, buflen); if (len != -1 /* This is for Linux 2.0. */ - && buf[0] != '[') + && ttyname_buf[0] != '[') { if (len >= buflen) return NULL; /* readlink need not terminate the string. */ - buf[len] = '\0'; - return buf; + ttyname_buf[len] = '\0'; + return ttyname_buf; } if (__fxstat (_STAT_VER, fd, &st) < 0) @@ -175,3 +181,12 @@ ttyname (int fd) return name; } + + +static void +free_mem (void) +{ + free (ttyname_buf); + free (getttyname_name); +} +text_set_element (__libc_subfreeres, free_mem);