diff options
author | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1994-09-27 18:43:30 -0300 |
---|---|---|
committer | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1994-09-27 18:43:30 -0300 |
commit | dc6d0dcc09126e70a4f6b36130752d0bd19aaf50 (patch) | |
tree | 8890751bed6ea8a83f4ca44a4be48f7e13179a1f /opcode.c | |
parent | 7cfb5ff41f993c0f7e248f6830e86055bddcd3ab (diff) | |
download | lua-dc6d0dcc09126e70a4f6b36130752d0bd19aaf50.tar.gz lua-dc6d0dcc09126e70a4f6b36130752d0bd19aaf50.tar.bz2 lua-dc6d0dcc09126e70a4f6b36130752d0bd19aaf50.zip |
retirar especificador de formato %n da funcao ToReal e
acertar funcao lua_convtonumber.
Diffstat (limited to 'opcode.c')
-rw-r--r-- | opcode.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_opcode="$Id: opcode.c,v 2.6 1994/09/08 16:51:49 celes Exp $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 2.7 1994/09/20 15:11:11 celes Exp celes $"; |
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
@@ -92,10 +92,9 @@ static char *lua_strconc (char *l, char *r) | |||
92 | 92 | ||
93 | static int ToReal (char* s, float* f) | 93 | static int ToReal (char* s, float* f) |
94 | { | 94 | { |
95 | int n; | 95 | char c; |
96 | float t; | 96 | float t; |
97 | sscanf(s,"%f %n",&t,&n); | 97 | if (sscanf(s,"%f %c",&t,&c) == 1) { *f=t; return 1; } else return 0; |
98 | if (s[n]==0) { *f=t; return 1; } else return 0; | ||
99 | } | 98 | } |
100 | 99 | ||
101 | /* | 100 | /* |
@@ -132,7 +131,7 @@ static Object *lua_convtonumber (Object *obj) | |||
132 | return &cvt; | 131 | return &cvt; |
133 | } | 132 | } |
134 | 133 | ||
135 | if (tag(obj) == T_STRING && ToReal(svalue(obj), &nvalue(obj))) | 134 | if (tag(obj) == T_STRING && ToReal(svalue(obj), &nvalue(&cvt))) |
136 | tag(&cvt) = T_NUMBER; | 135 | tag(&cvt) = T_NUMBER; |
137 | else | 136 | else |
138 | tag(&cvt) = T_NIL; | 137 | tag(&cvt) = T_NIL; |