Move nstr_promote() to src/lib/common/, external linkage

This commit is contained in:
Markus Armbruster 2008-03-04 07:51:56 +01:00
parent 9eab865c38
commit 422cd52209
3 changed files with 39 additions and 41 deletions

View file

@ -275,6 +275,7 @@ extern int nstr_coerce_val(struct valstr *, nsc_type, char *);
extern int nstr_exec(struct nscstr *, int, void *);
/* src/lib/common/nstreval.c */
extern void nstr_exec_val(struct valstr *, natid, void *, nsc_type);
extern int nstr_promote(int);
extern char *symbol_by_value(int, struct symbol *);
/* src/lib/global/nsc.c */
extern void nsc_init(void);

View file

@ -160,6 +160,44 @@ nstr_exec_val(struct valstr *val, natid cnum, void *ptr, nsc_type want)
val->val_type = valtype;
}
/*
* Promote VALTYPE.
* If VALTYPE is an integer type, return NSC_LONG.
* If VALTYPE is a floating-point type, return NSC_DOUBLE.
* If VALTYPE is a string type, return NSC_STRING.
*/
int
nstr_promote(int valtype)
{
switch (valtype) {
case NSC_LONG:
case NSC_DOUBLE:
case NSC_STRING:
break;
case NSC_CHAR:
case NSC_UCHAR:
case NSC_SHORT:
case NSC_USHORT:
case NSC_INT:
case NSC_XCOORD:
case NSC_YCOORD:
case NSC_HIDDEN:
case NSC_TIME:
valtype = NSC_LONG;
break;
case NSC_FLOAT:
valtype = NSC_DOUBLE;
break;
case NSC_STRINGY:
valtype = NSC_STRING;
break;
default:
CANT_REACH();
valtype = NSC_NOTYPE;
}
return valtype;
}
char *
symbol_by_value(int key, struct symbol *table)
{

View file

@ -49,8 +49,6 @@ static int nstr_string_ok(struct castr *ca, int idx);
static struct valstr *nstr_resolve_sel(struct valstr *, struct castr *);
static struct valstr *nstr_mkselval(struct valstr *, int, struct castr *);
static struct valstr *nstr_resolve_id(struct valstr *, struct castr *, int, int);
static int nstr_promote(int);
/*
* Compile conditions into array NP[LEN].
@ -474,45 +472,6 @@ nstr_comp_val(char *str, struct valstr *val, int type)
return tail;
}
/*
* Promote VALTYPE.
* If VALTYPE is an integer type, return NSC_LONG.
* If VALTYPE is a floating-point type, return NSC_DOUBLE.
* If VALTYPE is a string type, return NSC_STRING.
*/
static int
nstr_promote(int valtype)
{
switch (valtype) {
case NSC_LONG:
case NSC_DOUBLE:
case NSC_STRING:
break;
case NSC_CHAR:
case NSC_UCHAR:
case NSC_SHORT:
case NSC_USHORT:
case NSC_INT:
case NSC_XCOORD:
case NSC_YCOORD:
case NSC_HIDDEN:
case NSC_TIME:
valtype = NSC_LONG;
break;
case NSC_FLOAT:
valtype = NSC_DOUBLE;
break;
case NSC_STRINGY:
valtype = NSC_STRING;
break;
default:
CANT_REACH();
valtype = NSC_NOTYPE;
}
return valtype;
}
static int
cond_type_mismatch(char *str)
{