From: Paul Eggert Date: Sat, 28 Oct 2023 00:15:08 +0000 (-0700) Subject: maint: move field_sep into separate module X-Git-Tag: v9.5~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=684e810ae2de35dd2761bc28149280a249810d5b;p=thirdparty%2Fcoreutils.git maint: move field_sep into separate module This is so that we don’t need to have every source file include ctype.h. * bootstrap.conf (gnulib_modules): Add cu-ctype. * gl/lib/cu-ctype.c, gl/lib/cu-ctype.h, gl/modules/cu-ctype: New files. * src/join.c, src/numfmt.c, src/sort.c, src/uniq.c: Include cu-ctype.h, for field_sep. * src/system.h (field_sep): Remove; now supplied by cu-ctype. --- diff --git a/bootstrap.conf b/bootstrap.conf index db0c90c670..4724544d76 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -70,6 +70,7 @@ gnulib_modules=" crypto/sha256 crypto/sha512 crypto/sm3 + cu-ctype cycle-check d-ino d-type diff --git a/gl/lib/cu-ctype.c b/gl/lib/cu-ctype.c new file mode 100644 index 0000000000..9f753de2e0 --- /dev/null +++ b/gl/lib/cu-ctype.c @@ -0,0 +1,3 @@ +#include +#define CU_CTYPE_INLINE _GL_EXTERN_INLINE +#include diff --git a/gl/lib/cu-ctype.h b/gl/lib/cu-ctype.h new file mode 100644 index 0000000000..82f1d73f2d --- /dev/null +++ b/gl/lib/cu-ctype.h @@ -0,0 +1,35 @@ +/* Character type definitions for coreutils + + 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 . */ + +#include + +#ifndef _GL_INLINE_HEADER_BEGIN +# error "Please include config.h first." +#endif +_GL_INLINE_HEADER_BEGIN +#ifndef CU_CTYPE_INLINE +# define CU_CTYPE_INLINE _GL_INLINE +#endif + +/* '\n' is considered a field separator with --zero-terminated. */ +CU_CTYPE_INLINE bool +field_sep (unsigned char ch) +{ + return isblank (ch) || ch == '\n'; +} + +_GL_INLINE_HEADER_END diff --git a/gl/modules/cu-ctype b/gl/modules/cu-ctype new file mode 100644 index 0000000000..bd328b32ef --- /dev/null +++ b/gl/modules/cu-ctype @@ -0,0 +1,24 @@ +Description: +ctype.h-like definitions for coreutils + +Files: +lib/cu-ctype.c +lib/cu-ctype.h + +Depends-on: +ctype +extern-inline + +configure.ac: + +Makefile.am: +lib_SOURCES += cu-ctype.c + +Include: +"cu-ctype.h" + +License: +GPL + +Maintainer: +all diff --git a/src/join.c b/src/join.c index 7eef58c0bf..b95cf2b9be 100644 --- a/src/join.c +++ b/src/join.c @@ -23,6 +23,7 @@ #include "system.h" #include "assure.h" +#include "cu-ctype.h" #include "fadvise.h" #include "hard-locale.h" #include "linebuffer.h" diff --git a/src/numfmt.c b/src/numfmt.c index 8fd6e77adf..2ce70226cf 100644 --- a/src/numfmt.c +++ b/src/numfmt.c @@ -24,6 +24,7 @@ #include "argmatch.h" #include "c-ctype.h" +#include "cu-ctype.h" #include "mbswidth.h" #include "quote.h" #include "system.h" diff --git a/src/sort.c b/src/sort.c index 5c86b83324..6856e61514 100644 --- a/src/sort.c +++ b/src/sort.c @@ -31,6 +31,7 @@ #include "system.h" #include "argmatch.h" #include "assure.h" +#include "cu-ctype.h" #include "fadvise.h" #include "filevercmp.h" #include "flexmember.h" diff --git a/src/system.h b/src/system.h index 21b15839b6..b4e0a72752 100644 --- a/src/system.h +++ b/src/system.h @@ -158,13 +158,6 @@ enum errors that the cast doesn't. */ static inline unsigned char to_uchar (char ch) { return ch; } -/* '\n' is considered a field separator with --zero-terminated. */ -static inline bool -field_sep (unsigned char ch) -{ - return isblank (ch) || ch == '\n'; -} - #include /* Take care of NLS matters. */ diff --git a/src/uniq.c b/src/uniq.c index d294ed6654..7e177ac5a3 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -23,6 +23,7 @@ #include "system.h" #include "argmatch.h" +#include "cu-ctype.h" #include "linebuffer.h" #include "fadvise.h" #include "posixver.h"