]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: move field_sep into separate module
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 28 Oct 2023 00:15:08 +0000 (17:15 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 30 Oct 2023 07:58:04 +0000 (00:58 -0700)
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.

bootstrap.conf
gl/lib/cu-ctype.c [new file with mode: 0644]
gl/lib/cu-ctype.h [new file with mode: 0644]
gl/modules/cu-ctype [new file with mode: 0644]
src/join.c
src/numfmt.c
src/sort.c
src/system.h
src/uniq.c

index db0c90c6700104383d83c851b90ef1358207e4c0..4724544d76186faff6cb057d270a2ee06b195db0 100644 (file)
@@ -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 (file)
index 0000000..9f753de
--- /dev/null
@@ -0,0 +1,3 @@
+#include <config.h>
+#define CU_CTYPE_INLINE _GL_EXTERN_INLINE
+#include <cu-ctype.h>
diff --git a/gl/lib/cu-ctype.h b/gl/lib/cu-ctype.h
new file mode 100644 (file)
index 0000000..82f1d73
--- /dev/null
@@ -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 <https://www.gnu.org/licenses/>.  */
+
+#include <ctype.h>
+
+#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 (file)
index 0000000..bd328b3
--- /dev/null
@@ -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
index 7eef58c0bf940818d5c1ac13bb1f900705e34e4b..b95cf2b9be9198766abf0c86a0fd21a203ad95e0 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "system.h"
 #include "assure.h"
+#include "cu-ctype.h"
 #include "fadvise.h"
 #include "hard-locale.h"
 #include "linebuffer.h"
index 8fd6e77adf43d97e240454caef9469da9cbb3cce..2ce70226cffdafe71cbd541b5b28348b190cca0c 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "argmatch.h"
 #include "c-ctype.h"
+#include "cu-ctype.h"
 #include "mbswidth.h"
 #include "quote.h"
 #include "system.h"
index 5c86b83324cc1d0839f0c4f11b494f49b9d44071..6856e6151443fa5d75999f012492416640da494b 100644 (file)
@@ -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"
index 21b15839b6b33da4d616d6dbc3935c70af9fa526..b4e0a727524e9d52e8d9a8c1e00edd205a0e0be1 100644 (file)
@@ -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 <locale.h>
 
 /* Take care of NLS matters.  */
index d294ed6654b604a13aa21dd44fa353ca70e41a4e..7e177ac5a3639f7eb3fe4fc364df0aabe6cf3278 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "system.h"
 #include "argmatch.h"
+#include "cu-ctype.h"
 #include "linebuffer.h"
 #include "fadvise.h"
 #include "posixver.h"