Thanks for the inputs and feedbacks. Here are the new modules
string-desc,
xstring-desc,
string-desc-quotearg
that I'm adding.
2023-03-28 Bruno Haible
doc: Document string-desc and related modules.
* doc/string-desc.texi: New file.
* doc/gnulib.texi (Particular Modules): Include it.
string-desc-quotearg: Add tests.
* tests/test-string-desc-quotearg.c: New file.
* modules/string-desc-quotearg-tests: New file.
string-desc-quotearg: New module.
* lib/string-desc-quotearg.h: New file.
* lib/string-desc-quotearg.c: New file.
* modules/string-desc-quotearg: New file.
xstring-desc: Add tests.
* tests/test-xstring-desc.c: New file.
* modules/xstring-desc-tests: New file.
xstring-desc: New module.
* lib/xstring-desc.h: New file.
* lib/xstring-desc.c: New file.
* modules/xstring-desc: New file.
string-desc: Add tests.
* tests/test-string-desc.sh: New file.
* tests/test-string-desc.c: New file.
* modules/string-desc-tests: New file.
string-desc: New module.
* lib/string-desc.h: New file.
* lib/string-desc.c: New file.
* lib/string-desc-contains.c: New file.
* modules/string-desc: New file.
From 93e98eb64e33d1a9d5e562fe61f9eb86a2a4de2e Mon Sep 17 00:00:00 2001
From: Bruno Haible
Date: Wed, 29 Mar 2023 00:22:17 +0200
Subject: [PATCH 1/7] string-desc: New module.
* lib/string-desc.h: New file.
* lib/string-desc.c: New file.
* lib/string-desc-contains.c: New file.
* modules/string-desc: New file.
---
ChangeLog | 8 +
lib/string-desc-contains.c | 44 +
lib/string-desc.c | 358 +
lib/string-desc.h | 229
modules/string-desc| 30
5 files changed, 669 insertions(+)
create mode 100644 lib/string-desc-contains.c
create mode 100644 lib/string-desc.c
create mode 100644 lib/string-desc.h
create mode 100644 modules/string-desc
diff --git a/ChangeLog b/ChangeLog
index 0688e05bd8..2865fdea7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-03-28 Bruno Haible
+
+ string-desc: New module.
+ * lib/string-desc.h: New file.
+ * lib/string-desc.c: New file.
+ * lib/string-desc-contains.c: New file.
+ * modules/string-desc: New file.
+
2023-03-28 Bruno Haible
doc: Fix placement of memset_explicit node.
diff --git a/lib/string-desc-contains.c b/lib/string-desc-contains.c
new file mode 100644
index 00..c02617629e
--- /dev/null
+++ b/lib/string-desc-contains.c
@@ -0,0 +1,44 @@
+/* String descriptors.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This file 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible , 2023. */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/* Specification. */
+#include "string-desc.h"
+
+#include
+
+
+/* This function is in a separate compilation unit, because not all users
+ of the 'string-desc' module need this function and it depends on 'memmem'
+ which — depending on platforms — costs up to 2 KB of binary code. */
+
+ptrdiff_t
+string_desc_contains (string_desc_t haystack, string_desc_t needle)
+{
+ if (needle._nbytes == 0)
+return 0;
+ void *found =
+memmem (haystack._data, haystack._nbytes, needle._data, needle._nbytes);
+ if (found != NULL)
+return (char *) found - haystack._data;
+ else
+return -1;
+}
diff --git a/lib/string-desc.c b/lib/string-desc.c
new file mode 100644
index 00..2747612bbc
--- /dev/null
+++ b/lib/string-desc.c
@@ -0,0 +1,358 @@
+/* String descriptors.
+ Copyright (C) 2023 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This file 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+