Fix $ungetc() arguments to be in the correct order.

The arguments to $ungetc() were backwards! This patch fixes that
and adds a bit more checking to the compile_tf routine. It still
needs more work, but that can wait for the major system function
clean up I have planned when I can find the time.
This commit is contained in:
Cary R 2008-05-14 14:59:38 -07:00 committed by Stephen Williams
parent cef0d0071b
commit ca880c73fc
1 changed files with 31 additions and 16 deletions

View File

@ -480,23 +480,40 @@ static PLI_INT32 sys_ungetc_compiletf(PLI_BYTE8*name)
vpiHandle item = vpi_scan(argv);
if (item == 0) {
vpi_printf("%s: mcd parameter missing.\n", name);
vpi_printf("%s: character parameter missing.\n", name);
return 0;
}
type = vpi_get(vpiType, item);
switch (type) {
case vpiReg:
case vpiRealVal:
case vpiRealVal: // Is this correct?
case vpiIntegerVar:
break;
default:
vpi_printf("ERROR: %s mcd parameter must be of integral", name);
vpi_printf(", got vpiType=%d\n", type);
vpi_printf("ERROR: %s character parameter must be ", name);
vpi_printf("integral, got vpiType=%d\n", type);
vpi_free_object(argv);
return 0;
}
item = vpi_scan(argv);
type = vpi_get(vpiType, item);
switch (type) {
case vpiReg:
case vpiRealVal: // Is this correct?
case vpiIntegerVar:
break;
default:
vpi_printf("ERROR: %s mcd parameter must be integral, ", name);
vpi_printf("got vpiType=%d\n", type);
vpi_free_object(argv);
return 0;
}
/* That should be all the arguments. */
item = vpi_scan(argv);
assert(item == 0);
return 0;
}
@ -504,7 +521,7 @@ static PLI_INT32 sys_ungetc_calltf(PLI_BYTE8*name)
{
unsigned int mcd;
unsigned char x;
s_vpi_value value, xvalue, rval;
s_vpi_value val, rval;
vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, sys);
vpiHandle item = vpi_scan(argv);
@ -512,11 +529,15 @@ static PLI_INT32 sys_ungetc_calltf(PLI_BYTE8*name)
rval.format = vpiIntVal;
assert(item);
val.format = vpiIntVal;
vpi_get_value(item, &val);
x = val.value.integer;
value.format = vpiIntVal;
vpi_get_value(item, &value);
mcd = value.value.integer;
item = vpi_scan(argv);
val.format = vpiIntVal;
vpi_get_value(item, &val);
mcd = val.value.integer;
if (IS_MCD(mcd)) {
rval.value.integer = EOF;
@ -524,12 +545,6 @@ static PLI_INT32 sys_ungetc_calltf(PLI_BYTE8*name)
return 0;
}
item = vpi_scan(argv);
xvalue.format = vpiIntVal;
vpi_get_value(item, &xvalue);
x = xvalue.value.integer;
fp = vpi_get_file(mcd);
if ( !fp ) {
rval.value.integer = EOF;