aboutsummaryrefslogtreecommitdiff
path: root/src/node_url.cc
diff options
context:
space:
mode:
authorBirunthan Mohanathas <birunthan@mohanathas.com>2017-01-19 08:38:50 +0200
committerJames M Snell <jasnell@gmail.com>2017-01-22 18:17:12 -0800
commitdcab88d529da07a73174ffb5e93cd3652a4fe0dd (patch)
tree9ebfbf0c80dc3b4b4384b0ced1a999ea13273874 /src/node_url.cc
parent09ebdf14005cc948529b3f193ad550d5dfded26a (diff)
downloadandroid-node-v8-dcab88d529da07a73174ffb5e93cd3652a4fe0dd.tar.gz
android-node-v8-dcab88d529da07a73174ffb5e93cd3652a4fe0dd.tar.bz2
android-node-v8-dcab88d529da07a73174ffb5e93cd3652a4fe0dd.zip
url: add return value to ToUnicode/ToAscii stubs
This fixes compilation errors like: node\src\node_url.cc(134) : error C4716: 'node::url::ToUnicode': must return a value PR-URL: https://github.com/nodejs/node/pull/10893 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michal Zasso <targos@protonmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Diffstat (limited to 'src/node_url.cc')
-rw-r--r--src/node_url.cc58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/node_url.cc b/src/node_url.cc
index 538126eb87..92cb8efbb8 100644
--- a/src/node_url.cc
+++ b/src/node_url.cc
@@ -96,50 +96,50 @@ using v8::Value;
namespace url {
#if defined(NODE_HAVE_I18N_SUPPORT)
- static int ToUnicode(std::string* input, std::string* output) {
+ static bool ToUnicode(std::string* input, std::string* output) {
MaybeStackBuffer<char> buf;
if (i18n::ToUnicode(&buf, input->c_str(), input->length()) < 0)
- return -1;
+ return false;
output->assign(*buf, buf.length());
- return 0;
+ return true;
}
- static int ToASCII(std::string* input, std::string* output) {
+ static bool ToASCII(std::string* input, std::string* output) {
MaybeStackBuffer<char> buf;
if (i18n::ToASCII(&buf, input->c_str(), input->length()) < 0)
- return -1;
+ return false;
output->assign(*buf, buf.length());
- return 0;
+ return true;
}
// Unfortunately there's not really a better way to do this.
// Iterate through each encoded codepoint and verify that
// it is a valid unicode codepoint.
- static int IsValidUTF8(std::string* input) {
+ static bool IsValidUTF8(std::string* input) {
const char* p = input->c_str();
int32_t len = input->length();
for (int32_t i = 0; i < len;) {
UChar32 c;
U8_NEXT_UNSAFE(p, i, c);
if (!U_IS_UNICODE_CHAR(c))
- return -1;
+ return false;
}
- return 0;
+ return true;
}
#else
// Intentional non-ops if ICU is not present.
- static int ToUnicode(std::string* input, std::string* output) {
- output->reserve(input->length());
- *output = input->c_str();
+ static bool ToUnicode(std::string* input, std::string* output) {
+ *output = *input;
+ return true;
}
- static int ToASCII(std::string* input, std::string* output) {
- output->reserve(input->length());
- *output = input->c_str();
+ static bool ToASCII(std::string* input, std::string* output) {
+ *output = *input;
+ return true;
}
- static int IsValidUTF8(std::string* input) {
- return 0;
+ static bool IsValidUTF8(std::string* input) {
+ return true;
}
#endif
@@ -381,11 +381,11 @@ namespace url {
// If there are any invalid UTF8 byte sequences, we have to fail.
// Unfortunately this means iterating through the string and checking
// each decoded codepoint.
- if (IsValidUTF8(&decoded) < 0)
+ if (!IsValidUTF8(&decoded))
goto end;
// Then we have to punycode toASCII
- if (ToASCII(&decoded, &decoded) < 0)
+ if (!ToASCII(&decoded, &decoded))
goto end;
// If any of the following characters are still present, we have to fail
@@ -405,7 +405,7 @@ namespace url {
goto end;
// If the unicode flag is set, run the result through punycode ToUnicode
- if (unicode && ToUnicode(&decoded, &decoded) < 0)
+ if (unicode && !ToUnicode(&decoded, &decoded))
goto end;
// It's not an IPv4 or IPv6 address, it must be a domain
@@ -499,17 +499,17 @@ namespace url {
return host->type;
}
- static int ParseHost(std::string* input,
- std::string* output,
- bool unicode = false) {
+ static bool ParseHost(std::string* input,
+ std::string* output,
+ bool unicode = false) {
if (input->length() == 0)
- return 0;
+ return true;
url_host host{{""}, HOST_TYPE_DOMAIN};
ParseHost(&host, input->c_str(), input->length(), unicode);
if (host.type == HOST_TYPE_FAILED)
- return -1;
+ return false;
WriteHost(&host, output);
- return 0;
+ return true;
}
static inline void Copy(Isolate* isolate,
@@ -996,7 +996,7 @@ namespace url {
if (special && buffer.size() == 0)
URL_FAILED()
SET_HAVE_HOST()
- if (ParseHost(&buffer, &url.host) < 0)
+ if (!ParseHost(&buffer, &url.host))
URL_FAILED()
buffer.clear();
state = kPort;
@@ -1011,7 +1011,7 @@ namespace url {
if (special && buffer.size() == 0)
URL_FAILED()
SET_HAVE_HOST()
- if (ParseHost(&buffer, &url.host) < 0)
+ if (!ParseHost(&buffer, &url.host))
URL_FAILED()
buffer.clear();
state = kPathStart;
@@ -1161,7 +1161,7 @@ namespace url {
} else {
if (buffer != "localhost") {
SET_HAVE_HOST()
- if (ParseHost(&buffer, &url.host) < 0)
+ if (!ParseHost(&buffer, &url.host))
URL_FAILED()
}
buffer.clear();