[ruby/prism] Remove ssize_t usage
https://github.com/ruby/prism/commit/64c4f1268b
This commit is contained in:
parent
572e791567
commit
4dd9602c6f
@ -460,9 +460,9 @@ pm_static_literal_inspect(pm_buffer_t *buffer, const pm_parser_t *parser, const
|
|||||||
// %g will not insert a .0 for 1e100 (we'll get back 1e+100). So
|
// %g will not insert a .0 for 1e100 (we'll get back 1e+100). So
|
||||||
// we check for the decimal point and add it in here if it's not
|
// we check for the decimal point and add it in here if it's not
|
||||||
// present.
|
// present.
|
||||||
if (pm_buffer_index(buffer, '.') == -1) {
|
if (pm_buffer_index(buffer, '.') == SIZE_MAX) {
|
||||||
ssize_t exponent_index = pm_buffer_index(buffer, 'e');
|
size_t exponent_index = pm_buffer_index(buffer, 'e');
|
||||||
size_t index = exponent_index == -1 ? pm_buffer_length(buffer) : (size_t) exponent_index;
|
size_t index = exponent_index == SIZE_MAX ? pm_buffer_length(buffer) : exponent_index;
|
||||||
pm_buffer_insert(buffer, index, ".0", 2);
|
pm_buffer_insert(buffer, index, ".0", 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,15 +286,17 @@ pm_buffer_rstrip(pm_buffer_t *buffer) {
|
|||||||
/**
|
/**
|
||||||
* Checks if the buffer includes the given value.
|
* Checks if the buffer includes the given value.
|
||||||
*/
|
*/
|
||||||
ssize_t pm_buffer_index(const pm_buffer_t *buffer, char value) {
|
size_t
|
||||||
|
pm_buffer_index(const pm_buffer_t *buffer, char value) {
|
||||||
const char *first = memchr(buffer->value, value, buffer->length);
|
const char *first = memchr(buffer->value, value, buffer->length);
|
||||||
return (first == NULL) ? -1 : (ssize_t) (first - buffer->value);
|
return (first == NULL) ? SIZE_MAX : (size_t) (first - buffer->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert the given string into the buffer at the given index.
|
* Insert the given string into the buffer at the given index.
|
||||||
*/
|
*/
|
||||||
void pm_buffer_insert(pm_buffer_t *buffer, size_t index, const char *value, size_t length) {
|
void
|
||||||
|
pm_buffer_insert(pm_buffer_t *buffer, size_t index, const char *value, size_t length) {
|
||||||
assert(index <= buffer->length);
|
assert(index <= buffer->length);
|
||||||
|
|
||||||
if (index == buffer->length) {
|
if (index == buffer->length) {
|
||||||
|
@ -201,10 +201,10 @@ void pm_buffer_rstrip(pm_buffer_t *buffer);
|
|||||||
*
|
*
|
||||||
* @param buffer The buffer to check.
|
* @param buffer The buffer to check.
|
||||||
* @param value The value to check for.
|
* @param value The value to check for.
|
||||||
* @returns The index of the first occurrence of the value in the buffer, or -1
|
* @returns The index of the first occurrence of the value in the buffer, or
|
||||||
* if the value is not found.
|
* SIZE_MAX if the value is not found.
|
||||||
*/
|
*/
|
||||||
ssize_t pm_buffer_index(const pm_buffer_t *buffer, char value);
|
size_t pm_buffer_index(const pm_buffer_t *buffer, char value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert the given string into the buffer at the given index.
|
* Insert the given string into the buffer at the given index.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user