Works around a VC bug by avoiding defining a function named strdup().
This commit is contained in:
parent
3c7bbf5b46
commit
e120fc5890
@ -736,13 +736,18 @@ namespace posix {
|
|||||||
typedef struct _stat stat_struct;
|
typedef struct _stat stat_struct;
|
||||||
|
|
||||||
inline int chdir(const char* dir) { return ::_chdir(dir); }
|
inline int chdir(const char* dir) { return ::_chdir(dir); }
|
||||||
|
// We cannot write ::_fileno() as MSVC defines it as a macro.
|
||||||
inline int fileno(FILE* file) { return _fileno(file); }
|
inline int fileno(FILE* file) { return _fileno(file); }
|
||||||
inline int isatty(int fd) { return ::_isatty(fd); }
|
inline int isatty(int fd) { return ::_isatty(fd); }
|
||||||
inline int stat(const char* path, stat_struct* buf) { return ::_stat(path, buf); }
|
inline int stat(const char* path, stat_struct* buf) {
|
||||||
|
return ::_stat(path, buf);
|
||||||
|
}
|
||||||
inline int strcasecmp(const char* s1, const char* s2) {
|
inline int strcasecmp(const char* s1, const char* s2) {
|
||||||
return ::_stricmp(s1, s2);
|
return ::_stricmp(s1, s2);
|
||||||
}
|
}
|
||||||
inline const char* strdup(const char* src) { return ::_strdup(src); }
|
// We cannot define the function as strdup(const char* src), since
|
||||||
|
// MSVC defines strdup as a macro.
|
||||||
|
inline char* StrDup(const char* src) { return ::_strdup(src); }
|
||||||
inline int rmdir(const char* dir) { return ::_rmdir(dir); }
|
inline int rmdir(const char* dir) { return ::_rmdir(dir); }
|
||||||
inline bool IsDir(const stat_struct& st) {
|
inline bool IsDir(const stat_struct& st) {
|
||||||
return (_S_IFDIR & st.st_mode) != 0;
|
return (_S_IFDIR & st.st_mode) != 0;
|
||||||
@ -757,7 +762,7 @@ using ::fileno;
|
|||||||
using ::isatty;
|
using ::isatty;
|
||||||
using ::stat;
|
using ::stat;
|
||||||
using ::strcasecmp;
|
using ::strcasecmp;
|
||||||
using ::strdup;
|
inline char* StrDup(const char* src) { return ::strdup(src); }
|
||||||
using ::rmdir;
|
using ::rmdir;
|
||||||
inline bool IsDir(const stat_struct& st) { return S_ISDIR(st.st_mode); }
|
inline bool IsDir(const stat_struct& st) { return S_ISDIR(st.st_mode); }
|
||||||
|
|
||||||
|
@ -810,7 +810,7 @@ class Arguments {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void AddArgument(const char* argument) {
|
void AddArgument(const char* argument) {
|
||||||
args_.insert(args_.end() - 1, strdup(argument));
|
args_.insert(args_.end() - 1, posix::StrDup(argument));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Str>
|
template <typename Str>
|
||||||
@ -818,7 +818,7 @@ class Arguments {
|
|||||||
for (typename ::std::vector<Str>::const_iterator i = arguments.begin();
|
for (typename ::std::vector<Str>::const_iterator i = arguments.begin();
|
||||||
i != arguments.end();
|
i != arguments.end();
|
||||||
++i) {
|
++i) {
|
||||||
args_.insert(args_.end() - 1, strdup(i->c_str()));
|
args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char* const* Argv() {
|
char* const* Argv() {
|
||||||
|
@ -98,7 +98,7 @@ bool RE::PartialMatch(const char* str, const RE& re) {
|
|||||||
|
|
||||||
// Initializes an RE from its string representation.
|
// Initializes an RE from its string representation.
|
||||||
void RE::Init(const char* regex) {
|
void RE::Init(const char* regex) {
|
||||||
pattern_ = strdup(regex);
|
pattern_ = posix::StrDup(regex);
|
||||||
|
|
||||||
// Reserves enough bytes to hold the regular expression used for a
|
// Reserves enough bytes to hold the regular expression used for a
|
||||||
// full match.
|
// full match.
|
||||||
@ -346,7 +346,7 @@ bool RE::PartialMatch(const char* str, const RE& re) {
|
|||||||
void RE::Init(const char* regex) {
|
void RE::Init(const char* regex) {
|
||||||
pattern_ = full_pattern_ = NULL;
|
pattern_ = full_pattern_ = NULL;
|
||||||
if (regex != NULL) {
|
if (regex != NULL) {
|
||||||
pattern_ = posix::strdup(regex);
|
pattern_ = posix::StrDup(regex);
|
||||||
}
|
}
|
||||||
|
|
||||||
is_valid_ = ValidateRegex(regex);
|
is_valid_ = ValidateRegex(regex);
|
||||||
|
Loading…
Reference in New Issue
Block a user