Skip to content

Commit

Permalink
clean up number scanner in Units
Browse files Browse the repository at this point in the history
  • Loading branch information
jriegel committed Aug 3, 2014
1 parent 1da5543 commit b32b227
Show file tree
Hide file tree
Showing 3 changed files with 391 additions and 366 deletions.
23 changes: 22 additions & 1 deletion src/Base/Quantity.cpp
Expand Up @@ -239,7 +239,28 @@ Quantity Quantity::Gon (360.0/400.0 ,Unit(0,0,0,0,0,0,0,1)); // g

Quantity QuantResult;


/* helper function for tuning number strings with groups in a locale agnostic way... */
double num_change(char* yytext,char dez_delim,char grp_delim)
{
double ret_val;
char temp[40];
int i = 0;
for(char* c=yytext;*c!='\0';c++){
// skipp group delimiter
if(*c==grp_delim) continue;
// check for a dez delimiter othere then dot
if(*c==dez_delim && dez_delim !='.')
temp[i++] = '.';
else
temp[i++] = *c;
// check buffor overflow
if (i>39) return 0.0;
}
temp[i] = '\0';

ret_val = atof( temp );
return ret_val;
};

// error func
void Quantity_yyerror(char *errorinfo)
Expand Down

0 comments on commit b32b227

Please sign in to comment.