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