42 s->str_end =
s->str_start;
44 memset(
s->str_start, 0, size);
50 if (
s->str_start )
lwfree(
s->str_start);
99 s->str_start[0] =
'\0';
100 s->str_end =
s->str_start;
109 if(
s->str_end ==
s->str_start )
112 return *(
s->str_end - 1);
135 size_t size = (
s->str_end -
s->str_start) + 1;
137 memcpy(
str,
s->str_start, size);
138 str[size - 1] =
'\0';
153 size_t size = (
s->str_end -
s->str_start);
157 memcpy(output->
data,
s->str_start, size);
168 return (
s->str_end -
s->str_start);
198 int maxlen = (
s->capacity - (
s->str_end -
s->str_start));
205 len = vsnprintf(
s->str_end, maxlen,
fmt, ap2);
210 #if defined(__MINGW64_VERSION_MAJOR)
212 len = _vscprintf(
fmt, ap2);
224 maxlen = (
s->capacity - (
s->str_end -
s->str_start));
227 len = vsnprintf(
s->str_end, maxlen,
fmt, ap);
230 if ( len < 0 )
return len;
232 if ( len >= maxlen )
return -1;
264 char *ptr =
s->str_end;
268 while( ptr >
s->str_start )
271 if( (*ptr ==
' ') || (*ptr ==
'\t') )
278 dist =
s->str_end - ptr;
300 char *ptr =
s->str_end;
301 char *decimal_ptr = NULL;
304 if (
s->str_end -
s->str_start < 2)
308 while( ptr >
s->str_start )
316 if ( (*ptr >=
'0') && (*ptr <=
'9' ) )
329 while( ptr >= decimal_ptr )
339 if ( ptr ==
s->str_end )
350 dist =
s->str_end - ptr;
#define LWSIZE_SET(varsize, len)
void * lwalloc(size_t size)
stringbuffer_t * stringbuffer_create_with_size(size_t size)
Allocate a new stringbuffer_t.
void stringbuffer_release(stringbuffer_t *s)
void stringbuffer_clear(stringbuffer_t *s)
Reset the stringbuffer_t.
int stringbuffer_aprintf(stringbuffer_t *s, const char *fmt,...)
Appends a formatted string to the current string buffer, using the format and argument list provided.
lwvarlena_t * stringbuffer_getvarlenacopy(stringbuffer_t *s)
char stringbuffer_lastchar(stringbuffer_t *s)
Return the last character in the buffer.
void stringbuffer_set(stringbuffer_t *s, const char *str)
Clear the stringbuffer_t and re-start it with the specified string.
int stringbuffer_trim_trailing_zeroes(stringbuffer_t *s)
Trims zeroes off the end of the last number in the stringbuffer.
stringbuffer_t * stringbuffer_create(void)
Allocate a new stringbuffer_t.
static void stringbuffer_init_with_size(stringbuffer_t *s, size_t size)
int stringbuffer_getlength(stringbuffer_t *s)
Returns the length of the current string, not including the null terminator (same behavior as strlen(...
void stringbuffer_destroy(stringbuffer_t *s)
Free the stringbuffer_t and all memory managed within it.
void stringbuffer_init(stringbuffer_t *s)
char * stringbuffer_getstringcopy(stringbuffer_t *s)
Returns a newly allocated string large enough to contain the current state of the string.
lwvarlena_t * stringbuffer_getvarlena(stringbuffer_t *s)
static int stringbuffer_avprintf(stringbuffer_t *s, const char *fmt, va_list ap)
Appends a formatted string to the current string buffer, using the format and argument list provided.
void stringbuffer_copy(stringbuffer_t *dst, stringbuffer_t *src)
Copy the contents of src into dst.
const char * stringbuffer_getstring(stringbuffer_t *s)
Returns a reference to the internal string being managed by the stringbuffer.
void stringbuffer_init_varlena(stringbuffer_t *s)
int stringbuffer_trim_trailing_white(stringbuffer_t *s)
Trims whitespace off the end of the stringbuffer.
#define STRINGBUFFER_STARTSIZE
static void stringbuffer_append(stringbuffer_t *s, const char *a)
Append the specified string to the stringbuffer_t.
static void stringbuffer_append_len(stringbuffer_t *s, const char *a, size_t alen)
Append the specified string to the stringbuffer_t using known length.
static void stringbuffer_makeroom(stringbuffer_t *s, size_t size_to_add)
If necessary, expand the stringbuffer_t internal buffer to accommodate the specified additional size.