Replace atoi32, strtoll, and strtoull.
BUG=
TEST=unittest
REF_BUG=19010851
REF_CL=84611844
Noriyuki Takahashi authored 8 years ago
Yohei Yukawa committed 8 years ago
41 | 41 | |
42 | 42 | #include "base/crash_report_handler.h" |
43 | 43 | #include "base/init.h" |
44 | #include "base/number_util.h" | |
44 | 45 | #include "base/singleton.h" |
45 | 46 | #include "base/system_util.h" |
46 | 47 | #include "base/util.h" |
48 | 49 | DEFINE_string(program_invocation_name, "", "Program name copied from argv[0]."); |
49 | 50 | |
50 | 51 | namespace mozc_flags { |
51 | ||
52 | 52 | namespace { |
53 | 53 | |
54 | 54 | typedef map<string, mozc_flags::Flag *> FlagMap; |
124 | 124 | |
125 | 125 | switch (flag->type) { |
126 | 126 | case I: |
127 | *(reinterpret_cast<int32 *>(flag->storage)) = atoi32(v.c_str()); | |
127 | mozc::NumberUtil::SafeStrToInt32( | |
128 | v, reinterpret_cast<int32 *>(flag->storage)); | |
128 | 129 | break; |
129 | 130 | case B: |
130 | 131 | *(reinterpret_cast<bool *>(flag->storage)) = IsTrue(v.c_str()); |
131 | 132 | break; |
132 | 133 | case I64: |
133 | *(reinterpret_cast<int64 *>(flag->storage)) = | |
134 | strtoll(v.c_str(), NULL, 10); | |
134 | mozc::NumberUtil::SafeStrToInt64( | |
135 | v, reinterpret_cast<int64 *>(flag->storage)); | |
135 | 136 | break; |
136 | 137 | case U64: |
137 | *(reinterpret_cast<uint64 *>(flag->storage)) = | |
138 | strtoull(v.c_str(), NULL, 10); | |
138 | mozc::NumberUtil::SafeStrToUInt64( | |
139 | v, reinterpret_cast<uint64 *>(flag->storage)); | |
139 | 140 | break; |
140 | 141 | case D: |
141 | 142 | *(reinterpret_cast<double *>(flag->storage)) = strtod(v.c_str(), NULL); |
267 | 267 | return converter.StartConversionForRequest(conversion_request, segments); |
268 | 268 | } else if (func == "convertwithnodeinfo" || func == "cn") { |
269 | 269 | CHECK_FIELDS_LENGTH(5); |
270 | Lattice::SetDebugDisplayNode(atoi32(fields[2].c_str()), // begin pos | |
271 | atoi32(fields[3].c_str()), // end pos | |
272 | fields[4]); | |
270 | Lattice::SetDebugDisplayNode( | |
271 | NumberUtil::SimpleAtoi(fields[2]), // begin pos | |
272 | NumberUtil::SimpleAtoi(fields[3]), // end pos | |
273 | fields[4]); | |
273 | 274 | const bool result = converter.StartConversion(segments, fields[1]); |
274 | 275 | Lattice::ResetDebugDisplayNode(); |
275 | 276 | return result; |
310 | 311 | } else if (func == "commitsegmentvalue" || func == "commit" || func == "c") { |
311 | 312 | CHECK_FIELDS_LENGTH(3); |
312 | 313 | return converter.CommitSegmentValue(segments, |
313 | atoi32(fields[1].c_str()), | |
314 | atoi32(fields[2].c_str())); | |
314 | NumberUtil::SimpleAtoi(fields[1]), | |
315 | NumberUtil::SimpleAtoi(fields[2])); | |
315 | 316 | } else if (func == "commitallandfinish") { |
316 | 317 | for (int i = 0; i < segments->conversion_segments_size(); ++i) { |
317 | 318 | if (segments->conversion_segment(i).segment_type() != |
326 | 327 | } else if (func == "focussegmentvalue" || func == "focus") { |
327 | 328 | CHECK_FIELDS_LENGTH(3); |
328 | 329 | return converter.FocusSegmentValue(segments, |
329 | atoi32(fields[1].c_str()), | |
330 | atoi32(fields[2].c_str())); | |
330 | NumberUtil::SimpleAtoi(fields[1]), | |
331 | NumberUtil::SimpleAtoi(fields[2])); | |
331 | 332 | } else if (func == "commitfirstsegment") { |
332 | 333 | CHECK_FIELDS_LENGTH(2); |
333 | 334 | vector<size_t> singleton_vector; |
334 | singleton_vector.push_back(static_cast<size_t>(atoi32(fields[1].c_str()))); | |
335 | singleton_vector.push_back(NumberUtil::SimpleAtoi(fields[1])); | |
335 | 336 | return converter.CommitSegments(segments, singleton_vector); |
336 | 337 | } else if (func == "freesegmentvalue" || func == "free") { |
337 | 338 | CHECK_FIELDS_LENGTH(2); |
338 | 339 | return converter.FreeSegmentValue(segments, |
339 | atoi32(fields[1].c_str())); | |
340 | NumberUtil::SimpleAtoi(fields[1])); | |
340 | 341 | } else if (func == "resizesegment" || func == "resize") { |
341 | 342 | const ConversionRequest request; |
342 | 343 | if (fields.size() == 3) { |
343 | 344 | return converter.ResizeSegment(segments, |
344 | 345 | request, |
345 | atoi32(fields[1].c_str()), | |
346 | atoi32(fields[2].c_str())); | |
346 | NumberUtil::SimpleAtoi(fields[1]), | |
347 | NumberUtil::SimpleAtoi(fields[2])); | |
347 | 348 | } else if (fields.size() > 3) { |
348 | 349 | vector<uint8> new_arrays; |
349 | 350 | for (size_t i = 3; i < fields.size(); ++i) { |
350 | new_arrays.push_back(static_cast<uint8>(atoi32(fields[i].c_str()))); | |
351 | new_arrays.push_back( | |
352 | static_cast<uint8>(NumberUtil::SimpleAtoi(fields[i]))); | |
351 | 353 | } |
352 | 354 | return converter.ResizeSegment(segments, |
353 | 355 | request, |
354 | atoi32(fields[1].c_str()), // start | |
355 | atoi32(fields[2].c_str()), | |
356 | NumberUtil::SimpleAtoi(fields[1]), | |
357 | NumberUtil::SimpleAtoi(fields[2]), | |
356 | 358 | &new_arrays[0], |
357 | 359 | new_arrays.size()); |
358 | 360 | } |
0 | 0 | MAJOR=2 |
1 | 1 | MINOR=17 |
2 | BUILD=2131 | |
2 | BUILD=2132 | |
3 | 3 | REVISION=102 |
4 | 4 | # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be |
5 | 5 | # downloaded by NaCl Mozc. |
34 | 34 | #include <vector> |
35 | 35 | |
36 | 36 | #include "base/logging.h" |
37 | #include "base/number_util.h" | |
37 | 38 | #include "base/port.h" |
38 | 39 | #include "base/util.h" |
39 | 40 | |
96 | 97 | ++begin; |
97 | 98 | } |
98 | 99 | |
99 | *output = atoi32(str.c_str()); | |
100 | *output = NumberUtil::SimpleAtoi(str); | |
100 | 101 | |
101 | 102 | return true; |
102 | 103 | } |
1741 | 1741 | if (!NumberUtil::IsArabicNumber(era_year_str)) { |
1742 | 1742 | return false; |
1743 | 1743 | } |
1744 | *year = atoi32(era_year_str.c_str()); | |
1744 | *year = NumberUtil::SimpleAtoi(era_year_str); | |
1745 | 1745 | if (*year <= 0) { |
1746 | 1746 | return false; |
1747 | 1747 | } |
2249 | 2249 | string year_str; |
2250 | 2250 | Util::FullWidthAsciiToHalfWidthAscii(current_key, &year_str); |
2251 | 2251 | |
2252 | const uint32 year = atoi32(year_str.c_str()); | |
2252 | uint32 year = 0; | |
2253 | if (!NumberUtil::SafeStrToUInt32(year_str, &year)) { | |
2254 | return false; | |
2255 | } | |
2253 | 2256 | |
2254 | 2257 | vector<string> results; |
2255 | 2258 | if (!AdToEra(year, &results)) { |
2376 | 2379 | string number_str; |
2377 | 2380 | Util::FullWidthAsciiToHalfWidthAscii(key, &number_str); |
2378 | 2381 | |
2379 | const uint32 number = atoi32(number_str.c_str()); | |
2382 | uint32 number = 0; | |
2383 | if (!NumberUtil::SafeStrToUInt32(number_str, &number)) { | |
2384 | return false; | |
2385 | } | |
2380 | 2386 | const uint32 upper_number = number / 100; |
2381 | 2387 | const uint32 lower_number = number % 100; |
2382 | 2388 |
34 | 34 | |
35 | 35 | #include "base/file_stream.h" |
36 | 36 | #include "base/logging.h" |
37 | #include "base/number_util.h" | |
37 | 38 | #include "base/util.h" |
38 | 39 | #include "rewriter/embedded_dictionary.h" |
39 | 40 | |
40 | 41 | namespace mozc { |
41 | ||
42 | 42 | namespace { |
43 | 43 | |
44 | 44 | struct CompilerToken { |
63 | 63 | return (t1.cost < t2.cost); |
64 | 64 | } |
65 | 65 | }; |
66 | ||
66 | 67 | } // namespace |
67 | 68 | |
68 | 69 | EmbeddedDictionary::EmbeddedDictionary(const EmbeddedDictionary::Token *token, |
114 | 115 | CompilerToken token; |
115 | 116 | const string &key = fields[0]; |
116 | 117 | token.value = fields[4]; |
117 | token.lid = atoi32(fields[1].c_str()); | |
118 | token.rid = atoi32(fields[2].c_str()); | |
119 | token.cost = atoi32(fields[3].c_str()); | |
118 | CHECK(NumberUtil::SafeStrToUInt16(fields[1], &token.lid)); | |
119 | CHECK(NumberUtil::SafeStrToUInt16(fields[2], &token.rid)); | |
120 | CHECK(NumberUtil::SafeStrToInt16(fields[3], &token.cost)); | |
120 | 121 | token.description = (fields.size() > 5) ? fields[5] : ""; |
121 | 122 | token.additional_description = (fields.size() > 6) ? fields[6] : ""; |
122 | 123 | dic[key].push_back(token); |