This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] nm: sort according to collating order of current locale
- From: Mitsuru Chinen <mchinen at yamato dot ibm dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 19 Jun 2002 18:51:57 +0900
- Subject: [PATCH] nm: sort according to collating order of current locale
- Organization: IBM Japan, Ltd.
Dear sirs,
IEEE 1003.1-2001 says that nm sorts an output according to the collating
order of the current locale.
This patch fixed the sorting order of nm.
2002-06-19 Mitsru Chinen <chinen@jp.ibm.com>
* gettext.m4: Add strcoll to AC_CHECK_FUNCS.
* binutils/nm.c (main): Add setting of the locale domain to LC_COLLATE.
(non_numeric_forward): Sort the symbols according to the collating
order of the current locale.
Would you please read my patch and take in it if you think it is applicable?
Regards,
------
Mitsuru Chinen
// AP Linux Competency Center, Yamato Software Lab., SWG, IBM;
diff -upr binutils-020617.orig/binutils/nm.c binutils-020617/binutils/nm.c
--- binutils-020617.orig/binutils/nm.c Wed Jun 19 15:58:58 2002
+++ binutils-020617/binutils/nm.c Wed Jun 19 15:59:50 2002
@@ -351,6 +351,7 @@ main (argc, argv)
#endif
#if defined (HAVE_SETLOCALE)
setlocale (LC_CTYPE, "");
+ setlocale (LC_COLLATE, "");
#endif
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
@@ -658,6 +659,7 @@ non_numeric_forward (P_x, P_y)
{
asymbol *x, *y;
const char *xn, *yn;
+ int (*compare_string) (const char *s1, const char *s2);
x = bfd_minisymbol_to_symbol (sort_bfd, sort_dynamic, P_x, sort_x);
y = bfd_minisymbol_to_symbol (sort_bfd, sort_dynamic, P_y, sort_y);
@@ -667,8 +669,13 @@ non_numeric_forward (P_x, P_y)
xn = bfd_asymbol_name (x);
yn = bfd_asymbol_name (y);
+ compare_string = strcmp;
+#ifdef HAVE_STRCOLL
+ if (MB_CUR_MAX > 1)
+ compare_string = strcoll;
+#endif
return ((xn == NULL) ? ((yn == NULL) ? 0 : -1) :
- ((yn == NULL) ? 1 : strcmp (xn, yn)));
+ ((yn == NULL) ? 1 : compare_string (xn, yn)));
}
static int
diff -upr binutils-020617.orig/gettext.m4 binutils-020617/gettext.m4
--- binutils-020617.orig/gettext.m4 Wed Jun 19 15:58:58 2002
+++ binutils-020617/gettext.m4 Wed Jun 19 15:59:29 2002
@@ -174,7 +174,7 @@ AC_DEFUN(CY_GNU_GETTEXT,
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
unistd.h values.h sys/param.h])
AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
-__argz_count __argz_stringify __argz_next])
+strcoll __argz_count __argz_stringify __argz_next])
if test "${ac_cv_func_stpcpy+set}" != "set"; then
AC_CHECK_FUNCS(stpcpy)