rpms/coreutils/devel coreutils-i18n-sort.patch, NONE, 1.1 coreutils.spec, 1.88, 1.89
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Fri Oct 28 11:29:41 UTC 2005
Author: twaugh
Update of /cvs/dist/rpms/coreutils/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv19881
Modified Files:
coreutils.spec
Added Files:
coreutils-i18n-sort.patch
Log Message:
* Fri Oct 28 2005 Tim Waugh <twaugh at redhat.com>
- Start porting i18n patch to sort.c.
coreutils-i18n-sort.patch:
sort.c | 61 ++++++++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 44 insertions(+), 17 deletions(-)
--- NEW FILE coreutils-i18n-sort.patch ---
--- coreutils-5.92/src/sort.c.i18n-sort 2005-10-07 20:16:56.000000000 +0100
+++ coreutils-5.92/src/sort.c 2005-10-28 12:10:07.000000000 +0100
@@ -26,6 +26,10 @@
#include <getopt.h>
#include <sys/types.h>
#include <signal.h>
+#if HAVE_WCHAR_H
+# include <wchar.h>
+#endif
+
#include "system.h"
#include "error.h"
#include "hard-locale.h"
@@ -239,13 +243,11 @@
they were read if all keys compare equal. */
static bool stable;
-/* If TAB has this value, blanks separate fields. */
-enum { TAB_DEFAULT = CHAR_MAX + 1 };
-
-/* Tab character separating fields. If TAB_DEFAULT, then fields are
+/* Tab character separating fields. If tab_length is 0, then fields are
separated by the empty string between a non-blank character and a blank
character. */
-static int tab = TAB_DEFAULT;
+static char tab[MB_LEN_MAX + 1];
+static size_t tab_length = 0;
/* Flag to remove consecutive duplicate lines from the output.
Only the last of a sequence of equal lines will be output. */
@@ -818,10 +820,10 @@
/* The leading field separator itself is included in a field when -t
is absent. */
- if (tab != TAB_DEFAULT)
+ if (tab_length)
while (ptr < lim && sword--)
{
- while (ptr < lim && *ptr != tab)
+ while (ptr < lim && *ptr != tab[0])
++ptr;
if (ptr < lim)
++ptr;
@@ -866,10 +868,10 @@
`beginning' is the first character following the delimiting TAB.
Otherwise, leave PTR pointing at the first `blank' character after
the preceding field. */
- if (tab != TAB_DEFAULT)
+ if (tab_length)
while (ptr < lim && eword--)
{
- while (ptr < lim && *ptr != tab)
+ while (ptr < lim && *ptr != tab[0])
++ptr;
if (ptr < lim && (eword | echar))
++ptr;
@@ -915,10 +917,10 @@
*/
/* Make LIM point to the end of (one byte past) the current field. */
- if (tab != TAB_DEFAULT)
+ if (tab_length)
{
char *newlim;
- newlim = memchr (ptr, tab, lim - ptr);
+ newlim = memchr (ptr, tab[0], lim - ptr);
if (newlim)
lim = newlim;
}
@@ -2349,13 +2351,35 @@
case 't':
{
- char newtab = optarg[0];
- if (! newtab)
+ char newtab[MB_LEN_MAX + 1];
+ size_t newtab_length = 1;
+ strncpy (newtab, optarg, MB_LEN_MAX);
+ if (! newtab[0])
error (SORT_FAILURE, 0, _("empty tab"));
- if (optarg[1])
+#if HAVE_MBRTOWC
+ if (MB_CUR_MAX > 1)
+ {
+ wchar_t wc;
+ mbstate_t state;
+ size_t i;
+
+ memset (&state, '\0', sizeof (mbstate_t));
+ newtab_length = mbrtowc (&wc, newtab, strnlen (newtab,
+ MB_LEN_MAX),
+ &state);
+ switch (newtab_length)
+ {
+ case (size_t) -1:
+ case (size_t) -2:
+ case 0:
+ newtab_length = 1;
+ }
+ }
+#endif
+ if (newtab_length == 1 && optarg[1])
{
if (STREQ (optarg, "\\0"))
- newtab = '\0';
+ newtab[0] = '\0';
else
{
/* Provoke with `sort -txx'. Complain about
@@ -2366,9 +2390,12 @@
quote (optarg));
}
}
- if (tab != TAB_DEFAULT && tab != newtab)
+ if (tab_length
+ && (tab_length != newtab_length
+ || memcmp (tab, newtab, tab_length) != 0))
error (SORT_FAILURE, 0, _("incompatible tabs"));
- tab = newtab;
+ memcpy (tab, newtab, newtab_length);
+ tab_length = newtab_length;
}
break;
Index: coreutils.spec
===================================================================
RCS file: /cvs/dist/rpms/coreutils/devel/coreutils.spec,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- coreutils.spec 28 Oct 2005 08:58:13 -0000 1.88
+++ coreutils.spec 28 Oct 2005 11:29:37 -0000 1.89
@@ -38,6 +38,7 @@
# (sb) lin18nux/lsb compliance
Patch800: coreutils-i18n.patch
+Patch801: coreutils-i18n-sort.patch
Patch907: coreutils-5.2.1-runuser.patch
Patch908: coreutils-getgrouplist.patch
@@ -91,6 +92,7 @@
# li18nux/lsb
%patch800 -p1 -b .i18n
+%patch801 -p1 -b .i18n-sort
# Coreutils
%patch907 -p1 -b .runuser
@@ -262,6 +264,9 @@
/sbin/runuser
%changelog
+* Fri Oct 28 2005 Tim Waugh <twaugh at redhat.com>
+- Start porting i18n patch to sort.c.
+
* Fri Oct 28 2005 Tim Waugh <twaugh at redhat.com> 5.92-0.2
- Fix chgrp basic test.
- Include md5sum patch from ALT.
More information about the fedora-cvs-commits
mailing list