23 #include <lal/LALString.h>
24 #include <lal/XLALError.h>
25 #include <lal/LALMalloc.h>
27 static inline int sign(
int s) {
33 #define STRCMPCHK(XLALCMP, XLALS1, XLALS2, CCMP, CS1, CS2) do { \
34 int xlalsign = sign(XLALCMP(XLALS1, XLALS2)); \
35 int csign = sign(CCMP(CS1, CS2)); \
36 XLAL_CHECK_MAIN( xlalsign == csign, XLAL_EFAILED, \
37 "Failed string comparison test: sign(%s('%s','%s')) = %i, sign(%s('%s','%s')) = %i\n", \
38 #XLALCMP, XLALS1, XLALS2, xlalsign, #CCMP, CS1, CS2, csign ); \
41 #define STRNCMPCHK(N, XLALCMP, XLALS1, XLALS2, CCMP, CS1, CS2) do { \
42 int xlalsign = sign(XLALCMP(XLALS1, XLALS2, N)); \
43 int csign = sign(CCMP(CS1, CS2, N)); \
44 XLAL_CHECK_MAIN( xlalsign == csign, XLAL_EFAILED, \
45 "Failed string comparison test: sign(%s('%s','%s',%zu)) = %i, sign(%s('%s','%s',%zu)) = %i\n", \
46 #XLALCMP, XLALS1, XLALS2, N, xlalsign, #CCMP, CS1, CS2, N, csign ); \
75 for (
size_t n = 0; n < 12; ++n) {
96 char s[] =
"abc,def-,ghij k-lmn, ,-";
107 char s[] =
"abc,def-,ghij k-lmn, ,-";
122 strcpy( s,
"a0!bCd1$E2fG^&H3i*4(j5Kl$6mN %op&qRs7&t8V,..9VW/X?0YZ" );
124 strcpy( s,
"a0!bCd1$E2fG^&H3i*4(j5Kl$6mN %op&qRs7&t8V,..9VW/X?0YZ" );
126 strcpy( s,
"a0!bCd1$E2fG^&H3i*4(j5Kl$6mN %op&qRs7&t8V,..9VW/X?0YZ" );
128 strcpy( s,
"a0!bCd1$E2fG^&H3i*4(j5Kl$6mN %op&qRs7&t8V,..9VW/X?0YZ" );
134 strcpy( s,
"a0!bCd1$E2fG^&H3i*4(j5Kl$6mN %op&qRs7&t8V,..9VW/X?0YZ" );
136 strcpy( s,
"a0!bCd1$E2fG^&H3i*4(j5Kl$6mN %op&qRs7&t8V,..9VW/X?0YZ" );
138 strcpy( s,
"a0!bCd1$E2fG^&H3i*4(j5Kl$6mN %op&qRs7&t8V,..9VW/X?0YZ" );
140 strcpy( s,
"a0!bCd1$E2fG^&H3i*4(j5Kl$6mN %op&qRs7&t8V,..9VW/X?0YZ" );
145 char s[] =
"abcbdeacd";
void LALCheckMemoryLeaks(void)
char * XLALStringAppendFmt(char *s, const char *fmt,...)
Append the formatted string 'fmt' to the string 's', which is reallocated with XLALRealloc() to the r...
#define STRCMPCHK(XLALCMP, XLALS1, XLALS2, CCMP, CS1, CS2)
#define STRNCMPCHK(N, XLALCMP, XLALS1, XLALS2, CCMP, CS1, CS2)
char * XLALStringStripChars(char *s, int(*f)(int))
Return the string 's' with all characters for which 'f()' is true removed.
char * XLALStringReplaceChar(char *s, const int from, const int to)
Return the string 's' with all characters 'from' replaced with 'to'.
int XLALStringCaseCompare(const char *s1, const char *s2)
Compare two strings, ignoring case and without using locale-dependent functions.
char * XLALStringKeepChars(char *s, int(*f)(int))
Return the string 's' with all characters for which 'f()' is false removed.
int XLALStringNCaseCompare(const char *s1, const char *s2, size_t n)
Compare the first N characters of two strings, ignoring case and without using locale-dependent funct...
char * XLALStringToken(char **s, const char *delim, int empty)
Return the next token delimited by any character in 'delim' from the string 's', which is updated to ...
#define XLAL_CHECK(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns an integ...
#define XLAL_CHECK_MAIN(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a C main() routine.
@ XLAL_EFAILED
Generic failure.