~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_path.cc

  • Committer: Toru Maesaka
  • Date: 2008-12-10 18:33:08 UTC
  • mto: (670.1.11 devel)
  • mto: This revision was merged to the branch mainline in revision 672.
  • Revision ID: dev@torum.net-20081210183308-mb6a5x0sbl1dhc5c
Replaced MySQL's my_stpncpy() with libc and c++ calls

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <mystrings/m_string.h>
18
18
#include "my_static.h"
19
19
#include <stdlib.h>
 
20
#include <sstream>
20
21
 
21
22
static char *find_file_in_path(char *to,const char *name);
22
23
 
78
79
 
79
80
static char *find_file_in_path(char *to, const char *name)
80
81
{
81
 
  char *path,*pos,dir[2];
 
82
  char *path,*pos, dir[2];
82
83
  const char *ext="";
 
84
  std::ostringstream sstream;
83
85
 
84
86
  if (!(path=getenv("PATH")))
85
87
    return NULL;
93
95
  {
94
96
    if (path != pos)
95
97
    {
96
 
      strxmov(my_stpncpy(to,path,(uint) (pos-path)),dir,name,ext,NULL);
 
98
      sstream << path << dir << name << ext << NULL;
 
99
      strncpy(to, sstream.str().c_str(), sstream.str().length());
97
100
      if (!access(to,F_OK))
98
101
      {
99
 
        to[(uint) (pos-path)+1]=0;      /* Return path only */
100
 
        return to;
 
102
        to[(uint) (pos-path)+1]=0;      /* Return path only */
 
103
        return to;
101
104
      }
102
105
    }
103
106
  }