[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] for strports.c: scm_c_eval_string_from_file_line
From: |
Bruce Korb |
Subject: |
[PATCH] for strports.c: scm_c_eval_string_from_file_line |
Date: |
Sat, 24 May 2003 13:47:04 -0700 |
Hi all,
I established my own private MTA, so I can now once again get email
through to gnu.org. Some of you have already seen this, so here it
is again. Sorry.
BTW, "inner_eval_string" is local to strports.c.
2003-05-24 Bruce Korb <address@hidden>
* guile-core/libguile/strports.c(scm_c_eval_string_from_file_line):
new procedure. Facilitate error messages for applications that
extract scheme code from their input files.
* guile-core/libguile/strports.h: declare the procedure.
Index: strports.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/strports.c,v
retrieving revision 1.98
diff -u -p -r1.98 strports.c
--- strports.c 24 Apr 2003 16:02:04 -0000 1.98
+++ strports.c 24 May 2003 20:29:38 -0000
@@ -474,6 +474,37 @@ scm_eval_string (SCM string)
return scm_eval_string_in_module (string, SCM_UNDEFINED);
}
+/* Given a NUL-terminated string EXPR containing Scheme program text,
+ a NUL terminated source file name and a line number,
+ evaluate it, and return the result of the last expression evaluated. */
+SCM
+scm_c_eval_string_from_file_line (const char *pzexpr, const char *pzfile,
+ int line)
+{
+ SCM port;
+
+ {
+ static const char z_ex[] = "c-eval-string-from-file-line";
+ SCM expr = scm_makfrom0str (pzexpr);
+ port = scm_mkstrport (SCM_INUM0, expr, SCM_OPN | SCM_RDNG, z_ex);
+ }
+
+ {
+ static SCM file = SCM_UNDEFINED;
+ scm_t_port* pt = SCM_PTAB_ENTRY (port);
+
+ if ( (file == SCM_UNDEFINED)
+ || (strcmp (SCM_CHARS (file), pzfile) != 0) )
+ file = scm_makfrom0str (pzfile); /* only do this if name changes */
+
+ pt->line_number = line - 1; /* zero-based line numbering */
+ pt->file_name = file;
+ }
+
+ return scm_c_call_with_current_module(
+ SCM_UNDEFINED, inner_eval_string, (void*)port );
+}
+
static scm_t_bits
scm_make_stptob ()
{
Index: strports.h
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/strports.h,v
retrieving revision 1.26
diff -u -p -r1.26 strports.h
--- strports.h 5 Apr 2003 19:10:22 -0000 1.26
+++ strports.h 24 May 2003 20:29:38 -0000
@@ -56,6 +56,8 @@ SCM_API SCM scm_c_eval_string_in_module
SCM_API SCM scm_eval_string (SCM string);
SCM_API SCM scm_eval_string_in_module (SCM string, SCM module);
SCM_API void scm_init_strports (void);
+SCM_API SCM scm_c_eval_string_from_file_line (const char *expr,
+ const char *file, int lineno);
#endif /* SCM_STRPORTS_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] for strports.c: scm_c_eval_string_from_file_line,
Bruce Korb <=