*** 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> #include <xp/awk/awk_i.h>
@ -341,7 +341,7 @@ static int __print_expression (xp_awk_nde_t* nde)
if (px->cmd != XP_NULL) if (px->cmd != XP_NULL)
{ {
__print_expression (px->cmd); __print_expression (px->cmd);
xp_printf (XP_TEXT("|")); xp_printf (XP_TEXT(" | "));
} }
xp_printf (XP_TEXT("getline")); xp_printf (XP_TEXT("getline"));
@ -353,7 +353,7 @@ static int __print_expression (xp_awk_nde_t* nde)
if (px->out != XP_NULL) if (px->out != XP_NULL)
{ {
xp_printf (XP_TEXT("<")); xp_printf (XP_TEXT(" < "));
__print_expression (px->out); __print_expression (px->out);
} }
break; 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> #include <xp/awk/awk.h>
@ -35,28 +35,35 @@ static xp_ssize_t process_source (
{ {
xp_char_t c; xp_char_t c;
switch (cmd) { switch (cmd)
case XP_AWK_INPUT_OPEN: {
case XP_AWK_INPUT_CLOSE: case XP_AWK_INPUT_OPEN:
case XP_AWK_INPUT_NEXT: case XP_AWK_INPUT_CLOSE:
return 0; case XP_AWK_INPUT_NEXT:
{
return 0;
}
case XP_AWK_INPUT_DATA: case XP_AWK_INPUT_DATA:
if (size <= 0) return -1; {
#ifdef XP_CHAR_IS_MCHAR if (size <= 0) return -1;
c = fgetc (stdin); #ifdef XP_CHAR_IS_MCHAR
#else c = fgetc (stdin);
c = fgetwc (stdin); #else
#endif c = fgetwc (stdin);
if (c == XP_CHAR_EOF) return 0; #endif
*data = c; if (c == XP_CHAR_EOF) return 0;
return 1; *data = c;
return 1;
}
case XP_AWK_OUTPUT_OPEN: case XP_AWK_OUTPUT_OPEN:
case XP_AWK_OUTPUT_CLOSE: case XP_AWK_OUTPUT_CLOSE:
case XP_AWK_OUTPUT_NEXT: case XP_AWK_OUTPUT_NEXT:
case XP_AWK_OUTPUT_DATA: case XP_AWK_OUTPUT_DATA:
return 0; {
return 0;
}
} }
return -1; return -1;
@ -74,37 +81,48 @@ static xp_ssize_t process_data (
struct data_io* io = (struct data_io*)arg; struct data_io* io = (struct data_io*)arg;
xp_char_t c; xp_char_t c;
switch (cmd) { switch (cmd)
case XP_AWK_INPUT_OPEN: {
io->input_handle = fopen (io->input_file, "r"); case XP_AWK_INPUT_OPEN:
if (io->input_handle == NULL) return -1; {
return 0; io->input_handle = fopen (io->input_file, "r");
if (io->input_handle == NULL) return -1;
return 0;
}
case XP_AWK_INPUT_CLOSE: case XP_AWK_INPUT_CLOSE:
fclose (io->input_handle); {
io->input_handle = NULL; fclose (io->input_handle);
return 0; io->input_handle = NULL;
return 0;
}
case XP_AWK_INPUT_NEXT: case XP_AWK_INPUT_NEXT:
/* input switching not supported for the time being... */ {
return -1; /* input switching not supported for the time being... */
return -1;
}
case XP_AWK_INPUT_DATA: case XP_AWK_INPUT_DATA:
if (size <= 0) return -1; {
#ifdef XP_CHAR_IS_MCHAR if (size <= 0) return -1;
c = fgetc (io->input_handle); #ifdef XP_CHAR_IS_MCHAR
#else c = fgetc (io->input_handle);
c = fgetwc (io->input_handle); #else
#endif c = fgetwc (io->input_handle);
if (c == XP_CHAR_EOF) return 0; #endif
*data = c; if (c == XP_CHAR_EOF) return 0;
return 1; *data = c;
return 1;
}
case XP_AWK_OUTPUT_OPEN: case XP_AWK_OUTPUT_OPEN:
case XP_AWK_OUTPUT_CLOSE: case XP_AWK_OUTPUT_CLOSE:
case XP_AWK_OUTPUT_NEXT: case XP_AWK_OUTPUT_NEXT:
case XP_AWK_OUTPUT_DATA: case XP_AWK_OUTPUT_DATA:
return -1; {
return -1;
}
} }
return -1; return -1;