From 9412606265c2774712e3f805798896734b32c7fd Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 25 Apr 2011 01:12:16 +0300 Subject: [PATCH] Normalize whitespace in the arguments of Strip leading and trailing whitespace and replace interior whitespace by a single space. This avoids problems with the index generator producing duplicate index entries for terms that differ only in whitespace. Commit dca30da3433c40b5f92f1704c496cda052decef9 actually fixed all the indexterm elements that would cause this problem at the moment, but in case it sneaks in again, we're set. --- doc/src/sgml/stylesheet.dsl | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/doc/src/sgml/stylesheet.dsl b/doc/src/sgml/stylesheet.dsl index b95b357294..637758ff42 100644 --- a/doc/src/sgml/stylesheet.dsl +++ b/doc/src/sgml/stylesheet.dsl @@ -163,6 +163,22 @@ ;; Add more here if needed... +;; Replace a sequence of whitespace in a string by a single space +(define (normalize-whitespace str #!optional (whitespace '(#\space #\U-000D))) + (let loop ((characters (string->list str)) + (result '()) + (prev-was-space #f)) + (if (null? characters) + (list->string (reverse result)) + (let ((c (car characters)) + (rest (cdr characters))) + (if (member c whitespace) + (if prev-was-space + (loop rest result #t) + (loop rest (cons #\space result) #t)) + (loop rest (cons c result) #f)))))) + + -- GitLab