*** empty log message ***
This commit is contained in:
		@ -4,7 +4,7 @@ OUT = xpawk.lib
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
CC = cl
 | 
					CC = cl
 | 
				
			||||||
#CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I../..
 | 
					#CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I../..
 | 
				
			||||||
CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I../.. -D__STAND_ALONE
 | 
					CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I../.. -D__STAND_ALONE -DXP_CHAR_IS_WCHAR
 | 
				
			||||||
 | 
					
 | 
				
			||||||
all: $(OBJS)
 | 
					all: $(OBJS)
 | 
				
			||||||
	link -lib @<<
 | 
						link -lib @<<
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
/* 
 | 
					/* 
 | 
				
			||||||
 * $Id: awk.c,v 1.35 2006-03-28 16:33:09 bacon Exp $ 
 | 
					 * $Id: awk.c,v 1.36 2006-03-29 16:37:31 bacon Exp $ 
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <xp/awk/awk.h>
 | 
					#include <xp/awk/awk.h>
 | 
				
			||||||
@ -10,6 +10,7 @@
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void __free_func (xp_awk_t* awk, void* func);
 | 
					static void __free_func (xp_awk_t* awk, void* func);
 | 
				
			||||||
 | 
					static void __free_namedval (xp_awk_t* awk, void* val);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
xp_awk_t* xp_awk_open (xp_awk_t* awk)
 | 
					xp_awk_t* xp_awk_open (xp_awk_t* awk)
 | 
				
			||||||
{	
 | 
					{	
 | 
				
			||||||
@ -56,7 +57,7 @@ xp_awk_t* xp_awk_open (xp_awk_t* awk)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: initial map size...
 | 
					// TODO: initial map size...
 | 
				
			||||||
	if (xp_awk_map_open(&awk->run.named,awk,256,xp_awk_refdownval) == XP_NULL) {
 | 
						if (xp_awk_map_open(&awk->run.named,awk,256,__free_namedval) == XP_NULL) {
 | 
				
			||||||
		xp_str_close (&awk->token.name);
 | 
							xp_str_close (&awk->token.name);
 | 
				
			||||||
		xp_awk_map_close (&awk->tree.funcs);
 | 
							xp_awk_map_close (&awk->tree.funcs);
 | 
				
			||||||
		xp_awk_tab_close (&awk->parse.globals);
 | 
							xp_awk_tab_close (&awk->parse.globals);
 | 
				
			||||||
@ -198,3 +199,8 @@ static void __free_func (xp_awk_t* awk, void* func)
 | 
				
			|||||||
	xp_awk_clrpt (f->body);
 | 
						xp_awk_clrpt (f->body);
 | 
				
			||||||
	xp_free (f);
 | 
						xp_free (f);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void __free_namedval (xp_awk_t* awk, void* val)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						xp_awk_refdownval (awk, val);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										202
									
								
								ase/awk/parse.c
									
									
									
									
									
								
							
							
						
						
									
										202
									
								
								ase/awk/parse.c
									
									
									
									
									
								
							@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * $Id: parse.c,v 1.61 2006-03-27 11:43:17 bacon Exp $
 | 
					 * $Id: parse.c,v 1.62 2006-03-29 16:37:31 bacon Exp $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <xp/awk/awk.h>
 | 
					#include <xp/awk/awk.h>
 | 
				
			||||||
@ -35,6 +35,10 @@ enum
 | 
				
			|||||||
	TOKEN_MOD,
 | 
						TOKEN_MOD,
 | 
				
			||||||
	TOKEN_RSHIFT,
 | 
						TOKEN_RSHIFT,
 | 
				
			||||||
	TOKEN_LSHIFT,
 | 
						TOKEN_LSHIFT,
 | 
				
			||||||
 | 
						TOKEN_LOR,
 | 
				
			||||||
 | 
						TOKEN_LAND,
 | 
				
			||||||
 | 
						TOKEN_BOR,
 | 
				
			||||||
 | 
						TOKEN_BAND,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	TOKEN_LPAREN,
 | 
						TOKEN_LPAREN,
 | 
				
			||||||
	TOKEN_RPAREN,
 | 
						TOKEN_RPAREN,
 | 
				
			||||||
@ -96,6 +100,11 @@ static xp_awk_nde_t* __parse_statement (xp_awk_t* awk);
 | 
				
			|||||||
static xp_awk_nde_t* __parse_statement_nb (xp_awk_t* awk);
 | 
					static xp_awk_nde_t* __parse_statement_nb (xp_awk_t* awk);
 | 
				
			||||||
static xp_awk_nde_t* __parse_expression (xp_awk_t* awk);
 | 
					static xp_awk_nde_t* __parse_expression (xp_awk_t* awk);
 | 
				
			||||||
static xp_awk_nde_t* __parse_basic_expr (xp_awk_t* awk);
 | 
					static xp_awk_nde_t* __parse_basic_expr (xp_awk_t* awk);
 | 
				
			||||||
 | 
					static xp_awk_nde_t* __parse_conditional (xp_awk_t* awk);
 | 
				
			||||||
 | 
					static xp_awk_nde_t* __parse_logical_or (xp_awk_t* awk);
 | 
				
			||||||
 | 
					static xp_awk_nde_t* __parse_logical_and (xp_awk_t* awk);
 | 
				
			||||||
 | 
					static xp_awk_nde_t* __parse_bitwise_or (xp_awk_t* awk);
 | 
				
			||||||
 | 
					static xp_awk_nde_t* __parse_bitwise_xor (xp_awk_t* awk);
 | 
				
			||||||
static xp_awk_nde_t* __parse_equality (xp_awk_t* awk);
 | 
					static xp_awk_nde_t* __parse_equality (xp_awk_t* awk);
 | 
				
			||||||
static xp_awk_nde_t* __parse_relational (xp_awk_t* awk);
 | 
					static xp_awk_nde_t* __parse_relational (xp_awk_t* awk);
 | 
				
			||||||
static xp_awk_nde_t* __parse_shift (xp_awk_t* awk);
 | 
					static xp_awk_nde_t* __parse_shift (xp_awk_t* awk);
 | 
				
			||||||
@ -920,7 +929,6 @@ static xp_awk_nde_t* __parse_statement_nb (xp_awk_t* awk)
 | 
				
			|||||||
		if (__get_token(awk) == -1) return XP_NULL;
 | 
							if (__get_token(awk) == -1) return XP_NULL;
 | 
				
			||||||
		nde = __parse_exit(awk);
 | 
							nde = __parse_exit(awk);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
/* TODO:
 | 
					/* TODO:
 | 
				
			||||||
	else if (MATCH(awk,TOKEN_DELETE)) 
 | 
						else if (MATCH(awk,TOKEN_DELETE)) 
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@ -1033,7 +1041,165 @@ static xp_awk_nde_t* __parse_basic_expr (xp_awk_t* awk)
 | 
				
			|||||||
	 * <basic expression list> ::= <basic expression> [comma <basic expression>]*
 | 
						 * <basic expression list> ::= <basic expression> [comma <basic expression>]*
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return __parse_equality (awk);
 | 
						return __parse_conditional (awk);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static xp_awk_nde_t* __parse_conditional (xp_awk_t* awk)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return __parse_logical_or (awk);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static xp_awk_nde_t* __parse_logical_or (xp_awk_t* awk)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						xp_awk_nde_exp_t* nde;
 | 
				
			||||||
 | 
						xp_awk_nde_t* left, * right;
 | 
				
			||||||
 | 
						int opcode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						left = __parse_logical_and (awk);
 | 
				
			||||||
 | 
						if (left == XP_NULL) return XP_NULL;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						while (1) 
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (MATCH(awk,TOKEN_LOR)) opcode = XP_AWK_BINOP_LOR;
 | 
				
			||||||
 | 
							else break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (__get_token(awk) == -1) 
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								xp_awk_clrpt (left);
 | 
				
			||||||
 | 
								return XP_NULL; 
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							right = __parse_logical_and (awk);
 | 
				
			||||||
 | 
							if (right == XP_NULL) 
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								xp_awk_clrpt (left);
 | 
				
			||||||
 | 
								return XP_NULL;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// TODO: constant folding -> in other parts of the program also...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							nde = (xp_awk_nde_exp_t*)xp_malloc(xp_sizeof(xp_awk_nde_exp_t));
 | 
				
			||||||
 | 
							if (nde == XP_NULL) 
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								xp_awk_clrpt (right);
 | 
				
			||||||
 | 
								xp_awk_clrpt (left);
 | 
				
			||||||
 | 
								PANIC (awk, XP_AWK_ENOMEM);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							nde->type = XP_AWK_NDE_EXP_BIN;
 | 
				
			||||||
 | 
							nde->next = XP_NULL;
 | 
				
			||||||
 | 
							nde->opcode = opcode; 
 | 
				
			||||||
 | 
							nde->left = left;
 | 
				
			||||||
 | 
							nde->right = right;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							left = (xp_awk_nde_t*)nde;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return left;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static xp_awk_nde_t* __parse_logical_and (xp_awk_t* awk)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						xp_awk_nde_exp_t* nde;
 | 
				
			||||||
 | 
						xp_awk_nde_t* left, * right;
 | 
				
			||||||
 | 
						int opcode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						left = __parse_bitwise_or (awk);
 | 
				
			||||||
 | 
						if (left == XP_NULL) return XP_NULL;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						while (1) 
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (MATCH(awk,TOKEN_LAND)) opcode = XP_AWK_BINOP_LAND;
 | 
				
			||||||
 | 
							else break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (__get_token(awk) == -1) 
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								xp_awk_clrpt (left);
 | 
				
			||||||
 | 
								return XP_NULL; 
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							right = __parse_bitwise_or (awk);
 | 
				
			||||||
 | 
							if (right == XP_NULL) 
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								xp_awk_clrpt (left);
 | 
				
			||||||
 | 
								return XP_NULL;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// TODO: constant folding -> in other parts of the program also...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							nde = (xp_awk_nde_exp_t*)xp_malloc(xp_sizeof(xp_awk_nde_exp_t));
 | 
				
			||||||
 | 
							if (nde == XP_NULL) 
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								xp_awk_clrpt (right);
 | 
				
			||||||
 | 
								xp_awk_clrpt (left);
 | 
				
			||||||
 | 
								PANIC (awk, XP_AWK_ENOMEM);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							nde->type = XP_AWK_NDE_EXP_BIN;
 | 
				
			||||||
 | 
							nde->next = XP_NULL;
 | 
				
			||||||
 | 
							nde->opcode = opcode; 
 | 
				
			||||||
 | 
							nde->left = left;
 | 
				
			||||||
 | 
							nde->right = right;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							left = (xp_awk_nde_t*)nde;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return left;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static xp_awk_nde_t* __parse_bitwise_or (xp_awk_t* awk)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						xp_awk_nde_exp_t* nde;
 | 
				
			||||||
 | 
						xp_awk_nde_t* left, * right;
 | 
				
			||||||
 | 
						int opcode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						left = __parse_bitwise_xor (awk); 
 | 
				
			||||||
 | 
						if (left == XP_NULL) return XP_NULL;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						while (1) 
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (MATCH(awk,TOKEN_BOR)) opcode = XP_AWK_BINOP_BOR;
 | 
				
			||||||
 | 
							else break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (__get_token(awk) == -1) 
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								xp_awk_clrpt (left);
 | 
				
			||||||
 | 
								return XP_NULL; 
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							right = __parse_bitwise_xor (awk);
 | 
				
			||||||
 | 
							if (right == XP_NULL) 
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								xp_awk_clrpt (left);
 | 
				
			||||||
 | 
								return XP_NULL;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// TODO: constant folding -> in other parts of the program also...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							nde = (xp_awk_nde_exp_t*)xp_malloc(xp_sizeof(xp_awk_nde_exp_t));
 | 
				
			||||||
 | 
							if (nde == XP_NULL) 
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								xp_awk_clrpt (right);
 | 
				
			||||||
 | 
								xp_awk_clrpt (left);
 | 
				
			||||||
 | 
								PANIC (awk, XP_AWK_ENOMEM);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							nde->type = XP_AWK_NDE_EXP_BIN;
 | 
				
			||||||
 | 
							nde->next = XP_NULL;
 | 
				
			||||||
 | 
							nde->opcode = opcode; 
 | 
				
			||||||
 | 
							nde->left = left;
 | 
				
			||||||
 | 
							nde->right = right;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							left = (xp_awk_nde_t*)nde;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return left;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static xp_awk_nde_t* __parse_bitwise_xor (xp_awk_t* awk)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// TODO:
 | 
				
			||||||
 | 
						return XP_NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static xp_awk_nde_t* __parse_equality (xp_awk_t* awk)
 | 
					static xp_awk_nde_t* __parse_equality (xp_awk_t* awk)
 | 
				
			||||||
@ -2208,6 +2374,36 @@ static int __get_token (xp_awk_t* awk)
 | 
				
			|||||||
			ADD_TOKEN_STR (awk, XP_TEXT("<"));
 | 
								ADD_TOKEN_STR (awk, XP_TEXT("<"));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						else if (c == XP_CHAR('|'))
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							GET_CHAR_TO (awk, c);
 | 
				
			||||||
 | 
							if (c == XP_CHAR('|'))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								SET_TOKEN_TYPE (awk, TOKEN_LOR);
 | 
				
			||||||
 | 
								ADD_TOKEN_STR (awk, XP_TEXT("||"));
 | 
				
			||||||
 | 
								GET_CHAR_TO (awk, c);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								SET_TOKEN_TYPE (awk, TOKEN_BOR);
 | 
				
			||||||
 | 
								ADD_TOKEN_STR (awk, XP_TEXT("|"));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (c == XP_CHAR('&'))
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							GET_CHAR_TO (awk, c);
 | 
				
			||||||
 | 
							if (c == XP_CHAR('&&'))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								SET_TOKEN_TYPE (awk, TOKEN_LAND);
 | 
				
			||||||
 | 
								ADD_TOKEN_STR (awk, XP_TEXT("&&"));
 | 
				
			||||||
 | 
								GET_CHAR_TO (awk, c);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								SET_TOKEN_TYPE (awk, TOKEN_BAND);
 | 
				
			||||||
 | 
								ADD_TOKEN_STR (awk, XP_TEXT("&"));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	else if (c == XP_CHAR('+')) 
 | 
						else if (c == XP_CHAR('+')) 
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		GET_CHAR_TO (awk, c);
 | 
							GET_CHAR_TO (awk, c);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * $Id: run.h,v 1.1 2006-03-07 16:02:58 bacon Exp $
 | 
					 * $Id: run.h,v 1.2 2006-03-29 16:37:31 bacon Exp $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _XP_AWK_RUN_H_
 | 
					#ifndef _XP_AWK_RUN_H_
 | 
				
			||||||
@ -21,6 +21,10 @@ struct xp_awk_frm_t
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
enum 
 | 
					enum 
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						XP_AWK_BINOP_LOR,
 | 
				
			||||||
 | 
						XP_AWK_BINOP_LAND,
 | 
				
			||||||
 | 
						XP_AWK_BINOP_BOR,
 | 
				
			||||||
 | 
						XP_AWK_BINOP_BAND,
 | 
				
			||||||
	XP_AWK_BINOP_PLUS,
 | 
						XP_AWK_BINOP_PLUS,
 | 
				
			||||||
	XP_AWK_BINOP_MINUS,
 | 
						XP_AWK_BINOP_MINUS,
 | 
				
			||||||
	XP_AWK_BINOP_MUL,
 | 
						XP_AWK_BINOP_MUL,
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										25
									
								
								ase/awk/sa.c
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								ase/awk/sa.c
									
									
									
									
									
								
							@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * $Id: sa.c,v 1.10 2006-03-27 14:40:58 bacon Exp $
 | 
					 * $Id: sa.c,v 1.11 2006-03-29 16:37:31 bacon Exp $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <xp/awk/awk.h>
 | 
					#include <xp/awk/awk.h>
 | 
				
			||||||
@ -8,6 +8,13 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static xp_char_t* __adjust_format (const xp_char_t* format);
 | 
					static xp_char_t* __adjust_format (const xp_char_t* format);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					xp_size_t xp_strlen (const xp_char_t* str)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						const xp_char_t* p = str;
 | 
				
			||||||
 | 
						while (*p != XP_CHAR('\0')) p++;
 | 
				
			||||||
 | 
						return p - str;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
xp_char_t* xp_strdup (const xp_char_t* str)
 | 
					xp_char_t* xp_strdup (const xp_char_t* str)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	xp_char_t* tmp;
 | 
						xp_char_t* tmp;
 | 
				
			||||||
@ -31,6 +38,13 @@ xp_char_t* xp_strxdup (const xp_char_t* str, xp_size_t len)
 | 
				
			|||||||
	return tmp;
 | 
						return tmp;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					xp_size_t xp_strcpy (xp_char_t* buf, const xp_char_t* str)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						xp_char_t* org = buf;
 | 
				
			||||||
 | 
						while ((*buf++ = *str++) != XP_CHAR('\0'));
 | 
				
			||||||
 | 
						return buf - org - 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
xp_size_t xp_strxncpy (
 | 
					xp_size_t xp_strxncpy (
 | 
				
			||||||
	xp_char_t* buf, xp_size_t bsz, const xp_char_t* str, xp_size_t len)
 | 
						xp_char_t* buf, xp_size_t bsz, const xp_char_t* str, xp_size_t len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -44,6 +58,15 @@ xp_size_t xp_strxncpy (
 | 
				
			|||||||
	return n;
 | 
						return n;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int xp_strcmp (const xp_char_t* s1, const xp_char_t* s2)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						while (*s1 == *s2 && *s2 != XP_CHAR('\0')) s1++, s2++;
 | 
				
			||||||
 | 
						if (*s1 > *s2) return 1;
 | 
				
			||||||
 | 
						else if (*s1 < *s2) return -1;
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
xp_long_t xp_strtolong (xp_char_t* str)
 | 
					xp_long_t xp_strtolong (xp_char_t* str)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	xp_long_t n = 0;
 | 
						xp_long_t n = 0;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										79
									
								
								ase/awk/sa.h
									
									
									
									
									
								
							
							
						
						
									
										79
									
								
								ase/awk/sa.h
									
									
									
									
									
								
							@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * $Id: sa.h,v 1.14 2006-03-27 11:43:17 bacon Exp $
 | 
					 * $Id: sa.h,v 1.15 2006-03-29 16:37:31 bacon Exp $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _XP_AWK_SA_H_
 | 
					#ifndef _XP_AWK_SA_H_
 | 
				
			||||||
@ -11,29 +11,45 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef __STAND_ALONE 
 | 
					#ifdef __STAND_ALONE 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if !defined(XP_CHAR_IS_MCHAR) && !defined(XP_CHAR_IS_WCHAR)
 | 
				
			||||||
 | 
					#error Neither XP_CHAR_IS_MCHAR nor XP_CHAR_IS_WCHAR is defined.
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <wchar.h>
 | 
					 | 
				
			||||||
#include <wctype.h>
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <stdarg.h>
 | 
					#include <stdarg.h>
 | 
				
			||||||
#include <assert.h>
 | 
					#include <assert.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef XP_CHAR_IS_MCHAR
 | 
				
			||||||
 | 
					#include <ctype.h>
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#include <wchar.h>
 | 
				
			||||||
 | 
					#if !defined(__BEOS__)
 | 
				
			||||||
 | 
					#include <wctype.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define xp_malloc malloc
 | 
					#define xp_malloc malloc
 | 
				
			||||||
#define xp_realloc realloc
 | 
					#define xp_realloc realloc
 | 
				
			||||||
#define xp_free free
 | 
					#define xp_free free
 | 
				
			||||||
#define xp_assert assert
 | 
					#define xp_assert assert
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef XP_CHAR_IS_MCHAR
 | 
				
			||||||
 | 
					#define xp_isdigit isdigit
 | 
				
			||||||
 | 
					#define xp_isalpha isalpha
 | 
				
			||||||
 | 
					#define xp_isalnum isalnum
 | 
				
			||||||
 | 
					#define xp_isspace isspace
 | 
				
			||||||
 | 
					#define xp_toupper toupper
 | 
				
			||||||
 | 
					#define xp_tolower tolower
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
#define xp_isdigit iswdigit
 | 
					#define xp_isdigit iswdigit
 | 
				
			||||||
#define xp_isalpha iswalpha
 | 
					#define xp_isalpha iswalpha
 | 
				
			||||||
#define xp_isalnum iswalnum
 | 
					#define xp_isalnum iswalnum
 | 
				
			||||||
#define xp_isspace iswspace
 | 
					#define xp_isspace iswspace
 | 
				
			||||||
#define xp_toupper towupper
 | 
					#define xp_toupper towupper
 | 
				
			||||||
#define xp_tolower towlower
 | 
					#define xp_tolower towlower
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#define xp_strcpy wcscpy
 | 
					 | 
				
			||||||
#define xp_strcmp wcscmp
 | 
					 | 
				
			||||||
#define xp_strlen wcslen
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define xp_memcpy memcpy
 | 
					#define xp_memcpy memcpy
 | 
				
			||||||
#define xp_memcmp memcmp
 | 
					#define xp_memcmp memcmp
 | 
				
			||||||
@ -45,10 +61,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define xp_main  main
 | 
					#define xp_main  main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define XP_CHAR(c) L##c
 | 
					 | 
				
			||||||
#define XP_TEXT(c) L##c
 | 
					 | 
				
			||||||
#define XP_CHAR_EOF WEOF
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define XP_NULL NULL
 | 
					#define XP_NULL NULL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define xp_sizeof(n)   (sizeof(n))
 | 
					#define xp_sizeof(n)   (sizeof(n))
 | 
				
			||||||
@ -59,25 +71,45 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
typedef unsigned char xp_byte_t;
 | 
					typedef unsigned char xp_byte_t;
 | 
				
			||||||
typedef int xp_bool_t;
 | 
					typedef int xp_bool_t;
 | 
				
			||||||
typedef wchar_t       xp_char_t;
 | 
					 | 
				
			||||||
typedef wint_t        xp_cint_t;
 | 
					 | 
				
			||||||
typedef size_t xp_size_t;
 | 
					typedef size_t xp_size_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(_WIN32) || defined(vms) || defined(__vms)
 | 
					#ifdef XP_CHAR_IS_MCHAR
 | 
				
			||||||
typedef long	xp_ssize_t;
 | 
						typedef char xp_char_t;
 | 
				
			||||||
 | 
						typedef int xp_cint_t;
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
typedef ssize_t xp_ssize_t;
 | 
						typedef wchar_t xp_char_t;
 | 
				
			||||||
 | 
						typedef wint_t xp_cint_t;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if defined(_WIN32) || defined(vms) || defined(__vms)
 | 
				
			||||||
 | 
						typedef long xp_ssize_t;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
						typedef ssize_t xp_ssize_t;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(_WIN32)
 | 
					#if defined(_WIN32)
 | 
				
			||||||
typedef __int64 xp_long_t;
 | 
						typedef __int64 xp_long_t;
 | 
				
			||||||
typedef long double xp_real_t;
 | 
						typedef long double xp_real_t;
 | 
				
			||||||
#elif defined(vax) || defined(__vax)
 | 
					#elif defined(vax) || defined(__vax)
 | 
				
			||||||
typedef long xp_long_t;
 | 
						typedef long xp_long_t;
 | 
				
			||||||
typedef long double xp_real_t;
 | 
						typedef long double xp_real_t;
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
typedef long long xp_long_t;
 | 
						typedef long long xp_long_t;
 | 
				
			||||||
typedef long double xp_real_t;
 | 
						typedef long double xp_real_t;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef XP_CHAR_IS_MCHAR
 | 
				
			||||||
 | 
						#define XP_CHAR(c) c
 | 
				
			||||||
 | 
						#define XP_TEXT(c) c
 | 
				
			||||||
 | 
						#define XP_CHAR_EOF EOF
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
						#define XP_CHAR(c) L##c
 | 
				
			||||||
 | 
						#define XP_TEXT(c) L##c
 | 
				
			||||||
 | 
						#ifdef WEOF
 | 
				
			||||||
 | 
						#define XP_CHAR_EOF WEOF
 | 
				
			||||||
 | 
						#else
 | 
				
			||||||
 | 
						#define XP_CHAR_EOF ((xp_char_t)-1)
 | 
				
			||||||
 | 
						#endif
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define XP_STR_LEN(x)  ((x)->size)
 | 
					#define XP_STR_LEN(x)  ((x)->size)
 | 
				
			||||||
@ -99,12 +131,15 @@ struct xp_str_t
 | 
				
			|||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					xp_size_t xp_strlen (const xp_char_t* str);
 | 
				
			||||||
xp_char_t* xp_strdup (const xp_char_t* str);
 | 
					xp_char_t* xp_strdup (const xp_char_t* str);
 | 
				
			||||||
xp_char_t* xp_strxdup (const xp_char_t* str, xp_size_t len);
 | 
					xp_char_t* xp_strxdup (const xp_char_t* str, xp_size_t len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					xp_size_t xp_strcpy (xp_char_t* buf, const xp_char_t* str);
 | 
				
			||||||
xp_size_t xp_strxncpy (
 | 
					xp_size_t xp_strxncpy (
 | 
				
			||||||
	xp_char_t* buf, xp_size_t bsz, const xp_char_t* str, xp_size_t len);
 | 
						xp_char_t* buf, xp_size_t bsz, const xp_char_t* str, xp_size_t len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int xp_strcmp (const xp_char_t* s1, const xp_char_t* s2);
 | 
				
			||||||
xp_long_t xp_strtolong (xp_char_t* str);
 | 
					xp_long_t xp_strtolong (xp_char_t* str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int xp_printf (const xp_char_t* fmt, ...);
 | 
					int xp_printf (const xp_char_t* fmt, ...);
 | 
				
			||||||
 | 
				
			|||||||
@ -4,7 +4,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static xp_ssize_t process_source (int cmd, void* arg, xp_char_t* data, xp_size_t size)
 | 
					static xp_ssize_t process_source (int cmd, void* arg, xp_char_t* data, xp_size_t size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	wchar_t c;
 | 
						xp_char_t c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch (cmd) {
 | 
						switch (cmd) {
 | 
				
			||||||
	case XP_AWK_IO_OPEN:
 | 
						case XP_AWK_IO_OPEN:
 | 
				
			||||||
@ -13,7 +13,11 @@ static xp_ssize_t process_source (int cmd, void* arg, xp_char_t* data, xp_size_t
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	case XP_AWK_IO_DATA:
 | 
						case XP_AWK_IO_DATA:
 | 
				
			||||||
		if (size <= 0) return -1;
 | 
							if (size <= 0) return -1;
 | 
				
			||||||
 | 
					#ifdef XP_CHAR_IS_MCHAR
 | 
				
			||||||
 | 
							c = fgetc (stdin);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
		c = fgetwc (stdin);
 | 
							c = fgetwc (stdin);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		if (c == XP_CHAR_EOF) return 0;
 | 
							if (c == XP_CHAR_EOF) return 0;
 | 
				
			||||||
		*data = c;
 | 
							*data = c;
 | 
				
			||||||
		return 1;
 | 
							return 1;
 | 
				
			||||||
@ -52,7 +56,11 @@ static xp_ssize_t process_source (int cmd, void* arg, xp_char_t* data, xp_size_t
 | 
				
			|||||||
#include <mcheck.h>
 | 
					#include <mcheck.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef _WIN32
 | 
				
			||||||
int xp_main (int argc, xp_char_t* argv[])
 | 
					int xp_main (int argc, xp_char_t* argv[])
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					int xp_main (int argc, char* argv[])
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	xp_awk_t awk;
 | 
						xp_awk_t awk;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user