Index: read.c =================================================================== RCS file: /sources/guile/guile/guile-core/libguile/read.c,v retrieving revision 1.128 diff -a -u -r1.128 read.c --- read.c 17 Oct 2007 21:56:10 -0000 1.128 +++ read.c 2 Nov 2007 23:54:18 -0000 @@ -53,6 +53,7 @@ SCM_GLOBAL_SYMBOL (scm_sym_dot, "."); SCM_SYMBOL (scm_keyword_prefix, "prefix"); +SCM_SYMBOL (scm_keyword_postfix, "postfix"); scm_t_option scm_read_opts[] = { { SCM_OPTION_BOOLEAN, "copy", 0, @@ -62,7 +63,7 @@ { SCM_OPTION_BOOLEAN, "case-insensitive", 0, "Convert symbols to lower case."}, { SCM_OPTION_SCM, "keywords", SCM_UNPACK (SCM_BOOL_F), - "Style of keyword recognition: #f or 'prefix."}, + "Style of keyword recognition: #f, 'prefix, or 'postfix."}, #if SCM_ENABLE_ELISP { SCM_OPTION_BOOLEAN, "elisp-vectors", 0, "Support Elisp vector syntax, namely `[...]'."}, @@ -532,6 +533,8 @@ { SCM result, str = SCM_EOL; int overflow = 0; + int postfix = scm_is_eq (SCM_PACK (SCM_KEYWORD_STYLE), scm_keyword_postfix); + char buffer[READER_BUFFER_SIZE]; size_t read = 0; @@ -549,12 +552,26 @@ { str = scm_string_concatenate (scm_reverse_x (str, SCM_EOL)); result = scm_string_to_symbol (str); + + if (postfix) + { + size_t l = scm_c_string_length (str) - 1; + if (l && scm_is_true (scm_char_eq_p (scm_c_string_ref (str, l), + SCM_MAKE_CHAR (':')))) + result = scm_from_locale_keywordn (scm_i_string_chars (str), l); + } } else + { + /* For symbols smaller than `sizeof (buffer)', we don't need to recur to Scheme strings. Therefore, we only create one Scheme object (a symbol) per symbol read. */ - result = scm_from_locale_symboln (buffer, read); + if (postfix && read > 1 && buffer[read - 1] == ':') + result = scm_from_locale_keywordn (buffer, read - 1); + else + result = scm_from_locale_symboln (buffer, read); + } return result; }