diff options
| author | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1994-09-12 16:24:31 -0300 |
|---|---|---|
| committer | Waldemar Celes <celes@tecgraf.puc-rio.br> | 1994-09-12 16:24:31 -0300 |
| commit | 98263e2ef156c04c305708fa8792d80b3b76aceb (patch) | |
| tree | c9f238eaebd432514c287254b61c84b2cdffffa0 | |
| parent | d2117d66ec893ed01efa6bc065f842e39d80e6df (diff) | |
| download | lua-98263e2ef156c04c305708fa8792d80b3b76aceb.tar.gz lua-98263e2ef156c04c305708fa8792d80b3b76aceb.tar.bz2 lua-98263e2ef156c04c305708fa8792d80b3b76aceb.zip | |
acertar bug no formato de string.
| -rw-r--r-- | iolib.c | 11 |
1 files changed, 6 insertions, 5 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** Input/output library to LUA | 3 | ** Input/output library to LUA |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_iolib="$Id: iolib.c,v 1.7 1994/08/17 15:10:04 celes Exp roberto $"; | 6 | char *rcs_iolib="$Id: iolib.c,v 1.8 1994/08/17 22:34:20 roberto Exp celes $"; |
| 7 | 7 | ||
| 8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
| 9 | #include <string.h> | 9 | #include <string.h> |
| @@ -345,7 +345,7 @@ static char *buildformat (char *e, lua_Object o) | |||
| 345 | static char buffer[512]; | 345 | static char buffer[512]; |
| 346 | static char f[80]; | 346 | static char f[80]; |
| 347 | char *string = &buffer[255]; | 347 | char *string = &buffer[255]; |
| 348 | char *fstart=e, *fspace; | 348 | char *fstart=e, *fspace, *send; |
| 349 | char t, j='r'; | 349 | char t, j='r'; |
| 350 | int m=0, n=0, l; | 350 | int m=0, n=0, l; |
| 351 | while (isspace(*e)) e++; | 351 | while (isspace(*e)) e++; |
| @@ -354,7 +354,7 @@ static char *buildformat (char *e, lua_Object o) | |||
| 354 | if (*e == '<' || *e == '|' || *e == '>') j = *e++; | 354 | if (*e == '<' || *e == '|' || *e == '>') j = *e++; |
| 355 | while (isdigit(*e)) | 355 | while (isdigit(*e)) |
| 356 | m = m*10 + (*e++ - '0'); | 356 | m = m*10 + (*e++ - '0'); |
| 357 | e++; /* skip point */ | 357 | if (*e == '.') e++; /* skip point */ |
| 358 | while (isdigit(*e)) | 358 | while (isdigit(*e)) |
| 359 | n = n*10 + (*e++ - '0'); | 359 | n = n*10 + (*e++ - '0'); |
| 360 | 360 | ||
| @@ -383,6 +383,7 @@ static char *buildformat (char *e, lua_Object o) | |||
| 383 | default: return ""; | 383 | default: return ""; |
| 384 | } | 384 | } |
| 385 | l = strlen(string); | 385 | l = strlen(string); |
| 386 | send = string+l; | ||
| 386 | if (m!=0 && l>m) | 387 | if (m!=0 && l>m) |
| 387 | { | 388 | { |
| 388 | int i; | 389 | int i; |
| @@ -406,8 +407,8 @@ static char *buildformat (char *e, lua_Object o) | |||
| 406 | fspace--; | 407 | fspace--; |
| 407 | *string = *fspace; | 408 | *string = *fspace; |
| 408 | } | 409 | } |
| 409 | while (isspace(*e)) string[l++] = *e++; | 410 | while (isspace(*e)) *send++ = *e++; |
| 410 | string[l] = 0; | 411 | *send = 0; |
| 411 | return string; | 412 | return string; |
| 412 | } | 413 | } |
| 413 | static void io_write (void) | 414 | static void io_write (void) |
