~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzletest.cc

Merged in changes from Andrey.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
#define MTEST_VERSION "3.3"
40
40
 
 
41
#include "config.h"
 
42
#include "client_priv.h"
 
43
 
41
44
#include <queue>
42
45
#include <map>
43
46
#include <string>
44
47
 
45
48
#include <pcrecpp.h>
46
49
 
47
 
#include "client_priv.h"
48
50
#include <mysys/hash.h>
49
51
#include <stdarg.h>
50
 
#include <vio/violite.h>
51
52
 
52
53
#include "errname.h"
53
54
 
506
507
  @param append string to be appended.
507
508
  @param ... Optional. Additional string(s) to be appended.
508
509
 
509
 
  @note The final argument in the list must be NullS even if no additional
 
510
  @note The final argument in the list must be NULL even if no additional
510
511
  options are passed.
511
512
*/
512
513
 
519
520
 
520
521
  str->append(quote_str, quote_len); /* Leading quote */
521
522
  va_start(dirty_text, append);
522
 
  while (append != NullS)
 
523
  while (append != NULL)
523
524
  {
524
525
    const char  *cur_pos= append;
525
526
    const char *next_pos= cur_pos;
532
533
      str->append(quote_str, quote_len);
533
534
      cur_pos= next_pos + 1;
534
535
    }
535
 
    str->append(cur_pos, next_pos - cur_pos);
 
536
    str->append(cur_pos);
536
537
    append= va_arg(dirty_text, char *);
537
538
  }
538
539
  va_end(dirty_text);
802
803
    drizzle_close(&next_con->drizzle);
803
804
    if (next_con->util_drizzle)
804
805
      drizzle_close(next_con->util_drizzle);
805
 
    my_free(next_con->name, MYF(MY_ALLOW_ZERO_PTR));
 
806
    free(next_con->name);
806
807
  }
807
808
  return;
808
809
}
817
818
    {
818
819
      my_fclose(cur_file->file, MYF(0));
819
820
    }
820
 
    my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
 
821
    free((unsigned char*) cur_file->file_name);
821
822
    cur_file->file_name= 0;
822
823
  }
823
824
  return;
847
848
  for (i= 0; i < 10; i++)
848
849
  {
849
850
    if (var_reg[i].alloced_len)
850
 
      my_free(var_reg[i].str_val, MYF(MY_WME));
 
851
      free(var_reg[i].str_val);
851
852
  }
852
853
  while (embedded_server_arg_count > 1)
853
 
    my_free(embedded_server_args[--embedded_server_arg_count],MYF(0));
 
854
    free(embedded_server_args[--embedded_server_arg_count]);
854
855
 
855
856
  free_all_replace();
856
 
  my_free(opt_pass,MYF(MY_ALLOW_ZERO_PTR));
 
857
  free(opt_pass);
857
858
  free_defaults(default_argv);
858
859
 
859
 
  /* Only call drizzle_server_end if drizzle_server_init has been called */
860
 
  if (server_initialized)
861
 
    drizzle_server_end();
862
 
 
863
860
  return;
864
861
}
865
862
 
1082
1079
 
1083
1080
  if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
1084
1081
    die("Failed to open file '%s'", filename);
1085
 
  while((len= my_read(fd, (uchar*)&buff,
 
1082
  while((len= my_read(fd, (unsigned char*)&buff,
1086
1083
                      sizeof(buff), MYF(0))) > 0)
1087
1084
  {
1088
1085
    char *p= buff, *start= buff;
1159
1156
  string ds_cmdline;
1160
1157
 
1161
1158
 
1162
 
  append_os_quoted(&ds_cmdline, tool_path);
 
1159
  append_os_quoted(&ds_cmdline, tool_path, NULL);
1163
1160
  ds_cmdline.append(" ");
1164
1161
 
1165
1162
  va_start(args, result);
1168
1165
  {
1169
1166
    /* Options should be os quoted */
1170
1167
    if (strncmp(arg, "--", 2) == 0)
1171
 
      append_os_quoted(&ds_cmdline, arg, NullS);
 
1168
      append_os_quoted(&ds_cmdline, arg, NULL);
1172
1169
    else
1173
1170
      ds_cmdline.append(arg);
1174
1171
    ds_cmdline.append(" ");
1293
1290
    my_close(fd, MYF(0));
1294
1291
    die("Failed to open second file: '%s'", filename2);
1295
1292
  }
1296
 
  while((len= my_read(fd, (uchar*)&buff,
 
1293
  while((len= my_read(fd, (unsigned char*)&buff,
1297
1294
                      sizeof(buff), MYF(0))) > 0)
1298
1295
  {
1299
 
    if ((len2= my_read(fd2, (uchar*)&buff2,
 
1296
    if ((len2= my_read(fd2, (unsigned char*)&buff2,
1300
1297
                       sizeof(buff2), MYF(0))) < len)
1301
1298
    {
1302
1299
      /* File 2 was smaller */
1316
1313
      break;
1317
1314
    }
1318
1315
  }
1319
 
  if (!error && my_read(fd2, (uchar*)&buff2,
 
1316
  if (!error && my_read(fd2, (unsigned char*)&buff2,
1320
1317
                        sizeof(buff2), MYF(0)) > 0)
1321
1318
  {
1322
1319
    /* File 1 was smaller */
1382
1379
    die("Failed to create temporary file for ds");
1383
1380
 
1384
1381
  /* Write ds to temporary file and set file pos to beginning*/
1385
 
  if (my_write(fd, (uchar *) ds->c_str(), ds->length(),
 
1382
  if (my_write(fd, (unsigned char *) ds->c_str(), ds->length(),
1386
1383
               MYF(MY_FNABP | MY_WME)) ||
1387
1384
      my_seek(fd, 0, SEEK_SET, MYF(0)) == MY_FILEPOS_ERROR)
1388
1385
  {
1541
1538
}
1542
1539
 
1543
1540
 
1544
 
static uchar *get_var_key(const uchar* var, size_t *len,
 
1541
static unsigned char *get_var_key(const unsigned char* var, size_t *len,
1545
1542
                          bool __attribute__((unused)) t)
1546
1543
{
1547
1544
  register char* key;
1548
1545
  key = ((VAR*)var)->name;
1549
1546
  *len = ((VAR*)var)->name_len;
1550
 
  return (uchar*)key;
 
1547
  return (unsigned char*)key;
1551
1548
}
1552
1549
 
1553
1550
 
1589
1586
 
1590
1587
void var_free(void *v)
1591
1588
{
1592
 
  my_free(((VAR*) v)->str_val, MYF(MY_WME));
1593
 
  my_free(((VAR*) v)->env_s, MYF(MY_WME|MY_ALLOW_ZERO_PTR));
 
1589
  free(((VAR*) v)->str_val);
 
1590
  free(((VAR*) v)->env_s);
1594
1591
  if (((VAR*)v)->alloced)
1595
 
    my_free(v, MYF(MY_WME));
 
1592
    free(v);
1596
1593
}
1597
1594
 
1598
1595
 
1604
1601
    tmp = def_val;
1605
1602
 
1606
1603
  v = var_init(0, name, strlen(name), tmp, strlen(tmp));
1607
 
  my_hash_insert(&var_hash, (uchar*)v);
 
1604
  my_hash_insert(&var_hash, (unsigned char*)v);
1608
1605
  return v;
1609
1606
}
1610
1607
 
1635
1632
    if (length >= MAX_VAR_NAME_LENGTH)
1636
1633
      die("Too long variable name: %s", save_var_name);
1637
1634
 
1638
 
    if (!(v = (VAR*) hash_search(&var_hash, (const uchar*) save_var_name,
 
1635
    if (!(v = (VAR*) hash_search(&var_hash, (const unsigned char*) save_var_name,
1639
1636
                                 length)))
1640
1637
    {
1641
1638
      char buff[MAX_VAR_NAME_LENGTH+1];
1667
1664
static VAR *var_obtain(const char *name, int len)
1668
1665
{
1669
1666
  VAR* v;
1670
 
  if ((v = (VAR*)hash_search(&var_hash, (const uchar *) name, len)))
 
1667
  if ((v = (VAR*)hash_search(&var_hash, (const unsigned char *) name, len)))
1671
1668
    return v;
1672
1669
  v = var_init(0, name, len, "", 0);
1673
 
  my_hash_insert(&var_hash, (uchar*)v);
 
1670
  my_hash_insert(&var_hash, (unsigned char*)v);
1674
1671
  return v;
1675
1672
}
1676
1673
 
1717
1714
    if (!(v->env_s= my_strdup(buf, MYF(MY_WME))))
1718
1715
      die("Out of memory");
1719
1716
    putenv(v->env_s);
1720
 
    my_free(old_env_s, MYF(MY_ALLOW_ZERO_PTR));
 
1717
    free(old_env_s);
1721
1718
  }
1722
1719
  return;
1723
1720
}
2036
2033
 
2037
2034
  if (!test_if_hard_path(name))
2038
2035
  {
2039
 
    strxmov(buff, opt_basedir, name, NullS);
 
2036
    strxmov(buff, opt_basedir, name, NULL);
2040
2037
    name=buff;
2041
2038
  }
2042
2039
  fn_format(buff, name, "", "", MY_UNPACK_FILENAME);
2419
2416
 
2420
2417
  /* Parse what mode to set */
2421
2418
  if (ds_mode.length() != 4 ||
2422
 
      str2int(ds_mode.c_str(), 8, 0, INT_MAX, &mode) == NullS)
 
2419
      str2int(ds_mode.c_str(), 8, 0, INT_MAX, &mode) == NULL)
2423
2420
    die("You must write a 4 digit octal number for mode");
2424
2421
 
2425
2422
  handle_command_error(command, chmod(ds_file.c_str(), mode));
3084
3081
    die("drizzle_store_result() retuned NULL for '%s'", query);
3085
3082
  if (!(row = drizzle_fetch_row(res)))
3086
3083
    die("empty result in show master status");
3087
 
  stpncpy(master_pos.file, row[0], sizeof(master_pos.file)-1);
 
3084
  my_stpncpy(master_pos.file, row[0], sizeof(master_pos.file)-1);
3088
3085
  master_pos.pos = strtoul(row[1], (char**) 0, 10);
3089
3086
  drizzle_free_result(res);
3090
3087
  return(0);
3511
3508
  {
3512
3509
    if (con->drizzle.net.vio)
3513
3510
    {
3514
 
      vio_delete(con->drizzle.net.vio);
3515
 
      con->drizzle.net.vio = 0;
 
3511
      net_close(&(con->drizzle.net));
3516
3512
    }
3517
3513
  }
3518
3514
 
3522
3518
    drizzle_close(con->util_drizzle);
3523
3519
  con->util_drizzle= 0;
3524
3520
 
3525
 
  my_free(con->name, MYF(0));
 
3521
  free(con->name);
3526
3522
 
3527
3523
  /*
3528
3524
    When the connection is closed set name to "-closed_connection-"
3792
3788
  if (!drizzle_create(&con_slot->drizzle))
3793
3789
    die("Failed on drizzle_create()");
3794
3790
  if (opt_compress || con_compress)
3795
 
    drizzle_options(&con_slot->drizzle, DRIZZLE_OPT_COMPRESS, NullS);
 
3791
    drizzle_options(&con_slot->drizzle, DRIZZLE_OPT_COMPRESS, NULL);
3796
3792
  drizzle_options(&con_slot->drizzle, DRIZZLE_OPT_LOCAL_INFILE, 0);
3797
 
  drizzle_options(&con_slot->drizzle, DRIZZLE_SET_CHARSET_NAME,
3798
 
                  charset_info->csname);
3799
 
  int opt_protocol= DRIZZLE_PROTOCOL_TCP;
3800
 
  drizzle_options(&con_slot->drizzle,DRIZZLE_OPT_PROTOCOL,(char*)&opt_protocol);
3801
 
  if (opt_charsets_dir)
3802
 
    drizzle_options(&con_slot->drizzle, DRIZZLE_SET_CHARSET_DIR,
3803
 
                    opt_charsets_dir);
3804
3793
 
3805
3794
  /* Use default db name */
3806
3795
  if (ds_database.length() == 0)
4040
4029
        my_fclose(cur_file->file, MYF(0));
4041
4030
        cur_file->file= 0;
4042
4031
      }
4043
 
      my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
 
4032
      free((unsigned char*) cur_file->file_name);
4044
4033
      cur_file->file_name= 0;
4045
4034
      if (cur_file == file_stack)
4046
4035
      {
4076
4065
        return(0);
4077
4066
      }
4078
4067
      else if ((c == '{' &&
4079
 
                (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
4080
 
                                      (uchar*) buf, min((long)5, p - buf), 0) ||
4081
 
                 !my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
4082
 
                                      (uchar*) buf, min((long)2, p - buf), 0))))
 
4068
                (!my_strnncoll_simple(charset_info, (const unsigned char*) "while", 5,
 
4069
                                      (unsigned char*) buf, cmin((long)5, p - buf), 0) ||
 
4070
                 !my_strnncoll_simple(charset_info, (const unsigned char*) "if", 2,
 
4071
                                      (unsigned char*) buf, cmin((long)2, p - buf), 0))))
4083
4072
      {
4084
4073
        /* Only if and while commands can be terminated by { */
4085
4074
        *p++= c;
4379
4368
  if (!(*command_ptr= command=
4380
4369
        (struct st_command*) my_malloc(sizeof(*command),
4381
4370
                                       MYF(MY_WME|MY_ZEROFILL))))
4382
 
    die(NullS);
 
4371
    die(NULL);
4383
4372
  q_lines.push_back(command);
4384
4373
  command->type= Q_UNKNOWN;
4385
4374
 
4534
4523
 
4535
4524
  if (!test_if_hard_path(name))
4536
4525
  {
4537
 
    strxmov(buff, opt_basedir, name, NullS);
 
4526
    strxmov(buff, opt_basedir, name, NULL);
4538
4527
    name=buff;
4539
4528
  }
4540
4529
  fn_format(buff, name, "", "", MY_UNPACK_FILENAME);
4581
4570
    char buff[FN_REFLEN];
4582
4571
    if (!test_if_hard_path(argument))
4583
4572
    {
4584
 
      strxmov(buff, opt_basedir, argument, NullS);
 
4573
      strxmov(buff, opt_basedir, argument, NULL);
4585
4574
      argument= buff;
4586
4575
    }
4587
4576
    fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
4598
4587
    static char buff[FN_REFLEN];
4599
4588
    if (!test_if_hard_path(argument))
4600
4589
    {
4601
 
      strxmov(buff, opt_basedir, argument, NullS);
 
4590
      strxmov(buff, opt_basedir, argument, NULL);
4602
4591
      argument= buff;
4603
4592
    }
4604
4593
    fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
4609
4598
  case 'p':
4610
4599
    if (argument)
4611
4600
    {
4612
 
      my_free(opt_pass, MYF(MY_ALLOW_ZERO_PTR));
 
4601
      free(opt_pass);
4613
4602
      opt_pass= my_strdup(argument, MYF(MY_FAE));
4614
4603
      while (*argument) *argument++= 'x';    /* Destroy argument */
4615
4604
      tty_password= 0;
4618
4607
      tty_password= 1;
4619
4608
    break;
4620
4609
  case 't':
4621
 
    stpncpy(TMPDIR, argument, sizeof(TMPDIR));
 
4610
    my_stpncpy(TMPDIR, argument, sizeof(TMPDIR));
4622
4611
    break;
4623
4612
  case 'A':
4624
4613
    if (!embedded_server_arg_count)
4663
4652
  if (argc == 1)
4664
4653
    opt_db= *argv;
4665
4654
  if (tty_password)
4666
 
    opt_pass= get_tty_password(NullS);          /* purify tested */
 
4655
    opt_pass= get_tty_password(NULL);          /* purify tested */
4667
4656
  if (debug_info_flag)
4668
4657
    my_end_arg= MY_CHECK_ERROR | MY_GIVE_INFO;
4669
4658
  if (debug_check_flag)
4690
4679
  int flags= O_WRONLY | O_CREAT;
4691
4680
  if (!test_if_hard_path(fname))
4692
4681
  {
4693
 
    strxmov(buff, opt_basedir, fname, NullS);
 
4682
    strxmov(buff, opt_basedir, fname, NULL);
4694
4683
    fname= buff;
4695
4684
  }
4696
4685
  fn_format(buff, fname, "", "", MY_UNPACK_FILENAME);
4702
4691
    die("Could not open '%s' for writing: errno = %d", buff, errno);
4703
4692
  if (append && my_seek(fd, 0, SEEK_END, MYF(0)) == MY_FILEPOS_ERROR)
4704
4693
    die("Could not find end of file '%s': errno = %d", buff, errno);
4705
 
  if (my_write(fd, (uchar*)str, size, MYF(MY_WME|MY_FNABP)))
 
4694
  if (my_write(fd, (unsigned char*)str, size, MYF(MY_WME|MY_FNABP)))
4706
4695
    die("write failed");
4707
4696
  my_close(fd, MYF(0));
4708
4697
}
4854
4843
    ds->append("\t", 1);
4855
4844
    replace_append_uint(ds, field->max_length);
4856
4845
    ds->append("\t", 1);
4857
 
    ds->append((char*) (IS_NOT_NULL(field->flags) ?
 
4846
    ds->append((char*) ((field->flags & NOT_NULL_FLAG) ?
4858
4847
                        "N" : "Y"), 1);
4859
4848
    ds->append("\t", 1);
4860
4849
    replace_append_uint(ds, field->flags);
5500
5489
  if (!( drizzle_create(&cur_con->drizzle)))
5501
5490
    die("Failed in drizzle_create()");
5502
5491
  if (opt_compress)
5503
 
    drizzle_options(&cur_con->drizzle,DRIZZLE_OPT_COMPRESS,NullS);
 
5492
    drizzle_options(&cur_con->drizzle,DRIZZLE_OPT_COMPRESS,NULL);
5504
5493
  drizzle_options(&cur_con->drizzle, DRIZZLE_OPT_LOCAL_INFILE, 0);
5505
 
  drizzle_options(&cur_con->drizzle, DRIZZLE_SET_CHARSET_NAME,
5506
 
                  charset_info->csname);
5507
 
  int opt_protocol= DRIZZLE_PROTOCOL_TCP;
5508
 
  drizzle_options(&cur_con->drizzle,DRIZZLE_OPT_PROTOCOL,(char*)&opt_protocol);
5509
 
  if (opt_charsets_dir)
5510
 
    drizzle_options(&cur_con->drizzle, DRIZZLE_SET_CHARSET_DIR,
5511
 
                    opt_charsets_dir);
5512
5494
 
5513
5495
  if (!(cur_con->name = my_strdup("default", MYF(MY_WME))))
5514
5496
    die("Out of memory");
5957
5939
    if (!*from)
5958
5940
      die("Wrong number of arguments to replace_column in '%s'", command->query);
5959
5941
    to= get_string(&buff, &from, command);
5960
 
    my_free(replace_column[column_number-1], MY_ALLOW_ZERO_PTR);
 
5942
    free(replace_column[column_number-1]);
5961
5943
    replace_column[column_number-1]= my_strdup(to, MYF(MY_WME | MY_FAE));
5962
5944
    set_if_bigger(max_replace_column, column_number);
5963
5945
  }
5964
 
  my_free(start, MYF(0));
 
5946
  free(start);
5965
5947
  command->last_argument= command->end;
5966
5948
}
5967
5949
 
5973
5955
  {
5974
5956
    if (replace_column[i])
5975
5957
    {
5976
 
      my_free(replace_column[i], 0);
 
5958
      free(replace_column[i]);
5977
5959
      replace_column[i]= 0;
5978
5960
    }
5979
5961
  }
5990
5972
 
5991
5973
typedef struct st_pointer_array {    /* when using array-strings */
5992
5974
  TYPELIB typelib;        /* Pointer to strings */
5993
 
  uchar  *str;          /* Strings is here */
5994
 
  int7  *flag;          /* Flag about each var. */
 
5975
  unsigned char  *str;          /* Strings is here */
 
5976
  uint8_t *flag;          /* Flag about each var. */
5995
5977
  uint  array_allocs,max_count,length,max_length;
5996
5978
} POINTER_ARRAY;
5997
5979
 
6051
6033
    die("Can't initialize replace from '%s'", command->query);
6052
6034
  free_pointer_array(&from_array);
6053
6035
  free_pointer_array(&to_array);
6054
 
  my_free(start, MYF(0));
 
6036
  free(start);
6055
6037
  command->last_argument= command->end;
6056
6038
  return;
6057
6039
}
6062
6044
 
6063
6045
  if (glob_replace)
6064
6046
  {
6065
 
    my_free(glob_replace,MYF(0));
 
6047
    free(glob_replace);
6066
6048
    glob_replace=0;
6067
6049
  }
6068
6050
  return;
6096
6078
  {
6097
6079
    /* Loop through states */
6098
6080
    while (!rep_pos->found)
6099
 
      rep_pos= rep_pos->next[(uchar) *from++];
 
6081
      rep_pos= rep_pos->next[(unsigned char) *from++];
6100
6082
 
6101
6083
    /* Does this state contain a string to be replaced */
6102
6084
    if (!(rep_str = ((REPLACE_STRING*) rep_pos))->replace_string)
6262
6244
      reg.icase= 1;
6263
6245
 
6264
6246
    /* done parsing the statement, now place it in regex_arr */
6265
 
    if (insert_dynamic(&res->regex_arr,(uchar*) &reg))
 
6247
    if (insert_dynamic(&res->regex_arr,(unsigned char*) &reg))
6266
6248
      die("Out of memory");
6267
6249
  }
6268
6250
  res->odd_buf_len= res->even_buf_len= 8192;
6273
6255
  return res;
6274
6256
 
6275
6257
err:
6276
 
  my_free(res,0);
 
6258
  free(res);
6277
6259
  die("Error parsing replace_regex \"%s\"", expr);
6278
6260
  return 0;
6279
6261
}
6314
6296
    struct st_regex re;
6315
6297
    char* save_out_buf= out_buf;
6316
6298
 
6317
 
    get_dynamic(&r->regex_arr,(uchar*)&re,i);
 
6299
    get_dynamic(&r->regex_arr,(unsigned char*)&re,i);
6318
6300
 
6319
6301
    if (!reg_replace(&out_buf, buf_len_p, re.pattern, re.replace,
6320
6302
                     in_buf, re.icase))
6365
6347
  if (glob_replace_regex)
6366
6348
  {
6367
6349
    delete_dynamic(&glob_replace_regex->regex_arr);
6368
 
    my_free(glob_replace_regex->even_buf,MYF(MY_ALLOW_ZERO_PTR));
6369
 
    my_free(glob_replace_regex->odd_buf,MYF(MY_ALLOW_ZERO_PTR));
6370
 
    my_free(glob_replace_regex,MYF(0));
 
6350
    free(glob_replace_regex->even_buf);
 
6351
    free(glob_replace_regex->odd_buf);
 
6352
    free(glob_replace_regex);
6371
6353
    glob_replace_regex=0;
6372
6354
  }
6373
6355
}
6532
6514
  }
6533
6515
  memset(is_word_end, 0, sizeof(is_word_end));
6534
6516
  for (i=0 ; word_end_chars[i] ; i++)
6535
 
    is_word_end[(uchar) word_end_chars[i]]=1;
 
6517
    is_word_end[(unsigned char) word_end_chars[i]]=1;
6536
6518
 
6537
6519
  if (init_sets(&sets,states))
6538
6520
    return(0);
6543
6525
    free_sets(&sets);
6544
6526
    return(0);
6545
6527
  }
6546
 
  VOID(make_new_set(&sets));      /* Set starting set */
 
6528
  make_new_set(&sets);      /* Set starting set */
6547
6529
  make_sets_invisible(&sets);      /* Hide previus sets */
6548
6530
  used_sets=-1;
6549
6531
  word_states=make_new_set(&sets);    /* Start of new word */
6551
6533
  if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME))))
6552
6534
  {
6553
6535
    free_sets(&sets);
6554
 
    my_free(found_set,MYF(0));
 
6536
    free(found_set);
6555
6537
    return(0);
6556
6538
  }
6557
6539
 
6610
6592
          follow_ptr->chr = '\v';
6611
6593
          break;
6612
6594
        default:
6613
 
          follow_ptr->chr = (uchar) *pos;
 
6595
          follow_ptr->chr = (unsigned char) *pos;
6614
6596
          break;
6615
6597
        }
6616
6598
      }
6617
6599
      else
6618
 
        follow_ptr->chr= (uchar) *pos;
 
6600
        follow_ptr->chr= (unsigned char) *pos;
6619
6601
      follow_ptr->table_offset=i;
6620
6602
      follow_ptr->len= ++len;
6621
6603
      follow_ptr++;
6661
6643
    /* Mark word_chars used if \b is in state */
6662
6644
    if (used_chars[SPACE_CHAR])
6663
6645
      for (pos= word_end_chars ; *pos ; pos++)
6664
 
        used_chars[(int) (uchar) *pos] = 1;
 
6646
        used_chars[(int) (unsigned char) *pos] = 1;
6665
6647
 
6666
6648
    /* Handle other used characters */
6667
6649
    for (chr= 0 ; chr < 256 ; chr++)
6751
6733
    for (i=0 ; i < count ; i++)
6752
6734
    {
6753
6735
      to_array[i]=to_pos;
6754
 
      to_pos=stpcpy(to_pos,to[i])+1;
 
6736
      to_pos=my_stpcpy(to_pos,to[i])+1;
6755
6737
    }
6756
6738
    rep_str[0].found=1;
6757
6739
    rep_str[0].replace_string=0;
6773
6755
          replace[i].next[j]=(REPLACE*) (rep_str+(-sets.set[i].next[j]-1));
6774
6756
    }
6775
6757
  }
6776
 
  my_free(follow,MYF(0));
 
6758
  free(follow);
6777
6759
  free_sets(&sets);
6778
 
  my_free(found_set,MYF(0));
 
6760
  free(found_set);
6779
6761
  return(replace);
6780
6762
}
6781
6763
 
6790
6772
  if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits*
6791
6773
                                           SET_MALLOC_HUNC,MYF(MY_WME))))
6792
6774
  {
6793
 
    my_free(sets->set,MYF(0));
 
6775
    free(sets->set);
6794
6776
    return 1;
6795
6777
  }
6796
6778
  return 0;
6822
6804
    return set;
6823
6805
  }
6824
6806
  count=sets->count+sets->invisible+SET_MALLOC_HUNC;
6825
 
  if (!(set=(REP_SET*) my_realloc((uchar*) sets->set_buffer,
 
6807
  if (!(set=(REP_SET*) my_realloc((unsigned char*) sets->set_buffer,
6826
6808
                                  sizeof(REP_SET)*count,
6827
6809
                                  MYF(MY_WME))))
6828
6810
    return 0;
6829
6811
  sets->set_buffer=set;
6830
6812
  sets->set=set+sets->invisible;
6831
 
  if (!(bit_buffer=(uint*) my_realloc((uchar*) sets->bit_buffer,
 
6813
  if (!(bit_buffer=(uint*) my_realloc((unsigned char*) sets->bit_buffer,
6832
6814
                                      (sizeof(uint)*sets->size_of_bits)*count,
6833
6815
                                      MYF(MY_WME))))
6834
6816
    return 0;
6851
6833
 
6852
6834
void free_sets(REP_SETS *sets)
6853
6835
{
6854
 
  my_free(sets->set_buffer,MYF(0));
6855
 
  my_free(sets->bit_buffer,MYF(0));
 
6836
  free(sets->set_buffer);
 
6837
  free(sets->bit_buffer);
6856
6838
  return;
6857
6839
}
6858
6840
 
6975
6957
int insert_pointer_name(POINTER_ARRAY *pa,char * name)
6976
6958
{
6977
6959
  uint i,length,old_count;
6978
 
  uchar *new_pos;
 
6960
  unsigned char *new_pos;
6979
6961
  const char **new_array;
6980
6962
 
6981
6963
 
6986
6968
                     (sizeof(char *)+sizeof(*pa->flag))*
6987
6969
                     (sizeof(char *)+sizeof(*pa->flag))),MYF(MY_WME))))
6988
6970
      return(-1);
6989
 
    if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD),
 
6971
    if (!(pa->str= (unsigned char*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD),
6990
6972
                                      MYF(MY_WME))))
6991
6973
    {
6992
 
      my_free((char*) pa->typelib.type_names,MYF(0));
 
6974
      free((char*) pa->typelib.type_names);
6993
6975
      return (-1);
6994
6976
    }
6995
 
    pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+
 
6977
    pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(unsigned char*)+
6996
6978
                                               sizeof(*pa->flag));
6997
 
    pa->flag= (int7*) (pa->typelib.type_names+pa->max_count);
 
6979
    pa->flag= (uint8_t*) (pa->typelib.type_names+pa->max_count);
6998
6980
    pa->length=0;
6999
6981
    pa->max_length=PS_MALLOC-MALLOC_OVERHEAD;
7000
6982
    pa->array_allocs=1;
7002
6984
  length=(uint) strlen(name)+1;
7003
6985
  if (pa->length+length >= pa->max_length)
7004
6986
  {
7005
 
    if (!(new_pos= (uchar*) my_realloc((uchar*) pa->str,
 
6987
    if (!(new_pos= (unsigned char*) my_realloc((unsigned char*) pa->str,
7006
6988
                                       (uint) (pa->max_length+PS_MALLOC),
7007
6989
                                       MYF(MY_WME))))
7008
6990
      return(1);
7021
7003
    int len;
7022
7004
    pa->array_allocs++;
7023
7005
    len=(PC_MALLOC*pa->array_allocs - MALLOC_OVERHEAD);
7024
 
    if (!(new_array=(const char **) my_realloc((uchar*) pa->typelib.type_names,
 
7006
    if (!(new_array=(const char **) my_realloc((unsigned char*) pa->typelib.type_names,
7025
7007
                                               (uint) len/
7026
 
                                               (sizeof(uchar*)+sizeof(*pa->flag))*
7027
 
                                               (sizeof(uchar*)+sizeof(*pa->flag)),
 
7008
                                               (sizeof(unsigned char*)+sizeof(*pa->flag))*
 
7009
                                               (sizeof(unsigned char*)+sizeof(*pa->flag)),
7028
7010
                                               MYF(MY_WME))))
7029
7011
      return(1);
7030
7012
    pa->typelib.type_names=new_array;
7031
7013
    old_count=pa->max_count;
7032
 
    pa->max_count=len/(sizeof(uchar*) + sizeof(*pa->flag));
7033
 
    pa->flag= (int7*) (pa->typelib.type_names+pa->max_count);
 
7014
    pa->max_count=len/(sizeof(unsigned char*) + sizeof(*pa->flag));
 
7015
    pa->flag= (uint8_t*) (pa->typelib.type_names+pa->max_count);
7034
7016
    memcpy(pa->flag, pa->typelib.type_names+old_count,
7035
7017
           old_count*sizeof(*pa->flag));
7036
7018
  }
7037
7019
  pa->flag[pa->typelib.count]=0;      /* Reset flag */
7038
7020
  pa->typelib.type_names[pa->typelib.count++]= (char*) pa->str+pa->length;
7039
 
  pa->typelib.type_names[pa->typelib.count]= NullS;  /* Put end-mark */
7040
 
  VOID(stpcpy((char*) pa->str+pa->length,name));
 
7021
  pa->typelib.type_names[pa->typelib.count]= NULL;  /* Put end-mark */
 
7022
  my_stpcpy((char*) pa->str+pa->length,name);
7041
7023
  pa->length+=length;
7042
7024
  return(0);
7043
7025
} /* insert_pointer_name */
7050
7032
  if (pa->typelib.count)
7051
7033
  {
7052
7034
    pa->typelib.count=0;
7053
 
    my_free((char*) pa->typelib.type_names,MYF(0));
 
7035
    free((char*) pa->typelib.type_names);
7054
7036
    pa->typelib.type_names=0;
7055
 
    my_free(pa->str,MYF(0));
 
7037
    free(pa->str);
7056
7038
  }
7057
7039
} /* free_pointer_array */
7058
7040