X-Git-Url: https://git.hcoop.net/bpt/guile.git/blobdiff_plain/453acfacf408fafe0712f8796e06241d236d011a..5b744b67f7f8350bd66d6c0b659f9375a6d700fa:/libguile/chars.c diff --git a/libguile/chars.c b/libguile/chars.c index fbedb0fe2..064fca40a 100644 --- a/libguile/chars.c +++ b/libguile/chars.c @@ -1,5 +1,6 @@ -/* Copyright (C) 1995,1996,1998, 2000, 2001, 2004, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. - * +/* Copyright (C) 1995,1996,1998, 2000, 2001, 2004, 2006, 2008, 2009, + * 2010, 2011, 2014 Free Software Foundation, Inc. + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 3 of @@ -535,7 +536,7 @@ static const char *const scm_r5rs_charnames[] = { "space", "newline" }; -static const scm_t_uint32 const scm_r5rs_charnums[] = { +static const scm_t_uint32 scm_r5rs_charnums[] = { 0x20, 0x0a }; @@ -547,13 +548,23 @@ static const char *const scm_r6rs_charnames[] = { /* 'space' and 'newline' are already included from the R5RS list. */ }; -static const scm_t_uint32 const scm_r6rs_charnums[] = { +static const scm_t_uint32 scm_r6rs_charnums[] = { 0x00, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x1b, 0x7f }; #define SCM_N_R6RS_CHARNAMES (sizeof (scm_r6rs_charnames) / sizeof (char *)) +static const char *const scm_r7rs_charnames[] = { + "escape" +}; + +static const scm_t_uint32 scm_r7rs_charnums[] = { + 0x1b +}; + +#define SCM_N_R7RS_CHARNAMES (sizeof (scm_r7rs_charnames) / sizeof (char *)) + /* The abbreviated names for control characters. */ static const char *const scm_C0_control_charnames[] = { /* C0 controls */ @@ -564,7 +575,7 @@ static const char *const scm_C0_control_charnames[] = { "sp", "del" }; -static const scm_t_uint32 const scm_C0_control_charnums[] = { +static const scm_t_uint32 scm_C0_control_charnums[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -578,7 +589,7 @@ static const char *const scm_alt_charnames[] = { "null", "nl", "np" }; -static const scm_t_uint32 const scm_alt_charnums[] = { +static const scm_t_uint32 scm_alt_charnums[] = { 0x00, 0x0a, 0x0c }; @@ -600,6 +611,10 @@ scm_i_charname (SCM chr) if (scm_r6rs_charnums[c] == i) return scm_r6rs_charnames[c]; + for (c = 0; c < SCM_N_R7RS_CHARNAMES; c++) + if (scm_r7rs_charnums[c] == i) + return scm_r7rs_charnames[c]; + for (c = 0; c < SCM_N_C0_CONTROL_CHARNAMES; c++) if (scm_C0_control_charnums[c] == i) return scm_C0_control_charnames[c]; @@ -625,13 +640,20 @@ scm_i_charname_to_char (const char *charname, size_t charname_len) && (!strncasecmp (scm_r5rs_charnames[c], charname, charname_len))) return SCM_MAKE_CHAR (scm_r5rs_charnums[c]); - /* The R6RS charnames. R6RS says that these should be case-sensitive. They - are left as case-insensitive to avoid confusion. */ + /* The R6RS charnames. R6RS says that these should be case-sensitive. + They are left as case-insensitive to avoid confusion. */ for (c = 0; c < SCM_N_R6RS_CHARNAMES; c++) if ((strlen (scm_r6rs_charnames[c]) == charname_len) && (!strncasecmp (scm_r6rs_charnames[c], charname, charname_len))) return SCM_MAKE_CHAR (scm_r6rs_charnums[c]); + /* The R7RS charnames. R7RS says that these should be case-sensitive. + They are left as case-insensitive to avoid confusion. */ + for (c = 0; c < SCM_N_R7RS_CHARNAMES; c++) + if ((strlen (scm_r7rs_charnames[c]) == charname_len) + && (!strncasecmp (scm_r7rs_charnames[c], charname, charname_len))) + return SCM_MAKE_CHAR (scm_r7rs_charnums[c]); + /* Then come the controls. By Guile convention, these are not case sensitive. */ for (c = 0; c < SCM_N_C0_CONTROL_CHARNAMES; c++)