touched up error handling in sed
This commit is contained in:
@ -24,13 +24,13 @@ static const qse_char_t* geterrstr (int errnum)
|
||||
{
|
||||
QSE_T("no error"),
|
||||
QSE_T("out of memory"),
|
||||
QSE_T("too much text"),
|
||||
QSE_T("command ${0} not recognized"),
|
||||
QSE_T("command '${0}' not recognized"),
|
||||
QSE_T("command code missing"),
|
||||
QSE_T("command ${0} not terminated properly"),
|
||||
QSE_T("regular expression build error"),
|
||||
QSE_T("regular expression match error"),
|
||||
QSE_T("address 1 prohibited"),
|
||||
QSE_T("command '${0}' not terminated properly"),
|
||||
QSE_T("regular expression '${0}' incomplete"),
|
||||
QSE_T("failed to compile regular expression '${0}'"),
|
||||
QSE_T("failed to match regular expression"),
|
||||
QSE_T("address 1 prohibited for '${0}'"),
|
||||
QSE_T("address 2 prohibited"),
|
||||
QSE_T("invalid step address"),
|
||||
QSE_T("a new line expected"),
|
||||
@ -39,8 +39,8 @@ static const qse_char_t* geterrstr (int errnum)
|
||||
QSE_T("garbage after a backslash"),
|
||||
QSE_T("a semicolon expected"),
|
||||
QSE_T("empty label name"),
|
||||
QSE_T("duplicate label name ${0}"),
|
||||
QSE_T("label ${0} not found"),
|
||||
QSE_T("duplicate label name '${0}'"),
|
||||
QSE_T("label '${0}' not found"),
|
||||
QSE_T("empty file name"),
|
||||
QSE_T("illegal file name"),
|
||||
QSE_T("strings in translation set not the same length"),
|
||||
|
@ -262,7 +262,10 @@ static void* compile_rex (qse_sed_t* sed, qse_char_t rxend)
|
||||
c = NXTSC (sed);
|
||||
if (c == QSE_CHAR_EOF || c == QSE_T('\n'))
|
||||
{
|
||||
sed->errnum = QSE_SED_ETMTXT;
|
||||
SETERR1 (sed, QSE_SED_EREXIC, 0,
|
||||
QSE_STR_PTR(&sed->rexbuf),
|
||||
QSE_STR_LEN(&sed->rexbuf)
|
||||
);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
@ -274,7 +277,10 @@ static void* compile_rex (qse_sed_t* sed, qse_char_t rxend)
|
||||
c = CURSC (sed);
|
||||
if (c == QSE_CHAR_EOF || c == QSE_T('\n'))
|
||||
{
|
||||
sed->errnum = QSE_SED_ETMTXT;
|
||||
SETERR1 (sed, QSE_SED_EREXIC, 0,
|
||||
QSE_STR_PTR(&sed->rexbuf),
|
||||
QSE_STR_LEN(&sed->rexbuf)
|
||||
);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
@ -298,7 +304,10 @@ static void* compile_rex (qse_sed_t* sed, qse_char_t rxend)
|
||||
);
|
||||
if (code == QSE_NULL)
|
||||
{
|
||||
sed->errnum = QSE_SED_EREXBL;
|
||||
SETERR1 (sed, QSE_SED_EREXBL, 0,
|
||||
QSE_STR_PTR(&sed->rexbuf),
|
||||
QSE_STR_LEN(&sed->rexbuf)
|
||||
);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
@ -343,9 +352,7 @@ static qse_sed_adr_t* get_address (qse_sed_t* sed, qse_sed_adr_t* a)
|
||||
c = NXTSC (sed);
|
||||
if (c == QSE_CHAR_EOF || c == QSE_T('\n'))
|
||||
{
|
||||
/* TODO: change error code -
|
||||
* unterminated address regular expression */
|
||||
sed->errnum = QSE_SED_ETMTXT;
|
||||
SETERR1 (sed, QSE_SED_EREXIC, 0, QSE_T(""), 0);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
@ -811,7 +818,10 @@ static int get_subst (qse_sed_t* sed, qse_sed_cmd_t* cmd)
|
||||
);
|
||||
if (cmd->u.subst.rex == QSE_NULL)
|
||||
{
|
||||
sed->errnum = QSE_SED_EREXBL;
|
||||
SETERR1 (sed, QSE_SED_EREXBL, 0,
|
||||
QSE_STR_PTR(t[0]),
|
||||
QSE_STR_LEN(t[0])
|
||||
);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
@ -968,7 +978,7 @@ restart:
|
||||
if (cmd->a1.type != QSE_SED_ADR_NONE)
|
||||
{
|
||||
/* label cannot have an address */
|
||||
sed->errnum = QSE_SED_EA1PHB;
|
||||
SETERR1 (sed, QSE_SED_EA1PHB, 0, &cmd->type, 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user