diff options
author | Michael Gran <spk121@yahoo.com> | 2009-08-27 07:32:50 -0700 |
---|---|---|
committer | Michael Gran <spk121@yahoo.com> | 2009-08-27 07:43:33 -0700 |
commit | f49dbcadf3829fe6ca2e4815c2af772360d454e8 (patch) | |
tree | 9fe2de9e2b5b74e2026bb1c1e39401e9baed3dd5 /libguile/srfi-14.h | |
parent | 3bcf189ba0d903e42935154c499ad60e1bf9cb3b (diff) | |
download | guile-f49dbcadf3829fe6ca2e4815c2af772360d454e8.tar.gz |
Unicode-capable srfi-14 charsets
* libguile/Makefile.am: distribute new files srfi-14.i.c and
unidata_to_charset.pl
* chars.c (scm_c_upcase, scm_c_downcase): use unicode-enable toupper
and tolower
* libguile/srfi-14.h (scm_t_char_range, scm_t_char_set): new structures
to describe char-sets
(scm_t_char_set_cursor): new structure to describe char-set-cursors
(SCM_BITS_PER_LONG): removed
(SCM_CHARSET_GET): calls function
New declarations for scm_i_charset_get, scm_i_charset_set,
scm_i_charset_unset, and scm_debug_char_set.
* test-suite/tests/srfi-14.test: new tests
* libguile/srfi-14.c (SCM_CHARSET_DATA): new macro
(SCM_CHARSET_SET, SCM_CHARSET_UNSET): call function
(BYTES_PER_CHARSET, LONGS_PER_CHARSET): removed
(scm_i_charset_get, scm_i_charset_set, scm_i_charset_unset)
(charsets_equal, charsets_leq, charsets_union)
(charsets_intersection, charsets_complement, charsets_xor): new
functions that are low-level charset operators
(charset_print, charset_free): modified for new charset struct
(charset_cursor_print, charset_cursor_free): new function
(make_char_set, scm_char_set_p, scm_char_set_eq, scm_car_set_leq)
(scm_char_set_hash, scm_char_set_cursor, scm_char_set_ref)
(scm_char_set_cursor_next, scm_end_of_char_set_p, scm_char_set_fold)
(scm_char_set_unfold, scm_char_set_unfold_x, scm_char_set_for_each)
(scm_char_set_map, scm_char_set_copy, scm_char_set, scm_list_to_char_set)
(scm_list_to_char_set_x, scm_string_to_char_set, scm_string_to_char_set_x)
(scm_char_set_filter, scm_char_set_filter_x, scm_ucs_range_to_char_set)
(scm_ucs_range_to_char_set_x, scm_to_char_set, scm_char_set_size)
(scm_char_set_count, scm_char_set_to_list, scm_char_set_to_string)
(scm_char_set_contains_p, scm_char_set_every, scm_char_set_any)
(scm_char_set_adjoin, scm_char_set_delete, scm_char_set_adjoin_x)
(scm_char_set_delete_x, scm_char_set_complement, scm_char_set_union)
(scm_char_set_intersection, scm_char_set_difference, scm_char_set_xor)
(scm_char_set_diff_plus_intersection, scm_char_set_complement_x)
(scm_char_set_union_x, scm_char_set_intersection_x, scm_char_set_difference_x)
(scm_char_set_xor_x, scm_char_set_diff_plus_intersection_x): modified
to use new charset and charset-cursor data structures
(CSET_BLANK_PRED, CSET_SYMBOL_PRED, CSET_PUNCT_PRED, CSET_LOWER_PRED)
(CSET_UPPER_PRED, CSET_LETTER_PRED, CSET_DIGIT_PRED, CSET_WHITESPACE_PRED)
(CSET_CONTROL_PRED, CSET_HEX_DIGIT_PRED, CSET_ASCII_PRED, CSET_LETTER_PRED)
(CSET_LETTER_AND_DIGIT_PRED, CSET_PRINTING_PRED, CSET_TRUE_PRED)
(CSET_FALSE_PRED): removed
(scm_srfi_14_compute_char_sets): removed - too slow to iterate
over all of unicode at startup
(scm_debug_char_set) [SCM_CHARSET_DEBUG]: new function
Diffstat (limited to 'libguile/srfi-14.h')
-rw-r--r-- | libguile/srfi-14.h | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/libguile/srfi-14.h b/libguile/srfi-14.h index 54e0d329c..bdcdd0889 100644 --- a/libguile/srfi-14.h +++ b/libguile/srfi-14.h @@ -24,22 +24,34 @@ #include "libguile/__scm.h" -#define SCM_CHARSET_SIZE 256 +typedef struct +{ + scm_t_wchar lo; + scm_t_wchar hi; +} scm_t_char_range; -/* We expect 8-bit bytes here. Should be no problem in the year - 2001. */ -#ifndef SCM_BITS_PER_LONG -# define SCM_BITS_PER_LONG (sizeof (long) * 8) -#endif +typedef struct +{ + size_t len; + scm_t_char_range *ranges; +} scm_t_char_set; + +typedef struct +{ + size_t range; + scm_t_wchar n; +} scm_t_char_set_cursor; -#define SCM_CHARSET_GET(cs, idx) (((long *) SCM_SMOB_DATA (cs))\ - [((unsigned char) (idx)) / SCM_BITS_PER_LONG] &\ - (1L << (((unsigned char) (idx)) % SCM_BITS_PER_LONG))) +#define SCM_CHARSET_GET(cs,idx) \ + scm_i_charset_get((scm_t_char_set *)SCM_SMOB_DATA(cs),idx) #define SCM_CHARSETP(x) (!SCM_IMP (x) && (SCM_TYP16 (x) == scm_tc16_charset)) /* Smob type code for character sets. */ SCM_API int scm_tc16_charset; +SCM_INTERNAL int scm_i_charset_get (scm_t_char_set *cs, scm_t_wchar n); +SCM_INTERNAL void scm_i_charset_set (scm_t_char_set *cs, scm_t_wchar n); +SCM_INTERNAL void scm_i_charset_unset (scm_t_char_set *cs, scm_t_wchar n); SCM_API SCM scm_char_set_p (SCM obj); SCM_API SCM scm_char_set_eq (SCM char_sets); @@ -88,6 +100,9 @@ SCM_API SCM scm_char_set_intersection_x (SCM cs1, SCM rest); SCM_API SCM scm_char_set_difference_x (SCM cs1, SCM rest); SCM_API SCM scm_char_set_xor_x (SCM cs1, SCM rest); SCM_API SCM scm_char_set_diff_plus_intersection_x (SCM cs1, SCM cs2, SCM rest); +#if SCM_CHARSET_DEBUG +SCM_API SCM scm_debug_char_set (SCM cs); +#endif SCM_API SCM scm_char_set_lower_case; SCM_API SCM scm_char_set_upper_case; @@ -107,7 +122,6 @@ SCM_API SCM scm_char_set_ascii; SCM_API SCM scm_char_set_empty; SCM_API SCM scm_char_set_full; -SCM_INTERNAL void scm_srfi_14_compute_char_sets (void); SCM_INTERNAL void scm_init_srfi_14 (void); #endif /* SCM_SRFI_14_H */ |