From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Bruce Korb Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] for strports.c: scm_c_eval_string_from_file_line Date: Sat, 24 May 2003 13:47:04 -0700 Organization: Home Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <3ECFDA48.309D0F5@veritas.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1053808808 4929 80.91.224.249 (24 May 2003 20:40:08 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 24 May 2003 20:40:08 +0000 (UTC) Cc: bkorb@veritas.com Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat May 24 22:40:00 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19Jfo8-0001GQ-00 for ; Sat, 24 May 2003 22:40:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19JfoO-0004zP-5c for guile-devel@m.gmane.org; Sat, 24 May 2003 16:40:16 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19Jfny-00046S-5d for guile-devel@gnu.org; Sat, 24 May 2003 16:39:50 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19JfnP-0002i2-5f for guile-devel@gnu.org; Sat, 24 May 2003 16:39:16 -0400 Original-Received: from bay-bridge.veritas.com ([143.127.3.10] helo=bach.veritas.com) by monty-python.gnu.org with esmtp (Exim 4.20) id 19JfmY-0002DQ-Ng for guile-devel@gnu.org; Sat, 24 May 2003 16:38:23 -0400 Original-Received: from veritas.com (localhost [127.0.0.1]) by bach.veritas.com (Postfix) with ESMTP id 572CC24AD8; Sat, 24 May 2003 13:47:04 -0700 (PDT) X-Mailer: Mozilla 4.8 [en] (X11; U; Linux 2.4.19-4GB i686) X-Accept-Language: en Original-To: guile development X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2442 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2442 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 * 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