From 346298c7658f2ec8b105e5e53101637af232724f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marcin=20Baczy=C5=84ski?= Date: Sat, 13 Mar 2010 14:26:45 +0100 Subject: [PATCH] Replace _mesa_strtod with _mesa_strtof. Reviewed-by: Ian Romanick --- src/mesa/main/imports.c | 12 +++++++----- src/mesa/main/imports.h | 4 ++-- src/mesa/shader/lex.yy.c | 8 ++++---- src/mesa/shader/nvfragparse.c | 2 +- src/mesa/shader/program_lexer.l | 8 ++++---- src/mesa/shader/slang/slang_compile.c | 4 ++-- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 56e8195..1ae0853 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -795,18 +795,20 @@ _mesa_strdup( const char *s ) } } -/** Wrapper around strtod() */ -double -_mesa_strtod( const char *s, char **end ) +/** Wrapper around strtof() */ +float +_mesa_strtof( const char *s, char **end ) { #ifdef _GNU_SOURCE static locale_t loc = NULL; if (!loc) { loc = newlocale(LC_CTYPE_MASK, "C", NULL); } - return strtod_l(s, end, loc); + return strtof_l(s, end, loc); +#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) + return strtof(s, end); #else - return strtod(s, end); + return (float)strtod(s, end); #endif } diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index fb4a00e..d28f4ad 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -575,8 +575,8 @@ _mesa_getenv( const char *var ); extern char * _mesa_strdup( const char *s ); -extern double -_mesa_strtod( const char *s, char **end ); +extern float +_mesa_strtof( const char *s, char **end ); extern unsigned int _mesa_str_checksum(const char *str); diff --git a/src/mesa/shader/lex.yy.c b/src/mesa/shader/lex.yy.c index a08617f..4c5c644 100644 --- a/src/mesa/shader/lex.yy.c +++ b/src/mesa/shader/lex.yy.c @@ -2198,7 +2198,7 @@ case 142: YY_RULE_SETUP #line 326 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK @@ -2210,7 +2210,7 @@ YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP #line 330 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK @@ -2218,7 +2218,7 @@ case 144: YY_RULE_SETUP #line 334 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK @@ -2226,7 +2226,7 @@ case 145: YY_RULE_SETUP #line 338 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index d03cb4e..0de3c58 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -456,7 +456,7 @@ Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number) { char *end = NULL; - *number = (GLfloat) _mesa_strtod((const char *) parseState->pos, &end); + *number = (GLfloat) _mesa_strtof((const char *) parseState->pos, &end); if (end && end > (char *) parseState->pos) { /* got a number */ diff --git a/src/mesa/shader/program_lexer.l b/src/mesa/shader/program_lexer.l index b007657..fe18272 100644 --- a/src/mesa/shader/program_lexer.l +++ b/src/mesa/shader/program_lexer.l @@ -324,19 +324,19 @@ ARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require return INTEGER; } {num}?{frac}{exp}? { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } {num}"."/[^.] { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } {num}{exp} { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } {num}"."{exp} { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index b95c15f..ad86676 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -246,7 +246,7 @@ parse_general_number(slang_parse_ctx *ctx, float *number) if (flt[strlen(flt) - 1] == 'f' || flt[strlen(flt) - 1] == 'F') { flt[strlen(flt) - 1] = '\0'; } - *number = (float)_mesa_strtod(flt, (char **)NULL); + *number = _mesa_strtof(flt, (char **)NULL); free(flt); return 1; @@ -312,7 +312,7 @@ parse_float(slang_parse_ctx * C, float *number) slang_string_concat(whole, "E"); slang_string_concat(whole, exponent); - *number = (float) (_mesa_strtod(whole, (char **) NULL)); + *number = _mesa_strtof(whole, (char **) NULL); _slang_free(whole); } -- 2.7.4