diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index 1a4b8ff..f14a4ba 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -14,7 +14,7 @@ Subject: [PATCH] coreutils-i18n.patch src/expand-common.c | 114 ++++++ src/expand-common.h | 12 + src/expand.c | 90 ++++- - src/fold.c | 309 +++++++++++++-- + src/fold.c | 312 +++++++++++++-- src/join.c | 359 ++++++++++++++--- src/local.mk | 4 +- src/pr.c | 443 +++++++++++++++++++-- @@ -35,7 +35,7 @@ Subject: [PATCH] coreutils-i18n.patch tests/misc/uniq.pl | 55 +++ tests/pr/pr-tests.pl | 49 +++ tests/unexpand/mb.sh | 172 ++++++++ - 31 files changed, 3637 insertions(+), 213 deletions(-) + 31 files changed, 3640 insertions(+), 213 deletions(-) create mode 100644 lib/mbfile.c create mode 100644 lib/mbfile.h create mode 100644 m4/mbfile.m4 @@ -545,7 +545,7 @@ index cdf33d8..b8301d7 100644 +static void +cut_characters_or_cut_bytes_no_split (FILE *stream) +{ -+ uintmax_t idx; /* number of bytes or characters in the line so far. */ ++ uintmax_t idx; /* number of bytes or characters in the line so far. */ + char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ + char *bufpos; /* Next read position of BUF. */ + size_t buflen; /* The length of the byte sequence in buf. */ @@ -1412,7 +1412,7 @@ index 94a6d37..a278783 100644 /* Look for the last blank. */ while (logical_end) { -@@ -215,13 +252,222 @@ fold_file (char const *filename, size_t width) +@@ -215,13 +252,225 @@ fold_file (char const *filename, size_t width) line_out[offset_out++] = c; } @@ -1510,38 +1510,39 @@ index 94a6d37..a278783 100644 + } + +rescan: -+ if (convfail) -+ increment = 1; -+ else if (wc == L'\n') -+ { -+ /* preserve newline */ -+ fwrite (line_out, sizeof(char), offset_out, stdout); -+ START_NEW_LINE; -+ continue; -+ } -+ else if (operating_mode == byte_mode) /* byte mode */ ++ if (operating_mode == byte_mode) /* byte mode */ + increment = mblength; + else if (operating_mode == character_mode) /* character mode */ + increment = 1; -+ else /* column mode */ ++ else /* column mode */ + { -+ switch (wc) ++ if (convfail) ++ increment = 1; ++ else + { -+ case L'\b': -+ increment = (column > 0) ? -1 : 0; -+ break; ++ switch (wc) ++ { ++ case L'\n': ++ fwrite (line_out, sizeof(char), offset_out, stdout); ++ START_NEW_LINE; ++ continue; + -+ case L'\r': -+ increment = -1 * column; -+ break; ++ case L'\b': ++ increment = (column > 0) ? -1 : 0; ++ break; + -+ case L'\t': -+ increment = 8 - column % 8; -+ break; ++ case L'\r': ++ increment = -1 * column; ++ break; + -+ default: -+ increment = wcwidth (wc); -+ increment = (increment < 0) ? 0 : increment; ++ case L'\t': ++ increment = 8 - column % 8; ++ break; ++ ++ default: ++ increment = wcwidth (wc); ++ increment = (increment < 0) ? 0 : increment; ++ } + } + } + @@ -1595,6 +1596,8 @@ index 94a6d37..a278783 100644 + } + + *saved_errno = errno; ++ if (!ferror (istream)) ++ *saved_errno = 0; + + if (offset_out) + fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); @@ -1637,7 +1640,7 @@ index 94a6d37..a278783 100644 if (STREQ (filename, "-")) clearerr (istream); else if (fclose (istream) != 0 && !saved_errno) -@@ -252,7 +498,8 @@ main (int argc, char **argv) +@@ -252,7 +501,8 @@ main (int argc, char **argv) atexit (close_stdout); @@ -1647,7 +1650,7 @@ index 94a6d37..a278783 100644 while ((optc = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1) { -@@ -261,7 +508,15 @@ main (int argc, char **argv) +@@ -261,7 +511,15 @@ main (int argc, char **argv) switch (optc) { case 'b': /* Count bytes rather than columns. */ @@ -3299,7 +3302,7 @@ index 5f4c817..bd9c672 100644 } +#if HAVE_MBRTOWC -+static char * ++static char * _GL_ATTRIBUTE_PURE +limfield_mb (const struct line *line, const struct keyfield *key) +{ + char *ptr = line->text, *lim = ptr + line->length - 1;