From ca880c73fc6909f369ca63e6589a0ea22d96d3ce Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 14 May 2008 14:59:38 -0700 Subject: [PATCH] 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. --- vpi/sys_fileio.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/vpi/sys_fileio.c b/vpi/sys_fileio.c index 9bbd5bb1c..996566640 100644 --- a/vpi/sys_fileio.c +++ b/vpi/sys_fileio.c @@ -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;