string-desc, xstring-desc, string-desc-quotearg: Rename functions.
authorBruno Haible <bruno@clisp.org>
Thu, 2 Jan 2025 12:54:54 +0000 (13:54 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 2 Jan 2025 12:54:54 +0000 (13:54 +0100)
* lib/string-desc.h (sd_equals): Renamed from string_desc_equals.
(sd_startswith): Renamed from string_desc_startswith.
(sd_endswith): Renamed from string_desc_endswith.
(sd_cmp): Renamed from string_desc_cmp.
(sd_c_casecmp): Renamed from string_desc_c_casecmp.
(sd_index): Renamed from string_desc_index.
(sd_last_index): Renamed from string_desc_last_index.
(sd_contains): Renamed from string_desc_contains.
(sd_new_empty): Renamed from string_desc_new_empty.
(sd_new_addr): Renamed from string_desc_new_addr.
(sd_from_c): Renamed from string_desc_from_c.
(sd_substring): Renamed from string_desc_substring.
(sd_write): Renamed from string_desc_write.
(sd_fwrite): Renamed from string_desc_fwrite.
(sd_new): Renamed from string_desc_new.
(sd_new_filled): Renamed from string_desc_new_filled.
(sd_copy): Renamed from string_desc_copy.
(sd_concat): Renamed from string_desc_concat.
(sd_c): Renamed from string_desc_c.
(sd_set_char_at): Renamed from string_desc_set_char_at.
(sd_fill): Renamed from string_desc_fill.
(sd_overwrite): Renamed from string_desc_overwrite.
(sd_free): Renamed from string_desc_free.
(sd_length): Renamed from string_desc_length.
(sd_char_at): Renamed from string_desc_char_at.
(sd_data): Renamed from string_desc_data.
(sd_is_empty): Renamed from string_desc_is_empty.
* lib/string-desc.c (sd_equals): Renamed from string_desc_equals.
(sd_startswith): Renamed from string_desc_startswith.
(sd_endswith): Renamed from string_desc_endswith.
(sd_cmp): Renamed from string_desc_cmp.
(sd_c_casecmp): Renamed from string_desc_c_casecmp.
(sd_index): Renamed from string_desc_index.
(sd_last_index): Renamed from string_desc_last_index.
(sd_new_empty): Renamed from string_desc_new_empty.
(sd_new_addr): Renamed from string_desc_new_addr.
(sd_from_c): Renamed from string_desc_from_c.
(sd_substring): Renamed from string_desc_substring.
(sd_write): Renamed from string_desc_write.
(sd_fwrite): Renamed from string_desc_fwrite.
(sd_new): Renamed from string_desc_new.
(sd_new_filled): Renamed from string_desc_new_filled.
(sd_copy): Renamed from string_desc_copy.
(sd_concat): Renamed from string_desc_concat.
(sd_c): Renamed from string_desc_c.
(sd_set_char_at): Renamed from string_desc_set_char_at.
(sd_fill): Renamed from string_desc_fill.
(sd_overwrite): Renamed from string_desc_overwrite.
(sd_free): Renamed from string_desc_free.
* lib/xstring-desc.h (xsd_concat): Renamed from xstring_desc_concat.
(xsd_new): Renamed from xstring_desc_new.
(xsd_new_filled): Renamed from xstring_desc_new_filled.
(xsd_copy): Renamed from xstring_desc_copy.
(xsd_c): Renamed from xstring_desc_c.
* lib/xstring-desc.c (xsd_concat): Renamed from xstring_desc_concat.
* lib/string-desc-quotearg.h (sd_quotearg_buffer): Renamed from
string_desc_quotearg_buffer.
(sd_quotearg_alloc): Renamed from string_desc_quotearg_alloc.
(sd_quotearg_n): Renamed from string_desc_quotearg_n.
(sd_quotearg): Renamed from string_desc_quotearg.
(sd_quotearg_n_style): Renamed from string_desc_quotearg_n_style.
(sd_quotearg_style): Renamed from string_desc_quotearg_style.
(sd_quotearg_char): Renamed from string_desc_quotearg_char.
(sd_quotearg_colon): Renamed from string_desc_quotearg_colon.
(sd_quotearg_n_custom): Renamed from string_desc_quotearg_n_custom.
(sd_quotearg_custom): Renamed from sd_quotearg_n_custom.
* lib/string-desc-contains.c (sd_contains): Renamed from
string_desc_contains.
* lib/string-buffer.h: Update.
* lib/string-buffer.c (sb_append_desc, sb_contents, sb_dupfree): Update.
* lib/xstring-buffer.c (sb_xdupfree): Update.
* lib/sf-istream.c (sf_istream_init_from_string_desc): Update.
* tests/test-string-desc.c (main): Update.
* tests/test-string-desc.sh: Update.
* tests/test-xstring-desc.c (main): Update.
* tests/test-string-desc-quotearg.c (main): Update.
* tests/test-string-buffer.c (main): Update.
* tests/test-sf-istream.c (main): Update.
* tests/test-sfl-istream.c (main): Update.
* doc/string-desc.texi: Update.
* doc/strings.texi: Update.
* NEWS: Mention the change.

21 files changed:
ChangeLog
NEWS
doc/string-desc.texi
doc/strings.texi
lib/sf-istream.c
lib/string-buffer.c
lib/string-buffer.h
lib/string-desc-contains.c
lib/string-desc-quotearg.h
lib/string-desc.c
lib/string-desc.h
lib/xstring-buffer.c
lib/xstring-desc.c
lib/xstring-desc.h
tests/test-sf-istream.c
tests/test-sfl-istream.c
tests/test-string-buffer.c
tests/test-string-desc-quotearg.c
tests/test-string-desc.c
tests/test-string-desc.sh
tests/test-xstring-desc.c

index 70bf7a7bb017ea88ebb1cdcf365a491d55cd27e8..ea1a742b40768979d8f94eec737e4c93bdc4652a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,89 @@
+2025-01-02  Bruno Haible  <bruno@clisp.org>
+
+       string-desc, xstring-desc, string-desc-quotearg: Rename functions.
+       * lib/string-desc.h (sd_equals): Renamed from string_desc_equals.
+       (sd_startswith): Renamed from string_desc_startswith.
+       (sd_endswith): Renamed from string_desc_endswith.
+       (sd_cmp): Renamed from string_desc_cmp.
+       (sd_c_casecmp): Renamed from string_desc_c_casecmp.
+       (sd_index): Renamed from string_desc_index.
+       (sd_last_index): Renamed from string_desc_last_index.
+       (sd_contains): Renamed from string_desc_contains.
+       (sd_new_empty): Renamed from string_desc_new_empty.
+       (sd_new_addr): Renamed from string_desc_new_addr.
+       (sd_from_c): Renamed from string_desc_from_c.
+       (sd_substring): Renamed from string_desc_substring.
+       (sd_write): Renamed from string_desc_write.
+       (sd_fwrite): Renamed from string_desc_fwrite.
+       (sd_new): Renamed from string_desc_new.
+       (sd_new_filled): Renamed from string_desc_new_filled.
+       (sd_copy): Renamed from string_desc_copy.
+       (sd_concat): Renamed from string_desc_concat.
+       (sd_c): Renamed from string_desc_c.
+       (sd_set_char_at): Renamed from string_desc_set_char_at.
+       (sd_fill): Renamed from string_desc_fill.
+       (sd_overwrite): Renamed from string_desc_overwrite.
+       (sd_free): Renamed from string_desc_free.
+       (sd_length): Renamed from string_desc_length.
+       (sd_char_at): Renamed from string_desc_char_at.
+       (sd_data): Renamed from string_desc_data.
+       (sd_is_empty): Renamed from string_desc_is_empty.
+       * lib/string-desc.c (sd_equals): Renamed from string_desc_equals.
+       (sd_startswith): Renamed from string_desc_startswith.
+       (sd_endswith): Renamed from string_desc_endswith.
+       (sd_cmp): Renamed from string_desc_cmp.
+       (sd_c_casecmp): Renamed from string_desc_c_casecmp.
+       (sd_index): Renamed from string_desc_index.
+       (sd_last_index): Renamed from string_desc_last_index.
+       (sd_new_empty): Renamed from string_desc_new_empty.
+       (sd_new_addr): Renamed from string_desc_new_addr.
+       (sd_from_c): Renamed from string_desc_from_c.
+       (sd_substring): Renamed from string_desc_substring.
+       (sd_write): Renamed from string_desc_write.
+       (sd_fwrite): Renamed from string_desc_fwrite.
+       (sd_new): Renamed from string_desc_new.
+       (sd_new_filled): Renamed from string_desc_new_filled.
+       (sd_copy): Renamed from string_desc_copy.
+       (sd_concat): Renamed from string_desc_concat.
+       (sd_c): Renamed from string_desc_c.
+       (sd_set_char_at): Renamed from string_desc_set_char_at.
+       (sd_fill): Renamed from string_desc_fill.
+       (sd_overwrite): Renamed from string_desc_overwrite.
+       (sd_free): Renamed from string_desc_free.
+       * lib/xstring-desc.h (xsd_concat): Renamed from xstring_desc_concat.
+       (xsd_new): Renamed from xstring_desc_new.
+       (xsd_new_filled): Renamed from xstring_desc_new_filled.
+       (xsd_copy): Renamed from xstring_desc_copy.
+       (xsd_c): Renamed from xstring_desc_c.
+       * lib/xstring-desc.c (xsd_concat): Renamed from xstring_desc_concat.
+       * lib/string-desc-quotearg.h (sd_quotearg_buffer): Renamed from
+       string_desc_quotearg_buffer.
+       (sd_quotearg_alloc): Renamed from string_desc_quotearg_alloc.
+       (sd_quotearg_n): Renamed from string_desc_quotearg_n.
+       (sd_quotearg): Renamed from string_desc_quotearg.
+       (sd_quotearg_n_style): Renamed from string_desc_quotearg_n_style.
+       (sd_quotearg_style): Renamed from string_desc_quotearg_style.
+       (sd_quotearg_char): Renamed from string_desc_quotearg_char.
+       (sd_quotearg_colon): Renamed from string_desc_quotearg_colon.
+       (sd_quotearg_n_custom): Renamed from string_desc_quotearg_n_custom.
+       (sd_quotearg_custom): Renamed from sd_quotearg_n_custom.
+       * lib/string-desc-contains.c (sd_contains): Renamed from
+       string_desc_contains.
+       * lib/string-buffer.h: Update.
+       * lib/string-buffer.c (sb_append_desc, sb_contents, sb_dupfree): Update.
+       * lib/xstring-buffer.c (sb_xdupfree): Update.
+       * lib/sf-istream.c (sf_istream_init_from_string_desc): Update.
+       * tests/test-string-desc.c (main): Update.
+       * tests/test-string-desc.sh: Update.
+       * tests/test-xstring-desc.c (main): Update.
+       * tests/test-string-desc-quotearg.c (main): Update.
+       * tests/test-string-buffer.c (main): Update.
+       * tests/test-sf-istream.c (main): Update.
+       * tests/test-sfl-istream.c (main): Update.
+       * doc/string-desc.texi: Update.
+       * doc/strings.texi: Update.
+       * NEWS: Mention the change.
+
 2025-01-02  Simon Josefsson  <simon@josefsson.org>
 
        maintainer-makefile: Improve gnulib-version handling.
diff --git a/NEWS b/NEWS
index e64d1583f8c02b06c1cda94e219246b7fad1038b..d009455429732674697b8c0333232f294dd21921 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,10 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2025-01-02  string-desc     The function prefix is changed from string_desc_
+            xstring-desc    to sd_, and from xstring_desc_ to xsd_.
+            string-desc-quotearg
+
 2024-12-25  xprintf         The functions x[v][f]printf now return an 'off64_t'
                             instead of an 'int'.
 
index 521ead0363ca945841d95d90337607979f8fca8f..ab5c5fced3f5cc2096175d7122d5ea9d9654c530 100644 (file)
@@ -90,10 +90,10 @@ would not work for strings longer than @code{INT_MAX} bytes.
 Therefore Gnulib offers
 @itemize
 @item
-a function @code{string_desc_fwrite} that outputs a string descriptor to
+a function @code{sd_fwrite} that outputs a string descriptor to
 a @code{FILE} stream,
 @item
-a function @code{string_desc_write} that outputs a string descriptor to
+a function @code{sd_write} that outputs a string descriptor to
 a file descriptor,
 @item
 and for those applications where the NUL characters should become
index 574f76dcb63571f10d0b2d426f37d22a58a97230..89d48b7adbc637eadb93139565fbc43807e8d1a1 100644 (file)
@@ -402,7 +402,7 @@ and in Gnulib.
 @item @code{strlen}
 @tab @code{strlen}
 @tab @code{mbslen}
-@tab @code{string_desc_length}
+@tab @code{sd_length}
 @tab @code{wcslen}
 @tab @code{u32_strlen}
 
@@ -416,7 +416,7 @@ and in Gnulib.
 @item @code{strcmp}
 @tab @code{strcmp}
 @tab @code{strcmp}
-@tab @code{string_desc_cmp}
+@tab @code{sd_cmp}
 @tab @code{wcscmp}
 @tab @code{u32_strcmp}
 
@@ -458,21 +458,21 @@ and in Gnulib.
 @item @code{strchr}
 @tab @code{strchr}
 @tab @code{mbschr}
-@tab @code{string_desc_index}
+@tab @code{sd_index}
 @tab @code{wcschr}
 @tab @code{u32_strchr}
 
 @item @code{strrchr}
 @tab @code{strrchr}
 @tab @code{mbsrchr}
-@tab @code{string_desc_last_index}
+@tab @code{sd_last_index}
 @tab @code{wcsrchr}
 @tab @code{u32_strrchr}
 
 @item @code{strstr}
 @tab @code{strstr}
 @tab @code{mbsstr}
-@tab @code{string_desc_contains}
+@tab @code{sd_contains}
 @tab @code{wcsstr}
 @tab @code{u32_strstr}
 
@@ -521,7 +521,7 @@ and in Gnulib.
 @item @code{strcpy}
 @tab @code{strcpy}
 @tab @code{strcpy}
-@tab @code{string_desc_copy}
+@tab @code{sd_copy}
 @tab @code{wcscpy}
 @tab @code{u32_strcpy}
 
@@ -549,7 +549,7 @@ and in Gnulib.
 @item @code{strcat}
 @tab @code{strcat}
 @tab @code{strcat}
-@tab @code{string_desc_concat}
+@tab @code{sd_concat}
 @tab @code{wcscat}
 @tab @code{u32_strcat}
 
@@ -563,14 +563,14 @@ and in Gnulib.
 @item @code{free}
 @tab @code{free}
 @tab @code{free}
-@tab @code{string_desc_free}
+@tab @code{sd_free}
 @tab @code{free}
 @tab @code{free}
 
 @item @code{strdup}
 @tab @code{strdup}
 @tab @code{strdup}
-@tab @code{string_desc_copy}
+@tab @code{sd_copy}
 @tab @code{wcsdup}
 @tab @code{u32_strdup}
 
index 9b6e72f647b53d379c6e27683cc8d34984418dcf..8416cd52690520b5552bb87315a66ae53c4bcfe5 100644 (file)
@@ -46,8 +46,8 @@ sf_istream_init_from_string_desc (sf_istream_t *stream,
                                   string_desc_t input)
 {
   stream->fp = NULL;
-  stream->input = string_desc_data (input);
-  stream->input_end = stream->input + string_desc_length (input);
+  stream->input = sd_data (input);
+  stream->input_end = stream->input + sd_length (input);
 }
 
 int
index 9595729f165f779a7713354e41780918b77bc942..efb95adf6a6cd5c67f69de269c9fa63d58295642 100644 (file)
@@ -101,13 +101,13 @@ sb_append1 (struct string_buffer *buffer, char c)
 int
 sb_append_desc (struct string_buffer *buffer, string_desc_t s)
 {
-  size_t len = string_desc_length (s);
+  size_t len = sd_length (s);
   if (sb_ensure_more_bytes (buffer, len) < 0)
     {
       buffer->error = true;
       return -1;
     }
-  memcpy (buffer->data + buffer->length, string_desc_data (s), len);
+  memcpy (buffer->data + buffer->length, sd_data (s), len);
   buffer->length += len;
   return 0;
 }
@@ -136,7 +136,7 @@ sb_free (struct string_buffer *buffer)
 string_desc_t
 sb_contents (struct string_buffer *buffer)
 {
-  return string_desc_new_addr (buffer->length, buffer->data);
+  return sd_new_addr (buffer->length, buffer->data);
 }
 
 const char *
@@ -162,7 +162,7 @@ sb_dupfree (struct string_buffer *buffer)
       if (copy == NULL)
         goto fail;
       memcpy (copy, buffer->data, length);
-      return string_desc_new_addr (length, copy);
+      return sd_new_addr (length, copy);
     }
   else
     {
@@ -174,12 +174,12 @@ sb_dupfree (struct string_buffer *buffer)
           if (contents == NULL)
             goto fail;
         }
-      return string_desc_new_addr (length, contents);
+      return sd_new_addr (length, contents);
     }
 
  fail:
   sb_free (buffer);
-  return string_desc_new_addr (0, NULL);
+  return sd_new_addr (0, NULL);
 }
 
 char *
index 33b9f469338421c7562ac0d1aa1ebd67bccd3c69..78ce736c02d62b245091ad0587dc21234c9810c4 100644 (file)
@@ -115,7 +115,7 @@ extern const char * sb_contents_c (struct string_buffer *buffer);
 
 /* Returns the contents of BUFFER and frees all other memory held by BUFFER.
    Returns NULL upon failure or if there was an error earlier.
-   It is the responsibility of the caller to string_desc_free() the result.  */
+   It is the responsibility of the caller to sd_free() the result.  */
 extern string_desc_t sb_dupfree (struct string_buffer *buffer)
   _GL_ATTRIBUTE_RELEASE_CAPABILITY (buffer->data);
 
@@ -182,7 +182,7 @@ extern const char * sb_xcontents_c (struct string_buffer *buffer)
 
 /* Returns the contents of BUFFER and frees all other memory held by BUFFER.
    Returns (0, NULL) if there was an error earlier.
-   It is the responsibility of the caller to string_desc_free() the result.  */
+   It is the responsibility of the caller to sd_free() the result.  */
 extern string_desc_t sb_xdupfree (struct string_buffer *buffer)
   _GL_ATTRIBUTE_RELEASE_CAPABILITY (buffer->data);
 
index 9612f7765d97217064640f97804b2acf0df0cfef..18657c70ff641e4648ae4bb230b8d530302a9201 100644 (file)
@@ -31,7 +31,7 @@
    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)
+sd_contains (string_desc_t haystack, string_desc_t needle)
 {
   if (needle._nbytes == 0)
     return 0;
index f63ed7603a5403c2b3250bf863d84b8c505f1fa9..41840896123c2fb3ac7140b1f75ab364abb433bf 100644 (file)
@@ -50,22 +50,22 @@ extern "C" {
    does not use backslash escapes and the flags of O do not request
    elision of null bytes.  */
 #if 0
-extern size_t string_desc_quotearg_buffer (char *restrict buffer,
-                                           size_t buffersize,
-                                           string_desc_t arg,
-                                           struct quoting_options const *o);
+extern size_t sd_quotearg_buffer (char *restrict buffer,
+                                  size_t buffersize,
+                                  string_desc_t arg,
+                                  struct quoting_options const *o);
 #endif
 
-/* Like string_desc_quotearg_buffer, except return the result in a newly
+/* Like sd_quotearg_buffer, except return the result in a newly
    allocated buffer and store its length, excluding the terminating null
    byte, in *SIZE.  It is the caller's responsibility to free the result.
    The result might contain embedded null bytes if the style of O does
    not use backslash escapes and the flags of O do not request elision
    of null bytes.  */
 #if 0
-extern char *string_desc_quotearg_alloc (string_desc_t arg,
-                                         size_t *size,
-                                         struct quoting_options const *o)
+extern char *sd_quotearg_alloc (string_desc_t arg,
+                                size_t *size,
+                                struct quoting_options const *o)
   _GL_ATTRIBUTE_NONNULL ((2))
   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
   _GL_ATTRIBUTE_RETURNS_NONNULL;
@@ -77,68 +77,68 @@ extern char *string_desc_quotearg_alloc (string_desc_t arg,
    reused by the next call to this function with the same value of N.
    N must be nonnegative.  */
 #if 0
-extern char *string_desc_quotearg_n (int n, string_desc_t arg);
+extern char *sd_quotearg_n (int n, string_desc_t arg);
 #endif
 
-/* Equivalent to string_desc_quotearg_n (0, ARG).  */
+/* Equivalent to sd_quotearg_n (0, ARG).  */
 #if 0
-extern char *string_desc_quotearg (string_desc_t arg);
+extern char *sd_quotearg (string_desc_t arg);
 #endif
 
 /* Use style S and storage slot N to return a quoted version of the string ARG.
-   This is like string_desc_quotearg_n (N, ARG), except that it uses S
+   This is like sd_quotearg_n (N, ARG), except that it uses S
    with no other options to specify the quoting method.  */
 #if 0
-extern char *string_desc_quotearg_n_style (int n, enum quoting_style s,
-                                           string_desc_t arg);
+extern char *sd_quotearg_n_style (int n, enum quoting_style s,
+                                  string_desc_t arg);
 #endif
 
-/* Equivalent to string_desc_quotearg_n_style (0, S, ARG).  */
+/* Equivalent to sd_quotearg_n_style (0, S, ARG).  */
 #if 0
-extern char *string_desc_quotearg_style (enum quoting_style s,
-                                         string_desc_t arg);
+extern char *sd_quotearg_style (enum quoting_style s,
+                                string_desc_t arg);
 #endif
 
-/* Like string_desc_quotearg (ARG), except also quote any instances of CH.
+/* Like sd_quotearg (ARG), except also quote any instances of CH.
    See set_char_quoting for a description of acceptable CH values.  */
 #if 0
-extern char *string_desc_quotearg_char (string_desc_t arg, char ch);
+extern char *sd_quotearg_char (string_desc_t arg, char ch);
 #endif
 
-/* Equivalent to string_desc_quotearg_char (ARG, ':').  */
+/* Equivalent to sd_quotearg_char (ARG, ':').  */
 #if 0
-extern char *string_desc_quotearg_colon (string_desc_t arg);
+extern char *sd_quotearg_colon (string_desc_t arg);
 #endif
 
-/* Like string_desc_quotearg_n_style (N, S, ARG) but with S as
+/* Like sd_quotearg_n_style (N, S, ARG) but with S as
    custom_quoting_style with left quote as LEFT_QUOTE and right quote
    as RIGHT_QUOTE.  See set_custom_quoting for a description of acceptable
    LEFT_QUOTE and RIGHT_QUOTE values.  */
 #if 0
-extern char *string_desc_quotearg_n_custom (int n,
-                                            char const *left_quote,
-                                            char const *right_quote,
-                                            string_desc_t arg);
+extern char *sd_quotearg_n_custom (int n,
+                                   char const *left_quote,
+                                   char const *right_quote,
+                                   string_desc_t arg);
 #endif
 
 /* Equivalent to
-   string_desc_quotearg_n_custom (0, LEFT_QUOTE, RIGHT_QUOTE, ARG).  */
+   sd_quotearg_n_custom (0, LEFT_QUOTE, RIGHT_QUOTE, ARG).  */
 #if 0
-extern char *string_desc_quotearg_custom (char const *left_quote,
-                                          char const *right_quote,
-                                          string_desc_t arg);
+extern char *sd_quotearg_custom (char const *left_quote,
+                                 char const *right_quote,
+                                 string_desc_t arg);
 #endif
 
 
 /* ==== Inline function definitions ==== */
 
 GL_STRING_DESC_QUOTEARG_INLINE size_t
-string_desc_quotearg_buffer (char *restrict buffer, size_t buffersize,
-                             string_desc_t arg,
-                             struct quoting_options const *o)
+sd_quotearg_buffer (char *restrict buffer, size_t buffersize,
+                    string_desc_t arg,
+                    struct quoting_options const *o)
 {
   return quotearg_buffer (buffer, buffersize,
-                          string_desc_data (arg), string_desc_length (arg),
+                          sd_data (arg), sd_length (arg),
                           o);
 }
 
@@ -147,69 +147,69 @@ _GL_ATTRIBUTE_NONNULL ((2))
 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
 _GL_ATTRIBUTE_RETURNS_NONNULL
 char *
-string_desc_quotearg_alloc (string_desc_t arg,
-                            size_t *size,
-                            struct quoting_options const *o)
+sd_quotearg_alloc (string_desc_t arg,
+                   size_t *size,
+                   struct quoting_options const *o)
 {
-  return quotearg_alloc_mem (string_desc_data (arg), string_desc_length (arg),
+  return quotearg_alloc_mem (sd_data (arg), sd_length (arg),
                              size,
                              o);
 }
 
 GL_STRING_DESC_QUOTEARG_INLINE char *
-string_desc_quotearg_n (int n, string_desc_t arg)
+sd_quotearg_n (int n, string_desc_t arg)
 {
-  return quotearg_n_mem (n, string_desc_data (arg), string_desc_length (arg));
+  return quotearg_n_mem (n, sd_data (arg), sd_length (arg));
 }
 
 GL_STRING_DESC_QUOTEARG_INLINE char *
-string_desc_quotearg (string_desc_t arg)
+sd_quotearg (string_desc_t arg)
 {
-  return quotearg_mem (string_desc_data (arg), string_desc_length (arg));
+  return quotearg_mem (sd_data (arg), sd_length (arg));
 }
 
 GL_STRING_DESC_QUOTEARG_INLINE char *
-string_desc_quotearg_n_style (int n, enum quoting_style s, string_desc_t arg)
+sd_quotearg_n_style (int n, enum quoting_style s, string_desc_t arg)
 {
   return quotearg_n_style_mem (n, s,
-                               string_desc_data (arg), string_desc_length (arg));
+                               sd_data (arg), sd_length (arg));
 }
 
 GL_STRING_DESC_QUOTEARG_INLINE char *
-string_desc_quotearg_style (enum quoting_style s, string_desc_t arg)
+sd_quotearg_style (enum quoting_style s, string_desc_t arg)
 {
   return quotearg_style_mem (s,
-                             string_desc_data (arg), string_desc_length (arg));
+                             sd_data (arg), sd_length (arg));
 }
 
 GL_STRING_DESC_QUOTEARG_INLINE char *
-string_desc_quotearg_char (string_desc_t arg, char ch)
+sd_quotearg_char (string_desc_t arg, char ch)
 {
-  return quotearg_char_mem (string_desc_data (arg), string_desc_length (arg),
+  return quotearg_char_mem (sd_data (arg), sd_length (arg),
                             ch);
 }
 
 GL_STRING_DESC_QUOTEARG_INLINE char *
-string_desc_quotearg_colon (string_desc_t arg)
+sd_quotearg_colon (string_desc_t arg)
 {
-  return quotearg_colon_mem (string_desc_data (arg), string_desc_length (arg));
+  return quotearg_colon_mem (sd_data (arg), sd_length (arg));
 }
 
 GL_STRING_DESC_QUOTEARG_INLINE char *
-string_desc_quotearg_n_custom (int n,
-                               char const *left_quote, char const *right_quote,
-                               string_desc_t arg)
+sd_quotearg_n_custom (int n,
+                      char const *left_quote, char const *right_quote,
+                      string_desc_t arg)
 {
   return quotearg_n_custom_mem (n, left_quote, right_quote,
-                                string_desc_data (arg), string_desc_length (arg));
+                                sd_data (arg), sd_length (arg));
 }
 
 GL_STRING_DESC_QUOTEARG_INLINE char *
-string_desc_quotearg_custom (char const *left_quote, char const *right_quote,
-                             string_desc_t arg)
+sd_quotearg_custom (char const *left_quote, char const *right_quote,
+                    string_desc_t arg)
 {
   return quotearg_custom_mem (left_quote, right_quote,
-                              string_desc_data (arg), string_desc_length (arg));
+                              sd_data (arg), sd_length (arg));
 }
 
 
index ca201b0500bceac5033ce4a8c47cbe5d75d351ef..d99eca80e34b03031a67e44dcc1ac75700164c4e 100644 (file)
 
 /* Return true if A and B are equal.  */
 bool
-string_desc_equals (string_desc_t a, string_desc_t b)
+sd_equals (string_desc_t a, string_desc_t b)
 {
   return (a._nbytes == b._nbytes
           && (a._nbytes == 0 || memcmp (a._data, b._data, a._nbytes) == 0));
 }
 
 bool
-string_desc_startswith (string_desc_t s, string_desc_t prefix)
+sd_startswith (string_desc_t s, string_desc_t prefix)
 {
   return (s._nbytes >= prefix._nbytes
           && (prefix._nbytes == 0
@@ -54,7 +54,7 @@ string_desc_startswith (string_desc_t s, string_desc_t prefix)
 }
 
 bool
-string_desc_endswith (string_desc_t s, string_desc_t suffix)
+sd_endswith (string_desc_t s, string_desc_t suffix)
 {
   return (s._nbytes >= suffix._nbytes
           && (suffix._nbytes == 0
@@ -63,7 +63,7 @@ string_desc_endswith (string_desc_t s, string_desc_t suffix)
 }
 
 int
-string_desc_cmp (string_desc_t a, string_desc_t b)
+sd_cmp (string_desc_t a, string_desc_t b)
 {
   if (a._nbytes > b._nbytes)
     {
@@ -86,14 +86,14 @@ string_desc_cmp (string_desc_t a, string_desc_t b)
 }
 
 int
-string_desc_c_casecmp (string_desc_t a, string_desc_t b)
+sd_c_casecmp (string_desc_t a, string_desc_t b)
 {
   /* Don't use memcasecmp here, since it uses the current locale, not the
      "C" locale.  */
-  idx_t an = string_desc_length (a);
-  idx_t bn = string_desc_length (b);
-  const char *ap = string_desc_data (a);
-  const char *bp = string_desc_data (b);
+  idx_t an = sd_length (a);
+  idx_t bn = sd_length (b);
+  const char *ap = sd_data (a);
+  const char *bp = sd_data (b);
   idx_t n = (an < bn ? an : bn);
   idx_t i;
   for (i = 0; i < n; i++)
@@ -108,7 +108,7 @@ string_desc_c_casecmp (string_desc_t a, string_desc_t b)
 }
 
 ptrdiff_t
-string_desc_index (string_desc_t s, char c)
+sd_index (string_desc_t s, char c)
 {
   if (s._nbytes > 0)
     {
@@ -120,7 +120,7 @@ string_desc_index (string_desc_t s, char c)
 }
 
 ptrdiff_t
-string_desc_last_index (string_desc_t s, char c)
+sd_last_index (string_desc_t s, char c)
 {
   if (s._nbytes > 0)
     {
@@ -132,7 +132,7 @@ string_desc_last_index (string_desc_t s, char c)
 }
 
 string_desc_t
-string_desc_new_empty (void)
+sd_new_empty (void)
 {
   string_desc_t result;
 
@@ -144,7 +144,7 @@ string_desc_new_empty (void)
 }
 
 string_desc_t
-string_desc_new_addr (idx_t n, char *addr)
+sd_new_addr (idx_t n, char *addr)
 {
   string_desc_t result;
 
@@ -158,7 +158,7 @@ string_desc_new_addr (idx_t n, char *addr)
 }
 
 string_desc_t
-string_desc_from_c (const char *s)
+sd_from_c (const char *s)
 {
   string_desc_t result;
 
@@ -169,7 +169,7 @@ string_desc_from_c (const char *s)
 }
 
 string_desc_t
-string_desc_substring (string_desc_t s, idx_t start, idx_t end)
+sd_substring (string_desc_t s, idx_t start, idx_t end)
 {
   string_desc_t result;
 
@@ -184,7 +184,7 @@ string_desc_substring (string_desc_t s, idx_t start, idx_t end)
 }
 
 int
-string_desc_write (int fd, string_desc_t s)
+sd_write (int fd, string_desc_t s)
 {
   if (s._nbytes > 0)
     if (full_write (fd, s._data, s._nbytes) != s._nbytes)
@@ -194,7 +194,7 @@ string_desc_write (int fd, string_desc_t s)
 }
 
 int
-string_desc_fwrite (FILE *fp, string_desc_t s)
+sd_fwrite (FILE *fp, string_desc_t s)
 {
   if (s._nbytes > 0)
     if (fwrite (s._data, 1, s._nbytes, fp) != s._nbytes)
@@ -206,7 +206,7 @@ string_desc_fwrite (FILE *fp, string_desc_t s)
 /* ==== Memory-allocating operations on string descriptors ==== */
 
 int
-string_desc_new (string_desc_t *resultp, idx_t n)
+sd_new (string_desc_t *resultp, idx_t n)
 {
   string_desc_t result;
 
@@ -230,7 +230,7 @@ string_desc_new (string_desc_t *resultp, idx_t n)
 }
 
 int
-string_desc_new_filled (string_desc_t *resultp, idx_t n, char c)
+sd_new_filled (string_desc_t *resultp, idx_t n, char c)
 {
   string_desc_t result;
 
@@ -251,7 +251,7 @@ string_desc_new_filled (string_desc_t *resultp, idx_t n, char c)
 }
 
 int
-string_desc_copy (string_desc_t *resultp, string_desc_t s)
+sd_copy (string_desc_t *resultp, string_desc_t s)
 {
   string_desc_t result;
   idx_t n = s._nbytes;
@@ -273,7 +273,7 @@ string_desc_copy (string_desc_t *resultp, string_desc_t s)
 }
 
 int
-string_desc_concat (string_desc_t *resultp, idx_t n, string_desc_t string1, ...)
+sd_concat (string_desc_t *resultp, idx_t n, string_desc_t string1, ...)
 {
   if (n <= 0)
     /* Invalid argument.  */
@@ -327,7 +327,7 @@ string_desc_concat (string_desc_t *resultp, idx_t n, string_desc_t string1, ...)
 }
 
 char *
-string_desc_c (string_desc_t s)
+sd_c (string_desc_t s)
 {
   idx_t n = s._nbytes;
   char *result = (char *) imalloc (n + 1);
@@ -345,7 +345,7 @@ string_desc_c (string_desc_t s)
 /* ==== Operations with side effects on string descriptors ==== */
 
 void
-string_desc_set_char_at (string_desc_t s, idx_t i, char c)
+sd_set_char_at (string_desc_t s, idx_t i, char c)
 {
   if (!(i >= 0 && i < s._nbytes))
     /* Invalid argument.  */
@@ -354,7 +354,7 @@ string_desc_set_char_at (string_desc_t s, idx_t i, char c)
 }
 
 void
-string_desc_fill (string_desc_t s, idx_t start, idx_t end, char c)
+sd_fill (string_desc_t s, idx_t start, idx_t end, char c)
 {
   if (!(start >= 0 && start <= end))
     /* Invalid arguments.  */
@@ -365,7 +365,7 @@ string_desc_fill (string_desc_t s, idx_t start, idx_t end, char c)
 }
 
 void
-string_desc_overwrite (string_desc_t s, idx_t start, string_desc_t t)
+sd_overwrite (string_desc_t s, idx_t start, string_desc_t t)
 {
   if (!(start >= 0 && start + t._nbytes <= s._nbytes))
     /* Invalid arguments.  */
@@ -376,7 +376,7 @@ string_desc_overwrite (string_desc_t s, idx_t start, string_desc_t t)
 }
 
 void
-string_desc_free (string_desc_t s)
+sd_free (string_desc_t s)
 {
   free (s._data);
 }
index 5854220d05d2e0536fead9004b1d5b011f7eb957..12a0fb199b92b49da3b99ce1cb47e887871acaa2 100644 (file)
@@ -69,82 +69,82 @@ struct string_desc_t
 
 /* Return the length of the string S.  */
 #if 0 /* Defined inline below.  */
-extern idx_t string_desc_length (string_desc_t s);
+extern idx_t sd_length (string_desc_t s);
 #endif
 
 /* Return the byte at index I of string S.
    I must be < length(S).  */
 #if 0 /* Defined inline below.  */
-extern char string_desc_char_at (string_desc_t s, idx_t i);
+extern char sd_char_at (string_desc_t s, idx_t i);
 #endif
 
 /* Return a read-only view of the bytes of S.  */
 #if 0 /* Defined inline below.  */
-extern const char * string_desc_data (string_desc_t s);
+extern const char * sd_data (string_desc_t s);
 #endif
 
 /* Return true if S is the empty string.  */
 #if 0 /* Defined inline below.  */
-extern bool string_desc_is_empty (string_desc_t s);
+extern bool sd_is_empty (string_desc_t s);
 #endif
 
 /* Return true if A and B are equal.  */
-extern bool string_desc_equals (string_desc_t a, string_desc_t b);
+extern bool sd_equals (string_desc_t a, string_desc_t b);
 
 /* Return true if S starts with PREFIX.  */
-extern bool string_desc_startswith (string_desc_t s, string_desc_t prefix);
+extern bool sd_startswith (string_desc_t s, string_desc_t prefix);
 
 /* Return true if S ends with SUFFIX.  */
-extern bool string_desc_endswith (string_desc_t s, string_desc_t suffix);
+extern bool sd_endswith (string_desc_t s, string_desc_t 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_t a, string_desc_t b);
+extern int sd_cmp (string_desc_t a, string_desc_t b);
 
 /* Return > 0, == 0, or < 0 if A > B, A == B, A < B.
    Either A or B must be entirely ASCII.
    This uses a lexicographic ordering, where the bytes are compared as
    'unsigned char', ignoring case, in the "C" locale.  */
-extern int string_desc_c_casecmp (string_desc_t a, string_desc_t b);
+extern int sd_c_casecmp (string_desc_t a, string_desc_t 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_t s, char c);
+extern ptrdiff_t sd_index (string_desc_t 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_t s, char c);
+extern ptrdiff_t sd_last_index (string_desc_t 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_t haystack, string_desc_t needle);
+extern ptrdiff_t sd_contains (string_desc_t haystack, string_desc_t needle);
 
 /* Return an empty string.  */
-extern string_desc_t string_desc_new_empty (void);
+extern string_desc_t sd_new_empty (void);
 
 /* Construct and return a string of length N, at the given memory address.  */
-extern string_desc_t string_desc_new_addr (idx_t n, char *addr);
+extern string_desc_t sd_new_addr (idx_t n, char *addr);
 
 /* Return a string that represents the C string S, of length strlen (S).  */
-extern string_desc_t string_desc_from_c (const char *s);
+extern string_desc_t sd_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_t string_desc_substring (string_desc_t s, idx_t start, idx_t end);
+extern string_desc_t sd_substring (string_desc_t s, idx_t start, idx_t end);
 
 /* Output S to the file descriptor FD.
    Return 0 if successful.
    Upon error, return -1 with errno set.  */
-extern int string_desc_write (int fd, string_desc_t s);
+extern int sd_write (int fd, string_desc_t s);
 
 /* Output S to the FILE stream FP.
    Return 0 if successful.
    Upon error, return -1.  */
-extern int string_desc_fwrite (FILE *fp, string_desc_t s);
+extern int sd_fwrite (FILE *fp, string_desc_t s);
 
 
 /* ==== Memory-allocating operations on string descriptors ==== */
@@ -153,61 +153,61 @@ extern int string_desc_fwrite (FILE *fp, string_desc_t s);
    Return 0 if successful.
    Upon error, return -1 with errno set.  */
 _GL_ATTRIBUTE_NODISCARD
-extern int string_desc_new (string_desc_t *resultp, idx_t n);
+extern int sd_new (string_desc_t *resultp, idx_t n);
 
 /* Construct a string of length N, filled with C.
    Return 0 if successful.
    Upon error, return -1 with errno set.  */
 _GL_ATTRIBUTE_NODISCARD
-extern int string_desc_new_filled (string_desc_t *resultp, idx_t n, char c);
+extern int sd_new_filled (string_desc_t *resultp, idx_t n, char c);
 
 /* Construct a copy of string S.
    Return 0 if successful.
    Upon error, return -1 with errno set.  */
 _GL_ATTRIBUTE_NODISCARD
-extern int string_desc_copy (string_desc_t *resultp, string_desc_t s);
+extern int sd_copy (string_desc_t *resultp, string_desc_t s);
 
 /* Construct the concatenation of N strings.  N must be > 0.
    Return 0 if successful.
    Upon error, return -1 with errno set.  */
 _GL_ATTRIBUTE_NODISCARD
-extern int string_desc_concat (string_desc_t *resultp, idx_t n, string_desc_t string1, ...);
+extern int sd_concat (string_desc_t *resultp, idx_t n, string_desc_t string1, ...);
 
 /* Construct a copy of string S, as a NUL-terminated C string.
    Return it is successful.
    Upon error, return NULL with errno set.  */
-extern char * string_desc_c (string_desc_t s) _GL_ATTRIBUTE_DEALLOC_FREE;
+extern char * sd_c (string_desc_t s) _GL_ATTRIBUTE_DEALLOC_FREE;
 
 
 /* ==== 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_t s, idx_t i, char c);
+extern void sd_set_char_at (string_desc_t s, idx_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_t s, idx_t start, idx_t end, char c);
+extern void sd_fill (string_desc_t s, idx_t start, idx_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_t s, idx_t start, string_desc_t t);
+extern void sd_overwrite (string_desc_t s, idx_t start, string_desc_t t);
 
 /* Free S.  */
-extern void string_desc_free (string_desc_t s);
+extern void sd_free (string_desc_t s);
 
 
 /* ==== Inline function definitions ==== */
 
 GL_STRING_DESC_INLINE idx_t
-string_desc_length (string_desc_t s)
+sd_length (string_desc_t s)
 {
   return s._nbytes;
 }
 
 GL_STRING_DESC_INLINE char
-string_desc_char_at (string_desc_t s, idx_t i)
+sd_char_at (string_desc_t s, idx_t i)
 {
   if (!(i >= 0 && i < s._nbytes))
     /* Invalid argument.  */
@@ -216,13 +216,13 @@ string_desc_char_at (string_desc_t s, idx_t i)
 }
 
 GL_STRING_DESC_INLINE const char *
-string_desc_data (string_desc_t s)
+sd_data (string_desc_t s)
 {
   return s._data;
 }
 
 GL_STRING_DESC_INLINE bool
-string_desc_is_empty (string_desc_t s)
+sd_is_empty (string_desc_t s)
 {
   return s._nbytes == 0;
 }
index f96e541a69be55c9e79481c4ab97bd27dfdf71ea..7518f4f3816dacfad0542606005fd2e2eea012c2 100644 (file)
@@ -59,10 +59,10 @@ sb_xdupfree (struct string_buffer *buffer)
   if (buffer->error)
     {
       sb_free (buffer);
-      return string_desc_new_addr (0, NULL);
+      return sd_new_addr (0, NULL);
     }
   string_desc_t contents = sb_dupfree (buffer);
-  if (string_desc_data (contents) == NULL)
+  if (sd_data (contents) == NULL)
     xalloc_die ();
   return contents;
 }
index b1d52cafaba047e919a5099ad53c049c132667ad..69520e2b0ab7e844f3743e9b5009f7e03747f4c6 100644 (file)
@@ -22,7 +22,7 @@
 #include "ialloc.h"
 
 string_desc_t
-xstring_desc_concat (idx_t n, string_desc_t string1, ...)
+xsd_concat (idx_t n, string_desc_t string1, ...)
 {
   if (n <= 0)
     /* Invalid argument.  */
index f5acf8434d213d706971d61986d25bb76206b8ec..7957795d9853614133ea63f6635d7f74784f7163 100644 (file)
@@ -43,53 +43,53 @@ extern "C" {
 
 /* Return a string of length N, with uninitialized contents.  */
 #if 0 /* Defined inline below.  */
-extern string_desc_t xstring_desc_new (idx_t n);
+extern string_desc_t xsd_new (idx_t n);
 #endif
 
 /* Return a string of length N, filled with C.  */
 #if 0 /* Defined inline below.  */
-extern string_desc_t xstring_desc_new_filled (idx_t n, char c);
+extern string_desc_t xsd_new_filled (idx_t n, char c);
 #endif
 
 /* Return a copy of string S.  */
 #if 0 /* Defined inline below.  */
-extern string_desc_t xstring_desc_copy (string_desc_t s);
+extern string_desc_t xsd_copy (string_desc_t s);
 #endif
 
 /* Return the concatenation of N strings.  N must be > 0.  */
-extern string_desc_t xstring_desc_concat (idx_t n, string_desc_t string1, ...);
+extern string_desc_t xsd_concat (idx_t n, string_desc_t string1, ...);
 
 /* Construct and return a copy of string S, as a NUL-terminated C string.  */
 #if 0 /* Defined inline below.  */
-extern char * xstring_desc_c (string_desc_t s) _GL_ATTRIBUTE_DEALLOC_FREE;
+extern char * xsd_c (string_desc_t s) _GL_ATTRIBUTE_DEALLOC_FREE;
 #endif
 
 
 /* ==== Inline function definitions ==== */
 
 GL_XSTRING_DESC_INLINE string_desc_t
-xstring_desc_new (idx_t n)
+xsd_new (idx_t n)
 {
   string_desc_t result;
-  if (string_desc_new (&result, n) < 0)
+  if (sd_new (&result, n) < 0)
     xalloc_die ();
   return result;
 }
 
 GL_XSTRING_DESC_INLINE string_desc_t
-xstring_desc_new_filled (idx_t n, char c)
+xsd_new_filled (idx_t n, char c)
 {
   string_desc_t result;
-  if (string_desc_new_filled (&result, n, c) < 0)
+  if (sd_new_filled (&result, n, c) < 0)
     xalloc_die ();
   return result;
 }
 
 GL_XSTRING_DESC_INLINE string_desc_t
-xstring_desc_copy (string_desc_t s)
+xsd_copy (string_desc_t s)
 {
   string_desc_t result;
-  if (string_desc_copy (&result, s) < 0)
+  if (sd_copy (&result, s) < 0)
     xalloc_die ();
   return result;
 }
@@ -97,9 +97,9 @@ xstring_desc_copy (string_desc_t s)
 GL_XSTRING_DESC_INLINE
 _GL_ATTRIBUTE_DEALLOC_FREE
 char *
-xstring_desc_c (string_desc_t s)
+xsd_c (string_desc_t s)
 {
-  char *result = string_desc_c (s);
+  char *result = sd_c (s);
   if (result == NULL)
     xalloc_die ();
   return result;
index f9d0a09d4490ea9d40bb9603b6527d3b57163754..e3063c34d6aeecdf170c5bad79f770872db16073 100644 (file)
@@ -91,8 +91,8 @@ main ()
   {
     sf_istream_t stream;
     sf_istream_init_from_string_desc (&stream,
-                                      string_desc_new_addr (CONTENTS_LEN,
-                                                            (char *) contents));
+                                      sd_new_addr (CONTENTS_LEN,
+                                                   (char *) contents));
     test_open_stream (&stream);
     sf_free (&stream);
   }
index 931f8615cdbfa2728f1223da20c99eb6d64eb6d1..e0e9a02a9e6ce4013aa28a84bfaf7f7183a530c5 100644 (file)
@@ -115,8 +115,8 @@ main ()
   {
     sfl_istream_t stream;
     sfl_istream_init_from_string_desc (&stream,
-                                       string_desc_new_addr (CONTENTS_LEN,
-                                                             (char *) contents));
+                                       sd_new_addr (CONTENTS_LEN,
+                                                    (char *) contents));
     test_open_stream (&stream);
     sfl_free (&stream);
   }
index 216f4cdab4fa4502712f36b452da88f707a0ecfa..fa3bb82bb6de0e279504b7d27bfcef2991cdb0f2 100644 (file)
@@ -63,19 +63,19 @@ main ()
     sb_append1 (&buffer, '\377');
     {
       string_desc_t sd = sb_contents (&buffer);
-      ASSERT (string_desc_length (sd) == 2);
-      ASSERT (string_desc_char_at (sd, 0) == 'x');
-      ASSERT (string_desc_char_at (sd, 1) == '\377');
+      ASSERT (sd_length (sd) == 2);
+      ASSERT (sd_char_at (sd, 0) == 'x');
+      ASSERT (sd_char_at (sd, 1) == '\377');
     }
     sb_append1 (&buffer, '\0');
     sb_append1 (&buffer, 'z');
     {
       string_desc_t sd = sb_contents (&buffer);
-      ASSERT (string_desc_length (sd) == 4);
-      ASSERT (string_desc_char_at (sd, 0) == 'x');
-      ASSERT (string_desc_char_at (sd, 1) == '\377');
-      ASSERT (string_desc_char_at (sd, 2) == '\0');
-      ASSERT (string_desc_char_at (sd, 3) == 'z');
+      ASSERT (sd_length (sd) == 4);
+      ASSERT (sd_char_at (sd, 0) == 'x');
+      ASSERT (sd_char_at (sd, 1) == '\377');
+      ASSERT (sd_char_at (sd, 2) == '\0');
+      ASSERT (sd_char_at (sd, 3) == 'z');
     }
     char *s = sb_dupfree_c (&buffer);
     ASSERT (s != NULL && memcmp (s, "x\377\0z\0", 5) == 0);
@@ -109,7 +109,7 @@ main ()
 
     sb_init (&buffer);
     sb_append_c (&buffer, "abc");
-    sb_append_desc (&buffer, string_desc_new_addr (5, "de\0fg"));
+    sb_append_desc (&buffer, sd_new_addr (5, "de\0fg"));
     sb_append_c (&buffer, "hij");
     char *s = sb_dupfree_c (&buffer);
     ASSERT (s != NULL && memcmp (s, "abcde\0fghij", 12) == 0);
index 865e8f91130aaad8d01b75eeb53b3788232529bc..23c290e957a013ac3cb1d86d0fcf389466277f9c 100644 (file)
 int
 main (void)
 {
-  string_desc_t s1 = string_desc_from_c ("Hello world!");
-  string_desc_t s2 = string_desc_new_addr (21, "The\0quick\0brown\0\0fox");
+  string_desc_t s1 = sd_from_c ("Hello world!");
+  string_desc_t s2 = sd_new_addr (21, "The\0quick\0brown\0\0fox");
 
-  /* Test string_desc_quotearg_buffer.  */
+  /* Test sd_quotearg_buffer.  */
   {
     char buf[80];
-    size_t n = string_desc_quotearg_buffer (buf, sizeof (buf), s2, NULL);
+    size_t n = sd_quotearg_buffer (buf, sizeof (buf), s2, NULL);
     ASSERT (n == 21);
     ASSERT (memcmp (buf, "The\0quick\0brown\0\0fox", n) == 0);
   }
 
-  /* Test string_desc_quotearg_alloc.  */
+  /* Test sd_quotearg_alloc.  */
   {
     size_t n;
-    char *ret = string_desc_quotearg_alloc (s2, &n, NULL);
+    char *ret = sd_quotearg_alloc (s2, &n, NULL);
     ASSERT (n == 21);
     ASSERT (memcmp (ret, "The\0quick\0brown\0\0fox", n) == 0);
     free (ret);
   }
 
-  /* Test string_desc_quotearg_n.  */
+  /* Test sd_quotearg_n.  */
   {
-    char *ret = string_desc_quotearg_n (1, s2);
+    char *ret = sd_quotearg_n (1, s2);
     ASSERT (memcmp (ret, "Thequickbrownfox", 16 + 1) == 0);
   }
 
-  /* Test string_desc_quotearg.  */
+  /* Test sd_quotearg.  */
   {
-    char *ret = string_desc_quotearg (s2);
+    char *ret = sd_quotearg (s2);
     ASSERT (memcmp (ret, "Thequickbrownfox", 16 + 1) == 0);
   }
 
-  /* Test string_desc_quotearg_n_style.  */
+  /* Test sd_quotearg_n_style.  */
   {
-    char *ret = string_desc_quotearg_n_style (1, clocale_quoting_style, s2);
+    char *ret = sd_quotearg_n_style (1, clocale_quoting_style, s2);
     ASSERT (memcmp (ret, "\"The\\0quick\\0brown\\0\\0fox\\0\"", 28 + 1) == 0
             || /* if the locale has UTF-8 encoding */
                memcmp (ret, "\342\200\230The\\0quick\\0brown\\0\\0fox\\0\342\200\231", 32 + 1) == 0);
   }
 
-  /* Test string_desc_quotearg_style.  */
+  /* Test sd_quotearg_style.  */
   {
-    char *ret = string_desc_quotearg_style (clocale_quoting_style, s2);
+    char *ret = sd_quotearg_style (clocale_quoting_style, s2);
     ASSERT (memcmp (ret, "\"The\\0quick\\0brown\\0\\0fox\\0\"", 28 + 1) == 0
             || /* if the locale has UTF-8 encoding */
                memcmp (ret, "\342\200\230The\\0quick\\0brown\\0\\0fox\\0\342\200\231", 32 + 1) == 0);
   }
 
-  /* Test string_desc_quotearg_char.  */
+  /* Test sd_quotearg_char.  */
   {
-    char *ret = string_desc_quotearg_char (s1, ' ');
+    char *ret = sd_quotearg_char (s1, ' ');
     ASSERT (memcmp (ret, "Hello world!", 12 + 1) == 0); /* ' ' not quoted?! */
   }
 
-  /* Test string_desc_quotearg_colon.  */
+  /* Test sd_quotearg_colon.  */
   {
-    char *ret = string_desc_quotearg_colon (string_desc_from_c ("a:b"));
+    char *ret = sd_quotearg_colon (sd_from_c ("a:b"));
     ASSERT (memcmp (ret, "a:b", 3 + 1) == 0); /* ':' not quoted?! */
   }
 
-  /* Test string_desc_quotearg_n_custom.  */
+  /* Test sd_quotearg_n_custom.  */
   {
-    char *ret = string_desc_quotearg_n_custom (2, "<", ">", s1);
+    char *ret = sd_quotearg_n_custom (2, "<", ">", s1);
     ASSERT (memcmp (ret, "<Hello world!>", 14 + 1) == 0);
   }
 
-  /* Test string_desc_quotearg_n_custom.  */
+  /* Test sd_quotearg_n_custom.  */
   {
-    char *ret = string_desc_quotearg_custom ("[[", "]]", s1);
+    char *ret = sd_quotearg_custom ("[[", "]]", s1);
     ASSERT (memcmp (ret, "[[Hello world!]]", 16 + 1) == 0);
   }
 
index 2fd82f74f956e964007ba4230d395677702a7a76..d90b548f6af8281a3ecefae6e2ac6b74b146c513 100644 (file)
@@ -34,172 +34,172 @@ main (int argc, char *argv[])
   int fd3 = open (argv[1], O_RDWR | O_TRUNC | O_CREAT, 0600);
   ASSERT (fd3 >= 0);
 
-  string_desc_t s0 = string_desc_new_empty ();
-  string_desc_t s1 = string_desc_from_c ("Hello world!");
-  string_desc_t s2 = string_desc_new_addr (21, "The\0quick\0brown\0\0fox");
-
-  /* Test string_desc_length.  */
-  ASSERT (string_desc_length (s0) == 0);
-  ASSERT (string_desc_length (s1) == 12);
-  ASSERT (string_desc_length (s2) == 21);
-
-  /* Test string_desc_char_at.  */
-  ASSERT (string_desc_char_at (s1, 0) == 'H');
-  ASSERT (string_desc_char_at (s1, 11) == '!');
-  ASSERT (string_desc_char_at (s2, 0) == 'T');
-  ASSERT (string_desc_char_at (s2, 1) == 'h');
-  ASSERT (string_desc_char_at (s2, 2) == 'e');
-  ASSERT (string_desc_char_at (s2, 3) == '\0');
-  ASSERT (string_desc_char_at (s2, 4) == 'q');
-  ASSERT (string_desc_char_at (s2, 15) == '\0');
-  ASSERT (string_desc_char_at (s2, 16) == '\0');
-
-  /* Test string_desc_data.  */
-  (void) string_desc_data (s0);
-  ASSERT (memcmp (string_desc_data (s1), "Hello world!", 12) == 0);
-  ASSERT (memcmp (string_desc_data (s2), "The\0quick\0brown\0\0fox", 21) == 0);
-
-  /* Test string_desc_is_empty.  */
-  ASSERT (string_desc_is_empty (s0));
-  ASSERT (!string_desc_is_empty (s1));
-  ASSERT (!string_desc_is_empty (s2));
-
-  /* Test string_desc_startswith.  */
-  ASSERT (string_desc_startswith (s1, s0));
-  ASSERT (!string_desc_startswith (s0, s1));
-  ASSERT (!string_desc_startswith (s1, s2));
-  ASSERT (!string_desc_startswith (s2, s1));
-  ASSERT (string_desc_startswith (s2, string_desc_from_c ("The")));
-  ASSERT (string_desc_startswith (s2, string_desc_new_addr (9, "The\0quick")));
-  ASSERT (!string_desc_startswith (s2, string_desc_new_addr (9, "The\0quirk")));
-
-  /* Test string_desc_endswith.  */
-  ASSERT (string_desc_endswith (s1, s0));
-  ASSERT (!string_desc_endswith (s0, s1));
-  ASSERT (!string_desc_endswith (s1, s2));
-  ASSERT (!string_desc_endswith (s2, s1));
-  ASSERT (!string_desc_endswith (s2, string_desc_from_c ("fox")));
-  ASSERT (string_desc_endswith (s2, string_desc_new_addr (4, "fox")));
-  ASSERT (string_desc_endswith (s2, string_desc_new_addr (6, "\0\0fox")));
-  ASSERT (!string_desc_endswith (s2, string_desc_new_addr (5, "\0\0ox")));
-
-  /* Test string_desc_cmp.  */
-  ASSERT (string_desc_cmp (s0, s0) == 0);
-  ASSERT (string_desc_cmp (s0, s1) < 0);
-  ASSERT (string_desc_cmp (s0, s2) < 0);
-  ASSERT (string_desc_cmp (s1, s0) > 0);
-  ASSERT (string_desc_cmp (s1, s1) == 0);
-  ASSERT (string_desc_cmp (s1, s2) < 0);
-  ASSERT (string_desc_cmp (s2, s0) > 0);
-  ASSERT (string_desc_cmp (s2, s1) > 0);
-  ASSERT (string_desc_cmp (s2, s2) == 0);
-
-  /* Test string_desc_c_casecmp.  */
-  ASSERT (string_desc_c_casecmp (s0, s0) == 0);
-  ASSERT (string_desc_c_casecmp (s0, s1) < 0);
-  ASSERT (string_desc_c_casecmp (s0, s2) < 0);
-  ASSERT (string_desc_c_casecmp (s1, s0) > 0);
-  ASSERT (string_desc_c_casecmp (s1, s1) == 0);
-  ASSERT (string_desc_c_casecmp (s1, s2) < 0);
-  ASSERT (string_desc_c_casecmp (s2, s0) > 0);
-  ASSERT (string_desc_c_casecmp (s2, s1) > 0);
-  ASSERT (string_desc_c_casecmp (s2, s2) == 0);
-  ASSERT (string_desc_c_casecmp (string_desc_from_c ("acab"), string_desc_from_c ("AcAB")) == 0);
-  ASSERT (string_desc_c_casecmp (string_desc_from_c ("AcAB"), string_desc_from_c ("acab")) == 0);
-  ASSERT (string_desc_c_casecmp (string_desc_from_c ("aca"), string_desc_from_c ("AcAB")) < 0);
-  ASSERT (string_desc_c_casecmp (string_desc_from_c ("AcAB"), string_desc_from_c ("aca")) > 0);
-  ASSERT (string_desc_c_casecmp (string_desc_from_c ("aca"), string_desc_from_c ("Aca\377")) < 0);
-  ASSERT (string_desc_c_casecmp (string_desc_from_c ("Aca\377"), string_desc_from_c ("aca")) > 0);
-
-  /* Test string_desc_index.  */
-  ASSERT (string_desc_index (s0, 'o') == -1);
-  ASSERT (string_desc_index (s2, 'o') == 12);
-
-  /* Test string_desc_last_index.  */
-  ASSERT (string_desc_last_index (s0, 'o') == -1);
-  ASSERT (string_desc_last_index (s2, 'o') == 18);
-
-  /* Test string_desc_contains.  */
-  ASSERT (string_desc_contains (s0, string_desc_from_c ("ll")) == -1);
-  ASSERT (string_desc_contains (s1, string_desc_from_c ("ll")) == 2);
-  ASSERT (string_desc_contains (s1, string_desc_new_addr (1, "")) == -1);
-  ASSERT (string_desc_contains (s2, string_desc_new_addr (1, "")) == 3);
-  ASSERT (string_desc_contains (s1, string_desc_new_addr (2, "\0")) == -1);
-  ASSERT (string_desc_contains (s2, string_desc_new_addr (2, "\0")) == 15);
-
-  /* Test string_desc_substring.  */
-  ASSERT (string_desc_cmp (string_desc_substring (s1, 2, 5),
-                           string_desc_from_c ("llo")) == 0);
-
-  /* Test string_desc_write.  */
-  ASSERT (string_desc_write (fd3, s0) == 0);
-  ASSERT (string_desc_write (fd3, s1) == 0);
-  ASSERT (string_desc_write (fd3, s2) == 0);
-
-  /* Test string_desc_fwrite.  */
-  ASSERT (string_desc_fwrite (stdout, s0) == 0);
-  ASSERT (string_desc_fwrite (stdout, s1) == 0);
-  ASSERT (string_desc_fwrite (stdout, s2) == 0);
-
-  /* Test string_desc_new, string_desc_set_char_at, string_desc_fill.  */
+  string_desc_t s0 = sd_new_empty ();
+  string_desc_t s1 = sd_from_c ("Hello world!");
+  string_desc_t s2 = sd_new_addr (21, "The\0quick\0brown\0\0fox");
+
+  /* Test sd_length.  */
+  ASSERT (sd_length (s0) == 0);
+  ASSERT (sd_length (s1) == 12);
+  ASSERT (sd_length (s2) == 21);
+
+  /* Test sd_char_at.  */
+  ASSERT (sd_char_at (s1, 0) == 'H');
+  ASSERT (sd_char_at (s1, 11) == '!');
+  ASSERT (sd_char_at (s2, 0) == 'T');
+  ASSERT (sd_char_at (s2, 1) == 'h');
+  ASSERT (sd_char_at (s2, 2) == 'e');
+  ASSERT (sd_char_at (s2, 3) == '\0');
+  ASSERT (sd_char_at (s2, 4) == 'q');
+  ASSERT (sd_char_at (s2, 15) == '\0');
+  ASSERT (sd_char_at (s2, 16) == '\0');
+
+  /* Test sd_data.  */
+  (void) sd_data (s0);
+  ASSERT (memcmp (sd_data (s1), "Hello world!", 12) == 0);
+  ASSERT (memcmp (sd_data (s2), "The\0quick\0brown\0\0fox", 21) == 0);
+
+  /* Test sd_is_empty.  */
+  ASSERT (sd_is_empty (s0));
+  ASSERT (!sd_is_empty (s1));
+  ASSERT (!sd_is_empty (s2));
+
+  /* Test sd_startswith.  */
+  ASSERT (sd_startswith (s1, s0));
+  ASSERT (!sd_startswith (s0, s1));
+  ASSERT (!sd_startswith (s1, s2));
+  ASSERT (!sd_startswith (s2, s1));
+  ASSERT (sd_startswith (s2, sd_from_c ("The")));
+  ASSERT (sd_startswith (s2, sd_new_addr (9, "The\0quick")));
+  ASSERT (!sd_startswith (s2, sd_new_addr (9, "The\0quirk")));
+
+  /* Test sd_endswith.  */
+  ASSERT (sd_endswith (s1, s0));
+  ASSERT (!sd_endswith (s0, s1));
+  ASSERT (!sd_endswith (s1, s2));
+  ASSERT (!sd_endswith (s2, s1));
+  ASSERT (!sd_endswith (s2, sd_from_c ("fox")));
+  ASSERT (sd_endswith (s2, sd_new_addr (4, "fox")));
+  ASSERT (sd_endswith (s2, sd_new_addr (6, "\0\0fox")));
+  ASSERT (!sd_endswith (s2, sd_new_addr (5, "\0\0ox")));
+
+  /* Test sd_cmp.  */
+  ASSERT (sd_cmp (s0, s0) == 0);
+  ASSERT (sd_cmp (s0, s1) < 0);
+  ASSERT (sd_cmp (s0, s2) < 0);
+  ASSERT (sd_cmp (s1, s0) > 0);
+  ASSERT (sd_cmp (s1, s1) == 0);
+  ASSERT (sd_cmp (s1, s2) < 0);
+  ASSERT (sd_cmp (s2, s0) > 0);
+  ASSERT (sd_cmp (s2, s1) > 0);
+  ASSERT (sd_cmp (s2, s2) == 0);
+
+  /* Test sd_c_casecmp.  */
+  ASSERT (sd_c_casecmp (s0, s0) == 0);
+  ASSERT (sd_c_casecmp (s0, s1) < 0);
+  ASSERT (sd_c_casecmp (s0, s2) < 0);
+  ASSERT (sd_c_casecmp (s1, s0) > 0);
+  ASSERT (sd_c_casecmp (s1, s1) == 0);
+  ASSERT (sd_c_casecmp (s1, s2) < 0);
+  ASSERT (sd_c_casecmp (s2, s0) > 0);
+  ASSERT (sd_c_casecmp (s2, s1) > 0);
+  ASSERT (sd_c_casecmp (s2, s2) == 0);
+  ASSERT (sd_c_casecmp (sd_from_c ("acab"), sd_from_c ("AcAB")) == 0);
+  ASSERT (sd_c_casecmp (sd_from_c ("AcAB"), sd_from_c ("acab")) == 0);
+  ASSERT (sd_c_casecmp (sd_from_c ("aca"), sd_from_c ("AcAB")) < 0);
+  ASSERT (sd_c_casecmp (sd_from_c ("AcAB"), sd_from_c ("aca")) > 0);
+  ASSERT (sd_c_casecmp (sd_from_c ("aca"), sd_from_c ("Aca\377")) < 0);
+  ASSERT (sd_c_casecmp (sd_from_c ("Aca\377"), sd_from_c ("aca")) > 0);
+
+  /* Test sd_index.  */
+  ASSERT (sd_index (s0, 'o') == -1);
+  ASSERT (sd_index (s2, 'o') == 12);
+
+  /* Test sd_last_index.  */
+  ASSERT (sd_last_index (s0, 'o') == -1);
+  ASSERT (sd_last_index (s2, 'o') == 18);
+
+  /* Test sd_contains.  */
+  ASSERT (sd_contains (s0, sd_from_c ("ll")) == -1);
+  ASSERT (sd_contains (s1, sd_from_c ("ll")) == 2);
+  ASSERT (sd_contains (s1, sd_new_addr (1, "")) == -1);
+  ASSERT (sd_contains (s2, sd_new_addr (1, "")) == 3);
+  ASSERT (sd_contains (s1, sd_new_addr (2, "\0")) == -1);
+  ASSERT (sd_contains (s2, sd_new_addr (2, "\0")) == 15);
+
+  /* Test sd_substring.  */
+  ASSERT (sd_cmp (sd_substring (s1, 2, 5),
+                  sd_from_c ("llo")) == 0);
+
+  /* Test sd_write.  */
+  ASSERT (sd_write (fd3, s0) == 0);
+  ASSERT (sd_write (fd3, s1) == 0);
+  ASSERT (sd_write (fd3, s2) == 0);
+
+  /* Test sd_fwrite.  */
+  ASSERT (sd_fwrite (stdout, s0) == 0);
+  ASSERT (sd_fwrite (stdout, s1) == 0);
+  ASSERT (sd_fwrite (stdout, s2) == 0);
+
+  /* Test sd_new, sd_set_char_at, sd_fill.  */
   string_desc_t s4;
-  ASSERT (string_desc_new (&s4, 5) == 0);
-  string_desc_set_char_at (s4, 0, 'H');
-  string_desc_set_char_at (s4, 4, 'o');
-  string_desc_set_char_at (s4, 1, 'e');
-  string_desc_fill (s4, 2, 4, 'l');
-  ASSERT (string_desc_length (s4) == 5);
-  ASSERT (string_desc_startswith (s1, s4));
-
-  /* Test string_desc_new_filled, string_desc_set_char_at.  */
+  ASSERT (sd_new (&s4, 5) == 0);
+  sd_set_char_at (s4, 0, 'H');
+  sd_set_char_at (s4, 4, 'o');
+  sd_set_char_at (s4, 1, 'e');
+  sd_fill (s4, 2, 4, 'l');
+  ASSERT (sd_length (s4) == 5);
+  ASSERT (sd_startswith (s1, s4));
+
+  /* Test sd_new_filled, sd_set_char_at.  */
   string_desc_t s5;
-  ASSERT (string_desc_new_filled (&s5, 5, 'l') == 0);
-  string_desc_set_char_at (s5, 0, 'H');
-  string_desc_set_char_at (s5, 4, 'o');
-  string_desc_set_char_at (s5, 1, 'e');
-  ASSERT (string_desc_length (s5) == 5);
-  ASSERT (string_desc_startswith (s1, s5));
-
-  /* Test string_desc_equals.  */
-  ASSERT (!string_desc_equals (s1, s5));
-  ASSERT (string_desc_equals (s4, s5));
-
-  /* Test string_desc_copy, string_desc_free.  */
+  ASSERT (sd_new_filled (&s5, 5, 'l') == 0);
+  sd_set_char_at (s5, 0, 'H');
+  sd_set_char_at (s5, 4, 'o');
+  sd_set_char_at (s5, 1, 'e');
+  ASSERT (sd_length (s5) == 5);
+  ASSERT (sd_startswith (s1, s5));
+
+  /* Test sd_equals.  */
+  ASSERT (!sd_equals (s1, s5));
+  ASSERT (sd_equals (s4, s5));
+
+  /* Test sd_copy, sd_free.  */
   {
     string_desc_t s6;
-    ASSERT (string_desc_copy (&s6, s0) == 0);
-    ASSERT (string_desc_is_empty (s6));
-    string_desc_free (s6);
+    ASSERT (sd_copy (&s6, s0) == 0);
+    ASSERT (sd_is_empty (s6));
+    sd_free (s6);
   }
   {
     string_desc_t s6;
-    ASSERT (string_desc_copy (&s6, s2) == 0);
-    ASSERT (string_desc_equals (s6, s2));
-    string_desc_free (s6);
+    ASSERT (sd_copy (&s6, s2) == 0);
+    ASSERT (sd_equals (s6, s2));
+    sd_free (s6);
   }
 
-  /* Test string_desc_overwrite.  */
+  /* Test sd_overwrite.  */
   {
     string_desc_t s7;
-    ASSERT (string_desc_copy (&s7, s2) == 0);
-    string_desc_overwrite (s7, 4, s1);
-    ASSERT (string_desc_equals (s7, string_desc_new_addr (21, "The\0Hello world!\0fox")));
+    ASSERT (sd_copy (&s7, s2) == 0);
+    sd_overwrite (s7, 4, s1);
+    ASSERT (sd_equals (s7, sd_new_addr (21, "The\0Hello world!\0fox")));
   }
 
-  /* Test string_desc_concat.  */
+  /* Test sd_concat.  */
   {
     string_desc_t s8;
-    ASSERT (string_desc_concat (&s8, 3, string_desc_new_addr (10, "The\0quick"),
-                                        string_desc_new_addr (7, "brown\0"),
-                                        string_desc_new_addr (4, "fox"),
-                                        string_desc_new_addr (7, "unused")) == 0);
-    ASSERT (string_desc_equals (s8, s2));
-    string_desc_free (s8);
+    ASSERT (sd_concat (&s8, 3, sd_new_addr (10, "The\0quick"),
+                               sd_new_addr (7, "brown\0"),
+                               sd_new_addr (4, "fox"),
+                               sd_new_addr (7, "unused")) == 0);
+    ASSERT (sd_equals (s8, s2));
+    sd_free (s8);
   }
 
-  /* Test string_desc_c.  */
+  /* Test sd_c.  */
   {
-    char *ptr = string_desc_c (s2);
+    char *ptr = sd_c (s2);
     ASSERT (ptr != NULL);
     ASSERT (memcmp (ptr, "The\0quick\0brown\0\0fox\0", 22) == 0);
     free (ptr);
index a4d92792eb4d56fdee6604400db5ddf55d538fe5..a6ee1ac4245557c88758641caa4e6d148cad03e9 100755 (executable)
@@ -6,7 +6,7 @@ ${CHECKER} test-string-desc${EXEEXT} test-string-desc-3.tmp > test-string-desc-1
 printf 'Hello world!The\0quick\0brown\0\0fox\0' > test-string-desc.ok
 
 : "${DIFF=diff}"
-${DIFF} test-string-desc.ok test-string-desc-1.tmp || { echo "string_desc_fwrite KO" 1>&2; Exit 1; }
-${DIFF} test-string-desc.ok test-string-desc-3.tmp || { echo "string_desc_write KO" 1>&2; Exit 1; }
+${DIFF} test-string-desc.ok test-string-desc-1.tmp || { echo "sd_fwrite KO" 1>&2; Exit 1; }
+${DIFF} test-string-desc.ok test-string-desc-3.tmp || { echo "sd_write KO" 1>&2; Exit 1; }
 
 Exit 0
index 8d361d0770f3a9737efd9954d1001699a1a5c639..d74063404992777cd481e9e48671c16780437169 100644 (file)
 int
 main (void)
 {
-  string_desc_t s0 = string_desc_new_empty ();
-  string_desc_t s1 = string_desc_from_c ("Hello world!");
-  string_desc_t s2 = string_desc_new_addr (21, "The\0quick\0brown\0\0fox");
+  string_desc_t s0 = sd_new_empty ();
+  string_desc_t s1 = sd_from_c ("Hello world!");
+  string_desc_t s2 = sd_new_addr (21, "The\0quick\0brown\0\0fox");
 
-  /* Test xstring_desc_new.  */
-  string_desc_t s4 = xstring_desc_new (5);
-  string_desc_set_char_at (s4, 0, 'H');
-  string_desc_set_char_at (s4, 4, 'o');
-  string_desc_set_char_at (s4, 1, 'e');
-  string_desc_fill (s4, 2, 4, 'l');
-  ASSERT (string_desc_length (s4) == 5);
-  ASSERT (string_desc_startswith (s1, s4));
+  /* Test xsd_new.  */
+  string_desc_t s4 = xsd_new (5);
+  sd_set_char_at (s4, 0, 'H');
+  sd_set_char_at (s4, 4, 'o');
+  sd_set_char_at (s4, 1, 'e');
+  sd_fill (s4, 2, 4, 'l');
+  ASSERT (sd_length (s4) == 5);
+  ASSERT (sd_startswith (s1, s4));
 
-  /* Test xstring_desc_new_filled.  */
-  string_desc_t s5 = xstring_desc_new_filled (5, 'l');
-  string_desc_set_char_at (s5, 0, 'H');
-  string_desc_set_char_at (s5, 4, 'o');
-  string_desc_set_char_at (s5, 1, 'e');
-  ASSERT (string_desc_length (s5) == 5);
-  ASSERT (string_desc_startswith (s1, s5));
+  /* Test xsd_new_filled.  */
+  string_desc_t s5 = xsd_new_filled (5, 'l');
+  sd_set_char_at (s5, 0, 'H');
+  sd_set_char_at (s5, 4, 'o');
+  sd_set_char_at (s5, 1, 'e');
+  ASSERT (sd_length (s5) == 5);
+  ASSERT (sd_startswith (s1, s5));
 
-  /* Test xstring_desc_copy.  */
+  /* Test xsd_copy.  */
   {
-    string_desc_t s6 = xstring_desc_copy (s0);
-    ASSERT (string_desc_is_empty (s6));
-    string_desc_free (s6);
+    string_desc_t s6 = xsd_copy (s0);
+    ASSERT (sd_is_empty (s6));
+    sd_free (s6);
   }
   {
-    string_desc_t s6 = xstring_desc_copy (s2);
-    ASSERT (string_desc_equals (s6, s2));
-    string_desc_free (s6);
+    string_desc_t s6 = xsd_copy (s2);
+    ASSERT (sd_equals (s6, s2));
+    sd_free (s6);
   }
 
-  /* Test xstring_desc_concat.  */
+  /* Test xsd_concat.  */
   {
     string_desc_t s8 =
-      xstring_desc_concat (3, string_desc_new_addr (10, "The\0quick"),
-                              string_desc_new_addr (7, "brown\0"),
-                              string_desc_new_addr (4, "fox"),
-                              string_desc_new_addr (7, "unused"));
-    ASSERT (string_desc_equals (s8, s2));
-    string_desc_free (s8);
+      xsd_concat (3, sd_new_addr (10, "The\0quick"),
+                     sd_new_addr (7, "brown\0"),
+                     sd_new_addr (4, "fox"),
+                     sd_new_addr (7, "unused"));
+    ASSERT (sd_equals (s8, s2));
+    sd_free (s8);
   }
 
-  /* Test xstring_desc_c.  */
+  /* Test xsd_c.  */
   {
-    char *ptr = xstring_desc_c (s2);
+    char *ptr = xsd_c (s2);
     ASSERT (ptr != NULL);
     ASSERT (memcmp (ptr, "The\0quick\0brown\0\0fox\0", 22) == 0);
     free (ptr);