[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
xstring.h
From: |
Bruno Haible |
Subject: |
xstring.h |
Date: |
Sat, 10 May 2008 01:50:23 +0200 |
User-agent: |
KMail/1.5.4 |
Going a bit farther than Eric's xmemdup0 function, I would like to propose
a module 'xstring' with an <xstring.h> header file that defines the following
functions:
/* Return a substring of the given string, len bytes long starting at str. */
char * xsubstring (const char *str, size_t len);
/* Return a string containing the bytes from the given memory region,
checking that they are not NUL. */
char * xmemtostr (const void *ptr, size_t len);
/* Concatenate an array of strings. The last argument must be NULL. */
char *xstrconcat (const char *string1, ...);
/* Concatenate an array of strings. */
char *xvstrconcat (const char *string[], size_t nstrings);
/* Concatenate an array of strings, freeing all the arguments. The last
argument must be NULL. */
char *xstrconcat_free (char *string1, ...);
/* Concatenate an array of strings, freeing all the arguments. */
char *xvstrconcat_free (char *string[], size_t nstrings);
/* Return a freshly allocated string obtained by concatenating all the
strings in the list, separated by the separator character, terminated
by the terminator character. The terminator character is not added if
drop_redundant_terminator is true and the last string already ends with
the terminator. */
char *xstrjoin (char separator, char terminator, bool
drop_redundant_terminator,
const char *string1, ...);
char *xvstrjoin (char separator, char terminator, bool
drop_redundant_terminator,
const char *string[], size_t nstrings);
/* Duplicate a string. Moved here from xalloc.h. Keeps being declared in
xalloc.h for a transition period, with a warning if it's used from there
(a migration aid). */
char * xstrdup (const char *string);
Comments? Additions?
Bruno
- xstring.h,
Bruno Haible <=