unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] for strports.c: scm_c_eval_string_from_file_line
@ 2003-05-24 20:47 Bruce Korb
  2003-06-01 20:00 ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: Bruce Korb @ 2003-05-24 20:47 UTC (permalink / raw)
  Cc: bkorb

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  <bkorb@gnu.org>

	* 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 */


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-06-09 19:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-24 20:47 [PATCH] for strports.c: scm_c_eval_string_from_file_line Bruce Korb
2003-06-01 20:00 ` Marius Vollmer
2003-06-01 20:38   ` Bruce Korb
2003-06-09 19:53     ` Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).