From 1581a54a66e6f745a7e6b09d5e9168cecbfb9cd5 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Mon, 6 Jun 2005 14:43:06 +0000 Subject: [PATCH] mala_engine_exception git-archimport-id: chth@gmx.net--2004/mala-glibc--devel--0.2--patch-59 --- ChangeLog | 12 ++++++++++++ engine/engine.c | 45 +++++++++++++++++++++++++++------------------ engine/engine.h | 9 ++++++++- engine/mala_types.h | 2 +- 4 files changed, 48 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 009ade4..f670710 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,18 @@ # arch-tag: automatic-ChangeLog--chth@gmx.net--2004/mala-glibc--devel--0.2 # +2005-06-06 14:43:06 GMT Christian Thaeter patch-59 + + Summary: + mala_engine_exception + Revision: + mala-glibc--devel--0.2--patch-59 + + + modified files: + ChangeLog engine/engine.c engine/engine.h engine/mala_types.h + + 2005-06-01 16:05:04 GMT Christian Thaeter patch-58 Summary: diff --git a/engine/engine.c b/engine/engine.c index d3e48f6..a7fc235 100644 --- a/engine/engine.c +++ b/engine/engine.c @@ -42,6 +42,7 @@ static const char * mala_common_strings []= "--ENVSUBST", "--SETENV", "--SECTION", + "--HERE", "--FLAG-LITERAL-EXPANSION", "--FLAG-EXCLAM-EXPANSION", "--FLAG-NO-EXPANSION", @@ -53,6 +54,7 @@ static const char * mala_common_strings []= "--FLAG-UNDERSCORE-EXPANSION", "--FLAG-BRACKET-EXPANSION", "--FLAG-ASSIGN-CONTRACTION", + "--ERROR-MISSING-ARGUMENT", NULL }; @@ -427,14 +429,36 @@ mala_engine_eval (MalaEngine self, MalaStringListNode_ref pptr) if (act) self->state = mala_action_execute(act, pptr, self); - else if (self->state == MALA_EXCEPTION) + + if (self->state == MALA_EXCEPTION) self->state = MALA_ENOACTION; - else - self->state = MALA_LITERAL; + return self->state; } int +mala_engine_exception (MalaEngine self, + MalaStringListNode_ref pptr, + MalaStringListNode here, + MalaString except) +{ + MalaStringListNode tmp; + + if (!mala_stringlist_before_new (&self->program, *pptr, except)) + return self->state = MALA_EALLOC; + + if (!mala_stringlist_after_new (&self->program, here, + self->common_string[MALA_STRING_HERE])) + return self->state = MALA_EALLOC; + + *pptr = tmp; + + /*TODO self-state needs to be preserved somehow?*/ + return self->state = MALA_EXCEPTION; +} + + +int mala_engine_expand (MalaEngine self, MalaStringList list, MalaStringListNode_ref pptr) { int ret = 0; @@ -1170,21 +1194,6 @@ mala_engine_argv (MalaEngine self, int n) -int -mala_engine_exception (MalaEngine self, MalaStringListNode begin, MalaStringListNode end, const char * excpt) -{ - self->state = mala_strlist_insert_before (begin, excpt); - if (self->state > MALA_EFAULT) - return self->state; - - self->state = mala_strlist_insert_after_cat2 (end, "--HERE", excpt+1); - if (self->state > MALA_EFAULT) - return self->state; - - return self->state = MALA_EXCEPTION; -} - - MalaAction mala_engine_action_new (MalaEngine self, t_uchar** name, void** data, MalaParserFunc parser, MalaDataDestructor destructor) diff --git a/engine/engine.h b/engine/engine.h index 7444982..cf469b4 100644 --- a/engine/engine.h +++ b/engine/engine.h @@ -39,6 +39,7 @@ enum mala_common_strings_enum MALA_STRING_ENVSUBST, MALA_STRING_SETENV, MALA_STRING_SECTION, + MALA_STRING_HERE, MALA_STRING_FLAG_LITERAL_EXPANSION, MALA_STRING_FLAG_EXCLAM_EXPANSION, MALA_STRING_FLAG_NO_EXPANSION, @@ -50,6 +51,7 @@ enum mala_common_strings_enum MALA_STRING_FLAG_UNDERSCORE_EXPANSION, MALA_STRING_FLAG_BRACKET_EXPANSION, MALA_STRING_FLAG_ASSIGN_CONTRACTION, + MALA_STRING_ERROR_MISSING_ARGUMENT, MALA_MAX_COMMON_STRING }; @@ -102,11 +104,16 @@ mala_engine_new_main (int (*initfunc) (MalaEngine), void mala_engine_free (MalaEngine self); - int mala_engine_actions_register (MalaEngine, MalaActionInit); int +mala_engine_exception (MalaEngine self, + MalaStringListNode_ref pptr, + MalaStringListNode here, + MalaString message); + +int mala_engine_macro_define (MalaEngine self, const char * name, int argc, char **argv); int diff --git a/engine/mala_types.h b/engine/mala_types.h index 3f28dbd..17597f5 100644 --- a/engine/mala_types.h +++ b/engine/mala_types.h @@ -43,7 +43,7 @@ enum mala_state_enum MALA_FAILURE, /* last comand returned false */ MALA_EXCEPTION, /* some error occured (in MaLa code) */ MALA_LITERAL, /* dont evaluate the next argument */ - MALA_BLOCK, /* next command is a (maybe nested) --BEGIN --END block */ + // MALA_BLOCK, /* next command is a (maybe nested) --BEGIN --END block */ MALA_EFAULT, /* everything beyond are runtime errors, which may be handled by the userprogram */ MALA_ENOACTION, /* no action found, exception falltrough */ -- 2.11.4.GIT