Fix code style issue
This commit is contained in:
parent
d9f143d7d3
commit
9d08aa82ca
@ -17,19 +17,20 @@
|
||||
|
||||
#include "helper_stream.h"
|
||||
|
||||
void gmio_stringstream_init(struct gmio_stringstream *it)
|
||||
void gmio_stringstream_init(struct gmio_stringstream *sstream)
|
||||
{
|
||||
/* Trick: declaring the buffer exhausted will actually trigger the first
|
||||
* call to gmio_stream_read() inside gmio_next_char()
|
||||
*/
|
||||
it->strbuff.len = 0;
|
||||
it->strbuff_end = it->strbuff.ptr;
|
||||
it->strbuff_at = it->strbuff_end;
|
||||
gmio_stringstream_next_char(it);
|
||||
sstream->strbuff.len = 0;
|
||||
sstream->strbuff_end = sstream->strbuff.ptr;
|
||||
sstream->strbuff_at = sstream->strbuff_end;
|
||||
gmio_stringstream_next_char(sstream);
|
||||
}
|
||||
|
||||
enum gmio_eat_word_error gmio_stringstream_eat_word(
|
||||
struct gmio_stringstream *it, struct gmio_string *str)
|
||||
struct gmio_stringstream *sstream,
|
||||
struct gmio_string *str)
|
||||
{
|
||||
char* str_ptr_at = str->ptr + str->len;
|
||||
const char* str_ptr_end = str->ptr + str->max_len;
|
||||
@ -37,7 +38,7 @@ enum gmio_eat_word_error gmio_stringstream_eat_word(
|
||||
|
||||
/* assert(str != NULL && str->ptr != NULL); */
|
||||
|
||||
stream_curr_char = gmio_stringstream_skip_ascii_spaces(it);
|
||||
stream_curr_char = gmio_stringstream_skip_ascii_spaces(sstream);
|
||||
if (stream_curr_char == NULL) { /* Empty word */
|
||||
*str_ptr_at = 0;
|
||||
return GMIO_EAT_WORD_ERROR_EMPTY;
|
||||
@ -45,7 +46,7 @@ enum gmio_eat_word_error gmio_stringstream_eat_word(
|
||||
|
||||
do {
|
||||
*str_ptr_at = *stream_curr_char;
|
||||
stream_curr_char = gmio_stringstream_next_char(it);
|
||||
stream_curr_char = gmio_stringstream_next_char(sstream);
|
||||
++str_ptr_at;
|
||||
} while (stream_curr_char != NULL
|
||||
&& !gmio_ascii_isspace(*stream_curr_char)
|
||||
@ -61,14 +62,14 @@ enum gmio_eat_word_error gmio_stringstream_eat_word(
|
||||
|
||||
#if 0
|
||||
gmio_bool_t gmio_stringstream_checked_next_chars(
|
||||
struct gmio_stringstream *it, const char *str)
|
||||
struct gmio_stringstream *sstream, const char *str)
|
||||
{
|
||||
size_t pos = 0;
|
||||
const char* curr_char = gmio_stringstream_current_char(it);
|
||||
const char* curr_char = gmio_stringstream_current_char(sstream);
|
||||
gmio_bool_t same = curr_char != NULL && *curr_char == *str;
|
||||
|
||||
while (same) {
|
||||
curr_char = gmio_stringstream_next_char(it);
|
||||
curr_char = gmio_stringstream_next_char(sstream);
|
||||
same = curr_char != NULL && *curr_char == str[++pos];
|
||||
}
|
||||
|
||||
|
@ -39,28 +39,28 @@ struct gmio_stringstream
|
||||
};
|
||||
|
||||
/*! Initializes iterator */
|
||||
void gmio_stringstream_init(struct gmio_stringstream* it);
|
||||
void gmio_stringstream_init(struct gmio_stringstream* sstream);
|
||||
|
||||
/*! Returns the char where the iterator is currently pointing at */
|
||||
GMIO_INLINE const char* gmio_stringstream_current_char(
|
||||
const struct gmio_stringstream* it);
|
||||
const struct gmio_stringstream* sstream);
|
||||
|
||||
/*! Moves on next char in stream */
|
||||
GMIO_INLINE const char* gmio_stringstream_next_char(
|
||||
struct gmio_stringstream *it);
|
||||
struct gmio_stringstream* sstream);
|
||||
|
||||
/*! Moves on next char in stream */
|
||||
GMIO_INLINE struct gmio_stringstream* gmio_stringstream_move_next_char(
|
||||
struct gmio_stringstream *it);
|
||||
struct gmio_stringstream* sstream);
|
||||
|
||||
/*! Advances iterator until the first non-space char */
|
||||
GMIO_INLINE const char* gmio_stringstream_skip_ascii_spaces(
|
||||
struct gmio_stringstream* it);
|
||||
struct gmio_stringstream* sstream);
|
||||
|
||||
/*! Advances iterator until the first non-space char and copies in \p str any
|
||||
* space found */
|
||||
GMIO_INLINE void gmio_stringstream_copy_ascii_spaces(
|
||||
struct gmio_stringstream* it, struct gmio_string* str);
|
||||
struct gmio_stringstream* sstream, struct gmio_string* str);
|
||||
|
||||
/*! Error codes returned by gmio_eat_word() */
|
||||
enum gmio_eat_word_error
|
||||
@ -72,7 +72,7 @@ enum gmio_eat_word_error
|
||||
|
||||
/*! Advances iterator so that next word is extracted into \p str */
|
||||
enum gmio_eat_word_error gmio_stringstream_eat_word(
|
||||
struct gmio_stringstream* it, struct gmio_string* str);
|
||||
struct gmio_stringstream* sstream, struct gmio_string* str);
|
||||
|
||||
#if 0
|
||||
/*! Iterate over stream while it matches input string \p str
|
||||
@ -80,12 +80,12 @@ enum gmio_eat_word_error gmio_stringstream_eat_word(
|
||||
* Returns GMIO_TRUE if \p str was fully matched
|
||||
*/
|
||||
gmio_bool_t gmio_stringstream_checked_next_chars(
|
||||
struct gmio_stringstream* it, const char* str);
|
||||
struct gmio_stringstream* sstream, const char* str);
|
||||
#endif
|
||||
|
||||
/*! Parses float from string iterator \p it */
|
||||
/*! Parses float from stringstream \p sstream */
|
||||
GMIO_INLINE gmio_float32_t gmio_stringstream_parse_float32(
|
||||
struct gmio_stringstream* it);
|
||||
struct gmio_stringstream* sstream);
|
||||
|
||||
/*! Converts C string \p str to float
|
||||
*
|
||||
@ -118,57 +118,59 @@ GMIO_INLINE gmio_float32_t gmio_to_float32(const char* str);
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
const char* gmio_stringstream_current_char(const struct gmio_stringstream* it)
|
||||
const char* gmio_stringstream_current_char(
|
||||
const struct gmio_stringstream* sstream)
|
||||
{
|
||||
return it->strbuff_at < it->strbuff_end ?
|
||||
it->strbuff_at :
|
||||
return sstream->strbuff_at < sstream->strbuff_end ?
|
||||
sstream->strbuff_at :
|
||||
NULL;
|
||||
}
|
||||
|
||||
const char *gmio_stringstream_next_char(struct gmio_stringstream *it)
|
||||
const char *gmio_stringstream_next_char(struct gmio_stringstream *sstream)
|
||||
{
|
||||
++(it->strbuff_at);
|
||||
if (it->strbuff_at < it->strbuff_end)
|
||||
return it->strbuff_at;
|
||||
++(sstream->strbuff_at);
|
||||
if (sstream->strbuff_at < sstream->strbuff_end)
|
||||
return sstream->strbuff_at;
|
||||
|
||||
/* Read next chunk of data */
|
||||
it->strbuff_at = it->strbuff.ptr;
|
||||
it->strbuff.len =
|
||||
sstream->strbuff_at = sstream->strbuff.ptr;
|
||||
sstream->strbuff.len =
|
||||
gmio_stream_read(
|
||||
&it->stream, it->strbuff.ptr, 1, it->strbuff.max_len);
|
||||
it->strbuff_end = it->strbuff.ptr + it->strbuff.len;
|
||||
if (it->strbuff.len > 0) {
|
||||
if (it->func_stream_read_hook != NULL)
|
||||
it->func_stream_read_hook(it->cookie, &it->strbuff);
|
||||
return it->strbuff.ptr;
|
||||
&sstream->stream, sstream->strbuff.ptr, 1, sstream->strbuff.max_len);
|
||||
sstream->strbuff_end = sstream->strbuff.ptr + sstream->strbuff.len;
|
||||
if (sstream->strbuff.len > 0) {
|
||||
if (sstream->func_stream_read_hook != NULL)
|
||||
sstream->func_stream_read_hook(sstream->cookie, &sstream->strbuff);
|
||||
return sstream->strbuff.ptr;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct gmio_stringstream* gmio_stringstream_move_next_char(struct gmio_stringstream *it)
|
||||
struct gmio_stringstream* gmio_stringstream_move_next_char(
|
||||
struct gmio_stringstream *sstream)
|
||||
{
|
||||
gmio_stringstream_next_char(it);
|
||||
return it;
|
||||
gmio_stringstream_next_char(sstream);
|
||||
return sstream;
|
||||
}
|
||||
|
||||
const char* gmio_stringstream_skip_ascii_spaces(struct gmio_stringstream* it)
|
||||
const char* gmio_stringstream_skip_ascii_spaces(struct gmio_stringstream* sstream)
|
||||
{
|
||||
const char* curr_char = gmio_stringstream_current_char(it);
|
||||
const char* curr_char = gmio_stringstream_current_char(sstream);
|
||||
while (curr_char != NULL && gmio_ascii_isspace(*curr_char))
|
||||
curr_char = gmio_stringstream_next_char(it);
|
||||
curr_char = gmio_stringstream_next_char(sstream);
|
||||
return curr_char;
|
||||
}
|
||||
|
||||
void gmio_stringstream_copy_ascii_spaces(
|
||||
struct gmio_stringstream* it, struct gmio_string* str)
|
||||
struct gmio_stringstream* sstream, struct gmio_string* str)
|
||||
{
|
||||
const char* curr_char = gmio_stringstream_current_char(it);
|
||||
const char* curr_char = gmio_stringstream_current_char(sstream);
|
||||
while (curr_char != NULL
|
||||
&& gmio_ascii_isspace(*curr_char)
|
||||
&& str->len < str->max_len)
|
||||
{
|
||||
str->ptr[str->len] = *curr_char;
|
||||
curr_char = gmio_stringstream_next_char(it);
|
||||
curr_char = gmio_stringstream_next_char(sstream);
|
||||
++str->len;
|
||||
}
|
||||
}
|
||||
@ -199,14 +201,14 @@ gmio_float32_t gmio_to_float32(const char* str)
|
||||
#endif
|
||||
}
|
||||
|
||||
gmio_float32_t gmio_stringstream_parse_float32(struct gmio_stringstream* it)
|
||||
gmio_float32_t gmio_stringstream_parse_float32(struct gmio_stringstream* sstream)
|
||||
{
|
||||
#if defined(GMIO_STRINGSTREAM_USE_FAST_ATOF)
|
||||
return gmio_stringstream_fast_atof(it);
|
||||
return gmio_stringstream_fast_atof(sstream);
|
||||
#else
|
||||
char strbuff_ptr[64];
|
||||
struct gmio_string strbuff = { &strbuff_ptr[0], 0, sizeof(strbuff_ptr) };
|
||||
gmio_stringstream_eat_word(it, &strbuff);
|
||||
gmio_stringstream_eat_word(sstream, &strbuff);
|
||||
return (gmio_float32_t)atof(strbuff_ptr);
|
||||
#endif
|
||||
}
|
||||
|
@ -12,28 +12,30 @@
|
||||
#include "fast_atof.h"
|
||||
#include "stringstream.h"
|
||||
|
||||
GMIO_INLINE uint32_t gmio_stringstream_strtoul10(struct gmio_stringstream* it)
|
||||
GMIO_INLINE uint32_t gmio_stringstream_strtoul10(
|
||||
struct gmio_stringstream* sstream)
|
||||
{
|
||||
unsigned int value = 0;
|
||||
const char* in = gmio_stringstream_current_char(it);
|
||||
const char* in = gmio_stringstream_current_char(sstream);
|
||||
for (;
|
||||
in != NULL && gmio_ascii_isdigit(*in);
|
||||
in = gmio_stringstream_next_char(it))
|
||||
in = gmio_stringstream_next_char(sstream))
|
||||
{
|
||||
value = (value * 10) + (*in - '0');
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
GMIO_INLINE int32_t gmio_stringstream_strtol10(struct gmio_stringstream* it)
|
||||
GMIO_INLINE int32_t gmio_stringstream_strtol10(
|
||||
struct gmio_stringstream* sstream)
|
||||
{
|
||||
const char* in = gmio_stringstream_current_char(it);
|
||||
const char* in = gmio_stringstream_current_char(sstream);
|
||||
const gmio_bool_t inv = (*in == '-');
|
||||
int value = 0;
|
||||
if (inv || *in == '+')
|
||||
in = gmio_stringstream_next_char(it);
|
||||
in = gmio_stringstream_next_char(sstream);
|
||||
|
||||
value = gmio_stringstream_strtoul10(it);
|
||||
value = gmio_stringstream_strtoul10(sstream);
|
||||
if (inv)
|
||||
value = -value;
|
||||
return value;
|
||||
@ -46,9 +48,9 @@ struct gmio_stringstream_strtof10_result
|
||||
};
|
||||
|
||||
GMIO_INLINE struct gmio_stringstream_strtof10_result
|
||||
gmio_stringstream_strtof10(struct gmio_stringstream* it)
|
||||
gmio_stringstream_strtof10(struct gmio_stringstream* sstream)
|
||||
{
|
||||
const char* in = gmio_stringstream_current_char(it);
|
||||
const char* in = gmio_stringstream_current_char(sstream);
|
||||
const uint32_t MAX_SAFE_U32_VALUE = UINT_MAX / 10 - 10;
|
||||
uint32_t int_val = 0;
|
||||
float float_val = 0.f;
|
||||
@ -59,7 +61,7 @@ GMIO_INLINE struct gmio_stringstream_strtof10_result
|
||||
* precision */
|
||||
for (;
|
||||
in != NULL && gmio_ascii_isdigit(*in) && int_val < MAX_SAFE_U32_VALUE;
|
||||
in = gmio_stringstream_next_char(it))
|
||||
in = gmio_stringstream_next_char(sstream))
|
||||
{
|
||||
int_val = (int_val * 10) + (*in - '0');
|
||||
++char_diff;
|
||||
@ -69,7 +71,7 @@ GMIO_INLINE struct gmio_stringstream_strtof10_result
|
||||
* arithmetic from here */
|
||||
for (;
|
||||
in != NULL && gmio_ascii_isdigit(*in) && float_val <= FLT_MAX;
|
||||
in = gmio_stringstream_next_char(it))
|
||||
in = gmio_stringstream_next_char(sstream))
|
||||
{
|
||||
float_val = (float_val * 10) + (*in - '0');
|
||||
++char_diff;
|
||||
@ -79,35 +81,35 @@ GMIO_INLINE struct gmio_stringstream_strtof10_result
|
||||
return result;
|
||||
}
|
||||
|
||||
GMIO_INLINE float gmio_stringstream_fast_atof(struct gmio_stringstream* it)
|
||||
GMIO_INLINE float gmio_stringstream_fast_atof(struct gmio_stringstream* sstream)
|
||||
{
|
||||
const char* in = gmio_stringstream_current_char(it);
|
||||
const char* in = gmio_stringstream_current_char(sstream);
|
||||
const gmio_bool_t negative = ('-' == *in);
|
||||
float value = 0.f;
|
||||
|
||||
/* Please run the regression test when making any modifications to this
|
||||
* function. */
|
||||
if (negative || ('+' == *in))
|
||||
in = gmio_stringstream_next_char(it);
|
||||
value = gmio_stringstream_strtof10(it).val;
|
||||
in = gmio_stringstream_current_char(it);
|
||||
in = gmio_stringstream_next_char(sstream);
|
||||
value = gmio_stringstream_strtof10(sstream).val;
|
||||
in = gmio_stringstream_current_char(sstream);
|
||||
if (is_local_decimal_point(*in)) {
|
||||
const struct gmio_stringstream_strtof10_result decimal =
|
||||
gmio_stringstream_strtof10(
|
||||
gmio_stringstream_move_next_char(it));
|
||||
gmio_stringstream_move_next_char(sstream));
|
||||
value += decimal.val * fast_atof_table[decimal.char_diff];
|
||||
in = gmio_stringstream_current_char(it);
|
||||
in = gmio_stringstream_current_char(sstream);
|
||||
}
|
||||
if (in != NULL && ('e' == *in || 'E' == *in)) {
|
||||
in = gmio_stringstream_next_char(it);
|
||||
in = gmio_stringstream_next_char(sstream);
|
||||
/* Assume that the exponent is a whole number.
|
||||
* strtol10() will deal with both + and - signs,
|
||||
* but calculate as float to prevent overflow at FLT_MAX */
|
||||
value *=
|
||||
#ifdef GMIO_HAVE_POWF_FUNC
|
||||
powf(10.f, (float)gmio_stringstream_strtol10(it));
|
||||
powf(10.f, (float)gmio_stringstream_strtol10(sstream));
|
||||
#else
|
||||
(float)pow(10., (double)gmio_stringstream_strtol10(it));
|
||||
(float)pow(10., (double)gmio_stringstream_strtol10(sstream));
|
||||
#endif
|
||||
}
|
||||
return negative ? -value : value;
|
||||
|
@ -117,8 +117,8 @@ struct gmio_stla_parse_data
|
||||
{
|
||||
enum gmio_stla_token token;
|
||||
gmio_bool_t error;
|
||||
struct gmio_stringstream stream_iterator;
|
||||
struct gmio_stringstream_stla_cookie stream_iterator_cookie;
|
||||
struct gmio_stringstream strstream;
|
||||
struct gmio_stringstream_stla_cookie strstream_cookie;
|
||||
struct gmio_string string_buffer;
|
||||
struct gmio_stl_mesh_creator* creator;
|
||||
};
|
||||
@ -161,19 +161,19 @@ int gmio_stla_read(
|
||||
parse_data.token = unknown_token;
|
||||
parse_data.error = GMIO_FALSE;
|
||||
|
||||
parse_data.stream_iterator_cookie.rwargs = args;
|
||||
parse_data.stream_iterator_cookie.stream_offset = 0;
|
||||
parse_data.stream_iterator_cookie.stream_size =
|
||||
parse_data.strstream_cookie.rwargs = args;
|
||||
parse_data.strstream_cookie.stream_offset = 0;
|
||||
parse_data.strstream_cookie.stream_size =
|
||||
gmio_stream_size(&args->stream);
|
||||
parse_data.stream_iterator_cookie.is_stop_requested = GMIO_FALSE;
|
||||
parse_data.strstream_cookie.is_stop_requested = GMIO_FALSE;
|
||||
|
||||
parse_data.stream_iterator.stream = args->stream;
|
||||
parse_data.stream_iterator.strbuff.ptr = args->memblock.ptr;
|
||||
parse_data.stream_iterator.strbuff.max_len = args->memblock.size;
|
||||
parse_data.stream_iterator.cookie = &parse_data.stream_iterator_cookie;
|
||||
parse_data.stream_iterator.func_stream_read_hook =
|
||||
parse_data.strstream.stream = args->stream;
|
||||
parse_data.strstream.strbuff.ptr = args->memblock.ptr;
|
||||
parse_data.strstream.strbuff.max_len = args->memblock.size;
|
||||
parse_data.strstream.cookie = &parse_data.strstream_cookie;
|
||||
parse_data.strstream.func_stream_read_hook =
|
||||
gmio_stringstream_stla_read_hook;
|
||||
gmio_stringstream_init(&parse_data.stream_iterator);
|
||||
gmio_stringstream_init(&parse_data.strstream);
|
||||
|
||||
parse_data.string_buffer.ptr = &fixed_buffer[0];
|
||||
parse_data.string_buffer.len = 0;
|
||||
@ -185,7 +185,7 @@ int gmio_stla_read(
|
||||
|
||||
if (parse_data.error)
|
||||
return GMIO_STL_ERROR_PARSING;
|
||||
if (parse_data.stream_iterator_cookie.is_stop_requested)
|
||||
if (parse_data.strstream_cookie.is_stop_requested)
|
||||
return GMIO_ERROR_TRANSFER_STOPPED;
|
||||
return GMIO_ERROR_OK;
|
||||
}
|
||||
@ -461,7 +461,7 @@ int stla_eat_next_token(
|
||||
enum gmio_eat_word_error eat_error;
|
||||
|
||||
strbuff->len = 0;
|
||||
eat_error = gmio_stringstream_eat_word(&data->stream_iterator, strbuff);
|
||||
eat_error = gmio_stringstream_eat_word(&data->strstream, strbuff);
|
||||
if (eat_error == GMIO_EAT_WORD_ERROR_OK) {
|
||||
const char* expected_token_str = stla_token_to_string(expected_token);
|
||||
if (gmio_ascii_stricmp(strbuff->ptr, expected_token_str) == 0) {
|
||||
@ -484,13 +484,13 @@ int stla_eat_next_token_inplace(
|
||||
struct gmio_stla_parse_data* data,
|
||||
enum gmio_stla_token expected_token)
|
||||
{
|
||||
struct gmio_stringstream* it = &data->stream_iterator;
|
||||
struct gmio_stringstream* sstream = &data->strstream;
|
||||
const char* stream_char = NULL;
|
||||
const char* expected_token_str = stla_token_to_string(expected_token);
|
||||
gmio_bool_t error = GMIO_FALSE;
|
||||
|
||||
data->token = unknown_token;
|
||||
stream_char = gmio_stringstream_skip_ascii_spaces(it);
|
||||
stream_char = gmio_stringstream_skip_ascii_spaces(sstream);
|
||||
while (!error) {
|
||||
if (stream_char == NULL || gmio_ascii_isspace(*stream_char)) {
|
||||
if (*expected_token_str == 0) {
|
||||
@ -504,7 +504,7 @@ int stla_eat_next_token_inplace(
|
||||
{
|
||||
error = GMIO_TRUE;
|
||||
}
|
||||
stream_char = gmio_stringstream_next_char(it);
|
||||
stream_char = gmio_stringstream_next_char(sstream);
|
||||
++expected_token_str;
|
||||
}
|
||||
|
||||
@ -519,7 +519,7 @@ int stla_eat_until_token(
|
||||
struct gmio_stla_parse_data* data, const enum gmio_stla_token* end_tokens)
|
||||
{
|
||||
if (!stla_token_match_candidate(data->token, end_tokens)) {
|
||||
struct gmio_stringstream* stream_it = &data->stream_iterator;
|
||||
struct gmio_stringstream* sstream = &data->strstream;
|
||||
struct gmio_string* strbuff = &data->string_buffer;
|
||||
gmio_bool_t end_token_found = GMIO_FALSE;
|
||||
|
||||
@ -529,10 +529,10 @@ int stla_eat_until_token(
|
||||
const char* next_word = NULL; /* Pointer on next word string */
|
||||
size_t next_word_len = 0; /* Length of next word string */
|
||||
|
||||
gmio_stringstream_copy_ascii_spaces(stream_it, strbuff);
|
||||
gmio_stringstream_copy_ascii_spaces(sstream, strbuff);
|
||||
/* Next word */
|
||||
next_word = strbuff->ptr + strbuff->len;
|
||||
eat_word_err = gmio_stringstream_eat_word(stream_it, strbuff);
|
||||
eat_word_err = gmio_stringstream_eat_word(sstream, strbuff);
|
||||
next_word_len = (strbuff->ptr + strbuff->len) - next_word;
|
||||
/* Qualify token */
|
||||
data->token =
|
||||
@ -560,7 +560,7 @@ int stla_eat_until_token(
|
||||
|
||||
gmio_bool_t stla_parsing_can_continue(const struct gmio_stla_parse_data* data)
|
||||
{
|
||||
return !data->error && !data->stream_iterator_cookie.is_stop_requested;
|
||||
return !data->error && !data->strstream_cookie.is_stop_requested;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
@ -598,7 +598,7 @@ int parse_beginsolid(struct gmio_stla_parse_data* data)
|
||||
if (parse_solidname_beg(data) == 0) {
|
||||
gmio_stl_mesh_creator_ascii_begin_solid(
|
||||
data->creator,
|
||||
data->stream_iterator_cookie.stream_size,
|
||||
data->strstream_cookie.stream_size,
|
||||
data->string_buffer.ptr);
|
||||
return 0;
|
||||
}
|
||||
@ -633,20 +633,20 @@ GMIO_INLINE int is_float_char(const char* str)
|
||||
int parse_xyz_coords(struct gmio_stla_parse_data* data, struct gmio_stl_coords* coords)
|
||||
{
|
||||
int errc = 0;
|
||||
struct gmio_stringstream* it = &data->stream_iterator;
|
||||
struct gmio_stringstream* sstream = &data->strstream;
|
||||
const char* strbuff = NULL;
|
||||
|
||||
strbuff = gmio_stringstream_skip_ascii_spaces(it);
|
||||
strbuff = gmio_stringstream_skip_ascii_spaces(sstream);
|
||||
errc += !is_float_char(strbuff);
|
||||
coords->x = gmio_stringstream_parse_float32(it);
|
||||
coords->x = gmio_stringstream_parse_float32(sstream);
|
||||
|
||||
strbuff = gmio_stringstream_skip_ascii_spaces(it);
|
||||
strbuff = gmio_stringstream_skip_ascii_spaces(sstream);
|
||||
errc += !is_float_char(strbuff);
|
||||
coords->y = gmio_stringstream_parse_float32(it);
|
||||
coords->y = gmio_stringstream_parse_float32(sstream);
|
||||
|
||||
strbuff = gmio_stringstream_skip_ascii_spaces(it);
|
||||
strbuff = gmio_stringstream_skip_ascii_spaces(sstream);
|
||||
errc += !is_float_char(strbuff);
|
||||
coords->z = gmio_stringstream_parse_float32(it);
|
||||
coords->z = gmio_stringstream_parse_float32(sstream);
|
||||
|
||||
data->string_buffer.len = 0;
|
||||
data->token = unknown_token;
|
||||
@ -654,7 +654,9 @@ int parse_xyz_coords(struct gmio_stla_parse_data* data, struct gmio_stl_coords*
|
||||
return errc;
|
||||
}
|
||||
|
||||
int parse_facet(struct gmio_stla_parse_data* data, struct gmio_stl_triangle* facet)
|
||||
int parse_facet(
|
||||
struct gmio_stla_parse_data* data,
|
||||
struct gmio_stl_triangle* facet)
|
||||
{
|
||||
int errc = 0;
|
||||
if (data->token != FACET_token)
|
||||
@ -696,7 +698,7 @@ void parse_facets(struct gmio_stla_parse_data* data)
|
||||
func_add_triangle(creator_cookie, i_facet, &facet);
|
||||
/* Eat next unknown token */
|
||||
strbuff->len = 0;
|
||||
gmio_stringstream_eat_word(&data->stream_iterator, strbuff);
|
||||
gmio_stringstream_eat_word(&data->strstream, strbuff);
|
||||
data->token = stla_find_token_from_string(strbuff);
|
||||
++i_facet;
|
||||
}
|
||||
|
@ -131,16 +131,16 @@ const char* test_internal__gmio_fast_atof()
|
||||
|
||||
{
|
||||
char strbuff[2048] = {0};
|
||||
struct gmio_stringstream it = {0};
|
||||
struct gmio_stringstream sstream = {0};
|
||||
gmio_ro_buffer_t streambuff = { fstr, sizeof(fstr) - 1, 0 };
|
||||
float f2;
|
||||
|
||||
it.stream = gmio_istream_buffer(&streambuff);
|
||||
it.strbuff.ptr = &strbuff[0];
|
||||
it.strbuff.max_len = sizeof(strbuff) - 1;
|
||||
gmio_stringstream_init(&it);
|
||||
sstream.stream = gmio_istream_buffer(&streambuff);
|
||||
sstream.strbuff.ptr = &strbuff[0];
|
||||
sstream.strbuff.max_len = sizeof(strbuff) - 1;
|
||||
gmio_stringstream_init(&sstream);
|
||||
|
||||
f2 = gmio_stringstream_fast_atof(&it);
|
||||
f2 = gmio_stringstream_fast_atof(&sstream);
|
||||
|
||||
UTEST_ASSERT(gmio_float32_equals_by_ulp(f1, f2, 1));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user