Add `scm_c_symbol_length ()'.
authorLudovic Courtès <ludo@gnu.org>
Sat, 5 Jul 2008 18:10:44 +0000 (20:10 +0200)
committerLudovic Courtès <ludo@gnu.org>
Sat, 5 Jul 2008 18:16:12 +0000 (20:16 +0200)
NEWS
doc/ref/ChangeLog
doc/ref/api-data.texi
libguile/ChangeLog
libguile/strings.c
libguile/strings.h

diff --git a/NEWS b/NEWS
index 16b1880..c2c8751 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,10 @@ indicating length of the `scm_t_option' array.
 \f
 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
index 1eb1539..5812d65 100644 (file)
@@ -1,3 +1,7 @@
+2008-07-05  Ludovic Courtès  <ludo@gnu.org>
+
+       * api-data.texi (Symbol Primitives): Add `scm_c_symbol_length ()'.
+
 2008-06-30  Julian Graham  <joolean@gmail.com>
 
        * srfi-modules.texi (SRFI-18): New section.
index b2b5b07..e1db2a6 100755 (executable)
@@ -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
index f6fcdc6..0223b0b 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-05  Ludovic Courtès  <ludo@gnu.org>
+
+       * strings.c (scm_c_symbol_length): New function.
+       * strings.h (scm_c_symbol_length): New declaration.
+
 2008-07-04  Ludovic Courtès  <ludo@gnu.org>
 
        * posix.h (scm_i_locale_mutex): Don't declare as `SCM_INTERNAL'
index c322132..c9b08a0 100644 (file)
@@ -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)
 {
index 04ae552..ca5f52c 100644 (file)
@@ -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);