mirrored from git://git.sv.gnu.org/coreutils.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
join,uniq: support multi-byte separators
* NEWS: Mention this. * bootstrap.conf (gnulib_modules): Remove cu-ctype, as this module is now more trouble than it’s worth. All uses removed. Add skipchars. * gl/lib/cu-ctype.c, gl/lib/cu-ctype.h, gl/modules/cu-ctype: Remove. * gl/lib/skipchars.c, gl/lib/skipchars.h, gl/modules/skipchars: * tests/misc/join-utf8.sh: New files. * src/join.c: Include skipchars.h and mcel.h instead of cu-ctype.h. (tab): Now mcel_t, not int. All uses changed. (output_separator, output_seplen): New static vars. (eq_tab, newline_or_blank, comma_or_blank): New functions. (xfields, prfields, prjoin, add_field_list, main): Support multi-byte characters. * src/numfmt.c: Include ctype.h, skipchars.h. Do not include cu-ctype.h. (newline_or_blank): New function. (next_field): Support multi-byte characters. * src/sort.c: Include ctype.h instead of cu-ctype.h. (inittables): Open-code field_sep since it no longer exists. ‘sort’ is not multi-byte safe yet, but when it is this code will need revamping anyway. * src/uniq.c: Include mcel.h and skipchars.h instead of cu-ctype.h. (newline_or_blank): New function. (find_field): Support multi-byte characters. * tests/local.mk (all_tests): Add tests/misc/join-utf8.sh
- Loading branch information
Showing
14 changed files
with
244 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include <config.h> | ||
#define SKIPCHARS_INLINE _GL_EXTERN_INLINE | ||
#include <skipchars.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* Skipping sequences of characters satisfying a predicate | ||
Copyright 2023 Free Software Foundation, Inc. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. */ | ||
|
||
#include "mcel.h" | ||
|
||
_GL_INLINE_HEADER_BEGIN | ||
#ifndef SKIPCHARS_INLINE | ||
# define SKIPCHARS_INLINE _GL_INLINE | ||
#endif | ||
|
||
/* Return the address just past the leading sequence of possibly | ||
multi-byte characters or encoding errors G in STR that satisfy | ||
PREDICATE (G) if OK is true, or that do not satisfy the predicate | ||
call if OK is false. */ | ||
|
||
SKIPCHARS_INLINE char * | ||
skip_str_matching (char const *str, bool (*predicate) (mcel_t), bool ok) | ||
{ | ||
char const *s = str; | ||
for (mcel_t g; *s && predicate (g = mcel_scanz (s)) == ok; | ||
s += g.len) | ||
continue; | ||
return (char *) s; | ||
} | ||
|
||
/* Return the address just past the leading sequence of possibly | ||
multi-byte characters or encoding errors G in BUF (which ends at LIM) | ||
that satisfy PREDICATE (G) if OK is true, or that do not satisfy | ||
the predicate call if OK is false. */ | ||
|
||
SKIPCHARS_INLINE char * | ||
skip_buf_matching (char const *buf, char const *lim, | ||
bool (*predicate) (mcel_t), bool ok) | ||
{ | ||
char const *s = buf; | ||
for (mcel_t g; s < lim && predicate (g = mcel_scan (s, lim)) == ok; | ||
s += g.len) | ||
continue; | ||
return (char *) s; | ||
} | ||
|
||
_GL_INLINE_HEADER_END |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Description: | ||
Skip sequences of multi-byte characters or encoding errors | ||
|
||
Files: | ||
lib/skipchars.c | ||
lib/skipchars.h | ||
|
||
Depends-on: | ||
extern-inline | ||
mcel | ||
|
||
configure.ac: | ||
|
||
Makefile.am: | ||
lib_SOURCES += skipchars.c | ||
|
||
Include: | ||
"skipchars.h" | ||
|
||
License: | ||
GPL | ||
|
||
Maintainer: | ||
all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.