V0.8: fix $ungetc argument order.

This patch mirrors what was done in development to fix $ungetc.
This commit is contained in:
Cary R 2008-11-21 17:11:25 -08:00 committed by Stephen Williams
parent 8deb2c0b60
commit d134f6f074
1 changed files with 23 additions and 14 deletions

View File

@ -334,7 +334,7 @@ static PLI_INT32 sys_ungetc_compiletf(char*name)
vpiHandle item = vpi_scan(argv); vpiHandle item = vpi_scan(argv);
if (item == 0) { if (item == 0) {
vpi_printf("%s: mcd parameter missing.\n", name); vpi_printf("%s: charater parameter missing.\n", name);
return 0; return 0;
} }
@ -351,22 +351,38 @@ static PLI_INT32 sys_ungetc_compiletf(char*name)
return 0; return 0;
} }
item = vpi_scan(argv);
type = vpi_get(vpiType, item);
switch (type) {
case vpiReg:
case vpiRealVal:
case vpiIntegerVar:
break;
default:
vpi_printf("ERROR: %s mcd parameter must be of integral", name);
vpi_printf(", got vpiType=%d\n", type);
vpi_free_object(argv);
return 0;
}
return 0; return 0;
} }
static PLI_INT32 sys_ungetc_calltf(char *name) static PLI_INT32 sys_ungetc_calltf(char *name)
{ {
unsigned int mcd; unsigned int mcd;
unsigned char x; unsigned char chr;
s_vpi_value value, xvalue, rval; s_vpi_value value, rval;
vpiHandle sys = vpi_handle(vpiSysTfCall, 0); vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, sys); vpiHandle argv = vpi_iterate(vpiArgument, sys);
vpiHandle item = vpi_scan(argv); vpiHandle item = vpi_scan(argv);
FILE *fp; FILE *fp;
rval.format = vpiIntVal; value.format = vpiIntVal;
vpi_get_value(item, &value);
chr = value.value.integer;
assert(item); item = vpi_scan(argv);
value.format = vpiIntVal; value.format = vpiIntVal;
vpi_get_value(item, &value); vpi_get_value(item, &value);
@ -378,12 +394,6 @@ static PLI_INT32 sys_ungetc_calltf(char *name)
return 0; return 0;
} }
item = vpi_scan(argv);
xvalue.format = vpiIntVal;
vpi_get_value(item, &xvalue);
x = xvalue.value.integer;
fp = vpi_get_file(mcd); fp = vpi_get_file(mcd);
if ( !fp ) { if ( !fp ) {
rval.value.integer = EOF; rval.value.integer = EOF;
@ -391,9 +401,8 @@ static PLI_INT32 sys_ungetc_calltf(char *name)
return 0; return 0;
} }
ungetc(x, fp); rval.format = vpiIntVal;
rval.value.integer = ungetc(chr, fp);
rval.value.integer = 0;
vpi_put_value(sys, &rval, 0, vpiNoDelay); vpi_put_value(sys, &rval, 0, vpiNoDelay);
return 0; return 0;
} }