*** empty log message ***

This commit is contained in:
hyung-hwan 2006-06-13 04:26:24 +00:00
parent 8dd2ceb931
commit 6ddd8df782
2 changed files with 69 additions and 51 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: tree.c,v 1.50 2006-06-12 15:11:02 bacon Exp $
* $Id: tree.c,v 1.51 2006-06-13 04:26:24 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -341,7 +341,7 @@ static int __print_expression (xp_awk_nde_t* nde)
if (px->cmd != XP_NULL)
{
__print_expression (px->cmd);
xp_printf (XP_TEXT("|"));
xp_printf (XP_TEXT(" | "));
}
xp_printf (XP_TEXT("getline"));
@ -353,7 +353,7 @@ static int __print_expression (xp_awk_nde_t* nde)
if (px->out != XP_NULL)
{
xp_printf (XP_TEXT("<"));
xp_printf (XP_TEXT(" < "));
__print_expression (px->out);
}
break;

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.34 2006-05-13 16:33:07 bacon Exp $
* $Id: awk.c,v 1.35 2006-06-13 04:26:24 bacon Exp $
*/
#include <xp/awk/awk.h>
@ -35,29 +35,36 @@ static xp_ssize_t process_source (
{
xp_char_t c;
switch (cmd) {
switch (cmd)
{
case XP_AWK_INPUT_OPEN:
case XP_AWK_INPUT_CLOSE:
case XP_AWK_INPUT_NEXT:
{
return 0;
}
case XP_AWK_INPUT_DATA:
{
if (size <= 0) return -1;
#ifdef XP_CHAR_IS_MCHAR
#ifdef XP_CHAR_IS_MCHAR
c = fgetc (stdin);
#else
#else
c = fgetwc (stdin);
#endif
#endif
if (c == XP_CHAR_EOF) return 0;
*data = c;
return 1;
}
case XP_AWK_OUTPUT_OPEN:
case XP_AWK_OUTPUT_CLOSE:
case XP_AWK_OUTPUT_NEXT:
case XP_AWK_OUTPUT_DATA:
{
return 0;
}
}
return -1;
}
@ -74,38 +81,49 @@ static xp_ssize_t process_data (
struct data_io* io = (struct data_io*)arg;
xp_char_t c;
switch (cmd) {
switch (cmd)
{
case XP_AWK_INPUT_OPEN:
{
io->input_handle = fopen (io->input_file, "r");
if (io->input_handle == NULL) return -1;
return 0;
}
case XP_AWK_INPUT_CLOSE:
{
fclose (io->input_handle);
io->input_handle = NULL;
return 0;
}
case XP_AWK_INPUT_NEXT:
{
/* input switching not supported for the time being... */
return -1;
}
case XP_AWK_INPUT_DATA:
{
if (size <= 0) return -1;
#ifdef XP_CHAR_IS_MCHAR
#ifdef XP_CHAR_IS_MCHAR
c = fgetc (io->input_handle);
#else
#else
c = fgetwc (io->input_handle);
#endif
#endif
if (c == XP_CHAR_EOF) return 0;
*data = c;
return 1;
}
case XP_AWK_OUTPUT_OPEN:
case XP_AWK_OUTPUT_CLOSE:
case XP_AWK_OUTPUT_NEXT:
case XP_AWK_OUTPUT_DATA:
{
return -1;
}
}
return -1;
}