~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_dirname.cc

  • Committer: Stewart Smith
  • Date: 2009-06-16 03:02:59 UTC
  • mto: This revision was merged to the branch mainline in revision 1065.
  • Revision ID: stewart@flamingspork.com-20090616030259-tn2thqrajk6cappd
ER_NISAMCHK is unused, mark it as so. Thanks to Paul DuBois for researching this for MySQL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#include "mysys_priv.h"
 
16
#include "mysys/mysys_priv.h"
17
17
#include <mystrings/m_string.h>
18
18
 
19
19
        /* Functions definied in this file */
21
21
size_t dirname_length(const char *name)
22
22
{
23
23
  register const char *pos, *gpos;
24
 
#ifdef BASKSLASH_MBTAIL
25
 
  CHARSET_INFO *fs= fs_character_set();
26
 
#endif
27
24
#ifdef FN_DEVCHAR
28
25
  if ((pos=(char*)strrchr(name,FN_DEVCHAR)) == 0)
29
26
#endif
32
29
  gpos= pos++;
33
30
  for ( ; *pos ; pos++)                         /* Find last FN_LIBCHAR */
34
31
  {
35
 
#ifdef BASKSLASH_MBTAIL
36
 
    uint32_t l;
37
 
    if (use_mb(fs) && (l= my_ismbchar(fs, pos, pos + 3)))
38
 
    {
39
 
      pos+= l - 1;
40
 
      continue;
41
 
    }
42
 
#endif
43
32
    if (*pos == FN_LIBCHAR || *pos == '/'
44
33
#ifdef FN_C_AFTER_DIR
45
34
        || *pos == FN_C_AFTER_DIR || *pos == FN_C_AFTER_DIR_2
107
96
char *convert_dirname(char *to, const char *from, const char *from_end)
108
97
{
109
98
  char *to_org=to;
110
 
#ifdef BACKSLASH_MBTAIL
111
 
  CHARSET_INFO *fs= fs_character_set();
112
 
#endif
113
99
 
114
100
  /* We use -2 here, becasue we need place for the last FN_LIBCHAR */
115
101
  if (!from_end || (from_end - from) > FN_REFLEN-2)
129
115
#endif
130
116
      else
131
117
      {
132
 
#ifdef BACKSLASH_MBTAIL
133
 
        uint32_t l;
134
 
        if (use_mb(fs) && (l= my_ismbchar(fs, from, from + 3)))
135
 
        {
136
 
          memmove(to, from, l);
137
 
          to+= l;
138
 
          from+= l - 1;
139
 
          to_org= to; /* Don't look inside mbchar */
140
 
        }
141
 
        else
142
 
#endif
143
 
        {
144
 
          *to++= *from;
145
 
        }
 
118
        *to++= *from;
146
119
      }
147
120
    }
148
121
    *to=0;
149
122
  }
150
123
#else
151
124
  /* This is ok even if to == from, becasue we need to cut the string */
152
 
  to= strmake(to, from, (size_t) (from_end-from));
 
125
  size_t len= cmin(strlen(from),(size_t)(from_end-from));
 
126
  assert(memmove(to, from, len));
 
127
  to+= len;
 
128
  to[0]= '\0';
153
129
#endif
154
130
 
155
131
  /* Add FN_LIBCHAR to the end of directory path */