~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_format.c

  • Committer: Monty Taylor
  • Date: 2008-08-09 02:24:34 UTC
  • mto: (266.1.8 codestyle)
  • mto: This revision was merged to the branch mainline in revision 279.
  • Revision ID: monty@inaugust.com-20080809022434-97na8pnugghskxip
Removed mystringslt conv lib and replaced it with a noinst lib.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
*/
25
25
 
26
26
char * fn_format(char * to, const char *name, const char *dir,
27
 
                    const char *extension, uint32_t flag)
 
27
                    const char *extension, uint flag)
28
28
{
29
 
  char dev[FN_REFLEN], buff[FN_REFLEN], *pos;
30
 
  const char *startpos = name;
 
29
  char dev[FN_REFLEN], buff[FN_REFLEN], *pos, *startpos;
31
30
  const char *ext;
32
31
  register size_t length;
33
32
  size_t dev_length;
34
33
 
35
34
  /* Copy and skip directory */
36
 
  name+=(length=dirname_part(dev, startpos, &dev_length));
 
35
  name+=(length=dirname_part(dev, (startpos=(char *) name), &dev_length));
37
36
  if (length == 0 || (flag & MY_REPLACE_DIR))
38
37
  {
39
38
    /* Use given directory */
40
 
    convert_dirname(dev,dir,NULL);              /* Fix to this OS */
 
39
    convert_dirname(dev,dir,NullS);             /* Fix to this OS */
41
40
  }
42
41
  else if ((flag & MY_RELATIVE_PATH) && !test_if_hard_path(dev))
43
42
  {
44
43
    /* Put 'dir' before the given path */
45
44
    strmake(buff,dev,sizeof(buff)-1);
46
 
    pos=convert_dirname(dev,dir,NULL);
 
45
    pos=convert_dirname(dev,dir,NullS);
47
46
    strmake(pos,buff,sizeof(buff)-1- (int) (pos-dev));
48
47
  }
49
48
 
53
52
    (void) unpack_dirname(dev,dev);             /* Replace ~/.. with dir */
54
53
 
55
54
  if (!(flag & MY_APPEND_EXT) &&
56
 
      (pos= (char*) strchr(name,FN_EXTCHAR)) != NULL)
 
55
      (pos= (char*) strchr(name,FN_EXTCHAR)) != NullS)
57
56
  {
58
57
    if ((flag & MY_REPLACE_EXT) == 0)           /* If we should keep old ext */
59
58
    {
77
76
    /* To long path, return original or NULL */
78
77
    size_t tmp_length;
79
78
    if (flag & MY_SAFE_PATH)
80
 
      return NULL;
 
79
      return NullS;
81
80
    tmp_length= strlength(startpos);
82
 
    (void) strmake(to,startpos,cmin(tmp_length,FN_REFLEN-1));
 
81
    (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1));
83
82
  }
84
83
  else
85
84
  {
88
87
      memcpy(buff, name, length); /* Save name for last copy */
89
88
      name=buff;
90
89
    }
91
 
    pos=strmake(my_stpcpy(to,dev),name,length);
92
 
    (void) my_stpcpy(pos,ext);                  /* Don't convert extension */
 
90
    pos=strmake(strmov(to,dev),name,length);
 
91
    (void) strmov(pos,ext);                     /* Don't convert extension */
93
92
  }
94
93
  /*
95
94
    If MY_RETURN_REAL_PATH and MY_RESOLVE_SYMLINK is given, only do
100
99
                                   MY_RESOLVE_LINK: 0));
101
100
  else if (flag & MY_RESOLVE_SYMLINKS)
102
101
  {
103
 
    my_stpcpy(buff,to);
 
102
    strmov(buff,to);
104
103
    (void) my_readlink(to, buff, MYF(0));
105
104
  }
106
105
  return(to);