summaryrefslogtreecommitdiff
path: root/libguile/deprecated.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2020-04-12 21:26:47 +0200
committerAndy Wingo <wingo@pobox.com>2020-04-12 21:36:30 +0200
commit24a34074ef8fd91c111ed9987375f25925f69e26 (patch)
tree98fde41becf8208ecbb5b7ad0237d9a060e7a182 /libguile/deprecated.c
parent2b4e45ca1b89a942200b7b9f46060dddc44d2876 (diff)
downloadguile-24a34074ef8fd91c111ed9987375f25925f69e26.tar.gz
Deprecate bitvector-ref on array slices
* NEWS: Update. * doc/ref/api-data.texi (Bit Vectors): Update documentation on bit-set*! and bit-count*. * libguile/bitvectors.c: Add a to-do list. (scm_c_bitvector_ref, scm_c_bitvector_set_x, scm_bitvector_fill_x) (scm_bitvector_to_list, scm_bit_count, scm_bit_position): Issue deprecation warnings when used on array slices. (scm_list_to_bitvector): Simplify. (scm_bit_set_star_x, scm_bit_count_star): Deprecate arrays as target bitvectors, and also use of u32vector as selection vector. * libguile/bitvectors.h: * libguile/deprecated.h: * libguile/deprecated.c (scm_istr2bve): Deprecate. * test-suite/tests/bitvectors.test ("bit-count*"): Remove test of u32 selectors.
Diffstat (limited to 'libguile/deprecated.c')
-rw-r--r--libguile/deprecated.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/libguile/deprecated.c b/libguile/deprecated.c
index cc8e78b97..60459c603 100644
--- a/libguile/deprecated.c
+++ b/libguile/deprecated.c
@@ -1,4 +1,4 @@
-/* Copyright 2003-2004,2006,2008-2018
+/* Copyright 2003-2004,2006,2008-2018,2020
Free Software Foundation, Inc.
This file is part of Guile.
@@ -27,8 +27,10 @@
#define SCM_BUILDING_DEPRECATED_CODE
+#include "bitvectors.h"
#include "deprecation.h"
#include "gc.h"
+#include "strings.h"
#include "deprecated.h"
@@ -83,6 +85,55 @@ scm_find_executable (const char *name)
+SCM
+scm_istr2bve (SCM str)
+{
+ scm_t_array_handle handle;
+ size_t len = scm_i_string_length (str);
+ SCM vec = scm_c_make_bitvector (len, SCM_UNDEFINED);
+ SCM res = vec;
+
+ uint32_t mask;
+ size_t k, j;
+ const char *c_str;
+ uint32_t *data;
+
+ scm_c_issue_deprecation_warning
+ ("scm_istr2bve is deprecated. "
+ "Read from a string instead, prefixed with `#*'.");
+
+ data = scm_bitvector_writable_elements (vec, &handle, NULL, NULL, NULL);
+ c_str = scm_i_string_chars (str);
+
+ for (k = 0; k < (len + 31) / 32; k++)
+ {
+ data[k] = 0L;
+ j = len - k * 32;
+ if (j > 32)
+ j = 32;
+ for (mask = 1L; j--; mask <<= 1)
+ switch (*c_str++)
+ {
+ case '0':
+ break;
+ case '1':
+ data[k] |= mask;
+ break;
+ default:
+ res = SCM_BOOL_F;
+ goto exit;
+ }
+ }
+
+ exit:
+ scm_array_handle_release (&handle);
+ scm_remember_upto_here_1 (str);
+ return res;
+}
+
+
+
+
void
scm_i_init_deprecated ()
{