On Fri, 8 Aug 2008 12:23:49 +0200, "Bernd Jendrissek"
<[EMAIL PROTECTED]> wrote:
> On Thu, Aug 7, 2008 at 8:47 AM, Peter TB Brett <[EMAIL PROTECTED]>
wrote:
>> On Thursday 07 August 2008 02:35:01 Bernd Jendrissek wrote:
>>
>> +  interpreter = scm_c_lookup("invoke-macro");
>> +  interpreter = scm_variable_ref(interpreter);
>> +  if (scm_is_true(scm_procedure_p(interpreter))) {
>> +    scm_call_1(interpreter,
>> scm_from_locale_string(gtk_entry_get_text(entry)));
>> +  } else {
>> +    g_warning(_("invoke-macro is not a scheme procedure!\n"));
>> +  }
>>
>> Shouldn't you catch any errors from the first two lines? At the very
> least, if
>> the 'invoke-macro' symbol is undefined, scm_c_lookup will signal an
> error
>> condition, won't it?
> 
> I was rougly copying the code in
> gschem/src/g_keys.c:g_keys_dump_keymap() and convinced myself (and now
> hoping to convince you) that trying to catch errors here is not so
> critical:
> 
> 1. There is a definition of (invoke-macro STR) in system-gschemrc.
> 2. Causing the code above to fail requires:
> 2a. Awareness of (invoke-macro STR)
> 2b. The act of overriding system-gschemrc's definition, brokenly.

How about this: in C, assemble a SCM structure which looks like:

(invoke-macro "user string")

Then just call that via g_scm_eval_protected()? That way you can just use
eval-string in invoke-macro, and any user who hacks it around doesn't need
to know that their code needs to be wrapped in one of our special
protection functions -- and you won't have to do -any- error checking in
x_window_invoke_macro() because errors will automagically get logged for
you.

                                  Peter



_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev

Reply via email to