aboutsummaryrefslogtreecommitdiff
path: root/external/rapidjson/internal/itoa.h
diff options
context:
space:
mode:
Diffstat (limited to 'external/rapidjson/internal/itoa.h')
-rw-r--r--external/rapidjson/internal/itoa.h42
1 files changed, 20 insertions, 22 deletions
diff --git a/external/rapidjson/internal/itoa.h b/external/rapidjson/internal/itoa.h
index 425e9830c..01a4e7e72 100644
--- a/external/rapidjson/internal/itoa.h
+++ b/external/rapidjson/internal/itoa.h
@@ -1,27 +1,23 @@
-// Copyright (C) 2011 Milo Yip
+// Tencent is pleased to support the open source community by making RapidJSON available.
+//
+// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
+// Licensed under the MIT License (the "License"); you may not use this file except
+// in compliance with the License. You may obtain a copy of the License at
//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
+// http://opensource.org/licenses/MIT
//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
+// Unless required by applicable law or agreed to in writing, software distributed
+// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+// CONDITIONS OF ANY KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations under the License.
#ifndef RAPIDJSON_ITOA_
#define RAPIDJSON_ITOA_
-namespace rapidjson {
+#include "../rapidjson.h"
+
+RAPIDJSON_NAMESPACE_BEGIN
namespace internal {
inline const char* GetDigitsLut() {
@@ -115,12 +111,13 @@ inline char* u32toa(uint32_t value, char* buffer) {
}
inline char* i32toa(int32_t value, char* buffer) {
+ uint32_t u = static_cast<uint32_t>(value);
if (value < 0) {
*buffer++ = '-';
- value = -value;
+ u = ~u + 1;
}
- return u32toa(static_cast<uint32_t>(value), buffer);
+ return u32toa(u, buffer);
}
inline char* u64toa(uint64_t value, char* buffer) {
@@ -292,15 +289,16 @@ inline char* u64toa(uint64_t value, char* buffer) {
}
inline char* i64toa(int64_t value, char* buffer) {
+ uint64_t u = static_cast<uint64_t>(value);
if (value < 0) {
*buffer++ = '-';
- value = -value;
+ u = ~u + 1;
}
- return u64toa(static_cast<uint64_t>(value), buffer);
+ return u64toa(u, buffer);
}
} // namespace internal
-} // namespace rapidjson
+RAPIDJSON_NAMESPACE_END
#endif // RAPIDJSON_ITOA_