| 102 | } |
| 103 | |
| 104 | static bool breakup(const char *str, size_t slen, |
| 105 | /* Length of first numeric part. */ |
| 106 | size_t *whole_number_len, |
| 107 | /* Pointer to post-decimal part, or NULL */ |
| 108 | const char **post_decimal_ptr, |
| 109 | size_t *post_decimal_len, |
| 110 | /* Pointer to suffix, or NULL */ |
| 111 | const char **suffix_ptr, |
| 112 | size_t *suffix_len) |
| 113 | { |
| 114 | size_t i; |
| 115 | |
| 116 | *whole_number_len = 0; |
| 117 | *post_decimal_len = 0; |
| 118 | *post_decimal_ptr = NULL; |
| 119 | *suffix_ptr = NULL; |
| 120 | *suffix_len = 0; |
| 121 | |
| 122 | for (i = 0;; i++) { |
| 123 | /* The string may be null-terminated. */ |
| 124 | if (i >= slen || str[i] == '\0') |
| 125 | return i != 0; |
| 126 | if (cisdigit(str[i])) |
| 127 | (*whole_number_len)++; |
| 128 | else |
| 129 | break; |
| 130 | } |
| 131 | |
| 132 | if (str[i] == '.') { |
| 133 | i++; |
| 134 | *post_decimal_ptr = str + i; |
| 135 | for (;; i++) { |
| 136 | /* True if > 0 decimals. */ |
| 137 | if (i >= slen || str[i] == '\0') |
| 138 | return str + i != *post_decimal_ptr; |
| 139 | if (cisdigit(str[i])) |
| 140 | (*post_decimal_len)++; |
| 141 | else |
| 142 | break; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | *suffix_ptr = str + i; |
| 147 | *suffix_len = slen - i; |
| 148 | return true; |
| 149 | } |
| 150 | |
| 151 | static bool from_number(u64 *res, const char *s, size_t len, int tens_factor) |
| 152 | { |
no test coverage detected