Mercurial > octave-nkf
comparison src/lex.l @ 3598:0ae310231c46
[project @ 2000-02-19 08:07:08 by jwe]
author | jwe |
---|---|
date | Sat, 19 Feb 2000 08:07:10 +0000 |
parents | 7576a76f6d7b |
children | 0689afb1d001 |
comparison
equal
deleted
inserted
replaced
3597:26662775f4e9 | 3598:0ae310231c46 |
---|---|
1538 } | 1538 } |
1539 | 1539 |
1540 static void | 1540 static void |
1541 handle_number (void) | 1541 handle_number (void) |
1542 { | 1542 { |
1543 char *tmp = strsave (yytext); | |
1544 | |
1545 char *idx = strpbrk (tmp, "Dd"); | |
1546 | |
1547 if (idx) | |
1548 *idx = 'e'; | |
1549 | |
1550 double value = 0.0; | 1543 double value = 0.0; |
1551 int nread = 0; | 1544 int nread = 0; |
1552 | 1545 |
1553 if (looks_like_hex (tmp, strlen (tmp))) | 1546 if (looks_like_hex (yytext, strlen (yytext))) |
1554 { | 1547 { |
1555 unsigned long ival; | 1548 unsigned long ival; |
1556 nread = sscanf (tmp, "%lx", &ival); | 1549 |
1550 nread = sscanf (yytext, "%lx", &ival); | |
1551 | |
1557 value = static_cast<double> (ival); | 1552 value = static_cast<double> (ival); |
1558 } | 1553 } |
1559 else | 1554 else |
1560 nread = sscanf (tmp, "%lf", &value); | 1555 { |
1561 | 1556 char *tmp = strsave (yytext); |
1562 delete [] tmp; | 1557 |
1558 char *idx = strpbrk (tmp, "Dd"); | |
1559 | |
1560 if (idx) | |
1561 *idx = 'e'; | |
1562 | |
1563 nread = sscanf (tmp, "%lf", &value); | |
1564 | |
1565 delete [] tmp; | |
1566 } | |
1563 | 1567 |
1564 // If yytext doesn't contain a valid number, we are in deep doo doo. | 1568 // If yytext doesn't contain a valid number, we are in deep doo doo. |
1565 | 1569 |
1566 assert (nread == 1); | 1570 assert (nread == 1); |
1567 | 1571 |