*** empty log message ***
This commit is contained in:
		@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: run.c,v 1.88 2006-05-09 03:00:25 bacon Exp $
 | 
			
		||||
 * $Id: run.c,v 1.89 2006-05-09 15:21:26 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <xp/awk/awk_i.h>
 | 
			
		||||
@ -41,6 +41,7 @@ static void __close_run (xp_awk_run_t* run);
 | 
			
		||||
 | 
			
		||||
static int __run_main (xp_awk_run_t* run);
 | 
			
		||||
static int __run_pattern_blocks  (xp_awk_run_t* run);
 | 
			
		||||
static int __run_pattern_block_chain (xp_awk_run_t* run, xp_awk_chain_t* chain);
 | 
			
		||||
static int __run_block (xp_awk_run_t* run, xp_awk_nde_blk_t* nde);
 | 
			
		||||
static int __run_statement (xp_awk_run_t* run, xp_awk_nde_t* nde);
 | 
			
		||||
static int __run_if_statement (xp_awk_run_t* run, xp_awk_nde_if_t* nde);
 | 
			
		||||
@ -428,7 +429,7 @@ xp_printf (XP_T("-[END VARIABLES]--------------------------\n"));
 | 
			
		||||
	return n;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int __run_pattern_blocks  (xp_awk_run_t* run)
 | 
			
		||||
static int __run_pattern_blocks (xp_awk_run_t* run)
 | 
			
		||||
{
 | 
			
		||||
	xp_ssize_t n;
 | 
			
		||||
 | 
			
		||||
@ -445,6 +446,7 @@ static int __run_pattern_blocks  (xp_awk_run_t* run)
 | 
			
		||||
	       run->exit_level != EXIT_ABORT)
 | 
			
		||||
	{
 | 
			
		||||
		int x;
 | 
			
		||||
 | 
			
		||||
		run->exit_level = EXIT_NONE;
 | 
			
		||||
 | 
			
		||||
		x = __read_text_input(run);
 | 
			
		||||
@ -460,14 +462,18 @@ static int __run_pattern_blocks  (xp_awk_run_t* run)
 | 
			
		||||
 | 
			
		||||
		/*
 | 
			
		||||
xp_printf (XP_T("**** line [%s]\n"), XP_STR_BUF(&run->input.line));
 | 
			
		||||
		 * TODO: execute pattern blocks.
 | 
			
		||||
		 */
 | 
			
		||||
		/* for each block { run it }
 | 
			
		||||
		 * TODO: handle according if next and nextfile has been called 
 | 
			
		||||
		 */
 | 
			
		||||
/* TODO */
 | 
			
		||||
		if (__run_block (run, 
 | 
			
		||||
			(xp_awk_nde_blk_t*)run->tree->begin) == -1) n = -1;
 | 
			
		||||
		if (__run_pattern_block_chain (run, run->tree->chain) == -1)
 | 
			
		||||
		{
 | 
			
		||||
			/* don't care about the result of input close */
 | 
			
		||||
			run->txtio (XP_AWK_INPUT_CLOSE, 
 | 
			
		||||
				run->txtio_arg, XP_NULL, 0);
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	n = run->txtio (XP_AWK_INPUT_CLOSE, run->txtio_arg, XP_NULL, 0);
 | 
			
		||||
@ -476,6 +482,57 @@ xp_printf (XP_T("**** line [%s]\n"), XP_STR_BUF(&run->input.line));
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int __run_pattern_block_chain (xp_awk_run_t* run, xp_awk_chain_t* chain)
 | 
			
		||||
{
 | 
			
		||||
	xp_awk_nde_t* ptn;
 | 
			
		||||
 | 
			
		||||
	while (chain != XP_NULL)
 | 
			
		||||
	{
 | 
			
		||||
		ptn = chain->pattern;
 | 
			
		||||
 | 
			
		||||
		if (ptn == XP_NULL)
 | 
			
		||||
		{
 | 
			
		||||
			/* just execute the block */
 | 
			
		||||
			if (__run_block (run, (xp_awk_nde_blk_t*)chain->action) == -1) return -1;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			xp_awk_val_t* v1;
 | 
			
		||||
			
 | 
			
		||||
			v1 = __eval_expression (run, ptn);
 | 
			
		||||
			if (v1 == XP_NULL) return -1;
 | 
			
		||||
 | 
			
		||||
			xp_awk_refupval (v1);
 | 
			
		||||
 | 
			
		||||
			if (ptn->next == XP_NULL)
 | 
			
		||||
			{
 | 
			
		||||
				if (xp_awk_boolval(v1))
 | 
			
		||||
				{
 | 
			
		||||
					if (__run_block (run, (xp_awk_nde_blk_t*)chain->action) == -1) 
 | 
			
		||||
					{
 | 
			
		||||
						xp_awk_refdownval (run, v1);
 | 
			
		||||
						return -1;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				xp_awk_refdownval (run, v1);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				xp_assert (ptn->next->next == XP_NULL);
 | 
			
		||||
				/* TODO: implement this */
 | 
			
		||||
				xp_awk_refdownval (run, v1);
 | 
			
		||||
				xp_printf (XP_TEXT("ERROR: pattern, pattern NOT OMPLEMENTED\n"));
 | 
			
		||||
				PANIC_I (run, XP_AWK_EINTERNAL);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		chain = chain->next;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int __run_block (xp_awk_run_t* run, xp_awk_nde_blk_t* nde)
 | 
			
		||||
{
 | 
			
		||||
	xp_awk_nde_t* p;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										17
									
								
								ase/test/awk/t6.awk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								ase/test/awk/t6.awk
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
			
		||||
BEGIN
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	for (i = -10; i < 10; i++) 
 | 
			
		||||
	{
 | 
			
		||||
		if (i == 5) exit; /*break;*/
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	j = -10;
 | 
			
		||||
       	while (j < 10) 
 | 
			
		||||
	{
 | 
			
		||||
		if (j == 5) break;
 | 
			
		||||
		j++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										4
									
								
								ase/test/awk/t7.awk
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								ase/test/awk/t7.awk
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
			
		||||
BEGIN { i = 20; j = 0; }
 | 
			
		||||
{ i++; }
 | 
			
		||||
i % 2 { j++; }
 | 
			
		||||
/*END { i  = i + 1234; j = j + 1234; }*/
 | 
			
		||||
		Reference in New Issue
	
	Block a user