~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_pack.cc

MergedĀ fromĀ Toru.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    buff_length= strlen(buff);
49
49
    d_length= (size_t) (start-to);
50
50
    if ((start == to ||
51
 
         (buff_length == d_length && !memcmp(buff,start,d_length))) &&
52
 
        *start != FN_LIBCHAR && *start)
 
51
        (buff_length == d_length && !memcmp(buff,start,d_length))) &&
 
52
        *start != FN_LIBCHAR && *start)
53
53
    {                                           /* Put current dir before */
54
54
      bchange((unsigned char*) to, d_length, (unsigned char*) buff, buff_length, strlen(to)+1);
55
55
    }
62
62
    {
63
63
      length= strlen(home_dir);
64
64
      if (home_dir[length-1] == FN_LIBCHAR)
65
 
        length--;                               /* Don't test last '/' */
 
65
        length--;                               /* Don't test last '/' */
66
66
    }
67
67
    if (length > 1 && length < d_length)
68
68
    {                                           /* test if /xx/yy -> ~/yy */
69
69
      if (memcmp(to,home_dir,length) == 0 && to[length] == FN_LIBCHAR)
70
70
      {
71
 
        to[0]=FN_HOMELIB;                       /* Filename begins with ~ */
72
 
        (void) strmov_overlapp(to+1,to+length);
 
71
        to[0]=FN_HOMELIB;                       /* Filename begins with ~ */
 
72
        (void) strcpy(to+1,to+length);
73
73
      }
74
74
    }
75
75
    if (! getcwd_error)
76
76
    {                                           /* Test if cwd is ~/... */
77
77
      if (length > 1 && length < buff_length)
78
78
      {
79
 
        if (memcmp(buff,home_dir,length) == 0 && buff[length] == FN_LIBCHAR)
80
 
        {
81
 
          buff[0]=FN_HOMELIB;
82
 
          (void) strmov_overlapp(buff+1,buff+length);
83
 
        }
 
79
        if (memcmp(buff,home_dir,length) == 0 && buff[length] == FN_LIBCHAR)
 
80
        {
 
81
          buff[0]=FN_HOMELIB;
 
82
          (void) strcpy(buff+1,buff+length);
 
83
        }
84
84
      }
85
85
      if (is_prefix(to,buff))
86
86
      {
87
 
        length= strlen(buff);
88
 
        if (to[length])
89
 
          (void) strmov_overlapp(to,to+length); /* Remove everything before */
90
 
        else
91
 
        {
92
 
          to[0]= FN_CURLIB;                     /* Put ./ instead of cwd */
93
 
          to[1]= FN_LIBCHAR;
94
 
          to[2]= '\0';
95
 
        }
 
87
        length= strlen(buff);
 
88
        if (to[length])
 
89
          (void) strcpy(to,to+length);  /* Remove everything before */
 
90
        else
 
91
        {
 
92
          to[0]= FN_CURLIB;                     /* Put ./ instead of cwd */
 
93
          to[1]= FN_LIBCHAR;
 
94
          to[2]= '\0';
 
95
        }
96
96
      }
97
97
    }
98
98
  }
143
143
#endif
144
144
 
145
145
  parent[0]=FN_LIBCHAR;
146
 
  length=(size_t) (my_stpcpy(parent+1,FN_PARENTDIR)-parent);
 
146
  length= (size_t)((strcpy(parent+1,FN_PARENTDIR)+strlen(FN_PARENTDIR))-parent);
147
147
  for (pos=start ; (*pos= *from_ptr++) != 0 ; pos++)
148
148
  {
149
149
#ifdef BACKSLASH_MBTAIL
173
173
              pos+=length+1;                    /* Don't unpack ~/.. */
174
174
              continue;
175
175
            }
176
 
            pos=my_stpcpy(buff,home_dir)-1;     /* Unpacks ~/.. */
 
176
            pos= strcpy(buff,home_dir)+strlen(home_dir)-1;      /* Unpacks ~/.. */
177
177
            if (*pos == FN_LIBCHAR)
178
178
              pos--;                            /* home ended with '/' */
179
179
          }
184
184
              pos+=length+1;                    /* Don't unpack ./.. */
185
185
              continue;
186
186
            }
187
 
            pos=my_stpcpy(buff,curr_dir)-1;     /* Unpacks ./.. */
 
187
            pos= strcpy(buff,curr_dir)+strlen(curr_dir)-1;      /* Unpacks ./.. */
188
188
            if (*pos == FN_LIBCHAR)
189
189
              pos--;                            /* home ended with '/' */
190
190
          }
193
193
            pos--;
194
194
          if (pos[1] == FN_HOMELIB || memcmp(pos,parent,length) == 0)
195
195
          {                                     /* Don't remove ~user/ */
196
 
            pos=my_stpcpy(end_parentdir+1,parent);
 
196
            pos= strcpy(end_parentdir+1,parent)+strlen(parent);
197
197
            *pos=FN_LIBCHAR;
198
198
            continue;
199
199
          }
219
219
      }
220
220
    }
221
221
  }
222
 
  (void) my_stpcpy(to,buff);
 
222
  (void) strcpy(to,buff);
223
223
  return((size_t) (pos-buff));
224
224
} /* cleanup_dirname */
225
225
 
245
245
    File file;
246
246
    size_t length;
247
247
    char temp= *(--pos);            /* May be "/" or "\" */
248
 
    my_stpcpy(pos,".sym");
 
248
    strcpy(pos,".sym");
249
249
    file= my_open(dir, O_RDONLY, MYF(0));
250
250
    *pos++=temp; *pos=0;          /* Restore old filename */
251
251
    if (file >= 0)
387
387
  n_length=unpack_dirname(buff,buff);
388
388
  if (n_length+strlen(from+length) < FN_REFLEN)
389
389
  {
390
 
    (void) my_stpcpy(buff+n_length,from+length);
 
390
    (void) strcpy(buff+n_length,from+length);
391
391
    length= system_filename(to,buff);           /* Fix to usably filename */
392
392
  }
393
393
  else
419
419
  char buff[FN_REFLEN];
420
420
 
421
421
  libchar_found=0;
422
 
  (void) my_stpcpy(buff,from);                   /* If to == from */
 
422
  (void) strcpy(buff,from);                      /* If to == from */
423
423
  from_pos= buff;
424
424
  if ((pos=strrchr(from_pos,FN_DEVCHAR)))       /* Skip device part */
425
425
  {
440
440
      from_pos+=strlen(FN_ROOTDIR);             /* Actually +1 but... */
441
441
      if (! strchr(from_pos,FN_LIBCHAR))
442
442
      {                                         /* No dir, use [000000] */
443
 
        to_pos=my_stpcpy(to_pos,FN_C_ROOT_DIR);
 
443
        to_pos= strcpy(to_pos,FN_C_ROOT_DIR)+strlen(FN_C_ROOT_DIR);
444
444
        libchar_found++;
445
445
      }
446
446
    }
450
450
    while ((pos=strchr(from_pos,FN_LIBCHAR)))
451
451
    {
452
452
      if (libchar_found++)
453
 
        *(to_pos++)=FN_C_DIR_SEP;               /* Add '.' between dirs */
 
453
        *(to_pos++)=FN_C_DIR_SEP;               /* Add '.' between dirs */
454
454
      if (strstr(from_pos,FN_PARENTDIR) == from_pos &&
455
 
          from_pos+strlen(FN_PARENTDIR) == pos)
456
 
        to_pos=my_stpcpy(to_pos,FN_C_PARENT_DIR);       /* Found '../' */
 
455
          from_pos+strlen(FN_PARENTDIR) == pos) {
 
456
        to_pos= strcpy(to_pos,FN_C_PARENT_DIR); /* Found '../' */
 
457
        to_pos+= strlen(FN_C_PARENT_DIR);
 
458
      }
457
459
      else
458
 
        to_pos=my_stpncpy(to_pos,from_pos,(size_t) (pos-from_pos));
 
460
        to_pos=my_stpncpy(to_pos,from_pos,(size_t) (pos-from_pos));
459
461
      from_pos=pos+1;
460
462
    }
461
463
    *(to_pos++)=FN_C_AFTER_DIR;
462
464
  }
463
 
  length= (size_t) (my_stpcpy(to_pos,from_pos)-to);
 
465
  
 
466
  strcpy(to_pos, from_pos);
 
467
  length= strlen(to);
464
468
  return(length);
465
469
#endif
466
470
} /* system_filename */
474
478
  char buff[FN_REFLEN];
475
479
  if (from == to)
476
480
  {                                             /* Dirname may destroy from */
477
 
    my_stpcpy(buff,from);
 
481
    strcpy(buff,from);
478
482
    from=buff;
479
483
  }
480
484
  length= dirname_part(to, from, &to_length);   /* Copy dirname & fix chars */
481
 
  (void) my_stpcpy(to + to_length,from+length);
 
485
  (void) strcpy(to + to_length,from+length);
482
486
  return (to);
483
487
} /* intern_filename */