acertar bug no formato de string.

This commit is contained in:
Waldemar Celes
1994-09-12 16:24:31 -03:00
parent d2117d66ec
commit 98263e2ef1

11
iolib.c
View File

@@ -3,7 +3,7 @@
** Input/output library to LUA ** Input/output library to LUA
*/ */
char *rcs_iolib="$Id: iolib.c,v 1.7 1994/08/17 15:10:04 celes Exp roberto $"; char *rcs_iolib="$Id: iolib.c,v 1.8 1994/08/17 22:34:20 roberto Exp celes $";
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -345,7 +345,7 @@ static char *buildformat (char *e, lua_Object o)
static char buffer[512]; static char buffer[512];
static char f[80]; static char f[80];
char *string = &buffer[255]; char *string = &buffer[255];
char *fstart=e, *fspace; char *fstart=e, *fspace, *send;
char t, j='r'; char t, j='r';
int m=0, n=0, l; int m=0, n=0, l;
while (isspace(*e)) e++; while (isspace(*e)) e++;
@@ -354,7 +354,7 @@ static char *buildformat (char *e, lua_Object o)
if (*e == '<' || *e == '|' || *e == '>') j = *e++; if (*e == '<' || *e == '|' || *e == '>') j = *e++;
while (isdigit(*e)) while (isdigit(*e))
m = m*10 + (*e++ - '0'); m = m*10 + (*e++ - '0');
e++; /* skip point */ if (*e == '.') e++; /* skip point */
while (isdigit(*e)) while (isdigit(*e))
n = n*10 + (*e++ - '0'); n = n*10 + (*e++ - '0');
@@ -383,6 +383,7 @@ static char *buildformat (char *e, lua_Object o)
default: return ""; default: return "";
} }
l = strlen(string); l = strlen(string);
send = string+l;
if (m!=0 && l>m) if (m!=0 && l>m)
{ {
int i; int i;
@@ -406,8 +407,8 @@ static char *buildformat (char *e, lua_Object o)
fspace--; fspace--;
*string = *fspace; *string = *fspace;
} }
while (isspace(*e)) string[l++] = *e++; while (isspace(*e)) *send++ = *e++;
string[l] = 0; *send = 0;
return string; return string;
} }
static void io_write (void) static void io_write (void)