~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzletest.cc

  • Committer: Monty Taylor
  • Date: 2009-02-21 03:33:30 UTC
  • mfrom: (895 drizzle)
  • mto: (896.2.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 898.
  • Revision ID: mordred@inaugust.com-20090221033330-v110f94679dej04p
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
static const char *load_default_groups[]= { "drizzletest", "client", 0 };
98
98
static char line_buffer[MAX_DELIMITER_LENGTH], *line_buffer_pos= line_buffer;
99
99
 
100
 
static uint start_lineno= 0; /* Start line of current command */
101
 
static uint my_end_arg= 0;
 
100
static uint32_t start_lineno= 0; /* Start line of current command */
 
101
static uint32_t my_end_arg= 0;
102
102
 
103
103
/* Number of lines of the result to include in failure report */
104
 
static uint opt_tail_lines= 0;
 
104
static uint32_t opt_tail_lines= 0;
105
105
 
106
106
static char delimiter[MAX_DELIMITER_LENGTH]= ";";
107
 
static uint delimiter_length= 1;
 
107
static uint32_t delimiter_length= 1;
108
108
 
109
109
static char TMPDIR[FN_REFLEN];
110
110
 
130
130
{
131
131
  FILE* file;
132
132
  const char *file_name;
133
 
  uint lineno; /* Current line in file */
 
133
  uint32_t lineno; /* Current line in file */
134
134
};
135
135
 
136
136
static struct st_test_file file_stack[16];
350
350
  enum match_err_type type;
351
351
  union
352
352
  {
353
 
    uint errnum;
 
353
    uint32_t errnum;
354
354
    char sqlstate[SQLSTATE_LENGTH+1];  /* \0 terminated string */
355
355
  } code;
356
356
};
358
358
struct st_expected_errors
359
359
{
360
360
  struct st_match_err err[10];
361
 
  uint count;
 
361
  uint32_t count;
362
362
};
363
363
static struct st_expected_errors saved_expected_errors;
364
364
 
397
397
VAR* var_get(const char *var_name, const char** var_name_end,
398
398
             bool raw, bool ignore_not_existing);
399
399
void eval_expr(VAR* v, const char *p, const char** p_end);
400
 
bool match_delimiter(int c, const char *delim, uint length);
 
400
bool match_delimiter(int c, const char *delim, uint32_t length);
401
401
void dump_result_to_reject_file(char *buf, int size);
402
402
void dump_result_to_log_file(const char *buf, int size);
403
403
void dump_warning_messages(void);
410
410
 
411
411
/* For replace_column */
412
412
static char *replace_column[MAX_COLUMNS];
413
 
static uint max_replace_column= 0;
 
413
static uint32_t max_replace_column= 0;
414
414
void do_get_replace_column(struct st_command*);
415
415
void free_replace_column(void);
416
416
 
435
435
void replace_append_mem(string *ds, const char *val,
436
436
                        int len);
437
437
void replace_append(string *ds, const char *val);
438
 
void replace_append_uint(string *ds, uint val);
 
438
void replace_append_uint(string *ds, uint32_t val);
439
439
void append_sorted(string* ds, string* ds_input);
440
440
 
441
441
void handle_error(struct st_command*,
519
519
void append_os_quoted(string *str, const char *append, ...)
520
520
{
521
521
  const char *quote_str= "\'";
522
 
  const uint  quote_len= 1;
 
522
  const uint32_t  quote_len= 1;
523
523
 
524
524
  va_list dirty_text;
525
525
 
767
767
}
768
768
 
769
769
 
770
 
static void handle_command_error(struct st_command *command, uint error)
 
770
static void handle_command_error(struct st_command *command, uint32_t error)
771
771
{
772
772
 
773
773
  if (error != 0)
774
774
  {
775
 
    uint i;
 
775
    uint32_t i;
776
776
 
777
777
    if (command->abort_on_error)
778
778
      die("command \"%.*s\" failed with error %d",
832
832
 
833
833
static void free_used_memory(void)
834
834
{
835
 
  uint i;
 
835
  uint32_t i;
836
836
 
837
837
 
838
838
  close_connections();
1079
1079
static void cat_file(string* ds, const char* filename)
1080
1080
{
1081
1081
  int fd;
1082
 
  uint len;
 
1082
  uint32_t len;
1083
1083
  char buff[512];
1084
1084
 
1085
1085
  if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
1286
1286
{
1287
1287
  int error= RESULT_OK;
1288
1288
  File fd2;
1289
 
  uint len, len2;
 
1289
  uint32_t len, len2;
1290
1290
  char buff[512], buff2[512];
1291
1291
  const char *fname= filename2;
1292
1292
  string tmpfile;
1637
1637
  if (digit < 0 || digit >= 10)
1638
1638
  {
1639
1639
    const char *save_var_name = var_name, *end;
1640
 
    uint length;
 
1640
    uint32_t length;
1641
1641
    end = (var_name_end) ? *var_name_end : 0;
1642
1642
    while (my_isvar(charset_info,*var_name) && var_name != end)
1643
1643
      var_name++;
1647
1647
        return(0);
1648
1648
      die("Empty variable");
1649
1649
    }
1650
 
    length= (uint) (var_name - save_var_name);
 
1650
    length= (uint32_t) (var_name - save_var_name);
1651
1651
    if (length >= MAX_VAR_NAME_LENGTH)
1652
1652
      die("Too long variable name: %s", save_var_name);
1653
1653
 
1712
1712
  digit= *var_name - '0';
1713
1713
  if (!(digit < 10 && digit >= 0))
1714
1714
  {
1715
 
    v= var_obtain(var_name, (uint) (var_name_end - var_name));
 
1715
    v= var_obtain(var_name, (uint32_t) (var_name_end - var_name));
1716
1716
  }
1717
1717
  else
1718
1718
    v= var_reg + digit;
1921
1921
 
1922
1922
  {
1923
1923
    /* Find column number from the given column name */
1924
 
    uint i;
1925
 
    uint num_fields= drizzleclient_num_fields(res);
 
1924
    uint32_t i;
 
1925
    uint32_t num_fields= drizzleclient_num_fields(res);
1926
1926
    const DRIZZLE_FIELD *fields= drizzleclient_fetch_fields(res);
1927
1927
 
1928
1928
    for (i= 0; i < num_fields; i++)
2228
2228
  error= pclose(res_file);
2229
2229
  if (error > 0)
2230
2230
  {
2231
 
    uint status= WEXITSTATUS(error), i;
 
2231
    uint32_t status= WEXITSTATUS(error), i;
2232
2232
    bool ok= 0;
2233
2233
 
2234
2234
    if (command->abort_on_error)
3229
3229
 
3230
3230
 
3231
3231
static void do_get_file_name(struct st_command *command,
3232
 
                             char* dest, uint dest_max_len)
 
3232
                             char* dest, uint32_t dest_max_len)
3233
3233
{
3234
3234
  char *p= command->first_argument, *name;
3235
3235
  if (!*p)
3263
3263
    abort_not_supported_test("Test requires charset '%s'", charset_name);
3264
3264
}
3265
3265
 
3266
 
static uint get_errcode_from_name(char *error_name, char *error_end)
 
3266
static uint32_t get_errcode_from_name(char *error_name, char *error_end)
3267
3267
{
3268
3268
  /* SQL error as string */
3269
3269
  st_error *e= global_error_names;
3277
3277
      (as in ER_WRONG_VALUE vs. ER_WRONG_VALUE_COUNT).
3278
3278
    */
3279
3279
    if (!strncmp(error_name, e->name, (int) (error_end - error_name)) &&
3280
 
        (uint) strlen(e->name) == (uint) (error_end - error_name))
 
3280
        (uint32_t) strlen(e->name) == (uint32_t) (error_end - error_name))
3281
3281
    {
3282
3282
      return(e->code);
3283
3283
    }
3291
3291
{
3292
3292
  struct st_match_err *to= saved_expected_errors.err;
3293
3293
  char *p= command->first_argument;
3294
 
  uint count= 0;
 
3294
  uint32_t count= 0;
3295
3295
 
3296
3296
 
3297
3297
 
3370
3370
      if (!str2int(start, 10, (long) INT_MIN, (long) INT_MAX, &val))
3371
3371
        die("Invalid argument to error: '%s'", command->first_argument);
3372
3372
 
3373
 
      to->code.errnum= (uint) val;
 
3373
      to->code.errnum= (uint32_t) val;
3374
3374
      to->type= ERR_ERRNO;
3375
3375
    }
3376
3376
    to++;
3985
3985
}
3986
3986
 
3987
3987
 
3988
 
bool match_delimiter(int c, const char *delim, uint length)
 
3988
bool match_delimiter(int c, const char *delim, uint32_t length)
3989
3989
{
3990
 
  uint i;
 
3990
  uint32_t i;
3991
3991
  char tmp[MAX_DELIMITER_LENGTH];
3992
3992
 
3993
3993
  if (c != *delim)
4287
4287
        ptr[2] && ptr[2] == '-' &&
4288
4288
        ptr[3])
4289
4289
    {
4290
 
      uint type;
 
4290
      uint32_t type;
4291
4291
      char save;
4292
4292
      char *end, *start= (char*)ptr+3;
4293
4293
      /* Skip leading spaces */
4434
4434
  p= command->query;
4435
4435
  while (*p && !my_isspace(charset_info, *p) && *p != '(')
4436
4436
    p++;
4437
 
  command->first_word_len= (uint) (p - command->query);
 
4437
  command->first_word_len= (uint32_t) (p - command->query);
4438
4438
 
4439
4439
  /* Skip spaces between command and first argument */
4440
4440
  while (*p && my_isspace(charset_info, *p))
4813
4813
  Append the result for one field to the dynamic string ds
4814
4814
*/
4815
4815
 
4816
 
static void append_field(string *ds, uint col_idx, const DRIZZLE_FIELD* field,
 
4816
static void append_field(string *ds, uint32_t col_idx, const DRIZZLE_FIELD* field,
4817
4817
                         const char* val, uint64_t len, bool is_null)
4818
4818
{
4819
4819
  if (col_idx < max_replace_column && replace_column[col_idx])
4875
4875
 
4876
4876
static void append_metadata(string *ds,
4877
4877
                            const DRIZZLE_FIELD *field,
4878
 
                            uint num_fields)
 
4878
                            uint32_t num_fields)
4879
4879
{
4880
4880
  const DRIZZLE_FIELD *field_end;
4881
4881
  ds->append("Catalog\tDatabase\tTable\tTable_alias\tColumn\t"
4946
4946
 
4947
4947
static void append_table_headings(string *ds,
4948
4948
                                  const DRIZZLE_FIELD *field,
4949
 
                                  uint num_fields)
 
4949
                                  uint32_t num_fields)
4950
4950
{
4951
 
  uint col_idx;
 
4951
  uint32_t col_idx;
4952
4952
  for (col_idx= 0; col_idx < num_fields; col_idx++)
4953
4953
  {
4954
4954
    if (col_idx)
4967
4967
 
4968
4968
static int append_warnings(string *ds, DRIZZLE *drizzle)
4969
4969
{
4970
 
  uint count;
 
4970
  uint32_t count;
4971
4971
  DRIZZLE_RES *warn_res;
4972
4972
 
4973
4973
 
5062
5062
      if (res)
5063
5063
      {
5064
5064
        const DRIZZLE_FIELD *fields= drizzleclient_fetch_fields(res);
5065
 
        uint num_fields= drizzleclient_num_fields(res);
 
5065
        uint32_t num_fields= drizzleclient_num_fields(res);
5066
5066
 
5067
5067
        if (display_metadata)
5068
5068
          append_metadata(ds, fields, num_fields);
5149
5149
                  unsigned int err_errno, const char *err_error,
5150
5150
                  const char *err_sqlstate, string *ds)
5151
5151
{
5152
 
  uint i;
 
5152
  uint32_t i;
5153
5153
 
5154
5154
 
5155
5155
  if (command->require_file[0])
5172
5172
  if (command->abort_on_error)
5173
5173
    die("query '%s' failed: %d: %s", command->query, err_errno, err_error);
5174
5174
 
5175
 
  for (i= 0 ; (uint) i < command->expected_errors.count ; i++)
 
5175
  for (i= 0 ; (uint32_t) i < command->expected_errors.count ; i++)
5176
5176
  {
5177
5177
    if (((command->expected_errors.err[i].type == ERR_ERRNO) &&
5178
5178
         (command->expected_errors.err[i].code.errnum == err_errno)) ||
5373
5373
static void get_command_type(struct st_command* command)
5374
5374
{
5375
5375
  char save;
5376
 
  uint type;
 
5376
  uint32_t type;
5377
5377
 
5378
5378
 
5379
5379
  if (*command->query == '}')
5492
5492
{
5493
5493
  struct st_command *command;
5494
5494
  bool q_send_flag= 0, abort_flag= 0;
5495
 
  uint command_executed= 0, last_command_executed= 0;
 
5495
  uint32_t command_executed= 0, last_command_executed= 0;
5496
5496
  char save_file[FN_REFLEN];
5497
5497
  struct stat res_info;
5498
5498
  MY_INIT(argv[0]);
5997
5997
  while (*from)
5998
5998
  {
5999
5999
    char *to;
6000
 
    uint column_number;
 
6000
    uint32_t column_number;
6001
6001
 
6002
6002
    to= get_string(&buff, &from, command);
6003
6003
    if (!(column_number= atoi(to)) || column_number > MAX_COLUMNS)
6018
6018
 
6019
6019
void free_replace_column()
6020
6020
{
6021
 
  uint i;
 
6021
  uint32_t i;
6022
6022
  for (i=0 ; i < max_replace_column ; i++)
6023
6023
  {
6024
6024
    if (replace_column[i])
6042
6042
  TYPELIB typelib;        /* Pointer to strings */
6043
6043
  unsigned char  *str;          /* Strings is here */
6044
6044
  uint8_t *flag;          /* Flag about each var. */
6045
 
  uint  array_allocs,max_count,length,max_length;
 
6045
  uint32_t  array_allocs,max_count,length,max_length;
6046
6046
} POINTER_ARRAY;
6047
6047
 
6048
6048
struct st_replace;
6049
 
struct st_replace *init_replace(char * *from, char * *to, uint count,
 
6049
struct st_replace *init_replace(char * *from, char * *to, uint32_t count,
6050
6050
                                char * word_end_chars);
6051
6051
int insert_pointer_name(POINTER_ARRAY *pa,char * name);
6052
6052
void replace_strings_append(struct st_replace *rep, string* ds,
6065
6065
 
6066
6066
void do_get_replace(struct st_command *command)
6067
6067
{
6068
 
  uint i;
 
6068
  uint32_t i;
6069
6069
  char *from= command->first_argument;
6070
6070
  char *buff, *start;
6071
6071
  char word_end_chars[256], *pos;
6096
6096
  *pos=0;          /* End pointer */
6097
6097
  if (!(glob_replace= init_replace((char**) from_array.typelib.type_names,
6098
6098
                                   (char**) to_array.typelib.type_names,
6099
 
                                   (uint) from_array.typelib.count,
 
6099
                                   (uint32_t) from_array.typelib.count,
6100
6100
                                   word_end_chars)))
6101
6101
    die("Can't initialize replace from '%s'", command->query);
6102
6102
  free_pointer_array(&from_array);
6127
6127
typedef struct st_replace_found {
6128
6128
  bool found;
6129
6129
  char *replace_string;
6130
 
  uint to_offset;
 
6130
  uint32_t to_offset;
6131
6131
  int from_offset;
6132
6132
} REPLACE_STRING;
6133
6133
 
6253
6253
  char* buf,*expr_end;
6254
6254
  char* p;
6255
6255
  char* buf_p;
6256
 
  uint expr_len= strlen(expr);
 
6256
  uint32_t expr_len= strlen(expr);
6257
6257
  char last_c = 0;
6258
6258
  struct st_regex reg;
6259
6259
 
6349
6349
 
6350
6350
static int multi_reg_replace(struct st_replace_regex* r,char* val)
6351
6351
{
6352
 
  uint i;
 
6352
  uint32_t i;
6353
6353
  char* in_buf, *out_buf;
6354
6354
  int* buf_len_p;
6355
6355
 
6483
6483
 
6484
6484
 
6485
6485
#ifndef WORD_BIT
6486
 
#define WORD_BIT (8*sizeof(uint))
 
6486
#define WORD_BIT (8*sizeof(uint32_t))
6487
6487
#endif
6488
6488
 
6489
6489
#define SET_MALLOC_HUNC 64
6490
6490
#define LAST_CHAR_CODE 259
6491
6491
 
6492
6492
typedef struct st_rep_set {
6493
 
  uint  *bits;        /* Pointer to used sets */
 
6493
  uint32_t  *bits;        /* Pointer to used sets */
6494
6494
  short next[LAST_CHAR_CODE];    /* Pointer to next sets */
6495
 
  uint  found_len;      /* Best match to date */
 
6495
  uint32_t  found_len;      /* Best match to date */
6496
6496
  int  found_offset;
6497
 
  uint  table_offset;
6498
 
  uint  size_of_bits;      /* For convinience */
 
6497
  uint32_t  table_offset;
 
6498
  uint32_t  size_of_bits;      /* For convinience */
6499
6499
} REP_SET;
6500
6500
 
6501
6501
typedef struct st_rep_sets {
6502
 
  uint    count;      /* Number of sets */
6503
 
  uint    extra;      /* Extra sets in buffer */
6504
 
  uint    invisible;    /* Sets not chown */
6505
 
  uint    size_of_bits;
 
6502
  uint32_t    count;      /* Number of sets */
 
6503
  uint32_t    extra;      /* Extra sets in buffer */
 
6504
  uint32_t    invisible;    /* Sets not chown */
 
6505
  uint32_t    size_of_bits;
6506
6506
  REP_SET  *set,*set_buffer;
6507
 
  uint    *bit_buffer;
 
6507
  uint32_t    *bit_buffer;
6508
6508
} REP_SETS;
6509
6509
 
6510
6510
typedef struct st_found_set {
6511
 
  uint table_offset;
 
6511
  uint32_t table_offset;
6512
6512
  int found_offset;
6513
6513
} FOUND_SET;
6514
6514
 
6515
6515
typedef struct st_follow {
6516
6516
  int chr;
6517
 
  uint table_offset;
6518
 
  uint len;
 
6517
  uint32_t table_offset;
 
6518
  uint32_t len;
6519
6519
} FOLLOWS;
6520
6520
 
6521
6521
 
6522
 
int init_sets(REP_SETS *sets,uint states);
 
6522
int init_sets(REP_SETS *sets,uint32_t states);
6523
6523
REP_SET *make_new_set(REP_SETS *sets);
6524
6524
void make_sets_invisible(REP_SETS *sets);
6525
6525
void free_last_set(REP_SETS *sets);
6526
6526
void free_sets(REP_SETS *sets);
6527
 
void internal_set_bit(REP_SET *set, uint bit);
6528
 
void internal_clear_bit(REP_SET *set, uint bit);
 
6527
void internal_set_bit(REP_SET *set, uint32_t bit);
 
6528
void internal_clear_bit(REP_SET *set, uint32_t bit);
6529
6529
void or_bits(REP_SET *to,REP_SET *from);
6530
6530
void copy_bits(REP_SET *to,REP_SET *from);
6531
6531
int cmp_bits(REP_SET *set1,REP_SET *set2);
6532
 
int get_next_bit(REP_SET *set,uint lastpos);
 
6532
int get_next_bit(REP_SET *set,uint32_t lastpos);
6533
6533
int find_set(REP_SETS *sets,REP_SET *find);
6534
 
int find_found(FOUND_SET *found_set,uint table_offset,
 
6534
int find_found(FOUND_SET *found_set,uint32_t table_offset,
6535
6535
               int found_offset);
6536
 
uint start_at_word(char * pos);
6537
 
uint end_of_word(char * pos);
6538
 
 
6539
 
static uint found_sets=0;
6540
 
 
6541
 
 
6542
 
static uint replace_len(char * str)
 
6536
uint32_t start_at_word(char * pos);
 
6537
uint32_t end_of_word(char * pos);
 
6538
 
 
6539
static uint32_t found_sets=0;
 
6540
 
 
6541
 
 
6542
static uint32_t replace_len(char * str)
6543
6543
{
6544
 
  uint len=0;
 
6544
  uint32_t len=0;
6545
6545
  while (*str)
6546
6546
  {
6547
6547
    if (str[0] == '\\' && str[1])
6554
6554
 
6555
6555
/* Init a replace structure for further calls */
6556
6556
 
6557
 
REPLACE *init_replace(char * *from, char * *to,uint count,
 
6557
REPLACE *init_replace(char * *from, char * *to,uint32_t count,
6558
6558
                      char * word_end_chars)
6559
6559
{
6560
6560
  static const int SPACE_CHAR= 256;
6561
6561
  static const int START_OF_LINE= 257;
6562
6562
  static const int END_OF_LINE= 258;
6563
6563
 
6564
 
  uint i,j,states,set_nr,len,result_len,max_length,found_end,bits_set,bit_nr;
 
6564
  uint32_t i,j,states,set_nr,len,result_len,max_length,found_end,bits_set,bit_nr;
6565
6565
  int used_sets,chr,default_state;
6566
6566
  char used_chars[LAST_CHAR_CODE],is_word_end[256];
6567
6567
  char * pos, *to_pos, **to_array;
6583
6583
      return(0);
6584
6584
    }
6585
6585
    states+=len+1;
6586
 
    result_len+=(uint) strlen(to[i])+1;
 
6586
    result_len+=(uint32_t) strlen(to[i])+1;
6587
6587
    if (len > max_length)
6588
6588
      max_length=len;
6589
6589
  }
6681
6681
    follow_ptr->table_offset=i;
6682
6682
    follow_ptr->len=len;
6683
6683
    follow_ptr++;
6684
 
    states+=(uint) len+1;
 
6684
    states+=(uint32_t) len+1;
6685
6685
  }
6686
6686
 
6687
6687
 
6839
6839
}
6840
6840
 
6841
6841
 
6842
 
int init_sets(REP_SETS *sets,uint states)
 
6842
int init_sets(REP_SETS *sets,uint32_t states)
6843
6843
{
6844
6844
  memset(sets, 0, sizeof(*sets));
6845
6845
  sets->size_of_bits=((states+7)/8);
6846
6846
  if (!(sets->set_buffer=(REP_SET*) malloc(sizeof(REP_SET)*SET_MALLOC_HUNC)))
6847
6847
    return 1;
6848
 
  if (!(sets->bit_buffer=(uint*) malloc(sizeof(uint)*sets->size_of_bits*
 
6848
  if (!(sets->bit_buffer=(uint*) malloc(sizeof(uint32_t)*sets->size_of_bits*
6849
6849
                                        SET_MALLOC_HUNC)))
6850
6850
  {
6851
6851
    free(sets->set);
6865
6865
 
6866
6866
REP_SET *make_new_set(REP_SETS *sets)
6867
6867
{
6868
 
  uint i,count,*bit_buffer;
 
6868
  uint32_t i,count,*bit_buffer;
6869
6869
  REP_SET *set;
6870
6870
  if (sets->extra)
6871
6871
  {
6872
6872
    sets->extra--;
6873
6873
    set=sets->set+ sets->count++;
6874
 
    memset(set->bits, 0, sizeof(uint)*sets->size_of_bits);
 
6874
    memset(set->bits, 0, sizeof(uint32_t)*sets->size_of_bits);
6875
6875
    memset(&set->next[0], 0, sizeof(set->next[0])*LAST_CHAR_CODE);
6876
6876
    set->found_offset=0;
6877
6877
    set->found_len=0;
6886
6886
  sets->set_buffer=set;
6887
6887
  sets->set=set+sets->invisible;
6888
6888
  if (!(bit_buffer=(uint*) realloc((unsigned char*) sets->bit_buffer,
6889
 
                                   (sizeof(uint)*sets->size_of_bits)*count)))
 
6889
                                   (sizeof(uint32_t)*sets->size_of_bits)*count)))
6890
6890
    return 0;
6891
6891
  sets->bit_buffer=bit_buffer;
6892
6892
  for (i=0 ; i < count ; i++)
6912
6912
  return;
6913
6913
}
6914
6914
 
6915
 
void internal_set_bit(REP_SET *set, uint bit)
 
6915
void internal_set_bit(REP_SET *set, uint32_t bit)
6916
6916
{
6917
6917
  set->bits[bit / WORD_BIT] |= 1 << (bit % WORD_BIT);
6918
6918
  return;
6919
6919
}
6920
6920
 
6921
 
void internal_clear_bit(REP_SET *set, uint bit)
 
6921
void internal_clear_bit(REP_SET *set, uint32_t bit)
6922
6922
{
6923
6923
  set->bits[bit / WORD_BIT] &= ~ (1 << (bit % WORD_BIT));
6924
6924
  return;
6927
6927
 
6928
6928
void or_bits(REP_SET *to,REP_SET *from)
6929
6929
{
6930
 
  register uint i;
 
6930
  register uint32_t i;
6931
6931
  for (i=0 ; i < to->size_of_bits ; i++)
6932
6932
    to->bits[i]|=from->bits[i];
6933
6933
  return;
6936
6936
void copy_bits(REP_SET *to,REP_SET *from)
6937
6937
{
6938
6938
  memcpy(to->bits,from->bits,
6939
 
         (size_t) (sizeof(uint) * to->size_of_bits));
 
6939
         (size_t) (sizeof(uint32_t) * to->size_of_bits));
6940
6940
}
6941
6941
 
6942
6942
int cmp_bits(REP_SET *set1,REP_SET *set2)
6943
6943
{
6944
 
  return memcmp(set1->bits,set2->bits, sizeof(uint) * set1->size_of_bits);
 
6944
  return memcmp(set1->bits,set2->bits, sizeof(uint32_t) * set1->size_of_bits);
6945
6945
}
6946
6946
 
6947
6947
 
6948
6948
/* Get next set bit from set. */
6949
6949
 
6950
 
int get_next_bit(REP_SET *set,uint lastpos)
 
6950
int get_next_bit(REP_SET *set,uint32_t lastpos)
6951
6951
{
6952
 
  uint pos,*start,*end,bits;
 
6952
  uint32_t pos,*start,*end,bits;
6953
6953
 
6954
6954
  start=set->bits+ ((lastpos+1) / WORD_BIT);
6955
6955
  end=set->bits + set->size_of_bits;
6959
6959
    bits=start[0];
6960
6960
  if (!bits)
6961
6961
    return 0;
6962
 
  pos=(uint) (start-set->bits)*WORD_BIT;
 
6962
  pos=(uint32_t) (start-set->bits)*WORD_BIT;
6963
6963
  while (! (bits & 1))
6964
6964
  {
6965
6965
    bits>>=1;
6974
6974
 
6975
6975
int find_set(REP_SETS *sets,REP_SET *find)
6976
6976
{
6977
 
  uint i;
 
6977
  uint32_t i;
6978
6978
  for (i=0 ; i < sets->count-1 ; i++)
6979
6979
  {
6980
6980
    if (!cmp_bits(sets->set+i,find))
6993
6993
   set->next[] == -1 is reserved for end without replaces.
6994
6994
*/
6995
6995
 
6996
 
int find_found(FOUND_SET *found_set,uint table_offset, int found_offset)
 
6996
int find_found(FOUND_SET *found_set,uint32_t table_offset, int found_offset)
6997
6997
{
6998
6998
  int i;
6999
 
  for (i=0 ; (uint) i < found_sets ; i++)
 
6999
  for (i=0 ; (uint32_t) i < found_sets ; i++)
7000
7000
    if (found_set[i].table_offset == table_offset &&
7001
7001
        found_set[i].found_offset == found_offset)
7002
7002
      return -i-2;
7008
7008
 
7009
7009
/* Return 1 if regexp starts with \b or ends with \b*/
7010
7010
 
7011
 
uint start_at_word(char * pos)
 
7011
uint32_t start_at_word(char * pos)
7012
7012
{
7013
7013
  return (((!memcmp(pos, "\\b",2) && pos[2]) ||
7014
7014
           !memcmp(pos, "\\^", 2)) ? 1 : 0);
7015
7015
}
7016
7016
 
7017
 
uint end_of_word(char * pos)
 
7017
uint32_t end_of_word(char * pos)
7018
7018
{
7019
7019
  char * end= strchr(pos, '\0');
7020
7020
  return ((end > pos+2 && !memcmp(end-2, "\\b", 2)) ||
7030
7030
 
7031
7031
int insert_pointer_name(POINTER_ARRAY *pa,char * name)
7032
7032
{
7033
 
  uint i,length,old_count;
 
7033
  uint32_t i,length,old_count;
7034
7034
  unsigned char *new_pos;
7035
7035
  const char **new_array;
7036
7036
 
7054
7054
    pa->max_length=PS_MALLOC-MALLOC_OVERHEAD;
7055
7055
    pa->array_allocs=1;
7056
7056
  }
7057
 
  length=(uint) strlen(name)+1;
 
7057
  length=(uint32_t) strlen(name)+1;
7058
7058
  if (pa->length+length >= pa->max_length)
7059
7059
  {
7060
7060
    if (!(new_pos= (unsigned char*)realloc((unsigned char*)pa->str,
7147
7147
  replace_append_mem(ds, val, strlen(val));
7148
7148
}
7149
7149
 
7150
 
/* Append uint to ds, with optional replace */
7151
 
void replace_append_uint(string *ds, uint val)
 
7150
/* Append uint32_t to ds, with optional replace */
 
7151
void replace_append_uint(string *ds, uint32_t val)
7152
7152
{
7153
7153
  char buff[22]; /* This should be enough for any int */
7154
7154
  char *end= int64_t10_to_str(val, buff, 10);