~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_pack.c

  • Committer: Brian Aker
  • Date: 2008-08-11 17:33:54 UTC
  • mfrom: (287.3.17 codestyle)
  • Revision ID: brian@tangent.org-20080811173354-ys7tgjknox52semx
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
         (buff_length == d_length && !memcmp(buff,start,d_length))) &&
56
56
        *start != FN_LIBCHAR && *start)
57
57
    {                                           /* Put current dir before */
58
 
      bchange((unsigned char*) to, d_length, (unsigned char*) buff, buff_length, strlen(to)+1);
 
58
      bchange((uchar*) to, d_length, (uchar*) buff, buff_length, strlen(to)+1);
59
59
    }
60
60
  }
61
61
 
142
142
  if ((pos=strrchr(from_ptr,FN_DEVCHAR)) != 0)
143
143
  {                                             /* Skip device part */
144
144
    length=(size_t) (pos-from_ptr)+1;
145
 
    start=my_stpncpy(buff,from_ptr,length); from_ptr+=length;
 
145
    start=stpncpy(buff,from_ptr,length); from_ptr+=length;
146
146
  }
147
147
#endif
148
148
 
149
149
  parent[0]=FN_LIBCHAR;
150
 
  length=(size_t) (my_stpcpy(parent+1,FN_PARENTDIR)-parent);
 
150
  length=(size_t) (stpcpy(parent+1,FN_PARENTDIR)-parent);
151
151
  for (pos=start ; (*pos= *from_ptr++) != 0 ; pos++)
152
152
  {
153
153
#ifdef BACKSLASH_MBTAIL
154
 
    uint32_t l;
 
154
    uint l;
155
155
    if (use_mb(fs) && (l= my_ismbchar(fs, from_ptr - 1, from_ptr + 2)))
156
156
    {
157
157
      for (l-- ; l ; *++pos= *from_ptr++, l--);
177
177
              pos+=length+1;                    /* Don't unpack ~/.. */
178
178
              continue;
179
179
            }
180
 
            pos=my_stpcpy(buff,home_dir)-1;     /* Unpacks ~/.. */
 
180
            pos=stpcpy(buff,home_dir)-1;        /* Unpacks ~/.. */
181
181
            if (*pos == FN_LIBCHAR)
182
182
              pos--;                            /* home ended with '/' */
183
183
          }
188
188
              pos+=length+1;                    /* Don't unpack ./.. */
189
189
              continue;
190
190
            }
191
 
            pos=my_stpcpy(buff,curr_dir)-1;     /* Unpacks ./.. */
 
191
            pos=stpcpy(buff,curr_dir)-1;        /* Unpacks ./.. */
192
192
            if (*pos == FN_LIBCHAR)
193
193
              pos--;                            /* home ended with '/' */
194
194
          }
197
197
            pos--;
198
198
          if (pos[1] == FN_HOMELIB || memcmp(pos,parent,length) == 0)
199
199
          {                                     /* Don't remove ~user/ */
200
 
            pos=my_stpcpy(end_parentdir+1,parent);
 
200
            pos=stpcpy(end_parentdir+1,parent);
201
201
            *pos=FN_LIBCHAR;
202
202
            continue;
203
203
          }
223
223
      }
224
224
    }
225
225
  }
226
 
  (void) my_stpcpy(to,buff);
 
226
  (void) stpcpy(to,buff);
227
227
  return((size_t) (pos-buff));
228
228
} /* cleanup_dirname */
229
229
 
243
243
void symdirget(char *dir)
244
244
{
245
245
  char buff[FN_REFLEN];
246
 
  char *pos= strchr(dir, '\0');
 
246
  char *pos=strend(dir);
247
247
  if (dir[0] && pos[-1] != FN_DEVCHAR && my_access(dir, F_OK))
248
248
  {
249
249
    File file;
250
250
    size_t length;
251
251
    char temp= *(--pos);            /* May be "/" or "\" */
252
 
    my_stpcpy(pos,".sym");
 
252
    stpcpy(pos,".sym");
253
253
    file= my_open(dir, O_RDONLY, MYF(0));
254
254
    *pos++=temp; *pos=0;          /* Restore old filename */
255
255
    if (file >= 0)
323
323
        if (buff+h_length < suffix)
324
324
          memcpy(buff+h_length, suffix, length);
325
325
        else
326
 
          bmove_upp((unsigned char*) buff+h_length+length, (unsigned char*) suffix+length, length);
 
326
          bmove_upp((uchar*) buff+h_length+length, (uchar*) suffix+length, length);
327
327
        memcpy(buff, tilde_expansion, h_length);
328
328
      }
329
329
    }
349
349
    struct passwd *user_entry;
350
350
 
351
351
    if (!(str=strchr(*path,FN_LIBCHAR)))
352
 
      str= strchr(*path, '\0');
 
352
      str=strend(*path);
353
353
    save= *str; *str= '\0';
354
354
    user_entry=getpwnam(*path);
355
355
    *str=save;
391
391
  n_length=unpack_dirname(buff,buff);
392
392
  if (n_length+strlen(from+length) < FN_REFLEN)
393
393
  {
394
 
    (void) my_stpcpy(buff+n_length,from+length);
 
394
    (void) stpcpy(buff+n_length,from+length);
395
395
    length= system_filename(to,buff);           /* Fix to usably filename */
396
396
  }
397
397
  else
423
423
  char buff[FN_REFLEN];
424
424
 
425
425
  libchar_found=0;
426
 
  (void) my_stpcpy(buff,from);                   /* If to == from */
 
426
  (void) stpcpy(buff,from);                      /* If to == from */
427
427
  from_pos= buff;
428
428
  if ((pos=strrchr(from_pos,FN_DEVCHAR)))       /* Skip device part */
429
429
  {
430
430
    pos++;
431
 
    to_pos=my_stpncpy(to,from_pos,(size_t) (pos-from_pos));
 
431
    to_pos=stpncpy(to,from_pos,(size_t) (pos-from_pos));
432
432
    from_pos=pos;
433
433
  }
434
434
  else
444
444
      from_pos+=strlen(FN_ROOTDIR);             /* Actually +1 but... */
445
445
      if (! strchr(from_pos,FN_LIBCHAR))
446
446
      {                                         /* No dir, use [000000] */
447
 
        to_pos=my_stpcpy(to_pos,FN_C_ROOT_DIR);
 
447
        to_pos=stpcpy(to_pos,FN_C_ROOT_DIR);
448
448
        libchar_found++;
449
449
      }
450
450
    }
457
457
        *(to_pos++)=FN_C_DIR_SEP;               /* Add '.' between dirs */
458
458
      if (strstr(from_pos,FN_PARENTDIR) == from_pos &&
459
459
          from_pos+strlen(FN_PARENTDIR) == pos)
460
 
        to_pos=my_stpcpy(to_pos,FN_C_PARENT_DIR);       /* Found '../' */
 
460
        to_pos=stpcpy(to_pos,FN_C_PARENT_DIR);  /* Found '../' */
461
461
      else
462
 
        to_pos=my_stpncpy(to_pos,from_pos,(size_t) (pos-from_pos));
 
462
        to_pos=stpncpy(to_pos,from_pos,(size_t) (pos-from_pos));
463
463
      from_pos=pos+1;
464
464
    }
465
465
    *(to_pos++)=FN_C_AFTER_DIR;
466
466
  }
467
 
  length= (size_t) (my_stpcpy(to_pos,from_pos)-to);
 
467
  length= (size_t) (stpcpy(to_pos,from_pos)-to);
468
468
  return(length);
469
469
#endif
470
470
} /* system_filename */
478
478
  char buff[FN_REFLEN];
479
479
  if (from == to)
480
480
  {                                             /* Dirname may destroy from */
481
 
    my_stpcpy(buff,from);
 
481
    stpcpy(buff,from);
482
482
    from=buff;
483
483
  }
484
484
  length= dirname_part(to, from, &to_length);   /* Copy dirname & fix chars */
485
 
  (void) my_stpcpy(to + to_length,from+length);
 
485
  (void) stpcpy(to + to_length,from+length);
486
486
  return (to);
487
487
} /* intern_filename */