Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libc/src/__support/str_to_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ LIBC_INLINE StrToNumResult<T> strtofloatingpoint(const char *__restrict src) {

int error = 0;

size_t index = static_cast<size_t>(first_non_whitespace(src) - src);
size_t index = first_non_whitespace(src);

if (src[index] == '+' || src[index] == '-') {
sign = src[index];
Expand Down
9 changes: 4 additions & 5 deletions libc/src/__support/str_to_integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@
namespace LIBC_NAMESPACE_DECL {
namespace internal {

// Returns a pointer to the first character in src that is not a whitespace
// Returns the idx to the first character in src that is not a whitespace
// character (as determined by isspace())
// TODO: Change from returning a pointer to returning a length.
LIBC_INLINE const char *
LIBC_INLINE size_t
first_non_whitespace(const char *__restrict src,
size_t src_len = cpp::numeric_limits<size_t>::max()) {
size_t src_cur = 0;
while (src_cur < src_len && internal::isspace(src[src_cur])) {
++src_cur;
}
return src + src_cur;
return src_cur;
}

// checks if the next 3 characters of the string pointer are the start of a
Expand Down Expand Up @@ -96,7 +95,7 @@ strtointeger(const char *__restrict src, int base,
if (base < 0 || base == 1 || base > 36)
return {0, 0, EINVAL};

src_cur = static_cast<size_t>(first_non_whitespace(src, src_len) - src);
src_cur = first_non_whitespace(src, src_len);

char result_sign = '+';
if (src[src_cur] == '+' || src[src_cur] == '-') {
Expand Down
Loading