From 4a33c2f55eab04206e22ab972a77f62486fe5a97 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 13 Sep 1999 09:07:36 +0000 Subject: Update. 1999-09-13 Ulrich Drepper * locale/langinfo.h: Remove byte-order dependent names. * locale/categories.def: Update after removal of byte-order dependent names. * locale/loadlocale.c (_nl_load_locale): Don't allow locale files with magic number in other byte order. * locale/newlocale.c (__newlocale): Remove byte-order dependent code. * locale/C-collate.c: Remove initializers for other byte-order. * locale/C-ctype.c: Likewise. * locale/C-monetary.c: Likewise. * locale/C-paper.c: Likewise. * locale/C-time.c: Likewise. * locale/lc-collate.c: Remove byte-order oriented initialization. * locale/lc-ctype.c: Likewise. * locale/lc-monetary.c: Likewise. * locale/lc-time.c: Likewise. * locale/programs/ld-address.c: Don't generate output in both byte-orders. * locale/programs/ld-ctype.c: Likewise. * locale/programs/ld-paper.c: Likewise. * locale/programs/ld-time.c: Likewise. * time/strftime.c (NLW): Don't use different byte-orders. * wctype/cname-lookup.h (cname_lookup): Likewise. * Makeconfig (localedir): Define using libdir, not datadir. (msgcatdir): New variable. * catgets/Makefile (CPPFLAGS): Define NLSPATH using msgcatdir. * elf/Makefile (bash-ldd-rewrite): Replace @TEXTDOMAINDIR@ using msgcatdir. * intl/Makefile (install-others): Install locale.alias in msgcatdir. (CPPFLAGS): Define paths using msgcatdir. * locale/Makefile (CPPFLAGS): Define LOCALE_ALIAS_PATH using msgcatdir. * po/Makefile (mo-installed): Define using msgcatdir. * sysdeps/unix/sysv/linux/net/if_arp.h: Fix typo. --- locale/loadlocale.c | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) (limited to 'locale/loadlocale.c') diff --git a/locale/loadlocale.c b/locale/loadlocale.c index 121798782e..d829309f9f 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -18,7 +18,6 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include #include #include #include @@ -70,15 +69,8 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) struct stat st; struct locale_data *newdata; int save_err; - int swap = 0; int mmaped = 1; size_t cnt; - inline unsigned int SWAP (const unsigned int *inw) - { - if (!swap) - return *inw; - return bswap_32 (*inw); - } file->decided = 1; file->data = NULL; @@ -164,28 +156,18 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) /* This cannot be a locale data file since it's too small. */ goto puntfd; - if (filedata->magic == LIMAGIC (category)) - /* Good data file in our byte order. */ - swap = 0; - else + if (filedata->magic != LIMAGIC (category)) + /* Bad data file in either byte order. */ { - /* Try the other byte order. */ - swap = 1; - if (SWAP (&filedata->magic) != LIMAGIC (category)) - /* Bad data file in either byte order. */ - { - puntmap: - __munmap ((caddr_t) filedata, st.st_size); - puntfd: - __close (fd); - return; - } + puntmap: + __munmap ((caddr_t) filedata, st.st_size); + puntfd: + __close (fd); + return; } -#define W(word) SWAP (&(word)) - - if (W (filedata->nstrings) < _nl_category_num_items[category] || - (sizeof *filedata + W (filedata->nstrings) * sizeof (unsigned int) + if (filedata->nstrings < _nl_category_num_items[category] || + (sizeof *filedata + filedata->nstrings * sizeof (unsigned int) >= (size_t) st.st_size)) { /* Insufficient data. */ @@ -207,7 +189,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) newdata->nstrings = _nl_category_num_items[category]; for (cnt = 0; cnt < newdata->nstrings; ++cnt) { - off_t idx = W (filedata->strindex[cnt]); + off_t idx = filedata->strindex[cnt]; if (idx >= newdata->filesize) { free (newdata); @@ -215,8 +197,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) goto puntmap; } if (_nl_value_types[category][cnt] == word) - newdata->values[cnt].word = W (*((u_int32_t *) (newdata->filedata - + idx))); + newdata->values[cnt].word = *((u_int32_t *) (newdata->filedata + idx)); else newdata->values[cnt].string = newdata->filedata + idx; } -- cgit v1.2.3