renamed a parameter name of ase_awk_getrundata()
This commit is contained in:
		| @ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * $Id: awk.h 469 2008-12-11 10:05:28Z baconevi $ | ||||
|  * $Id: awk.h 470 2008-12-11 13:43:05Z baconevi $ | ||||
|  * | ||||
|  * {License} | ||||
|  */ | ||||
| @ -975,7 +975,7 @@ ase_mmgr_t* ase_awk_getrunmmgr ( | ||||
|  * SYNOPSIS | ||||
|  */ | ||||
| void* ase_awk_getrundata ( | ||||
| 	ase_awk_run_t* awk | ||||
| 	ase_awk_run_t* run | ||||
| ); | ||||
| /******/ | ||||
|  | ||||
|  | ||||
| @ -88,6 +88,21 @@ ase_fio_hnd_t ase_fio_gethandle ( | ||||
| 	ase_fio_t* fio | ||||
| ); | ||||
|  | ||||
| /****f* ase.cmn.fio/ase_fio_sethandle | ||||
|  * SYNOPSIS | ||||
|  *  ase_fio_sethandle - set the file handle | ||||
|  * WARNING | ||||
|  *  Avoid using this function if you don't know what you are doing. | ||||
|  *  You may have to retrieve the previous handle using ase_fio_gethandle() | ||||
|  *  to take relevant actions before resetting it with ase_fio_sethandle(). | ||||
|  * SYNOPSIS | ||||
|  */ | ||||
| void ase_fio_sethandle ( | ||||
| 	ase_fio_t* fio, | ||||
| 	ase_fio_hnd_t handle | ||||
| ); | ||||
| /******/ | ||||
|  | ||||
| ase_fio_off_t ase_fio_seek ( | ||||
| 	ase_fio_t*    fio, | ||||
| 	ase_fio_off_t offset, | ||||
|  | ||||
| @ -68,19 +68,55 @@ void ase_sio_fini ( | ||||
| 	ase_sio_t* sio | ||||
| ); | ||||
|  | ||||
| ase_fio_hnd_t ase_sio_gethandle (ase_sio_t* sio); | ||||
| ase_fio_hnd_t ase_sio_gethandle ( | ||||
| 	ase_sio_t* sio | ||||
| ); | ||||
|  | ||||
| ase_ssize_t ase_sio_flush (ase_sio_t* sio); | ||||
| void ase_sio_purge (ase_sio_t* sio); | ||||
| ase_ssize_t ase_sio_flush ( | ||||
| 	ase_sio_t* sio | ||||
| ); | ||||
|  | ||||
| ase_ssize_t ase_sio_getc (ase_sio_t* sio, ase_char_t* c); | ||||
| ase_ssize_t ase_sio_gets (ase_sio_t* sio, ase_char_t* buf, ase_size_t size); | ||||
| ase_ssize_t ase_sio_getsx (ase_sio_t* sio, ase_char_t* buf, ase_size_t size); | ||||
| ase_ssize_t ase_sio_getstr (ase_sio_t* sio, ase_str_t* buf); | ||||
| void ase_sio_purge ( | ||||
| 	ase_sio_t* sio | ||||
| ); | ||||
|  | ||||
| ase_ssize_t ase_sio_putc (ase_sio_t* sio, ase_char_t c); | ||||
| ase_ssize_t ase_sio_puts (ase_sio_t* sio, const ase_char_t* str); | ||||
| ase_ssize_t ase_sio_putsx (ase_sio_t* sio, const ase_char_t* str, ase_size_t size); | ||||
| ase_ssize_t ase_sio_getc ( | ||||
| 	ase_sio_t* sio, | ||||
| 	ase_char_t* c | ||||
| ); | ||||
|  | ||||
| ase_ssize_t ase_sio_gets ( | ||||
| 	ase_sio_t* sio, | ||||
| 	ase_char_t* buf, | ||||
| 	ase_size_t size | ||||
| ); | ||||
|  | ||||
| ase_ssize_t ase_sio_getsx ( | ||||
| 	ase_sio_t* sio, | ||||
| 	ase_char_t* buf, | ||||
| 	ase_size_t size | ||||
| ); | ||||
|  | ||||
| ase_ssize_t ase_sio_getstr ( | ||||
| 	ase_sio_t* sio,  | ||||
| 	ase_str_t* buf | ||||
| ); | ||||
|  | ||||
| ase_ssize_t ase_sio_putc ( | ||||
| 	ase_sio_t* sio,  | ||||
| 	ase_char_t c | ||||
| ); | ||||
|  | ||||
| ase_ssize_t ase_sio_puts ( | ||||
| 	ase_sio_t* sio, | ||||
| 	const ase_char_t* str | ||||
| ); | ||||
|  | ||||
| ase_ssize_t ase_sio_putsx ( | ||||
| 	ase_sio_t* sio,  | ||||
| 	const ase_char_t* str, | ||||
| 	ase_size_t size | ||||
| ); | ||||
|  | ||||
| #if 0 | ||||
| ase_ssize_t ase_sio_putsn (ase_sio_t* sio, ...); | ||||
|  | ||||
| @ -448,9 +448,79 @@ static ase_ssize_t awk_extio_file ( | ||||
| 	return -1; | ||||
| } | ||||
|  | ||||
| static int open_extio_console (ase_awk_extio_t* epa); | ||||
| static int close_extio_console (ase_awk_extio_t* epa); | ||||
| static int next_extio_console (ase_awk_extio_t* epa); | ||||
| static int open_extio_console (ase_awk_extio_t* epa) | ||||
| { | ||||
| 	runio_data_t* rd = (runio_data_t*)epa->data; | ||||
|  | ||||
| 	//dprint (ASE_T("opening console[%s] of type %x\n"), epa->name, epa->type); | ||||
|  | ||||
| 	if (epa->mode == ASE_AWK_EXTIO_CONSOLE_READ) | ||||
| 	{ | ||||
| 		if (rd->icf[rd->icf_cur] == ASE_NULL) | ||||
| 		{ | ||||
| 			/* no more input file */ | ||||
| 			//dprint (ASE_T("console - no more file\n"));; | ||||
| 			return 0; | ||||
| 		} | ||||
|  | ||||
| 		if (rd->icf[rd->icf_cur][0] == ASE_T('\0')) | ||||
| 		{ | ||||
| 			//dprint (ASE_T("    console(r) - <standard input>\n")); | ||||
| 			epa->handle = ase_sio_in; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			/* a temporary variable fp is used here not to change  | ||||
| 			 * any fields of epa when the open operation fails */ | ||||
| 			ase_sio_t* fp; | ||||
|  | ||||
| 			fp = ase_sio_open ( | ||||
| 				ase_awk_getrunmmgr(epa->run), | ||||
| 				0, | ||||
| 				rd->icf[rd->icf_cur], | ||||
| 				ASE_SIO_READ | ||||
| 			); | ||||
| 			if (fp == ASE_NULL) | ||||
| 			{ | ||||
| 				ase_cstr_t errarg; | ||||
|  | ||||
| 				errarg.ptr = rd->icf[rd->icf_cur]; | ||||
| 				errarg.len = ase_strlen(rd->icf[rd->icf_cur]); | ||||
|  | ||||
| 				ase_awk_setrunerror (epa->run, ASE_AWK_EOPEN, 0, &errarg, 1); | ||||
| 				return -1; | ||||
| 			} | ||||
|  | ||||
| 			//dprint (ASE_T("    console(r) - %s\n"), rd->icf[rd->icf_cur]); | ||||
| 			if (ase_awk_setfilename ( | ||||
| 				epa->run, rd->icf[rd->icf_cur],  | ||||
| 				ase_strlen(rd->icf[rd->icf_cur])) == -1) | ||||
| 			{ | ||||
| 				ase_sio_close (fp); | ||||
| 				return -1; | ||||
| 			} | ||||
|  | ||||
| 			epa->handle = fp; | ||||
| 		} | ||||
|  | ||||
| 		rd->icf_cur++; | ||||
| 		return 1; | ||||
| 	} | ||||
| 	else if (epa->mode == ASE_AWK_EXTIO_CONSOLE_WRITE) | ||||
| 	{ | ||||
| 		//dprint (ASE_T("    console(w) - <standard output>\n")); | ||||
|  | ||||
| 		if (ase_awk_setofilename (epa->run, ASE_T(""), 0) == -1) | ||||
| 		{ | ||||
| 			return -1; | ||||
| 		} | ||||
|  | ||||
| 		epa->handle = ase_sio_out; | ||||
| 		return 1; | ||||
| 	} | ||||
|  | ||||
| 	return -1; | ||||
| } | ||||
|  | ||||
| static ase_ssize_t awk_extio_console ( | ||||
| 	int cmd, void* arg, ase_char_t* data, ase_size_t size) | ||||
| @ -464,7 +534,17 @@ static ase_ssize_t awk_extio_console ( | ||||
| 	} | ||||
| 	else if (cmd == ASE_AWK_IO_CLOSE) | ||||
| 	{ | ||||
| 		return close_extio_console (epa); | ||||
| 		//dprint (ASE_T("closing console of type %x\n"), epa->type); | ||||
|  | ||||
| 		if (epa->handle != ASE_NULL && | ||||
| 		    epa->handle != ase_sio_in &&  | ||||
| 		    epa->handle != ase_sio_out &&  | ||||
| 		    epa->handle != ase_sio_err) | ||||
| 		{ | ||||
| 			ase_sio_close ((ase_sio_t*)epa->handle); | ||||
| 		} | ||||
|  | ||||
| 		return 0; | ||||
| 	} | ||||
| 	else if (cmd == ASE_AWK_IO_READ) | ||||
| 	{ | ||||
| @ -561,129 +641,34 @@ static ase_ssize_t awk_extio_console ( | ||||
| 	} | ||||
| 	else if (cmd == ASE_AWK_IO_NEXT) | ||||
| 	{ | ||||
| 		return next_extio_console (epa); | ||||
| 	} | ||||
| 		int n; | ||||
| 		ase_sio_t* fp = (ase_sio_t*)epa->handle; | ||||
|  | ||||
| 	return -1; | ||||
| } | ||||
| 		//dprint (ASE_T("switching console[%s] of type %x\n"), epa->name, epa->type); | ||||
|  | ||||
| static int open_extio_console (ase_awk_extio_t* epa) | ||||
| { | ||||
| 	runio_data_t* rd = (runio_data_t*)epa->data; | ||||
| 		n = open_extio_console(epa); | ||||
| 		if (n == -1) return -1; | ||||
|  | ||||
|  | ||||
| 	//dprint (ASE_T("opening console[%s] of type %x\n"), epa->name, epa->type); | ||||
|  | ||||
| 	if (epa->mode == ASE_AWK_EXTIO_CONSOLE_READ) | ||||
| 	{ | ||||
| 		if (rd->icf[rd->icf_cur] == ASE_NULL) | ||||
| 		if (n == 0)  | ||||
| 		{ | ||||
| 			/* no more input file */ | ||||
| 			//dprint (ASE_T("console - no more file\n"));; | ||||
| 			/* if there is no more file, keep the previous handle */ | ||||
| 			return 0; | ||||
| 		} | ||||
|  | ||||
| 		if (rd->icf[rd->icf_cur][0] == ASE_T('\0')) | ||||
| 		if (fp != ASE_NULL &&  | ||||
| 		    fp != ase_sio_in &&  | ||||
| 		    fp != ase_sio_out && | ||||
| 		    fp != ase_sio_err)  | ||||
| 		{ | ||||
| 			//dprint (ASE_T("    console(r) - <standard input>\n")); | ||||
| 			epa->handle = ase_sio_in; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			/* a temporary variable fp is used here not to change  | ||||
| 			 * any fields of epa when the open operation fails */ | ||||
| 			ase_sio_t* fp; | ||||
|  | ||||
| 			fp = ase_sio_open ( | ||||
| 				ase_awk_getrunmmgr(epa->run), | ||||
| 				0, | ||||
| 				rd->icf[rd->icf_cur], | ||||
| 				ASE_SIO_READ | ||||
| 			); | ||||
| 			if (fp == ASE_NULL) | ||||
| 			{ | ||||
| 				ase_cstr_t errarg; | ||||
|  | ||||
| 				errarg.ptr = rd->icf[rd->icf_cur]; | ||||
| 				errarg.len = ase_strlen(rd->icf[rd->icf_cur]); | ||||
|  | ||||
| 				ase_awk_setrunerror (epa->run, ASE_AWK_EOPEN, 0, &errarg, 1); | ||||
| 				return -1; | ||||
| 			} | ||||
|  | ||||
| 			//dprint (ASE_T("    console(r) - %s\n"), rd->icf[rd->icf_cur]); | ||||
| 			if (ase_awk_setfilename ( | ||||
| 				epa->run, rd->icf[rd->icf_cur],  | ||||
| 				ase_strlen(rd->icf[rd->icf_cur])) == -1) | ||||
| 			{ | ||||
| 				ase_sio_close (fp); | ||||
| 				return -1; | ||||
| 			} | ||||
|  | ||||
| 			epa->handle = fp; | ||||
| 			ase_sio_close (fp); | ||||
| 		} | ||||
|  | ||||
| 		rd->icf_cur++; | ||||
| 		return 1; | ||||
| 	} | ||||
| 	else if (epa->mode == ASE_AWK_EXTIO_CONSOLE_WRITE) | ||||
| 	{ | ||||
| 		//dprint (ASE_T("    console(w) - <standard output>\n")); | ||||
|  | ||||
| 		if (ase_awk_setofilename (epa->run, ASE_T(""), 0) == -1) | ||||
| 		{ | ||||
| 			return -1; | ||||
| 		} | ||||
|  | ||||
| 		epa->handle = ase_sio_out; | ||||
| 		return 1; | ||||
| 		return n; | ||||
| 	} | ||||
|  | ||||
| 	return -1; | ||||
| } | ||||
|  | ||||
| static int close_extio_console (ase_awk_extio_t* epa) | ||||
| { | ||||
| 	//dprint (ASE_T("closing console of type %x\n"), epa->type); | ||||
|  | ||||
| 	if (epa->handle != ASE_NULL && | ||||
| 	    epa->handle != ase_sio_in &&  | ||||
| 	    epa->handle != ase_sio_out &&  | ||||
| 	    epa->handle != ase_sio_err) | ||||
| 	{ | ||||
| 		ase_sio_close ((ase_sio_t*)epa->handle); | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static int next_extio_console (ase_awk_extio_t* epa) | ||||
| { | ||||
| 	int n; | ||||
| 	ase_sio_t* fp = (ase_sio_t*)epa->handle; | ||||
|  | ||||
| 	//dprint (ASE_T("switching console[%s] of type %x\n"), epa->name, epa->type); | ||||
|  | ||||
| 	n = open_extio_console(epa); | ||||
| 	if (n == -1) return -1; | ||||
|  | ||||
| 	if (n == 0)  | ||||
| 	{ | ||||
| 		/* if there is no more file, keep the previous handle */ | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| 	if (fp != ASE_NULL &&  | ||||
| 	    fp != ase_sio_in &&  | ||||
| 	    fp != ase_sio_out && | ||||
| 	    fp != ase_sio_err)  | ||||
| 	{ | ||||
| 		ase_sio_close (fp); | ||||
| 	} | ||||
|  | ||||
| 	return n; | ||||
| } | ||||
|  | ||||
| int ase_awk_runsimple (ase_awk_t* awk, ase_char_t** icf) | ||||
| { | ||||
| 	ase_awk_runcbs_t runcbs; | ||||
|  | ||||
| @ -181,6 +181,11 @@ ase_fio_hnd_t ase_fio_gethandle (ase_fio_t* fio) | ||||
| 	return fio->handle; | ||||
| } | ||||
|  | ||||
| void ase_fio_sethandle (ase_fio_t* fio, ase_fio_hnd_t handle) | ||||
| { | ||||
| 	fio->handle = handle; | ||||
| } | ||||
|  | ||||
| ase_fio_off_t ase_fio_seek ( | ||||
| 	ase_fio_t* fio, ase_fio_off_t offset, ase_fio_ori_t origin) | ||||
| { | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * $Id: rex.c 337 2008-08-20 09:17:25Z baconevi $ | ||||
|  * $Id: rex.c 470 2008-12-11 13:43:05Z baconevi $ | ||||
|  * | ||||
|  * {License} | ||||
|  */ | ||||
| @ -9,7 +9,8 @@ | ||||
| #include "chr.h" | ||||
|  | ||||
| #ifdef DEBUG_REX | ||||
| #include <ase/utl/stdio.h> | ||||
| #include <ase/bas/sio.h> | ||||
| #define DPUTS(x) ase_sio_puts(&ase_sio_err,x) | ||||
| #endif | ||||
|  | ||||
| enum | ||||
| @ -736,8 +737,7 @@ static int build_charset (builder_t* builder, code_t* cmd) | ||||
| 		{ | ||||
| 			/* invalid range */ | ||||
| 		#ifdef DEBUG_REX | ||||
| 			ase_dprintf ( | ||||
| 				ASE_T("build_charset: invalid character set range\n")); | ||||
| 			DPUTS (ASE_T("build_charset: invalid character set range\n")); | ||||
| 		#endif | ||||
| 			builder->errnum = ASE_REX_ECRANGE; | ||||
| 			return -1; | ||||
| @ -768,7 +768,7 @@ static int build_cclass (builder_t* builder, ase_char_t* cc) | ||||
| 	{ | ||||
| 		/* wrong class name */ | ||||
| 	#ifdef DEBUG_REX | ||||
| 		ase_dprintf (ASE_T("build_cclass: wrong class name\n")); | ||||
| 		DPUTS (ASE_T("build_cclass: wrong class name\n")); | ||||
| 	#endif | ||||
| 		builder->errnum = ASE_REX_ECCLASS; | ||||
| 		return -1; | ||||
| @ -781,7 +781,7 @@ static int build_cclass (builder_t* builder, ase_char_t* cc) | ||||
| 	    builder->ptn.curc.value != ASE_T(':')) | ||||
| 	{ | ||||
| 	#ifdef DEBUG_REX | ||||
| 		ase_dprintf (ASE_T("build_cclass: a colon(:) expected\n")); | ||||
| 		DPUTS (ASE_T("build_cclass: a colon(:) expected\n")); | ||||
| 	#endif | ||||
| 		builder->errnum = ASE_REX_ECOLON; | ||||
| 		return -1; | ||||
| @ -794,7 +794,7 @@ static int build_cclass (builder_t* builder, ase_char_t* cc) | ||||
| 	    builder->ptn.curc.value != ASE_T(']')) | ||||
| 	{ | ||||
| 	#ifdef DEBUG_REX | ||||
| 		ase_dprintf (ASE_T("build_cclass: ] expected\n")); | ||||
| 		DPUTS (ASE_T("build_cclass: ] expected\n")); | ||||
| 	#endif | ||||
| 		builder->errnum = ASE_REX_ERBRACKET;	 | ||||
| 		return -1; | ||||
| @ -1427,11 +1427,11 @@ static const ase_byte_t* match_ord_char ( | ||||
| 		while (si < ubound) | ||||
| 		{ | ||||
| 			if (&mat->match_ptr[si] >= matcher->match.str.end) break; | ||||
| #ifdef DEBUG_REX | ||||
| 		#ifdef DEBUG_REX | ||||
| 			ase_dprintf ( | ||||
| 				ASE_T("match_ord_char: <ignorecase> %c %c\n"), | ||||
| 				cc, mat->match_ptr[si]); | ||||
| #endif | ||||
| 		#endif | ||||
| 			if (cc != ASE_CCLS_TOUPPER (matcher->ccls, mat->match_ptr[si])) break; | ||||
| 			si++; | ||||
| 		} | ||||
| @ -1441,11 +1441,11 @@ static const ase_byte_t* match_ord_char ( | ||||
| 		while (si < ubound) | ||||
| 		{ | ||||
| 			if (&mat->match_ptr[si] >= matcher->match.str.end) break; | ||||
| #ifdef DEBUG_REX | ||||
| 		#ifdef DEBUG_REX | ||||
| 			ase_dprintf ( | ||||
| 				ASE_T("match_ord_char: %c %c\n"),  | ||||
| 				cc, mat->match_ptr[si]); | ||||
| #endif | ||||
| 		#endif | ||||
| 			if (cc != mat->match_ptr[si]) break; | ||||
| 			si++; | ||||
| 		} | ||||
|  | ||||
		Reference in New Issue
	
	Block a user