r5rs
srfi-0
srfi-4
+srfi-6
srfi-13
srfi-14
+ srfi-16
srfi-23
+ srfi-30
srfi-39
srfi-55
srfi-61
- /* 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, 2014 Free Software Foundation, Inc.
- *
++ * 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
return SCM_UNSPECIFIED;
}
- c = scm_getc (port);
+ /* If the EXPECTED_CHARS are the next ones available from PORT, then
+ consume them and return 1. Otherwise leave the port position where
+ it was and return 0. EXPECTED_CHARS should be all lowercase, and
+ will be matched case-insensitively against the characters read from
+ PORT. */
+ static int
+ try_read_ci_chars (SCM port, const char *expected_chars)
+ {
+ int num_chars_wanted = strlen (expected_chars);
+ int num_chars_read = 0;
+ char *chars_read = alloca (num_chars_wanted);
+ int c;
+
+ while (num_chars_read < num_chars_wanted)
+ {
- scm_ungetc (c, port);
++ c = scm_getc_unlocked (port);
+ if (c == EOF)
+ break;
+ else if (c_tolower (c) != expected_chars[num_chars_read])
+ {
- scm_ungetc (chars_read[--num_chars_read], port);
++ scm_ungetc_unlocked (c, port);
+ break;
+ }
+ else
+ chars_read[num_chars_read++] = c;
+ }
+
+ if (num_chars_read == num_chars_wanted)
+ return 1;
+ else
+ {
+ while (num_chars_read > 0)
++ scm_ungetc_unlocked (chars_read[--num_chars_read], port);
+ return 0;
+ }
+ }
+
\f
/* Sharp readers, i.e. readers called after a `#' sign has been read. */
/* Disambiguate between '#f' and uniform floating point vectors. */
if (c == 'f')
{
- c = scm_getc (port);
+ c = scm_getc_unlocked (port);
if (c != '3' && c != '6')
{
- if (c != EOF)
- scm_ungetc_unlocked (c, port);
+ if (c == 'a' && try_read_ci_chars (port, "lse"))
+ return SCM_BOOL_F;
+ else if (c != EOF)
- scm_ungetc (c, port);
++ scm_ungetc_unlocked (c, port);
return SCM_BOOL_F;
}
rank = 1;
r5rs
srfi-0 ;; cond-expand itself
srfi-4 ;; homogeneous numeric vectors
- ;; We omit srfi-6 because the 'open-input-string' etc in Guile
- ;; core are not conformant with SRFI-6; they expose details
- ;; of the binary I/O model and may fail to support some characters.
+ srfi-6 ;; string ports
srfi-13 ;; string library
srfi-14 ;; character sets
+ srfi-16 ;; case-lambda
srfi-23 ;; `error` procedure
+ srfi-30 ;; nested multi-line comments
srfi-39 ;; parameterize
srfi-55 ;; require-extension
srfi-61 ;; general cond clause
;;;; reader.test --- Reader test. -*- coding: iso-8859-1; mode: scheme -*-
;;;;
;;;; Copyright (C) 1999, 2001, 2002, 2003, 2007, 2008, 2009, 2010, 2011,
- ;;;; 2013 Free Software Foundation, Inc.
-;;;; 2014 Free Software Foundation, Inc.
++;;;; 2013, 2014 Free Software Foundation, Inc.
;;;; Jim Blandy <jimb@red-bean.com>
;;;;
;;;; This library is free software; you can redistribute it and/or