*** empty log message ***

This commit is contained in:
hyung-hwan 2006-08-25 03:31:09 +00:00
parent 503a24f5c1
commit 2cebde672f
3 changed files with 45 additions and 33 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: extio.c,v 1.32 2006-08-24 03:30:07 bacon Exp $
* $Id: extio.c,v 1.33 2006-08-25 03:30:38 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -92,6 +92,7 @@ int xp_awk_readextio (
xp_awk_val_t* rs;
xp_char_t* rs_ptr;
xp_size_t rs_len;
xp_size_t line_len = 0;
xp_assert (in_type >= 0 && in_type <= xp_countof(__in_type_map));
xp_assert (in_type >= 0 && in_type <= xp_countof(__in_mode_map));
@ -138,7 +139,7 @@ int xp_awk_readextio (
p->mode = extio_mode;
p->handle = XP_NULL;
p->in.buf[0] = XP_C('\0');
p->in.buf[0] = XP_T('\0');
p->in.pos = 0;
p->in.len = 0;
p->in.eof = xp_false;
@ -246,12 +247,30 @@ int xp_awk_readextio (
if (rs_ptr == XP_NULL)
{
/* separate by a new line */
if (c == XP_C('\n')) break;
if (c == XP_T('\n')) break;
}
else if (rs_len == 0)
{
/* TODO: */
/* separate by a blank line */
/* TODO: handle different line terminator like \r\n */
if (line_len == 0 && c == XP_T('\n'))
{
if (XP_STR_LEN(buf) <= 0)
{
/* if the record is empty when a blank
* line is encountered, the line
* terminator should not be added to
* the record */
continue;
}
/* when a blank line is encountered,
* it needs to snip off the line
* terminator of the previous line */
/* TODO: handle different line terminator like \r\n */
XP_STR_LEN(buf) -= 1;
break;
}
}
else if (rs_len == 1)
{
@ -269,6 +288,10 @@ int xp_awk_readextio (
ret = -1;
break;
}
/* TODO: handle difference line terminator like \r\n */
if (c == XP_T('\n')) line_len = 0;
else line_len = line_len + 1;
}
if (rs_ptr != XP_NULL && rs->type != XP_AWK_VAL_STR) xp_free (rs_ptr);

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.74 2006-08-23 15:42:16 bacon Exp $
* $Id: awk.c,v 1.75 2006-08-25 03:30:38 bacon Exp $
*/
#include <xp/awk/awk.h>
@ -544,7 +544,7 @@ static int __main (int argc, xp_char_t* argv[])
xp_awk_runcbs_t runcbs;
xp_awk_runios_t runios;
struct src_io src_io = { NULL, NULL };
int opt;
int opt, i, file_count = 0;
if ((awk = xp_awk_open(XP_NULL)) == XP_NULL)
{
@ -556,46 +556,33 @@ static int __main (int argc, xp_char_t* argv[])
XP_AWK_SHADING | XP_AWK_IMPLICIT | XP_AWK_SHIFT |
XP_AWK_EXTIO | XP_AWK_BLOCKLESS | XP_AWK_STRINDEXONE;
if (argc == 2)
for (i = 1; i < argc; i++)
{
#if defined(__STAND_ALONE) && !defined(_WIN32)
if (strcmp(argv[1], "-m") == 0)
if (strcmp(argv[i], "-m") == 0)
#else
if (xp_strcmp(argv[1], XP_T("-m")) == 0)
#endif
{
xp_awk_close (awk);
xp_printf (XP_T("Usage: %s [-m] source_file\n"), argv[0]);
return -1;
}
src_io.input_file = argv[1];
}
else if (argc == 3)
{
#if defined(__STAND_ALONE) && !defined(_WIN32)
if (strcmp(argv[1], "-m") == 0)
#else
if (xp_strcmp(argv[1], XP_T("-m")) == 0)
if (xp_strcmp(argv[i], XP_T("-m")) == 0)
#endif
{
opt |= XP_AWK_RUNMAIN;
}
else
else if (file_count == 0)
{
xp_awk_close (awk);
xp_printf (XP_T("Usage: %s [-m] source_file\n"), argv[0]);
return -1;
src_io.input_file = argv[i];
file_count++;
}
src_io.input_file = argv[2];
else if (file_count == 1)
{
infiles[0] = argv[i];
file_count++;
}
else
{
xp_awk_close (awk);
xp_printf (XP_T("Usage: %s [-m] source_file\n"), argv[0]);
xp_printf (XP_T("Usage: %s [-m] source_file [data_file]\n"), argv[0]);
return -1;
}
}
xp_awk_setopt (awk, opt);

2
ase/test/awk/t32.awk Normal file
View File

@ -0,0 +1,2 @@
BEGIN { RS = ""; }
{ print "record: ", $0; }