SHA256
1
0
forked from pool/coreutils
coreutils/i18n-limfield.diff

99 lines
2.7 KiB
Diff

--- src/sort.c
+++ src/sort.c
@@ -1627,7 +1627,7 @@ limfield_mb (const struct line *line, co
GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state);
ptr += mblength;
}
- if (ptr < lim)
+ if (ptr < lim && (eword | echar))
{
GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state);
ptr += mblength;
@@ -1638,11 +1638,6 @@ limfield_mb (const struct line *line, co
{
while (ptr < lim && ismbblank (ptr, &mblength))
ptr += mblength;
- if (ptr < lim)
- {
- GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state);
- ptr += mblength;
- }
while (ptr < lim && !ismbblank (ptr, &mblength))
ptr += mblength;
}
@@ -1652,20 +1647,19 @@ limfield_mb (const struct line *line, co
/* Make LIM point to the end of (one byte past) the current field. */
if (tab != NULL)
{
- char *newlim, *p;
+ char *newlim;
- newlim = NULL;
- for (p = ptr; p < lim;)
- {
- if (memcmp (p, tab, tab_length) == 0)
- {
- newlim = p;
- break;
- }
-
- GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state);
- p += mblength;
- }
+ for (newlim = ptr; newlim < lim;)
+ {
+ if (memcmp (newlim, tab, tab_length) == 0)
+ {
+ lim = newlim;
+ break;
+ }
+
+ GET_BYTELEN_OF_CHAR (lim, newlim, mblength, state);
+ newlim += mblength;
+ }
}
else
{
@@ -1674,24 +1668,20 @@ limfield_mb (const struct line *line, co
while (newlim < lim && ismbblank (newlim, &mblength))
newlim += mblength;
- if (ptr < lim)
- {
- GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state);
- ptr += mblength;
- }
while (newlim < lim && !ismbblank (newlim, &mblength))
- newlim += mblength;
+ newlim += mblength;
lim = newlim;
}
# endif
- /* If we're skipping leading blanks, don't start counting characters
- until after skipping past any leading blanks. */
+ /* If we're ignoring leading blanks when computing the End
+ of the field, don't start counting bytes until after skipping
+ past any leading blanks. */
if (key->skipeblanks)
while (ptr < lim && ismbblank (ptr, &mblength))
ptr += mblength;
- memset (&state, '\0', sizeof(mbstate_t));
+ memset (&state, '\0', sizeof (mbstate_t));
/* Advance PTR by ECHAR (if possible), but no further than LIM. */
for (i = 0; i < echar; i++)
@@ -1699,9 +1689,9 @@ limfield_mb (const struct line *line, co
GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state);
if (ptr + mblength > lim)
- break;
+ break;
else
- ptr += mblength;
+ ptr += mblength;
}
return ptr;