unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Bruce Korb <bkorb@veritas.com>
Cc: bkorb@veritas.com
Subject: [PATCH] for strports.c: scm_c_eval_string_from_file_line
Date: Sat, 24 May 2003 13:47:04 -0700	[thread overview]
Message-ID: <3ECFDA48.309D0F5@veritas.com> (raw)

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


             reply	other threads:[~2003-05-24 20:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-24 20:47 Bruce Korb [this message]
2003-06-01 20:00 ` [PATCH] for strports.c: scm_c_eval_string_from_file_line Marius Vollmer
2003-06-01 20:38   ` Bruce Korb
2003-06-09 19:53     ` Marius Vollmer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ECFDA48.309D0F5@veritas.com \
    --to=bkorb@veritas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).