~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/default.c

  • Committer: Mats Kindahl
  • Date: 2008-08-07 06:24:22 UTC
  • mfrom: (265 drizzle)
  • mto: (264.1.19 codestyle)
  • mto: This revision was merged to the branch mainline in revision 266.
  • Revision ID: mats@mysql.com-20080807062422-20kyv6ssp4grfm0s
Manual merge of lp:drizzle into ~mkindahl/remove-mem-casts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
*/
127
127
 
128
128
int my_search_option_files(const char *conf_file, int *argc, char ***argv,
129
 
                           uint32_t *args_used, Process_option_func func,
 
129
                           uint *args_used, Process_option_func func,
130
130
                           void *func_ctx)
131
131
{
132
132
  const char **dirs, *forced_default_file, *forced_extra_defaults;
155
155
  if (my_defaults_group_suffix && func == handle_default_option)
156
156
  {
157
157
    /* Handle --defaults-group-suffix= */
158
 
    uint32_t i;
 
158
    uint i;
159
159
    const char **extra_groups;
160
 
    const uint32_t instance_len= strlen(my_defaults_group_suffix); 
 
160
    const uint instance_len= strlen(my_defaults_group_suffix); 
161
161
    struct handle_option_ctx *ctx= (struct handle_option_ctx*) func_ctx;
162
162
    char *ptr;
163
163
    TYPELIB *group= ctx->group;
169
169
    
170
170
    for (i= 0; i < group->count; i++)
171
171
    {
172
 
      uint32_t len;
 
172
      uint len;
173
173
      extra_groups[i]= group->type_names[i]; /** copy group */
174
174
      
175
175
      len= strlen(extra_groups[i]);
202
202
  }
203
203
  else if (dirname_length(conf_file))
204
204
  {
205
 
    if ((error= search_default_file(func, func_ctx, NULL, conf_file)) < 0)
 
205
    if ((error= search_default_file(func, func_ctx, NullS, conf_file)) < 0)
206
206
      goto err;
207
207
  }
208
208
  else
274
274
  {
275
275
    if (!(tmp= alloc_root(ctx->alloc, strlen(option) + 1)))
276
276
      return 1;
277
 
    if (insert_dynamic(ctx->args, (unsigned char*) &tmp))
 
277
    if (insert_dynamic(ctx->args, (uchar*) &tmp))
278
278
      return 1;
279
 
    my_stpcpy(tmp, option);
 
279
    strmov(tmp, option);
280
280
  }
281
281
 
282
282
  return 0;
372
372
  DYNAMIC_ARRAY args;
373
373
  TYPELIB group;
374
374
  bool found_print_defaults= 0;
375
 
  uint32_t args_used= 0;
 
375
  uint args_used= 0;
376
376
  int error= 0;
377
377
  MEM_ROOT alloc;
378
378
  char *ptr,**res;
387
387
  if (*argc >= 2 && !strcmp(argv[0][1],"--no-defaults"))
388
388
  {
389
389
    /* remove the --no-defaults argument and return only the other arguments */
390
 
    uint32_t i;
 
390
    uint i;
391
391
    if (!(ptr=(char*) alloc_root(&alloc,sizeof(alloc)+
392
392
                                 (*argc + 1)*sizeof(char*))))
393
393
      goto err;
517
517
*/
518
518
 
519
519
static char *get_argument(const char *keyword, size_t kwlen,
520
 
                          char *ptr, char *name, uint32_t line)
 
520
                          char *ptr, char *name, uint line)
521
521
{
522
522
  char *end;
523
523
 
524
524
  /* Skip over "include / includedir keyword" and following whitespace */
525
525
 
526
526
  for (ptr+= kwlen - 1;
527
 
       my_isspace(&my_charset_utf8_general_ci, ptr[0]);
 
527
       my_isspace(&my_charset_latin1, ptr[0]);
528
528
       ptr++)
529
529
  {}
530
530
 
534
534
    Note that my_isspace() is true for \r and \n
535
535
  */
536
536
  for (end= ptr + strlen(ptr) - 1;
537
 
       my_isspace(&my_charset_utf8_general_ci, *(end - 1));
 
537
       my_isspace(&my_charset_latin1, *(end - 1));
538
538
       end--)
539
539
  {}
540
540
  end[0]= 0;                                    /* Cut off end space */
586
586
  static const char include_keyword[]= "include";
587
587
  const int max_recursion_level= 10;
588
588
  FILE *fp;
589
 
  uint32_t line=0;
 
589
  uint line=0;
590
590
  bool found_group=0;
591
 
  uint32_t i;
 
591
  uint i;
592
592
  MY_DIR *search_dir;
593
593
  FILEINFO *search_file;
594
594
 
596
596
    return 0;                                   /* Ignore wrong paths */
597
597
  if (dir)
598
598
  {
599
 
    end=convert_dirname(name, dir, NULL);
 
599
    end=convert_dirname(name, dir, NullS);
600
600
    if (dir[0] == FN_HOMELIB)           /* Add . to filenames in home */
601
601
      *end++='.';
602
 
    strxmov(end,config_file,ext,NULL);
 
602
    strxmov(end,config_file,ext,NullS);
603
603
  }
604
604
  else
605
605
  {
606
 
    my_stpcpy(name,config_file);
 
606
    strmov(name,config_file);
607
607
  }
608
608
  fn_format(name,name,"","",4);
609
609
  {
630
630
  {
631
631
    line++;
632
632
    /* Ignore comment and empty lines */
633
 
    for (ptr= buff; my_isspace(&my_charset_utf8_general_ci, *ptr); ptr++)
 
633
    for (ptr= buff; my_isspace(&my_charset_latin1, *ptr); ptr++)
634
634
    {}
635
635
 
636
636
    if (*ptr == '#' || *ptr == ';' || !*ptr)
642
642
      if (recursion_level >= max_recursion_level)
643
643
      {
644
644
        for (end= ptr + strlen(ptr) - 1; 
645
 
             my_isspace(&my_charset_utf8_general_ci, *(end - 1));
 
645
             my_isspace(&my_charset_latin1, *(end - 1));
646
646
             end--)
647
647
        {}
648
648
        end[0]= 0;
654
654
      }
655
655
 
656
656
      /* skip over `!' and following whitespace */
657
 
      for (++ptr; my_isspace(&my_charset_utf8_general_ci, ptr[0]); ptr++)
 
657
      for (++ptr; my_isspace(&my_charset_latin1, ptr[0]); ptr++)
658
658
      {}
659
659
 
660
660
      if ((!strncmp(ptr, includedir_keyword,
661
661
                    sizeof(includedir_keyword) - 1)) &&
662
 
          my_isspace(&my_charset_utf8_general_ci, ptr[sizeof(includedir_keyword) - 1]))
 
662
          my_isspace(&my_charset_latin1, ptr[sizeof(includedir_keyword) - 1]))
663
663
      {
664
664
        if (!(ptr= get_argument(includedir_keyword,
665
665
                                sizeof(includedir_keyword),
694
694
        my_dirend(search_dir);
695
695
      }
696
696
      else if ((!strncmp(ptr, include_keyword, sizeof(include_keyword) - 1)) &&
697
 
               my_isspace(&my_charset_utf8_general_ci, ptr[sizeof(include_keyword)-1]))
 
697
               my_isspace(&my_charset_latin1, ptr[sizeof(include_keyword)-1]))
698
698
      {
699
699
        if (!(ptr= get_argument(include_keyword,
700
700
                                sizeof(include_keyword), ptr,
719
719
        goto err;
720
720
      }
721
721
      /* Remove end space */
722
 
      for ( ; my_isspace(&my_charset_utf8_general_ci,end[-1]) ; end--) ;
 
722
      for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
723
723
      end[0]=0;
724
724
 
725
 
      strmake(curr_gr, ptr, cmin((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
 
725
      strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
726
726
 
727
727
      /* signal that a new group is found */
728
728
      opt_handler(handler_ctx, curr_gr, NULL);
741
741
    end= remove_end_comment(ptr);
742
742
    if ((value= strchr(ptr, '=')))
743
743
      end= value;                               /* Option without argument */
744
 
    for ( ; my_isspace(&my_charset_utf8_general_ci,end[-1]) ; end--) ;
 
744
    for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;
745
745
    if (!value)
746
746
    {
747
 
      strmake(my_stpcpy(option,"--"),ptr, (size_t) (end-ptr));
 
747
      strmake(strmov(option,"--"),ptr, (size_t) (end-ptr));
748
748
      if (opt_handler(handler_ctx, curr_gr, option))
749
749
        goto err;
750
750
    }
752
752
    {
753
753
      /* Remove pre- and end space */
754
754
      char *value_end;
755
 
      for (value++ ; my_isspace(&my_charset_utf8_general_ci,*value); value++) ;
756
 
      value_end= strchr(value, '\0');
 
755
      for (value++ ; my_isspace(&my_charset_latin1,*value); value++) ;
 
756
      value_end=strend(value);
757
757
      /*
758
758
        We don't have to test for value_end >= value as we know there is
759
759
        an '=' before
760
760
      */
761
 
      for ( ; my_isspace(&my_charset_utf8_general_ci,value_end[-1]) ; value_end--) ;
 
761
      for ( ; my_isspace(&my_charset_latin1,value_end[-1]) ; value_end--) ;
762
762
      if (value_end < value)                    /* Empty string */
763
763
        value_end=value;
764
764
 
770
770
        value++;
771
771
        value_end--;
772
772
      }
773
 
      ptr=my_stpncpy(my_stpcpy(option,"--"),ptr,(size_t) (end-ptr));
 
773
      ptr=strnmov(strmov(option,"--"),ptr,(size_t) (end-ptr));
774
774
      *ptr++= '=';
775
775
 
776
776
      for ( ; value != value_end; value++)
877
877
          pos= my_defaults_extra_file;
878
878
        else
879
879
          continue;
880
 
        end= convert_dirname(name, pos, NULL);
 
880
        end= convert_dirname(name, pos, NullS);
881
881
        if (name[0] == FN_HOMELIB)      /* Add . to filenames in home */
882
882
          *end++='.';
883
 
        strxmov(end, conf_file, *ext, " ", NULL);
 
883
        strxmov(end, conf_file, *ext, " ", NullS);
884
884
        fputs(name,stdout);
885
885
      }
886
886
    }