Recovering from errors in MPlib

Nicola <[email protected]>
Newsgroups gmane.comp.tex.metapost
Message-ID <[email protected]>
Hi,
when using MPlib, is it possible to recover from errors?

In other words, when the current status of the MP instance is
mp_error_message_issued, is it possible to return to a status
where commands are accepted again? If so, how?

I ask, because whatever command I send after an error,
the status doesn't change. Maybe I'm doing something wrong.

This is the function I'm using:

void eval(MP mp) {
   int history = mp_execute(mp, line_read, strlen(line_read));
   mp_run_data *result = mp_rundata(mp); // TODO: I guess I must free this
   printf("%s\n", result->term_out.data);
   printf("DEBUG: mp_status = %d\n", mp_status(mp));
   switch (history) {
     case mp_spotless:
       printf("OK\n");
       break;
     case mp_warning_issued:
       printf("Warning\n");
       break;
     case mp_error_message_issued:
       printf("Error\n");
       break;
     case mp_fatal_error_stop:
       printf("Fatal error\n");
       break;
     case mp_system_error_stop:
       printf("System error\n");
       break;
     default:
       printf("Default\n");
   }
}

Nicola

--
http://tug.org/metapost/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.