Commit 563287b0 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Introduced a platform independent version of strchr, as the return value is const on Windows.

This fixes building of D8 on Windows.

Mac OS and FreeBSD changes have not been tested.
Review URL: http://codereview.chromium.org/20534

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1326 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0b4b32d9
......@@ -419,8 +419,8 @@ static char* ReadChars(const char *name, int* size_out) {
}
static char* ReadToken(const char* data, char token) {
char* next = ::strchr(data, token);
static char* ReadToken(char* data, char token) {
char* next = i::OS::StrChr(data, token);
if (next != NULL) {
*next = '\0';
return (next + 1);
......@@ -430,12 +430,12 @@ static char* ReadToken(const char* data, char token) {
}
static char* ReadLine(const char* data) {
static char* ReadLine(char* data) {
return ReadToken(data, '\n');
}
static char* ReadWord(const char* data) {
static char* ReadWord(char* data) {
return ReadToken(data, ' ');
}
......
......@@ -184,6 +184,11 @@ int OS::VSNPrintF(Vector<char> str,
}
char* OS::StrChr(char* str, int c) {
return strchr(str, c);
}
void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
strncpy(dest.start(), src, n);
}
......
......@@ -180,6 +180,11 @@ int OS::VSNPrintF(Vector<char> str,
}
char* OS::StrChr(char* str, int c) {
return strchr(str, c);
}
void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
strncpy(dest.start(), src, n);
}
......
......@@ -185,6 +185,11 @@ int OS::VSNPrintF(Vector<char> str,
}
char* OS::StrChr(char* str, int c) {
return strchr(str, c);
}
void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
strncpy(dest.start(), src, n);
}
......
......@@ -732,6 +732,11 @@ int OS::VSNPrintF(Vector<char> str, const char* format, va_list args) {
}
char* OS::StrChr(char* str, int c) {
return const_cast<char*>(strchr(str, c));
}
void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
int result = strncpy_s(dest.start(), dest.length(), src, n);
USE(result);
......
......@@ -219,6 +219,7 @@ class OS {
const char* format,
va_list args);
static char* StrChr(char* str, int c);
static void StrNCpy(Vector<char> dest, const char* src, size_t n);
static char* StrDup(const char* str);
static char* StrNDup(const char* str, size_t n);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment