interpreters/bas: Fix the nxstyle warning
except "Mixed case identifier found" Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
c94b091bd3
commit
df2db2e410
@ -14,8 +14,8 @@
|
|||||||
* The above copyright notice and this permission notice shall be included in
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
@ -77,7 +77,7 @@ void Auto_destroy(struct Auto *this)
|
|||||||
free(this->slot);
|
free(this->slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (l = this->all; l != (struct Symbol *)0;)
|
for (l = this->all; l != (struct Symbol *)0; )
|
||||||
{
|
{
|
||||||
struct Symbol *f;
|
struct Symbol *f;
|
||||||
|
|
||||||
@ -203,7 +203,8 @@ int Auto_gosubReturn(struct Auto *this, struct Pc *pc)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Auto_frameToError(struct Auto *this, struct Program *program, struct Value *v)
|
void Auto_frameToError(struct Auto *this,
|
||||||
|
struct Program *program, struct Value *v)
|
||||||
{
|
{
|
||||||
struct Pc p;
|
struct Pc p;
|
||||||
int framePointer;
|
int framePointer;
|
||||||
@ -229,7 +230,8 @@ void Auto_frameToError(struct Auto *this, struct Program *program, struct Value
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Auto_setError(struct Auto *this, long int line, struct Pc *pc, struct Value *v)
|
void Auto_setError(struct Auto *this, long int line,
|
||||||
|
struct Pc *pc, struct Value *v)
|
||||||
{
|
{
|
||||||
this->erpc = *pc;
|
this->erpc = *pc;
|
||||||
this->erl = line;
|
this->erl = line;
|
||||||
@ -238,6 +240,7 @@ void Auto_setError(struct Auto *this, long int line, struct Pc *pc, struct Value
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* compilation methods */
|
/* compilation methods */
|
||||||
|
|
||||||
int Auto_find(struct Auto *this, struct Identifier *ident)
|
int Auto_find(struct Auto *this, struct Identifier *ident)
|
||||||
{
|
{
|
||||||
struct Symbol *find;
|
struct Symbol *find;
|
||||||
@ -293,7 +296,9 @@ int Auto_variable(struct Auto *this, const struct Identifier *ident)
|
|||||||
(*tail)->type = LOCALVAR;
|
(*tail)->type = LOCALVAR;
|
||||||
(*tail)->u.local.type = ident->defaultType;
|
(*tail)->u.local.type = ident->defaultType;
|
||||||
|
|
||||||
/* the offset -1 of the V_VOID procedure return symbol is ok, it is not used */
|
/* the offset -1 of the V_VOID procedure return symbol is ok,
|
||||||
|
* it is not used
|
||||||
|
*/
|
||||||
|
|
||||||
(*tail)->u.local.offset =
|
(*tail)->u.local.offset =
|
||||||
offset - (this->cur->u.local.type == V_VOID ? 1 : 0);
|
offset - (this->cur->u.local.type == V_VOID ? 1 : 0);
|
||||||
@ -310,7 +315,8 @@ enum ValueType Auto_argType(const struct Auto *this, int l)
|
|||||||
++l;
|
++l;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (offset = 0, find = this->cur; l != offset; find = find->next, ++offset)
|
for (offset = 0, find = this->cur; l != offset;
|
||||||
|
find = find->next, ++offset)
|
||||||
{
|
{
|
||||||
assert(find != (struct Symbol *)0);
|
assert(find != (struct Symbol *)0);
|
||||||
}
|
}
|
||||||
@ -338,7 +344,7 @@ void Auto_funcEnd(struct Auto *this)
|
|||||||
{
|
{
|
||||||
struct Symbol **tail;
|
struct Symbol **tail;
|
||||||
|
|
||||||
for (tail = &this->all; *tail != (struct Symbol *)0; tail = &(*tail)->next);
|
for (tail = &this->all; *tail != NULL; tail = &(*tail)->next);
|
||||||
*tail = this->cur;
|
*tail = this->cur;
|
||||||
this->cur = (struct Symbol *)0;
|
this->cur = (struct Symbol *)0;
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
* The above copyright notice and this permission notice shall be included in
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
@ -188,7 +188,8 @@ static struct Value *hex(struct Value *v, long int value, long int digits)
|
|||||||
static struct Value *find(struct Value *v, struct String *pattern,
|
static struct Value *find(struct Value *v, struct String *pattern,
|
||||||
long int occurrence)
|
long int occurrence)
|
||||||
{
|
{
|
||||||
struct String dirname, basename;
|
struct String dirname;
|
||||||
|
struct String basename;
|
||||||
char *slash;
|
char *slash;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
@ -322,8 +323,8 @@ static struct Value *string(struct Value *v, long int len, int c)
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct Value *mid(struct Value *v, struct String *s, long int position,
|
static struct Value *mid(struct Value *v, struct String *s,
|
||||||
long int length)
|
long int position, long int length)
|
||||||
{
|
{
|
||||||
--position;
|
--position;
|
||||||
if (position < 0)
|
if (position < 0)
|
||||||
@ -520,7 +521,8 @@ static struct Value *fn_binid(struct Value *v, struct Auto *stack)
|
|||||||
static struct Value *fn_bindd(struct Value *v, struct Auto *stack)
|
static struct Value *fn_bindd(struct Value *v, struct Auto *stack)
|
||||||
{
|
{
|
||||||
int overflow;
|
int overflow;
|
||||||
long int n, digits;
|
long int n;
|
||||||
|
long int digits;
|
||||||
|
|
||||||
n = Value_toi(realValue(stack, 0), &overflow);
|
n = Value_toi(realValue(stack, 0), &overflow);
|
||||||
if (overflow)
|
if (overflow)
|
||||||
@ -691,7 +693,8 @@ static struct Value *fn_date(struct Value *v, struct Auto *stack)
|
|||||||
|
|
||||||
static struct Value *fn_dec(struct Value *v, struct Auto *stack)
|
static struct Value *fn_dec(struct Value *v, struct Auto *stack)
|
||||||
{
|
{
|
||||||
struct Value value, *arg;
|
struct Value value;
|
||||||
|
struct Value *arg;
|
||||||
size_t using;
|
size_t using;
|
||||||
|
|
||||||
Value_new_STRING(v);
|
Value_new_STRING(v);
|
||||||
@ -718,7 +721,10 @@ static struct Value *fn_det(struct Value *v, struct Auto *stack)
|
|||||||
static struct Value *fn_edit(struct Value *v, struct Auto *stack)
|
static struct Value *fn_edit(struct Value *v, struct Auto *stack)
|
||||||
{
|
{
|
||||||
int code;
|
int code;
|
||||||
char *begin, *end, *rd, *wr;
|
char *begin;
|
||||||
|
char *end;
|
||||||
|
char *rd;
|
||||||
|
char *wr;
|
||||||
char quote;
|
char quote;
|
||||||
|
|
||||||
code = intValue(stack, 1);
|
code = intValue(stack, 1);
|
||||||
@ -755,11 +761,12 @@ static struct Value *fn_edit(struct Value *v, struct Auto *stack)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 4 - Discard all carriage returns, line feeds, form feeds, deletes,
|
/* 4 - Discard all carriage returns, line feeds, form feeds, deletes,
|
||||||
* escapes, and nulls */
|
* escapes, and nulls
|
||||||
|
*/
|
||||||
|
|
||||||
if ((code & 4) &&
|
if ((code & 4) &&
|
||||||
(*rd == '\r' || *rd == '\n' || *rd == '\f' || *rd == 127 || *rd == 27
|
(*rd == '\r' || *rd == '\n' || *rd == '\f' || *rd == 127 ||
|
||||||
|| *rd == '\0'))
|
*rd == 27 || *rd == '\0'))
|
||||||
{
|
{
|
||||||
++rd;
|
++rd;
|
||||||
continue;
|
continue;
|
||||||
@ -996,6 +1003,7 @@ static struct Value *fn_hexdi(struct Value *v, struct Auto *stack)
|
|||||||
{
|
{
|
||||||
return Value_new_ERROR(v, OUTOFRANGE, _("number"));
|
return Value_new_ERROR(v, OUTOFRANGE, _("number"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return hex(v, n, intValue(stack, 1));
|
return hex(v, n, intValue(stack, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1201,8 +1209,8 @@ static struct Value *fn_instr3ssd(struct Value *v, struct Auto *stack)
|
|||||||
|
|
||||||
static struct Value *fn_instr4ii(struct Value *v, struct Auto *stack)
|
static struct Value *fn_instr4ii(struct Value *v, struct Auto *stack)
|
||||||
{
|
{
|
||||||
return instr(v, intValue(stack, 2), intValue(stack, 3), stringValue(stack, 0),
|
return instr(v, intValue(stack, 2), intValue(stack, 3),
|
||||||
stringValue(stack, 1));
|
stringValue(stack, 0), stringValue(stack, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct Value *fn_instr4id(struct Value *v, struct Auto *stack)
|
static struct Value *fn_instr4id(struct Value *v, struct Auto *stack)
|
||||||
@ -1502,7 +1510,8 @@ static struct Value *fn_mid2d(struct Value *v, struct Auto *stack)
|
|||||||
|
|
||||||
static struct Value *fn_mid3ii(struct Value *v, struct Auto *stack)
|
static struct Value *fn_mid3ii(struct Value *v, struct Auto *stack)
|
||||||
{
|
{
|
||||||
return mid(v, stringValue(stack, 0), intValue(stack, 1), intValue(stack, 2));
|
return mid(v, stringValue(stack, 0),
|
||||||
|
intValue(stack, 1), intValue(stack, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct Value *fn_mid3id(struct Value *v, struct Auto *stack)
|
static struct Value *fn_mid3id(struct Value *v, struct Auto *stack)
|
||||||
@ -1931,6 +1940,7 @@ static struct Value *fn_tl(struct Value *v, struct Auto *stack)
|
|||||||
memcpy(v->u.string.character, s->character + 1, tail);
|
memcpy(v->u.string.character, s->character + 1, tail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1966,7 +1976,7 @@ static struct Value *fn_val(struct Value *v, struct Auto *stack)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Value_new_REAL(v, Value_vald(s->character, (char **)0, &overflow));
|
return Value_new_REAL(v, Value_vald(s->character, NULL, &overflow));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1983,10 +1993,11 @@ static unsigned int hash(const char *s)
|
|||||||
return h % GLOBAL_HASHSIZE;
|
return h % GLOBAL_HASHSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void builtin(struct Global *this, const char *ident, enum ValueType type,
|
static void builtin(struct Global *this,
|
||||||
|
const char *ident, enum ValueType type,
|
||||||
struct Value *(*func) (struct Value * value,
|
struct Value *(*func) (struct Value * value,
|
||||||
struct Auto * stack), int argLength,
|
struct Auto * stack),
|
||||||
...)
|
int argLength, ...)
|
||||||
{
|
{
|
||||||
struct Symbol **r;
|
struct Symbol **r;
|
||||||
struct Symbol *s, **sptr;
|
struct Symbol *s, **sptr;
|
||||||
@ -2040,7 +2051,8 @@ struct Global *Global_new(struct Global *this)
|
|||||||
builtin(this, "atn", V_REAL, fn_atn, 1, (int)V_REAL);
|
builtin(this, "atn", V_REAL, fn_atn, 1, (int)V_REAL);
|
||||||
builtin(this, "bin$", V_STRING, fn_bini, 1, (int)V_INTEGER);
|
builtin(this, "bin$", V_STRING, fn_bini, 1, (int)V_INTEGER);
|
||||||
builtin(this, "bin$", V_STRING, fn_bind, 1, (int)V_REAL);
|
builtin(this, "bin$", V_STRING, fn_bind, 1, (int)V_REAL);
|
||||||
builtin(this, "bin$", V_STRING, fn_binii, 2, (int)V_INTEGER, (int)V_INTEGER);
|
builtin(this, "bin$", V_STRING, fn_binii, 2,
|
||||||
|
(int)V_INTEGER, (int)V_INTEGER);
|
||||||
builtin(this, "bin$", V_STRING, fn_bindi, 2, (int)V_REAL, (int)V_INTEGER);
|
builtin(this, "bin$", V_STRING, fn_bindi, 2, (int)V_REAL, (int)V_INTEGER);
|
||||||
builtin(this, "bin$", V_STRING, fn_binid, 2, (int)V_INTEGER, (int)V_REAL);
|
builtin(this, "bin$", V_STRING, fn_binid, 2, (int)V_INTEGER, (int)V_REAL);
|
||||||
builtin(this, "bin$", V_STRING, fn_bindd, 2, (int)V_REAL, (int)V_REAL);
|
builtin(this, "bin$", V_STRING, fn_bindd, 2, (int)V_REAL, (int)V_REAL);
|
||||||
@ -2060,7 +2072,8 @@ struct Global *Global_new(struct Global *this)
|
|||||||
builtin(this, "dec$", V_STRING, fn_dec, 2, (int)V_STRING, (int)V_STRING);
|
builtin(this, "dec$", V_STRING, fn_dec, 2, (int)V_STRING, (int)V_STRING);
|
||||||
builtin(this, "deg", V_REAL, fn_deg, 1, (int)V_REAL);
|
builtin(this, "deg", V_REAL, fn_deg, 1, (int)V_REAL);
|
||||||
builtin(this, "det", V_REAL, fn_det, 0);
|
builtin(this, "det", V_REAL, fn_det, 0);
|
||||||
builtin(this, "edit$", V_STRING, fn_edit, 2, (int)V_STRING, (int)V_INTEGER);
|
builtin(this, "edit$", V_STRING, fn_edit, 2,
|
||||||
|
(int)V_STRING, (int)V_INTEGER);
|
||||||
builtin(this, "environ$", V_STRING, fn_environi, 1, (int)V_INTEGER);
|
builtin(this, "environ$", V_STRING, fn_environi, 1, (int)V_INTEGER);
|
||||||
builtin(this, "environ$", V_STRING, fn_environd, 1, (int)V_REAL);
|
builtin(this, "environ$", V_STRING, fn_environd, 1, (int)V_REAL);
|
||||||
builtin(this, "environ$", V_STRING, fn_environs, 1, (int)V_STRING);
|
builtin(this, "environ$", V_STRING, fn_environs, 1, (int)V_STRING);
|
||||||
@ -2070,7 +2083,8 @@ struct Global *Global_new(struct Global *this)
|
|||||||
builtin(this, "exp", V_REAL, fn_exp, 1, (int)V_REAL);
|
builtin(this, "exp", V_REAL, fn_exp, 1, (int)V_REAL);
|
||||||
builtin(this, "false", V_INTEGER, fn_false, 0);
|
builtin(this, "false", V_INTEGER, fn_false, 0);
|
||||||
builtin(this, "find$", V_STRING, fn_find, 1, (int)V_STRING);
|
builtin(this, "find$", V_STRING, fn_find, 1, (int)V_STRING);
|
||||||
builtin(this, "find$", V_STRING, fn_findi, 2, (int)V_STRING, (int)V_INTEGER);
|
builtin(this, "find$", V_STRING, fn_findi, 2,
|
||||||
|
(int)V_STRING, (int)V_INTEGER);
|
||||||
builtin(this, "find$", V_STRING, fn_findd, 2, (int)V_STRING, (int)V_REAL);
|
builtin(this, "find$", V_STRING, fn_findd, 2, (int)V_STRING, (int)V_REAL);
|
||||||
builtin(this, "fix", V_REAL, fn_fix, 1, (int)V_REAL);
|
builtin(this, "fix", V_REAL, fn_fix, 1, (int)V_REAL);
|
||||||
builtin(this, "frac", V_REAL, fn_frac, 1, (int)V_REAL);
|
builtin(this, "frac", V_REAL, fn_frac, 1, (int)V_REAL);
|
||||||
@ -2078,43 +2092,51 @@ struct Global *Global_new(struct Global *this)
|
|||||||
builtin(this, "fp", V_REAL, fn_frac, 1, (int)V_REAL);
|
builtin(this, "fp", V_REAL, fn_frac, 1, (int)V_REAL);
|
||||||
builtin(this, "hex$", V_STRING, fn_hexi, 1, (int)V_INTEGER);
|
builtin(this, "hex$", V_STRING, fn_hexi, 1, (int)V_INTEGER);
|
||||||
builtin(this, "hex$", V_STRING, fn_hexd, 1, (int)V_REAL);
|
builtin(this, "hex$", V_STRING, fn_hexd, 1, (int)V_REAL);
|
||||||
builtin(this, "hex$", V_STRING, fn_hexii, 2, (int)V_INTEGER, (int)V_INTEGER);
|
builtin(this, "hex$", V_STRING, fn_hexii, 2,
|
||||||
|
(int)V_INTEGER, (int)V_INTEGER);
|
||||||
builtin(this, "hex$", V_STRING, fn_hexdi, 2, (int)V_REAL, (int)V_INTEGER);
|
builtin(this, "hex$", V_STRING, fn_hexdi, 2, (int)V_REAL, (int)V_INTEGER);
|
||||||
builtin(this, "hex$", V_STRING, fn_hexid, 2, (int)V_INTEGER, (int)V_REAL);
|
builtin(this, "hex$", V_STRING, fn_hexid, 2, (int)V_INTEGER, (int)V_REAL);
|
||||||
builtin(this, "hex$", V_STRING, fn_hexdd, 2, (int)V_REAL, (int)V_REAL);
|
builtin(this, "hex$", V_STRING, fn_hexdd, 2, (int)V_REAL, (int)V_REAL);
|
||||||
builtin(this, "inkey$", V_STRING, fn_inkey, 0);
|
builtin(this, "inkey$", V_STRING, fn_inkey, 0);
|
||||||
builtin(this, "inkey$", V_STRING, fn_inkeyi, 1, (int)V_INTEGER);
|
builtin(this, "inkey$", V_STRING, fn_inkeyi, 1, (int)V_INTEGER);
|
||||||
builtin(this, "inkey$", V_STRING, fn_inkeyd, 1, (int)V_REAL);
|
builtin(this, "inkey$", V_STRING, fn_inkeyd, 1, (int)V_REAL);
|
||||||
builtin(this, "inkey$", V_STRING, fn_inkeyii, 2, (int)V_INTEGER, (int)V_INTEGER);
|
builtin(this, "inkey$", V_STRING, fn_inkeyii, 2,
|
||||||
builtin(this, "inkey$", V_STRING, fn_inkeyid, 2, (int)V_INTEGER, (int)V_REAL);
|
(int)V_INTEGER, (int)V_INTEGER);
|
||||||
builtin(this, "inkey$", V_STRING, fn_inkeydi, 2, (int)V_REAL, (int)V_INTEGER);
|
builtin(this, "inkey$", V_STRING, fn_inkeyid, 2,
|
||||||
builtin(this, "inkey$", V_STRING, fn_inkeydd, 2, (int)V_REAL, (int)V_REAL);
|
(int)V_INTEGER, (int)V_REAL);
|
||||||
|
builtin(this, "inkey$", V_STRING, fn_inkeydi, 2,
|
||||||
|
(int)V_REAL, (int)V_INTEGER);
|
||||||
|
builtin(this, "inkey$", V_STRING, fn_inkeydd, 2,
|
||||||
|
(int)V_REAL, (int)V_REAL);
|
||||||
builtin(this, "inp", V_INTEGER, fn_inp, 1, (int)V_INTEGER);
|
builtin(this, "inp", V_INTEGER, fn_inp, 1, (int)V_INTEGER);
|
||||||
builtin(this, "input$", V_STRING, fn_input1, 1, (int)V_INTEGER);
|
builtin(this, "input$", V_STRING, fn_input1, 1, (int)V_INTEGER);
|
||||||
builtin(this, "input$", V_STRING, fn_input2, 2, (int)V_INTEGER, (int)V_INTEGER);
|
builtin(this, "input$", V_STRING, fn_input2, 2,
|
||||||
builtin(this, "instr", V_INTEGER, fn_instr2, 2, (int)V_STRING, (int)V_STRING);
|
|
||||||
builtin(this, "instr", V_INTEGER, fn_instr3iss, 3, (int)V_INTEGER, (int)V_STRING,
|
|
||||||
V_STRING);
|
|
||||||
builtin(this, "instr", V_INTEGER, fn_instr3ssi, 3, (int)V_STRING, (int)V_STRING,
|
|
||||||
V_INTEGER);
|
|
||||||
builtin(this, "instr", V_INTEGER, fn_instr3dss, 3, (int)V_REAL, (int)V_STRING,
|
|
||||||
V_STRING);
|
|
||||||
builtin(this, "instr", V_INTEGER, fn_instr3ssd, 3, (int)V_STRING, (int)V_STRING,
|
|
||||||
V_REAL);
|
|
||||||
builtin(this, "instr", V_INTEGER, fn_instr4ii, 4, (int)V_STRING, (int)V_STRING,
|
|
||||||
(int)V_INTEGER, (int)V_INTEGER);
|
(int)V_INTEGER, (int)V_INTEGER);
|
||||||
builtin(this, "instr", V_INTEGER, fn_instr4id, 4, (int)V_STRING, (int)V_STRING,
|
builtin(this, "instr", V_INTEGER, fn_instr2, 2,
|
||||||
(int)V_INTEGER, (int)V_REAL);
|
(int)V_STRING, (int)V_STRING);
|
||||||
builtin(this, "instr", V_INTEGER, fn_instr4di, 4, (int)V_STRING, (int)V_STRING,
|
builtin(this, "instr", V_INTEGER, fn_instr3iss, 3,
|
||||||
(int)V_REAL, (int)V_INTEGER);
|
(int)V_INTEGER, (int)V_STRING, (int)V_STRING);
|
||||||
builtin(this, "instr", V_INTEGER, fn_instr4dd, 4, (int)V_STRING, (int)V_STRING,
|
builtin(this, "instr", V_INTEGER, fn_instr3ssi, 3,
|
||||||
(int)V_REAL, (int)V_REAL);
|
(int)V_STRING, (int)V_STRING, (int)V_INTEGER);
|
||||||
|
builtin(this, "instr", V_INTEGER, fn_instr3dss, 3,
|
||||||
|
(int)V_REAL, (int)V_STRING, (int)V_STRING);
|
||||||
|
builtin(this, "instr", V_INTEGER, fn_instr3ssd, 3,
|
||||||
|
(int)V_STRING, (int)V_STRING, (int)V_REAL);
|
||||||
|
builtin(this, "instr", V_INTEGER, fn_instr4ii, 4,
|
||||||
|
(int)V_STRING, (int)V_STRING, (int)V_INTEGER, (int)V_INTEGER);
|
||||||
|
builtin(this, "instr", V_INTEGER, fn_instr4id, 4,
|
||||||
|
(int)V_STRING, (int)V_STRING, (int)V_INTEGER, (int)V_REAL);
|
||||||
|
builtin(this, "instr", V_INTEGER, fn_instr4di, 4,
|
||||||
|
(int)V_STRING, (int)V_STRING, (int)V_REAL, (int)V_INTEGER);
|
||||||
|
builtin(this, "instr", V_INTEGER, fn_instr4dd, 4,
|
||||||
|
(int)V_STRING, (int)V_STRING, (int)V_REAL, (int)V_REAL);
|
||||||
builtin(this, "int", V_REAL, fn_int, 1, (int)V_REAL);
|
builtin(this, "int", V_REAL, fn_int, 1, (int)V_REAL);
|
||||||
builtin(this, "int%", V_INTEGER, fn_intp, 1, (int)V_REAL);
|
builtin(this, "int%", V_INTEGER, fn_intp, 1, (int)V_REAL);
|
||||||
builtin(this, "ip", V_REAL, fn_fix, 1, (int)V_REAL);
|
builtin(this, "ip", V_REAL, fn_fix, 1, (int)V_REAL);
|
||||||
builtin(this, "lcase$", V_STRING, fn_lcase, 1, (int)V_STRING);
|
builtin(this, "lcase$", V_STRING, fn_lcase, 1, (int)V_STRING);
|
||||||
builtin(this, "lower$", V_STRING, fn_lcase, 1, (int)V_STRING);
|
builtin(this, "lower$", V_STRING, fn_lcase, 1, (int)V_STRING);
|
||||||
builtin(this, "left$", V_STRING, fn_left, 2, (int)V_STRING, (int)V_INTEGER);
|
builtin(this, "left$", V_STRING, fn_left, 2,
|
||||||
|
(int)V_STRING, (int)V_INTEGER);
|
||||||
builtin(this, "len", V_INTEGER, fn_len, 1, (int)V_STRING);
|
builtin(this, "len", V_INTEGER, fn_len, 1, (int)V_STRING);
|
||||||
builtin(this, "loc", V_INTEGER, fn_loc, 1, (int)V_INTEGER);
|
builtin(this, "loc", V_INTEGER, fn_loc, 1, (int)V_INTEGER);
|
||||||
builtin(this, "lof", V_INTEGER, fn_lof, 1, (int)V_INTEGER);
|
builtin(this, "lof", V_INTEGER, fn_lof, 1, (int)V_INTEGER);
|
||||||
@ -2122,20 +2144,26 @@ struct Global *Global_new(struct Global *this)
|
|||||||
builtin(this, "log10", V_REAL, fn_log10, 1, (int)V_REAL);
|
builtin(this, "log10", V_REAL, fn_log10, 1, (int)V_REAL);
|
||||||
builtin(this, "log2", V_REAL, fn_log2, 1, (int)V_REAL);
|
builtin(this, "log2", V_REAL, fn_log2, 1, (int)V_REAL);
|
||||||
builtin(this, "ltrim$", V_STRING, fn_ltrim, 1, (int)V_STRING);
|
builtin(this, "ltrim$", V_STRING, fn_ltrim, 1, (int)V_STRING);
|
||||||
builtin(this, "match", V_INTEGER, fn_match, 3, (int)V_STRING, (int)V_STRING,
|
builtin(this, "match", V_INTEGER, fn_match, 3,
|
||||||
(int)V_INTEGER);
|
(int)V_STRING, (int)V_STRING, (int)V_INTEGER);
|
||||||
builtin(this, "max", V_INTEGER, fn_maxii, 2, (int)V_INTEGER, (int)V_INTEGER);
|
builtin(this, "max", V_INTEGER, fn_maxii, 2,
|
||||||
|
(int)V_INTEGER, (int)V_INTEGER);
|
||||||
builtin(this, "max", V_REAL, fn_maxdi, 2, (int)V_REAL, (int)V_INTEGER);
|
builtin(this, "max", V_REAL, fn_maxdi, 2, (int)V_REAL, (int)V_INTEGER);
|
||||||
builtin(this, "max", V_REAL, fn_maxid, 2, (int)V_INTEGER, (int)V_REAL);
|
builtin(this, "max", V_REAL, fn_maxid, 2, (int)V_INTEGER, (int)V_REAL);
|
||||||
builtin(this, "max", V_REAL, fn_maxdd, 2, (int)V_REAL, (int)V_REAL);
|
builtin(this, "max", V_REAL, fn_maxdd, 2, (int)V_REAL, (int)V_REAL);
|
||||||
builtin(this, "mid$", V_STRING, fn_mid2i, 2, (int)V_STRING, (int)V_INTEGER);
|
builtin(this, "mid$", V_STRING, fn_mid2i, 2,
|
||||||
|
(int)V_STRING, (int)V_INTEGER);
|
||||||
builtin(this, "mid$", V_STRING, fn_mid2d, 2, (int)V_STRING, (int)V_REAL);
|
builtin(this, "mid$", V_STRING, fn_mid2d, 2, (int)V_STRING, (int)V_REAL);
|
||||||
builtin(this, "mid$", V_STRING, fn_mid3ii, 3, (int)V_STRING, (int)V_INTEGER,
|
builtin(this, "mid$", V_STRING, fn_mid3ii, 3,
|
||||||
V_INTEGER);
|
(int)V_STRING, (int)V_INTEGER, (int)V_INTEGER);
|
||||||
builtin(this, "mid$", V_STRING, fn_mid3id, 3, (int)V_STRING, (int)V_INTEGER, (int)V_REAL);
|
builtin(this, "mid$", V_STRING, fn_mid3id, 3,
|
||||||
builtin(this, "mid$", V_STRING, fn_mid3di, 3, (int)V_STRING, (int)V_REAL, (int)V_INTEGER);
|
(int)V_STRING, (int)V_INTEGER, (int)V_REAL);
|
||||||
builtin(this, "mid$", V_STRING, fn_mid3dd, 3, (int)V_STRING, (int)V_REAL, (int)V_REAL);
|
builtin(this, "mid$", V_STRING, fn_mid3di, 3,
|
||||||
builtin(this, "min", V_INTEGER, fn_minii, 2, (int)V_INTEGER, (int)V_INTEGER);
|
(int)V_STRING, (int)V_REAL, (int)V_INTEGER);
|
||||||
|
builtin(this, "mid$", V_STRING, fn_mid3dd, 3,
|
||||||
|
(int)V_STRING, (int)V_REAL, (int)V_REAL);
|
||||||
|
builtin(this, "min", V_INTEGER, fn_minii, 2,
|
||||||
|
(int)V_INTEGER, (int)V_INTEGER);
|
||||||
builtin(this, "min", V_REAL, fn_mindi, 2, (int)V_REAL, (int)V_INTEGER);
|
builtin(this, "min", V_REAL, fn_mindi, 2, (int)V_REAL, (int)V_INTEGER);
|
||||||
builtin(this, "min", V_REAL, fn_minid, 2, (int)V_INTEGER, (int)V_REAL);
|
builtin(this, "min", V_REAL, fn_minid, 2, (int)V_INTEGER, (int)V_REAL);
|
||||||
builtin(this, "min", V_REAL, fn_mindd, 2, (int)V_REAL, (int)V_REAL);
|
builtin(this, "min", V_REAL, fn_mindd, 2, (int)V_REAL, (int)V_REAL);
|
||||||
@ -2147,20 +2175,21 @@ struct Global *Global_new(struct Global *this)
|
|||||||
builtin(this, "pi", V_REAL, fn_pi, 0);
|
builtin(this, "pi", V_REAL, fn_pi, 0);
|
||||||
builtin(this, "pos", V_INTEGER, fn_pos, 1, (int)V_INTEGER);
|
builtin(this, "pos", V_INTEGER, fn_pos, 1, (int)V_INTEGER);
|
||||||
builtin(this, "pos", V_INTEGER, fn_pos, 1, (int)V_REAL);
|
builtin(this, "pos", V_INTEGER, fn_pos, 1, (int)V_REAL);
|
||||||
builtin(this, "pos", V_INTEGER, fn_instr3ssi, 3, (int)V_STRING, (int)V_STRING,
|
builtin(this, "pos", V_INTEGER, fn_instr3ssi, 3,
|
||||||
(int)V_INTEGER);
|
(int)V_STRING, (int)V_STRING, (int)V_INTEGER);
|
||||||
builtin(this, "pos", V_INTEGER, fn_instr3ssd, 3, (int)V_STRING, (int)V_STRING,
|
builtin(this, "pos", V_INTEGER, fn_instr3ssd, 3,
|
||||||
(int)V_REAL);
|
(int)V_STRING, (int)V_STRING, (int)V_REAL);
|
||||||
builtin(this, "rad", V_REAL, fn_rad, 1, (int)V_REAL);
|
builtin(this, "rad", V_REAL, fn_rad, 1, (int)V_REAL);
|
||||||
builtin(this, "right$", V_STRING, fn_right, 2, (int)V_STRING, (int)V_INTEGER);
|
builtin(this, "right$", V_STRING, fn_right, 2,
|
||||||
|
(int)V_STRING, (int)V_INTEGER);
|
||||||
builtin(this, "rnd", V_INTEGER, fn_rnd, 0);
|
builtin(this, "rnd", V_INTEGER, fn_rnd, 0);
|
||||||
builtin(this, "rnd", V_INTEGER, fn_rndd, 1, (int)V_REAL);
|
builtin(this, "rnd", V_INTEGER, fn_rndd, 1, (int)V_REAL);
|
||||||
builtin(this, "rnd", V_INTEGER, fn_rndi, 1, (int)V_INTEGER);
|
builtin(this, "rnd", V_INTEGER, fn_rndi, 1, (int)V_INTEGER);
|
||||||
builtin(this, "rtrim$", V_STRING, fn_rtrim, 1, (int)V_STRING);
|
builtin(this, "rtrim$", V_STRING, fn_rtrim, 1, (int)V_STRING);
|
||||||
builtin(this, "seg$", V_STRING, fn_mid3ii, 3, (int)V_STRING, (int)V_INTEGER,
|
builtin(this, "seg$", V_STRING, fn_mid3ii, 3,
|
||||||
(int)V_INTEGER);
|
(int)V_STRING, (int)V_INTEGER, (int)V_INTEGER);
|
||||||
builtin(this, "seg$", V_STRING, fn_mid3id, 3, (int)V_STRING, (int)V_INTEGER,
|
builtin(this, "seg$", V_STRING, fn_mid3id, 3,
|
||||||
(int)V_REAL);
|
(int)V_STRING, (int)V_INTEGER, (int)V_REAL);
|
||||||
builtin(this, "seg$", V_STRING, fn_mid3di, 3, (int)V_STRING, (int)V_REAL,
|
builtin(this, "seg$", V_STRING, fn_mid3di, 3, (int)V_STRING, (int)V_REAL,
|
||||||
(int)V_INTEGER);
|
(int)V_INTEGER);
|
||||||
builtin(this, "seg$", V_STRING, fn_mid3dd, 3, (int)V_STRING, (int)V_REAL,
|
builtin(this, "seg$", V_STRING, fn_mid3dd, 3, (int)V_STRING, (int)V_REAL,
|
||||||
@ -2171,12 +2200,18 @@ struct Global *Global_new(struct Global *this)
|
|||||||
builtin(this, "sqr", V_REAL, fn_sqr, 1, (int)V_REAL);
|
builtin(this, "sqr", V_REAL, fn_sqr, 1, (int)V_REAL);
|
||||||
builtin(this, "str$", V_STRING, fn_str, 1, (int)V_REAL);
|
builtin(this, "str$", V_STRING, fn_str, 1, (int)V_REAL);
|
||||||
builtin(this, "str$", V_STRING, fn_str, 1, (int)V_INTEGER);
|
builtin(this, "str$", V_STRING, fn_str, 1, (int)V_INTEGER);
|
||||||
builtin(this, "string$", V_STRING, fn_stringii, 2, (int)V_INTEGER, (int)V_INTEGER);
|
builtin(this, "string$", V_STRING, fn_stringii, 2,
|
||||||
builtin(this, "string$", V_STRING, fn_stringid, 2, (int)V_INTEGER, (int)V_REAL);
|
(int)V_INTEGER, (int)V_INTEGER);
|
||||||
builtin(this, "string$", V_STRING, fn_stringdi, 2, (int)V_REAL, (int)V_INTEGER);
|
builtin(this, "string$", V_STRING, fn_stringid, 2,
|
||||||
builtin(this, "string$", V_STRING, fn_stringdd, 2, (int)V_REAL, (int)V_REAL);
|
(int)V_INTEGER, (int)V_REAL);
|
||||||
builtin(this, "string$", V_STRING, fn_stringis, 2, (int)V_INTEGER, (int)V_STRING);
|
builtin(this, "string$", V_STRING, fn_stringdi, 2,
|
||||||
builtin(this, "string$", V_STRING, fn_stringds, 2, (int)V_REAL, (int)V_STRING);
|
(int)V_REAL, (int)V_INTEGER);
|
||||||
|
builtin(this, "string$", V_STRING, fn_stringdd, 2,
|
||||||
|
(int)V_REAL, (int)V_REAL);
|
||||||
|
builtin(this, "string$", V_STRING, fn_stringis, 2,
|
||||||
|
(int)V_INTEGER, (int)V_STRING);
|
||||||
|
builtin(this, "string$", V_STRING, fn_stringds, 2,
|
||||||
|
(int)V_REAL, (int)V_STRING);
|
||||||
builtin(this, "strip$", V_STRING, fn_strip, 1, (int)V_STRING);
|
builtin(this, "strip$", V_STRING, fn_strip, 1, (int)V_STRING);
|
||||||
builtin(this, "tan", V_REAL, fn_tan, 1, (int)V_REAL);
|
builtin(this, "tan", V_REAL, fn_tan, 1, (int)V_REAL);
|
||||||
builtin(this, "time", V_INTEGER, fn_timei, 0);
|
builtin(this, "time", V_INTEGER, fn_timei, 0);
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
* The above copyright notice and this permission notice shall be included in
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
@ -136,7 +136,9 @@ static void format_double(struct String *buf, double value, int width,
|
|||||||
else /* print decimal numbers or integers, if
|
else /* print decimal numbers or integers, if
|
||||||
* possible */
|
* possible */
|
||||||
{
|
{
|
||||||
int o, n, p = 6;
|
int o;
|
||||||
|
int n;
|
||||||
|
int p = 6;
|
||||||
|
|
||||||
while (x >= 10.0 && p > 0)
|
while (x >= 10.0 && p > 0)
|
||||||
{
|
{
|
||||||
@ -153,6 +155,7 @@ static void format_double(struct String *buf, double value, int width,
|
|||||||
{
|
{
|
||||||
--buf->length;
|
--buf->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf->character[buf->length - 1] == '.')
|
if (buf->character[buf->length - 1] == '.')
|
||||||
{
|
{
|
||||||
--buf->length;
|
--buf->length;
|
||||||
@ -222,8 +225,8 @@ struct Value *Value_new_NIL(struct Value *this)
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Value *Value_new_ERROR(struct Value *this, int code, const char *error,
|
struct Value *Value_new_ERROR(struct Value *this, int code,
|
||||||
...)
|
const char *error, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
@ -1151,6 +1154,7 @@ struct Value *Value_eq(struct Value *this, struct Value *x, int calc)
|
|||||||
Value_new_INTEGER(this, v);
|
Value_new_INTEGER(this, v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case V_STRING:
|
case V_STRING:
|
||||||
{
|
{
|
||||||
int v;
|
int v;
|
||||||
@ -1356,7 +1360,8 @@ struct Value *Value_ne(struct Value *this, struct Value *x, int calc)
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Value_exitFor(struct Value *this, struct Value *limit, struct Value *step)
|
int Value_exitFor(struct Value *this,
|
||||||
|
struct Value *limit, struct Value *step)
|
||||||
{
|
{
|
||||||
switch (this->type)
|
switch (this->type)
|
||||||
{
|
{
|
||||||
@ -1383,7 +1388,8 @@ int Value_exitFor(struct Value *this, struct Value *limit, struct Value *step)
|
|||||||
|
|
||||||
void Value_errorPrefix(struct Value *this, const char *prefix)
|
void Value_errorPrefix(struct Value *this, const char *prefix)
|
||||||
{
|
{
|
||||||
size_t prefixlen, msglen;
|
size_t prefixlen;
|
||||||
|
size_t msglen;
|
||||||
|
|
||||||
assert(this->type == V_ERROR);
|
assert(this->type == V_ERROR);
|
||||||
prefixlen = strlen(prefix);
|
prefixlen = strlen(prefix);
|
||||||
@ -1395,7 +1401,8 @@ void Value_errorPrefix(struct Value *this, const char *prefix)
|
|||||||
|
|
||||||
void Value_errorSuffix(struct Value *this, const char *suffix)
|
void Value_errorSuffix(struct Value *this, const char *suffix)
|
||||||
{
|
{
|
||||||
size_t suffixlen, msglen;
|
size_t suffixlen;
|
||||||
|
size_t msglen;
|
||||||
|
|
||||||
assert(this->type == V_ERROR);
|
assert(this->type == V_ERROR);
|
||||||
suffixlen = strlen(suffix);
|
suffixlen = strlen(suffix);
|
||||||
@ -1409,7 +1416,8 @@ struct Value *Value_new_typeError(struct Value *this, enum ValueType t1,
|
|||||||
{
|
{
|
||||||
assert(typestr[t1]);
|
assert(typestr[t1]);
|
||||||
assert(typestr[t2]);
|
assert(typestr[t2]);
|
||||||
return Value_new_ERROR(this, TYPEMISMATCH1, _(typestr[t1]), _(typestr[t2]));
|
return Value_new_ERROR(this, TYPEMISMATCH1,
|
||||||
|
_(typestr[t1]), _(typestr[t2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void retypeError(struct Value *this, enum ValueType to)
|
static void retypeError(struct Value *this, enum ValueType to)
|
||||||
@ -1616,8 +1624,8 @@ struct String *Value_toString(struct Value *this, struct String *s, char pad,
|
|||||||
{
|
{
|
||||||
if (precision > 0 || exponent)
|
if (precision > 0 || exponent)
|
||||||
{
|
{
|
||||||
format_double(&buf, (double)this->u.integer, width, precision,
|
format_double(&buf, (double)this->u.integer, width,
|
||||||
exponent);
|
precision, exponent);
|
||||||
}
|
}
|
||||||
else if (precision == 0)
|
else if (precision == 0)
|
||||||
{
|
{
|
||||||
@ -1795,12 +1803,14 @@ struct Value *Value_toStringUsing(struct Value *this, struct String *s,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '&': /* output string */
|
case '&': /* output string */
|
||||||
{
|
{
|
||||||
width = 0;
|
width = 0;
|
||||||
++(*usingpos);
|
++(*usingpos);
|
||||||
goto work;
|
goto work;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '*':
|
case '*':
|
||||||
case '$':
|
case '$':
|
||||||
case '0':
|
case '0':
|
||||||
@ -1849,10 +1859,12 @@ struct Value *Value_toStringUsing(struct Value *this, struct String *s,
|
|||||||
default:
|
default:
|
||||||
++width;
|
++width;
|
||||||
}
|
}
|
||||||
|
|
||||||
++(*usingpos);
|
++(*usingpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*usingpos < using->length && using->character[*usingpos] == '.')
|
if (*usingpos < using->length &&
|
||||||
|
using->character[*usingpos] == '.')
|
||||||
{
|
{
|
||||||
++(*usingpos);
|
++(*usingpos);
|
||||||
++width;
|
++width;
|
||||||
@ -1872,13 +1884,15 @@ struct Value *Value_toStringUsing(struct Value *this, struct String *s,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*usingpos < using->length && using->character[*usingpos] == '-')
|
if (*usingpos < using->length &&
|
||||||
|
using->character[*usingpos] == '-')
|
||||||
{
|
{
|
||||||
++(*usingpos);
|
++(*usingpos);
|
||||||
if (headingsign == 0)
|
if (headingsign == 0)
|
||||||
{
|
{
|
||||||
headingsign = 2;
|
headingsign = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
trailingsign = -1;
|
trailingsign = -1;
|
||||||
}
|
}
|
||||||
else if (*usingpos < using->length &&
|
else if (*usingpos < using->length &&
|
||||||
@ -1889,6 +1903,7 @@ struct Value *Value_toStringUsing(struct Value *this, struct String *s,
|
|||||||
{
|
{
|
||||||
headingsign = 2;
|
headingsign = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
trailingsign = 1;
|
trailingsign = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1910,8 +1925,8 @@ struct Value *Value_toStringUsing(struct Value *this, struct String *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
work:
|
work:
|
||||||
Value_toString(this, s, pad, headingsign, width, commas, dollar, dollarleft,
|
Value_toString(this, s, pad, headingsign, width, commas, dollar,
|
||||||
precision, exponent, trailingsign);
|
dollarleft, precision, exponent, trailingsign);
|
||||||
if ((this->type == V_INTEGER || this->type == V_REAL) && width == 0 &&
|
if ((this->type == V_INTEGER || this->type == V_REAL) && width == 0 &&
|
||||||
precision == -1)
|
precision == -1)
|
||||||
{
|
{
|
||||||
@ -1969,7 +1984,8 @@ struct String *Value_toWrite(struct Value *this, struct String *s)
|
|||||||
{
|
{
|
||||||
double x;
|
double x;
|
||||||
int p = DBL_DIG;
|
int p = DBL_DIG;
|
||||||
int n, o;
|
int n;
|
||||||
|
int o;
|
||||||
|
|
||||||
x = (this->u.real < 0.0 ? -this->u.real : this->u.real);
|
x = (this->u.real < 0.0 ? -this->u.real : this->u.real);
|
||||||
while (x > 1.0 && p > 0)
|
while (x > 1.0 && p > 0)
|
||||||
@ -2026,10 +2042,21 @@ struct String *Value_toWrite(struct Value *this, struct String *s)
|
|||||||
|
|
||||||
struct Value *Value_nullValue(enum ValueType type)
|
struct Value *Value_nullValue(enum ValueType type)
|
||||||
{
|
{
|
||||||
static struct Value integer = { V_INTEGER };
|
static struct Value integer =
|
||||||
static struct Value real = { V_REAL };
|
{
|
||||||
static struct Value string = { V_STRING };
|
V_INTEGER
|
||||||
static char n[] = "";
|
};
|
||||||
|
|
||||||
|
static struct Value real =
|
||||||
|
{
|
||||||
|
V_REAL
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct Value string =
|
||||||
|
{
|
||||||
|
V_STRING
|
||||||
|
};
|
||||||
|
|
||||||
static int init = 0;
|
static int init = 0;
|
||||||
|
|
||||||
if (!init)
|
if (!init)
|
||||||
@ -2037,7 +2064,8 @@ struct Value *Value_nullValue(enum ValueType type)
|
|||||||
integer.u.integer = 0;
|
integer.u.integer = 0;
|
||||||
real.u.real = 0.0;
|
real.u.real = 0.0;
|
||||||
string.u.string.length = 0;
|
string.u.string.length = 0;
|
||||||
string.u.string.character = n;
|
string.u.string.character = "";
|
||||||
|
init = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user