69 for (i = 0; i < n && s[i] !=
'\0'; i += 1 )
94 for (i = 0; i < n && s[i] !=
'\0'; i += 1 )
108 #define BUFFER_SIZE_INCREMENT 128
110 #define MAX(x,y) (((x)>(y))?(x):(y))
122 static char buf[ 20 ] ;
123 sprintf( &
buf[0],
"%d", i ) ;
149 size_t len = strlen(s);
187 char * initial_buffer =
buffer;
189 if (next && next!=initial_buffer)
195 va_start(args, next);
199 if (next!=initial_buffer)
201 next = va_arg(args,
string);
202 message_assert(
"reuse concatenate result only as the first argument",
203 !next || next!=initial_buffer);
218 *
s1 = (islower((
int)*s2)) ? toupper(*s2) : *s2;
233 *
s1 = (isupper((
int)*s2)) ? tolower(*s2) : *s2;
245 return b?
"true":
"false";
254 message_assert(
"Formal parameter i is greater or equal to 1", i >= 1);
257 case 1: suffix =
"st";
259 case 2: suffix =
"nd";
261 case 3: suffix =
"rd";
263 default: suffix =
"th";
275 size_t l = strlen(s);
276 size_t l_suffix = strlen(suffix);
282 string suffix_position = s + l - l_suffix;
283 if (memcmp(suffix_position, suffix, l_suffix) == 0)
285 return suffix_position;
298 if (flg ==
true) r =
strdup(s);
301 if (*(r + l - 1) ==
'\n') *(r + l - 1) =
'\0';
322 for(
string tmp = strtok(
buffer,d); tmp;tmp=strtok(NULL,d))
333 return strcmp(*(
char **)
s1, *(
char **)s2);
list gen_nreverse(list cp)
reverse a list in place
#define NIL
The empty list (nil in Lisp)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
#define message_assert(msg, ex)
static const char * prefix
string remove_newline_of_string(string s)
string bool_to_string(bool b)
string get_the_buffer(void)
string append_to_the_buffer(const char *s)
If the string is undefined, just skip it.
string chop_newline(string s, bool flg)
string gen_strndup(string s, size_t n)
Like strdup() but copy at most n characters.
string gen_strndup0(string s, size_t n)
Like strdup() but copy at most n characters.
string find_suffix(const string s, const string suffix)
Find if a string s end with a suffix.
string strupper(string s1, const char *s2)
string strlower(string s1, const char *s2)
static size_t buffer_size
#define BUFFER_SIZE_INCREMENT
CONCATENATE() *********** Last argument must be NULL.
list strsplit(const char *s, const char *d)
string concatenate(const char *next,...)
Return the concatenation of the given strings.
void str_append(string *dst, string suffix)
Append the suffix to the string.
char * i2a(int i)
I2A (Integer TO Ascii) yields a string for a given Integer.
void init_the_buffer(void)
void str_prepend(string *dst, string prefix)
Prepend the prefix to the string.
int gen_qsort_string_cmp(const void *s1, const void *s2)
Callback for sorting string with qsort.
The structure used to build lists in NewGen.