From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] Add `scm_c_symbol_length ()' Date: Tue, 01 Jul 2008 14:13:23 +0200 Message-ID: <873amtvm3g.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1214914455 14536 80.91.229.12 (1 Jul 2008 12:14:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 1 Jul 2008 12:14:15 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Jul 01 14:14:57 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KDekx-0002uS-Mc for guile-devel@m.gmane.org; Tue, 01 Jul 2008 14:14:48 +0200 Original-Received: from localhost ([127.0.0.1]:33357 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KDek3-0002Re-Lu for guile-devel@m.gmane.org; Tue, 01 Jul 2008 08:13:51 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KDejz-0002RP-R0 for guile-devel@gnu.org; Tue, 01 Jul 2008 08:13:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KDejx-0002RD-Uf for guile-devel@gnu.org; Tue, 01 Jul 2008 08:13:47 -0400 Original-Received: from [199.232.76.173] (port=57068 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KDejx-0002RA-Qh for guile-devel@gnu.org; Tue, 01 Jul 2008 08:13:45 -0400 Original-Received: from main.gmane.org ([80.91.229.2]:35492 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KDejw-0001cd-CL for guile-devel@gnu.org; Tue, 01 Jul 2008 08:13:45 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1KDejk-000890-Tq for guile-devel@gnu.org; Tue, 01 Jul 2008 12:13:33 +0000 Original-Received: from 193.50.110.120 ([193.50.110.120]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Jul 2008 12:13:32 +0000 Original-Received: from ludo by 193.50.110.120 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 01 Jul 2008 12:13:32 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 274 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 193.50.110.120 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 14 Messidor an 216 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: i686-pc-linux-gnu User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:6erUkAy3kICSvw1kypiT9ydFKIQ= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7346 Archived-At: --=-=-= Hi, Andy pointed out that `scm_i_symbol_length ()' is actually used in places where struct layout strings are manipulated, for instance, so making it internal can be harmful. The attached patch renames it to `scm_c_symbol_length ()' and documents it. I'll apply it if nobody disagrees in the next few days. Thanks, Ludovic. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Add-scm_c_symbol_length.patch Content-Description: The patch >From 5ce6c5667b3930be7a617c27f49c202fd2660eec Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 1 Jul 2008 14:08:07 +0200 Subject: [PATCH] Add `scm_c_symbol_length ()'. --- NEWS | 4 ++++ doc/ref/api-data.texi | 5 +++++ libguile/deprecated.c | 2 +- libguile/gc-mark.c | 4 ++-- libguile/print.c | 6 +++--- libguile/strings.c | 6 +++++- libguile/strings.h | 2 +- libguile/struct.c | 16 ++++++++-------- libguile/symbols.c | 6 +++--- 9 files changed, 32 insertions(+), 19 deletions(-) diff --git a/NEWS b/NEWS index 16b1880..c2c8751 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,10 @@ indicating length of the `scm_t_option' array. Changes in 1.8.6 (since 1.8.5) +* New features (see the manual for details) + +** New convenience function `scm_c_symbol_length ()' + * Bugs fixed ** Internal `scm_i_' functions now have "hidden" linkage with GCC/ELF diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi index b2b5b07..e1db2a6 100755 --- a/doc/ref/api-data.texi +++ b/doc/ref/api-data.texi @@ -4647,6 +4647,11 @@ immediately after creating the Scheme string. In certain cases, Guile can then use @var{str} directly as its internal representation. @end deftypefn +The size of a symbol can also be obtained from C: + +@deftypefn {C Function} size_t scm_c_symbol_length (SCM sym) +Return the number of characters in @var{sym}. +@end deftypefn Finally, some applications, especially those that generate new Scheme code dynamically, need to generate symbols for use in the generated diff --git a/libguile/deprecated.c b/libguile/deprecated.c index da11608..f59a9b1 100644 --- a/libguile/deprecated.c +++ b/libguile/deprecated.c @@ -1220,7 +1220,7 @@ scm_i_deprecated_symbol_length (SCM sym) { scm_c_issue_deprecation_warning ("SCM_SYMBOL_LENGTH is deprecated. Use scm_symbol_to_string."); - return scm_i_symbol_length (sym); + return scm_c_symbol_length (sym); } int diff --git a/libguile/gc-mark.c b/libguile/gc-mark.c index 77f3ec2..f5fa057 100644 --- a/libguile/gc-mark.c +++ b/libguile/gc-mark.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2004, 2005, 2006, 2008 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -232,7 +232,7 @@ scm_gc_mark_dependencies (SCM p) scm_t_bits word0 = SCM_CELL_WORD_0 (ptr) - scm_tc3_struct; scm_t_bits * vtable_data = (scm_t_bits *) word0; SCM layout = SCM_PACK (vtable_data [scm_vtable_index_layout]); - long len = scm_i_symbol_length (layout); + long len = scm_c_symbol_length (layout); const char *fields_desc = scm_i_symbol_chars (layout); scm_t_bits *struct_data = (scm_t_bits *) SCM_STRUCT_DATA (ptr); diff --git a/libguile/print.c b/libguile/print.c index fb9a74e..85d9ca2 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-1999,2000,2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. +/* Copyright (C) 1995-1999,2000,2001, 2002, 2003, 2004, 2006, 2008 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -589,7 +589,7 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate) if (scm_i_symbol_is_interned (exp)) { scm_print_symbol_name (scm_i_symbol_chars (exp), - scm_i_symbol_length (exp), + scm_c_symbol_length (exp), port); scm_remember_upto_here_1 (exp); } @@ -597,7 +597,7 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate) { scm_puts ("#string", 1, 0, 0, #define FUNC_NAME s_scm_symbol_to_string { SCM_VALIDATE_SYMBOL (1, s); - return scm_i_symbol_substring (s, 0, scm_i_symbol_length (s)); + return scm_i_symbol_substring (s, 0, scm_c_symbol_length (s)); } #undef FUNC_NAME -- 1.5.6.1 --=-=-=--