From fb923fab4f0cf276c336d98692d00df6a943791d Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 29 Oct 2020 22:03:40 +1000 Subject: build: Support sources with CRNL line endings make-c-ext.tcl and parse-unidata.tcl now support input files with CRNL line endings Reported-by: Mark@TheMarkitecht.com Signed-off-by: Steve Bennett --- make-c-ext.tcl | 4 ++-- parse-unidata.tcl | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/make-c-ext.tcl b/make-c-ext.tcl index fd1a056..00d4d1e 100644 --- a/make-c-ext.tcl +++ b/make-c-ext.tcl @@ -18,8 +18,8 @@ set f [open $source] while {[gets $f buf] >= 0} { # Remove comment lines regsub {^[ \t]*#.*$} $buf "" buf - # Escape quotes and backlashes - set buf [string map [list \\ \\\\ \" \\"] $buf] + # Escape quotes and backlashes and remove carriage returns + set buf [string map [list \\ \\\\ \" \\" \r ""] $buf] lappend sourcelines \"$buf\\n\" } close $f diff --git a/parse-unidata.tcl b/parse-unidata.tcl index 2bf6547..17e2e30 100644 --- a/parse-unidata.tcl +++ b/parse-unidata.tcl @@ -33,6 +33,8 @@ lassign $argv unicodefile widthfile set f [open $unicodefile] while {[gets $f buf] >= 0} { + # Remove any trailing whitespace, especially errant CR + set buf [string trim $buf] set title "" set lower "" set upper "" @@ -115,6 +117,8 @@ foreach type {upper lower title} { if {$do_width} { set f [open $widthfile] while {[gets $f buf] >= 0} { + # Remove any trailing whitespace, especially errant CR + set buf [string trim $buf] if {[regexp {^([0-9A-Fa-f.]+);W} $buf -> range]} { set range [string tolower $range] lassign [split $range .] lower - upper -- cgit v1.1