diff options
Diffstat (limited to 'mysys/string.c')
-rw-r--r-- | mysys/string.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/mysys/string.c b/mysys/string.c index 6dcb034531e..10a72b8a295 100644 --- a/mysys/string.c +++ b/mysys/string.c @@ -23,15 +23,15 @@ #include <m_string.h> my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, - uint init_alloc, uint alloc_increment) + size_t init_alloc, size_t alloc_increment) { - uint length; + size_t length; DBUG_ENTER("init_dynamic_string"); if (!alloc_increment) alloc_increment=128; length=1; - if (init_str && (length= (uint) strlen(init_str)+1) < init_alloc) + if (init_str && (length= strlen(init_str)+1) < init_alloc) init_alloc=((length+alloc_increment-1)/alloc_increment)*alloc_increment; if (!init_alloc) init_alloc=alloc_increment; @@ -72,7 +72,7 @@ my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str) } -my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size) +my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size) { DBUG_ENTER("dynstr_realloc"); @@ -95,12 +95,12 @@ my_bool dynstr_append(DYNAMIC_STRING *str, const char *append) my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, - uint length) + size_t length) { char *new_ptr; if (str->length+length >= str->max_length) { - uint new_length=(str->length+length+str->alloc_increment)/ + size_t new_length=(str->length+length+str->alloc_increment)/ str->alloc_increment; new_length*=str->alloc_increment; if (!(new_ptr=(char*) my_realloc(str->str,new_length,MYF(MY_WME)))) @@ -115,19 +115,29 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, } -/** Concatenates any number of strings, escapes any OS quote in the result then - * surround the whole affair in another set of quotes which is finally appended - * to specified DYNAMIC_STRING. This function is especially useful when - * building strings to be executed with the system() function. - * @param str Dynamic String which will have addtional strings appended. - * @param append String to be appended. - * @param ... Optional. Additional string(s) to be appended. - * - * @note The final argument in the list must be NullS even if no additional - * options are passed. - * - * @return True = Success. - */ +my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n) +{ + str->length-=n; + str->str[str->length]= '\0'; + return FALSE; +} + +/* + Concatenates any number of strings, escapes any OS quote in the result then + surround the whole affair in another set of quotes which is finally appended + to specified DYNAMIC_STRING. This function is especially useful when + building strings to be executed with the system() function. + + @param str Dynamic String which will have addtional strings appended. + @param append String to be appended. + @param ... Optional. Additional string(s) to be appended. + + @note The final argument in the list must be NullS even if no additional + options are passed. + + @return True = Success. +*/ + my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...) { #ifdef __WIN__ |