6196
6195
/* Definitions for replace result */
6198
typedef struct st_pointer_array { /* when using array-strings */
6198
{ /* when using array-strings */
6201
int insert(char* name);
6205
memset(this, 0, sizeof(*this));
6199
6208
TYPELIB typelib; /* Pointer to strings */
6200
unsigned char *str; /* Strings is here */
6201
uint8_t *flag; /* Flag about each var. */
6202
uint32_t array_allocs,max_count,length,max_length;
6209
unsigned char *str; /* Strings is here */
6210
uint8_t* flag; /* Flag about each var. */
6211
uint32_t array_allocs;
6214
uint32_t max_length;
6205
6217
struct st_replace;
6206
6218
struct st_replace *init_replace(const char **from, const char **to, uint32_t count,
6207
6219
char *word_end_chars);
6208
int insert_pointer_name(POINTER_ARRAY *pa,char * name);
6209
6221
void replace_strings_append(struct st_replace *rep, string* ds,
6210
6222
const char *from, int len);
6220
6232
variable is replaced.
6223
static void free_pointer_array(POINTER_ARRAY *pa)
6235
POINTER_ARRAY::~POINTER_ARRAY()
6225
if (!pa->typelib.count)
6227
pa->typelib.count=0;
6228
free((char*) pa->typelib.type_names);
6229
pa->typelib.type_names=0;
6240
free((char*) typelib.type_names);
6241
typelib.type_names=0;
6233
void do_get_replace(struct st_command *command)
6245
void do_get_replace(st_command *command)
6236
6247
char *from= command->first_argument;
6238
char word_end_chars[256], *pos;
6249
die("Missing argument in %s", command->query);
6239
6251
POINTER_ARRAY to_array, from_array;
6244
memset(&to_array, 0, sizeof(to_array));
6245
memset(&from_array, 0, sizeof(from_array));
6247
die("Missing argument in %s", command->query);
6248
start= buff= (char *)malloc(strlen(from)+1);
6252
char* start= (char*)malloc(strlen(from) + 1);
6252
to= get_string(&buff, &from, command);
6256
char *to= get_string(&buff, &from, command);
6254
die("Wrong number of arguments to replace_result in '%s'",
6256
insert_pointer_name(&from_array,to);
6258
die("Wrong number of arguments to replace_result in '%s'", command->query);
6259
from_array.insert(to);
6257
6260
to= get_string(&buff, &from, command);
6258
insert_pointer_name(&to_array,to);
6261
to_array.insert(to);
6260
for (i= 1,pos= word_end_chars ; i < 256 ; i++)
6261
if (my_isspace(charset_info,i))
6263
char word_end_chars[256];
6264
char* pos= word_end_chars;
6265
for (int i= 1; i < 256; i++)
6267
if (my_isspace(charset_info, i))
6263
6270
*pos=0; /* End pointer */
6264
6271
if (!(glob_replace= init_replace(from_array.typelib.type_names,
6265
6272
to_array.typelib.type_names,
6266
6273
from_array.typelib.count,
6267
6274
word_end_chars)))
6268
6275
die("Can't initialize replace from '%s'", command->query);
6269
free_pointer_array(&from_array);
6270
free_pointer_array(&to_array);
6272
6277
command->last_argument= command->end;
7177
7182
#define PC_MALLOC 256 /* Bytes for pointers */
7178
7183
#define PS_MALLOC 512 /* Bytes for data */
7180
int insert_pointer_name(POINTER_ARRAY *pa,char * name)
7185
static int insert_pointer_name(POINTER_ARRAY* pa, char* name)
7182
7187
uint32_t i,length,old_count;
7183
7188
unsigned char *new_pos;