awwx.ws

skipwhite1

Skips whitespace using the current readtable’s definition of “whitespace”

http://awwx.ws/skipwhite1.arc:

; place in own library to abide by the LGPL
;
; skip-whitespace is copied from
; http://download.plt-scheme.org/doc/352/html/mzscheme/mzscheme-Z-H-11.html#node_sec_11.2.8
; which has the following licence:
;
; Copyright ©1995-2006 Matthew Flatt
;
; Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Library General Public License, Version 2 published by the Free Software Foundation.
;
; [ ] in source changed to ( ) to avoid conflict with brackets.scm

(scheme:define (skip-whitespace port)
  ;; Skips whitespace characters, sensitive to the current
  ;; readtable's definition of whitespace
  (let ((ch (peek-char port)))
    (unless (eof-object? ch)
      ;; Consult current readtable:
      (let-values (((like-ch/sym proc dispatch-proc)
                    (readtable-mapping (current-readtable) ch)))
        ;; If like-ch/sym is whitespace, then ch is whitespace
        (when (and (char? like-ch/sym)
                   (char-whitespace? like-ch/sym))
          (read-char port)
          (skip-whitespace port))))))

Prerequisites

This hack depends on arc3.1, defarc0, defarc-ac0, extend0, and scheme0.