fix the SUSE fix for cut output-delimiter

This commit is contained in:
Ondřej Vašík 2011-09-09 14:53:00 +02:00
commit fbca36cbd7
2 changed files with 41 additions and 15 deletions

View File

@ -226,7 +226,7 @@ diff -urNp coreutils-8.13-orig/src/cut.c coreutils-8.13/src/cut.c
} }
max_range_endpoint = 0; max_range_endpoint = 0;
@@ -582,6 +664,63 @@ cut_bytes (FILE *stream) @@ -582,6 +664,77 @@ cut_bytes (FILE *stream)
} }
} }
@ -251,6 +251,9 @@ diff -urNp coreutils-8.13-orig/src/cut.c coreutils-8.13/src/cut.c
+ as same character as WC. */ + as same character as WC. */
+ mbstate_t state; /* State of the stream. */ + mbstate_t state; /* State of the stream. */
+ int convfail = 0; /* 1, when conversion is failed. Otherwise 0. */ + int convfail = 0; /* 1, when conversion is failed. Otherwise 0. */
+ /* Whether to begin printing delimiters between ranges for the current line.
+ Set after we've begun printing data corresponding to the first range. */
+ bool print_delimiter = false;
+ +
+ idx = 0; + idx = 0;
+ buflen = 0; + buflen = 0;
@ -273,13 +276,24 @@ diff -urNp coreutils-8.13-orig/src/cut.c coreutils-8.13/src/cut.c
+ { + {
+ putchar ('\n'); + putchar ('\n');
+ idx = 0; + idx = 0;
+ print_delimiter = false;
+ } + }
+ else + else
+ { + {
+ bool range_start;
+ bool *rs = output_delimiter_specified ? &range_start : NULL;
+ idx += (operating_mode == byte_mode) ? mblength : 1; + idx += (operating_mode == byte_mode) ? mblength : 1;
+ if (print_kth (idx, NULL)) + if (print_kth (idx, rs))
+ {
+ if (rs && *rs && print_delimiter)
+ {
+ fwrite (output_delimiter_string, sizeof (char),
+ output_delimiter_length, stdout);
+ }
+ print_delimiter = true;
+ fwrite (bufpos, mblength, sizeof(char), stdout); + fwrite (bufpos, mblength, sizeof(char), stdout);
+ } + }
+ }
+ +
+ buflen -= mblength; + buflen -= mblength;
+ bufpos += mblength; + bufpos += mblength;
@ -290,7 +304,7 @@ diff -urNp coreutils-8.13-orig/src/cut.c coreutils-8.13/src/cut.c
/* Read from stream STREAM, printing to standard output any selected fields. */ /* Read from stream STREAM, printing to standard output any selected fields. */
static void static void
@@ -704,13 +843,192 @@ cut_fields (FILE *stream) @@ -704,13 +843,195 @@ cut_fields (FILE *stream)
} }
} }
@ -310,7 +324,7 @@ diff -urNp coreutils-8.13-orig/src/cut.c coreutils-8.13/src/cut.c
+ size_t mblength; /* The byte size of a multibyte character which shows + size_t mblength; /* The byte size of a multibyte character which shows
+ as same character as WC. */ + as same character as WC. */
+ mbstate_t state; /* State of the stream. */ + mbstate_t state; /* State of the stream. */
+ int convfail; /* 1, when conversion is failed. Otherwise 0. */ + int convfail = 0; /* 1, when conversion is failed. Otherwise 0. */
+ +
+ found_any_selected_field = 0; + found_any_selected_field = 0;
+ field_idx = 1; + field_idx = 1;
@ -321,7 +335,10 @@ diff -urNp coreutils-8.13-orig/src/cut.c coreutils-8.13/src/cut.c
+ c = getc (stream); + c = getc (stream);
+ empty_input = (c == EOF); + empty_input = (c == EOF);
+ if (c != EOF) + if (c != EOF)
+ {
+ ungetc (c, stream); + ungetc (c, stream);
+ wc = 0;
+ }
+ else + else
+ wc = WEOF; + wc = WEOF;
+ +
@ -1632,7 +1649,7 @@ diff -urNp coreutils-8.13-orig/src/join.c coreutils-8.13/src/join.c
case 't': case 't':
{ {
- unsigned char newtab = optarg[0]; - unsigned char newtab = optarg[0];
+ char *newtab; + char *newtab = NULL;
+ size_t newtablen; + size_t newtablen;
+ newtab = xstrdup (optarg); + newtab = xstrdup (optarg);
+#if HAVE_MBRTOWC +#if HAVE_MBRTOWC
@ -1654,7 +1671,8 @@ diff -urNp coreutils-8.13-orig/src/join.c coreutils-8.13/src/join.c
+ newtablen = 1; + newtablen = 1;
if (! newtab) if (! newtab)
+ { + {
newtab = '\n'; /* '' => process the whole line. */ - newtab = '\n'; /* '' => process the whole line. */
+ newtab = "\n"; /* '' => process the whole line. */
+ } + }
else if (optarg[1]) else if (optarg[1])
{ {
@ -3085,7 +3103,7 @@ diff -urNp coreutils-8.13-orig/src/sort.c coreutils-8.13/src/sort.c
else if (key->random) else if (key->random)
diff = compare_random (ta, tlena, tb, tlenb); diff = compare_random (ta, tlena, tb, tlenb);
else if (key->version) else if (key->version)
@@ -2632,6 +3066,179 @@ keycompare (struct line const *a, struct @@ -2632,6 +3066,180 @@ keycompare (struct line const *a, struct
return key->reverse ? -diff : diff; return key->reverse ? -diff : diff;
} }
@ -3167,7 +3185,8 @@ diff -urNp coreutils-8.13-orig/src/sort.c coreutils-8.13/src/sort.c
+ if (MBLENGTH == (size_t)-2 || MBLENGTH == (size_t)-1) \ + if (MBLENGTH == (size_t)-2 || MBLENGTH == (size_t)-1) \
+ STATE = state_bak; \ + STATE = state_bak; \
+ if (!ignore) \ + if (!ignore) \
+ COPY[NEW_LEN++] = TEXT[i++]; \ + COPY[NEW_LEN++] = TEXT[i]; \
+ i++; \
+ continue; \ + continue; \
+ } \ + } \
+ \ + \

View File

@ -324,8 +324,15 @@ fi
- new upstream release 8.13 - new upstream release 8.13
- temporarily disable recently added multibyte checks in - temporarily disable recently added multibyte checks in
misc/cut test misc/cut test
- fix the SUSE fix for cut output-delimiter
- drop coreutils-libs subpackage, no longer needed - drop coreutils-libs subpackage, no longer needed
* Mon Sep 05 2011 Ondrej Vasik <ovasik@redhat.com> - 8.12-7
- incorporate some i18n patch fixes from OpenSUSE:
- fix cut output-delimiter option
- prevent infinite loop in sort when ignoring chars
- prevent using unitialized variable in cut
* Tue Aug 23 2011 Ondrej Vasik <ovasik@redhat.com> - 8.12-6 * Tue Aug 23 2011 Ondrej Vasik <ovasik@redhat.com> - 8.12-6
- su: fix shell suspend in tcsh (#597928) - su: fix shell suspend in tcsh (#597928)