summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2023-03-30 15:18:27 +0200
committerBruno Haible <bruno@clisp.org>2023-03-30 15:18:27 +0200
commit9e5d25903af0670127c9af05b0482a6851bb436c (patch)
tree3ae133b72afa88c8738c9985e2c4695213835e6e
parent9a7cd7e0c5a732b90f926a608804db7e8fd491fb (diff)
downloadgettext-9e5d25903af0670127c9af05b0482a6851bb436c.tar.gz
Use string-desc module from gnulib.
* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC): Add string-desc. Remove memmem, memrchr. (GNULIB_MODULES_LIBGETTEXTPO): Likewise. * gettext-tools/src/str-desc.h: Remove file. * gettext-tools/src/str-desc.c: Remove file. * gettext-tools/src/FILES: Update. * gettext-tools/src/msgl-ascii.h: Include string-desc.h instead of str-desc.h. Use string_desc_t instead of string_desc_ty. * gettext-tools/src/msgl-ascii.c: Use string_desc_t instead of string_desc_ty. * gettext-tools/src/msgl-iconv.h: Include string-desc.h instead of str-desc.h. Use string_desc_t instead of string_desc_ty. * gettext-tools/src/msgl-iconv.c: Include string-desc.h instead of str-desc.h. Use string_desc_t instead of string_desc_ty. * gettext-tools/src/xg-encoding.h: Include string-desc.h instead of str-desc.h. Use string_desc_t instead of string_desc_ty. * gettext-tools/src/xg-encoding.c (string_desc_from_current_source_encoding): Use string_desc_t instead of string_desc_ty. * gettext-tools/src/x-perl.c: Include string-desc.h instead of str-desc.h. (extract_quotelike_pass1, extract_quotelike_pass1_utf8, extract_quotelike, extract_triple_quotelike, interpolate_keywords): Use string_desc_t instead of string_desc_ty. * gettext-tools/src/Makefile.am (noinst_HEADERS): Remove str-desc.h. (libgettextsrc_la_SOURCES): Remove str-desc.c. * gettext-tools/libgettextpo/Makefile.am (libgettextpo_la_AUXSOURCES): Remove str-desc.c.
-rw-r--r--.gitignore12
-rwxr-xr-xautogen.sh6
-rw-r--r--gettext-tools/libgettextpo/Makefile.am1
-rw-r--r--gettext-tools/src/FILES4
-rw-r--r--gettext-tools/src/Makefile.am3
-rw-r--r--gettext-tools/src/msgl-ascii.c2
-rw-r--r--gettext-tools/src/msgl-ascii.h4
-rw-r--r--gettext-tools/src/msgl-iconv.c8
-rw-r--r--gettext-tools/src/msgl-iconv.h7
-rw-r--r--gettext-tools/src/str-desc.c331
-rw-r--r--gettext-tools/src/str-desc.h140
-rw-r--r--gettext-tools/src/x-perl.c22
-rw-r--r--gettext-tools/src/xg-encoding.c4
-rw-r--r--gettext-tools/src/xg-encoding.h6
14 files changed, 42 insertions, 508 deletions
diff --git a/.gitignore b/.gitignore
index 0cb76f739..c11c3b2ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -113,6 +113,8 @@
/gettext-tools/libgettextpo/fstrcmp.c
/gettext-tools/libgettextpo/fstrcmp.h
/gettext-tools/libgettextpo/fsync.c
+/gettext-tools/libgettextpo/full-write.c
+/gettext-tools/libgettextpo/full-write.h
/gettext-tools/libgettextpo/fwriteerror.c
/gettext-tools/libgettextpo/fwriteerror.h
/gettext-tools/libgettextpo/gcd.c
@@ -175,6 +177,8 @@
/gettext-tools/libgettextpo/mem-hash-map.h
/gettext-tools/libgettextpo/memchr.c
/gettext-tools/libgettextpo/memchr.valgrind
+/gettext-tools/libgettextpo/memmem.c
+/gettext-tools/libgettextpo/memrchr.c
/gettext-tools/libgettextpo/minmax.h
/gettext-tools/libgettextpo/msvc-inval.c
/gettext-tools/libgettextpo/msvc-inval.h
@@ -199,6 +203,9 @@
/gettext-tools/libgettextpo/relocatable.c
/gettext-tools/libgettextpo/relocatable.h
/gettext-tools/libgettextpo/relocatable.valgrind
+/gettext-tools/libgettextpo/safe-read.c
+/gettext-tools/libgettextpo/safe-write.c
+/gettext-tools/libgettextpo/safe-write.h
/gettext-tools/libgettextpo/setlocale-lock.c
/gettext-tools/libgettextpo/setlocale_null.c
/gettext-tools/libgettextpo/setlocale_null.h
@@ -236,9 +243,13 @@
/gettext-tools/libgettextpo/striconveh.h
/gettext-tools/libgettextpo/striconveha.c
/gettext-tools/libgettextpo/striconveha.h
+/gettext-tools/libgettextpo/string-desc-contains.c
+/gettext-tools/libgettextpo/string-desc.c
+/gettext-tools/libgettextpo/string-desc.h
/gettext-tools/libgettextpo/string.in.h
/gettext-tools/libgettextpo/stripslash.c
/gettext-tools/libgettextpo/strstr.c
+/gettext-tools/libgettextpo/sys-limits.h
/gettext-tools/libgettextpo/sys_stat.in.h
/gettext-tools/libgettextpo/sys_types.in.h
/gettext-tools/libgettextpo/textstyle.in.h
@@ -273,6 +284,7 @@
/gettext-tools/libgettextpo/windows-rwlock.h
/gettext-tools/libgettextpo/windows-tls.c
/gettext-tools/libgettextpo/windows-tls.h
+/gettext-tools/libgettextpo/write.c
/gettext-tools/libgettextpo/xalloc-die.c
/gettext-tools/libgettextpo/xalloc-oversized.h
/gettext-tools/libgettextpo/xalloc.h
diff --git a/autogen.sh b/autogen.sh
index 842cb56fd..f63348ff4 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -182,9 +182,7 @@ if ! $skip_gnulib; then
lock
mem-hash-map
memchr
- memmem
memmove
- memrchr
memset
minmax
mkdir
@@ -214,6 +212,7 @@ if ! $skip_gnulib; then
strchrnul
strcspn
strerror
+ string-desc
strpbrk
strtol
strtoul
@@ -343,8 +342,6 @@ if ! $skip_gnulib; then
libunistring-optional
markup
mem-hash-map
- memmem
- memrchr
minmax
open
relocatable-lib
@@ -356,6 +353,7 @@ if ! $skip_gnulib; then
stpncpy
strchrnul
strerror
+ string-desc
unictype/ctype-space
unilbrk/ulc-width-linebreaks
unistr/u8-mbtouc
diff --git a/gettext-tools/libgettextpo/Makefile.am b/gettext-tools/libgettextpo/Makefile.am
index b9c9fb630..ee9ed39c4 100644
--- a/gettext-tools/libgettextpo/Makefile.am
+++ b/gettext-tools/libgettextpo/Makefile.am
@@ -52,7 +52,6 @@ libgettextpo_la_AUXSOURCES = \
../src/dir-list.c \
../src/message.c \
../src/pos.c \
- ../src/str-desc.c \
../src/msgl-ascii.c \
../src/po-error.c \
../src/po-xerror.c \
diff --git a/gettext-tools/src/FILES b/gettext-tools/src/FILES
index a119f6fa0..90471bccd 100644
--- a/gettext-tools/src/FILES
+++ b/gettext-tools/src/FILES
@@ -9,10 +9,6 @@ str-list.h
str-list.c
A list-of-immutable-strings type.
-str-desc.h
-str-desc.c
- A string descriptor type, for strings that may contain NULs.
-
dir-list.h
dir-list.c
Management of the list of directories where PO files are
diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am
index 3d5e2b989..59af8aaa7 100644
--- a/gettext-tools/src/Makefile.am
+++ b/gettext-tools/src/Makefile.am
@@ -39,7 +39,7 @@ noinst_HEADERS = \
pos.h message.h po-error.h po-xerror.h po-gram.h po-charset.h \
po-lex.h open-catalog.h read-catalog-abstract.h read-catalog.h \
read-po.h read-properties.h read-stringtable.h \
- str-desc.h str-list.h \
+ str-list.h \
write-catalog.h write-po.h write-properties.h write-stringtable.h \
dir-list.h file-list.h po-gram-gen.h po-gram-gen2.h cldr-plural.h \
cldr-plural-exp.h locating-rule.h its.h search-path.h \
@@ -172,7 +172,6 @@ FORMAT_SOURCE += \
# libgettextsrc contains all code that is needed by at least two programs.
libgettextsrc_la_SOURCES = \
$(COMMON_SOURCE) \
- str-desc.c \
read-catalog.c \
write-catalog.c write-properties.c write-stringtable.c write-po.c \
msgl-ascii.c \
diff --git a/gettext-tools/src/msgl-ascii.c b/gettext-tools/src/msgl-ascii.c
index cabad7295..a11f20b53 100644
--- a/gettext-tools/src/msgl-ascii.c
+++ b/gettext-tools/src/msgl-ascii.c
@@ -39,7 +39,7 @@ is_ascii_string (const char *string)
}
bool
-is_ascii_string_desc (string_desc_ty string)
+is_ascii_string_desc (string_desc_t string)
{
size_t len = string_desc_length (string);
size_t i;
diff --git a/gettext-tools/src/msgl-ascii.h b/gettext-tools/src/msgl-ascii.h
index 54b024022..b86bd4283 100644
--- a/gettext-tools/src/msgl-ascii.h
+++ b/gettext-tools/src/msgl-ascii.h
@@ -18,7 +18,7 @@
#ifndef _MSGL_ASCII_H
#define _MSGL_ASCII_H
-#include "str-desc.h"
+#include "string-desc.h"
#include "message.h"
#include <stdbool.h>
@@ -32,7 +32,7 @@ extern "C" {
extern bool
is_ascii_string (const char *string);
extern bool
- is_ascii_string_desc (string_desc_ty string);
+ is_ascii_string_desc (string_desc_t string);
extern bool
is_ascii_string_list (string_list_ty *slp);
extern bool
diff --git a/gettext-tools/src/msgl-iconv.c b/gettext-tools/src/msgl-iconv.c
index 178fd2dbe..77de5c9e2 100644
--- a/gettext-tools/src/msgl-iconv.c
+++ b/gettext-tools/src/msgl-iconv.c
@@ -35,7 +35,7 @@
#include "noreturn.h"
#include "progname.h"
#include "basename-lgpl.h"
-#include "str-desc.h"
+#include "string-desc.h"
#include "message.h"
#include "po-charset.h"
#include "xstriconv.h"
@@ -91,8 +91,8 @@ convert_string_directly (iconv_t cd, const char *string,
return NULL;
}
-string_desc_ty
-convert_string_desc_directly (iconv_t cd, string_desc_ty string,
+string_desc_t
+convert_string_desc_directly (iconv_t cd, string_desc_t string,
const struct conversion_context* context)
{
char *result = NULL;
@@ -104,7 +104,7 @@ convert_string_desc_directly (iconv_t cd, string_desc_ty string,
conversion_error (context);
/* NOTREACHED */
- return string_desc_new (0);
+ return string_desc_new_empty ();
}
static char *
diff --git a/gettext-tools/src/msgl-iconv.h b/gettext-tools/src/msgl-iconv.h
index 774d995a4..13bed10be 100644
--- a/gettext-tools/src/msgl-iconv.h
+++ b/gettext-tools/src/msgl-iconv.h
@@ -23,7 +23,8 @@
#include <iconv.h>
#endif
-#include "str-desc.h"
+#include "string-desc.h"
+
#include "message.h"
@@ -47,8 +48,8 @@ struct conversion_context
Assumes that either FROM_CODE or TO_CODE is UTF-8. */
extern char *convert_string_directly (iconv_t cd, const char *string,
const struct conversion_context* context);
-extern string_desc_ty
- convert_string_desc_directly (iconv_t cd, string_desc_ty string,
+extern string_desc_t
+ convert_string_desc_directly (iconv_t cd, string_desc_t string,
const struct conversion_context* context);
#endif
diff --git a/gettext-tools/src/str-desc.c b/gettext-tools/src/str-desc.c
deleted file mode 100644
index b6d101efa..000000000
--- a/gettext-tools/src/str-desc.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/* GNU gettext - internationalization aids
- Copyright (C) 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/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* Specification. */
-#include "str-desc.h"
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "xalloc.h"
-
-
-/* ==== Side-effect-free operations on string descriptors ==== */
-
-size_t
-string_desc_length (string_desc_ty s)
-{
- return s.nbytes;
-}
-
-char
-string_desc_char_at (string_desc_ty s, size_t i)
-{
- if (!(i < s.nbytes))
- /* Invalid argument. */
- abort ();
- return s.data[i];
-}
-
-const char *
-string_desc_data (string_desc_ty s)
-{
- return s.data;
-}
-
-bool
-string_desc_is_empty (string_desc_ty s)
-{
- return s.nbytes == 0;
-}
-
-bool
-string_desc_startswith (string_desc_ty s, string_desc_ty prefix)
-{
- return (s.nbytes >= prefix.nbytes
- && (prefix.nbytes == 0
- || memcmp (s.data, prefix.data, prefix.nbytes) == 0));
-}
-
-bool
-string_desc_endswith (string_desc_ty s, string_desc_ty suffix)
-{
- return (s.nbytes >= suffix.nbytes
- && (suffix.nbytes == 0
- || memcmp (s.data + (s.nbytes - suffix.nbytes), suffix.data,
- suffix.nbytes) == 0));
-}
-
-int
-string_desc_cmp (string_desc_ty a, string_desc_ty b)
-{
- if (a.nbytes > b.nbytes)
- {
- if (b.nbytes == 0)
- return 1;
- return (memcmp (a.data, b.data, b.nbytes) < 0 ? -1 : 1);
- }
- else if (a.nbytes < b.nbytes)
- {
- if (a.nbytes == 0)
- return -1;
- return (memcmp (a.data, b.data, a.nbytes) > 0 ? 1 : -1);
- }
- else /* a.nbytes == b.nbytes */
- {
- if (a.nbytes == 0)
- return 0;
- return memcmp (a.data, b.data, a.nbytes);
- }
-}
-
-ptrdiff_t
-string_desc_index (string_desc_ty s, char c)
-{
- if (s.nbytes > 0)
- {
- void *found = memchr (s.data, (unsigned char) c, s.nbytes);
- if (found != NULL)
- return (char *) found - s.data;
- }
- return -1;
-}
-
-ptrdiff_t
-string_desc_last_index (string_desc_ty s, char c)
-{
- if (s.nbytes > 0)
- {
- void *found = memrchr (s.data, (unsigned char) c, s.nbytes);
- if (found != NULL)
- return (char *) found - s.data;
- }
- return -1;
-}
-
-ptrdiff_t
-string_desc_contains (string_desc_ty haystack, string_desc_ty 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;
-}
-
-string_desc_ty
-string_desc_from_c (const char *s)
-{
- string_desc_ty result;
-
- result.nbytes = strlen (s);
- result.data = (char *) s;
-
- return result;
-}
-
-string_desc_ty
-string_desc_substring (string_desc_ty s, size_t start, size_t end)
-{
- string_desc_ty result;
-
- if (!(start <= end))
- /* Invalid arguments. */
- abort ();
-
- result.nbytes = end - start;
- result.data = s.data + start;
-
- return result;
-}
-
-
-/* ==== Memory-allocating operations on string descriptors ==== */
-
-string_desc_ty
-string_desc_new (size_t n)
-{
- string_desc_ty result;
-
- result.nbytes = n;
- if (n == 0)
- result.data = NULL;
- else
- result.data = (char *) xmalloc (n);
-
- return result;
-}
-
-string_desc_ty
-string_desc_new_addr (size_t n, char *addr)
-{
- string_desc_ty result;
-
- result.nbytes = n;
- if (n == 0)
- result.data = NULL;
- else
- result.data = addr;
-
- return result;
-}
-
-string_desc_ty
-string_desc_new_filled (size_t n, char c)
-{
- string_desc_ty result;
-
- result.nbytes = n;
- if (n == 0)
- result.data = NULL;
- else
- {
- result.data = (char *) xmalloc (n);
- memset (result.data, (unsigned char) c, n);
- }
-
- return result;
-}
-
-string_desc_ty
-string_desc_copy (string_desc_ty s)
-{
- string_desc_ty result;
- size_t n = s.nbytes;
-
- result.nbytes = n;
- if (n == 0)
- result.data = NULL;
- else
- {
- result.data = (char *) xmalloc (n);
- memcpy (result.data, s.data, n);
- }
-
- return result;
-}
-
-string_desc_ty
-string_desc_concat (size_t n, string_desc_ty string1, ...)
-{
- if (n == 0)
- /* Invalid argument. */
- abort ();
-
- size_t total = 0;
- total += string1.nbytes;
- if (n > 1)
- {
- va_list other_strings;
- size_t i;
-
- va_start (other_strings, string1);
- for (i = --n; i > 0; i--)
- {
- string_desc_ty arg = va_arg (other_strings, string_desc_ty);
- total += arg.nbytes;
- }
- va_end (other_strings);
- }
-
- char *combined = (char *) xmalloc (total);
- size_t pos = 0;
- memcpy (combined, string1.data, string1.nbytes);
- pos += string1.nbytes;
- if (n > 1)
- {
- va_list other_strings;
- size_t i;
-
- va_start (other_strings, string1);
- for (i = --n; i > 0; i--)
- {
- string_desc_ty arg = va_arg (other_strings, string_desc_ty);
- if (arg.nbytes > 0)
- memcpy (combined + pos, arg.data, arg.nbytes);
- pos += arg.nbytes;
- }
- va_end (other_strings);
- }
-
- string_desc_ty result;
- result.nbytes = total;
- result.data = combined;
-
- return result;
-}
-
-char *
-string_desc_c (string_desc_ty s)
-{
- size_t n = s.nbytes;
- char *result = (char *) xmalloc (n + 1);
- if (n > 0)
- memcpy (result, s.data, n);
- result[n] = '\0';
-
- return result;
-}
-
-
-/* ==== Operations with side effects on string descriptors ==== */
-
-void
-string_desc_set_char_at (string_desc_ty s, size_t i, char c)
-{
- if (!(i < s.nbytes))
- /* Invalid argument. */
- abort ();
- s.data[i] = c;
-}
-
-void
-string_desc_fill (string_desc_ty s, size_t start, size_t end, char c)
-{
- if (!(start <= end))
- /* Invalid arguments. */
- abort ();
-
- if (start < end)
- memset (s.data + start, (unsigned char) c, end - start);
-}
-
-void
-string_desc_overwrite (string_desc_ty s, size_t start, string_desc_ty t)
-{
- if (!(start + t.nbytes <= s.nbytes))
- /* Invalid arguments. */
- abort ();
-
- if (t.nbytes > 0)
- memcpy (s.data + start, t.data, t.nbytes);
-}
-
-void
-string_desc_free (string_desc_ty s)
-{
- free (s.data);
-}
diff --git a/gettext-tools/src/str-desc.h b/gettext-tools/src/str-desc.h
deleted file mode 100644
index 932641926..000000000
--- a/gettext-tools/src/str-desc.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/* GNU gettext - internationalization aids
- Copyright (C) 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/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2023. */
-
-#ifndef _STR_DESC_H
-#define _STR_DESC_H 1
-
-/* Get size_t, ptrdiff_t. */
-#include <stddef.h>
-
-/* Get bool. */
-#include <stdbool.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Type describing a string that may contain NUL bytes.
- It's merely a descriptor of an array of bytes. */
-typedef struct string_desc_ty string_desc_ty;
-struct string_desc_ty
-{
- size_t nbytes;
- char *data;
-};
-
-/* String descriptors can be passed and returned by value. */
-
-
-/* ==== Side-effect-free operations on string descriptors ==== */
-
-/* Return the length of the string S. */
-extern size_t string_desc_length (string_desc_ty s);
-
-/* Return the byte at index I of string S.
- I must be < length(S). */
-extern char string_desc_char_at (string_desc_ty s, size_t i);
-
-/* Return a read-only view of the bytes of S. */
-extern const char * string_desc_data (string_desc_ty s);
-
-/* Return true if S is the empty string. */
-extern bool string_desc_is_empty (string_desc_ty s);
-
-/* Return true if S starts with PREFIX. */
-extern bool string_desc_startswith (string_desc_ty s, string_desc_ty prefix);
-
-/* Return true if S ends with SUFFIX. */
-extern bool string_desc_endswith (string_desc_ty s, string_desc_ty suffix);
-
-/* Return > 0, == 0, or < 0 if A > B, A == B, A < B.
- This uses a lexicographic ordering, where the bytes are compared as
- 'unsigned char'. */
-extern int string_desc_cmp (string_desc_ty a, string_desc_ty b);
-
-/* Return the index of the first occurrence of C in S,
- or -1 if there is none. */
-extern ptrdiff_t string_desc_index (string_desc_ty s, char c);
-
-/* Return the index of the last occurrence of C in S,
- or -1 if there is none. */
-extern ptrdiff_t string_desc_last_index (string_desc_ty s, char c);
-
-/* Return the index of the first occurrence of NEEDLE in HAYSTACK,
- or -1 if there is none. */
-extern ptrdiff_t string_desc_contains (string_desc_ty haystack, string_desc_ty needle);
-
-/* Return a string that represents the C string S, of length strlen (S). */
-extern string_desc_ty string_desc_from_c (const char *s);
-
-/* Return the substring of S, starting at offset START and ending at offset END.
- START must be <= END.
- The result is of length END - START.
- The result must not be freed (since its storage is part of the storage
- of S). */
-extern string_desc_ty string_desc_substring (string_desc_ty s, size_t start, size_t end);
-
-
-/* ==== Memory-allocating operations on string descriptors ==== */
-
-/* Return a string of length N, with uninitialized contents. */
-extern string_desc_ty string_desc_new (size_t n);
-
-/* Return a string of length N, at the given memory address. */
-extern string_desc_ty string_desc_new_addr (size_t n, char *addr);
-
-/* Return a string of length N, filled with C. */
-extern string_desc_ty string_desc_new_filled (size_t n, char c);
-
-/* Return a copy of string S. */
-extern string_desc_ty string_desc_copy (string_desc_ty s);
-
-/* Return the concatenation of N strings. N must be > 0. */
-extern string_desc_ty string_desc_concat (size_t n, string_desc_ty string1, ...);
-
-/* Return a copy of string S, as a NUL-terminated C string. */
-extern char * string_desc_c (string_desc_ty s);
-
-
-/* ==== Operations with side effects on string descriptors ==== */
-
-/* Overwrite the byte at index I of string S with C.
- I must be < length(S). */
-extern void string_desc_set_char_at (string_desc_ty s, size_t i, char c);
-
-/* Fill part of S, starting at offset START and ending at offset END,
- with copies of C.
- START must be <= END. */
-extern void string_desc_fill (string_desc_ty s, size_t start, size_t end, char c);
-
-/* Overwrite part of S with T, starting at offset START.
- START + length(T) must be <= length (S). */
-extern void string_desc_overwrite (string_desc_ty s, size_t start, string_desc_ty t);
-
-/* Free S. */
-extern void string_desc_free (string_desc_ty s);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _STR_DESC_H */
diff --git a/gettext-tools/src/x-perl.c b/gettext-tools/src/x-perl.c
index 30d4f9d42..c8b28c2b2 100644
--- a/gettext-tools/src/x-perl.c
+++ b/gettext-tools/src/x-perl.c
@@ -32,7 +32,7 @@
#include "attribute.h"
#include "message.h"
#include "rc-str-list.h"
-#include "str-desc.h"
+#include "string-desc.h"
#include "xgettext.h"
#include "xg-pos.h"
#include "xg-encoding.h"
@@ -673,7 +673,7 @@ free_token (token_ty *tp)
of the semantics of the construct. Return the complete string,
including the starting and the trailing delimiter, with backslashes
removed where appropriate. */
-static string_desc_ty
+static string_desc_t
extract_quotelike_pass1 (int delim)
{
/* This function is called recursively. No way to allocate stuff
@@ -730,7 +730,7 @@ extract_quotelike_pass1 (int delim)
if (nested && c == delim)
{
- string_desc_ty inner = extract_quotelike_pass1 (delim);
+ string_desc_t inner = extract_quotelike_pass1 (delim);
size_t len = string_desc_length (inner);
/* Ensure room for len + 1 bytes. */
@@ -773,14 +773,14 @@ extract_quotelike_pass1 (int delim)
/* Like extract_quotelike_pass1, but return the complete string in UTF-8
encoding. */
-static string_desc_ty
+static string_desc_t
extract_quotelike_pass1_utf8 (int delim)
{
- string_desc_ty string = extract_quotelike_pass1 (delim);
- string_desc_ty utf8_string =
+ string_desc_t string = extract_quotelike_pass1 (delim);
+ string_desc_t utf8_string =
string_desc_from_current_source_encoding (string, lc_string,
logical_file_name, line_number);
- if (utf8_string.data != string.data)
+ if (string_desc_data (utf8_string) != string_desc_data (string))
string_desc_free (string);
return utf8_string;
}
@@ -801,7 +801,7 @@ static int nesting_depth;
/* Forward declaration of local functions. */
-static void interpolate_keywords (message_list_ty *mlp, string_desc_ty string,
+static void interpolate_keywords (message_list_ty *mlp, string_desc_t string,
int lineno);
static token_ty *x_perl_lex (message_list_ty *mlp);
static void x_perl_unlex (token_ty *tp);
@@ -877,7 +877,7 @@ extract_oct (const char *string, size_t len, unsigned int *result)
static void
extract_quotelike (token_ty *tp, int delim)
{
- string_desc_ty string = extract_quotelike_pass1_utf8 (delim);
+ string_desc_t string = extract_quotelike_pass1_utf8 (delim);
size_t len = string_desc_length (string);
tp->type = token_type_string;
@@ -897,7 +897,7 @@ static void
extract_triple_quotelike (message_list_ty *mlp, token_ty *tp, int delim,
bool interpolate)
{
- string_desc_ty string;
+ string_desc_t string;
tp->type = token_type_regex_op;
@@ -1691,7 +1691,7 @@ extract_variable (message_list_ty *mlp, token_ty *tp, int first)
variables inside a double-quoted string that may interpolate to
some keyword hash (reference). The string is UTF-8 encoded. */
static void
-interpolate_keywords (message_list_ty *mlp, string_desc_ty string, int lineno)
+interpolate_keywords (message_list_ty *mlp, string_desc_t string, int lineno)
{
static char *buffer;
static int bufmax = 0;
diff --git a/gettext-tools/src/xg-encoding.c b/gettext-tools/src/xg-encoding.c
index 4bcd76e48..a8b6fd2f0 100644
--- a/gettext-tools/src/xg-encoding.c
+++ b/gettext-tools/src/xg-encoding.c
@@ -199,8 +199,8 @@ from_current_source_encoding (const char *string,
}
/* Like from_current_source_encoding, for a string that may contain NULs. */
-string_desc_ty
-string_desc_from_current_source_encoding (string_desc_ty string,
+string_desc_t
+string_desc_from_current_source_encoding (string_desc_t string,
lexical_context_ty lcontext,
const char *file_name,
size_t line_number)
diff --git a/gettext-tools/src/xg-encoding.h b/gettext-tools/src/xg-encoding.h
index f09665d82..3991a1b98 100644
--- a/gettext-tools/src/xg-encoding.h
+++ b/gettext-tools/src/xg-encoding.h
@@ -23,7 +23,7 @@
#include <iconv.h>
#endif
-#include "str-desc.h"
+#include "string-desc.h"
#ifdef __cplusplus
@@ -82,8 +82,8 @@ extern char *from_current_source_encoding (const char *string,
size_t line_number);
/* Like from_current_source_encoding, for a string that may contain NULs. */
-extern string_desc_ty
- string_desc_from_current_source_encoding (string_desc_ty string,
+extern string_desc_t
+ string_desc_from_current_source_encoding (string_desc_t string,
lexical_context_ty lcontext,
const char *file_name,
size_t line_number);