interim commit

This commit is contained in:
hyung-hwan 2009-03-03 08:13:47 +00:00
parent a66c49812c
commit fc2877524c
4 changed files with 40 additions and 27 deletions

View File

@ -35,7 +35,8 @@ enum qse_sed_errnum_t
QSE_SED_EREXBL, /* regular expression build error */
QSE_SED_EA1PHB, /* address 1 prohibited */
QSE_SED_EA2PHB, /* address 2 prohibited */
QSE_SED_ENEWLN /* a new line is expected */
QSE_SED_ENEWLN, /* a new line is expected */
QSE_SED_EBASLA /* \ is expected */
};
typedef struct qse_sed_t qse_sed_t;

View File

@ -33,7 +33,7 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = lib/utl
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \

View File

@ -88,6 +88,10 @@ void qse_sed_fini (qse_sed_t* sed)
(((sed)->src.cur < (sed)->src.end)? *(sed)->src.cur: QSE_CHAR_EOF)
/* advance the current pointer of the source code */
#define ADVSCP(sed) ((sed)->src.cur++)
#define NXTSC(sed) \
(((++(sed)->src.cur) < (sed)->src.end)? *(sed)->src.cur: QSE_CHAR_EOF)
#define ISSPACE(c) (c == QSE_T(' ') || c == QSE_T('\t'))
static void* compile_regex (qse_sed_t* sed, qse_char_t seof)
{
@ -198,7 +202,6 @@ static int command (qse_sed_t* sed)
qse_sed_c_t* cmd = sed->cmd.cur;
c = CURSC (sed);
switch (c)
{
default:
@ -247,24 +250,42 @@ static int command (qse_sed_t* sed)
return -1;
}
c = CURSC (sed);
if (c == QSE_T('\\'))
c = NXTSC (sed);
while (ISSPACE(c)) c = NXTSC (sed);
if (c == QSE_CHAR_EOF)
{
ADVSCP (sed);
c = CURSC (sed);
/* TODO: something wrong??? */
}
if (c != QSE_T('\n')) /* TODO: handle \r\n or others */
{
/* new line is expected */
sed->errnum = QSE_SED_ENEWLN;
/* expected \ after 'a' */
sed->errnum = QSE_SED_EBASLA;
return -1;
}
/* TODO: get the next line... */
do
{
if (c == QSE_T('\n'))
{
ADVSCP (sed);
break;
}
if (c == QSE_T('\\'))
{
c = NXTSC (sed);
if (c == QSE_CHAR_EOF) break;
if (c == QSE_T('\n'))
{
/* TODO: support different line end scheme... */
c = NXTSC (sed);
continue;
}
}
/* TODO: add c to cmd->u.text */
c = NXTSC (sed);
}
while (c != QSE_CHAR_EOF);
break;
case QSE_T('c'):
@ -357,11 +378,7 @@ static int compile_source (
c = CURSC (sed);
/* skip white spaces */
while (c == QSE_T(' ') || c == QSE_T('\t'))
{
ADVSCP (sed);
c = CURSC (sed);
}
while (ISSPACE(c)) c = NXTSC (sed);
/* check if it has reached the end or is commented */
if (c == QSE_CHAR_EOF || c == QSE_T('#')) break;
@ -401,11 +418,7 @@ static int compile_source (
}
/* skip white spaces */
while (c == QSE_T(' ') || c == QSE_T('\t'))
{
ADVSCP (sed);
c = CURSC (sed);
}
while (ISSPACE(c)) c = NXTSC (sed);
if (c == QSE_T('!'))
{

View File

@ -53,7 +53,6 @@ struct qse_sed_c_t
void* rex; /* regular expression */
qse_char_t* text; /* added text or file name */
qse_sed_c_t* lbl; /* destination command of branch */
} u;
qse_char_t* rhs; /* right-hand side of sustitution */