~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_pack.cc

  • Committer: Monty Taylor
  • Date: 2009-01-19 07:30:16 UTC
  • mto: (801.1.3 testable) (779.3.2 devel)
  • mto: This revision was merged to the branch mainline in revision 799.
  • Revision ID: mordred@inaugust.com-20090119073016-smc5kj5ksbvxxldh
Removed stuff that gcov showed we weren't using.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
static char * expand_tilde(char * *path);
24
24
 
25
 
        /* Pack a dirname ; Changes HOME to ~/ and current dev to ./ */
26
 
        /* from is a dirname (from dirname() ?) ending with FN_LIBCHAR */
27
 
        /* to may be == from */
28
 
 
29
 
void pack_dirname(char * to, const char *from)
30
 
{
31
 
  int getcwd_error= 0;
32
 
  size_t d_length,length,buff_length= 0;
33
 
  char * start;
34
 
  char buff[FN_REFLEN];
35
 
 
36
 
  (void) intern_filename(to,from);              /* Change to intern name */
37
 
 
38
 
#ifdef FN_DEVCHAR
39
 
  if ((start=strrchr(to,FN_DEVCHAR)) != 0)      /* Skip device part */
40
 
    start++;
41
 
  else
42
 
#endif
43
 
    start=to;
44
 
 
45
 
  if (!(getcwd(buff, FN_REFLEN)))
46
 
  {
47
 
    getcwd_error= errno;
48
 
    buff_length= strlen(buff);
49
 
    d_length= (size_t) (start-to);
50
 
    if ((start == to ||
51
 
        (buff_length == d_length && !memcmp(buff,start,d_length))) &&
52
 
        *start != FN_LIBCHAR && *start)
53
 
    {                                           /* Put current dir before */
54
 
      bchange((unsigned char*) to, d_length, (unsigned char*) buff, buff_length, strlen(to)+1);
55
 
    }
56
 
  }
57
 
 
58
 
  if ((d_length= cleanup_dirname(to,to)) != 0)
59
 
  {
60
 
    length=0;
61
 
    if (home_dir)
62
 
    {
63
 
      length= strlen(home_dir);
64
 
      if (home_dir[length-1] == FN_LIBCHAR)
65
 
        length--;                               /* Don't test last '/' */
66
 
    }
67
 
    if (length > 1 && length < d_length)
68
 
    {                                           /* test if /xx/yy -> ~/yy */
69
 
      if (memcmp(to,home_dir,length) == 0 && to[length] == FN_LIBCHAR)
70
 
      {
71
 
        to[0]=FN_HOMELIB;                       /* Filename begins with ~ */
72
 
        (void) strcpy(to+1,to+length);
73
 
      }
74
 
    }
75
 
    if (! getcwd_error)
76
 
    {                                           /* Test if cwd is ~/... */
77
 
      if (length > 1 && length < buff_length)
78
 
      {
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
 
      }
85
 
      if (is_prefix(to,buff))
86
 
      {
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
 
      }
97
 
    }
98
 
  }
99
 
  return;
100
 
} /* pack_dirname */
101
 
 
102
25
 
103
26
/*
104
27
  remove unwanted chars from dirname