From 47463c8fd76cc66f17053403df2ed7fd61d9a511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 5 Jul 2008 20:10:44 +0200 Subject: [PATCH] Add `scm_c_symbol_length ()'. --- NEWS | 4 ++++ doc/ref/ChangeLog | 4 ++++ doc/ref/api-data.texi | 5 +++++ libguile/ChangeLog | 5 +++++ libguile/strings.c | 10 ++++++++++ libguile/strings.h | 1 + 6 files changed, 29 insertions(+) diff --git a/NEWS b/NEWS index 55addf75a..2c93494a4 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,10 @@ Please send Guile bug reports to bug-guile@gnu.org. 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/ChangeLog b/doc/ref/ChangeLog index f67c639d0..95a2491bd 100644 --- a/doc/ref/ChangeLog +++ b/doc/ref/ChangeLog @@ -1,3 +1,7 @@ +2008-07-05 Ludovic Courtès + + * api-data.texi (Symbol Primitives): Add `scm_c_symbol_length ()'. + 2008-06-28 Ludovic Courtès * api-modules.texi (Using Guile Modules): Substitute "syntax diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi index 2552b92f4..cabe2c5c8 100755 --- a/doc/ref/api-data.texi +++ b/doc/ref/api-data.texi @@ -4640,6 +4640,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/ChangeLog b/libguile/ChangeLog index 805cfa81d..5c30574a0 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,8 @@ +2008-07-05 Ludovic Courtès + + * strings.c (scm_c_symbol_length): New function. + * strings.h (scm_c_symbol_length): New declaration. + 2008-07-04 Ludovic Courtès * __scm.h (SCM_INTERNAL): Add `extern' so that these symbols are diff --git a/libguile/strings.c b/libguile/strings.c index c322132fd..c9b08a05b 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -452,6 +452,16 @@ scm_i_symbol_length (SCM sym) return STRINGBUF_LENGTH (SYMBOL_STRINGBUF (sym)); } +size_t +scm_c_symbol_length (SCM sym) +#define FUNC_NAME "scm_c_symbol_length" +{ + SCM_VALIDATE_SYMBOL (1, sym); + + return STRINGBUF_LENGTH (SYMBOL_STRINGBUF (sym)); +} +#undef FUNC_NAME + const char * scm_i_symbol_chars (SCM sym) { diff --git a/libguile/strings.h b/libguile/strings.h index 04ae552f9..ca5f52cd2 100644 --- a/libguile/strings.h +++ b/libguile/strings.h @@ -90,6 +90,7 @@ SCM_API SCM scm_string_append (SCM args); SCM_API SCM scm_c_make_string (size_t len, SCM chr); SCM_API size_t scm_c_string_length (SCM str); +SCM_API size_t scm_c_symbol_length (SCM sym); SCM_API SCM scm_c_string_ref (SCM str, size_t pos); SCM_API void scm_c_string_set_x (SCM str, size_t pos, SCM chr); SCM_API SCM scm_c_substring (SCM str, size_t start, size_t end);