From 2f0a98ce176728393e99b8ec17d2a18b216fbc9b Mon Sep 17 00:00:00 2001 From: Zbynek Slajchrt <zbynek.slajchrt@oracle.com> Date: Wed, 23 Aug 2017 11:16:41 +0200 Subject: [PATCH] Build process refactored --- .gitignore | 1 + ci.hocon | 10 +- .../Makefile | 23 +- com.oracle.truffle.r.native/Makefile | 12 +- com.oracle.truffle.r.native/fficall/Makefile | 5 +- .../fficall/src/common/Makefile | 18 +- .../fficall/src/include/Defn.h | 2 + .../fficall/src/truffle_nfi/Memory.c | 1 + .../gnur/Makefile.gnur | 59 +- .../gnur/Makefile.libs | 8 +- .../gnur/Makefile.platform | 2 - .../{ => gnur/patch/src}/library/Makefile | 2 +- .../patch/src}/library/base/Makefile | 14 +- .../gnur/patch/src/library/base/makebasedb.R | 130 - .../src}/library/base/src/registration.c | 0 .../patch/src}/library/compiler/Makefile | 2 +- .../patch/src}/library/datasets/Makefile | 2 +- .../patch/src}/library/grDevices/Makefile | 19 +- .../patch/src}/library/grDevices/src/gzio.c | 2 +- .../patch/src}/library/graphics/Makefile | 22 +- .../gnur/patch/src/library/grid/Makefile | 27 + .../{ => gnur/patch/src}/library/lib.mk | 37 +- .../patch/src/library/methods}/Makefile | 2 +- .../src}/library/methods/src/methods_dummy.c | 0 .../gnur/patch/src/library/parallel/Makefile | 26 + .../library/parallel/src/parallel_dummy.c | 0 .../src/library/parallel/src/rngstream.c | 2 +- .../gnur/patch/src/library/splines/Makefile | 24 + .../patch/src/library/splines/src/splines.c | 127 +- .../patch/src/library/stats}/Makefile | 22 +- .../gnur/patch/src/library/stats/src/fft.c | 22 +- .../src}/library/stats/src/gnur_extracts.c | 0 .../gnur/patch/src/library/stats/src/nls.c | 353 +- .../gnur/patch/src/library/stats/src/port.c | 588 +-- .../patch/src/library/stats/src/stats.c} | 15 +- .../src}/library/stats/src/statsR_dummy.c | 0 .../patch/src/library/stats/src/ts.c} | 26 +- .../patch/src}/library/stats4/Makefile | 2 +- .../patch/src}/library/tools/Makefile | 23 +- .../gnur/patch/src/library/tools/src/gramRd.c | 223 +- .../src}/library/tools/src/gramRd_fastr.h | 2 + .../src}/library/tools/src/tools_dummy.c | 0 .../tools/src/truffle_llvm/gramRd_llvm.c | 0 .../tools/src/truffle_nfi/gramRd_nfi.c | 0 .../gnur/patch/src/library/utils/Makefile | 24 + .../src}/library/utils/src/utils_dummy.c | 0 .../gnur/patch/src/main/rlocale_data.h | 3608 +++++++++++++++++ .../gnur/patch/src/main/xspline.c | 544 +++ .../gnur/sedEtcMakeconf | 2 - com.oracle.truffle.r.native/gnur/sedMakeconf | 18 +- com.oracle.truffle.r.native/include/Makefile | 3 +- .../library/grid/Makefile | 63 - .../library/grid/src/sed_grid | 10 - .../library/grid/src/sed_state | 18 - .../library/methods/Makefile | 35 - .../library/parallel/Makefile | 37 - .../library/parallel/RSHAREDnode.R | 26 - .../library/parallel/src/glpi.h | 41 - .../library/parallel/src/rngstream.c | 99 - .../library/splines/src/splines.c | 246 -- .../library/stats/Makefile | 74 - .../library/stats/src/ed_fft | 33 - .../library/stats/src/modreg.h | 125 - .../library/stats/src/port.h | 107 - .../library/stats/src/stats.h | 51 - com.oracle.truffle.r.native/run/Makefile | 20 +- .../oracle/truffle/r/runtime/REnvVars.java | 21 + .../packages/Makefile | 12 +- .../packages/package.mk | 4 +- .../r/install.packages.R | 6 +- .../r/test/generate/GnuROneShotRSession.java | 3 +- .../truffle/r/test/tools/RBuiltinCheck.java | 11 +- documentation/dev/build-process.md | 196 +- mx.fastr/copyrights/gnu_r.language.star | 18 + mx.fastr/copyrights/gnu_r.language.star.regex | 1 + mx.fastr/copyrights/overrides | 177 +- mx.fastr/mx_fastr.py | 6 +- mx.fastr/mx_fastr_edinclude.py | 4 +- mx.fastr/mx_fastr_mkgramrd.py | 166 - 79 files changed, 4958 insertions(+), 2706 deletions(-) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/Makefile (95%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/base/Makefile (79%) delete mode 100644 com.oracle.truffle.r.native/gnur/patch/src/library/base/makebasedb.R rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/base/src/registration.c (100%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/compiler/Makefile (94%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/datasets/Makefile (94%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/grDevices/Makefile (77%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/grDevices/src/gzio.c (89%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/graphics/Makefile (75%) create mode 100644 com.oracle.truffle.r.native/gnur/patch/src/library/grid/Makefile rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/lib.mk (75%) rename com.oracle.truffle.r.native/{library/splines => gnur/patch/src/library/methods}/Makefile (93%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/methods/src/methods_dummy.c (100%) create mode 100644 com.oracle.truffle.r.native/gnur/patch/src/library/parallel/Makefile rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/parallel/src/parallel_dummy.c (100%) create mode 100644 com.oracle.truffle.r.native/gnur/patch/src/library/splines/Makefile rename com.oracle.truffle.r.native/{library/utils => gnur/patch/src/library/stats}/Makefile (64%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/stats/src/gnur_extracts.c (100%) rename com.oracle.truffle.r.native/{library/stats/src/nls.h => gnur/patch/src/library/stats/src/stats.c} (69%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/stats/src/statsR_dummy.c (100%) rename com.oracle.truffle.r.native/{library/stats/src/ts.h => gnur/patch/src/library/stats/src/ts.c} (83%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/stats4/Makefile (94%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/tools/Makefile (77%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/tools/src/gramRd_fastr.h (96%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/tools/src/tools_dummy.c (100%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/tools/src/truffle_llvm/gramRd_llvm.c (100%) rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/tools/src/truffle_nfi/gramRd_nfi.c (100%) create mode 100644 com.oracle.truffle.r.native/gnur/patch/src/library/utils/Makefile rename com.oracle.truffle.r.native/{ => gnur/patch/src}/library/utils/src/utils_dummy.c (100%) create mode 100644 com.oracle.truffle.r.native/gnur/patch/src/main/rlocale_data.h create mode 100644 com.oracle.truffle.r.native/gnur/patch/src/main/xspline.c delete mode 100644 com.oracle.truffle.r.native/gnur/sedEtcMakeconf delete mode 100644 com.oracle.truffle.r.native/library/grid/Makefile delete mode 100644 com.oracle.truffle.r.native/library/grid/src/sed_grid delete mode 100644 com.oracle.truffle.r.native/library/grid/src/sed_state delete mode 100644 com.oracle.truffle.r.native/library/methods/Makefile delete mode 100644 com.oracle.truffle.r.native/library/parallel/Makefile delete mode 100644 com.oracle.truffle.r.native/library/parallel/RSHAREDnode.R delete mode 100644 com.oracle.truffle.r.native/library/parallel/src/glpi.h delete mode 100644 com.oracle.truffle.r.native/library/parallel/src/rngstream.c delete mode 100644 com.oracle.truffle.r.native/library/splines/src/splines.c delete mode 100644 com.oracle.truffle.r.native/library/stats/Makefile delete mode 100644 com.oracle.truffle.r.native/library/stats/src/ed_fft delete mode 100644 com.oracle.truffle.r.native/library/stats/src/modreg.h delete mode 100644 com.oracle.truffle.r.native/library/stats/src/port.h delete mode 100644 com.oracle.truffle.r.native/library/stats/src/stats.h create mode 100644 mx.fastr/copyrights/gnu_r.language.star create mode 100644 mx.fastr/copyrights/gnu_r.language.star.regex delete mode 100644 mx.fastr/mx_fastr_mkgramrd.py diff --git a/.gitignore b/.gitignore index ff804d8c80..8175db7bb9 100644 --- a/.gitignore +++ b/.gitignore @@ -143,3 +143,4 @@ com.oracle.truffle.r.test.native/packages/testrffi/testrffi/tests/asTests.R com.oracle.truffle.r.test.native/packages/testrffi/testrffi/tests/coerceTests.R com.oracle.truffle.r.native/version.built documentation/.pydevproject +com.oracle.truffle.r.native/gnur/patch-build diff --git a/ci.hocon b/ci.hocon index 208083f56e..b78484d9df 100644 --- a/ci.hocon +++ b/ci.hocon @@ -31,14 +31,12 @@ java9Downloads : { logfiles : [ "fastr_errors.log" "results.json" - "com.oracle.truffle.r.native/gnur/R-*/gnur_configure.log" - "com.oracle.truffle.r.native/gnur/R-*/gnur_make.log" - "com.oracle.truffle.r.native/gnur/R-*/Makeconf" + "libdownloads/R-*/gnur_configure.log" + "libdownloads/R-*/config.log" + "libdownloads/R-*/gnur_make.log" + "libdownloads/R-*/Makeconf" "com.oracle.truffle.r.native/gnur/tests/log/all.diff" - "com.oracle.truffle.r.native/gnur/libiconv-*/iconv_configure.log" - "com.oracle.truffle.r.native/gnur/libiconv-*/iconv_make.log" "*-tests/*.Rout" - "com.oracle.truffle.r.native/gnur/R-*/config.log" ] # This is needed by all (Linux) builds but is specific to the module system employed diff --git a/com.oracle.truffle.r.native.recommended/Makefile b/com.oracle.truffle.r.native.recommended/Makefile index b2857f7614..fd29a7a598 100644 --- a/com.oracle.truffle.r.native.recommended/Makefile +++ b/com.oracle.truffle.r.native.recommended/Makefile @@ -29,6 +29,15 @@ FASTR_R_HOME := $(abspath $(CURDIR)/..) NATIVE_PROJECT_DIR := $(FASTR_R_HOME)/com.oracle.truffle.r.native +TOPDIR := $(FASTR_R_HOME)/com.oracle.truffle.r.native.recommended + +# The package tar balls are copied from $(GNUR_HOME_BINARY)/src/library/Recommended +ifndef GNUR_HOME_BINARY +FASTR_R_HOME = $(abspath $(TOPDIR)/..) +R_VERSION = $(subst R-,,$(notdir $(basename $(basename $(wildcard $(FASTR_R_HOME)/libdownloads/R-*.gz))))) +export GNUR_HOME_BINARY = $(FASTR_R_HOME)/libdownloads/R-$(R_VERSION) +$(info GNUR_HOME_BINARY not set. Assuming the default location at $(GNUR_HOME_BINARY)) +endif ifneq (,$(wildcard $(NATIVE_PROJECT_DIR)/platform.mk)) include $(NATIVE_PROJECT_DIR)/platform.mk @@ -40,23 +49,21 @@ endif .PHONY: all clean -NATIVE_PROJECT := $(subst native.recommended,native,$(CURDIR)) -R_VERSION := $(notdir $(wildcard $(NATIVE_PROJECT)/gnur/R-*)) -GNUR_HOME := $(NATIVE_PROJECT)/gnur/$(R_VERSION) # order matters due to inter-package dependencies ifdef FASTR_RELEASE GNUR_RECOMMENDED_PKGNAMES := codetools MASS boot class cluster lattice nnet spatial Matrix survival KernSmooth foreign nlme rpart else -# codetools must be always installed because of S4 +# codetools must always be installed because of S4 GNUR_RECOMMENDED_PKGNAMES := codetools endif -GNUR_RECOMMENDED_TARS := $(foreach pkg, $(GNUR_RECOMMENDED_PKGNAMES),$(GNUR_HOME)/src/library/Recommended/$(pkg).tgz) -#$(info GNUR_RECOMMENDED_TARS=$(GNUR_RECOMMENDED_TARS)) +GNUR_RECOMMENDED_TARS := $(foreach pkg, $(GNUR_RECOMMENDED_PKGNAMES),$(GNUR_HOME_BINARY)/src/library/Recommended/$(pkg).tgz) all: install.recommended +$(info GNUR_RECOMMENDED_TARS=$(GNUR_RECOMMENDED_TARS)) + ifneq ($(FASTR_RFFI),managed) -install.recommended: $(GNUR_RECOMMENDED_TARS) +install.recommended: for pkgtar in $(GNUR_RECOMMENDED_TARS); do \ $(FASTR_R_HOME)/bin/R CMD INSTALL --library=$(FASTR_R_HOME)/library $$pkgtar; \ done @@ -68,6 +75,7 @@ ifeq ($(OS_NAME),Darwin) fi \ done endif + touch install.recommended else install.recommended: endif @@ -78,4 +86,3 @@ clean: rm -rf $(FASTR_R_HOME)/library/$$pkgname; \ done rm -f install.recommended - diff --git a/com.oracle.truffle.r.native/Makefile b/com.oracle.truffle.r.native/Makefile index dfc68d8f17..514fd0857f 100644 --- a/com.oracle.truffle.r.native/Makefile +++ b/com.oracle.truffle.r.native/Makefile @@ -27,8 +27,8 @@ export TOPDIR = $(CURDIR) export FASTR_R_HOME=$(abspath $(TOPDIR)/..) export FASTR_LIB_DIR=$(FASTR_R_HOME)/lib export FASTR_NATIVE_DIR = $(TOPDIR) -export R_VERSION = $(subst R-,,$(notdir $(basename $(basename $(wildcard $(FASTR_R_HOME)/libdownloads/R-*.gz))))) -export GNUR_HOME = $(TOPDIR)/gnur/R-$(R_VERSION) +export R_VERSION = 3.4.0 +export GNUR_HOME = $(TOPDIR)/gnur/patch-build $(info R_VERSION: $(R_VERSION)) $(info GNUR_HOME: $(GNUR_HOME)) @@ -37,6 +37,11 @@ ifndef FASTR_RFFI export FASTR_RFFI = nfi endif +ifndef GNUR_HOME_BINARY +export GNUR_HOME_BINARY = $(FASTR_R_HOME)/libdownloads/R-$(R_VERSION) +$(info GNUR_HOME_BINARY not set. Assuming the default location at $(GNUR_HOME_BINARY)) +endif + # Completely accurate dependency analysis is very difficult for this project, so use a version number # to force a clean build, and elsewhere use sentinels to avoid rebuilding when we can't compute the # dependencies accurately. @@ -45,14 +50,13 @@ all: checkversion $(MAKE) -C gnur $(MAKE) -C include $(MAKE) -C fficall - $(MAKE) -C library + $(MAKE) -C $(GNUR_HOME)/src/library $(MAKE) -C run cp version.source version.built clean: $(MAKE) -C include clean $(MAKE) -C fficall clean - $(MAKE) -C library clean $(MAKE) -C run clean $(MAKE) -C gnur clean diff --git a/com.oracle.truffle.r.native/fficall/Makefile b/com.oracle.truffle.r.native/fficall/Makefile index 7c8ebc3890..278d222f0c 100644 --- a/com.oracle.truffle.r.native/fficall/Makefile +++ b/com.oracle.truffle.r.native/fficall/Makefile @@ -51,7 +51,7 @@ all: $(R_LIB) # N.B. if things change in the subdirs, a clean must be invoked # to remove the sentinels -$(R_LIB): fficall.done +$(R_LIB): fficall.done ifeq ($(FASTR_RFFI),managed) # nop else @@ -91,7 +91,7 @@ endif #managed common.done: $(MAKE) -C src/common all - + touch common.done clean: $(MAKE) -C src/common clean @@ -108,4 +108,5 @@ endif endif rm -rf $(R_LIB) rm -rf fficall.done + rm -rf common.done diff --git a/com.oracle.truffle.r.native/fficall/src/common/Makefile b/com.oracle.truffle.r.native/fficall/src/common/Makefile index ac09cf124f..4b7fd7a6f0 100644 --- a/com.oracle.truffle.r.native/fficall/src/common/Makefile +++ b/com.oracle.truffle.r.native/fficall/src/common/Makefile @@ -35,18 +35,17 @@ OBJ = ../../lib GNUR_APPL_C_FILES = pretty.c interv.c GNUR_APPL_SRC = $(GNUR_HOME)/src/appl -# the Fortran sources are not recompiled (except for LLVM), just copied ifneq ($(FASTR_RFFI),llvm) -GNUR_APPL_F_OBJECTS := $(wildcard $(GNUR_APPL_SRC)/d*.o) +GNUR_APPL_F_FILES := $(notdir $(wildcard $(GNUR_APPL_SRC)/d*.f)) else -GNUR_APPL_F_OBJECTS := +GNUR_APPL_F_FILES := endif GNUR_MAIN_C_FILES = colors.c devices.c engine.c format.c graphics.c plot.c plot3d.c plotmath.c rlocale.c sort.c GNUR_MAIN_SRC = $(GNUR_HOME)/src/main GNUR_C_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_APPL_C_FILES:.c=.o) $(GNUR_MAIN_C_FILES:.c=.o)) -GNUR_F_OBJECTS := $(GNUR_APPL_F_OBJECTS) +GNUR_F_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_APPL_F_FILES:.f=.o)) C_SOURCES = $(wildcard *.c) C_OBJECTS := $(patsubst %.c,$(OBJ)/%.o,$(C_SOURCES)) @@ -66,13 +65,7 @@ else SUPPRESS_WARNINGS := -Wno-int-conversion -Wno-implicit-function-declaration endif -all: Makefile $(C_OBJECTS) $(F_OBJECTS) $(GNUR_C_OBJECTS) $(GNUR_F_OBJECTS) $(OBJ)/copy_appl_objects - -$(OBJ)/copy_appl_objects: $(GNUR_APPL_F_OBJECTS) -ifneq ($(FASTR_RFFI),llvm) - cp $(GNUR_APPL_F_OBJECTS) $(OBJ) -endif - touch $(OBJ)/copy_appl_objects +all: Makefile $(C_OBJECTS) $(F_OBJECTS) $(GNUR_C_OBJECTS) $(GNUR_F_OBJECTS) $(C_OBJECTS): | $(OBJ) @@ -98,6 +91,9 @@ $(OBJ)/%.o: %.c $(FASTR_NATIVE_DIR)/include/Rinternals.h $(OBJ)/%.o: %.f $(F77) $(FFLAGS) $(FPICFLAGS) -c $< -o $@ +$(OBJ)/%.o: $(GNUR_APPL_SRC)/%.f + $(F77) $(FFLAGS) $(FPICFLAGS) -c $< -o $@ + clean: rm -rf $(OBJ) diff --git a/com.oracle.truffle.r.native/fficall/src/include/Defn.h b/com.oracle.truffle.r.native/fficall/src/include/Defn.h index 3ad79cc188..5cd19fa99e 100644 --- a/com.oracle.truffle.r.native/fficall/src/include/Defn.h +++ b/com.oracle.truffle.r.native/fficall/src/include/Defn.h @@ -39,6 +39,8 @@ #define N_(String) String #define ngettext(String, StringP, N) (N > 1 ? StringP: String) +#define checkArity(a,b) Rf_checkArityCall(a,b,call) + void sortVector(SEXP, Rboolean); int Scollate(SEXP a, SEXP b); void Rf_checkArityCall(SEXP, SEXP, SEXP); diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c index 9aa78ee799..2fc719095f 100644 --- a/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c +++ b/com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c @@ -9,6 +9,7 @@ * * All rights reserved. */ +#include <Defn.h> #include "rffiutils.h" #include <stdlib.h> #include <string.h> diff --git a/com.oracle.truffle.r.native/gnur/Makefile.gnur b/com.oracle.truffle.r.native/gnur/Makefile.gnur index 7c7543f433..f43dec8c6f 100644 --- a/com.oracle.truffle.r.native/gnur/Makefile.gnur +++ b/com.oracle.truffle.r.native/gnur/Makefile.gnur @@ -33,6 +33,9 @@ OSNAME := $(shell uname) +PATCH := patch +PATCH_BUILD := patch-build + ifneq ($(FASTR_RFFI),llvm) # LLVM text parser and -g don't get on # TODO check still true @@ -53,10 +56,7 @@ else $(error OS $(OSNAME) is not supported) endif -all: Makefile $(GNUR_HOME) iconv config build - -$(GNUR_HOME): - tar xf $(TOPDIR)/../libdownloads/R-$(R_VERSION).tar.gz +all: Makefile $(GNUR_HOME_BINARY) $(PATCH_BUILD) iconv config $(PATCH_BUILD)/include # After this platform check, GNUR_CONFIG_FLAGS must be set ifeq ($(OSNAME), SunOS) @@ -124,13 +124,13 @@ GNUR_CONFIG_FLAGS := $(GNUR_CONFIG_FLAGS) FFLAGS=-O2 $(FASTR_COMPILERS) endif # End of platform check -config: $(GNUR_HOME)/Makefile config_update +config: $(PATCH_BUILD)/Makefile config_update ifeq ($(FORCE_PIC), true) config_update: Makeconf.done Makeconf.done: edMakeconf - ed $(GNUR_HOME)/Makeconf < edMakeconf + ed $(PATCH_BUILD)/Makeconf < edMakeconf touch Makeconf.done else config_update: @@ -141,19 +141,50 @@ ifndef FASTR_RELEASE RECPKGS := "--without-recommended-packages" endif -$(GNUR_HOME)/Makefile: - (cd $(GNUR_HOME); ./configure --with-x=no --with-aqua=no $(RECPKGS) --enable-memory-profiling $(GNUR_CONFIG_FLAGS) > gnur_configure.log 2>&1) +ifeq ($(wildcard $(GNUR_HOME_BINARY)),) +GNUR_HOME_BINARY_PARENT := $(dir $(GNUR_HOME_BINARY)) -build: $(GNUR_HOME)/bin/R +$(info Installing R-$(R_VERSION) into $(GNUR_HOME_BINARY) ...) -$(GNUR_HOME)/bin/R: $(GNUR_HOME)/Makeconf - (cd $(GNUR_HOME); $(MAKE) MAKE=$(MAKE) -j > gnur_make.log 2>&1) +$(GNUR_HOME_BINARY): + mkdir -p $(GNUR_HOME_BINARY_PARENT) + tar xf $(TOPDIR)/../libdownloads/R-$(R_VERSION).tar.gz -C $(GNUR_HOME_BINARY_PARENT) + ln -s $(GNUR_HOME_BINARY_PARENT)/R-$(R_VERSION) $(GNUR_HOME_BINARY) + (cd $(GNUR_HOME_BINARY); ./configure --with-x=no --with-aqua=no $(RECPKGS) --enable-memory-profiling $(GNUR_CONFIG_FLAGS) > gnur_configure.log 2>&1; $(MAKE) MAKE=$(MAKE) -j > gnur_make.log 2>&1) +else +$(GNUR_HOME_BINARY): +endif -clean: cleangnur cleaniconv +IN_FILES := $(patsubst %.in,%,$(abspath $(shell find $(PATCH) -name '*.in'))) +IN_FILES_PREFIX := $(abspath $(PATCH)) +$(info IN_FILES_PREFIX : $(IN_FILES_PREFIX)) +IN_FILES_PREFIX_LEN := $(shell echo $(IN_FILES_PREFIX) | wc -c) +$(info IN_FILES_PREFIX_LEN : $(IN_FILES_PREFIX_LEN)) + +$(PATCH_BUILD): + (cp -R $(PATCH) $(PATCH_BUILD)) + +# Copy/link configured files from the original GNUR to patch-build +$(PATCH_BUILD)/Makefile: + ln -s $(GNUR_HOME_BINARY)/tools $(PATCH_BUILD)/tools + ln -s $(GNUR_HOME_BINARY)/etc $(PATCH_BUILD)/etc + ln -s $(GNUR_HOME_BINARY)/share $(PATCH_BUILD)/share + ln -s $(GNUR_HOME_BINARY)/doc $(PATCH_BUILD)/doc + ln -s $(GNUR_HOME_BINARY)/config.status $(PATCH_BUILD)/config.status + ln -s $(GNUR_HOME_BINARY)/config.log $(PATCH_BUILD)/config.log + for target in $(IN_FILES); do \ + f=`echo $$target | cut -c $(IN_FILES_PREFIX_LEN)-`; \ + cp -v $(GNUR_HOME_BINARY)$$f $(PATCH_BUILD)$$f; \ + done + +$(PATCH_BUILD)/include: + $(MAKE) -C $(PATCH_BUILD)/src/include + +clean: cleanpatchbuild cleaniconv rm -f Makeconf.done -cleangnur: - rm -rf R-$(R_VERSION) +cleanpatchbuild: + rm -rf $(PATCH_BUILD) ifeq ($(OSNAME), SunOS) cleaniconv: diff --git a/com.oracle.truffle.r.native/gnur/Makefile.libs b/com.oracle.truffle.r.native/gnur/Makefile.libs index 7e6fa89861..c27c541500 100644 --- a/com.oracle.truffle.r.native/gnur/Makefile.libs +++ b/com.oracle.truffle.r.native/gnur/Makefile.libs @@ -45,11 +45,11 @@ all: $(FASTR_LIB_DIR) $(BLAS_TARGET) $(LAPACK_TARGET) rcopylib.done $(FASTR_LIB_DIR): mkdir -p $(FASTR_LIB_DIR) -$(BLAS_TARGET): $(GNUR_HOME)/lib/libRblas$(DYLIB_EXT) - cp $(GNUR_HOME)/lib/libRblas$(DYLIB_EXT) $(BLAS_TARGET) +$(BLAS_TARGET): $(GNUR_HOME_BINARY)/lib/libRblas$(DYLIB_EXT) + cp $(GNUR_HOME_BINARY)/lib/libRblas$(DYLIB_EXT) $(BLAS_TARGET) -$(LAPACK_TARGET): $(GNUR_HOME)/lib/libRlapack$(DYLIB_EXT) - cp $(GNUR_HOME)/lib/libRlapack$(DYLIB_EXT) $(LAPACK_TARGET) +$(LAPACK_TARGET): $(GNUR_HOME_BINARY)/lib/libRlapack$(DYLIB_EXT) + cp $(GNUR_HOME_BINARY)/lib/libRlapack$(DYLIB_EXT) $(LAPACK_TARGET) ifeq ($(OS_NAME),Darwin) # libRblas depends on libgfortran, libquadmath # libRlapack depends on libgfortran, libquadmath, libRblas, libR diff --git a/com.oracle.truffle.r.native/gnur/Makefile.platform b/com.oracle.truffle.r.native/gnur/Makefile.platform index 8366712be3..df1c5674e5 100644 --- a/com.oracle.truffle.r.native/gnur/Makefile.platform +++ b/com.oracle.truffle.r.native/gnur/Makefile.platform @@ -35,8 +35,6 @@ all: $(TOPDIR)/platform.mk $(TOPDIR)/platform.mk: sedMakeconf $(GNUR_HOME)/Makeconf Makefile sed -f sedMakeconf $(GNUR_HOME)/Makeconf > /dev/null 2>&1 - sed -f sedEtcMakeconf $(GNUR_HOME)/etc/Makeconf > /dev/null 2>&1 - cat platform.mk.temp1 platform.mk.temp2 > platform.mk.temp ed platform.mk.temp < edAddFASTR ifeq ($(FASTR_RFFI),llvm) ed platform.mk.temp <edLLVM diff --git a/com.oracle.truffle.r.native/library/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/Makefile similarity index 95% rename from com.oracle.truffle.r.native/library/Makefile rename to com.oracle.truffle.r.native/gnur/patch/src/library/Makefile index 3403b6835e..7c53c00be0 100644 --- a/com.oracle.truffle.r.native/library/Makefile +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/com.oracle.truffle.r.native/library/base/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/base/Makefile similarity index 79% rename from com.oracle.truffle.r.native/library/base/Makefile rename to com.oracle.truffle.r.native/gnur/patch/src/library/base/Makefile index 1609a5e864..ae24f4da0f 100644 --- a/com.oracle.truffle.r.native/library/base/Makefile +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/base/Makefile @@ -35,22 +35,22 @@ ifeq ($(FASTR_RFFI),managed) # The following changes GnuR's build script makebasedb.R so that it does not # compress the lazy load database, then it (re)builds GnuR pre.done: - cp $(GNUR_HOME)/src/library/base/makebasedb.R $(GNUR_HOME)/src/library/base/makebasedb.R.tmp - sed 's|compress = TRUE|compress = FALSE|g' $(GNUR_HOME)/src/library/base/makebasedb.R.tmp > $(GNUR_HOME)/src/library/base/makebasedb.R + cp $(GNUR_HOME_BINARY)/src/library/base/makebasedb.R $(GNUR_HOME_BINARY)/src/library/base/makebasedb.R.tmp + sed 's|compress = TRUE|compress = FALSE|g' $(GNUR_HOME_BINARY)/src/library/base/makebasedb.R.tmp > $(GNUR_HOME_BINARY)/src/library/base/makebasedb.R # force a base rebuild - rm $(GNUR_HOME)/src/library/base/all.R - (cd $(GNUR_HOME); $(MAKE)) + rm $(GNUR_HOME_BINARY)/src/library/base/all.R + (cd $(GNUR_HOME_BINARY); $(MAKE)) touch pre.done # original base assumes that "base" DLL is loaded, we change it to check for that first post.done: sed 's|## populate C\/Fortran symbols|if (length(getLoadedDLLs()) > 0)|g' $(FASTR_LIBRARY_DIR)/base/R/base > $(FASTR_LIBRARY_DIR)/base/R/base.tmp mv $(FASTR_LIBRARY_DIR)/base/R/base.tmp $(FASTR_LIBRARY_DIR)/base/R/base - mv $(GNUR_HOME)/src/library/base/makebasedb.R.tmp $(GNUR_HOME)/src/library/base/makebasedb.R + mv $(GNUR_HOME_BINARY)/src/library/base/makebasedb.R.tmp $(GNUR_HOME_BINARY)/src/library/base/makebasedb.R # force a base rebuild - rm $(GNUR_HOME)/src/library/base/all.R + rm $(GNUR_HOME_BINARY)/src/library/base/all.R # rebuild GNU R in compressed mode - (cd $(GNUR_HOME); $(MAKE)) + (cd $(GNUR_HOME_BINARY); $(MAKE)) touch post.done find $(FASTR_LIBRARY_DIR)/base -exec touch {} + diff --git a/com.oracle.truffle.r.native/gnur/patch/src/library/base/makebasedb.R b/com.oracle.truffle.r.native/gnur/patch/src/library/base/makebasedb.R deleted file mode 100644 index 893397c9b2..0000000000 --- a/com.oracle.truffle.r.native/gnur/patch/src/library/base/makebasedb.R +++ /dev/null @@ -1,130 +0,0 @@ -# File src/library/base/makebasedb.R -# Part of the R package, https://www.R-project.org -# -# Copyright (C) 1995-2012 The R Core Team -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# A copy of the GNU General Public License is available at -# https://www.R-project.org/Licenses/ - -local({ - makeLazyLoadDB <- function(from, filebase, compress = TRUE, ascii = FALSE, - variables) { - - envlist <- function(e) - .Internal(getVarsFromFrame(ls(e, all = TRUE), e, FALSE)) - - envtable <- function() { - idx <- 0 - envs <- NULL - enames <- character(0) - find <- function(v, keys, vals) { - for (i in seq_along(keys)) - if (identical(v, keys[[i]])) - return(vals[i]) - NULL - } - getname <- function(e) find(e, envs, enames) - getenv <- function(n) find(n, enames, envs) - insert <- function(e) { - idx <<- idx + 1 - name <- paste("env", idx, sep="::") - envs <<- c(e, envs) - enames <<- c(name, enames) - name - } - list(insert = insert, getenv = getenv, getname = getname) - } - - lazyLoadDBinsertValue <- function(value, file, ascii, compress, hook) - .Internal(lazyLoadDBinsertValue(value, file, ascii, compress, hook)) - - lazyLoadDBinsertListElement <- function(x, i, file, ascii, compress, hook) - .Internal(lazyLoadDBinsertValue(x[[i]], file, ascii, compress, hook)) - - lazyLoadDBinsertVariable <- function(n, e, file, ascii, compress, hook) { - x <- .Internal(getVarsFromFrame(n, e, FALSE)) - .Internal(lazyLoadDBinsertValue(x[[1L]], file, ascii, compress, hook)) - } - - mapfile <- paste(filebase, "rdx", sep = ".") - datafile <- paste(filebase, "rdb", sep = ".") - close(file(datafile, "w")) # truncate to zero - table <- envtable() - varenv <- new.env(hash = TRUE) - envenv <- new.env(hash = TRUE) - - envhook <- function(e) { - if (is.environment(e)) { - name <- table$getname(e) - if (is.null(name)) { - name <- table$insert(e) - data <- list(bindings = envlist(e), - enclos = parent.env(e)) - key <- lazyLoadDBinsertValue(data, datafile, ascii, - compress, envhook) - assign(name, key, envir = envenv) - } - name - } - } - - if (is.environment(from)) { - if (! missing(variables)) - vars <- variables - else vars <- ls(from, all = TRUE) - } - else if (is.list(from)) { - vars <- names(from) - if (length(vars) != length(from) || any(nchar(vars) == 0)) - stop("source list must have names for all elements") - } - else stop("source must be an environment or a list"); - - for (i in seq_along(vars)) { - if (is.environment(from)) - key <- lazyLoadDBinsertVariable(vars[i], from, datafile, - ascii, compress, envhook) - else key <- lazyLoadDBinsertListElement(from, i, datafile, ascii, - compress, envhook) - assign(vars[i], key, envir = varenv) - } - - vals <- lapply(vars, get, envir = varenv, inherits = FALSE) - names(vals) <- vars - - rvars <- ls(envenv, all = TRUE) - rvals <- lapply(rvars, get, envir = envenv, inherits = FALSE) - names(rvals) <- rvars - - val <- list(variables = vals, references = rvals, - compressed = compress) - saveRDS(val, mapfile) - } - - omit <- c(".Last.value", ".AutoloadEnv", ".BaseNamespaceEnv", - ".Device", ".Devices", ".Machine", ".Options", ".Platform") - - if (length(search()[search()!="Autoloads"]) != 2) - stop("start R with NO packages loaded to create the data base") - - baseFileBase <- file.path(.Library,"base","R","base") - - if (file.info(baseFileBase)["size"] < 20000) # crude heuristic - stop("may already be using lazy loading on base"); - - basevars <- ls(baseenv(), all.names=TRUE) - prims <- basevars[sapply(basevars, function(n) is.primitive(get(n, baseenv())))] - basevars <- basevars[! basevars %in% c(omit, prims)] - - makeLazyLoadDB(baseenv(), baseFileBase, variables = basevars) -}) diff --git a/com.oracle.truffle.r.native/library/base/src/registration.c b/com.oracle.truffle.r.native/gnur/patch/src/library/base/src/registration.c similarity index 100% rename from com.oracle.truffle.r.native/library/base/src/registration.c rename to com.oracle.truffle.r.native/gnur/patch/src/library/base/src/registration.c diff --git a/com.oracle.truffle.r.native/library/compiler/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/compiler/Makefile similarity index 94% rename from com.oracle.truffle.r.native/library/compiler/Makefile rename to com.oracle.truffle.r.native/gnur/patch/src/library/compiler/Makefile index 5d04f5a444..1a7107cd22 100644 --- a/com.oracle.truffle.r.native/library/compiler/Makefile +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/compiler/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/com.oracle.truffle.r.native/library/datasets/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/datasets/Makefile similarity index 94% rename from com.oracle.truffle.r.native/library/datasets/Makefile rename to com.oracle.truffle.r.native/gnur/patch/src/library/datasets/Makefile index 5d04f5a444..1a7107cd22 100644 --- a/com.oracle.truffle.r.native/library/datasets/Makefile +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/datasets/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/com.oracle.truffle.r.native/library/grDevices/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/Makefile similarity index 77% rename from com.oracle.truffle.r.native/library/grDevices/Makefile rename to com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/Makefile index 50e82ab7af..98589165bf 100644 --- a/com.oracle.truffle.r.native/library/grDevices/Makefile +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -37,24 +37,19 @@ GNUR_GZIO_H := $(GNUR_HOME)/src/main/gzio.h GNUR_SRC_CAIRO := $(GNUR_HOME)/src/library/grDevices/src/cairo GNUR_CAIRO_C_SOURCES := $(notdir $(wildcard $(GNUR_SRC_CAIRO)/*.c)) # not compiling Cairo currently -GNUR_C_SOURCES := axis_scales.c chull.c colors.c devCairo.c devPS.c devPicTeX.c devQuartz.c \ - devices.c init.c stubs.c ifeq ($(OS_NAME), Darwin) -ifneq ($(shell grep HAVE_AQUA $(GNUR_HOME)/config.log),) - GNUR_C_SOURCES := $(GNUR_C_SOURCES) qdBitmap.c qdPDF.c +ifeq ($(shell grep HAVE_AQUA $(GNUR_HOME)/config.log),) + C_SOURCES_EXCLUDED := src/qdBitmap.c src/qdPDF.c endif endif -GNUR_C_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_C_SOURCES:.c=.o)) - -include ../lib.mk include $(TOPDIR)/fficall/src/include/gnurheaders.mk +PKG_INCLUDES := $(GNUR_INCLUDES) $(GNUR_HEADER_DEFS) $(GRDEV_INCLUDES) +# Suppress warnings +XTRA_C_OPTS := -Wno-int-conversion -Wno-implicit-function-declaration -#CFLAGS := $(CFLAGS) -H - -$(OBJ)/%.o: $(GNUR_SRC)/%.c - $(CC) $(CFLAGS) $(INCLUDES) $(GNUR_INCLUDES) $(GNUR_HEADER_DEFS) $(GRDEV_INCLUDES) $(SUPPRESS_WARNINGS) -c $< -o $@ +include ../lib.mk $(OBJ)/%.o: $(GNUR_SRC_CAIRO)/%.c $(CC) $(CFLAGS) $(INCLUDES) $(GNUR_INCLUDES) $(GNUR_HEADER_DEFS) $(GRDEV_INCLUDES) $(SUPPRESS_WARNINGS) -c $< -o $@ diff --git a/com.oracle.truffle.r.native/library/grDevices/src/gzio.c b/com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/gzio.c similarity index 89% rename from com.oracle.truffle.r.native/library/grDevices/src/gzio.c rename to com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/gzio.c index d401654498..58cd1e36b3 100644 --- a/com.oracle.truffle.r.native/library/grDevices/src/gzio.c +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/gzio.c @@ -6,7 +6,7 @@ * Copyright (c) 1995, 1996, 1997 Robert Gentleman and Ross Ihaka * Copyright (c) 1995-2014, The R Core Team * Copyright (c) 2002-2008, The R Foundation - * Copyright (c) 2015, 2016, Oracle and/or its affiliates + * Copyright (c) 2015, 2017, Oracle and/or its affiliates * * All rights reserved. */ diff --git a/com.oracle.truffle.r.native/library/graphics/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/graphics/Makefile similarity index 75% rename from com.oracle.truffle.r.native/library/graphics/Makefile rename to com.oracle.truffle.r.native/gnur/patch/src/library/graphics/Makefile index 8a38d40ecb..ca7d3bacbf 100644 --- a/com.oracle.truffle.r.native/library/graphics/Makefile +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/graphics/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -23,22 +23,18 @@ OBJ = lib +include $(TOPDIR)/fficall/src/include/gnurheaders.mk + +C_SOURCES_EXCLUDED := src/par-common.c + GNUR_INCLUDES := -I$(TOPDIR)/fficall/src/include GRAPHICS_INCLUDES := -I$(GNUR_HOME)/src/library/graphics - -GNUR_C_SOURCES := base.c graphics.c init.c par.c plot.c plot3d.c stem.c - -GNUR_C_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_C_SOURCES:.c=.o)) +PKG_INCLUDES := $(GNUR_INCLUDES) $(GNUR_HEADER_DEFS) $(GRAPHICS_INCLUDES) +# Suppress warnings +XTRA_C_OPTS := -Wno-int-conversion -Wno-implicit-function-declaration include ../lib.mk -include $(TOPDIR)/fficall/src/include/gnurheaders.mk - -#CFLAGS := $(CFLAGS) -H - # plot.c needs to include the GNUR internal Print.h -$(OBJ)/plot.o: $(GNUR_SRC)/plot.c +$(OBJ)/plot.o: src/plot.c $(CC) $(CFLAGS) $(GNUR_INCLUDES) $(INCLUDES) $(GNUR_HEADER_DEFS) $(GRAPHICS_INCLUDES) $(SUPPRESS_WARNINGS) -c $< -o $@ - -$(OBJ)/%.o: $(GNUR_SRC)/%.c - $(CC) $(CFLAGS) $(INCLUDES) $(GNUR_INCLUDES) $(GNUR_HEADER_DEFS) $(GRAPHICS_INCLUDES) $(SUPPRESS_WARNINGS) -c $< -o $@ diff --git a/com.oracle.truffle.r.native/gnur/patch/src/library/grid/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/grid/Makefile new file mode 100644 index 0000000000..8f0b5733c9 --- /dev/null +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/grid/Makefile @@ -0,0 +1,27 @@ +# +# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# This is necessary so that #include "grid.h" works +PKG_INCLUDES = -I src + +include ../lib.mk diff --git a/com.oracle.truffle.r.native/library/lib.mk b/com.oracle.truffle.r.native/gnur/patch/src/library/lib.mk similarity index 75% rename from com.oracle.truffle.r.native/library/lib.mk rename to com.oracle.truffle.r.native/gnur/patch/src/library/lib.mk index 997d88708b..907b4c582d 100644 --- a/com.oracle.truffle.r.native/library/lib.mk +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/lib.mk @@ -29,11 +29,15 @@ # A package that requires special processing before the library is built should # define LIB_PKG_PRE and for post processing define LIB_PKG_POST in its Makefile. -# If a package-specfic clean is needed it should define CLEAN_PKG +# If a package-specfic clean is needed it should define CLEAN_PKG. PKG_INCLUDES can be +# used to define package-specific includes. XTRA_C_OBJECTS can be used to specify extra +# object files. PKG_LIBS can specify additional libraries required by the package. +# XTRA_C_OPTS and XTRA_F_OPTS can be used to specify additional C/Fortran compiler options. -# A package may include C and Fortran code compiled directly from the GnuR code base, -# but using FastR headers. This is handled by the package defining the variables -# GNUR_C_OBJECTS and GNUR_F_OBJECTS before including this file. +# A package uses C_SOURCES_EXCLUDED and F_SOURCES_EXCLUDED to specify excluded C/Fortran +# sources. + +# If no library file is produced, a package sets NO_LIBRARY to 1. ifneq ($(MAKECMDGOALS),clean) include $(TOPDIR)/platform.mk @@ -43,19 +47,16 @@ endif PKG = $(PACKAGE) -ifeq ($(GNUR_HOME),) -$(error must be run from top-level) -endif - SRC = src OBJ = lib -GNUR_SRC = $(GNUR_HOME)/src/library/$(PKG)/src C_SOURCES := $(wildcard $(SRC)/*.c) +C_SOURCES := $(filter-out $(C_SOURCES_EXCLUDED), $(C_SOURCES)) C_OBJECTS := $(subst $(SRC)/,$(OBJ)/,$(C_SOURCES:.c=.o)) F_SOURCES := $(wildcard $(SRC)/*.f) +F_SOURCES := $(filter-out $(F_SOURCES_EXCLUDED), $(F_SOURCES)) F_OBJECTS := $(subst $(SRC)/,$(OBJ)/,$(F_SOURCES:.f=.o)) @@ -69,7 +70,6 @@ LIB_PKG := $(OBJ)/$(PKG).so JNI_INCLUDES = -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/$(JDK_OS_DIR) FFI_INCLUDES = -I$(TOPDIR)/include -I$(TOPDIR)/include/R_ext -#$(info PKG_INCLUDES=$(PKG_INCLUDES)) INCLUDES := $(JNI_INCLUDES) $(FFI_INCLUDES) $(PKG_INCLUDES) PKGDIR := $(FASTR_LIBRARY_DIR)/$(PKG) @@ -88,24 +88,21 @@ endif libcommon: $(PKGDIR) -$(PKGDIR): $(GNUR_HOME)/library/$(PKG) - (cd $(GNUR_HOME)/library; tar cf - $(PKG)) | (cd $(FASTR_LIBRARY_DIR); tar xf -) +# Copy the package's artifacts to FASTR_LIBRARY_DIR. The binaries will be replaced at a later stage. +$(PKGDIR): $(GNUR_HOME_BINARY)/library/$(PKG) + (cd $(GNUR_HOME_BINARY)/library; tar cf - $(PKG)) | (cd $(FASTR_LIBRARY_DIR); tar xf -) touch $(PKGDIR) $(C_OBJECTS): | $(OBJ) $(F_OBJECTS): | $(OBJ) -$(GNUR_C_OBJECTS): | $(OBJ) - -$(GNUR_F_OBJECTS): | $(OBJ) - $(OBJ): mkdir -p $(OBJ) -$(LIB_PKG): $(C_OBJECTS) $(F_OBJECTS) $(GNUR_C_OBJECTS) $(GNUR_F_OBJECTS) $(PKGDIR) $(XTRA_C_OBJECTS) +$(LIB_PKG): $(C_OBJECTS) $(F_OBJECTS) $(PKGDIR) $(XTRA_C_OBJECTS) mkdir -p $(LIBDIR) - $(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(LIB_PKG) $(C_OBJECTS) $(F_OBJECTS) $(GNUR_C_OBJECTS) $(GNUR_F_OBJECTS) $(XTRA_C_OBJECTS) $(PKG_LIBS) + $(DYLIB_LD) $(DYLIB_LDFLAGS) -o $(LIB_PKG) $(C_OBJECTS) $(F_OBJECTS) $(XTRA_C_OBJECTS) $(PKG_LIBS) mkdir -p $(FASTR_LIBRARY_DIR)/$(PKG)/libs cp $(LIB_PKG) $(FASTR_LIBRARY_DIR)/$(PKG)/libs ifeq ($(OS_NAME),Darwin) @@ -115,10 +112,10 @@ endif endif $(OBJ)/%.o: $(SRC)/%.c $(H_SOURCES) - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ + $(CC) $(CFLAGS) $(INCLUDES) $(XTRA_C_OPTS) -c $< -o $@ $(OBJ)/%.o: $(SRC)/%.f - $(F77) $(FFLAGS) $(FPICFLAGS) -c $< -o $@ + $(F77) $(FFLAGS) $(FPICFLAGS) $(XTRA_F_OPTS) -c $< -o $@ clean: $(CLEAN_PKG) rm -rf $(LIBDIR)/* diff --git a/com.oracle.truffle.r.native/library/splines/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/methods/Makefile similarity index 93% rename from com.oracle.truffle.r.native/library/splines/Makefile rename to com.oracle.truffle.r.native/gnur/patch/src/library/methods/Makefile index f128fcf8a4..bc0ffdd0d4 100644 --- a/com.oracle.truffle.r.native/library/splines/Makefile +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/methods/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/com.oracle.truffle.r.native/library/methods/src/methods_dummy.c b/com.oracle.truffle.r.native/gnur/patch/src/library/methods/src/methods_dummy.c similarity index 100% rename from com.oracle.truffle.r.native/library/methods/src/methods_dummy.c rename to com.oracle.truffle.r.native/gnur/patch/src/library/methods/src/methods_dummy.c diff --git a/com.oracle.truffle.r.native/gnur/patch/src/library/parallel/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/parallel/Makefile new file mode 100644 index 0000000000..ad579cd8aa --- /dev/null +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/parallel/Makefile @@ -0,0 +1,26 @@ +# +# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +PKG_INCLUDES = -I src + +include ../lib.mk diff --git a/com.oracle.truffle.r.native/library/parallel/src/parallel_dummy.c b/com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/parallel_dummy.c similarity index 100% rename from com.oracle.truffle.r.native/library/parallel/src/parallel_dummy.c rename to com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/parallel_dummy.c diff --git a/com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/rngstream.c b/com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/rngstream.c index 3de81fbbcb..c39ff48825 100644 --- a/com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/rngstream.c +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/rngstream.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, a copy is available at - * https://www.R-project.org/Licenses/ + * http://www.r-project.org/Licenses/ */ #include "parallel.h" diff --git a/com.oracle.truffle.r.native/gnur/patch/src/library/splines/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/splines/Makefile new file mode 100644 index 0000000000..bc0ffdd0d4 --- /dev/null +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/splines/Makefile @@ -0,0 +1,24 @@ +# +# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +include ../lib.mk diff --git a/com.oracle.truffle.r.native/gnur/patch/src/library/splines/src/splines.c b/com.oracle.truffle.r.native/gnur/patch/src/library/splines/src/splines.c index 1bbae7b895..ccfaecb2d1 100644 --- a/com.oracle.truffle.r.native/gnur/patch/src/library/splines/src/splines.c +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/splines/src/splines.c @@ -2,7 +2,6 @@ * S or S-PLUS or R. * * Copyright (C) 1998 Douglas M. Bates and William N. Venables. - * Copyright (C) 1999-2017 The R Core Team. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -16,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, a copy is available at - * https://www.R-project.org/Licenses/ + * http://www.r-project.org/Licenses/ * * The routines are loosely based on the pseudo-code in Schumacher (Wiley, * 1981) and the CMLIB library DBSPLINES. @@ -24,7 +23,6 @@ #include <R.h> #include <Rinternals.h> -#include <string.h> // for memcpy #ifdef ENABLE_NLS #include <libintl.h> @@ -90,21 +88,17 @@ diff_table(splPTR sp, double x, int ndiff) static void basis_funcs(splPTR sp, double x, double *b) { + int j, r; + double saved, term; + diff_table(sp, x, sp->ordm1); b[0] = 1.; - for (int j = 1; j <= sp->ordm1; j++) { - double saved = 0.; - for (int r = 0; r < j; r++) { // do not divide by zero - double den = sp->rdel[r] + sp->ldel[j - 1 - r]; - if(den != 0) { - double term = b[r]/den; - b[r] = saved + sp->rdel[r] * term; - saved = sp->ldel[j - 1 - r] * term; - } else { - if(r != 0 || sp->rdel[r] != 0.) - b[r] = saved; - saved = 0.; - } + for (j = 1; j <= sp->ordm1; j++) { + saved = 0.; + for (r = 0; r < j; r++) { // FIXME: divides by zero + term = b[r]/(sp->rdel[r] + sp->ldel[j - 1 - r]); + b[r] = saved + sp->rdel[r] * term; + saved = sp->ldel[j - 1 - r] * term; } b[j] = saved; } @@ -141,41 +135,41 @@ spline_value(SEXP knots, SEXP coeff, SEXP order, SEXP x, SEXP deriv) SEXP val; splPTR sp; double *xx, *kk; - int n, nk; + int der, i, n, nk; PROTECT(knots = coerceVector(knots, REALSXP)); kk = REAL(knots); nk = length(knots); PROTECT(coeff = coerceVector(coeff, REALSXP)); PROTECT(x = coerceVector(x, REALSXP)); - xx = REAL(x); n = length(x); - int ord = asInteger(order); - int der = asInteger(deriv); - if (ord == NA_INTEGER || ord <= 0) - error(_("'ord' must be a positive integer")); + n = length(x); + xx = REAL(x); + PROTECT(order = coerceVector(order, INTSXP)); + PROTECT(deriv = coerceVector(deriv, INTSXP)); + der = INTEGER(deriv)[0]; + PROTECT(val = allocVector(REALSXP, n)); /* populate the spl_struct */ + sp = (struct spl_struct *) R_alloc(1, sizeof(struct spl_struct)); - sp->order = ord; - sp->ordm1 = ord - 1; + sp->order = INTEGER(order)[0]; + if (sp->order <= 0) { error(_("'ord' must be a positive integer")); } + sp->ordm1 = sp->order - 1; sp->ldel = (double *) R_alloc(sp->ordm1, sizeof(double)); sp->rdel = (double *) R_alloc(sp->ordm1, sizeof(double)); sp->knots = kk; sp->nknots = nk; sp->coeff = REAL(coeff); sp->a = (double *) R_alloc(sp->order, sizeof(double)); - PROTECT(val = allocVector(REALSXP, n)); - double *rval = REAL(val); - - for (int i = 0; i < n; i++) { + for (i = 0; i < n; i++) { set_cursor(sp, xx[i]); if (sp->curs < sp->order || sp->curs > (nk - sp->order)) { - rval[i] = R_NaN; + REAL(val)[i] = R_NaN; } else { - Memcpy(sp->a, sp->coeff + sp->curs - sp->order, sp->order); - rval[i] = evaluate(sp, xx[i], der); + Memcpy(sp->a, REAL(coeff) + sp->curs - sp->order, sp->order); + REAL(val)[i] = evaluate(sp, xx[i], der); } } - UNPROTECT(4); + UNPROTECT(6); return val; } @@ -185,69 +179,68 @@ spline_basis(SEXP knots, SEXP order, SEXP xvals, SEXP derivs) { /* evaluate the non-zero B-spline basis functions (or their derivatives) * at xvals. */ + int nd, nk, nx, i, j, *ders; + double *kk, *xx; + SEXP val, offsets; + splPTR sp = (struct spl_struct *) R_alloc(1, sizeof(struct spl_struct)); PROTECT(knots = coerceVector(knots, REALSXP)); - double *kk = REAL(knots); int nk = length(knots); - int ord = asInteger(order); + kk = REAL(knots); nk = length(knots); + PROTECT(order = coerceVector(order, INTSXP)); PROTECT(xvals = coerceVector(xvals, REALSXP)); - double *xx = REAL(xvals); int nx = length(xvals); + xx = REAL(xvals); nx = length(xvals); PROTECT(derivs = coerceVector(derivs, INTSXP)); - int *ders = INTEGER(derivs), nd = length(derivs); + ders = INTEGER(derivs); nd = length(derivs); - splPTR sp = (struct spl_struct *) R_alloc(1, sizeof(struct spl_struct)); /* fill sp : */ - sp->order = ord; - sp->ordm1 = ord - 1; + sp->order = INTEGER(order)[0]; + sp->ordm1 = sp->order - 1; sp->rdel = (double *) R_alloc(sp->ordm1, sizeof(double)); sp->ldel = (double *) R_alloc(sp->ordm1, sizeof(double)); sp->knots = kk; sp->nknots = nk; sp->a = (double *) R_alloc(sp->order, sizeof(double)); - SEXP val = PROTECT(allocMatrix(REALSXP, sp->order, nx)), - offsets = PROTECT(allocVector(INTSXP, nx)); - double *valM = REAL(val); - int *ioff = INTEGER(offsets); + PROTECT(val = allocMatrix(REALSXP, sp->order, nx)); + PROTECT(offsets = allocVector(INTSXP, nx)); - for(int i = 0; i < nx; i++) { + for(i = 0; i < nx; i++) { set_cursor(sp, xx[i]); - int io = ioff[i] = sp->curs - sp->order; - if (io < 0 || io > nk) { - for (int j = 0; j < sp->order; j++) { - valM[i * sp->order + j] = R_NaN; + INTEGER(offsets)[i] = j = sp->curs - sp->order; + if (j < 0 || j > nk) { + for (j = 0; j < sp->order; j++) { + REAL(val)[i * sp->order + j] = R_NaN; } - } else if (ders[i % nd] > 0) { /* slow method for derivatives */ - for(int ii = 0; ii < sp->order; ii++) { - for(int j = 0; j < sp->order; j++) sp->a[j] = 0; - sp->a[ii] = 1; - valM[i * sp->order + ii] = - evaluate(sp, xx[i], ders[i % nd]); + } else { + if (ders[i % nd] > 0) { /* slow method for derivatives */ + int ii; + for(ii = 0; ii < sp->order; ii++) { + for(j = 0; j < sp->order; j++) sp->a[j] = 0; + sp->a[ii] = 1; + REAL(val)[i * sp->order + ii] = + evaluate(sp, xx[i], ders[i % nd]); + } + } else { /* fast method for value */ + basis_funcs(sp, xx[i], REAL(val) + i * sp->order); } - } else { /* fast method for value */ - basis_funcs(sp, xx[i], valM + i * sp->order); } } setAttrib(val, install("Offsets"), offsets); - UNPROTECT(5); + UNPROTECT(6); return val; } #include <R_ext/Rdynload.h> -#define CALLDEF(name, n) {#name, (DL_FUNC) &name, n} - -static const R_CallMethodDef R_CallDef[] = { - CALLDEF(spline_basis, 4), - CALLDEF(spline_value, 5), - {NULL, NULL, 0} +const static R_CallMethodDef R_CallDef[] = { + {"spline_basis", (DL_FUNC)&spline_basis, 4}, + {"spline_value", (DL_FUNC)&spline_value, 5}, + {NULL, NULL, 0} }; void -#ifdef HAVE_VISIBILITY_ATTRIBUTE -__attribute__ ((visibility ("default"))) -#endif R_init_splines(DllInfo *dll) { R_registerRoutines(dll, NULL, R_CallDef, NULL, NULL); R_useDynamicSymbols(dll, FALSE); - R_forceSymbols(dll, TRUE); +// R_forceSymbols(dll, TRUE); // too few to worry about, used in cobs* } diff --git a/com.oracle.truffle.r.native/library/utils/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/Makefile similarity index 64% rename from com.oracle.truffle.r.native/library/utils/Makefile rename to com.oracle.truffle.r.native/gnur/patch/src/library/stats/Makefile index 5f351596d4..20981356dc 100644 --- a/com.oracle.truffle.r.native/library/utils/Makefile +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -20,16 +20,18 @@ # or visit www.oracle.com if you need additional information or have any # questions. # +# +# Completeness of the stats package is a work in progress +# Currently we compile a subset of the .c and .f files from the +# GnuR stats library source - those that do not depend on GnuR internals (always true for .f) +# Also do some necessary modifications to a copy of fft.c. -OBJ = lib - -GNUR_C_FILES = init.c +# have to include this here for PKG_LIBS +ifneq ($(MAKECMDGOALS),clean) +include $(TOPDIR)/platform.mk +endif -GNUR_C_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_C_FILES:.c=.o)) +PKG_LIBS := $(LAPACK_LIBS) $(BLAS_LIBS) -L$(FASTR_LIB_DIR) $(FLIBS) +PKG_INCLUDES = -I src include ../lib.mk - -$(C_OBJECTS): | $(OBJ) - -$(OBJ)/%.o: $(GNUR_SRC)/%.c - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ diff --git a/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/fft.c b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/fft.c index 451bd8d5a0..4b25faf447 100644 --- a/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/fft.c +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/fft.c @@ -18,16 +18,22 @@ * https://www.R-project.org/Licenses/ */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +//#ifdef HAVE_CONFIG_H +//#include <config.h> +//#endif #include <limits.h> /* for INT_MAX */ #include <stddef.h> /* for size_t */ #include <stdlib.h> /* for abs */ #include <math.h> -#include <Rmath.h> /* for imax2(.),..*/ -#include <R_ext/Applic.h> +//#include <Rmath.h> /* for imax2(.),..*/ +//#include <R_ext/Applic.h> +#define imax2(_x,_y) ((_x<_y) ? _y : _x) +#define imin2(_x,_y) ((_x<_y) ? _x : _y) +#define Rboolean int +#define FALSE 0 +#define TRUE 1 +#define M_SQRT_3 1.732050807568877293527446341506 /* Fast Fourier Transform * @@ -845,9 +851,13 @@ void fft_factor(int n, int *pmaxf, int *pmaxp) } -Rboolean fft_work(double *a, double *b, int nseg, int n, int nspn, int isn, +// signature modification: +// we need to do pointer shift for imaginary parts on the callee side (below) +// rather than on the caller side as in GNU R +Rboolean fft_work(double *a, int nseg, int n, int nspn, int isn, double *work, int *iwork) { + double *b=&(a[1]); int nf, nspan, ntot; /* check that factorization was successful */ diff --git a/com.oracle.truffle.r.native/library/stats/src/gnur_extracts.c b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/gnur_extracts.c similarity index 100% rename from com.oracle.truffle.r.native/library/stats/src/gnur_extracts.c rename to com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/gnur_extracts.c diff --git a/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/nls.c b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/nls.c index ad230bd4c7..5a84c1f0b1 100644 --- a/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/nls.c +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/nls.c @@ -1,357 +1,26 @@ /* - * Routines used in calculating least squares solutions in a - * nonlinear model in nls library for R. - * - * Copyright 1999-2001 Douglas M. Bates - * Saikat DebRoy - * - * Copyright 2005--2016 The R Core Team - * Copyright 2006 The R Foundation + * R : A Computer Language for Statistical Data Analysis + * Copyright (C) 1997-2007 The R Core Team. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more - * details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this program; if not, a copy is available at - * https://www.R-project.org/Licenses/ + * You should have received a copy of the GNU General Public License + * along with this program; if not, a copy is available at + * http://www.r-project.org/Licenses/ */ -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include <float.h> -#include <R.h> #include <Rinternals.h> #include "nls.h" -#ifndef MIN -#define MIN(a,b) (((a)<(b))?(a):(b)) -#endif - -/* - * get the list element named str. names is the name attribute of list - */ - -static SEXP -getListElement(SEXP list, SEXP names, const char *str) -{ - SEXP elmt = (SEXP) NULL; - const char *tempChar; - int i; - - for (i = 0; i < length(list); i++) { - tempChar = CHAR(STRING_ELT(names, i)); /* ASCII only */ - if( strcmp(tempChar,str) == 0) { - elmt = VECTOR_ELT(list, i); - break; - } - } - return elmt; -} - -/* - * put some convergence-related information into list - */ -static SEXP -ConvInfoMsg(char* msg, int iter, int whystop, double fac, - double minFac, int maxIter, double convNew) -{ - const char *nms[] = {"isConv", "finIter", "finTol", - "stopCode", "stopMessage", ""}; - SEXP ans; - PROTECT(ans = mkNamed(VECSXP, nms)); - - SET_VECTOR_ELT(ans, 0, ScalarLogical(whystop == 0)); /* isConv */ - SET_VECTOR_ELT(ans, 1, ScalarInteger(iter)); /* finIter */ - SET_VECTOR_ELT(ans, 2, ScalarReal (convNew)); /* finTol */ - SET_VECTOR_ELT(ans, 3, ScalarInteger(whystop)); /* stopCode */ - SET_VECTOR_ELT(ans, 4, mkString(msg)); /* stopMessage */ - - UNPROTECT(1); - return ans; -} - - -/* - * call to nls_iter from R --- .Call("nls_iter", m, control, doTrace) - * where m and control are nlsModel and nlsControl objects - * doTrace is a logical value. - * m is modified; the return value is a "convergence-information" list. - */ -SEXP -nls_iter(SEXP m, SEXP control, SEXP doTraceArg) -{ - double dev, fac, minFac, tolerance, newDev, convNew = -1./*-Wall*/; - int i, j, maxIter, hasConverged, nPars, doTrace, evaltotCnt = -1, warnOnly, printEval; - SEXP tmp, conv, incr, deviance, setPars, getPars, pars, newPars, trace; - - doTrace = asLogical(doTraceArg); - - if(!isNewList(control)) - error(_("'control' must be a list")); - if(!isNewList(m)) - error(_("'m' must be a list")); - - PROTECT(tmp = getAttrib(control, R_NamesSymbol)); - - conv = getListElement(control, tmp, "maxiter"); - if(conv == NULL || !isNumeric(conv)) - error(_("'%s' absent"), "control$maxiter"); - maxIter = asInteger(conv); - - conv = getListElement(control, tmp, "tol"); - if(conv == NULL || !isNumeric(conv)) - error(_("'%s' absent"), "control$tol"); - tolerance = asReal(conv); - - conv = getListElement(control, tmp, "minFactor"); - if(conv == NULL || !isNumeric(conv)) - error(_("'%s' absent"), "control$minFactor"); - minFac = asReal(conv); - - conv = getListElement(control, tmp, "warnOnly"); - if(conv == NULL || !isLogical(conv)) - error(_("'%s' absent"), "control$warnOnly"); - warnOnly = asLogical(conv); - - conv = getListElement(control, tmp, "printEval"); - if(conv == NULL || !isLogical(conv)) - error(_("'%s' absent"), "control$printEval"); - printEval = asLogical(conv); - -#define CONV_INFO_MSG(_STR_, _I_) \ - ConvInfoMsg(_STR_, i, _I_, fac, minFac, maxIter, convNew) - -#define NON_CONV_FINIS(_ID_, _MSG_) \ - if(warnOnly) { \ - warning(_MSG_); \ - return CONV_INFO_MSG(_MSG_, _ID_); \ - } \ - else \ - error(_MSG_); - -#define NON_CONV_FINIS_1(_ID_, _MSG_, _A1_) \ - if(warnOnly) { \ - char msgbuf[1000]; \ - warning(_MSG_, _A1_); \ - snprintf(msgbuf, 1000, _MSG_, _A1_); \ - return CONV_INFO_MSG(msgbuf, _ID_); \ - } \ - else \ - error(_MSG_, _A1_); - -#define NON_CONV_FINIS_2(_ID_, _MSG_, _A1_, _A2_) \ - if(warnOnly) { \ - char msgbuf[1000]; \ - warning(_MSG_, _A1_, _A2_); \ - snprintf(msgbuf, 1000, _MSG_, _A1_, _A2_); \ - return CONV_INFO_MSG(msgbuf, _ID_); \ - } \ - else \ - error(_MSG_, _A1_, _A2_); - - - - /* now get parts from 'm' */ - tmp = getAttrib(m, R_NamesSymbol); - - conv = getListElement(m, tmp, "conv"); - if(conv == NULL || !isFunction(conv)) - error(_("'%s' absent"), "m$conv()"); - PROTECT(conv = lang1(conv)); - - incr = getListElement(m, tmp, "incr"); - if(incr == NULL || !isFunction(incr)) - error(_("'%s' absent"), "m$incr()"); - PROTECT(incr = lang1(incr)); - - deviance = getListElement(m, tmp, "deviance"); - if(deviance == NULL || !isFunction(deviance)) - error(_("'%s' absent"), "m$deviance()"); - PROTECT(deviance = lang1(deviance)); - - trace = getListElement(m, tmp, "trace"); - if(trace == NULL || !isFunction(trace)) - error(_("'%s' absent"), "m$trace()"); - PROTECT(trace = lang1(trace)); - - setPars = getListElement(m, tmp, "setPars"); - if(setPars == NULL || !isFunction(setPars)) - error(_("'%s' absent"), "m$setPars()"); - PROTECT(setPars); - - getPars = getListElement(m, tmp, "getPars"); - if(getPars == NULL || !isFunction(getPars)) - error(_("'%s' absent"), "m$getPars()"); - PROTECT(getPars = lang1(getPars)); - - PROTECT(pars = eval(getPars, R_GlobalEnv)); - nPars = LENGTH(pars); - - dev = asReal(eval(deviance, R_GlobalEnv)); - if(doTrace) eval(trace,R_GlobalEnv); - - fac = 1.0; - hasConverged = FALSE; - - PROTECT(newPars = allocVector(REALSXP, nPars)); - if(printEval) - evaltotCnt = 1; - for (i = 0; i < maxIter; i++) { - SEXP newIncr; - int evalCnt = -1; - if((convNew = asReal(eval(conv, R_GlobalEnv))) < tolerance) { - hasConverged = TRUE; - break; - } - PROTECT(newIncr = eval(incr, R_GlobalEnv)); - - if(printEval) - evalCnt = 1; - - while(fac >= minFac) { - if(printEval) { - Rprintf(" It. %3d, fac= %11.6g, eval (no.,total): (%2d,%3d):", - i+1, fac, evalCnt, evaltotCnt); - evalCnt++; - evaltotCnt++; - } - for(j = 0; j < nPars; j++) - REAL(newPars)[j] = REAL(pars)[j] + fac * REAL(newIncr)[j]; - - PROTECT(tmp = lang2(setPars, newPars)); - if (asLogical(eval(tmp, R_GlobalEnv))) { /* singular gradient */ - UNPROTECT(11); - - NON_CONV_FINIS(1, _("singular gradient")); - } - UNPROTECT(1); - - newDev = asReal(eval(deviance, R_GlobalEnv)); - if(printEval) - Rprintf(" new dev = %g\n", newDev); - if(newDev <= dev) { - dev = newDev; - fac = MIN(2*fac, 1); - tmp = newPars; - newPars = pars; - pars = tmp; - break; - } - fac /= 2.; - } - UNPROTECT(1); - if( fac < minFac ) { - UNPROTECT(9); - NON_CONV_FINIS_2(2, - _("step factor %g reduced below 'minFactor' of %g"), - fac, minFac); - } - if(doTrace) eval(trace, R_GlobalEnv); - } - - UNPROTECT(9); - if(!hasConverged) { - NON_CONV_FINIS_1(3, - _("number of iterations exceeded maximum of %d"), - maxIter); - } - /* else */ - - return CONV_INFO_MSG(_("converged"), 0); -} -#undef CONV_INFO_MSG -#undef NON_CONV_FINIS -#undef NON_CONV_FINIS_1 -#undef NON_CONV_FINIS_2 - - -/* - * call to numeric_deriv from R - - * .Call("numeric_deriv", expr, theta, rho) - * Returns: ans - */ -SEXP -numeric_deriv(SEXP expr, SEXP theta, SEXP rho, SEXP dir) -{ - SEXP ans, gradient, pars; - double eps = sqrt(DOUBLE_EPS), *rDir; - int start, i, j, k, lengthTheta = 0; - - if(!isString(theta)) - error(_("'theta' should be of type character")); - if (isNull(rho)) { - error(_("use of NULL environment is defunct")); - rho = R_BaseEnv; - } else - if(!isEnvironment(rho)) - error(_("'rho' should be an environment")); - PROTECT(dir = coerceVector(dir, REALSXP)); - if(TYPEOF(dir) != REALSXP || LENGTH(dir) != LENGTH(theta)) - error(_("'dir' is not a numeric vector of the correct length")); - rDir = REAL(dir); - - PROTECT(pars = allocVector(VECSXP, LENGTH(theta))); - - PROTECT(ans = duplicate(eval(expr, rho))); - - if(!isReal(ans)) { - SEXP temp = coerceVector(ans, REALSXP); - UNPROTECT(1); - PROTECT(ans = temp); - } - for(i = 0; i < LENGTH(ans); i++) { - if (!R_FINITE(REAL(ans)[i])) - error(_("Missing value or an infinity produced when evaluating the model")); - } - const void *vmax = vmaxget(); - for(i = 0; i < LENGTH(theta); i++) { - const char *name = translateChar(STRING_ELT(theta, i)); - SEXP s_name = install(name); - SEXP temp = findVar(s_name, rho); - if(isInteger(temp)) - error(_("variable '%s' is integer, not numeric"), name); - if(!isReal(temp)) - error(_("variable '%s' is not numeric"), name); - if (MAYBE_SHARED(temp)) /* We'll be modifying the variable, so need to make sure it's unique PR#15849 */ - defineVar(s_name, temp = duplicate(temp), rho); - MARK_NOT_MUTABLE(temp); - SET_VECTOR_ELT(pars, i, temp); - lengthTheta += LENGTH(VECTOR_ELT(pars, i)); - } - vmaxset(vmax); - PROTECT(gradient = allocMatrix(REALSXP, LENGTH(ans), lengthTheta)); +SEXP nls_iter(SEXP m, SEXP control, SEXP doTraceArg) { return NULL; } +SEXP numeric_deriv(SEXP expr, SEXP theta, SEXP rho, SEXP dir) { return NULL; } - for(i = 0, start = 0; i < LENGTH(theta); i++) { - for(j = 0; j < LENGTH(VECTOR_ELT(pars, i)); j++, start += LENGTH(ans)) { - SEXP ans_del; - double origPar, xx, delta; - origPar = REAL(VECTOR_ELT(pars, i))[j]; - xx = fabs(origPar); - delta = (xx == 0) ? eps : xx*eps; - REAL(VECTOR_ELT(pars, i))[j] += rDir[i] * delta; - PROTECT(ans_del = eval(expr, rho)); - if(!isReal(ans_del)) ans_del = coerceVector(ans_del, REALSXP); - UNPROTECT(1); - for(k = 0; k < LENGTH(ans); k++) { - if (!R_FINITE(REAL(ans_del)[k])) - error(_("Missing value or an infinity produced when evaluating the model")); - REAL(gradient)[start + k] = - rDir[i] * (REAL(ans_del)[k] - REAL(ans)[k])/delta; - } - REAL(VECTOR_ELT(pars, i))[j] = origPar; - } - } - setAttrib(ans, install("gradient"), gradient); - UNPROTECT(4); - return ans; -} diff --git a/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/port.c b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/port.c index afdbe68184..28ae8bb071 100644 --- a/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/port.c +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/port.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2005-2015 The R Core Team. + * Copyright (C) 2005 The R Core Team. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,594 +14,26 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, a copy is available at - * https://www.R-project.org/Licenses/ + * http://www.r-project.org/Licenses/ */ #include "port.h" -#include <R_ext/Constants.h> -#include <R_ext/BLAS.h> -#include <R_ext/Print.h> +SEXP port_ivset(SEXP kind, SEXP iv, SEXP v) { return NULL; } - /* names of 1-based indices into iv and v */ -#define AFCTOL 31 -#define ALGSAV 51 -#define COVPRT 14 -#define COVREQ 15 -#define DRADPR 101 -#define DTYPE 16 -#define F 10 -#define F0 13 -#define FDIF 11 -#define G 28 -#define HC 71 -#define IERR 75 -#define INITH 25 -#define INITS 25 -#define IPIVOT 76 -#define IVNEED 3 -#define LASTIV 44 -#define LASTV 45 -#define LMAT 42 -#define MXFCAL 17 -#define MXITER 18 -#define NEXTV 47 -#define NFCALL 6 -#define NFCOV 52 -#define NFGCAL 7 -#define NGCOV 53 -#define NITER 31 -#define NVDFLT 50 -#define NVSAVE 9 -#define OUTLEV 19 -#define PARPRT 20 -#define PARSAV 49 -#define PERM 58 -#define PRUNIT 21 -#define QRTYP 80 -#define RDREQ 57 -#define RMAT 78 -#define SOLPRT 22 -#define STATPR 23 -#define TOOBIG 2 -#define VNEED 4 -#define VSAVE 60 -#define X0PRT 24 - - -/* C-language replacements for Fortran utilities in PORT sources */ - -/* dd7tpr... returns inner product of two vectors. */ -double F77_NAME(dd7tpr)(int *p, const double x[], const double y[]) -{ - int ione = 1; - return F77_CALL(ddot)(p, x, &ione, y, &ione); -} - -/* ditsum... prints iteration summary, initial and final alf. */ -void F77_NAME(ditsum)(const double d[], const double g[], - int iv[], const int *liv, const int *lv, - const int *n, double v[], const double x[]) -{ - int i, nn = *n; - int *ivm = iv - 1; double *vm = v - 1; /* offsets for 1-based indices */ - if (!ivm[OUTLEV]) return; /* no iteration output */ - if (!(ivm[NITER] % ivm[OUTLEV])) { /* output every ivm[OUTLEV] iterations */ - Rprintf("%3d:%#14.8g:", ivm[NITER], vm[F]); - for (i = 0; i < nn; i++) Rprintf(" %#8g", x[i]); - Rprintf("\n"); - } -} - - /* port sources */ -/* dv7dfl.... provides default values to v. */ -extern void F77_NAME(dv7dfl)(const int *Alg, const int *Lv, double v[]); - -/** - * Supply default values for elements of the iv and v arrays - * - * @param alg algorithm specification (1 <= alg <= 2) (was alg <= 4, but reduced to work around gcc bug; see PR#15914) - * @param iv integer working vector - * @param liv length of iv - * @param lv length of v - * @param v double precision working vector - */ -void Rf_divset(int alg, int iv[], int liv, int lv, double v[]) -{ -/* *** ALG = 1 MEANS REGRESSION CONSTANTS. */ -/* *** ALG = 2 MEANS GENERAL UNCONSTRAINED OPTIMIZATION CONSTANTS. */ - - - /* Initialized data */ - - // alg[orithm] : 1 2 3 4 - static int miniv[] = {0, 82, 59, 103, 103}; - static int minv [] = {0, 98, 71, 101, 85}; - - int mv, miv, alg1; - - /* Parameter adjustments - code will use 1-based indices*/ - --iv; - --v; - - /* Function Body */ - - - if (PRUNIT <= liv) iv[PRUNIT] = 0; /* suppress all Fortran output */ - if (ALGSAV <= liv) iv[ALGSAV] = alg; - if (alg < 1 || alg > 4) - error(_("Rf_divset: alg = %d must be 1, 2, 3, or 4"), alg); - - miv = miniv[alg]; - if (liv < miv) { - iv[1] = 15; - return; - } - mv = minv[alg]; - if (lv < mv) { - iv[1] = 16; - return; - } - alg1 = (alg - 1) % 2 + 1; - F77_CALL(dv7dfl)(&alg1, &lv, &v[1]); - // ------ - iv[1] = 12; - if (alg > 2) error(_("port algorithms 3 or higher are not supported")); - iv[IVNEED] = 0; - iv[LASTIV] = miv; - iv[LASTV] = mv; - iv[LMAT] = mv + 1; - iv[MXFCAL] = 200; - iv[MXITER] = 150; - iv[OUTLEV] = 0; /* default is no iteration output */ - iv[PARPRT] = 1; - iv[PERM] = miv + 1; - iv[SOLPRT] = 0; /* was 1 but we suppress Fortran output */ - iv[STATPR] = 0; /* was 1 but we suppress Fortran output */ - iv[VNEED] = 0; - iv[X0PRT] = 1; - - if (alg1 >= 2) { /* GENERAL OPTIMIZATION values: nlminb() */ - iv[DTYPE] = 0; - iv[INITS] = 1; - iv[NFCOV] = 0; - iv[NGCOV] = 0; - iv[NVDFLT] = 25; - iv[PARSAV] = (alg > 2) ? 61 : 47; - - v[AFCTOL] = 0.0; /* since R 2.12.0: Skip |f(x)| test */ - } - else { /* REGRESSION values: nls() */ - iv[COVPRT] = 3; - iv[COVREQ] = 1; - iv[DTYPE] = 1; - iv[HC] = 0; - iv[IERR] = 0; - iv[INITH] = 0; - iv[IPIVOT] = 0; - iv[NVDFLT] = 32; - iv[VSAVE] = (alg > 2) ? 61 : 58; - iv[PARSAV] = iv[60] + 9; - iv[QRTYP] = 1; - iv[RDREQ] = 3; - iv[RMAT] = 0; - } - return; -} - - -/* divset.... supply default values for elements of the iv and v arrays */ -void F77_NAME(divset)(const int *Alg, int iv[], const int *Liv, - const int *Lv, double v[]) -{ - Rf_divset(*Alg, iv, *Liv, *Lv, v); -} - -/* dn2cvp... prints covariance matrix. */ -void F77_NAME(dn2cvp)(const int iv[], int *liv, int *lv, int *p, - const double v[]) -{ - /* Done elsewhere */ -} - -/* dn2rdp... prints regression diagnostics for mlpsl and nl2s1. */ -void F77_NAME(dn2rdp)(const int iv[], int *liv, int *lv, int *n, - const double rd[], const double v[]) -{ - /* Done elsewhere */ -} - -/* ds7cpr... prints linear parameters at solution. */ -void F77_NAME(ds7cpr)(const double c[], const int iv[], int *l, int *liv) -{ - /* Done elsewhere */ -} - -/* dv2axy... computes scalar times one vector plus another */ -void F77_NAME(dv2axy)(int *n, double w[], const double *a, - const double x[], const double y[]) -{ - int i, nn = *n; double aa = *a; - for (i = 0; i < nn; i++) w[i] = aa * x[i] + y[i]; -} - -/* dv2nrm... returns the 2-norm of a vector. */ -double F77_NAME(dv2nrm)(int *n, const double x[]) -{ - int ione = 1; - return F77_CALL(dnrm2)(n, x, &ione); -} - -/* dv7cpy.... copy src to dest */ -void F77_NAME(dv7cpy)(int *n, double dest[], const double src[]) -{ - /* Was memcpy, but overlaps seen */ - memmove(dest, src, *n * sizeof(double)); -} - -/* dv7ipr... applies forward permutation to vector. */ -void F77_NAME(dv7ipr)(int *n, const int ip[], double x[]) -{ - /* permute x so that x[i] := x[ip[i]]. */ - int i, nn = *n; - double *xcp = Calloc(nn, double); - - for (i = 0; i < nn; i++) xcp[i] = x[ip[i] - 1]; /* ip contains 1-based indices */ - Memcpy(x, xcp, nn); - Free(xcp); -} - -/* dv7prm... applies reverse permutation to vector. */ -void F77_NAME(dv7prm)(int *n, const int ip[], double x[]) -{ - /* permute x so that x[ip[i]] := x[i]. */ - int i, nn = *n; - double *xcp = Calloc(nn, double); - - for (i = 0; i < nn; i++) xcp[ip[i] - 1] = x[i]; /* ip contains 1-based indices */ - Memcpy(x, xcp, nn); - Free(xcp); -} - -/* dv7scl... scale src by *scal to dest */ -void F77_NAME(dv7scl)(int *n, double dest[], - const double *scal, const double src[]) -{ - int nn = *n; double sc = *scal; - while (nn-- > 0) *dest++ = sc * *src++; -} - -/* dv7scp... set values of an array to a constant */ -void F77_NAME(dv7scp)(int *n, double dest[], double *c) -{ - int nn = *n; double cc = *c; - while (nn-- > 0) *dest++ = cc; -} - -/* dv7swp... interchange n-vectors x and y. */ -void F77_NAME(dv7swp)(int *n, double x[], double y[]) -{ - int ione = 1; - F77_CALL(dswap)(n, x, &ione, y, &ione); -} - -/* i7copy... copies one integer vector to another. */ -void F77_NAME(i7copy)(int *n, int dest[], const int src[]) -{ - int nn = *n; - while (nn-- > 0) *dest++ = *src++; -} - -/* i7pnvr... inverts permutation array. (Indices in array are 1-based) */ -void F77_NAME(i7pnvr)(int *n, int x[], const int y[]) -{ - int i, nn = *n; - for (i = 0; i < nn; i++) x[y[i] - 1] = i + 1; -} - -/* stopx.... returns .true. if the break key has been pressed. */ -int F77_NAME(stopx)(void) -{ - return 0; /* interrupts are caught elsewhere */ -} +SEXP port_nlminb(SEXP fn, SEXP gr, SEXP hs, SEXP rho, + SEXP lowerb, SEXP upperb, SEXP d, SEXP iv, SEXP v) { return NULL; } -static -double* check_gv(SEXP gr, SEXP hs, SEXP rho, int n, double *gv, double *hv) -{ - SEXP gval = PROTECT(coerceVector(PROTECT(eval(gr, rho)), REALSXP)); - if (LENGTH(gval) != n) - error(_("gradient function must return a numeric vector of length %d"), n); - Memcpy(gv, REAL(gval), n); - for (int i = 0; i < n; i++) - if(ISNAN(gv[i])) error("NA/NaN gradient evaluation"); - if (hv) { - SEXP hval = PROTECT(eval(hs, rho)); - SEXP dim = getAttrib(hval, R_DimSymbol); - int i, j, pos; - double *rhval = REAL(hval); +SEXP port_nlsb(SEXP m, SEXP d, SEXP gg, SEXP iv, SEXP v, + SEXP lowerb, SEXP upperb) { return NULL; } - if (!isReal(hval) || LENGTH(dim) != 2 || - INTEGER(dim)[0] != n || INTEGER(dim)[1] != n) - error(_("Hessian function must return a square numeric matrix of order %d"), - n); - for (i = 0, pos = 0; i < n; i++) /* copy lower triangle row-wise */ - for (j = 0; j <= i; j++) { - hv[pos] = rhval[i + j * n]; - if(ISNAN(hv[pos])) error("NA/NaN Hessian evaluation"); - pos++; - } - UNPROTECT(1); - } - UNPROTECT(2); - return gv; -} +void Rf_divset(int alg, int iv[], int liv, int lv, double v[]) { } void nlminb_iterate(double b[], double d[], double fx, double g[], double h[], - int iv[], int liv, int lv, int n, double v[], double x[]) -{ - int lh = (n * (n + 1))/2; - if (b) { - if (g) { - if (h) - F77_CALL(drmnhb)(b, d, &fx, g, h, iv, &lh, &liv, &lv, &n, v, x); - else - F77_CALL(drmngb)(b, d, &fx, g, iv, &liv, &lv, &n, v, x); - } else F77_CALL(drmnfb)(b, d, &fx, iv, &liv, &lv, &n, v, x); - } else { - if (g) { - if (h) - F77_CALL(drmnh)(d, &fx, g, h, iv, &lh, &liv, &lv, &n, v, x); - else - F77_CALL(drmng)(d, &fx, g, iv, &liv, &lv, &n, v, x); - } else F77_CALL(drmnf)(d, &fx, iv, &liv, &lv, &n, v, x); - } -} - -SEXP port_ivset(SEXP kind, SEXP iv, SEXP v) -{ - Rf_divset(asInteger(kind), INTEGER(iv), LENGTH(iv), LENGTH(v), REAL(v)); - return R_NilValue; -} - -SEXP port_nlminb(SEXP fn, SEXP gr, SEXP hs, SEXP rho, - SEXP lowerb, SEXP upperb, SEXP d, SEXP iv, SEXP v) -{ - int i, n = LENGTH(d); - SEXP xpt; - SEXP dot_par_symbol = install(".par"); - double *b = (double *) NULL, *g = (double *) NULL, - *h = (double *) NULL, fx = R_PosInf; - if (isNull(rho)) { - error(_("use of NULL environment is defunct")); - rho = R_BaseEnv; - } else - if (!isEnvironment(rho)) - error(_("'rho' must be an environment")); - if (!isReal(d) || n < 1) - error(_("'d' must be a nonempty numeric vector")); - if (hs != R_NilValue && gr == R_NilValue) - error(_("When Hessian defined must also have gradient defined")); - if (R_NilValue == (xpt = findVarInFrame(rho, dot_par_symbol)) || - !isReal(xpt) || LENGTH(xpt) != n) - error(_("environment 'rho' must contain a numeric vector '.par' of length %d"), - n); - /* We are going to alter .par, so must duplicate it */ - defineVar(dot_par_symbol, duplicate(xpt), rho); - PROTECT(xpt = findVarInFrame(rho, dot_par_symbol)); - - if ((LENGTH(lowerb) == n) && (LENGTH(upperb) == n)) { - if (isReal(lowerb) && isReal(upperb)) { - double *rl=REAL(lowerb), *ru=REAL(upperb); - b = (double *)R_alloc(2*n, sizeof(double)); - for (i = 0; i < n; i++) { - b[2*i] = rl[i]; - b[2*i + 1] = ru[i]; - } - } else error(_("'lower' and 'upper' must be numeric vectors")); - } - if (gr != R_NilValue) { - g = (double *)R_alloc(n, sizeof(double)); - if (hs != R_NilValue) - h = (double *)R_alloc((n * (n + 1))/2, sizeof(double)); - } - - do { - nlminb_iterate(b, REAL(d), fx, g, h, INTEGER(iv), LENGTH(iv), - LENGTH(v), n, REAL(v), REAL(xpt)); - if (INTEGER(iv)[0] == 2 && g) check_gv(gr, hs, rho, n, g, h); - else { - fx = asReal(eval(fn, rho)); - if (ISNAN(fx)) { - warning("NA/NaN function evaluation"); - fx = R_PosInf; - } - } - - /* duplicate .par value again in case a callback has stored - value (package varComp does this) */ - defineVar(dot_par_symbol, duplicate(xpt), rho); - xpt = findVarInFrame(rho, dot_par_symbol); - UNPROTECT(1); - PROTECT(xpt); - } while(INTEGER(iv)[0] < 3); - - UNPROTECT(1); /* xpt */ - return R_NilValue; -} + int iv[], int liv, int lv, int n, double v[], double x[]) { } void nlsb_iterate(double b[], double d[], double dr[], int iv[], int liv, int lv, int n, int nd, int p, double r[], double rd[], - double v[], double x[]) -{ - int ione = 1; - if (b) - F77_CALL(drn2gb)(b, d, dr, iv, &liv, &lv, &n, &nd, - &ione, &nd, &p, r, rd, v, x); - else - F77_CALL(drn2g)(d, dr, iv, &liv, &lv, &n, &nd, &ione, - &nd, &p, r, rd, v, x); -} - -/** - * Return the element of a given name from a named list - * - * @param list - * @param nm name of desired element - * - * @return element of list with name nm - */ -static R_INLINE SEXP getElement(SEXP list, char *nm) -{ - int i; SEXP names = getAttrib(list, R_NamesSymbol); - - if (!isNewList(list) || LENGTH(names) != LENGTH(list)) - error(_("'getElement' applies only to named lists")); - for (i = 0; i < LENGTH(list); i++) - if (!strcmp(CHAR(STRING_ELT(names, i)), nm)) /* ASCII only */ - return(VECTOR_ELT(list, i)); - return R_NilValue; -} - -/** - * Return the element of a given name from a named list after ensuring - * that it is a function - * - * @param list - * @param enm name of desired element - * @param lnm string version of the name of the list - * - * @return a SEXP that points to a function - */ -static R_INLINE SEXP getFunc(SEXP list, char *enm, char *lnm) -{ - SEXP ans; - if (!isFunction(ans = getElement(list, enm))) - error(_("%s$%s() not found"), lnm, enm); - return ans; -} - -static void neggrad(SEXP gf, SEXP rho, SEXP gg) -{ - SEXP val = PROTECT(eval(gf, rho)); - int *dims = INTEGER(getAttrib(val, R_DimSymbol)), - *gdims = INTEGER(getAttrib(gg, R_DimSymbol)); - int i, ntot = gdims[0] * gdims[1]; - - if (TYPEOF(val) != TYPEOF(gg) || !isMatrix(val) || dims[0] != gdims[0] || - dims[1] != gdims[1]) - error(_("'gradient' must be a numeric matrix of dimension (%d,%d)"), - gdims[0], gdims[1]); - for (i = 0; i < ntot; i++) REAL(gg)[i] = - REAL(val)[i]; - UNPROTECT(1); -} - -/** - * Evaluate an expression in an environment, check that the length and - * mode are as expected and store the result. - * - * @param fcn expression to evaluate - * @param rho environment in which to evaluate it - * @param vv position to store the result - * - * @return vv with new contents - */ -static -SEXP eval_check_store(SEXP fcn, SEXP rho, SEXP vv) -{ - SEXP v = PROTECT(eval(fcn, rho)); - if (TYPEOF(v) != TYPEOF(vv) || LENGTH(v) != LENGTH(vv)) - error(_("fcn produced mode %d, length %d - wanted mode %d, length %d"), - TYPEOF(v), LENGTH(v), TYPEOF(vv), LENGTH(vv)); - switch (TYPEOF(v)) { - case LGLSXP: - Memcpy(LOGICAL(vv), LOGICAL(v), LENGTH(vv)); - break; - case INTSXP: - Memcpy(INTEGER(vv), INTEGER(v), LENGTH(vv)); - break; - case REALSXP: - Memcpy(REAL(vv), REAL(v), LENGTH(vv)); - break; - default: - error(_("invalid type for eval_check_store")); - } - UNPROTECT(1); - return vv; -} - -SEXP port_nlsb(SEXP m, SEXP d, SEXP gg, SEXP iv, SEXP v, - SEXP lowerb, SEXP upperb) -{ - int *dims = INTEGER(getAttrib(gg, R_DimSymbol)); - int i, n = LENGTH(d), p = LENGTH(d), nd = dims[0]; - SEXP getPars, setPars, resid, gradient, - rr = PROTECT(allocVector(REALSXP, nd)), - x = PROTECT(allocVector(REALSXP, n)); - // This used to use Calloc, but that will leak if - // there is a premature return (and did in package drfit) - double *b = (double *) NULL, - *rd = (double *)R_alloc(nd, sizeof(double)); - - if (!isReal(d) || n < 1) - error(_("'d' must be a nonempty numeric vector")); - if(!isNewList(m)) error(_("m must be a list")); - /* Initialize parameter vector */ - getPars = PROTECT(lang1(getFunc(m, "getPars", "m"))); - eval_check_store(getPars, R_GlobalEnv, x); - /* Create the setPars call */ - setPars = PROTECT(lang2(getFunc(m, "setPars", "m"), x)); - /* Evaluate residual and gradient */ - resid = PROTECT(lang1(getFunc(m, "resid", "m"))); - eval_check_store(resid, R_GlobalEnv, rr); - gradient = PROTECT(lang1(getFunc(m, "gradient", "m"))); - neggrad(gradient, R_GlobalEnv, gg); - - if ((LENGTH(lowerb) == n) && (LENGTH(upperb) == n)) { - if (isReal(lowerb) && isReal(upperb)) { - double *rl = REAL(lowerb), *ru = REAL(upperb); - b = (double *)R_alloc(2*n, sizeof(double)); - for (i = 0; i < n; i++) { - b[2*i] = rl[i]; - b[2*i + 1] = ru[i]; - } - } else error(_("'lowerb' and 'upperb' must be numeric vectors")); - } - - do { - nlsb_iterate(b, REAL(d), REAL(gg), INTEGER(iv), LENGTH(iv), - LENGTH(v), n, nd, p, REAL(rr), rd, - REAL(v), REAL(x)); - switch(INTEGER(iv)[0]) { - case -3: - eval(setPars, R_GlobalEnv); - eval_check_store(resid, R_GlobalEnv, rr); - neggrad(gradient, R_GlobalEnv, gg); - break; - case -2: - eval_check_store(resid, R_GlobalEnv, rr); - neggrad(gradient, R_GlobalEnv, gg); - break; - case -1: - eval(setPars, R_GlobalEnv); - eval_check_store(resid, R_GlobalEnv, rr); - neggrad(gradient, R_GlobalEnv, gg); - break; - case 0: - Rprintf("nlsb_iterate returned %d", INTEGER(iv)[0]); - break; - case 1: - eval(setPars, R_GlobalEnv); - eval_check_store(resid, R_GlobalEnv, rr); - break; - case 2: - eval(setPars, R_GlobalEnv); - neggrad(gradient, R_GlobalEnv, gg); - break; - } - } while(INTEGER(iv)[0] < 3); - - UNPROTECT(6); - return R_NilValue; -} + double v[], double x[]) { } diff --git a/com.oracle.truffle.r.native/library/stats/src/nls.h b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/stats.c similarity index 69% rename from com.oracle.truffle.r.native/library/stats/src/nls.h rename to com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/stats.c index 50344e7b15..e70c072ac2 100644 --- a/com.oracle.truffle.r.native/library/stats/src/nls.h +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/stats.c @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 1997-2007 The R Core Team. + * Copyright (C) 2005-12 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,14 +17,7 @@ * http://www.r-project.org/Licenses/ */ -#ifdef ENABLE_NLS -#include <libintl.h> -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif - -SEXP nls_iter(SEXP m, SEXP control, SEXP doTraceArg) { return NULL; } -SEXP numeric_deriv(SEXP expr, SEXP theta, SEXP rho, SEXP dir) { return NULL; } - +#include "stats.h" +void rcont2(int *nrow, int *ncol, int *nrowt, int *ncolt, int *ntotal, + double *fact, int *jwork, int *matrix) { } diff --git a/com.oracle.truffle.r.native/library/stats/src/statsR_dummy.c b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/statsR_dummy.c similarity index 100% rename from com.oracle.truffle.r.native/library/stats/src/statsR_dummy.c rename to com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/statsR_dummy.c diff --git a/com.oracle.truffle.r.native/library/stats/src/ts.h b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/ts.c similarity index 83% rename from com.oracle.truffle.r.native/library/stats/src/ts.h rename to com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/ts.c index bd6b7b85aa..bdffee7d65 100644 --- a/com.oracle.truffle.r.native/library/stats/src/ts.h +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/ts.c @@ -17,10 +17,7 @@ * http://www.r-project.org/Licenses/ */ -#ifndef R_TS_H -#define R_TS_H -#include <Rinternals.h> -#include "stats.h" +#include "ts.h" void multi_burg(int *pn, double *x, int *pomax, int *pnser, double *coef, double *pacf, double *var, double *aic, int *porder, @@ -34,26 +31,6 @@ void HoltWinters (double *x, int *xl, double *alpha, double *beta, double *a, double *b, double *s, double *SSE, double *level, double *trend, double *season) { } -void -F77_SUB(eureka)(int *lr, double *r__, double *g, - double *f, double *var, double *a); - -void -F77_SUB(stl)(double *y, int *n, int *np, int *ns, - int *nt, int *nl, int *isdeg, int *itdeg, int *ildeg, - int *nsjump, int *ntjump, int *nljump, int *ni, - int *no, double *rw, double *season, double *trend, - double *work); - -typedef struct -{ - int p, q, r, np, nrbar, n, ncond, m, trans, method, nused; - int mp, mq, msp, msq, ns; - double delta, s2; - double *params, *phi, *theta, *a, *P, *V; - double *thetab, *xnext, *xrow, *rbar, *w, *wkeep, *resid, *reg; -} starma_struct, *Starma; - void starma(Starma G, int *ifault) { } void karma(Starma G, double *sumlog, double *ssq, int iupd, int *nit) { } @@ -97,4 +74,3 @@ SEXP Burg(SEXP x, SEXP order) { return NULL; } SEXP pp_sum(SEXP u, SEXP sl) { return NULL; } SEXP intgrt_vec(SEXP x, SEXP xi, SEXP slag) { return NULL; } -#endif diff --git a/com.oracle.truffle.r.native/library/stats4/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/stats4/Makefile similarity index 94% rename from com.oracle.truffle.r.native/library/stats4/Makefile rename to com.oracle.truffle.r.native/gnur/patch/src/library/stats4/Makefile index ba5dbd789d..abc7832734 100644 --- a/com.oracle.truffle.r.native/library/stats4/Makefile +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/stats4/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/com.oracle.truffle.r.native/library/tools/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/tools/Makefile similarity index 77% rename from com.oracle.truffle.r.native/library/tools/Makefile rename to com.oracle.truffle.r.native/gnur/patch/src/library/tools/Makefile index a9cc40115e..4154fe57a2 100644 --- a/com.oracle.truffle.r.native/library/tools/Makefile +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/tools/Makefile @@ -22,16 +22,7 @@ # OBJ = lib - -GNUR_C_FILES = init.c -GRAMRD_C = gramRd.c -GRAMRD_OBJ := $(addprefix $(OBJ)/, gramRd.o) - -GNUR_C_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_C_FILES:.c=.o)) $(GRAMRD_OBJ) - -LIB_PKG_PRE = $(GRAMRD_OBJ) - -CLEAN_PKG = rm_gramRd +SRC = src ifeq ($(FASTR_RFFI),nfi) XTRA_C_SOURCES += $(SRC)/truffle_nfi/gramRd_nfi.c @@ -48,22 +39,10 @@ endif include ../lib.mk -# in case already generated -C_OBJECTS := $(filter-out $(GRAMRD_OBJ), $(C_OBJECTS)) - $(C_OBJECTS): | $(OBJ) -$(SRC)/gramRd.c: $(GNUR_SRC)/gramRd.c - mx mkgramrd $(GNUR_SRC)/gramRd.c $(SRC)/gramRd.c - -$(OBJ)/%.o: $(GNUR_SRC)/%.c - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ - $(OBJ)/gramRd_nfi.o: $(SRC)/truffle_nfi/gramRd_nfi.c $(CC) $(CFLAGS) $(FFI_INCLUDES) $(NFI_INCLUDES) -c $< -o $@ $(OBJ)/gramRd_llvm.o: $(SRC)/truffle_llvm/gramRd_llvm.c $(CC) $(CFLAGS) $(FFI_INCLUDES) $(SULONG_INCLUDES) -c $< -o $@ - -rm_gramRd: - rm -f $(SRC)/gramRd.c diff --git a/com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/gramRd.c b/com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/gramRd.c index 2f6d3df660..1d76e4b506 100644 --- a/com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/gramRd.c +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/gramRd.c @@ -89,12 +89,14 @@ #endif #define R_USE_SIGNALS 1 -#include <Defn.h> -#include <Parse.h> +//#include <Defn.h> +#include <Rinternals.h> +#include <R_ext/Parse.h> #define STRICT_R_HEADERS #include <R_ext/RS.h> /* for R_chk_* allocation */ #include <ctype.h> -#include <Rmath.h> /* for imax2(.),..*/ +//#include <Rmath.h> /* for imax2(.),..*/ +#include "gramRd_fastr.h" #undef _ #ifdef ENABLE_NLS #include <libintl.h> @@ -103,6 +105,32 @@ #define _(String) (String) #endif + +extern SEXP FASTR_R_SrcrefSymbol(); +#define R_SrcrefSymbol FASTR_R_SrcrefSymbol() +extern SEXP FASTR_R_SrcfileSymbol(); +#define R_SrcfileSymbol FASTR_R_SrcfileSymbol() +extern int R_ParseContextLast; +#define R_EOF -1 +#define PARSE_ERROR_SIZE 256 +#define PARSE_CONTEXT_SIZE 256 +static char R_ParseErrorMsg[PARSE_ERROR_SIZE]; +static char R_ParseContext[PARSE_CONTEXT_SIZE]; +int R_ParseContextLast; +int R_ParseContextLine; +int R_ParseError; +extern SEXP FASTR_R_EmptyEnv(); +#define R_EmptyEnv FASTR_R_EmptyEnv() +extern SEXP R_NewHashedEnv(SEXP a, SEXP b); + +char *dgettext(const char *p, const char *msgid) { +return (char *)msgid; +} + +int imax2(int x, int y) +{ + return (x < y) ? y : x; +} /* bison creates a non-static symbol yylloc in both gramLatex.o and gramRd.o, so remap */ @@ -3145,7 +3173,7 @@ static SEXP xxnewcommand(SEXP cmd, SEXP name, SEXP defn, YYLTYPE *lloc) else PROTECT(thedefn = mkString("")); if (warnDups) { - prev = findVar(installTrChar(STRING_ELT(thename, 0)), parseState.xxMacroList); + prev = findVar(install(CHAR(STRING_ELT(thename, 0))), parseState.xxMacroList); if (prev != R_UnboundValue && strcmp(CHAR(STRING_ELT(cmd,0)), "\\renewcommand")) { snprintf(buffer, sizeof(buffer), _("Macro '%s' previously defined."), CHAR(STRING_ELT(thename, 0))); @@ -3164,7 +3192,7 @@ static SEXP xxnewcommand(SEXP cmd, SEXP name, SEXP defn, YYLTYPE *lloc) setAttrib(ans, install("Rd_tag"), cmd); setAttrib(ans, install("definition"), thedefn); setAttrib(ans, R_SrcrefSymbol, makeSrcref(lloc, SrcFile)); - defineVar(installTrChar(STRING_ELT(thename, 0)), ans, parseState.xxMacroList); + defineVar(install(CHAR(STRING_ELT(thename, 0))), ans, parseState.xxMacroList); UNPROTECT_PTR(thedefn); UNPROTECT_PTR(cmd); @@ -3575,7 +3603,13 @@ static SEXP ParseRd(ParseStatus *status, SEXP srcfile, Rboolean fragment, SEXP m return parseState.Value; } -#include "Rconnections.h" +//#include "Rconnections.h" + +typedef SEXP Rconnection; +static int Rconn_fgetc(Rconnection con) { + return -1; +} + static Rconnection con_parse; /* need to handle incomplete last line */ @@ -3584,7 +3618,7 @@ static int con_getc(void) int c; static int last=-1000; - c = Rconn_fgetc(con_parse); + c = callGetCMethod(con_parse); if (c == EOF && last != '\n') c = '\n'; return (last = c); } @@ -4321,12 +4355,6 @@ static int yylex(void) return tok; } -static void con_cleanup(void *data) -{ - Rconnection con = data; - if(con->isopen) con->close(con); -} - static void PutState(ParseState *state) { state->xxinRString = parseState.xxinRString; state->xxQuoteLine = parseState.xxQuoteLine; @@ -4389,19 +4417,24 @@ static void PopState() { /* "do_parseRd" .External2(C_parseRd,file, srcfile, encoding, verbose, basename, warningCalls, macros, warndups) + If there is text then that is read and the other arguments are ignored. -*/ -SEXP parseRd(SEXP call, SEXP op, SEXP args, SEXP env) -{ - args = CDR(args); + This is derived fron the function of the same name in the GnuR version. + Argument checking has already been performed, however, the types of the + arguments are as per the GnuR version, just passed explicitly (.Call style) + rather then as a list. +*/ +SEXP parseRd(SEXP call, SEXP op, SEXP args, SEXP env) { + args = CDR(args); // arg 0 skipped SEXP s = R_NilValue, source; Rconnection con; - Rboolean wasopen, fragment; - int ifile, wcall; + SEXP conArg; + Rboolean fragment; + int ifile; + int wcall; ParseStatus status; - RCNTXT cntxt; SEXP macros; #if DEBUGMODE @@ -4413,147 +4446,39 @@ SEXP parseRd(SEXP call, SEXP op, SEXP args, SEXP env) PushState(); - ifile = asInteger(CAR(args)); args = CDR(args); + conArg = CAR(args); // arg 1 + ifile = asInteger(conArg); + + con = R_GetFastRConnection(conArg); + + args = CDR(args); - con = getConnection(ifile); - wasopen = con->isopen; - source = CAR(args); args = CDR(args); + source = CAR(args); // arg 2 + args = CDR(args); /* encoding is unused */ args = CDR(args); - if(!isLogical(CAR(args)) || LENGTH(CAR(args)) != 1) + if(!isLogical(CAR(args)) || LENGTH(CAR(args)) != 1) // arg 4 error(_("invalid '%s' value"), "verbose"); - parseState.xxDebugTokens = asInteger(CAR(args)); args = CDR(args); - parseState.xxBasename = CHAR(STRING_ELT(CAR(args), 0)); args = CDR(args); - fragment = asLogical(CAR(args)); args = CDR(args); - wcall = asLogical(CAR(args)); args = CDR(args); + parseState.xxDebugTokens = asInteger(CAR(args)); // arg 4 + args = CDR(args); + parseState.xxBasename = CHAR(STRING_ELT(CAR(args), 0)); // arg 5 + args = CDR(args); + fragment = asLogical(CAR(args)); // arg 6 + args = CDR(args); + wcall = asLogical(CAR(args)); // arg 7 + args = CDR(args); if (wcall == NA_LOGICAL) error(_("invalid '%s' value"), "warningCalls"); wCalls = wcall; - macros = CAR(args); args = CDR(args); - warnDups = asLogical(CAR(args)); + macros = CAR(args); // arg 8 + args = CDR(args); + warnDups = asLogical(CAR(args)); // arg 9 if (ifile >= 3) {/* file != "" */ - if(!wasopen) { - if(!con->open(con)) error(_("cannot open the connection")); - /* Set up a context which will close the connection on error */ - begincontext(&cntxt, CTXT_CCODE, R_NilValue, R_BaseEnv, R_BaseEnv, - R_NilValue, R_NilValue); - cntxt.cend = &con_cleanup; - cntxt.cenddata = con; - } - if(!con->canread) error(_("cannot read from this connection")); s = R_ParseRd(con, &status, source, fragment, macros); - if(!wasopen) endcontext(&cntxt); PopState(); - if (status != PARSE_OK) parseError(call, R_ParseError); - } - else { - PopState(); - error(_("invalid Rd file")); } return s; } -/* "do_deparseRd" - - .External2(C_deparseRd, element, state) -*/ - -SEXP deparseRd(SEXP e, SEXP state) -{ - SEXP result; - int outlen, *statevals, quoteBraces, inRComment; - const char *c; - char *outbuf, *out, lookahead; - Rboolean escape; - - if(!isString(e) || LENGTH(e) != 1) - error(_("'deparseRd' only supports deparsing character elements")); - e = STRING_ELT(e, 0); - - if(!isInteger(state) || LENGTH(state) != 5) error(_("bad state")); - - PushState(); - - parseState.xxbraceDepth = INTEGER(state)[0]; - parseState.xxinRString = INTEGER(state)[1]; - parseState.xxmode = INTEGER(state)[2]; - parseState.xxinEqn = INTEGER(state)[3]; - quoteBraces = INTEGER(state)[4]; - - if (parseState.xxmode != LATEXLIKE && parseState.xxmode != RLIKE && parseState.xxmode != VERBATIM && parseState.xxmode != COMMENTMODE - && parseState.xxmode != INOPTION && parseState.xxmode != UNKNOWNMODE) { - PopState(); - error(_("bad text mode %d in 'deparseRd'"), parseState.xxmode); - } - - for (c = CHAR(e), outlen=0; *c; c++) { - outlen++; - /* any special char might be escaped */ - if (*c == '{' || *c == '}' || *c == '%' || *c == '\\') outlen++; - } - out = outbuf = R_chk_calloc(outlen+1, sizeof(char)); - inRComment = FALSE; - for (c = CHAR(e); *c; c++) { - escape = FALSE; - if (parseState.xxmode != UNKNOWNMODE) { - switch (*c) { - case '\\': - if (parseState.xxmode == RLIKE && parseState.xxinRString) { - lookahead = *(c+1); - if (lookahead == '\\' || lookahead == parseState.xxinRString || lookahead == 'l') - escape = TRUE; - break; - } /* fall through to % case for non-strings... */ - case '%': - if (parseState.xxmode != COMMENTMODE && !parseState.xxinEqn) - escape = TRUE; - break; - case LBRACE: - case RBRACE: - if (quoteBraces) - escape = TRUE; - else if (!parseState.xxinRString && !parseState.xxinEqn && (parseState.xxmode == RLIKE || parseState.xxmode == VERBATIM)) { - if (*c == LBRACE) parseState.xxbraceDepth++; - else if (parseState.xxbraceDepth <= 0) escape = TRUE; - else parseState.xxbraceDepth--; - } - break; - case '\'': - case '"': - case '`': - if (parseState.xxmode == RLIKE) { - if (parseState.xxinRString) { - if (parseState.xxinRString == *c) parseState.xxinRString = 0; - } else if (!inRComment) parseState.xxinRString = *c; - } - break; - case '#': - if (parseState.xxmode == RLIKE && !parseState.xxinRString) - inRComment = TRUE; - break; - case '\n': - inRComment = FALSE; - break; - } - } - if (escape) - *out++ = '\\'; - *out++ = *c; - } - *out = '\0'; - PROTECT(result = allocVector(VECSXP, 2)); - SET_VECTOR_ELT(result, 0, ScalarString(mkChar(outbuf))); - SET_VECTOR_ELT(result, 1, duplicate(state)); - R_chk_free(outbuf); - - statevals = INTEGER( VECTOR_ELT(result, 1) ); - statevals[0] = parseState.xxbraceDepth; - statevals[1] = parseState.xxinRString; - - PopState(); - - UNPROTECT(1); - return result; -} - +// TODO deparseRd diff --git a/com.oracle.truffle.r.native/library/tools/src/gramRd_fastr.h b/com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/gramRd_fastr.h similarity index 96% rename from com.oracle.truffle.r.native/library/tools/src/gramRd_fastr.h rename to com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/gramRd_fastr.h index c0a03dffb7..eac399337a 100644 --- a/com.oracle.truffle.r.native/library/tools/src/gramRd_fastr.h +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/gramRd_fastr.h @@ -31,4 +31,6 @@ int callGetCMethod(void *conn) { void* R_GetFastRConnection(void *conn); +void* R_GetFastRConnection(void *conn); + #endif //GRAMRD_FASTR_H diff --git a/com.oracle.truffle.r.native/library/tools/src/tools_dummy.c b/com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/tools_dummy.c similarity index 100% rename from com.oracle.truffle.r.native/library/tools/src/tools_dummy.c rename to com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/tools_dummy.c diff --git a/com.oracle.truffle.r.native/library/tools/src/truffle_llvm/gramRd_llvm.c b/com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/truffle_llvm/gramRd_llvm.c similarity index 100% rename from com.oracle.truffle.r.native/library/tools/src/truffle_llvm/gramRd_llvm.c rename to com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/truffle_llvm/gramRd_llvm.c diff --git a/com.oracle.truffle.r.native/library/tools/src/truffle_nfi/gramRd_nfi.c b/com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/truffle_nfi/gramRd_nfi.c similarity index 100% rename from com.oracle.truffle.r.native/library/tools/src/truffle_nfi/gramRd_nfi.c rename to com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/truffle_nfi/gramRd_nfi.c diff --git a/com.oracle.truffle.r.native/gnur/patch/src/library/utils/Makefile b/com.oracle.truffle.r.native/gnur/patch/src/library/utils/Makefile new file mode 100644 index 0000000000..bc0ffdd0d4 --- /dev/null +++ b/com.oracle.truffle.r.native/gnur/patch/src/library/utils/Makefile @@ -0,0 +1,24 @@ +# +# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +include ../lib.mk diff --git a/com.oracle.truffle.r.native/library/utils/src/utils_dummy.c b/com.oracle.truffle.r.native/gnur/patch/src/library/utils/src/utils_dummy.c similarity index 100% rename from com.oracle.truffle.r.native/library/utils/src/utils_dummy.c rename to com.oracle.truffle.r.native/gnur/patch/src/library/utils/src/utils_dummy.c diff --git a/com.oracle.truffle.r.native/gnur/patch/src/main/rlocale_data.h b/com.oracle.truffle.r.native/gnur/patch/src/main/rlocale_data.h new file mode 100644 index 0000000000..c50b52633b --- /dev/null +++ b/com.oracle.truffle.r.native/gnur/patch/src/main/rlocale_data.h @@ -0,0 +1,3608 @@ +/* + * R : A Computer Language for Statistical Data Analysis + * Copyright (C) 2005-2015 The R Core Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, a copy is available at + * https://www.R-project.org/Licenses/ + */ + +/* R i18n fake locale functions. */ +enum { MB_Default, MB_ja_JP, MB_ko_KR, MB_zh_SG, MB_zh_CN, MB_zh_HK, + MB_zh_TW, MB_SIZE }; + +struct interval { + int first; + int last; +}; + +/* ------------------- wcwidth -------------------- */ +struct interval_wcwidth { + int first; + int last; + char mb[MB_SIZE]; +}; + +/* Background info for the first column is in + http://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt +*/ + +/* Anything not in this table nor the zero-width one is width one */ +static const struct interval_wcwidth table_wcwidth[] = { + {0xa1,0xa1,{1,2,2,1,2,1,1}}, // 'East Asian' ambiguous + {0xa2,0xa3,{1,2,1,1,1,2,1}}, + {0xa4,0xa4,{1,2,2,2,2,1,1}}, // EA ambiguous + {0xa5,0xa5,{1,1,1,1,1,2,1}}, + {0xa6,0xa6,{1,2,1,1,1,1,1}}, + {0xa7,0xa7,{1,2,2,2,2,2,2}}, // EA ambiguous + {0xa8,0xa8,{1,2,2,2,2,1,1}}, // EA ambiguous + {0xa9,0xa9,{1,2,1,1,1,1,1}}, + {0xaa,0xaa,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xac,0xac,{1,2,1,1,1,1,1}}, + {0xad,0xad,{1,1,2,1,2,1,1}}, + {0xae,0xae,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xaf,0xaf,{1,2,1,1,1,1,2}}, + {0xb0,0xb1,{1,2,2,2,2,2,2}}, // EA ambiguous + {0xb2,0xb3,{1,1,2,1,2,1,1}}, // EA ambiguous + {0xb4,0xb4,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xb6,0xb6,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xb7,0xb7,{1,1,2,2,2,2,2}}, // EA ambiguous + {0xb8,0xb8,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xb9,0xb9,{1,1,2,1,2,1,1}}, // EA ambiguous + {0xba,0xba,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xbc,0xbe,{1,1,2,1,2,1,1}}, // EA ambiguous + {0xbf,0xbf,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xc0,0xc5,{1,2,1,1,1,1,1}}, + {0xc6,0xc6,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xc7,0xcf,{1,2,1,1,1,1,1}}, + {0xd0,0xd0,{1,1,2,1,2,1,1}}, // EA ambiguous + {0xd1,0xd6,{1,2,1,1,1,1,1}}, + {0xd7,0xd7,{1,2,2,2,2,2,2}}, // EA ambiguous + {0xd8,0xd8,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xd9,0xdd,{1,2,1,1,1,1,1}}, + {0xde,0xdf,{1,2,2,1,2,1,1}}, // 0xde is EA ambiguous +#ifdef Win32 + {0xe0,0xe1,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0xe0,0xe1,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0xe2,0xe5,{1,2,1,1,1,1,1}}, + {0xe6,0xe6,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xe7,0xe7,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0xe8,0xea,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0xe8,0xea,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0xeb,0xeb,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0xec,0xed,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0xec,0xed,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0xee,0xef,{1,2,1,1,1,1,1}}, + {0xf0,0xf0,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xf1,0xf1,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0xf2,0xf3,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0xf2,0xf3,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0xf4,0xf6,{1,2,1,1,1,1,1}}, + {0xf7,0xf7,{1,2,2,2,2,2,2}}, // EA ambiguous + {0xf8,0xf8,{1,2,2,1,2,1,1}}, // EA ambiguous +#ifdef Win32 + {0xf9,0xfa,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0xf9,0xfa,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0xfb,0xfb,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0xfc,0xfc,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0xfc,0xfc,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0xfd,0xfd,{1,2,1,1,1,1,1}}, + {0xfe,0xfe,{1,2,2,1,2,1,1}}, // EA ambiguous + {0xff,0x100,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x101,0x101,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x101,0x101,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x102,0x110,{1,2,1,1,1,1,1}}, + {0x111,0x111,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x112,0x112,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x113,0x113,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x113,0x113,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x116,0x11a,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x11b,0x11b,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x11b,0x11b,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x11c,0x122,{1,2,1,1,1,1,1}}, + {0x124,0x125,{1,2,1,1,1,1,1}}, + {0x126,0x127,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x128,0x12a,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x12b,0x12b,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x12b,0x12b,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x12e,0x130,{1,2,1,1,1,1,1}}, + {0x131,0x133,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x134,0x137,{1,2,1,1,1,1,1}}, + {0x138,0x138,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x139,0x13e,{1,2,1,1,1,1,1}}, + {0x13f,0x142,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x143,0x143,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x144,0x144,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x144,0x144,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x145,0x147,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x148,0x148,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x148,0x148,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x149,0x14b,{1,2,2,1,2,1,1}}, + {0x14c,0x14c,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x14d,0x14d,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x14d,0x14d,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x150,0x151,{1,2,1,1,1,1,1}}, + {0x152,0x153,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x154,0x165,{1,2,1,1,1,1,1}}, + {0x166,0x167,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x168,0x16a,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x16b,0x16b,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x16b,0x16b,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x16c,0x17e,{1,2,1,1,1,1,1}}, + {0x1cd,0x1cd,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x1ce,0x1ce,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x1ce,0x1ce,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x1cf,0x1cf,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x1d0,0x1d0,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x1d0,0x1d0,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x1d1,0x1d1,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x1d2,0x1d2,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x1d2,0x1d2,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x1d3,0x1d3,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x1d4,0x1d4,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x1d4,0x1d4,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x1d5,0x1d5,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x1d6,0x1d6,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x1d6,0x1d6,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x1d7,0x1d7,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x1d8,0x1d8,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x1d8,0x1d8,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x1d9,0x1d9,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x1da,0x1da,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x1da,0x1da,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x1db,0x1db,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x1dc,0x1dc,{1,2,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x1dc,0x1dc,{1,2,1,2,2,1,1}}, +#endif /* Win32 */ + {0x1f5,0x1f5,{1,2,1,1,1,1,1}}, +#ifdef Win32 + {0x251,0x251,{1,1,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x251,0x251,{1,1,1,2,2,1,1}}, +#endif /* Win32 */ +#ifdef Win32 + {0x261,0x261,{1,1,1,2,1,1,1}}, // EA ambiguous +#else /* Win32 */ + {0x261,0x261,{1,1,1,2,2,1,1}}, +#endif /* Win32 */ + {0x2c4,0x2c4,{1,1,1,1,2,1,1}}, // EA ambiguous + {0x2c7,0x2c7,{1,2,2,2,2,1,2}}, // EA ambiguous + {0x2c9,0x2cb,{1,1,1,2,2,1,2}}, // EA ambiguous + {0x2cd,0x2cd,{1,1,1,1,2,1,2}}, // EA ambiguous + {0x2d0,0x2d0,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x2d8,0x2d8,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x2d9,0x2d9,{1,2,2,2,2,1,2}}, + {0x2da,0x2db,{1,2,2,1,2,1,1}}, + {0x2dd,0x2dd,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x2df,0x2df,{1,1,1,1,2,1,1}}, // EA ambiguous + {0x384,0x386,{1,2,1,1,1,1,1}}, + {0x388,0x38a,{1,2,1,1,1,1,1}}, + {0x38c,0x38c,{1,2,1,1,1,1,1}}, + {0x38e,0x390,{1,2,1,1,1,1,1}}, + {0x391,0x3a1,{1,2,2,2,2,1,2}}, // EA ambiguous + {0x3a3,0x3a9,{1,2,2,2,2,1,2}}, // EA ambiguous + {0x3aa,0x3b0,{1,2,1,1,1,1,1}}, + {0x3b1,0x3c1,{1,2,2,2,2,1,2}}, // EA ambiguous + {0x3c2,0x3c2,{1,2,1,1,1,1,1}}, + {0x3c3,0x3c9,{1,2,2,2,2,1,2}}, // EA ambiguous + {0x3ca,0x3ce,{1,2,1,1,1,1,1}}, + {0x401,0x401,{1,2,2,2,2,1,1}}, // EA ambiguous + {0x402,0x40c,{1,2,1,1,1,1,1}}, + {0x40e,0x40f,{1,2,1,1,1,1,1}}, + {0x410,0x44f,{1,2,2,2,2,1,1}}, // Greek and Cyrillic, EA ambiguous + {0x451,0x451,{1,2,2,2,2,1,1}}, // EA ambiguous + {0x452,0x45c,{1,2,1,1,1,1,1}}, + {0x45e,0x45f,{1,2,1,1,1,1,1}}, + {0x1100,0x115f,{2,2,2,2,2,2,2}}, // Hangul + {0x2010,0x2010,{1,2,1,2,2,1,1}}, // EA ambiguous + {0x2013,0x2014,{1,1,1,2,2,2,2}}, // EA ambiguous + {0x2015,0x2015,{1,2,2,2,2,1,1}}, // EA ambiguous + {0x2016,0x2016,{1,2,1,2,2,1,2}}, // EA ambiguous + {0x2018,0x2019,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x201c,0x201d,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2020,0x2021,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x2022,0x2022,{1,1,1,1,2,2,1}}, // EA ambiguous + {0x2024,0x2024,{1,1,1,1,2,1,1}}, // EA ambiguous + {0x2025,0x2026,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2027,0x2027,{1,1,1,1,2,1,2}}, // EA ambiguous + {0x2030,0x2030,{1,2,2,2,2,1,1}}, // permille + {0x2032,0x2032,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2033,0x2033,{1,2,2,2,2,1,1}}, // EA ambiguous + {0x2035,0x2035,{1,1,1,2,2,2,2}}, // EA ambiguous + {0x203b,0x203b,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x203e,0x203e,{1,1,1,1,2,2,2}}, // EA ambiguous + {0x2074,0x2074,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x207f,0x207f,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x2081,0x2084,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x20ac,0x20ac,{1,1,2,1,2,1,2}}, // EA ambiguous + {0x2103,0x2103,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2105,0x2105,{1,1,1,2,2,2,2}}, // EA ambiguous + {0x2109,0x2109,{1,1,2,2,2,2,2}}, // EA ambiguous + {0x2113,0x2113,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x2116,0x2116,{1,2,2,2,2,2,1}}, // EA ambiguous + {0x2121,0x2121,{1,1,2,2,2,2,1}}, // EA ambiguous + {0x2122,0x2122,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x2126,0x2126,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x212b,0x212b,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x2153,0x2154,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x215b,0x215e,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x2160,0x2169,{1,1,2,2,2,2,2}}, // EA ambiguous + {0x216a,0x216b,{1,1,1,2,2,1,1}}, // EA ambiguous + {0x2170,0x2179,{1,1,2,2,2,2,2}}, // EA ambiguous + {0x2190,0x2193,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2194,0x2195,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x2196,0x2199,{1,1,2,2,2,2,2}}, // EA ambiguous + {0x21b8,0x21b9,{1,1,1,1,2,1,1}}, // EA ambiguous + {0x21d2,0x21d2,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x21d4,0x21d4,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x21e7,0x21e7,{1,1,1,1,2,1,1}}, // EA ambiguous + {0x2200,0x2200,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x2202,0x2203,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x2207,0x2207,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x2208,0x2208,{1,2,2,2,2,1,1}}, // EA ambiguous + {0x220b,0x220b,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x220f,0x220f,{1,1,2,2,2,1,1}}, // EA ambiguous + {0x2211,0x2211,{1,1,2,2,2,1,1}}, // EA ambiguous + {0x2212,0x2212,{1,2,1,1,1,1,1}}, // minus sign + {0x2215,0x2215,{1,1,1,2,2,1,2}}, // EA ambiguous + {0x221a,0x221a,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x221d,0x221d,{1,2,2,2,2,1,1}}, // EA ambiguous + {0x221e,0x221e,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x221f,0x221f,{1,1,1,2,2,2,2}}, // EA ambiguous + {0x2220,0x2220,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2223,0x2223,{1,1,1,2,2,2,2}}, // EA ambiguous + {0x2225,0x2225,{1,1,2,2,2,2,2}}, // EA ambiguous + {0x2227,0x2228,{1,2,2,2,2,1,1}}, // EA ambiguous + {0x2229,0x222b,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x222c,0x222c,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x222e,0x222e,{1,1,2,2,2,2,2}}, // EA ambiguous + {0x2234,0x2235,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2236,0x2237,{1,1,1,2,2,1,1}}, // EA ambiguous + {0x223c,0x223c,{1,1,2,1,2,2,2}}, // EA ambiguous + {0x223d,0x223d,{1,2,2,2,2,1,1}}, // EA ambiguous + {0x2248,0x2248,{1,1,1,2,2,1,1}}, // EA ambiguous + {0x224c,0x224c,{1,1,1,2,2,1,1}}, // EA ambiguous + {0x2252,0x2252,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2260,0x2261,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2264,0x2265,{1,1,2,2,2,1,1}}, // EA ambiguous + {0x2266,0x2267,{1,2,1,2,2,2,2}}, // EA ambiguous + {0x226a,0x226b,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x226e,0x226f,{1,1,1,2,2,1,1}}, // EA ambiguous + {0x2282,0x2283,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x2286,0x2287,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x2295,0x2295,{1,1,1,2,2,1,2}}, // EA ambiguous + {0x2299,0x2299,{1,1,2,2,2,1,2}}, // EA ambiguous + {0x22a5,0x22a5,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x22bf,0x22bf,{1,1,1,2,2,2,2}}, // EA ambiguous + {0x2312,0x2312,{1,2,2,2,2,1,1}}, // EA ambiguous + {0x2329,0x232a,{2,2,2,2,2,2,2}}, // arrows (at least ends) + {0x2400,0x241f,{1,1,1,1,1,1,2}}, // control pictures + {0x2421,0x2421,{1,1,1,1,1,1,2}}, + {0x2460,0x2469,{1,1,2,2,2,2,2}}, // EA ambiguous to 24e9 + {0x246a,0x246e,{1,1,2,1,2,1,1}}, + {0x246f,0x2473,{1,1,1,1,2,1,1}}, + {0x2474,0x247d,{1,1,2,2,2,2,2}}, + {0x247e,0x2482,{1,1,2,2,2,1,1}}, + {0x2483,0x249b,{1,1,1,2,2,1,1}}, + {0x249c,0x24b5,{1,1,2,1,2,1,1}}, + {0x24b6,0x24cf,{1,1,1,1,2,1,1}}, + {0x24d0,0x24e9,{1,1,2,1,2,1,1}}, + {0x24eb,0x24fe,{1,1,1,1,2,1,1}}, // EA ambiguous to 254b + {0x2500,0x2500,{1,2,2,2,2,2,2}}, + {0x2501,0x2501,{1,2,2,2,2,1,1}}, + {0x2502,0x2502,{1,2,2,2,2,2,2}}, + {0x2503,0x2503,{1,2,2,2,2,1,1}}, + {0x2504,0x250b,{1,1,1,2,2,1,1}}, + {0x250c,0x250c,{1,2,2,2,2,2,2}}, + {0x250d,0x250e,{1,1,2,2,2,1,1}}, + {0x250f,0x250f,{1,2,2,2,2,1,1}}, + {0x2510,0x2510,{1,2,2,2,2,2,2}}, + {0x2511,0x2512,{1,1,2,2,2,1,1}}, + {0x2513,0x2513,{1,2,2,2,2,1,1}}, + {0x2514,0x2514,{1,2,2,2,2,2,2}}, + {0x2515,0x2516,{1,1,2,2,2,1,1}}, + {0x2517,0x2517,{1,2,2,2,2,1,1}}, + {0x2518,0x2518,{1,2,2,2,2,2,2}}, + {0x2519,0x251a,{1,1,2,2,2,1,1}}, + {0x251b,0x251b,{1,2,2,2,2,1,1}}, + {0x251c,0x251c,{1,2,2,2,2,2,2}}, + {0x251d,0x251d,{1,2,2,2,2,1,1}}, + {0x251e,0x251f,{1,1,2,2,2,1,1}}, + {0x2520,0x2520,{1,2,2,2,2,1,1}}, + {0x2521,0x2522,{1,1,2,2,2,1,1}}, + {0x2523,0x2523,{1,2,2,2,2,1,1}}, + {0x2524,0x2524,{1,2,2,2,2,2,2}}, + {0x2525,0x2525,{1,2,2,2,2,1,1}}, + {0x2526,0x2527,{1,1,2,2,2,1,1}}, + {0x2528,0x2528,{1,2,2,2,2,1,1}}, + {0x2529,0x252a,{1,1,2,2,2,1,1}}, + {0x252b,0x252b,{1,2,2,2,2,1,1}}, + {0x252c,0x252c,{1,2,2,2,2,2,2}}, + {0x252d,0x252e,{1,1,2,2,2,1,1}}, + {0x252f,0x2530,{1,2,2,2,2,1,1}}, + {0x2531,0x2532,{1,1,2,2,2,1,1}}, + {0x2533,0x2533,{1,2,2,2,2,1,1}}, + {0x2534,0x2534,{1,2,2,2,2,2,2}}, + {0x2535,0x2536,{1,1,2,2,2,1,1}}, + {0x2537,0x2538,{1,2,2,2,2,1,1}}, + {0x2539,0x253a,{1,1,2,2,2,1,1}}, + {0x253b,0x253b,{1,2,2,2,2,1,1}}, + {0x253c,0x253c,{1,2,2,2,2,2,2}}, + {0x253d,0x253e,{1,1,2,2,2,1,1}}, + {0x253f,0x253f,{1,2,2,2,2,1,1}}, + {0x2540,0x2541,{1,1,2,2,2,1,1}}, + {0x2542,0x2542,{1,2,2,2,2,1,1}}, + {0x2543,0x254a,{1,1,2,2,2,1,1}}, + {0x254b,0x254b,{1,2,2,2,2,1,1}}, // end of EA ambiguous + {0x2550,0x2573,{1,1,1,2,2,2,2}}, // EA ambiguous + {0x2574,0x2574,{1,1,1,1,1,1,2}}, + {0x2580,0x2580,{1,1,1,1,2,1,1}}, // EA ambiguous + {0x2581,0x258f,{1,1,1,2,2,2,2}}, // EA ambiguous + {0x2592,0x2592,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x2593,0x2593,{1,1,1,2,2,1,2}}, // EA ambiguous + {0x2594,0x2595,{1,1,1,2,2,2,2}}, // EA ambiguous + {0x25a0,0x25a1,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x25a3,0x25a9,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x25b2,0x25b3,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x25b6,0x25b7,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x25bc,0x25bd,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x25c0,0x25c1,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x25c6,0x25c7,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x25c8,0x25c8,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x25cb,0x25cb,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x25ce,0x25cf,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x25d0,0x25d1,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x25e2,0x25e5,{1,1,1,2,2,2,2}}, // EA ambiguous + {0x25ef,0x25ef,{1,2,1,1,2,1,1}}, // EA ambiguous + {0x2605,0x2606,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2609,0x2609,{1,1,1,2,2,2,2}}, // EA ambiguous + {0x260e,0x260f,{1,1,2,1,2,1,1}}, // EA ambiguous + // 2614-5 are EA ambiguous + {0x261c,0x261c,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x261e,0x261e,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x2640,0x2640,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2641,0x2641,{1,1,1,1,1,2,2}}, + {0x2642,0x2642,{1,2,2,2,2,2,2}}, // EA ambiguous + {0x2660,0x2661,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x2663,0x2665,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x2667,0x2669,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x266a,0x266a,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x266c,0x266c,{1,1,2,1,2,1,1}}, // EA ambiguous + {0x266d,0x266d,{1,2,2,1,2,1,1}}, // EA ambiguous + {0x266f,0x266f,{1,2,1,1,2,1,1}}, // EA ambiguous + {0x273d,0x273d,{1,1,1,1,2,2,1}}, + {0x273e,0x274b,{1,1,1,1,1,1,1}}, // EA ambiguous + {0x2776,0x277f,{1,1,1,1,2,1,1}}, // EA ambiguous + {0x2e80,0x2e99,{2,2,2,2,2,2,2}}, + {0x2e9b,0x2ef3,{2,2,2,2,2,2,2}}, + {0x2f00,0x2fd5,{2,2,2,2,2,2,2}}, + {0x2ff0,0x2ffb,{2,2,2,2,2,2,2}}, + {0x3000,0x3029,{2,2,2,2,2,2,2}}, + {0x3030,0x303e,{2,2,2,2,2,2,2}}, + {0x3041,0x3096,{2,2,2,2,2,2,2}}, + {0x309B,0x30ff,{2,2,2,2,2,2,2}}, + {0x3105,0x312d,{2,2,2,2,2,2,2}}, + {0x3131,0x318e,{2,2,2,2,2,2,2}}, + {0x3190,0x31ba,{2,2,2,2,2,2,2}}, + {0x31c0,0x31e3,{2,2,2,2,2,2,2}}, + {0x31f0,0x321c,{2,2,2,2,2,2,2}}, + {0x321d,0x321e,{2,2,2,2,2,2,2}}, + {0x3220,0x32cf,{2,2,2,2,2,2,2}}, + {0x3250,0x327b,{2,2,2,2,2,2,2}}, + {0x327c,0x32cf,{2,2,2,2,2,2,2}}, + {0x32d0,0x32fe,{2,2,2,2,2,2,2}}, + {0x3300,0x337a,{2,2,2,2,2,2,2}}, + {0x337b,0x33dd,{2,2,2,2,2,2,2}}, + {0x33de,0x3edf,{2,2,2,2,2,2,2}}, + {0x33e0,0x33ff,{2,2,2,2,2,2,2}}, + {0x3400,0x4db5,{2,2,2,2,2,2,2}}, // CJK Unified Ideographs Externsion A (to 4dbf) + {0x4dc0,0x4dff,{2,2,2,2,2,2,2}}, + {0x4e00,0x9fcc,{2,2,2,2,2,2,2}}, // CJK Unified Ideographs (to 9fff) + {0xa000,0xa48c,{2,2,2,2,2,2,2}}, + {0xa490,0xa4c6,{2,2,2,2,2,2,2}}, +// {0xa960,0xa97c,{2,2,2,2,2,2,2}}, + {0xac00,0xd7a3,{2,2,2,2,2,2,2}}, // Hangul + {0xe000,0xe002,{1,1,1,1,2,1,1}}, // EA ambiguous to f8ff + {0xe003,0xe003,{1,1,1,1,2,2,1}}, + {0xe004,0xe017,{1,1,1,1,2,1,1}}, + {0xe018,0xe018,{1,1,1,1,2,2,1}}, + {0xe019,0xe01a,{1,1,1,1,2,1,1}}, + {0xe01b,0xe01b,{1,1,1,1,2,2,1}}, + {0xe01c,0xe02c,{1,1,1,1,2,1,1}}, + {0xe02d,0xe02d,{1,1,1,1,2,2,1}}, + {0xe02e,0xe037,{1,1,1,1,2,1,1}}, + {0xe038,0xe038,{1,1,1,1,2,2,1}}, + {0xe039,0xe04b,{1,1,1,1,2,1,1}}, + {0xe04c,0xe04c,{1,1,1,1,2,2,1}}, + {0xe04d,0xe059,{1,1,1,1,2,1,1}}, + {0xe05a,0xe05a,{1,1,1,1,2,2,1}}, + {0xe05b,0xe093,{1,1,1,1,2,1,1}}, + {0xe094,0xe094,{1,1,1,1,2,2,1}}, + {0xe095,0xe098,{1,1,1,1,2,1,1}}, + {0xe099,0xe09a,{1,1,1,1,2,2,1}}, + {0xe09b,0xe0c4,{1,1,1,1,2,1,1}}, + {0xe0c5,0xe0c5,{1,1,1,1,2,2,1}}, + {0xe0c6,0xe0cf,{1,1,1,1,2,1,1}}, + {0xe0d0,0xe0d0,{1,1,1,1,2,2,1}}, + {0xe0d1,0xe0f1,{1,1,1,1,2,1,1}}, + {0xe0f2,0xe0f2,{1,1,1,1,2,2,1}}, + {0xe0f3,0xe0f8,{1,1,1,1,2,1,1}}, + {0xe0f9,0xe0f9,{1,1,1,1,2,2,1}}, + {0xe0fa,0xe0fc,{1,1,1,1,2,1,1}}, + {0xe0fd,0xe0fd,{1,1,1,1,2,2,1}}, + {0xe0fe,0xe105,{1,1,1,1,2,1,1}}, + {0xe106,0xe106,{1,1,1,1,2,2,1}}, + {0xe107,0xe108,{1,1,1,1,2,1,1}}, + {0xe109,0xe10a,{1,1,1,1,2,2,1}}, + {0xe10b,0xe12f,{1,1,1,1,2,1,1}}, + {0xe130,0xe130,{1,1,1,1,2,2,1}}, + {0xe131,0xe14f,{1,1,1,1,2,1,1}}, + {0xe150,0xe150,{1,1,1,1,2,2,1}}, + {0xe151,0xe153,{1,1,1,1,2,1,1}}, + {0xe154,0xe154,{1,1,1,1,2,2,1}}, + {0xe155,0xe15c,{1,1,1,1,2,1,1}}, + {0xe15d,0xe15d,{1,1,1,1,2,2,1}}, + {0xe15e,0xe167,{1,1,1,1,2,1,1}}, + {0xe168,0xe168,{1,1,1,1,2,2,1}}, + {0xe169,0xe169,{1,1,1,1,2,1,1}}, + {0xe16a,0xe16a,{1,1,1,1,2,2,1}}, + {0xe16b,0xe170,{1,1,1,1,2,1,1}}, + {0xe171,0xe171,{1,1,1,1,2,2,1}}, + {0xe172,0xe174,{1,1,1,1,2,1,1}}, + {0xe175,0xe175,{1,1,1,1,2,2,1}}, + {0xe176,0xe18e,{1,1,1,1,2,1,1}}, + {0xe18f,0xe18f,{1,1,1,1,2,2,1}}, + {0xe190,0xe1ba,{1,1,1,1,2,1,1}}, + {0xe1bb,0xe1bb,{1,1,1,1,2,2,1}}, + {0xe1bc,0xe1cb,{1,1,1,1,2,1,1}}, + {0xe1cc,0xe1cd,{1,1,1,1,2,2,1}}, + {0xe1ce,0xe1d6,{1,1,1,1,2,1,1}}, + {0xe1d7,0xe1d7,{1,1,1,1,2,2,1}}, + {0xe1d8,0xe1ee,{1,1,1,1,2,1,1}}, + {0xe1ef,0xe1ef,{1,1,1,1,2,2,1}}, + {0xe1f0,0xe1f1,{1,1,1,1,2,1,1}}, + {0xe1f2,0xe1f2,{1,1,1,1,2,2,1}}, + {0xe1f3,0xe1f9,{1,1,1,1,2,1,1}}, + {0xe1fa,0xe1fa,{1,1,1,1,2,2,1}}, + {0xe1fb,0xe1fd,{1,1,1,1,2,1,1}}, + {0xe1fe,0xe1fe,{1,1,1,1,2,2,1}}, + {0xe1ff,0xe201,{1,1,1,1,2,1,1}}, + {0xe202,0xe202,{1,1,1,1,2,2,1}}, + {0xe203,0xe20a,{1,1,1,1,2,1,1}}, + {0xe20b,0xe20b,{1,1,1,1,2,2,1}}, + {0xe20c,0xe218,{1,1,1,1,2,1,1}}, + {0xe219,0xe219,{1,1,1,1,2,2,1}}, + {0xe21a,0xe21b,{1,1,1,1,2,1,1}}, + {0xe21c,0xe21c,{1,1,1,1,2,2,1}}, + {0xe21d,0xe226,{1,1,1,1,2,1,1}}, + {0xe227,0xe227,{1,1,1,1,2,2,1}}, + {0xe228,0xe244,{1,1,1,1,2,1,1}}, + {0xe245,0xe245,{1,1,1,1,2,2,1}}, + {0xe246,0xe249,{1,1,1,1,2,1,1}}, + {0xe24a,0xe24a,{1,1,1,1,2,2,1}}, + {0xe24b,0xe24d,{1,1,1,1,2,1,1}}, + {0xe24e,0xe24e,{1,1,1,1,2,2,1}}, + {0xe24f,0xe26a,{1,1,1,1,2,1,1}}, + {0xe26b,0xe26b,{1,1,1,1,2,2,1}}, + {0xe26c,0xe279,{1,1,1,1,2,1,1}}, + {0xe27a,0xe27a,{1,1,1,1,2,2,1}}, + {0xe27b,0xe281,{1,1,1,1,2,1,1}}, + {0xe282,0xe282,{1,1,1,1,2,2,1}}, + {0xe283,0xe28f,{1,1,1,1,2,1,1}}, + {0xe290,0xe290,{1,1,1,1,2,2,1}}, + {0xe291,0xe29a,{1,1,1,1,2,1,1}}, + {0xe29b,0xe29b,{1,1,1,1,2,2,1}}, + {0xe29c,0xe2a0,{1,1,1,1,2,1,1}}, + {0xe2a1,0xe2a1,{1,1,1,1,2,2,1}}, + {0xe2a2,0xe2b1,{1,1,1,1,2,1,1}}, + {0xe2b2,0xe2b2,{1,1,1,1,2,2,1}}, + {0xe2b3,0xe2b6,{1,1,1,1,2,1,1}}, + {0xe2b7,0xe2b7,{1,1,1,1,2,2,1}}, + {0xe2b8,0xe2c0,{1,1,1,1,2,1,1}}, + {0xe2c1,0xe2c1,{1,1,1,1,2,2,1}}, + {0xe2c2,0xe2c8,{1,1,1,1,2,1,1}}, + {0xe2c9,0xe2c9,{1,1,1,1,2,2,1}}, + {0xe2ca,0xe2d3,{1,1,1,1,2,1,1}}, + {0xe2d4,0xe2d4,{1,1,1,1,2,2,1}}, + {0xe2d5,0xe2e1,{1,1,1,1,2,1,1}}, + {0xe2e2,0xe2e2,{1,1,1,1,2,2,1}}, + {0xe2e3,0xe2ea,{1,1,1,1,2,1,1}}, + {0xe2eb,0xe2ec,{1,1,1,1,2,2,1}}, + {0xe2ed,0xe2ef,{1,1,1,1,2,1,1}}, + {0xe2f0,0xe2f1,{1,1,1,1,2,2,1}}, + {0xe2f2,0xe2ff,{1,1,1,1,2,1,1}}, + {0xe300,0xe300,{1,1,1,1,2,2,1}}, + {0xe301,0xe310,{1,1,1,1,2,1,1}}, + {0xe311,0xe311,{1,1,1,1,2,2,1}}, + {0xe312,0xe324,{1,1,1,1,2,1,1}}, + {0xe325,0xe325,{1,1,1,1,2,2,1}}, + {0xe326,0xe32f,{1,1,1,1,2,1,1}}, + {0xe330,0xe330,{1,1,1,1,2,2,1}}, + {0xe331,0xe344,{1,1,1,1,2,1,1}}, + {0xe345,0xe345,{1,1,1,1,2,2,1}}, + {0xe346,0xe361,{1,1,1,1,2,1,1}}, + {0xe362,0xe362,{1,1,1,1,2,2,1}}, + {0xe363,0xe380,{1,1,1,1,2,1,1}}, + {0xe381,0xe382,{1,1,1,1,2,2,1}}, + {0xe383,0xe385,{1,1,1,1,2,1,1}}, + {0xe386,0xe386,{1,1,1,1,2,2,1}}, + {0xe387,0xe388,{1,1,1,1,2,1,1}}, + {0xe389,0xe389,{1,1,1,1,2,2,1}}, + {0xe38a,0xe393,{1,1,1,1,2,1,1}}, + {0xe394,0xe394,{1,1,1,1,2,2,1}}, + {0xe395,0xe395,{1,1,1,1,2,1,1}}, + {0xe396,0xe396,{1,1,1,1,2,2,1}}, + {0xe397,0xe39d,{1,1,1,1,2,1,1}}, + {0xe39e,0xe39e,{1,1,1,1,2,2,1}}, + {0xe39f,0xe39f,{1,1,1,1,2,1,1}}, + {0xe3a0,0xe3a0,{1,1,1,1,2,2,1}}, + {0xe3a1,0xe3b3,{1,1,1,1,2,1,1}}, + {0xe3b4,0xe3b4,{1,1,1,1,2,2,1}}, + {0xe3b5,0xe3ba,{1,1,1,1,2,1,1}}, + {0xe3bb,0xe3bb,{1,1,1,1,2,2,1}}, + {0xe3bc,0xe3cc,{1,1,1,1,2,1,1}}, + {0xe3cd,0xe3cd,{1,1,1,1,2,2,1}}, + {0xe3ce,0xe3ce,{1,1,1,1,2,1,1}}, + {0xe3cf,0xe3cf,{1,1,1,1,2,2,1}}, + {0xe3d0,0xe3d4,{1,1,1,1,2,1,1}}, + {0xe3d5,0xe3d5,{1,1,1,1,2,2,1}}, + {0xe3d6,0xe3e0,{1,1,1,1,2,1,1}}, + {0xe3e1,0xe3e1,{1,1,1,1,2,2,1}}, + {0xe3e2,0xe3e6,{1,1,1,1,2,1,1}}, + {0xe3e7,0xe3e7,{1,1,1,1,2,2,1}}, + {0xe3e8,0xe3ef,{1,1,1,1,2,1,1}}, + {0xe3f0,0xe3f0,{1,1,1,1,2,2,1}}, + {0xe3f1,0xe3f1,{1,1,1,1,2,1,1}}, + {0xe3f2,0xe3f2,{1,1,1,1,2,2,1}}, + {0xe3f3,0xe3f3,{1,1,1,1,2,1,1}}, + {0xe3f4,0xe3f4,{1,1,1,1,2,2,1}}, + {0xe3f5,0xe425,{1,1,1,1,2,1,1}}, + {0xe426,0xe426,{1,1,1,1,2,2,1}}, + {0xe427,0xe435,{1,1,1,1,2,1,1}}, + {0xe436,0xe436,{1,1,1,1,2,2,1}}, + {0xe437,0xe447,{1,1,1,1,2,1,1}}, + {0xe448,0xe448,{1,1,1,1,2,2,1}}, + {0xe449,0xe44c,{1,1,1,1,2,1,1}}, + {0xe44d,0xe44d,{1,1,1,1,2,2,1}}, + {0xe44e,0xe44f,{1,1,1,1,2,1,1}}, + {0xe450,0xe450,{1,1,1,1,2,2,1}}, + {0xe451,0xe466,{1,1,1,1,2,1,1}}, + {0xe467,0xe469,{1,1,1,1,2,2,1}}, + {0xe46a,0xe473,{1,1,1,1,2,1,1}}, + {0xe474,0xe474,{1,1,1,1,2,2,1}}, + {0xe475,0xe489,{1,1,1,1,2,1,1}}, + {0xe48a,0xe48a,{1,1,1,1,2,2,1}}, + {0xe48b,0xe4a0,{1,1,1,1,2,1,1}}, + {0xe4a1,0xe4a1,{1,1,1,1,2,2,1}}, + {0xe4a2,0xe4c0,{1,1,1,1,2,1,1}}, + {0xe4c1,0xe4c1,{1,1,1,1,2,2,1}}, + {0xe4c2,0xe4c5,{1,1,1,1,2,1,1}}, + {0xe4c6,0xe4c6,{1,1,1,1,2,2,1}}, + {0xe4c7,0xe4dc,{1,1,1,1,2,1,1}}, + {0xe4dd,0xe4dd,{1,1,1,1,2,2,1}}, + {0xe4de,0xe51d,{1,1,1,1,2,1,1}}, + {0xe51e,0xe51e,{1,1,1,1,2,2,1}}, + {0xe51f,0xe523,{1,1,1,1,2,1,1}}, + {0xe524,0xe524,{1,1,1,1,2,2,1}}, + {0xe525,0xe527,{1,1,1,1,2,1,1}}, + {0xe528,0xe528,{1,1,1,1,2,2,1}}, + {0xe529,0xe52d,{1,1,1,1,2,1,1}}, + {0xe52e,0xe52f,{1,1,1,1,2,2,1}}, + {0xe530,0xe56c,{1,1,1,1,2,1,1}}, + {0xe56d,0xe56d,{1,1,1,1,2,2,1}}, + {0xe56e,0xe56f,{1,1,1,1,2,1,1}}, + {0xe570,0xe570,{1,1,1,1,2,2,1}}, + {0xe571,0xe579,{1,1,1,1,2,1,1}}, + {0xe57a,0xe57a,{1,1,1,1,2,2,1}}, + {0xe57b,0xe57c,{1,1,1,1,2,1,1}}, + {0xe57d,0xe57d,{1,1,1,1,2,2,1}}, + {0xe57e,0xe583,{1,1,1,1,2,1,1}}, + {0xe584,0xe584,{1,1,1,1,2,2,1}}, + {0xe585,0xe58a,{1,1,1,1,2,1,1}}, + {0xe58b,0xe58b,{1,1,1,1,2,2,1}}, + {0xe58c,0xe599,{1,1,1,1,2,1,1}}, + {0xe59a,0xe59a,{1,1,1,1,2,2,1}}, + {0xe59b,0xe59d,{1,1,1,1,2,1,1}}, + {0xe59e,0xe59e,{1,1,1,1,2,2,1}}, + {0xe59f,0xe59f,{1,1,1,1,2,1,1}}, + {0xe5a0,0xe5a0,{1,1,1,1,2,2,1}}, + {0xe5a1,0xe5a5,{1,1,1,1,2,1,1}}, + {0xe5a6,0xe5a6,{1,1,1,1,2,2,1}}, + {0xe5a7,0xe5a9,{1,1,1,1,2,1,1}}, + {0xe5aa,0xe5aa,{1,1,1,1,2,2,1}}, + {0xe5ab,0xe5c1,{1,1,1,1,2,1,1}}, + {0xe5c2,0xe5c2,{1,1,1,1,2,2,1}}, + {0xe5c3,0xe5c7,{1,1,1,1,2,1,1}}, + {0xe5c8,0xe5c8,{1,1,1,1,2,2,1}}, + {0xe5c9,0xe5d7,{1,1,1,1,2,1,1}}, + {0xe5d8,0xe5d8,{1,1,1,1,2,2,1}}, + {0xe5d9,0xe5f0,{1,1,1,1,2,1,1}}, + {0xe5f1,0xe5f1,{1,1,1,1,2,2,1}}, + {0xe5f2,0xe618,{1,1,1,1,2,1,1}}, + {0xe619,0xe619,{1,1,1,1,2,2,1}}, + {0xe61a,0xe61b,{1,1,1,1,2,1,1}}, + {0xe61c,0xe61c,{1,1,1,1,2,2,1}}, + {0xe61d,0xe645,{1,1,1,1,2,1,1}}, + {0xe646,0xe646,{1,1,1,1,2,2,1}}, + {0xe647,0xe653,{1,1,1,1,2,1,1}}, + {0xe654,0xe654,{1,1,1,1,2,2,1}}, + {0xe655,0xe65f,{1,1,1,1,2,1,1}}, + {0xe660,0xe660,{1,1,1,1,2,2,1}}, + {0xe661,0xe669,{1,1,1,1,2,1,1}}, + {0xe66a,0xe66a,{1,1,1,1,2,2,1}}, + {0xe66b,0xe67c,{1,1,1,1,2,1,1}}, + {0xe67d,0xe67d,{1,1,1,1,2,2,1}}, + {0xe67e,0xe67f,{1,1,1,1,2,1,1}}, + {0xe680,0xe680,{1,1,1,1,2,2,1}}, + {0xe681,0xe68d,{1,1,1,1,2,1,1}}, + {0xe68e,0xe68e,{1,1,1,1,2,2,1}}, + {0xe68f,0xe696,{1,1,1,1,2,1,1}}, + {0xe697,0xe697,{1,1,1,1,2,2,1}}, + {0xe698,0xe69d,{1,1,1,1,2,1,1}}, + {0xe69e,0xe69e,{1,1,1,1,2,2,1}}, + {0xe69f,0xe6bf,{1,1,1,1,2,1,1}}, + {0xe6c0,0xe6c0,{1,1,1,1,2,2,1}}, + {0xe6c1,0xe6c4,{1,1,1,1,2,1,1}}, + {0xe6c5,0xe6c5,{1,1,1,1,2,2,1}}, + {0xe6c6,0xe6dd,{1,1,1,1,2,1,1}}, + {0xe6de,0xe6df,{1,1,1,1,2,2,1}}, + {0xe6e0,0xe700,{1,1,1,1,2,1,1}}, + {0xe701,0xe701,{1,1,1,1,2,2,1}}, + {0xe702,0xe712,{1,1,1,1,2,1,1}}, + {0xe713,0xe713,{1,1,1,1,2,2,1}}, + {0xe714,0xe724,{1,1,1,1,2,1,1}}, + {0xe725,0xe725,{1,1,1,1,2,2,1}}, + {0xe726,0xe73c,{1,1,1,1,2,1,1}}, + {0xe73d,0xe73d,{1,1,1,1,2,2,1}}, + {0xe73e,0xe740,{1,1,1,1,2,1,1}}, + {0xe741,0xe741,{1,1,1,1,2,2,1}}, + {0xe742,0xe751,{1,1,1,1,2,1,1}}, + {0xe752,0xe752,{1,1,1,1,2,2,1}}, + {0xe753,0xe75c,{1,1,1,1,2,1,1}}, + {0xe75d,0xe75d,{1,1,1,1,2,2,1}}, + {0xe75e,0xe760,{1,1,1,1,2,1,1}}, + {0xe761,0xe761,{1,1,1,1,2,2,1}}, + {0xe762,0xe767,{1,1,1,1,2,1,1}}, + {0xe768,0xe768,{1,1,1,1,2,2,1}}, + {0xe769,0xe774,{1,1,1,1,2,1,1}}, + {0xe775,0xe775,{1,1,1,1,2,2,1}}, + {0xe776,0xe779,{1,1,1,1,2,1,1}}, + {0xe77a,0xe77a,{1,1,1,1,2,2,1}}, + {0xe77b,0xe77c,{1,1,1,1,2,1,1}}, + {0xe77d,0xe77d,{1,1,1,1,2,2,1}}, + {0xe77e,0xe78f,{1,1,1,1,2,1,1}}, + {0xe790,0xe790,{1,1,1,1,2,2,1}}, + {0xe791,0xe796,{1,1,1,1,2,1,1}}, + {0xe797,0xe797,{1,1,1,1,2,2,1}}, + {0xe798,0xe7a5,{1,1,1,1,2,1,1}}, + {0xe7a6,0xe7a6,{1,1,1,1,2,2,1}}, + {0xe7a7,0xe7b3,{1,1,1,1,2,1,1}}, + {0xe7b4,0xe7b4,{1,1,1,1,2,2,1}}, + {0xe7b5,0xe7c6,{1,1,1,1,2,1,1}}, +#ifdef Win32 + {0xe7c7,0xe7c7,{1,1,1,1,1,1,1}}, +#else /* Win32 */ + {0xe7c7,0xe7c7,{1,1,1,1,2,1,1}}, +#endif /* Win32 */ + {0xe7c8,0xe7d9,{1,1,1,1,2,1,1}}, + {0xe7da,0xe7da,{1,1,1,1,2,2,1}}, + {0xe7db,0xe7dc,{1,1,1,1,2,1,1}}, + {0xe7dd,0xe7dd,{1,1,1,1,2,2,1}}, + {0xe7de,0xe7e7,{1,1,1,1,2,1,1}}, + {0xe7e8,0xe7e9,{1,1,1,1,2,2,1}}, + {0xe7ea,0xe7ec,{1,1,1,1,2,1,1}}, + {0xe7ed,0xe7ed,{1,1,1,1,2,2,1}}, + {0xe7ee,0xe7f0,{1,1,1,1,2,1,1}}, + {0xe7f1,0xe7f1,{1,1,1,1,2,2,1}}, + {0xe7f2,0xe7fa,{1,1,1,1,2,1,1}}, + {0xe7fb,0xe7fc,{1,1,1,1,2,2,1}}, + {0xe7fd,0xe7ff,{1,1,1,1,2,1,1}}, + {0xe800,0xe800,{1,1,1,1,2,2,1}}, + {0xe801,0xe80b,{1,1,1,1,2,1,1}}, + {0xe80c,0xe80c,{1,1,1,1,2,2,1}}, + {0xe80d,0xe812,{1,1,1,1,2,1,1}}, + {0xe813,0xe813,{1,1,1,1,2,2,1}}, + {0xe814,0xe820,{1,1,1,1,2,1,1}}, + {0xe821,0xe821,{1,1,1,1,2,2,1}}, + {0xe822,0xe827,{1,1,1,1,2,1,1}}, + {0xe828,0xe828,{1,1,1,1,2,2,1}}, + {0xe829,0xe82c,{1,1,1,1,2,1,1}}, + {0xe82d,0xe82d,{1,1,1,1,2,2,1}}, + {0xe82e,0xe82e,{1,1,1,1,2,1,1}}, + {0xe82f,0xe82f,{1,1,1,1,2,2,1}}, + {0xe830,0xe84c,{1,1,1,1,2,1,1}}, + {0xe84d,0xe84d,{1,1,1,1,2,2,1}}, + {0xe84e,0xe854,{1,1,1,1,2,1,1}}, + {0xe855,0xe856,{1,1,1,1,2,2,1}}, + {0xe857,0xe85a,{1,1,1,1,2,1,1}}, + {0xe85b,0xe85b,{1,1,1,1,2,2,1}}, + {0xe85c,0xe85c,{1,1,1,1,2,1,1}}, + {0xe85d,0xe85d,{1,1,1,1,2,2,1}}, + {0xe85e,0xe864,{1,1,1,1,2,1,1}}, + {0xe865,0xe865,{1,1,1,1,2,2,1}}, + {0xe866,0xe886,{1,1,1,1,2,1,1}}, + {0xe887,0xe887,{1,1,1,1,2,2,1}}, + {0xe888,0xe88e,{1,1,1,1,2,1,1}}, + {0xe88f,0xe88f,{1,1,1,1,2,2,1}}, + {0xe890,0xe890,{1,1,1,1,2,1,1}}, + {0xe891,0xe891,{1,1,1,1,2,2,1}}, + {0xe892,0xe8a0,{1,1,1,1,2,1,1}}, + {0xe8a1,0xe8a1,{1,1,1,1,2,2,1}}, + {0xe8a2,0xe8a3,{1,1,1,1,2,1,1}}, + {0xe8a4,0xe8a4,{1,1,1,1,2,2,1}}, + {0xe8a5,0xe8c1,{1,1,1,1,2,1,1}}, + {0xe8c2,0xe8c3,{1,1,1,1,2,2,1}}, + {0xe8c4,0xe8cc,{1,1,1,1,2,1,1}}, + {0xe8cd,0xe8cd,{1,1,1,1,2,2,1}}, + {0xe8ce,0xe8d4,{1,1,1,1,2,1,1}}, + {0xe8d5,0xe8d6,{1,1,1,1,2,2,1}}, + {0xe8d7,0xe8d8,{1,1,1,1,2,1,1}}, + {0xe8d9,0xe8da,{1,1,1,1,2,2,1}}, + {0xe8db,0xe8e0,{1,1,1,1,2,1,1}}, + {0xe8e1,0xe8e1,{1,1,1,1,2,2,1}}, + {0xe8e2,0xe8e4,{1,1,1,1,2,1,1}}, + {0xe8e5,0xe8e5,{1,1,1,1,2,2,1}}, + {0xe8e6,0xe8fd,{1,1,1,1,2,1,1}}, + {0xe8fe,0xe8fe,{1,1,1,1,2,2,1}}, + {0xe8ff,0xe916,{1,1,1,1,2,1,1}}, + {0xe917,0xe918,{1,1,1,1,2,2,1}}, + {0xe919,0xe91e,{1,1,1,1,2,1,1}}, + {0xe91f,0xe91f,{1,1,1,1,2,2,1}}, + {0xe920,0xe924,{1,1,1,1,2,1,1}}, + {0xe925,0xe925,{1,1,1,1,2,2,1}}, + {0xe926,0xe92a,{1,1,1,1,2,1,1}}, + {0xe92b,0xe92b,{1,1,1,1,2,2,1}}, + {0xe92c,0xe933,{1,1,1,1,2,1,1}}, + {0xe934,0xe934,{1,1,1,1,2,2,1}}, + {0xe935,0xe94f,{1,1,1,1,2,1,1}}, + {0xe950,0xe950,{1,1,1,1,2,2,1}}, + {0xe951,0xe966,{1,1,1,1,2,1,1}}, + {0xe967,0xe967,{1,1,1,1,2,2,1}}, + {0xe968,0xe96d,{1,1,1,1,2,1,1}}, + {0xe96e,0xe96f,{1,1,1,1,2,2,1}}, + {0xe970,0xe972,{1,1,1,1,2,1,1}}, + {0xe973,0xe973,{1,1,1,1,2,2,1}}, + {0xe974,0xe976,{1,1,1,1,2,1,1}}, + {0xe977,0xe977,{1,1,1,1,2,2,1}}, + {0xe978,0xe979,{1,1,1,1,2,1,1}}, + {0xe97a,0xe97b,{1,1,1,1,2,2,1}}, + {0xe97c,0xe97c,{1,1,1,1,2,1,1}}, + {0xe97d,0xe97d,{1,1,1,1,2,2,1}}, + {0xe97e,0xe981,{1,1,1,1,2,1,1}}, + {0xe982,0xe982,{1,1,1,1,2,2,1}}, + {0xe983,0xe990,{1,1,1,1,2,1,1}}, + {0xe991,0xe991,{1,1,1,1,2,2,1}}, + {0xe992,0xe9ca,{1,1,1,1,2,1,1}}, + {0xe9cb,0xe9cb,{1,1,1,1,2,2,1}}, + {0xe9cc,0xeaa8,{1,1,1,1,2,1,1}}, + {0xeaa9,0xeaa9,{1,1,1,1,2,2,1}}, + {0xeaaa,0xeabe,{1,1,1,1,2,1,1}}, + {0xeabf,0xeac1,{1,1,1,1,2,2,1}}, + {0xeac2,0xeac4,{1,1,1,1,2,1,1}}, + {0xeac5,0xeac5,{1,1,1,1,2,2,1}}, + {0xeac6,0xeac8,{1,1,1,1,2,1,1}}, + {0xeac9,0xeacc,{1,1,1,1,2,2,1}}, + {0xeacd,0xeace,{1,1,1,1,2,1,1}}, + {0xeacf,0xead1,{1,1,1,1,2,2,1}}, + {0xead2,0xead2,{1,1,1,1,2,1,1}}, + {0xead3,0xead4,{1,1,1,1,2,2,1}}, + {0xead5,0xead5,{1,1,1,1,2,1,1}}, + {0xead6,0xead7,{1,1,1,1,2,2,1}}, + {0xead8,0xead8,{1,1,1,1,2,1,1}}, + {0xead9,0xeada,{1,1,1,1,2,2,1}}, + {0xeadb,0xeadb,{1,1,1,1,2,1,1}}, + {0xeadc,0xeadc,{1,1,1,1,2,2,1}}, + {0xeadd,0xeadd,{1,1,1,1,2,1,1}}, + {0xeade,0xeae3,{1,1,1,1,2,2,1}}, + {0xeae4,0xeae6,{1,1,1,1,2,1,1}}, + {0xeae7,0xeae7,{1,1,1,1,2,2,1}}, + {0xeae8,0xeae8,{1,1,1,1,2,1,1}}, + {0xeae9,0xeaea,{1,1,1,1,2,2,1}}, + {0xeaeb,0xeaeb,{1,1,1,1,2,1,1}}, + {0xeaec,0xeaec,{1,1,1,1,2,2,1}}, + {0xeaed,0xeaed,{1,1,1,1,2,1,1}}, + {0xeaee,0xeaee,{1,1,1,1,2,2,1}}, + {0xeaef,0xeaef,{1,1,1,1,2,1,1}}, + {0xeaf0,0xeaf1,{1,1,1,1,2,2,1}}, + {0xeaf2,0xeaf4,{1,1,1,1,2,1,1}}, + {0xeaf5,0xeaf6,{1,1,1,1,2,2,1}}, + {0xeaf7,0xeaf7,{1,1,1,1,2,1,1}}, + {0xeaf8,0xeafb,{1,1,1,1,2,2,1}}, + {0xeafc,0xeafe,{1,1,1,1,2,1,1}}, + {0xeaff,0xeb00,{1,1,1,1,2,2,1}}, + {0xeb01,0xeb01,{1,1,1,1,2,1,1}}, + {0xeb02,0xeb05,{1,1,1,1,2,2,1}}, + {0xeb06,0xeb07,{1,1,1,1,2,1,1}}, + {0xeb08,0xeb0f,{1,1,1,1,2,2,1}}, + {0xeb10,0xeb11,{1,1,1,1,2,1,1}}, + {0xeb12,0xeb12,{1,1,1,1,2,2,1}}, + {0xeb13,0xeb14,{1,1,1,1,2,1,1}}, + {0xeb15,0xeb15,{1,1,1,1,2,2,1}}, + {0xeb16,0xeb18,{1,1,1,1,2,1,1}}, + {0xeb19,0xeb1d,{1,1,1,1,2,2,1}}, + {0xeb1e,0xeb1e,{1,1,1,1,2,1,1}}, + {0xeb1f,0xeb20,{1,1,1,1,2,2,1}}, + {0xeb21,0xeb22,{1,1,1,1,2,1,1}}, + {0xeb23,0xeb23,{1,1,1,1,2,2,1}}, + {0xeb24,0xeb24,{1,1,1,1,2,1,1}}, + {0xeb25,0xeb25,{1,1,1,1,2,2,1}}, + {0xeb26,0xeb26,{1,1,1,1,2,1,1}}, + {0xeb27,0xeb27,{1,1,1,1,2,2,1}}, + {0xeb28,0xeb29,{1,1,1,1,2,1,1}}, + {0xeb2a,0xeb2a,{1,1,1,1,2,2,1}}, + {0xeb2b,0xeb2b,{1,1,1,1,2,1,1}}, + {0xeb2c,0xeb2e,{1,1,1,1,2,2,1}}, + {0xeb2f,0xeb2f,{1,1,1,1,2,1,1}}, + {0xeb30,0xeb39,{1,1,1,1,2,2,1}}, + {0xeb3a,0xeb3c,{1,1,1,1,2,1,1}}, + {0xeb3d,0xeb3f,{1,1,1,1,2,2,1}}, + {0xeb40,0xeb42,{1,1,1,1,2,1,1}}, + {0xeb43,0xeb44,{1,1,1,1,2,2,1}}, + {0xeb45,0xeb49,{1,1,1,1,2,1,1}}, + {0xeb4a,0xeb4a,{1,1,1,1,2,2,1}}, + {0xeb4b,0xeb4c,{1,1,1,1,2,1,1}}, + {0xeb4d,0xeb4e,{1,1,1,1,2,2,1}}, + {0xeb4f,0xeb52,{1,1,1,1,2,1,1}}, + {0xeb53,0xeb53,{1,1,1,1,2,2,1}}, + {0xeb54,0xeb54,{1,1,1,1,2,1,1}}, + {0xeb55,0xeb56,{1,1,1,1,2,2,1}}, + {0xeb57,0xeb57,{1,1,1,1,2,1,1}}, + {0xeb58,0xeb58,{1,1,1,1,2,2,1}}, + {0xeb59,0xeb59,{1,1,1,1,2,1,1}}, + {0xeb5a,0xeb5b,{1,1,1,1,2,2,1}}, + {0xeb5c,0xeb61,{1,1,1,1,2,1,1}}, + {0xeb62,0xeb63,{1,1,1,1,2,2,1}}, + {0xeb64,0xeb64,{1,1,1,1,2,1,1}}, + {0xeb65,0xeb65,{1,1,1,1,2,2,1}}, + {0xeb66,0xeb66,{1,1,1,1,2,1,1}}, + {0xeb67,0xeb69,{1,1,1,1,2,2,1}}, + {0xeb6a,0xeb6e,{1,1,1,1,2,1,1}}, + {0xeb6f,0xeb71,{1,1,1,1,2,2,1}}, + {0xeb72,0xeb72,{1,1,1,1,2,1,1}}, + {0xeb73,0xeb73,{1,1,1,1,2,2,1}}, + {0xeb74,0xeb75,{1,1,1,1,2,1,1}}, + {0xeb76,0xeb77,{1,1,1,1,2,2,1}}, + {0xeb78,0xeb79,{1,1,1,1,2,1,1}}, + {0xeb7a,0xeb7a,{1,1,1,1,2,2,1}}, + {0xeb7b,0xeb7d,{1,1,1,1,2,1,1}}, + {0xeb7e,0xeb80,{1,1,1,1,2,2,1}}, + {0xeb81,0xeb82,{1,1,1,1,2,1,1}}, + {0xeb83,0xeb83,{1,1,1,1,2,2,1}}, + {0xeb84,0xeb87,{1,1,1,1,2,1,1}}, + {0xeb88,0xeb88,{1,1,1,1,2,2,1}}, + {0xeb89,0xeb89,{1,1,1,1,2,1,1}}, + {0xeb8a,0xeb8a,{1,1,1,1,2,2,1}}, + {0xeb8b,0xeb8b,{1,1,1,1,2,1,1}}, + {0xeb8c,0xeb8c,{1,1,1,1,2,2,1}}, + {0xeb8d,0xeb8f,{1,1,1,1,2,1,1}}, + {0xeb90,0xeb90,{1,1,1,1,2,2,1}}, + {0xeb91,0xeb92,{1,1,1,1,2,1,1}}, + {0xeb93,0xeb93,{1,1,1,1,2,2,1}}, + {0xeb94,0xeb94,{1,1,1,1,2,1,1}}, + {0xeb95,0xeb95,{1,1,1,1,2,2,1}}, + {0xeb96,0xeb98,{1,1,1,1,2,1,1}}, + {0xeb99,0xeb99,{1,1,1,1,2,2,1}}, + {0xeb9a,0xeb9a,{1,1,1,1,2,1,1}}, + {0xeb9b,0xeb9b,{1,1,1,1,2,2,1}}, + {0xeb9c,0xeb9e,{1,1,1,1,2,1,1}}, + {0xeb9f,0xeb9f,{1,1,1,1,2,2,1}}, + {0xeba0,0xeba1,{1,1,1,1,2,1,1}}, + {0xeba2,0xeba2,{1,1,1,1,2,2,1}}, + {0xeba3,0xeba4,{1,1,1,1,2,1,1}}, + {0xeba5,0xeba6,{1,1,1,1,2,2,1}}, + {0xeba7,0xeba9,{1,1,1,1,2,1,1}}, + {0xebaa,0xebab,{1,1,1,1,2,2,1}}, + {0xebac,0xebad,{1,1,1,1,2,1,1}}, + {0xebae,0xebae,{1,1,1,1,2,2,1}}, + {0xebaf,0xebb1,{1,1,1,1,2,1,1}}, + {0xebb2,0xebb3,{1,1,1,1,2,2,1}}, + {0xebb4,0xebbc,{1,1,1,1,2,1,1}}, + {0xebbd,0xebbd,{1,1,1,1,2,2,1}}, + {0xebbe,0xebbe,{1,1,1,1,2,1,1}}, + {0xebbf,0xebbf,{1,1,1,1,2,2,1}}, + {0xebc0,0xebc4,{1,1,1,1,2,1,1}}, + {0xebc5,0xebc5,{1,1,1,1,2,2,1}}, + {0xebc6,0xebc9,{1,1,1,1,2,1,1}}, + {0xebca,0xebca,{1,1,1,1,2,2,1}}, + {0xebcb,0xebcb,{1,1,1,1,2,1,1}}, + {0xebcc,0xebcc,{1,1,1,1,2,2,1}}, + {0xebcd,0xebcd,{1,1,1,1,2,1,1}}, + {0xebce,0xebce,{1,1,1,1,2,2,1}}, + {0xebcf,0xebcf,{1,1,1,1,2,1,1}}, + {0xebd0,0xebd0,{1,1,1,1,2,2,1}}, + {0xebd1,0xebd4,{1,1,1,1,2,1,1}}, + {0xebd5,0xebd5,{1,1,1,1,2,2,1}}, + {0xebd6,0xebd6,{1,1,1,1,2,1,1}}, + {0xebd7,0xebd8,{1,1,1,1,2,2,1}}, + {0xebd9,0xebd9,{1,1,1,1,2,1,1}}, + {0xebda,0xebdb,{1,1,1,1,2,2,1}}, + {0xebdc,0xebdc,{1,1,1,1,2,1,1}}, + {0xebdd,0xebdd,{1,1,1,1,2,2,1}}, + {0xebde,0xebde,{1,1,1,1,2,1,1}}, + {0xebdf,0xebdf,{1,1,1,1,2,2,1}}, + {0xebe0,0xebe0,{1,1,1,1,2,1,1}}, + {0xebe1,0xebe1,{1,1,1,1,2,2,1}}, + {0xebe2,0xebe3,{1,1,1,1,2,1,1}}, + {0xebe4,0xebe4,{1,1,1,1,2,2,1}}, + {0xebe5,0xebe7,{1,1,1,1,2,1,1}}, + {0xebe8,0xebe9,{1,1,1,1,2,2,1}}, + {0xebea,0xebea,{1,1,1,1,2,1,1}}, + {0xebeb,0xebec,{1,1,1,1,2,2,1}}, + {0xebed,0xebee,{1,1,1,1,2,1,1}}, + {0xebef,0xebef,{1,1,1,1,2,2,1}}, + {0xebf0,0xebf1,{1,1,1,1,2,1,1}}, + {0xebf2,0xebf2,{1,1,1,1,2,2,1}}, + {0xebf3,0xebf4,{1,1,1,1,2,1,1}}, + {0xebf5,0xebf5,{1,1,1,1,2,2,1}}, + {0xebf6,0xebf8,{1,1,1,1,2,1,1}}, + {0xebf9,0xebfa,{1,1,1,1,2,2,1}}, + {0xebfb,0xebfd,{1,1,1,1,2,1,1}}, + {0xebfe,0xebfe,{1,1,1,1,2,2,1}}, + {0xebff,0xec07,{1,1,1,1,2,1,1}}, + {0xec08,0xec09,{1,1,1,1,2,2,1}}, + {0xec0a,0xec0e,{1,1,1,1,2,1,1}}, + {0xec0f,0xec0f,{1,1,1,1,2,2,1}}, + {0xec10,0xec12,{1,1,1,1,2,1,1}}, + {0xec13,0xec13,{1,1,1,1,2,2,1}}, + {0xec14,0xec18,{1,1,1,1,2,1,1}}, + {0xec19,0xec1c,{1,1,1,1,2,2,1}}, + {0xec1d,0xec23,{1,1,1,1,2,1,1}}, + {0xec24,0xec24,{1,1,1,1,2,2,1}}, + {0xec25,0xec25,{1,1,1,1,2,1,1}}, + {0xec26,0xec26,{1,1,1,1,2,2,1}}, + {0xec27,0xec2a,{1,1,1,1,2,1,1}}, + {0xec2b,0xec2b,{1,1,1,1,2,2,1}}, + {0xec2c,0xec2e,{1,1,1,1,2,1,1}}, + {0xec2f,0xec2f,{1,1,1,1,2,2,1}}, + {0xec30,0xec31,{1,1,1,1,2,1,1}}, + {0xec32,0xec32,{1,1,1,1,2,2,1}}, + {0xec33,0xec3e,{1,1,1,1,2,1,1}}, + {0xec3f,0xec3f,{1,1,1,1,2,2,1}}, + {0xec40,0xec42,{1,1,1,1,2,1,1}}, + {0xec43,0xec49,{1,1,1,1,2,2,1}}, + {0xec4a,0xec4a,{1,1,1,1,2,1,1}}, + {0xec4b,0xec4b,{1,1,1,1,2,2,1}}, + {0xec4c,0xec4e,{1,1,1,1,2,1,1}}, + {0xec4f,0xec4f,{1,1,1,1,2,2,1}}, + {0xec50,0xec51,{1,1,1,1,2,1,1}}, + {0xec52,0xec52,{1,1,1,1,2,2,1}}, + {0xec53,0xec53,{1,1,1,1,2,1,1}}, + {0xec54,0xec54,{1,1,1,1,2,2,1}}, + {0xec55,0xec55,{1,1,1,1,2,1,1}}, + {0xec56,0xec58,{1,1,1,1,2,2,1}}, + {0xec59,0xec59,{1,1,1,1,2,1,1}}, + {0xec5a,0xec5a,{1,1,1,1,2,2,1}}, + {0xec5b,0xec5b,{1,1,1,1,2,1,1}}, + {0xec5c,0xec5d,{1,1,1,1,2,2,1}}, + {0xec5e,0xec5f,{1,1,1,1,2,1,1}}, + {0xec60,0xec60,{1,1,1,1,2,2,1}}, + {0xec61,0xec61,{1,1,1,1,2,1,1}}, + {0xec62,0xec63,{1,1,1,1,2,2,1}}, + {0xec64,0xec66,{1,1,1,1,2,1,1}}, + {0xec67,0xec67,{1,1,1,1,2,2,1}}, + {0xec68,0xec68,{1,1,1,1,2,1,1}}, + {0xec69,0xec6d,{1,1,1,1,2,2,1}}, + {0xec6e,0xec6e,{1,1,1,1,2,1,1}}, + {0xec6f,0xec70,{1,1,1,1,2,2,1}}, + {0xec71,0xec71,{1,1,1,1,2,1,1}}, + {0xec72,0xec73,{1,1,1,1,2,2,1}}, + {0xec74,0xec74,{1,1,1,1,2,1,1}}, + {0xec75,0xec75,{1,1,1,1,2,2,1}}, + {0xec76,0xec78,{1,1,1,1,2,1,1}}, + {0xec79,0xec79,{1,1,1,1,2,2,1}}, + {0xec7a,0xec7a,{1,1,1,1,2,1,1}}, + {0xec7b,0xec7b,{1,1,1,1,2,2,1}}, + {0xec7c,0xec7d,{1,1,1,1,2,1,1}}, + {0xec7e,0xec7e,{1,1,1,1,2,2,1}}, + {0xec7f,0xec83,{1,1,1,1,2,1,1}}, + {0xec84,0xec84,{1,1,1,1,2,2,1}}, + {0xec85,0xec8d,{1,1,1,1,2,1,1}}, + {0xec8e,0xec8e,{1,1,1,1,2,2,1}}, + {0xec8f,0xec91,{1,1,1,1,2,1,1}}, + {0xec92,0xec92,{1,1,1,1,2,2,1}}, + {0xec93,0xec94,{1,1,1,1,2,1,1}}, + {0xec95,0xec95,{1,1,1,1,2,2,1}}, + {0xec96,0xecae,{1,1,1,1,2,1,1}}, + {0xecaf,0xecaf,{1,1,1,1,2,2,1}}, + {0xecb0,0xecb5,{1,1,1,1,2,1,1}}, + {0xecb6,0xecb6,{1,1,1,1,2,2,1}}, + {0xecb7,0xecce,{1,1,1,1,2,1,1}}, + {0xeccf,0xeccf,{1,1,1,1,2,2,1}}, + {0xecd0,0xecdb,{1,1,1,1,2,1,1}}, + {0xecdc,0xecdc,{1,1,1,1,2,2,1}}, + {0xecdd,0xecdf,{1,1,1,1,2,1,1}}, + {0xece0,0xece1,{1,1,1,1,2,2,1}}, + {0xece2,0xecef,{1,1,1,1,2,1,1}}, + {0xecf0,0xecf0,{1,1,1,1,2,2,1}}, + {0xecf1,0xecf1,{1,1,1,1,2,1,1}}, + {0xecf2,0xecf2,{1,1,1,1,2,2,1}}, + {0xecf3,0xecfb,{1,1,1,1,2,1,1}}, + {0xecfc,0xecfc,{1,1,1,1,2,2,1}}, + {0xecfd,0xed10,{1,1,1,1,2,1,1}}, + {0xed11,0xed11,{1,1,1,1,2,2,1}}, + {0xed12,0xed1c,{1,1,1,1,2,1,1}}, + {0xed1d,0xed1d,{1,1,1,1,2,2,1}}, + {0xed1e,0xed23,{1,1,1,1,2,1,1}}, + {0xed24,0xed24,{1,1,1,1,2,2,1}}, + {0xed25,0xed28,{1,1,1,1,2,1,1}}, + {0xed29,0xed29,{1,1,1,1,2,2,1}}, + {0xed2a,0xed2b,{1,1,1,1,2,1,1}}, + {0xed2c,0xed2c,{1,1,1,1,2,2,1}}, + {0xed2d,0xed3a,{1,1,1,1,2,1,1}}, + {0xed3b,0xed3b,{1,1,1,1,2,2,1}}, + {0xed3c,0xed40,{1,1,1,1,2,1,1}}, + {0xed41,0xed41,{1,1,1,1,2,2,1}}, + {0xed42,0xed4e,{1,1,1,1,2,1,1}}, + {0xed4f,0xed4f,{1,1,1,1,2,2,1}}, + {0xed50,0xed51,{1,1,1,1,2,1,1}}, + {0xed52,0xed52,{1,1,1,1,2,2,1}}, + {0xed53,0xed5e,{1,1,1,1,2,1,1}}, + {0xed5f,0xed5f,{1,1,1,1,2,2,1}}, + {0xed60,0xed6a,{1,1,1,1,2,1,1}}, + {0xed6b,0xed6b,{1,1,1,1,2,2,1}}, + {0xed6c,0xed77,{1,1,1,1,2,1,1}}, + {0xed78,0xed78,{1,1,1,1,2,2,1}}, + {0xed79,0xed83,{1,1,1,1,2,1,1}}, + {0xed84,0xed85,{1,1,1,1,2,2,1}}, + {0xed86,0xed87,{1,1,1,1,2,1,1}}, + {0xed88,0xed88,{1,1,1,1,2,2,1}}, + {0xed89,0xed8a,{1,1,1,1,2,1,1}}, + {0xed8b,0xed8b,{1,1,1,1,2,2,1}}, + {0xed8c,0xed8d,{1,1,1,1,2,1,1}}, + {0xed8e,0xed8e,{1,1,1,1,2,2,1}}, + {0xed8f,0xedce,{1,1,1,1,2,1,1}}, + {0xedcf,0xedcf,{1,1,1,1,2,2,1}}, + {0xedd0,0xedd9,{1,1,1,1,2,1,1}}, + {0xedda,0xedda,{1,1,1,1,2,2,1}}, + {0xeddb,0xedec,{1,1,1,1,2,1,1}}, + {0xeded,0xeded,{1,1,1,1,2,2,1}}, + {0xedee,0xee07,{1,1,1,1,2,1,1}}, + {0xee08,0xee08,{1,1,1,1,2,2,1}}, + {0xee09,0xee5c,{1,1,1,1,2,1,1}}, + {0xee5d,0xee5d,{1,1,1,1,2,2,1}}, + {0xee5e,0xee69,{1,1,1,1,2,1,1}}, + {0xee6a,0xee6a,{1,1,1,1,2,2,1}}, + {0xee6b,0xeea4,{1,1,1,1,2,1,1}}, + {0xeea5,0xeea5,{1,1,1,1,2,2,1}}, + {0xeea6,0xeeaf,{1,1,1,1,2,1,1}}, + {0xeeb0,0xeeb0,{1,1,1,1,2,2,1}}, + {0xeeb1,0xeeb3,{1,1,1,1,2,1,1}}, + {0xeeb4,0xeeb4,{1,1,1,1,2,2,1}}, + {0xeeb5,0xeeb6,{1,1,1,1,2,1,1}}, + {0xeeb7,0xeeb7,{1,1,1,1,2,2,1}}, + {0xeeb8,0xf302,{1,1,1,1,2,1,1}}, + {0xf303,0xf318,{1,1,1,1,2,2,1}}, + {0xf319,0xf324,{1,1,1,1,2,1,1}}, + {0xf325,0xf325,{1,1,1,1,2,2,1}}, + {0xf326,0xf326,{1,1,1,1,2,1,1}}, + {0xf327,0xf327,{1,1,1,1,2,2,1}}, + {0xf328,0xf343,{1,1,1,1,2,1,1}}, + {0xf344,0xf344,{1,1,1,1,2,2,1}}, + {0xf345,0xf345,{1,1,1,1,2,1,1}}, + {0xf346,0xf346,{1,1,1,1,2,2,1}}, + {0xf347,0xf349,{1,1,1,1,2,1,1}}, + {0xf34a,0xf34b,{1,1,1,1,2,2,1}}, + {0xf34c,0xf3a0,{1,1,1,1,2,1,1}}, + {0xf3a1,0xf3a1,{1,1,1,1,2,2,1}}, + {0xf3a2,0xf3ef,{1,1,1,1,2,1,1}}, + {0xf3f0,0xf3f0,{1,1,1,1,2,2,1}}, + {0xf3f1,0xf3f8,{1,1,1,1,2,1,1}}, + {0xf3f9,0xf3f9,{1,1,1,1,2,2,1}}, + {0xf3fa,0xf3fb,{1,1,1,1,2,1,1}}, + {0xf3fc,0xf3fc,{1,1,1,1,2,2,1}}, + {0xf3fd,0xf407,{1,1,1,1,2,1,1}}, + {0xf408,0xf408,{1,1,1,1,2,2,1}}, + {0xf409,0xf40a,{1,1,1,1,2,1,1}}, + {0xf40b,0xf40b,{1,1,1,1,2,2,1}}, + {0xf40c,0xf43c,{1,1,1,1,2,1,1}}, + {0xf43d,0xf43d,{1,1,1,1,2,2,1}}, + {0xf43e,0xf440,{1,1,1,1,2,1,1}}, + {0xf441,0xf442,{1,1,1,1,2,2,1}}, + {0xf443,0xf448,{1,1,1,1,2,1,1}}, + {0xf449,0xf449,{1,1,1,1,2,2,1}}, + {0xf44a,0xf44c,{1,1,1,1,2,1,1}}, + {0xf44d,0xf44d,{1,1,1,1,2,2,1}}, + {0xf44e,0xf44f,{1,1,1,1,2,1,1}}, + {0xf450,0xf450,{1,1,1,1,2,2,1}}, + {0xf451,0xf453,{1,1,1,1,2,1,1}}, + {0xf454,0xf454,{1,1,1,1,2,2,1}}, + {0xf455,0xf459,{1,1,1,1,2,1,1}}, + {0xf45a,0xf45d,{1,1,1,1,2,2,1}}, + {0xf45e,0xf461,{1,1,1,1,2,1,1}}, + {0xf462,0xf462,{1,1,1,1,2,2,1}}, + {0xf463,0xf464,{1,1,1,1,2,1,1}}, + {0xf465,0xf466,{1,1,1,1,2,2,1}}, + {0xf467,0xf468,{1,1,1,1,2,1,1}}, + {0xf469,0xf469,{1,1,1,1,2,2,1}}, + {0xf46a,0xf46c,{1,1,1,1,2,1,1}}, + {0xf46d,0xf46f,{1,1,1,1,2,2,1}}, + {0xf470,0xf476,{1,1,1,1,2,1,1}}, + {0xf477,0xf478,{1,1,1,1,2,2,1}}, + {0xf479,0xf47b,{1,1,1,1,2,1,1}}, + {0xf47c,0xf47e,{1,1,1,1,2,2,1}}, + {0xf47f,0xf47f,{1,1,1,1,2,1,1}}, + {0xf480,0xf480,{1,1,1,1,2,2,1}}, + {0xf481,0xf484,{1,1,1,1,2,1,1}}, + {0xf485,0xf485,{1,1,1,1,2,2,1}}, + {0xf486,0xf487,{1,1,1,1,2,1,1}}, + {0xf488,0xf488,{1,1,1,1,2,2,1}}, + {0xf489,0xf48a,{1,1,1,1,2,1,1}}, + {0xf48b,0xf48b,{1,1,1,1,2,2,1}}, + {0xf48c,0xf48c,{1,1,1,1,2,1,1}}, + {0xf48d,0xf48d,{1,1,1,1,2,2,1}}, + {0xf48e,0xf48e,{1,1,1,1,2,1,1}}, + {0xf48f,0xf491,{1,1,1,1,2,2,1}}, + {0xf492,0xf496,{1,1,1,1,2,1,1}}, + {0xf497,0xf498,{1,1,1,1,2,2,1}}, + {0xf499,0xf49a,{1,1,1,1,2,1,1}}, + {0xf49b,0xf49b,{1,1,1,1,2,2,1}}, + {0xf49c,0xf4a3,{1,1,1,1,2,1,1}}, + {0xf4a4,0xf4a4,{1,1,1,1,2,2,1}}, + {0xf4a5,0xf4a6,{1,1,1,1,2,1,1}}, + {0xf4a7,0xf4a7,{1,1,1,1,2,2,1}}, + {0xf4a8,0xf4a9,{1,1,1,1,2,1,1}}, + {0xf4aa,0xf4aa,{1,1,1,1,2,2,1}}, + {0xf4ab,0xf4ac,{1,1,1,1,2,1,1}}, + {0xf4ad,0xf4ad,{1,1,1,1,2,2,1}}, + {0xf4ae,0xf4ae,{1,1,1,1,2,1,1}}, + {0xf4af,0xf4af,{1,1,1,1,2,2,1}}, + {0xf4b0,0xf4b2,{1,1,1,1,2,1,1}}, + {0xf4b3,0xf4b4,{1,1,1,1,2,2,1}}, + {0xf4b5,0xf4b6,{1,1,1,1,2,1,1}}, + {0xf4b7,0xf4b7,{1,1,1,1,2,2,1}}, + {0xf4b8,0xf4b9,{1,1,1,1,2,1,1}}, + {0xf4ba,0xf4bd,{1,1,1,1,2,2,1}}, + {0xf4be,0xf4bf,{1,1,1,1,2,1,1}}, + {0xf4c0,0xf4c1,{1,1,1,1,2,2,1}}, + {0xf4c2,0xf4c2,{1,1,1,1,2,1,1}}, + {0xf4c3,0xf4c3,{1,1,1,1,2,2,1}}, + {0xf4c4,0xf4c7,{1,1,1,1,2,1,1}}, + {0xf4c8,0xf4c8,{1,1,1,1,2,2,1}}, + {0xf4c9,0xf4cd,{1,1,1,1,2,1,1}}, + {0xf4ce,0xf4cf,{1,1,1,1,2,2,1}}, + {0xf4d0,0xf4d1,{1,1,1,1,2,1,1}}, + {0xf4d2,0xf4d2,{1,1,1,1,2,2,1}}, + {0xf4d3,0xf4e1,{1,1,1,1,2,1,1}}, + {0xf4e2,0xf4e2,{1,1,1,1,2,2,1}}, + {0xf4e3,0xf4e4,{1,1,1,1,2,1,1}}, + {0xf4e5,0xf4e5,{1,1,1,1,2,2,1}}, + {0xf4e6,0xf4e6,{1,1,1,1,2,1,1}}, + {0xf4e7,0xf4e9,{1,1,1,1,2,2,1}}, + {0xf4ea,0xf4f2,{1,1,1,1,2,1,1}}, + {0xf4f3,0xf4f3,{1,1,1,1,2,2,1}}, + {0xf4f4,0xf521,{1,1,1,1,2,1,1}}, + {0xf522,0xf523,{1,1,1,1,2,2,1}}, + {0xf524,0xf524,{1,1,1,1,2,1,1}}, + {0xf525,0xf526,{1,1,1,1,2,2,1}}, + {0xf527,0xf529,{1,1,1,1,2,1,1}}, + {0xf52a,0xf52a,{1,1,1,1,2,2,1}}, + {0xf52b,0xf539,{1,1,1,1,2,1,1}}, + {0xf53a,0xf53b,{1,1,1,1,2,2,1}}, + {0xf53c,0xf53c,{1,1,1,1,2,1,1}}, + {0xf53d,0xf53d,{1,1,1,1,2,2,1}}, + {0xf53e,0xf54d,{1,1,1,1,2,1,1}}, + {0xf54e,0xf54e,{1,1,1,1,2,2,1}}, + {0xf54f,0xf552,{1,1,1,1,2,1,1}}, + {0xf553,0xf553,{1,1,1,1,2,2,1}}, + {0xf554,0xf555,{1,1,1,1,2,1,1}}, + {0xf556,0xf556,{1,1,1,1,2,2,1}}, + {0xf557,0xf558,{1,1,1,1,2,1,1}}, + {0xf559,0xf55a,{1,1,1,1,2,2,1}}, + {0xf55b,0xf55d,{1,1,1,1,2,1,1}}, + {0xf55e,0xf55e,{1,1,1,1,2,2,1}}, + {0xf55f,0xf564,{1,1,1,1,2,1,1}}, + {0xf565,0xf565,{1,1,1,1,2,2,1}}, + {0xf566,0xf56a,{1,1,1,1,2,1,1}}, + {0xf56b,0xf56b,{1,1,1,1,2,2,1}}, + {0xf56c,0xf571,{1,1,1,1,2,1,1}}, + {0xf572,0xf572,{1,1,1,1,2,2,1}}, + {0xf573,0xf6af,{1,1,1,1,2,1,1}}, + {0xf6b0,0xf6b0,{1,1,1,1,2,2,1}}, + {0xf6b1,0xf7e4,{1,1,1,1,2,1,2}}, + {0xf7e5,0xf7e6,{1,1,1,1,2,2,2}}, + {0xf7e7,0xf7e7,{1,1,1,1,2,1,2}}, + {0xf7e8,0xf7e8,{1,1,1,1,2,2,2}}, + {0xf7e9,0xf7e9,{1,1,1,1,2,1,2}}, + {0xf7ea,0xf7eb,{1,1,1,1,2,2,2}}, + {0xf7ec,0xf7ec,{1,1,1,1,2,1,2}}, + {0xf7ed,0xf7ee,{1,1,1,1,2,2,2}}, + {0xf7ef,0xf848,{1,1,1,1,2,1,2}}, // EA ambiguous to f8ff + {0xf849,0xf8ef,{1,1,1,1,2,1,1}}, + {0xf900,0xfa6d,{2,2,2,2,2,2,2}}, // CJK COMPATIBILITY IDEOGRAPH + {0xfa70,0xfad9,{2,2,2,2,2,2,2}}, // CJK COMPATIBILITY IDEOGRAPH + {0xfe10,0xfe19,{2,2,2,2,2,2,2}}, // Presentation forms, small signs + {0xfe30,0xfe52,{2,2,2,2,2,2,2}}, + {0xfe54,0xfe66,{2,2,2,2,2,2,2}}, + {0xfe68,0xfe6b,{2,2,2,2,2,2,2}}, // end of small signs + {0xff01,0xff60,{2,2,2,2,2,2,2}}, // fullwidth + {0xff64,0xff64,{1,1,1,1,1,2,1}}, + {0xffe0,0xffe6,{2,2,2,2,2,2,2}}, // fullwidth + {0xfffd,0xfffd,{1,1,1,1,2,1,1}}, // EA ambiguous + // tr11 has all unassigned in these planes as wide chars + {0x20000,0x2a6d6,{2,2,2,2,2,2,2}}, // Supplementary Ideographic Plane + {0x2f800,0x2fa1d,{2,2,2,2,2,2,2}}, // to 2fffd + {0x30000,0x3fffd,{2,2,2,2,2,2,2}}, // Tertiary Ideographic Plane + {0xf0000,0xffffd,{1,1,1,1,2,1,1}}, // EA ambiguous + {0x100000,0x10fffd,{1,1,1,1,2,1,1}}, // EA ambiguous +}; + +#if defined(__APPLE__) || defined(Win32) || defined(_AIX) +/* ------------------- iswalpha -------------------- */ +static const struct interval table_walpha[] = { + { 0x41, 0x5a }, + { 0x61, 0x7a }, + { 0xaa, 0xaa }, + { 0xb5, 0xb5 }, + { 0xba, 0xba }, + { 0xc0, 0xd6 }, + { 0xd8, 0xf6 }, + { 0xf8, 0x220 }, + { 0x222, 0x233 }, + { 0x250, 0x2ad }, + { 0x2b0, 0x2b8 }, + { 0x2bb, 0x2c1 }, + { 0x2d0, 0x2d1 }, + { 0x2e0, 0x2e4 }, + { 0x2ee, 0x2ee }, + { 0x345, 0x345 }, + { 0x37a, 0x37a }, + { 0x386, 0x386 }, + { 0x388, 0x38a }, + { 0x38c, 0x38c }, + { 0x38e, 0x3a1 }, + { 0x3a3, 0x3ce }, + { 0x3d0, 0x3f5 }, + { 0x400, 0x481 }, + { 0x48a, 0x4ce }, + { 0x4d0, 0x4f5 }, + { 0x4f8, 0x4f9 }, + { 0x500, 0x50f }, + { 0x531, 0x556 }, + { 0x559, 0x559 }, + { 0x561, 0x587 }, + { 0x5d0, 0x5ea }, + { 0x5f0, 0x5f2 }, + { 0x621, 0x63a }, + { 0x640, 0x64a }, + { 0x660, 0x669 }, + { 0x66e, 0x66f }, + { 0x671, 0x6d3 }, + { 0x6d5, 0x6d5 }, + { 0x6e5, 0x6e6 }, + { 0x6f0, 0x6fc }, + { 0x710, 0x710 }, + { 0x712, 0x72c }, + { 0x780, 0x7a5 }, + { 0x7b1, 0x7b1 }, + { 0x905, 0x939 }, + { 0x93d, 0x93d }, + { 0x950, 0x950 }, + { 0x958, 0x961 }, + { 0x966, 0x96f }, + { 0x985, 0x98c }, + { 0x98f, 0x990 }, + { 0x993, 0x9a8 }, + { 0x9aa, 0x9b0 }, + { 0x9b2, 0x9b2 }, + { 0x9b6, 0x9b9 }, + { 0x9dc, 0x9dd }, + { 0x9df, 0x9e1 }, + { 0x9e6, 0x9f1 }, + { 0xa05, 0xa0a }, + { 0xa0f, 0xa10 }, + { 0xa13, 0xa28 }, + { 0xa2a, 0xa30 }, + { 0xa32, 0xa33 }, + { 0xa35, 0xa36 }, + { 0xa38, 0xa39 }, + { 0xa59, 0xa5c }, + { 0xa5e, 0xa5e }, + { 0xa66, 0xa6f }, + { 0xa72, 0xa74 }, + { 0xa85, 0xa8b }, + { 0xa8d, 0xa8d }, + { 0xa8f, 0xa91 }, + { 0xa93, 0xaa8 }, + { 0xaaa, 0xab0 }, + { 0xab2, 0xab3 }, + { 0xab5, 0xab9 }, + { 0xabd, 0xabd }, + { 0xad0, 0xad0 }, + { 0xae0, 0xae0 }, + { 0xae6, 0xaef }, + { 0xb05, 0xb0c }, + { 0xb0f, 0xb10 }, + { 0xb13, 0xb28 }, + { 0xb2a, 0xb30 }, + { 0xb32, 0xb33 }, + { 0xb36, 0xb39 }, + { 0xb3d, 0xb3d }, + { 0xb5c, 0xb5d }, + { 0xb5f, 0xb61 }, + { 0xb66, 0xb6f }, + { 0xb83, 0xb83 }, + { 0xb85, 0xb8a }, + { 0xb8e, 0xb90 }, + { 0xb92, 0xb95 }, + { 0xb99, 0xb9a }, + { 0xb9c, 0xb9c }, + { 0xb9e, 0xb9f }, + { 0xba3, 0xba4 }, + { 0xba8, 0xbaa }, + { 0xbae, 0xbb5 }, + { 0xbb7, 0xbb9 }, + { 0xbe7, 0xbef }, + { 0xc05, 0xc0c }, + { 0xc0e, 0xc10 }, + { 0xc12, 0xc28 }, + { 0xc2a, 0xc33 }, + { 0xc35, 0xc39 }, + { 0xc60, 0xc61 }, + { 0xc66, 0xc6f }, + { 0xc85, 0xc8c }, + { 0xc8e, 0xc90 }, + { 0xc92, 0xca8 }, + { 0xcaa, 0xcb3 }, + { 0xcb5, 0xcb9 }, + { 0xcde, 0xcde }, + { 0xce0, 0xce1 }, + { 0xce6, 0xcef }, + { 0xd05, 0xd0c }, + { 0xd0e, 0xd10 }, + { 0xd12, 0xd28 }, + { 0xd2a, 0xd39 }, + { 0xd60, 0xd61 }, + { 0xd66, 0xd6f }, + { 0xd85, 0xd96 }, + { 0xd9a, 0xdb1 }, + { 0xdb3, 0xdbb }, + { 0xdbd, 0xdbd }, + { 0xdc0, 0xdc6 }, + { 0xe01, 0xe2e }, + { 0xe30, 0xe3a }, + { 0xe40, 0xe45 }, + { 0xe47, 0xe4e }, + { 0xe50, 0xe59 }, + { 0xe81, 0xe82 }, + { 0xe84, 0xe84 }, + { 0xe87, 0xe88 }, + { 0xe8a, 0xe8a }, + { 0xe8d, 0xe8d }, + { 0xe94, 0xe97 }, + { 0xe99, 0xe9f }, + { 0xea1, 0xea3 }, + { 0xea5, 0xea5 }, + { 0xea7, 0xea7 }, + { 0xeaa, 0xeab }, + { 0xead, 0xeb0 }, + { 0xeb2, 0xeb3 }, + { 0xebd, 0xebd }, + { 0xec0, 0xec4 }, + { 0xec6, 0xec6 }, + { 0xed0, 0xed9 }, + { 0xedc, 0xedd }, + { 0xf00, 0xf00 }, + { 0xf20, 0xf29 }, + { 0xf40, 0xf47 }, + { 0xf49, 0xf6a }, + { 0xf88, 0xf8b }, + { 0x1000, 0x1021 }, + { 0x1023, 0x1027 }, + { 0x1029, 0x102a }, + { 0x1040, 0x1049 }, + { 0x1050, 0x1055 }, + { 0x10a0, 0x10c5 }, + { 0x10d0, 0x10f8 }, + { 0x1100, 0x1159 }, + { 0x115f, 0x11a2 }, + { 0x11a8, 0x11f9 }, + { 0x1200, 0x1206 }, + { 0x1208, 0x1246 }, + { 0x1248, 0x1248 }, + { 0x124a, 0x124d }, + { 0x1250, 0x1256 }, + { 0x1258, 0x1258 }, + { 0x125a, 0x125d }, + { 0x1260, 0x1286 }, + { 0x1288, 0x1288 }, + { 0x128a, 0x128d }, + { 0x1290, 0x12ae }, + { 0x12b0, 0x12b0 }, + { 0x12b2, 0x12b5 }, + { 0x12b8, 0x12be }, + { 0x12c0, 0x12c0 }, + { 0x12c2, 0x12c5 }, + { 0x12c8, 0x12ce }, + { 0x12d0, 0x12d6 }, + { 0x12d8, 0x12ee }, + { 0x12f0, 0x130e }, + { 0x1310, 0x1310 }, + { 0x1312, 0x1315 }, + { 0x1318, 0x131e }, + { 0x1320, 0x1346 }, + { 0x1348, 0x135a }, + { 0x1369, 0x1371 }, + { 0x13a0, 0x13f4 }, + { 0x1401, 0x166c }, + { 0x166f, 0x1676 }, + { 0x1681, 0x169a }, + { 0x16a0, 0x16ea }, + { 0x16ee, 0x16f0 }, + { 0x1700, 0x170c }, + { 0x170e, 0x1711 }, + { 0x1720, 0x1731 }, + { 0x1740, 0x1751 }, + { 0x1760, 0x176c }, + { 0x176e, 0x1770 }, + { 0x1780, 0x17b3 }, + { 0x17d7, 0x17d7 }, + { 0x17dc, 0x17dc }, + { 0x17e0, 0x17e9 }, + { 0x1810, 0x1819 }, + { 0x1820, 0x1877 }, + { 0x1880, 0x18a8 }, + { 0x1e00, 0x1e9b }, + { 0x1ea0, 0x1ef9 }, + { 0x1f00, 0x1f15 }, + { 0x1f18, 0x1f1d }, + { 0x1f20, 0x1f45 }, + { 0x1f48, 0x1f4d }, + { 0x1f50, 0x1f57 }, + { 0x1f59, 0x1f59 }, + { 0x1f5b, 0x1f5b }, + { 0x1f5d, 0x1f5d }, + { 0x1f5f, 0x1f7d }, + { 0x1f80, 0x1fb4 }, + { 0x1fb6, 0x1fbc }, + { 0x1fbe, 0x1fbe }, + { 0x1fc2, 0x1fc4 }, + { 0x1fc6, 0x1fcc }, + { 0x1fd0, 0x1fd3 }, + { 0x1fd6, 0x1fdb }, + { 0x1fe0, 0x1fec }, + { 0x1ff2, 0x1ff4 }, + { 0x1ff6, 0x1ffc }, + { 0x2071, 0x2071 }, + { 0x207f, 0x207f }, + { 0x2102, 0x2102 }, + { 0x2107, 0x2107 }, + { 0x210a, 0x2113 }, + { 0x2115, 0x2115 }, + { 0x2119, 0x211d }, + { 0x2124, 0x2124 }, + { 0x2126, 0x2126 }, + { 0x2128, 0x212d }, + { 0x212f, 0x2131 }, + { 0x2133, 0x2139 }, + { 0x213d, 0x213f }, + { 0x2145, 0x2149 }, + { 0x2160, 0x2183 }, + { 0x249c, 0x24e9 }, + { 0x3005, 0x3007 }, + { 0x3021, 0x3029 }, + { 0x3031, 0x3035 }, + { 0x3038, 0x303c }, + { 0x3041, 0x3096 }, + { 0x309d, 0x309f }, + { 0x30a1, 0x30fa }, + { 0x30fc, 0x30ff }, + { 0x3105, 0x312c }, + { 0x3131, 0x318e }, + { 0x31a0, 0x31b7 }, + { 0x31f0, 0x31ff }, + { 0x3400, 0x4db5 }, + { 0x4e00, 0x9fa5 }, + { 0xa000, 0xa48c }, + { 0xac00, 0xd7a3 }, + { 0xf900, 0xfa2d }, + { 0xfa30, 0xfa6a }, + { 0xfb00, 0xfb06 }, + { 0xfb13, 0xfb17 }, + { 0xfb1d, 0xfb1d }, + { 0xfb1f, 0xfb28 }, + { 0xfb2a, 0xfb36 }, + { 0xfb38, 0xfb3c }, + { 0xfb3e, 0xfb3e }, + { 0xfb40, 0xfb41 }, + { 0xfb43, 0xfb44 }, + { 0xfb46, 0xfbb1 }, + { 0xfbd3, 0xfd3d }, + { 0xfd50, 0xfd8f }, + { 0xfd92, 0xfdc7 }, + { 0xfdf0, 0xfdfb }, + { 0xfe70, 0xfe74 }, + { 0xfe76, 0xfefc }, + { 0xff10, 0xff19 }, + { 0xff21, 0xff3a }, + { 0xff41, 0xff5a }, + { 0xff66, 0xffbe }, + { 0xffc2, 0xffc7 }, + { 0xffca, 0xffcf }, + { 0xffd2, 0xffd7 }, + { 0xffda, 0xffdc }, + { 0x10300, 0x1031e }, + { 0x10330, 0x1034a }, + { 0x10400, 0x10425 }, + { 0x10428, 0x1044d }, + { 0x1d400, 0x1d454 }, + { 0x1d456, 0x1d49c }, + { 0x1d49e, 0x1d49f }, + { 0x1d4a2, 0x1d4a2 }, + { 0x1d4a5, 0x1d4a6 }, + { 0x1d4a9, 0x1d4ac }, + { 0x1d4ae, 0x1d4b9 }, + { 0x1d4bb, 0x1d4bb }, + { 0x1d4bd, 0x1d4c0 }, + { 0x1d4c2, 0x1d4c3 }, + { 0x1d4c5, 0x1d505 }, + { 0x1d507, 0x1d50a }, + { 0x1d50d, 0x1d514 }, + { 0x1d516, 0x1d51c }, + { 0x1d51e, 0x1d539 }, + { 0x1d53b, 0x1d53e }, + { 0x1d540, 0x1d544 }, + { 0x1d546, 0x1d546 }, + { 0x1d54a, 0x1d550 }, + { 0x1d552, 0x1d6a3 }, + { 0x1d6a8, 0x1d6c0 }, + { 0x1d6c2, 0x1d6da }, + { 0x1d6dc, 0x1d6fa }, + { 0x1d6fc, 0x1d714 }, + { 0x1d716, 0x1d734 }, + { 0x1d736, 0x1d74e }, + { 0x1d750, 0x1d76e }, + { 0x1d770, 0x1d788 }, + { 0x1d78a, 0x1d7a8 }, + { 0x1d7aa, 0x1d7c2 }, + { 0x1d7c4, 0x1d7c9 }, + { 0x1d7ce, 0x1d7ff }, + { 0x20000, 0x2a6d6 }, + { 0x2f800, 0x2fa1d } +}; +static const int table_walpha_count = + (sizeof(table_walpha)/sizeof(struct interval)); + +/* ------------------- iswblank -------------------- */ +static const struct interval table_wblank[] = { + { 0x9, 0x9 }, + { 0x20, 0x20 }, + { 0xa0, 0xa0 }, /* non-breaking space */ + { 0x1680, 0x1680 }, /* ogham space mark */ + { 0x2000, 0x2006 }, /* why not figure space, 2007? Not in glibc */ + { 0x2008, 0x200b }, +// { 0x202f, 0x202f }, /* narrow no-break space, not in glibc */ + { 0x205f, 0x205f }, /* medium mathematical space */ + { 0x3000, 0x3000 } /* (CJK) ideographic space */ +}; +static const int table_wblank_count = + (sizeof(table_wblank)/sizeof(struct interval)); + +/* ------------------- iswcntrl -------------------- */ +static const struct interval table_wcntrl[] = { + { 0x0, 0x1f }, + { 0x7f, 0x9f }, + { 0x2028, 0x2029 } +}; +static const int table_wcntrl_count = + (sizeof(table_wcntrl)/sizeof(struct interval)); + +/* ------------------- iswdigit -------------------- */ +static const struct interval table_wdigit[] = { + { 0x30, 0x39 } +}; +static const int table_wdigit_count = + (sizeof(table_wdigit)/sizeof(struct interval)); + +/* ------------------- iswgraph -------------------- */ +static const struct interval table_wgraph[] = { + { 0x21, 0x7e }, + { 0xa0, 0x220 }, + { 0x222, 0x233 }, + { 0x250, 0x2ad }, + { 0x2b0, 0x2ee }, + { 0x300, 0x34f }, + { 0x360, 0x36f }, + { 0x374, 0x375 }, + { 0x37a, 0x37a }, + { 0x37e, 0x37e }, + { 0x384, 0x38a }, + { 0x38c, 0x38c }, + { 0x38e, 0x3a1 }, + { 0x3a3, 0x3ce }, + { 0x3d0, 0x3f6 }, + { 0x400, 0x486 }, + { 0x488, 0x4ce }, + { 0x4d0, 0x4f5 }, + { 0x4f8, 0x4f9 }, + { 0x500, 0x50f }, + { 0x531, 0x556 }, + { 0x559, 0x55f }, + { 0x561, 0x587 }, + { 0x589, 0x58a }, + { 0x591, 0x5a1 }, + { 0x5a3, 0x5b9 }, + { 0x5bb, 0x5c4 }, + { 0x5d0, 0x5ea }, + { 0x5f0, 0x5f4 }, + { 0x60c, 0x60c }, + { 0x61b, 0x61b }, + { 0x61f, 0x61f }, + { 0x621, 0x63a }, + { 0x640, 0x655 }, + { 0x660, 0x6ed }, + { 0x6f0, 0x6fe }, + { 0x700, 0x70d }, + { 0x70f, 0x72c }, + { 0x730, 0x74a }, + { 0x780, 0x7b1 }, + { 0x901, 0x903 }, + { 0x905, 0x939 }, + { 0x93c, 0x94d }, + { 0x950, 0x954 }, + { 0x958, 0x970 }, + { 0x981, 0x983 }, + { 0x985, 0x98c }, + { 0x98f, 0x990 }, + { 0x993, 0x9a8 }, + { 0x9aa, 0x9b0 }, + { 0x9b2, 0x9b2 }, + { 0x9b6, 0x9b9 }, + { 0x9bc, 0x9bc }, + { 0x9be, 0x9c4 }, + { 0x9c7, 0x9c8 }, + { 0x9cb, 0x9cd }, + { 0x9d7, 0x9d7 }, + { 0x9dc, 0x9dd }, + { 0x9df, 0x9e3 }, + { 0x9e6, 0x9fa }, + { 0xa02, 0xa02 }, + { 0xa05, 0xa0a }, + { 0xa0f, 0xa10 }, + { 0xa13, 0xa28 }, + { 0xa2a, 0xa30 }, + { 0xa32, 0xa33 }, + { 0xa35, 0xa36 }, + { 0xa38, 0xa39 }, + { 0xa3c, 0xa3c }, + { 0xa3e, 0xa42 }, + { 0xa47, 0xa48 }, + { 0xa4b, 0xa4d }, + { 0xa59, 0xa5c }, + { 0xa5e, 0xa5e }, + { 0xa66, 0xa74 }, + { 0xa81, 0xa83 }, + { 0xa85, 0xa8b }, + { 0xa8d, 0xa8d }, + { 0xa8f, 0xa91 }, + { 0xa93, 0xaa8 }, + { 0xaaa, 0xab0 }, + { 0xab2, 0xab3 }, + { 0xab5, 0xab9 }, + { 0xabc, 0xac5 }, + { 0xac7, 0xac9 }, + { 0xacb, 0xacd }, + { 0xad0, 0xad0 }, + { 0xae0, 0xae0 }, + { 0xae6, 0xaef }, + { 0xb01, 0xb03 }, + { 0xb05, 0xb0c }, + { 0xb0f, 0xb10 }, + { 0xb13, 0xb28 }, + { 0xb2a, 0xb30 }, + { 0xb32, 0xb33 }, + { 0xb36, 0xb39 }, + { 0xb3c, 0xb43 }, + { 0xb47, 0xb48 }, + { 0xb4b, 0xb4d }, + { 0xb56, 0xb57 }, + { 0xb5c, 0xb5d }, + { 0xb5f, 0xb61 }, + { 0xb66, 0xb70 }, + { 0xb82, 0xb83 }, + { 0xb85, 0xb8a }, + { 0xb8e, 0xb90 }, + { 0xb92, 0xb95 }, + { 0xb99, 0xb9a }, + { 0xb9c, 0xb9c }, + { 0xb9e, 0xb9f }, + { 0xba3, 0xba4 }, + { 0xba8, 0xbaa }, + { 0xbae, 0xbb5 }, + { 0xbb7, 0xbb9 }, + { 0xbbe, 0xbc2 }, + { 0xbc6, 0xbc8 }, + { 0xbca, 0xbcd }, + { 0xbd7, 0xbd7 }, + { 0xbe7, 0xbf2 }, + { 0xc01, 0xc03 }, + { 0xc05, 0xc0c }, + { 0xc0e, 0xc10 }, + { 0xc12, 0xc28 }, + { 0xc2a, 0xc33 }, + { 0xc35, 0xc39 }, + { 0xc3e, 0xc44 }, + { 0xc46, 0xc48 }, + { 0xc4a, 0xc4d }, + { 0xc55, 0xc56 }, + { 0xc60, 0xc61 }, + { 0xc66, 0xc6f }, + { 0xc82, 0xc83 }, + { 0xc85, 0xc8c }, + { 0xc8e, 0xc90 }, + { 0xc92, 0xca8 }, + { 0xcaa, 0xcb3 }, + { 0xcb5, 0xcb9 }, + { 0xcbe, 0xcc4 }, + { 0xcc6, 0xcc8 }, + { 0xcca, 0xccd }, + { 0xcd5, 0xcd6 }, + { 0xcde, 0xcde }, + { 0xce0, 0xce1 }, + { 0xce6, 0xcef }, + { 0xd02, 0xd03 }, + { 0xd05, 0xd0c }, + { 0xd0e, 0xd10 }, + { 0xd12, 0xd28 }, + { 0xd2a, 0xd39 }, + { 0xd3e, 0xd43 }, + { 0xd46, 0xd48 }, + { 0xd4a, 0xd4d }, + { 0xd57, 0xd57 }, + { 0xd60, 0xd61 }, + { 0xd66, 0xd6f }, + { 0xd82, 0xd83 }, + { 0xd85, 0xd96 }, + { 0xd9a, 0xdb1 }, + { 0xdb3, 0xdbb }, + { 0xdbd, 0xdbd }, + { 0xdc0, 0xdc6 }, + { 0xdca, 0xdca }, + { 0xdcf, 0xdd4 }, + { 0xdd6, 0xdd6 }, + { 0xdd8, 0xddf }, + { 0xdf2, 0xdf4 }, + { 0xe01, 0xe3a }, + { 0xe3f, 0xe5b }, + { 0xe81, 0xe82 }, + { 0xe84, 0xe84 }, + { 0xe87, 0xe88 }, + { 0xe8a, 0xe8a }, + { 0xe8d, 0xe8d }, + { 0xe94, 0xe97 }, + { 0xe99, 0xe9f }, + { 0xea1, 0xea3 }, + { 0xea5, 0xea5 }, + { 0xea7, 0xea7 }, + { 0xeaa, 0xeab }, + { 0xead, 0xeb9 }, + { 0xebb, 0xebd }, + { 0xec0, 0xec4 }, + { 0xec6, 0xec6 }, + { 0xec8, 0xecd }, + { 0xed0, 0xed9 }, + { 0xedc, 0xedd }, + { 0xf00, 0xf47 }, + { 0xf49, 0xf6a }, + { 0xf71, 0xf8b }, + { 0xf90, 0xf97 }, + { 0xf99, 0xfbc }, + { 0xfbe, 0xfcc }, + { 0xfcf, 0xfcf }, + { 0x1000, 0x1021 }, + { 0x1023, 0x1027 }, + { 0x1029, 0x102a }, + { 0x102c, 0x1032 }, + { 0x1036, 0x1039 }, + { 0x1040, 0x1059 }, + { 0x10a0, 0x10c5 }, + { 0x10d0, 0x10f8 }, + { 0x10fb, 0x10fb }, + { 0x1100, 0x1159 }, + { 0x115f, 0x11a2 }, + { 0x11a8, 0x11f9 }, + { 0x1200, 0x1206 }, + { 0x1208, 0x1246 }, + { 0x1248, 0x1248 }, + { 0x124a, 0x124d }, + { 0x1250, 0x1256 }, + { 0x1258, 0x1258 }, + { 0x125a, 0x125d }, + { 0x1260, 0x1286 }, + { 0x1288, 0x1288 }, + { 0x128a, 0x128d }, + { 0x1290, 0x12ae }, + { 0x12b0, 0x12b0 }, + { 0x12b2, 0x12b5 }, + { 0x12b8, 0x12be }, + { 0x12c0, 0x12c0 }, + { 0x12c2, 0x12c5 }, + { 0x12c8, 0x12ce }, + { 0x12d0, 0x12d6 }, + { 0x12d8, 0x12ee }, + { 0x12f0, 0x130e }, + { 0x1310, 0x1310 }, + { 0x1312, 0x1315 }, + { 0x1318, 0x131e }, + { 0x1320, 0x1346 }, + { 0x1348, 0x135a }, + { 0x1361, 0x137c }, + { 0x13a0, 0x13f4 }, + { 0x1401, 0x1676 }, + { 0x1681, 0x169c }, + { 0x16a0, 0x16f0 }, + { 0x1700, 0x170c }, + { 0x170e, 0x1714 }, + { 0x1720, 0x1736 }, + { 0x1740, 0x1753 }, + { 0x1760, 0x176c }, + { 0x176e, 0x1770 }, + { 0x1772, 0x1773 }, + { 0x1780, 0x17dc }, + { 0x17e0, 0x17e9 }, + { 0x1800, 0x180e }, + { 0x1810, 0x1819 }, + { 0x1820, 0x1877 }, + { 0x1880, 0x18a9 }, + { 0x1e00, 0x1e9b }, + { 0x1ea0, 0x1ef9 }, + { 0x1f00, 0x1f15 }, + { 0x1f18, 0x1f1d }, + { 0x1f20, 0x1f45 }, + { 0x1f48, 0x1f4d }, + { 0x1f50, 0x1f57 }, + { 0x1f59, 0x1f59 }, + { 0x1f5b, 0x1f5b }, + { 0x1f5d, 0x1f5d }, + { 0x1f5f, 0x1f7d }, + { 0x1f80, 0x1fb4 }, + { 0x1fb6, 0x1fc4 }, + { 0x1fc6, 0x1fd3 }, + { 0x1fd6, 0x1fdb }, + { 0x1fdd, 0x1fef }, + { 0x1ff2, 0x1ff4 }, + { 0x1ff6, 0x1ffe }, + { 0x2007, 0x2007 }, + { 0x200c, 0x2027 }, + { 0x202a, 0x2052 }, + { 0x2057, 0x2057 }, + { 0x2060, 0x2063 }, + { 0x206a, 0x2071 }, + { 0x2074, 0x208e }, + { 0x20a0, 0x20b1 }, + { 0x20d0, 0x20ea }, + { 0x2100, 0x213a }, + { 0x213d, 0x214b }, + { 0x2153, 0x2183 }, + { 0x2190, 0x23ce }, + { 0x2400, 0x2426 }, + { 0x2440, 0x244a }, + { 0x2460, 0x24fe }, + { 0x2500, 0x2613 }, + { 0x2616, 0x2617 }, + { 0x2619, 0x267d }, + { 0x2680, 0x2689 }, + { 0x2701, 0x2704 }, + { 0x2706, 0x2709 }, + { 0x270c, 0x2727 }, + { 0x2729, 0x274b }, + { 0x274d, 0x274d }, + { 0x274f, 0x2752 }, + { 0x2756, 0x2756 }, + { 0x2758, 0x275e }, + { 0x2761, 0x2794 }, + { 0x2798, 0x27af }, + { 0x27b1, 0x27be }, + { 0x27d0, 0x27eb }, + { 0x27f0, 0x2aff }, + { 0x2e80, 0x2e99 }, + { 0x2e9b, 0x2ef3 }, + { 0x2f00, 0x2fd5 }, + { 0x2ff0, 0x2ffb }, + { 0x3001, 0x303f }, + { 0x3041, 0x3096 }, + { 0x3099, 0x30ff }, + { 0x3105, 0x312c }, + { 0x3131, 0x318e }, + { 0x3190, 0x31b7 }, + { 0x31f0, 0x321c }, + { 0x3220, 0x3243 }, + { 0x3251, 0x327b }, + { 0x327f, 0x32cb }, + { 0x32d0, 0x32fe }, + { 0x3300, 0x3376 }, + { 0x337b, 0x33dd }, + { 0x33e0, 0x33fe }, + { 0x3400, 0x4db5 }, + { 0x4e00, 0x9fa5 }, + { 0xa000, 0xa48c }, + { 0xa490, 0xa4c6 }, + { 0xac00, 0xd7a3 }, + { 0xe000, 0xfa2d }, + { 0xfa30, 0xfa6a }, + { 0xfb00, 0xfb06 }, + { 0xfb13, 0xfb17 }, + { 0xfb1d, 0xfb36 }, + { 0xfb38, 0xfb3c }, + { 0xfb3e, 0xfb3e }, + { 0xfb40, 0xfb41 }, + { 0xfb43, 0xfb44 }, + { 0xfb46, 0xfbb1 }, + { 0xfbd3, 0xfd3f }, + { 0xfd50, 0xfd8f }, + { 0xfd92, 0xfdc7 }, + { 0xfdf0, 0xfdfc }, + { 0xfe00, 0xfe0f }, + { 0xfe20, 0xfe23 }, + { 0xfe30, 0xfe46 }, + { 0xfe49, 0xfe52 }, + { 0xfe54, 0xfe66 }, + { 0xfe68, 0xfe6b }, + { 0xfe70, 0xfe74 }, + { 0xfe76, 0xfefc }, + { 0xfeff, 0xfeff }, + { 0xff01, 0xffbe }, + { 0xffc2, 0xffc7 }, + { 0xffca, 0xffcf }, + { 0xffd2, 0xffd7 }, + { 0xffda, 0xffdc }, + { 0xffe0, 0xffe6 }, + { 0xffe8, 0xffee }, + { 0xfff9, 0xfffd }, + { 0x10300, 0x1031e }, + { 0x10320, 0x10323 }, + { 0x10330, 0x1034a }, + { 0x10400, 0x10425 }, + { 0x10428, 0x1044d }, + { 0x1d000, 0x1d0f5 }, + { 0x1d100, 0x1d126 }, + { 0x1d12a, 0x1d1dd }, + { 0x1d400, 0x1d454 }, + { 0x1d456, 0x1d49c }, + { 0x1d49e, 0x1d49f }, + { 0x1d4a2, 0x1d4a2 }, + { 0x1d4a5, 0x1d4a6 }, + { 0x1d4a9, 0x1d4ac }, + { 0x1d4ae, 0x1d4b9 }, + { 0x1d4bb, 0x1d4bb }, + { 0x1d4bd, 0x1d4c0 }, + { 0x1d4c2, 0x1d4c3 }, + { 0x1d4c5, 0x1d505 }, + { 0x1d507, 0x1d50a }, + { 0x1d50d, 0x1d514 }, + { 0x1d516, 0x1d51c }, + { 0x1d51e, 0x1d539 }, + { 0x1d53b, 0x1d53e }, + { 0x1d540, 0x1d544 }, + { 0x1d546, 0x1d546 }, + { 0x1d54a, 0x1d550 }, + { 0x1d552, 0x1d6a3 }, + { 0x1d6a8, 0x1d7c9 }, + { 0x1d7ce, 0x1d7ff }, + { 0x20000, 0x2a6d6 }, + { 0x2f800, 0x2fa1d }, + { 0xe0001, 0xe0001 }, + { 0xe0020, 0xe007f }, + { 0xf0000, 0xffffd }, + { 0x100000, 0x10fffd } +}; +static const int table_wgraph_count = + (sizeof(table_wgraph)/sizeof(struct interval)); + +/* ------------------- iswlower -------------------- */ +static const struct interval table_wlower[] = { + { 0x61, 0x7a }, + { 0xb5, 0xb5 }, + { 0xdf, 0xf6 }, + { 0xf8, 0xff }, + { 0x101, 0x101 }, + { 0x103, 0x103 }, + { 0x105, 0x105 }, + { 0x107, 0x107 }, + { 0x109, 0x109 }, + { 0x10b, 0x10b }, + { 0x10d, 0x10d }, + { 0x10f, 0x10f }, + { 0x111, 0x111 }, + { 0x113, 0x113 }, + { 0x115, 0x115 }, + { 0x117, 0x117 }, + { 0x119, 0x119 }, + { 0x11b, 0x11b }, + { 0x11d, 0x11d }, + { 0x11f, 0x11f }, + { 0x121, 0x121 }, + { 0x123, 0x123 }, + { 0x125, 0x125 }, + { 0x127, 0x127 }, + { 0x129, 0x129 }, + { 0x12b, 0x12b }, + { 0x12d, 0x12d }, + { 0x12f, 0x12f }, + { 0x131, 0x131 }, + { 0x133, 0x133 }, + { 0x135, 0x135 }, + { 0x137, 0x137 }, + { 0x13a, 0x13a }, + { 0x13c, 0x13c }, + { 0x13e, 0x13e }, + { 0x140, 0x140 }, + { 0x142, 0x142 }, + { 0x144, 0x144 }, + { 0x146, 0x146 }, + { 0x148, 0x148 }, + { 0x14b, 0x14b }, + { 0x14d, 0x14d }, + { 0x14f, 0x14f }, + { 0x151, 0x151 }, + { 0x153, 0x153 }, + { 0x155, 0x155 }, + { 0x157, 0x157 }, + { 0x159, 0x159 }, + { 0x15b, 0x15b }, + { 0x15d, 0x15d }, + { 0x15f, 0x15f }, + { 0x161, 0x161 }, + { 0x163, 0x163 }, + { 0x165, 0x165 }, + { 0x167, 0x167 }, + { 0x169, 0x169 }, + { 0x16b, 0x16b }, + { 0x16d, 0x16d }, + { 0x16f, 0x16f }, + { 0x171, 0x171 }, + { 0x173, 0x173 }, + { 0x175, 0x175 }, + { 0x177, 0x177 }, + { 0x17a, 0x17a }, + { 0x17c, 0x17c }, + { 0x17e, 0x17f }, + { 0x183, 0x183 }, + { 0x185, 0x185 }, + { 0x188, 0x188 }, + { 0x18c, 0x18c }, + { 0x192, 0x192 }, + { 0x195, 0x195 }, + { 0x199, 0x199 }, + { 0x19e, 0x19e }, + { 0x1a1, 0x1a1 }, + { 0x1a3, 0x1a3 }, + { 0x1a5, 0x1a5 }, + { 0x1a8, 0x1a8 }, + { 0x1ad, 0x1ad }, + { 0x1b0, 0x1b0 }, + { 0x1b4, 0x1b4 }, + { 0x1b6, 0x1b6 }, + { 0x1b9, 0x1b9 }, + { 0x1bd, 0x1bd }, + { 0x1bf, 0x1bf }, + { 0x1c5, 0x1c6 }, + { 0x1c8, 0x1c9 }, + { 0x1cb, 0x1cc }, + { 0x1ce, 0x1ce }, + { 0x1d0, 0x1d0 }, + { 0x1d2, 0x1d2 }, + { 0x1d4, 0x1d4 }, + { 0x1d6, 0x1d6 }, + { 0x1d8, 0x1d8 }, + { 0x1da, 0x1da }, + { 0x1dc, 0x1dd }, + { 0x1df, 0x1df }, + { 0x1e1, 0x1e1 }, + { 0x1e3, 0x1e3 }, + { 0x1e5, 0x1e5 }, + { 0x1e7, 0x1e7 }, + { 0x1e9, 0x1e9 }, + { 0x1eb, 0x1eb }, + { 0x1ed, 0x1ed }, + { 0x1ef, 0x1ef }, + { 0x1f2, 0x1f3 }, + { 0x1f5, 0x1f5 }, + { 0x1f9, 0x1f9 }, + { 0x1fb, 0x1fb }, + { 0x1fd, 0x1fd }, + { 0x1ff, 0x1ff }, + { 0x201, 0x201 }, + { 0x203, 0x203 }, + { 0x205, 0x205 }, + { 0x207, 0x207 }, + { 0x209, 0x209 }, + { 0x20b, 0x20b }, + { 0x20d, 0x20d }, + { 0x20f, 0x20f }, + { 0x211, 0x211 }, + { 0x213, 0x213 }, + { 0x215, 0x215 }, + { 0x217, 0x217 }, + { 0x219, 0x219 }, + { 0x21b, 0x21b }, + { 0x21d, 0x21d }, + { 0x21f, 0x21f }, + { 0x223, 0x223 }, + { 0x225, 0x225 }, + { 0x227, 0x227 }, + { 0x229, 0x229 }, + { 0x22b, 0x22b }, + { 0x22d, 0x22d }, + { 0x22f, 0x22f }, + { 0x231, 0x231 }, + { 0x233, 0x233 }, + { 0x253, 0x254 }, + { 0x256, 0x257 }, + { 0x259, 0x259 }, + { 0x25b, 0x25b }, + { 0x260, 0x260 }, + { 0x263, 0x263 }, + { 0x268, 0x269 }, + { 0x26f, 0x26f }, + { 0x272, 0x272 }, + { 0x275, 0x275 }, + { 0x280, 0x280 }, + { 0x283, 0x283 }, + { 0x288, 0x288 }, + { 0x28a, 0x28b }, + { 0x292, 0x292 }, + { 0x345, 0x345 }, + { 0x3ac, 0x3af }, + { 0x3b1, 0x3ce }, + { 0x3d0, 0x3d1 }, + { 0x3d5, 0x3d6 }, + { 0x3d9, 0x3d9 }, + { 0x3db, 0x3db }, + { 0x3dd, 0x3dd }, + { 0x3df, 0x3df }, + { 0x3e1, 0x3e1 }, + { 0x3e3, 0x3e3 }, + { 0x3e5, 0x3e5 }, + { 0x3e7, 0x3e7 }, + { 0x3e9, 0x3e9 }, + { 0x3eb, 0x3eb }, + { 0x3ed, 0x3ed }, + { 0x3ef, 0x3f2 }, + { 0x3f5, 0x3f5 }, + { 0x430, 0x45f }, + { 0x461, 0x461 }, + { 0x463, 0x463 }, + { 0x465, 0x465 }, + { 0x467, 0x467 }, + { 0x469, 0x469 }, + { 0x46b, 0x46b }, + { 0x46d, 0x46d }, + { 0x46f, 0x46f }, + { 0x471, 0x471 }, + { 0x473, 0x473 }, + { 0x475, 0x475 }, + { 0x477, 0x477 }, + { 0x479, 0x479 }, + { 0x47b, 0x47b }, + { 0x47d, 0x47d }, + { 0x47f, 0x47f }, + { 0x481, 0x481 }, + { 0x48b, 0x48b }, + { 0x48d, 0x48d }, + { 0x48f, 0x48f }, + { 0x491, 0x491 }, + { 0x493, 0x493 }, + { 0x495, 0x495 }, + { 0x497, 0x497 }, + { 0x499, 0x499 }, + { 0x49b, 0x49b }, + { 0x49d, 0x49d }, + { 0x49f, 0x49f }, + { 0x4a1, 0x4a1 }, + { 0x4a3, 0x4a3 }, + { 0x4a5, 0x4a5 }, + { 0x4a7, 0x4a7 }, + { 0x4a9, 0x4a9 }, + { 0x4ab, 0x4ab }, + { 0x4ad, 0x4ad }, + { 0x4af, 0x4af }, + { 0x4b1, 0x4b1 }, + { 0x4b3, 0x4b3 }, + { 0x4b5, 0x4b5 }, + { 0x4b7, 0x4b7 }, + { 0x4b9, 0x4b9 }, + { 0x4bb, 0x4bb }, + { 0x4bd, 0x4bd }, + { 0x4bf, 0x4bf }, + { 0x4c2, 0x4c2 }, + { 0x4c4, 0x4c4 }, + { 0x4c6, 0x4c6 }, + { 0x4c8, 0x4c8 }, + { 0x4ca, 0x4ca }, + { 0x4cc, 0x4cc }, + { 0x4ce, 0x4ce }, + { 0x4d1, 0x4d1 }, + { 0x4d3, 0x4d3 }, + { 0x4d5, 0x4d5 }, + { 0x4d7, 0x4d7 }, + { 0x4d9, 0x4d9 }, + { 0x4db, 0x4db }, + { 0x4dd, 0x4dd }, + { 0x4df, 0x4df }, + { 0x4e1, 0x4e1 }, + { 0x4e3, 0x4e3 }, + { 0x4e5, 0x4e5 }, + { 0x4e7, 0x4e7 }, + { 0x4e9, 0x4e9 }, + { 0x4eb, 0x4eb }, + { 0x4ed, 0x4ed }, + { 0x4ef, 0x4ef }, + { 0x4f1, 0x4f1 }, + { 0x4f3, 0x4f3 }, + { 0x4f5, 0x4f5 }, + { 0x4f9, 0x4f9 }, + { 0x501, 0x501 }, + { 0x503, 0x503 }, + { 0x505, 0x505 }, + { 0x507, 0x507 }, + { 0x509, 0x509 }, + { 0x50b, 0x50b }, + { 0x50d, 0x50d }, + { 0x50f, 0x50f }, + { 0x561, 0x586 }, + { 0x1e01, 0x1e01 }, + { 0x1e03, 0x1e03 }, + { 0x1e05, 0x1e05 }, + { 0x1e07, 0x1e07 }, + { 0x1e09, 0x1e09 }, + { 0x1e0b, 0x1e0b }, + { 0x1e0d, 0x1e0d }, + { 0x1e0f, 0x1e0f }, + { 0x1e11, 0x1e11 }, + { 0x1e13, 0x1e13 }, + { 0x1e15, 0x1e15 }, + { 0x1e17, 0x1e17 }, + { 0x1e19, 0x1e19 }, + { 0x1e1b, 0x1e1b }, + { 0x1e1d, 0x1e1d }, + { 0x1e1f, 0x1e1f }, + { 0x1e21, 0x1e21 }, + { 0x1e23, 0x1e23 }, + { 0x1e25, 0x1e25 }, + { 0x1e27, 0x1e27 }, + { 0x1e29, 0x1e29 }, + { 0x1e2b, 0x1e2b }, + { 0x1e2d, 0x1e2d }, + { 0x1e2f, 0x1e2f }, + { 0x1e31, 0x1e31 }, + { 0x1e33, 0x1e33 }, + { 0x1e35, 0x1e35 }, + { 0x1e37, 0x1e37 }, + { 0x1e39, 0x1e39 }, + { 0x1e3b, 0x1e3b }, + { 0x1e3d, 0x1e3d }, + { 0x1e3f, 0x1e3f }, + { 0x1e41, 0x1e41 }, + { 0x1e43, 0x1e43 }, + { 0x1e45, 0x1e45 }, + { 0x1e47, 0x1e47 }, + { 0x1e49, 0x1e49 }, + { 0x1e4b, 0x1e4b }, + { 0x1e4d, 0x1e4d }, + { 0x1e4f, 0x1e4f }, + { 0x1e51, 0x1e51 }, + { 0x1e53, 0x1e53 }, + { 0x1e55, 0x1e55 }, + { 0x1e57, 0x1e57 }, + { 0x1e59, 0x1e59 }, + { 0x1e5b, 0x1e5b }, + { 0x1e5d, 0x1e5d }, + { 0x1e5f, 0x1e5f }, + { 0x1e61, 0x1e61 }, + { 0x1e63, 0x1e63 }, + { 0x1e65, 0x1e65 }, + { 0x1e67, 0x1e67 }, + { 0x1e69, 0x1e69 }, + { 0x1e6b, 0x1e6b }, + { 0x1e6d, 0x1e6d }, + { 0x1e6f, 0x1e6f }, + { 0x1e71, 0x1e71 }, + { 0x1e73, 0x1e73 }, + { 0x1e75, 0x1e75 }, + { 0x1e77, 0x1e77 }, + { 0x1e79, 0x1e79 }, + { 0x1e7b, 0x1e7b }, + { 0x1e7d, 0x1e7d }, + { 0x1e7f, 0x1e7f }, + { 0x1e81, 0x1e81 }, + { 0x1e83, 0x1e83 }, + { 0x1e85, 0x1e85 }, + { 0x1e87, 0x1e87 }, + { 0x1e89, 0x1e89 }, + { 0x1e8b, 0x1e8b }, + { 0x1e8d, 0x1e8d }, + { 0x1e8f, 0x1e8f }, + { 0x1e91, 0x1e91 }, + { 0x1e93, 0x1e93 }, + { 0x1e95, 0x1e95 }, + { 0x1e9b, 0x1e9b }, + { 0x1ea1, 0x1ea1 }, + { 0x1ea3, 0x1ea3 }, + { 0x1ea5, 0x1ea5 }, + { 0x1ea7, 0x1ea7 }, + { 0x1ea9, 0x1ea9 }, + { 0x1eab, 0x1eab }, + { 0x1ead, 0x1ead }, + { 0x1eaf, 0x1eaf }, + { 0x1eb1, 0x1eb1 }, + { 0x1eb3, 0x1eb3 }, + { 0x1eb5, 0x1eb5 }, + { 0x1eb7, 0x1eb7 }, + { 0x1eb9, 0x1eb9 }, + { 0x1ebb, 0x1ebb }, + { 0x1ebd, 0x1ebd }, + { 0x1ebf, 0x1ebf }, + { 0x1ec1, 0x1ec1 }, + { 0x1ec3, 0x1ec3 }, + { 0x1ec5, 0x1ec5 }, + { 0x1ec7, 0x1ec7 }, + { 0x1ec9, 0x1ec9 }, + { 0x1ecb, 0x1ecb }, + { 0x1ecd, 0x1ecd }, + { 0x1ecf, 0x1ecf }, + { 0x1ed1, 0x1ed1 }, + { 0x1ed3, 0x1ed3 }, + { 0x1ed5, 0x1ed5 }, + { 0x1ed7, 0x1ed7 }, + { 0x1ed9, 0x1ed9 }, + { 0x1edb, 0x1edb }, + { 0x1edd, 0x1edd }, + { 0x1edf, 0x1edf }, + { 0x1ee1, 0x1ee1 }, + { 0x1ee3, 0x1ee3 }, + { 0x1ee5, 0x1ee5 }, + { 0x1ee7, 0x1ee7 }, + { 0x1ee9, 0x1ee9 }, + { 0x1eeb, 0x1eeb }, + { 0x1eed, 0x1eed }, + { 0x1eef, 0x1eef }, + { 0x1ef1, 0x1ef1 }, + { 0x1ef3, 0x1ef3 }, + { 0x1ef5, 0x1ef5 }, + { 0x1ef7, 0x1ef7 }, + { 0x1ef9, 0x1ef9 }, + { 0x1f00, 0x1f07 }, + { 0x1f10, 0x1f15 }, + { 0x1f20, 0x1f27 }, + { 0x1f30, 0x1f37 }, + { 0x1f40, 0x1f45 }, + { 0x1f51, 0x1f51 }, + { 0x1f53, 0x1f53 }, + { 0x1f55, 0x1f55 }, + { 0x1f57, 0x1f57 }, + { 0x1f60, 0x1f67 }, + { 0x1f70, 0x1f7d }, + { 0x1f80, 0x1f87 }, + { 0x1f90, 0x1f97 }, + { 0x1fa0, 0x1fa7 }, + { 0x1fb0, 0x1fb1 }, + { 0x1fb3, 0x1fb3 }, + { 0x1fbe, 0x1fbe }, + { 0x1fc3, 0x1fc3 }, + { 0x1fd0, 0x1fd1 }, + { 0x1fe0, 0x1fe1 }, + { 0x1fe5, 0x1fe5 }, + { 0x1ff3, 0x1ff3 }, + { 0x2170, 0x217f }, + { 0x24d0, 0x24e9 }, + { 0xff41, 0xff5a }, + { 0x10428, 0x1044d } +}; +static const int table_wlower_count = + (sizeof(table_wlower)/sizeof(struct interval)); + +/* ------------------- iswprint -------------------- */ +static const struct interval table_wprint[] = { + { 0x20, 0x7e }, + { 0xa0, 0x220 }, + { 0x222, 0x233 }, + { 0x250, 0x2ad }, + { 0x2b0, 0x2ee }, + { 0x300, 0x34f }, + { 0x360, 0x36f }, + { 0x374, 0x375 }, + { 0x37a, 0x37a }, + { 0x37e, 0x37e }, + { 0x384, 0x38a }, + { 0x38c, 0x38c }, + { 0x38e, 0x3a1 }, + { 0x3a3, 0x3ce }, + { 0x3d0, 0x3f6 }, + { 0x400, 0x486 }, + { 0x488, 0x4ce }, + { 0x4d0, 0x4f5 }, + { 0x4f8, 0x4f9 }, + { 0x500, 0x50f }, + { 0x531, 0x556 }, + { 0x559, 0x55f }, + { 0x561, 0x587 }, + { 0x589, 0x58a }, + { 0x591, 0x5a1 }, + { 0x5a3, 0x5b9 }, + { 0x5bb, 0x5c4 }, + { 0x5d0, 0x5ea }, + { 0x5f0, 0x5f4 }, + { 0x60c, 0x60c }, + { 0x61b, 0x61b }, + { 0x61f, 0x61f }, + { 0x621, 0x63a }, + { 0x640, 0x655 }, + { 0x660, 0x6ed }, + { 0x6f0, 0x6fe }, + { 0x700, 0x70d }, + { 0x70f, 0x72c }, + { 0x730, 0x74a }, + { 0x780, 0x7b1 }, + { 0x901, 0x903 }, + { 0x905, 0x939 }, + { 0x93c, 0x94d }, + { 0x950, 0x954 }, + { 0x958, 0x970 }, + { 0x981, 0x983 }, + { 0x985, 0x98c }, + { 0x98f, 0x990 }, + { 0x993, 0x9a8 }, + { 0x9aa, 0x9b0 }, + { 0x9b2, 0x9b2 }, + { 0x9b6, 0x9b9 }, + { 0x9bc, 0x9bc }, + { 0x9be, 0x9c4 }, + { 0x9c7, 0x9c8 }, + { 0x9cb, 0x9cd }, + { 0x9d7, 0x9d7 }, + { 0x9dc, 0x9dd }, + { 0x9df, 0x9e3 }, + { 0x9e6, 0x9fa }, + { 0xa02, 0xa02 }, + { 0xa05, 0xa0a }, + { 0xa0f, 0xa10 }, + { 0xa13, 0xa28 }, + { 0xa2a, 0xa30 }, + { 0xa32, 0xa33 }, + { 0xa35, 0xa36 }, + { 0xa38, 0xa39 }, + { 0xa3c, 0xa3c }, + { 0xa3e, 0xa42 }, + { 0xa47, 0xa48 }, + { 0xa4b, 0xa4d }, + { 0xa59, 0xa5c }, + { 0xa5e, 0xa5e }, + { 0xa66, 0xa74 }, + { 0xa81, 0xa83 }, + { 0xa85, 0xa8b }, + { 0xa8d, 0xa8d }, + { 0xa8f, 0xa91 }, + { 0xa93, 0xaa8 }, + { 0xaaa, 0xab0 }, + { 0xab2, 0xab3 }, + { 0xab5, 0xab9 }, + { 0xabc, 0xac5 }, + { 0xac7, 0xac9 }, + { 0xacb, 0xacd }, + { 0xad0, 0xad0 }, + { 0xae0, 0xae0 }, + { 0xae6, 0xaef }, + { 0xb01, 0xb03 }, + { 0xb05, 0xb0c }, + { 0xb0f, 0xb10 }, + { 0xb13, 0xb28 }, + { 0xb2a, 0xb30 }, + { 0xb32, 0xb33 }, + { 0xb36, 0xb39 }, + { 0xb3c, 0xb43 }, + { 0xb47, 0xb48 }, + { 0xb4b, 0xb4d }, + { 0xb56, 0xb57 }, + { 0xb5c, 0xb5d }, + { 0xb5f, 0xb61 }, + { 0xb66, 0xb70 }, + { 0xb82, 0xb83 }, + { 0xb85, 0xb8a }, + { 0xb8e, 0xb90 }, + { 0xb92, 0xb95 }, + { 0xb99, 0xb9a }, + { 0xb9c, 0xb9c }, + { 0xb9e, 0xb9f }, + { 0xba3, 0xba4 }, + { 0xba8, 0xbaa }, + { 0xbae, 0xbb5 }, + { 0xbb7, 0xbb9 }, + { 0xbbe, 0xbc2 }, + { 0xbc6, 0xbc8 }, + { 0xbca, 0xbcd }, + { 0xbd7, 0xbd7 }, + { 0xbe7, 0xbf2 }, + { 0xc01, 0xc03 }, + { 0xc05, 0xc0c }, + { 0xc0e, 0xc10 }, + { 0xc12, 0xc28 }, + { 0xc2a, 0xc33 }, + { 0xc35, 0xc39 }, + { 0xc3e, 0xc44 }, + { 0xc46, 0xc48 }, + { 0xc4a, 0xc4d }, + { 0xc55, 0xc56 }, + { 0xc60, 0xc61 }, + { 0xc66, 0xc6f }, + { 0xc82, 0xc83 }, + { 0xc85, 0xc8c }, + { 0xc8e, 0xc90 }, + { 0xc92, 0xca8 }, + { 0xcaa, 0xcb3 }, + { 0xcb5, 0xcb9 }, + { 0xcbe, 0xcc4 }, + { 0xcc6, 0xcc8 }, + { 0xcca, 0xccd }, + { 0xcd5, 0xcd6 }, + { 0xcde, 0xcde }, + { 0xce0, 0xce1 }, + { 0xce6, 0xcef }, + { 0xd02, 0xd03 }, + { 0xd05, 0xd0c }, + { 0xd0e, 0xd10 }, + { 0xd12, 0xd28 }, + { 0xd2a, 0xd39 }, + { 0xd3e, 0xd43 }, + { 0xd46, 0xd48 }, + { 0xd4a, 0xd4d }, + { 0xd57, 0xd57 }, + { 0xd60, 0xd61 }, + { 0xd66, 0xd6f }, + { 0xd82, 0xd83 }, + { 0xd85, 0xd96 }, + { 0xd9a, 0xdb1 }, + { 0xdb3, 0xdbb }, + { 0xdbd, 0xdbd }, + { 0xdc0, 0xdc6 }, + { 0xdca, 0xdca }, + { 0xdcf, 0xdd4 }, + { 0xdd6, 0xdd6 }, + { 0xdd8, 0xddf }, + { 0xdf2, 0xdf4 }, + { 0xe01, 0xe3a }, + { 0xe3f, 0xe5b }, + { 0xe81, 0xe82 }, + { 0xe84, 0xe84 }, + { 0xe87, 0xe88 }, + { 0xe8a, 0xe8a }, + { 0xe8d, 0xe8d }, + { 0xe94, 0xe97 }, + { 0xe99, 0xe9f }, + { 0xea1, 0xea3 }, + { 0xea5, 0xea5 }, + { 0xea7, 0xea7 }, + { 0xeaa, 0xeab }, + { 0xead, 0xeb9 }, + { 0xebb, 0xebd }, + { 0xec0, 0xec4 }, + { 0xec6, 0xec6 }, + { 0xec8, 0xecd }, + { 0xed0, 0xed9 }, + { 0xedc, 0xedd }, + { 0xf00, 0xf47 }, + { 0xf49, 0xf6a }, + { 0xf71, 0xf8b }, + { 0xf90, 0xf97 }, + { 0xf99, 0xfbc }, + { 0xfbe, 0xfcc }, + { 0xfcf, 0xfcf }, + { 0x1000, 0x1021 }, + { 0x1023, 0x1027 }, + { 0x1029, 0x102a }, + { 0x102c, 0x1032 }, + { 0x1036, 0x1039 }, + { 0x1040, 0x1059 }, + { 0x10a0, 0x10c5 }, + { 0x10d0, 0x10f8 }, + { 0x10fb, 0x10fb }, + { 0x1100, 0x1159 }, + { 0x115f, 0x11a2 }, + { 0x11a8, 0x11f9 }, + { 0x1200, 0x1206 }, + { 0x1208, 0x1246 }, + { 0x1248, 0x1248 }, + { 0x124a, 0x124d }, + { 0x1250, 0x1256 }, + { 0x1258, 0x1258 }, + { 0x125a, 0x125d }, + { 0x1260, 0x1286 }, + { 0x1288, 0x1288 }, + { 0x128a, 0x128d }, + { 0x1290, 0x12ae }, + { 0x12b0, 0x12b0 }, + { 0x12b2, 0x12b5 }, + { 0x12b8, 0x12be }, + { 0x12c0, 0x12c0 }, + { 0x12c2, 0x12c5 }, + { 0x12c8, 0x12ce }, + { 0x12d0, 0x12d6 }, + { 0x12d8, 0x12ee }, + { 0x12f0, 0x130e }, + { 0x1310, 0x1310 }, + { 0x1312, 0x1315 }, + { 0x1318, 0x131e }, + { 0x1320, 0x1346 }, + { 0x1348, 0x135a }, + { 0x1361, 0x137c }, + { 0x13a0, 0x13f4 }, + { 0x1401, 0x1676 }, + { 0x1680, 0x169c }, + { 0x16a0, 0x16f0 }, + { 0x1700, 0x170c }, + { 0x170e, 0x1714 }, + { 0x1720, 0x1736 }, + { 0x1740, 0x1753 }, + { 0x1760, 0x176c }, + { 0x176e, 0x1770 }, + { 0x1772, 0x1773 }, + { 0x1780, 0x17dc }, + { 0x17e0, 0x17e9 }, + { 0x1800, 0x180e }, + { 0x1810, 0x1819 }, + { 0x1820, 0x1877 }, + { 0x1880, 0x18a9 }, + { 0x1e00, 0x1e9b }, + { 0x1ea0, 0x1ef9 }, + { 0x1f00, 0x1f15 }, + { 0x1f18, 0x1f1d }, + { 0x1f20, 0x1f45 }, + { 0x1f48, 0x1f4d }, + { 0x1f50, 0x1f57 }, + { 0x1f59, 0x1f59 }, + { 0x1f5b, 0x1f5b }, + { 0x1f5d, 0x1f5d }, + { 0x1f5f, 0x1f7d }, + { 0x1f80, 0x1fb4 }, + { 0x1fb6, 0x1fc4 }, + { 0x1fc6, 0x1fd3 }, + { 0x1fd6, 0x1fdb }, + { 0x1fdd, 0x1fef }, + { 0x1ff2, 0x1ff4 }, + { 0x1ff6, 0x1ffe }, + { 0x2000, 0x2027 }, + { 0x202a, 0x2052 }, + { 0x2057, 0x2057 }, + { 0x205f, 0x2063 }, + { 0x206a, 0x2071 }, + { 0x2074, 0x208e }, + { 0x20a0, 0x20b1 }, + { 0x20d0, 0x20ea }, + { 0x2100, 0x213a }, + { 0x213d, 0x214b }, + { 0x2153, 0x2183 }, + { 0x2190, 0x23ce }, + { 0x2400, 0x2426 }, + { 0x2440, 0x244a }, + { 0x2460, 0x24fe }, + { 0x2500, 0x2613 }, + { 0x2616, 0x2617 }, + { 0x2619, 0x267d }, + { 0x2680, 0x2689 }, + { 0x2701, 0x2704 }, + { 0x2706, 0x2709 }, + { 0x270c, 0x2727 }, + { 0x2729, 0x274b }, + { 0x274d, 0x274d }, + { 0x274f, 0x2752 }, + { 0x2756, 0x2756 }, + { 0x2758, 0x275e }, + { 0x2761, 0x2794 }, + { 0x2798, 0x27af }, + { 0x27b1, 0x27be }, + { 0x27d0, 0x27eb }, + { 0x27f0, 0x2aff }, + { 0x2e80, 0x2e99 }, + { 0x2e9b, 0x2ef3 }, + { 0x2f00, 0x2fd5 }, + { 0x2ff0, 0x2ffb }, + { 0x3000, 0x303f }, + { 0x3041, 0x3096 }, + { 0x3099, 0x30ff }, + { 0x3105, 0x312c }, + { 0x3131, 0x318e }, + { 0x3190, 0x31b7 }, + { 0x31f0, 0x321c }, + { 0x3220, 0x3243 }, + { 0x3251, 0x327b }, + { 0x327f, 0x32cb }, + { 0x32d0, 0x32fe }, + { 0x3300, 0x3376 }, + { 0x337b, 0x33dd }, + { 0x33e0, 0x33fe }, + { 0x3400, 0x4db5 }, + { 0x4e00, 0x9fa5 }, + { 0xa000, 0xa48c }, + { 0xa490, 0xa4c6 }, + { 0xac00, 0xd7a3 }, + { 0xe000, 0xfa2d }, + { 0xfa30, 0xfa6a }, + { 0xfb00, 0xfb06 }, + { 0xfb13, 0xfb17 }, + { 0xfb1d, 0xfb36 }, + { 0xfb38, 0xfb3c }, + { 0xfb3e, 0xfb3e }, + { 0xfb40, 0xfb41 }, + { 0xfb43, 0xfb44 }, + { 0xfb46, 0xfbb1 }, + { 0xfbd3, 0xfd3f }, + { 0xfd50, 0xfd8f }, + { 0xfd92, 0xfdc7 }, + { 0xfdf0, 0xfdfc }, + { 0xfe00, 0xfe0f }, + { 0xfe20, 0xfe23 }, + { 0xfe30, 0xfe46 }, + { 0xfe49, 0xfe52 }, + { 0xfe54, 0xfe66 }, + { 0xfe68, 0xfe6b }, + { 0xfe70, 0xfe74 }, + { 0xfe76, 0xfefc }, + { 0xfeff, 0xfeff }, + { 0xff01, 0xffbe }, + { 0xffc2, 0xffc7 }, + { 0xffca, 0xffcf }, + { 0xffd2, 0xffd7 }, + { 0xffda, 0xffdc }, + { 0xffe0, 0xffe6 }, + { 0xffe8, 0xffee }, + { 0xfff9, 0xfffd }, + { 0x10300, 0x1031e }, + { 0x10320, 0x10323 }, + { 0x10330, 0x1034a }, + { 0x10400, 0x10425 }, + { 0x10428, 0x1044d }, + { 0x1d000, 0x1d0f5 }, + { 0x1d100, 0x1d126 }, + { 0x1d12a, 0x1d1dd }, + { 0x1d400, 0x1d454 }, + { 0x1d456, 0x1d49c }, + { 0x1d49e, 0x1d49f }, + { 0x1d4a2, 0x1d4a2 }, + { 0x1d4a5, 0x1d4a6 }, + { 0x1d4a9, 0x1d4ac }, + { 0x1d4ae, 0x1d4b9 }, + { 0x1d4bb, 0x1d4bb }, + { 0x1d4bd, 0x1d4c0 }, + { 0x1d4c2, 0x1d4c3 }, + { 0x1d4c5, 0x1d505 }, + { 0x1d507, 0x1d50a }, + { 0x1d50d, 0x1d514 }, + { 0x1d516, 0x1d51c }, + { 0x1d51e, 0x1d539 }, + { 0x1d53b, 0x1d53e }, + { 0x1d540, 0x1d544 }, + { 0x1d546, 0x1d546 }, + { 0x1d54a, 0x1d550 }, + { 0x1d552, 0x1d6a3 }, + { 0x1d6a8, 0x1d7c9 }, + { 0x1d7ce, 0x1d7ff }, + { 0x20000, 0x2a6d6 }, + { 0x2f800, 0x2fa1d }, + { 0xe0001, 0xe0001 }, + { 0xe0020, 0xe007f }, + { 0xf0000, 0xffffd }, + { 0x100000, 0x10fffd } +}; +static const int table_wprint_count = + (sizeof(table_wprint)/sizeof(struct interval)); + +/* ------------------- iswpunct -------------------- */ +static const struct interval table_wpunct[] = { + { 0x21, 0x2f }, + { 0x3a, 0x40 }, + { 0x5b, 0x60 }, + { 0x7b, 0x7e }, + { 0xa0, 0xa9 }, + { 0xab, 0xb4 }, + { 0xb6, 0xb9 }, + { 0xbb, 0xbf }, + { 0xd7, 0xd7 }, + { 0xf7, 0xf7 }, + { 0x2b9, 0x2ba }, + { 0x2c2, 0x2cf }, + { 0x2d2, 0x2df }, + { 0x2e5, 0x2ed }, + { 0x300, 0x344 }, + { 0x346, 0x34f }, + { 0x360, 0x36f }, + { 0x374, 0x375 }, + { 0x37e, 0x37e }, + { 0x384, 0x385 }, + { 0x387, 0x387 }, + { 0x3f6, 0x3f6 }, + { 0x482, 0x486 }, + { 0x488, 0x489 }, + { 0x55a, 0x55f }, + { 0x589, 0x58a }, + { 0x591, 0x5a1 }, + { 0x5a3, 0x5b9 }, + { 0x5bb, 0x5c4 }, + { 0x5f3, 0x5f4 }, + { 0x60c, 0x60c }, + { 0x61b, 0x61b }, + { 0x61f, 0x61f }, + { 0x64b, 0x655 }, + { 0x66a, 0x66d }, + { 0x670, 0x670 }, + { 0x6d4, 0x6d4 }, + { 0x6d6, 0x6e4 }, + { 0x6e7, 0x6ed }, + { 0x6fd, 0x6fe }, + { 0x700, 0x70d }, + { 0x70f, 0x70f }, + { 0x711, 0x711 }, + { 0x730, 0x74a }, + { 0x7a6, 0x7b0 }, + { 0x901, 0x903 }, + { 0x93c, 0x93c }, + { 0x93e, 0x94d }, + { 0x951, 0x954 }, + { 0x962, 0x965 }, + { 0x970, 0x970 }, + { 0x981, 0x983 }, + { 0x9bc, 0x9bc }, + { 0x9be, 0x9c4 }, + { 0x9c7, 0x9c8 }, + { 0x9cb, 0x9cd }, + { 0x9d7, 0x9d7 }, + { 0x9e2, 0x9e3 }, + { 0x9f2, 0x9fa }, + { 0xa02, 0xa02 }, + { 0xa3c, 0xa3c }, + { 0xa3e, 0xa42 }, + { 0xa47, 0xa48 }, + { 0xa4b, 0xa4d }, + { 0xa70, 0xa71 }, + { 0xa81, 0xa83 }, + { 0xabc, 0xabc }, + { 0xabe, 0xac5 }, + { 0xac7, 0xac9 }, + { 0xacb, 0xacd }, + { 0xb01, 0xb03 }, + { 0xb3c, 0xb3c }, + { 0xb3e, 0xb43 }, + { 0xb47, 0xb48 }, + { 0xb4b, 0xb4d }, + { 0xb56, 0xb57 }, + { 0xb70, 0xb70 }, + { 0xb82, 0xb82 }, + { 0xbbe, 0xbc2 }, + { 0xbc6, 0xbc8 }, + { 0xbca, 0xbcd }, + { 0xbd7, 0xbd7 }, + { 0xbf0, 0xbf2 }, + { 0xc01, 0xc03 }, + { 0xc3e, 0xc44 }, + { 0xc46, 0xc48 }, + { 0xc4a, 0xc4d }, + { 0xc55, 0xc56 }, + { 0xc82, 0xc83 }, + { 0xcbe, 0xcc4 }, + { 0xcc6, 0xcc8 }, + { 0xcca, 0xccd }, + { 0xcd5, 0xcd6 }, + { 0xd02, 0xd03 }, + { 0xd3e, 0xd43 }, + { 0xd46, 0xd48 }, + { 0xd4a, 0xd4d }, + { 0xd57, 0xd57 }, + { 0xd82, 0xd83 }, + { 0xdca, 0xdca }, + { 0xdcf, 0xdd4 }, + { 0xdd6, 0xdd6 }, + { 0xdd8, 0xddf }, + { 0xdf2, 0xdf4 }, + { 0xe2f, 0xe2f }, + { 0xe3f, 0xe3f }, + { 0xe46, 0xe46 }, + { 0xe4f, 0xe4f }, + { 0xe5a, 0xe5b }, + { 0xeb1, 0xeb1 }, + { 0xeb4, 0xeb9 }, + { 0xebb, 0xebc }, + { 0xec8, 0xecd }, + { 0xf01, 0xf1f }, + { 0xf2a, 0xf3f }, + { 0xf71, 0xf87 }, + { 0xf90, 0xf97 }, + { 0xf99, 0xfbc }, + { 0xfbe, 0xfcc }, + { 0xfcf, 0xfcf }, + { 0x102c, 0x1032 }, + { 0x1036, 0x1039 }, + { 0x104a, 0x104f }, + { 0x1056, 0x1059 }, + { 0x10fb, 0x10fb }, + { 0x1361, 0x1368 }, + { 0x1372, 0x137c }, + { 0x166d, 0x166e }, + { 0x169b, 0x169c }, + { 0x16eb, 0x16ed }, + { 0x1712, 0x1714 }, + { 0x1732, 0x1736 }, + { 0x1752, 0x1753 }, + { 0x1772, 0x1773 }, + { 0x17b4, 0x17d6 }, + { 0x17d8, 0x17db }, + { 0x1800, 0x180e }, + { 0x18a9, 0x18a9 }, + { 0x1fbd, 0x1fbd }, + { 0x1fbf, 0x1fc1 }, + { 0x1fcd, 0x1fcf }, + { 0x1fdd, 0x1fdf }, + { 0x1fed, 0x1fef }, + { 0x1ffd, 0x1ffe }, + { 0x2007, 0x2007 }, + { 0x200c, 0x2027 }, + { 0x202a, 0x2052 }, + { 0x2057, 0x2057 }, + { 0x2060, 0x2063 }, + { 0x206a, 0x2070 }, + { 0x2074, 0x207e }, + { 0x2080, 0x208e }, + { 0x20a0, 0x20b1 }, + { 0x20d0, 0x20ea }, + { 0x2100, 0x2101 }, + { 0x2103, 0x2106 }, + { 0x2108, 0x2109 }, + { 0x2114, 0x2114 }, + { 0x2116, 0x2118 }, + { 0x211e, 0x2123 }, + { 0x2125, 0x2125 }, + { 0x2127, 0x2127 }, + { 0x212e, 0x212e }, + { 0x2132, 0x2132 }, + { 0x213a, 0x213a }, + { 0x2140, 0x2144 }, + { 0x214a, 0x214b }, + { 0x2153, 0x215f }, + { 0x2190, 0x23ce }, + { 0x2400, 0x2426 }, + { 0x2440, 0x244a }, + { 0x2460, 0x249b }, + { 0x24ea, 0x24fe }, + { 0x2500, 0x2613 }, + { 0x2616, 0x2617 }, + { 0x2619, 0x267d }, + { 0x2680, 0x2689 }, + { 0x2701, 0x2704 }, + { 0x2706, 0x2709 }, + { 0x270c, 0x2727 }, + { 0x2729, 0x274b }, + { 0x274d, 0x274d }, + { 0x274f, 0x2752 }, + { 0x2756, 0x2756 }, + { 0x2758, 0x275e }, + { 0x2761, 0x2794 }, + { 0x2798, 0x27af }, + { 0x27b1, 0x27be }, + { 0x27d0, 0x27eb }, + { 0x27f0, 0x2aff }, + { 0x2e80, 0x2e99 }, + { 0x2e9b, 0x2ef3 }, + { 0x2f00, 0x2fd5 }, + { 0x2ff0, 0x2ffb }, + { 0x3001, 0x3004 }, + { 0x3008, 0x3020 }, + { 0x302a, 0x3030 }, + { 0x3036, 0x3037 }, + { 0x303d, 0x303f }, + { 0x3099, 0x309c }, + { 0x30a0, 0x30a0 }, + { 0x30fb, 0x30fb }, + { 0x3190, 0x319f }, + { 0x3200, 0x321c }, + { 0x3220, 0x3243 }, + { 0x3251, 0x327b }, + { 0x327f, 0x32cb }, + { 0x32d0, 0x32fe }, + { 0x3300, 0x3376 }, + { 0x337b, 0x33dd }, + { 0x33e0, 0x33fe }, + { 0xa490, 0xa4c6 }, + { 0xe000, 0xf8ff }, + { 0xfb1e, 0xfb1e }, + { 0xfb29, 0xfb29 }, + { 0xfd3e, 0xfd3f }, + { 0xfdfc, 0xfdfc }, + { 0xfe00, 0xfe0f }, + { 0xfe20, 0xfe23 }, + { 0xfe30, 0xfe44 }, + { 0xfe49, 0xfe52 }, + { 0xfe54, 0xfe66 }, + { 0xfe68, 0xfe6b }, + { 0xfeff, 0xfeff }, + { 0xff01, 0xff0f }, + { 0xff1a, 0xff20 }, + { 0xff3b, 0xff40 }, + { 0xff5b, 0xff65 }, + { 0xffe0, 0xffe6 }, + { 0xffe8, 0xffee }, + { 0xfff9, 0xfffd }, + { 0x10320, 0x10323 }, + { 0x1d000, 0x1d0f5 }, + { 0x1d100, 0x1d126 }, + { 0x1d12a, 0x1d1dd }, + { 0x1d6c1, 0x1d6c1 }, + { 0x1d6db, 0x1d6db }, + { 0x1d6fb, 0x1d6fb }, + { 0x1d715, 0x1d715 }, + { 0x1d735, 0x1d735 }, + { 0x1d74f, 0x1d74f }, + { 0x1d76f, 0x1d76f }, + { 0x1d789, 0x1d789 }, + { 0x1d7a9, 0x1d7a9 }, + { 0x1d7c3, 0x1d7c3 }, + { 0xe0001, 0xe0001 }, + { 0xe0020, 0xe007f }, + { 0xf0000, 0xffffd }, + { 0x100000, 0x10fffd } +}; +static const int table_wpunct_count = + (sizeof(table_wpunct)/sizeof(struct interval)); + +/* ------------------- iswspace -------------------- */ +static const struct interval table_wspace[] = { + { 0x9, 0xd }, + { 0x20, 0x20 }, + { 0xa0, 0xa0 }, /* non-breaking space */ + { 0x1680, 0x1680 }, /* ogham space mark */ + { 0x2000, 0x2006 }, /* why not figure space, 2007? */ + { 0x2008, 0x200b }, + { 0x2028, 0x2029 }, /* line separator, para separator */ + { 0x205f, 0x205f }, /* medium mathematical space */ + { 0x3000, 0x3000 } /* (CJK) ideographic space */ +}; +static const int table_wspace_count = + (sizeof(table_wspace)/sizeof(struct interval)); + +/* ------------------- iswupper -------------------- */ +static const struct interval table_wupper[] = { + { 0x41, 0x5a }, + { 0xc0, 0xd6 }, + { 0xd8, 0xde }, + { 0x100, 0x100 }, + { 0x102, 0x102 }, + { 0x104, 0x104 }, + { 0x106, 0x106 }, + { 0x108, 0x108 }, + { 0x10a, 0x10a }, + { 0x10c, 0x10c }, + { 0x10e, 0x10e }, + { 0x110, 0x110 }, + { 0x112, 0x112 }, + { 0x114, 0x114 }, + { 0x116, 0x116 }, + { 0x118, 0x118 }, + { 0x11a, 0x11a }, + { 0x11c, 0x11c }, + { 0x11e, 0x11e }, + { 0x120, 0x120 }, + { 0x122, 0x122 }, + { 0x124, 0x124 }, + { 0x126, 0x126 }, + { 0x128, 0x128 }, + { 0x12a, 0x12a }, + { 0x12c, 0x12c }, + { 0x12e, 0x12e }, + { 0x130, 0x130 }, + { 0x132, 0x132 }, + { 0x134, 0x134 }, + { 0x136, 0x136 }, + { 0x139, 0x139 }, + { 0x13b, 0x13b }, + { 0x13d, 0x13d }, + { 0x13f, 0x13f }, + { 0x141, 0x141 }, + { 0x143, 0x143 }, + { 0x145, 0x145 }, + { 0x147, 0x147 }, + { 0x14a, 0x14a }, + { 0x14c, 0x14c }, + { 0x14e, 0x14e }, + { 0x150, 0x150 }, + { 0x152, 0x152 }, + { 0x154, 0x154 }, + { 0x156, 0x156 }, + { 0x158, 0x158 }, + { 0x15a, 0x15a }, + { 0x15c, 0x15c }, + { 0x15e, 0x15e }, + { 0x160, 0x160 }, + { 0x162, 0x162 }, + { 0x164, 0x164 }, + { 0x166, 0x166 }, + { 0x168, 0x168 }, + { 0x16a, 0x16a }, + { 0x16c, 0x16c }, + { 0x16e, 0x16e }, + { 0x170, 0x170 }, + { 0x172, 0x172 }, + { 0x174, 0x174 }, + { 0x176, 0x176 }, + { 0x178, 0x179 }, + { 0x17b, 0x17b }, + { 0x17d, 0x17d }, + { 0x181, 0x182 }, + { 0x184, 0x184 }, + { 0x186, 0x187 }, + { 0x189, 0x18b }, + { 0x18e, 0x191 }, + { 0x193, 0x194 }, + { 0x196, 0x198 }, + { 0x19c, 0x19d }, + { 0x19f, 0x1a0 }, + { 0x1a2, 0x1a2 }, + { 0x1a4, 0x1a4 }, + { 0x1a6, 0x1a7 }, + { 0x1a9, 0x1a9 }, + { 0x1ac, 0x1ac }, + { 0x1ae, 0x1af }, + { 0x1b1, 0x1b3 }, + { 0x1b5, 0x1b5 }, + { 0x1b7, 0x1b8 }, + { 0x1bc, 0x1bc }, + { 0x1c4, 0x1c5 }, + { 0x1c7, 0x1c8 }, + { 0x1ca, 0x1cb }, + { 0x1cd, 0x1cd }, + { 0x1cf, 0x1cf }, + { 0x1d1, 0x1d1 }, + { 0x1d3, 0x1d3 }, + { 0x1d5, 0x1d5 }, + { 0x1d7, 0x1d7 }, + { 0x1d9, 0x1d9 }, + { 0x1db, 0x1db }, + { 0x1de, 0x1de }, + { 0x1e0, 0x1e0 }, + { 0x1e2, 0x1e2 }, + { 0x1e4, 0x1e4 }, + { 0x1e6, 0x1e6 }, + { 0x1e8, 0x1e8 }, + { 0x1ea, 0x1ea }, + { 0x1ec, 0x1ec }, + { 0x1ee, 0x1ee }, + { 0x1f1, 0x1f2 }, + { 0x1f4, 0x1f4 }, + { 0x1f6, 0x1f8 }, + { 0x1fa, 0x1fa }, + { 0x1fc, 0x1fc }, + { 0x1fe, 0x1fe }, + { 0x200, 0x200 }, + { 0x202, 0x202 }, + { 0x204, 0x204 }, + { 0x206, 0x206 }, + { 0x208, 0x208 }, + { 0x20a, 0x20a }, + { 0x20c, 0x20c }, + { 0x20e, 0x20e }, + { 0x210, 0x210 }, + { 0x212, 0x212 }, + { 0x214, 0x214 }, + { 0x216, 0x216 }, + { 0x218, 0x218 }, + { 0x21a, 0x21a }, + { 0x21c, 0x21c }, + { 0x21e, 0x21e }, + { 0x220, 0x220 }, + { 0x222, 0x222 }, + { 0x224, 0x224 }, + { 0x226, 0x226 }, + { 0x228, 0x228 }, + { 0x22a, 0x22a }, + { 0x22c, 0x22c }, + { 0x22e, 0x22e }, + { 0x230, 0x230 }, + { 0x232, 0x232 }, + { 0x386, 0x386 }, + { 0x388, 0x38a }, + { 0x38c, 0x38c }, + { 0x38e, 0x38f }, + { 0x391, 0x3a1 }, + { 0x3a3, 0x3ab }, + { 0x3d8, 0x3d8 }, + { 0x3da, 0x3da }, + { 0x3dc, 0x3dc }, + { 0x3de, 0x3de }, + { 0x3e0, 0x3e0 }, + { 0x3e2, 0x3e2 }, + { 0x3e4, 0x3e4 }, + { 0x3e6, 0x3e6 }, + { 0x3e8, 0x3e8 }, + { 0x3ea, 0x3ea }, + { 0x3ec, 0x3ec }, + { 0x3ee, 0x3ee }, + { 0x3f4, 0x3f4 }, + { 0x400, 0x42f }, + { 0x460, 0x460 }, + { 0x462, 0x462 }, + { 0x464, 0x464 }, + { 0x466, 0x466 }, + { 0x468, 0x468 }, + { 0x46a, 0x46a }, + { 0x46c, 0x46c }, + { 0x46e, 0x46e }, + { 0x470, 0x470 }, + { 0x472, 0x472 }, + { 0x474, 0x474 }, + { 0x476, 0x476 }, + { 0x478, 0x478 }, + { 0x47a, 0x47a }, + { 0x47c, 0x47c }, + { 0x47e, 0x47e }, + { 0x480, 0x480 }, + { 0x48a, 0x48a }, + { 0x48c, 0x48c }, + { 0x48e, 0x48e }, + { 0x490, 0x490 }, + { 0x492, 0x492 }, + { 0x494, 0x494 }, + { 0x496, 0x496 }, + { 0x498, 0x498 }, + { 0x49a, 0x49a }, + { 0x49c, 0x49c }, + { 0x49e, 0x49e }, + { 0x4a0, 0x4a0 }, + { 0x4a2, 0x4a2 }, + { 0x4a4, 0x4a4 }, + { 0x4a6, 0x4a6 }, + { 0x4a8, 0x4a8 }, + { 0x4aa, 0x4aa }, + { 0x4ac, 0x4ac }, + { 0x4ae, 0x4ae }, + { 0x4b0, 0x4b0 }, + { 0x4b2, 0x4b2 }, + { 0x4b4, 0x4b4 }, + { 0x4b6, 0x4b6 }, + { 0x4b8, 0x4b8 }, + { 0x4ba, 0x4ba }, + { 0x4bc, 0x4bc }, + { 0x4be, 0x4be }, + { 0x4c1, 0x4c1 }, + { 0x4c3, 0x4c3 }, + { 0x4c5, 0x4c5 }, + { 0x4c7, 0x4c7 }, + { 0x4c9, 0x4c9 }, + { 0x4cb, 0x4cb }, + { 0x4cd, 0x4cd }, + { 0x4d0, 0x4d0 }, + { 0x4d2, 0x4d2 }, + { 0x4d4, 0x4d4 }, + { 0x4d6, 0x4d6 }, + { 0x4d8, 0x4d8 }, + { 0x4da, 0x4da }, + { 0x4dc, 0x4dc }, + { 0x4de, 0x4de }, + { 0x4e0, 0x4e0 }, + { 0x4e2, 0x4e2 }, + { 0x4e4, 0x4e4 }, + { 0x4e6, 0x4e6 }, + { 0x4e8, 0x4e8 }, + { 0x4ea, 0x4ea }, + { 0x4ec, 0x4ec }, + { 0x4ee, 0x4ee }, + { 0x4f0, 0x4f0 }, + { 0x4f2, 0x4f2 }, + { 0x4f4, 0x4f4 }, + { 0x4f8, 0x4f8 }, + { 0x500, 0x500 }, + { 0x502, 0x502 }, + { 0x504, 0x504 }, + { 0x506, 0x506 }, + { 0x508, 0x508 }, + { 0x50a, 0x50a }, + { 0x50c, 0x50c }, + { 0x50e, 0x50e }, + { 0x531, 0x556 }, + { 0x1e00, 0x1e00 }, + { 0x1e02, 0x1e02 }, + { 0x1e04, 0x1e04 }, + { 0x1e06, 0x1e06 }, + { 0x1e08, 0x1e08 }, + { 0x1e0a, 0x1e0a }, + { 0x1e0c, 0x1e0c }, + { 0x1e0e, 0x1e0e }, + { 0x1e10, 0x1e10 }, + { 0x1e12, 0x1e12 }, + { 0x1e14, 0x1e14 }, + { 0x1e16, 0x1e16 }, + { 0x1e18, 0x1e18 }, + { 0x1e1a, 0x1e1a }, + { 0x1e1c, 0x1e1c }, + { 0x1e1e, 0x1e1e }, + { 0x1e20, 0x1e20 }, + { 0x1e22, 0x1e22 }, + { 0x1e24, 0x1e24 }, + { 0x1e26, 0x1e26 }, + { 0x1e28, 0x1e28 }, + { 0x1e2a, 0x1e2a }, + { 0x1e2c, 0x1e2c }, + { 0x1e2e, 0x1e2e }, + { 0x1e30, 0x1e30 }, + { 0x1e32, 0x1e32 }, + { 0x1e34, 0x1e34 }, + { 0x1e36, 0x1e36 }, + { 0x1e38, 0x1e38 }, + { 0x1e3a, 0x1e3a }, + { 0x1e3c, 0x1e3c }, + { 0x1e3e, 0x1e3e }, + { 0x1e40, 0x1e40 }, + { 0x1e42, 0x1e42 }, + { 0x1e44, 0x1e44 }, + { 0x1e46, 0x1e46 }, + { 0x1e48, 0x1e48 }, + { 0x1e4a, 0x1e4a }, + { 0x1e4c, 0x1e4c }, + { 0x1e4e, 0x1e4e }, + { 0x1e50, 0x1e50 }, + { 0x1e52, 0x1e52 }, + { 0x1e54, 0x1e54 }, + { 0x1e56, 0x1e56 }, + { 0x1e58, 0x1e58 }, + { 0x1e5a, 0x1e5a }, + { 0x1e5c, 0x1e5c }, + { 0x1e5e, 0x1e5e }, + { 0x1e60, 0x1e60 }, + { 0x1e62, 0x1e62 }, + { 0x1e64, 0x1e64 }, + { 0x1e66, 0x1e66 }, + { 0x1e68, 0x1e68 }, + { 0x1e6a, 0x1e6a }, + { 0x1e6c, 0x1e6c }, + { 0x1e6e, 0x1e6e }, + { 0x1e70, 0x1e70 }, + { 0x1e72, 0x1e72 }, + { 0x1e74, 0x1e74 }, + { 0x1e76, 0x1e76 }, + { 0x1e78, 0x1e78 }, + { 0x1e7a, 0x1e7a }, + { 0x1e7c, 0x1e7c }, + { 0x1e7e, 0x1e7e }, + { 0x1e80, 0x1e80 }, + { 0x1e82, 0x1e82 }, + { 0x1e84, 0x1e84 }, + { 0x1e86, 0x1e86 }, + { 0x1e88, 0x1e88 }, + { 0x1e8a, 0x1e8a }, + { 0x1e8c, 0x1e8c }, + { 0x1e8e, 0x1e8e }, + { 0x1e90, 0x1e90 }, + { 0x1e92, 0x1e92 }, + { 0x1e94, 0x1e94 }, + { 0x1ea0, 0x1ea0 }, + { 0x1ea2, 0x1ea2 }, + { 0x1ea4, 0x1ea4 }, + { 0x1ea6, 0x1ea6 }, + { 0x1ea8, 0x1ea8 }, + { 0x1eaa, 0x1eaa }, + { 0x1eac, 0x1eac }, + { 0x1eae, 0x1eae }, + { 0x1eb0, 0x1eb0 }, + { 0x1eb2, 0x1eb2 }, + { 0x1eb4, 0x1eb4 }, + { 0x1eb6, 0x1eb6 }, + { 0x1eb8, 0x1eb8 }, + { 0x1eba, 0x1eba }, + { 0x1ebc, 0x1ebc }, + { 0x1ebe, 0x1ebe }, + { 0x1ec0, 0x1ec0 }, + { 0x1ec2, 0x1ec2 }, + { 0x1ec4, 0x1ec4 }, + { 0x1ec6, 0x1ec6 }, + { 0x1ec8, 0x1ec8 }, + { 0x1eca, 0x1eca }, + { 0x1ecc, 0x1ecc }, + { 0x1ece, 0x1ece }, + { 0x1ed0, 0x1ed0 }, + { 0x1ed2, 0x1ed2 }, + { 0x1ed4, 0x1ed4 }, + { 0x1ed6, 0x1ed6 }, + { 0x1ed8, 0x1ed8 }, + { 0x1eda, 0x1eda }, + { 0x1edc, 0x1edc }, + { 0x1ede, 0x1ede }, + { 0x1ee0, 0x1ee0 }, + { 0x1ee2, 0x1ee2 }, + { 0x1ee4, 0x1ee4 }, + { 0x1ee6, 0x1ee6 }, + { 0x1ee8, 0x1ee8 }, + { 0x1eea, 0x1eea }, + { 0x1eec, 0x1eec }, + { 0x1eee, 0x1eee }, + { 0x1ef0, 0x1ef0 }, + { 0x1ef2, 0x1ef2 }, + { 0x1ef4, 0x1ef4 }, + { 0x1ef6, 0x1ef6 }, + { 0x1ef8, 0x1ef8 }, + { 0x1f08, 0x1f0f }, + { 0x1f18, 0x1f1d }, + { 0x1f28, 0x1f2f }, + { 0x1f38, 0x1f3f }, + { 0x1f48, 0x1f4d }, + { 0x1f59, 0x1f59 }, + { 0x1f5b, 0x1f5b }, + { 0x1f5d, 0x1f5d }, + { 0x1f5f, 0x1f5f }, + { 0x1f68, 0x1f6f }, + { 0x1f88, 0x1f8f }, + { 0x1f98, 0x1f9f }, + { 0x1fa8, 0x1faf }, + { 0x1fb8, 0x1fbc }, + { 0x1fc8, 0x1fcc }, + { 0x1fd8, 0x1fdb }, + { 0x1fe8, 0x1fec }, + { 0x1ff8, 0x1ffc }, + { 0x2126, 0x2126 }, + { 0x212a, 0x212b }, + { 0x2160, 0x216f }, + { 0x24b6, 0x24cf }, + { 0xff21, 0xff3a }, + { 0x10400, 0x10425 } +}; +static const int table_wupper_count = + (sizeof(table_wupper)/sizeof(struct interval)); + + +/* ------------------- iswxdigit -------------------- */ +static const struct interval table_wxdigit[] = { + { 0x30, 0x39 }, + { 0x41, 0x46 }, + { 0x61, 0x66 } +}; +static const int table_wxdigit_count = + (sizeof(table_wxdigit)/sizeof(struct interval)); +#endif + +/* -------------------helper for wcwidth -------------------- */ + +/* From http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c + * - Non-spacing and enclosing combining characters (general + * category code Mn or Me in the Unicode database) have a + * column width of 0. + * + * - Other format characters (general category code Cf in the Unicode + * database) and ZERO WIDTH SPACE (U+200B) have a column width of 0. + * + * - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF) + * have a column width of 0. + * + * Edited based on the Unicode 8.0.0 tables at + * http://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt + */ + +static const struct interval zero_width[] = { + // added for our purposes, the Unicode control characters + { 0x0000, 0x001F }, { 0x007F, 0x009F }, + // the rest is incomplete for Unicode 8, but omissions are esoteric + { 0x0300, 0x036F }, { 0x0483, 0x0487 }, { 0x0488, 0x0489 }, // MK had 0486 + { 0x0591, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 }, + { 0x05C4, 0x05C5 }, { 0x05C7, 0x05C7 }, { 0x0600, 0x0603 }, + { 0x0610, 0x0615 }, { 0x064B, 0x065F }, { 0x0670, 0x0670 }, // MK had 065E + { 0x06D6, 0x06DD }, + { 0x06DF, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED }, + { 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A }, + { 0x07A6, 0x07B0 }, { 0x07EB, 0x07F3 }, + { 0x0816, 0x0819 }, { 0x081B, 0x0823 }, {0x0825, 0x0827 }, + { 0x0829, 0x082D }, { 0x0859, 0x085B }, {0x08E3, 0x08FF }, + { 0x0901, 0x0902 }, { 0x093A, 0x093A }, + { 0x093C, 0x093C }, { 0x0941, 0x0948 }, { 0x094D, 0x094D }, + { 0x0951, 0x0957 }, { 0x0962, 0x0963 }, { 0x0981, 0x0981 }, + { 0x09BC, 0x09BC }, { 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, + { 0x09E2, 0x09E3 }, { 0x0A01, 0x0A02 }, { 0x0A3C, 0x0A3C }, + { 0x0A41, 0x0A42 }, { 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, + { 0x0A70, 0x0A71 }, { 0x0A75, 0x0A75 }, { 0x0A81, 0x0A82 }, + { 0x0ABC, 0x0ABC }, + { 0x0AC1, 0x0AC5 }, { 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, + { 0x0AE2, 0x0AE3 }, { 0x0B01, 0x0B01 }, { 0x0B3C, 0x0B3C }, + { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 }, { 0x0B4D, 0x0B4D }, + { 0x0B56, 0x0B56 }, { 0x0B62, 0x0B63 }, { 0x0B82, 0x0B82 }, + { 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C00, 0x0C03 }, + { 0x0C3E, 0x0C40 }, { 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, + { 0x0C55, 0x0C56 }, { 0x0C62, 0x0C63 }, { 0x0C81, 0x0C81 }, + { 0x0CBC, 0x0CBC }, + { 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD }, + { 0x0CE2, 0x0CE3 }, { 0x0D41, 0x0D4D }, + { 0x0DCA, 0x0DCA }, { 0x0DCF, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, + { 0x0E31, 0x0E31 }, { 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, + { 0x0EB1, 0x0EB1 }, { 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, + { 0x0EC8, 0x0ECD }, { 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, + { 0x0F37, 0x0F37 }, { 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, + { 0x0F80, 0x0F84 }, { 0x0F86, 0x0F87 }, { 0x0F8D, 0x0F97 }, + { 0x0F99, 0x0FBC }, { 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, + { 0x1032, 0x1037 }, { 0x1039, 0x103A }, { 0x103D, 0x103E }, + { 0x1058, 0x1059 }, // several missing here + { 0x1160, 0x11FF }, { 0x135D, 0x135F }, + { 0x1712, 0x1714 }, { 0x1732, 0x1734 }, { 0x1752, 0x1753 }, + { 0x1772, 0x1773 }, { 0x17B4, 0x17BD }, + { 0x17C6, 0x17C6 }, { 0x17C9, 0x17D3 }, { 0x17DD, 0x17DD }, + { 0x180B, 0x180D }, { 0x18A9, 0x18A9 }, { 0x1920, 0x1922 }, + { 0x1927, 0x193B }, + { 0x1A17, 0x1A1B }, { 0x1B00, 0x1B03 }, { 0x1B34, 0x1B34 }, + { 0x1B36, 0x1B3A }, { 0x1B3C, 0x1B3C }, { 0x1B42, 0x1B42 }, + { 0x1B6B, 0x1B73 }, { 0x1DC0, 0x1DCA }, { 0x1DFE, 0x1DFF }, + { 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x2060, 0x2063 }, + { 0x206A, 0x206F }, { 0x20D0, 0x20EF }, { 0x302A, 0x302F }, + { 0x3099, 0x309A }, { 0xA806, 0xA806 }, { 0xA80B, 0xA80B }, + { 0xA825, 0xA826 }, { 0xFB1E, 0xFB1E }, { 0xFE00, 0xFE0F }, + { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF }, { 0xFFF9, 0xFFFB }, + { 0x10A01, 0x10A03 }, { 0x10A05, 0x10A06 }, { 0x10A0C, 0x10A0F }, + { 0x10A38, 0x10A3A }, { 0x10A3F, 0x10A3F }, { 0x1D167, 0x1D169 }, + { 0x1D173, 0x1D182 }, { 0x1D185, 0x1D18B }, { 0x1D1AA, 0x1D1AD }, + { 0x1D242, 0x1D244 }, { 0xE0001, 0xE0001 }, { 0xE0020, 0xE007F }, + { 0xE0100, 0xE01EF } + }; + +static const int +zero_width_count = (sizeof(zero_width)/sizeof(struct interval)); diff --git a/com.oracle.truffle.r.native/gnur/patch/src/main/xspline.c b/com.oracle.truffle.r.native/gnur/patch/src/main/xspline.c new file mode 100644 index 0000000000..d2cf5d8ba5 --- /dev/null +++ b/com.oracle.truffle.r.native/gnur/patch/src/main/xspline.c @@ -0,0 +1,544 @@ +/* + * Source code from Xfig 3.2.4 modified to work with arrays of doubles + * instead linked lists of F_points and to remove some globals(!) + * See copyright etc below. + * + * #included from engine.c + * That manages the R_alloc stack. + */ + +/* + * From w_drawprim.h + */ + +#define MAXNUMPTS 25000 + +/* + * From u_draw.c + */ + +/* + * FIG : Facility for Interactive Generation of figures + * Copyright (c) 1985-1988 by Supoj Sutanthavibul + * Parts Copyright (c) 1989-2002 by Brian V. Smith + * Parts Copyright (c) 1991 by Paul King + * Parts Copyright (c) 1992 by James Tough + * Parts Copyright (c) 1998 by Georg Stemmer + * Parts Copyright (c) 1995 by C. Blanc and C. Schlick + * + * Any party obtaining a copy of these files is granted, free of charge, a + * full and unrestricted irrevocable, world-wide, paid up, royalty-free, + * nonexclusive right and license to deal in this software and + * documentation files (the "Software"), including without limitation the + * rights to use, copy, modify, merge, publish and/or distribute copies of + * the Software, and to permit persons who receive copies from any such + * party to do so, with the only requirement being that this copyright + * notice remain intact. + * + */ + +/************** POLYGON/CURVE DRAWING FACILITIES ****************/ + +static int npoints; +static int max_points; +static double *xpoints; +static double *ypoints; + +/************* Code begins here *************/ + +/* R_allocs or mallocs global arrays */ +static Rboolean +add_point(double x, double y, pGEDevDesc dd) +{ + if (npoints >= max_points) { + int tmp_n; + double *tmp_px; + double *tmp_py; + tmp_n = max_points + 200; + /* too many points, return false */ + if (tmp_n > MAXNUMPTS) { + error(_("add_point - reached MAXNUMPTS (%d)"),tmp_n); + } + if (max_points == 0) { + tmp_px = (double *) R_alloc(tmp_n, sizeof(double)); + tmp_py = (double *) R_alloc(tmp_n, sizeof(double)); + } else { + tmp_px = (double *) S_realloc((char *) xpoints, + tmp_n, max_points, + sizeof(double)); + tmp_py = (double *) S_realloc((char *) ypoints, + tmp_n, max_points, + sizeof(double)); + } + if (tmp_px == NULL || tmp_py == NULL) { + error(_("insufficient memory to allocate point array")); + } + xpoints = tmp_px; + ypoints = tmp_py; + max_points = tmp_n; + } + /* ignore identical points */ + if (npoints > 0 && xpoints[npoints-1] == x && ypoints[npoints-1] == y) + return TRUE; + /* + * Convert back from 1200ppi to DEVICE coordinates + */ + xpoints[npoints] = toDeviceX(x / 1200, GE_INCHES, dd); + ypoints[npoints] = toDeviceY(y / 1200, GE_INCHES, dd); + npoints = npoints + 1; + return TRUE; +} + +/* + * From u_draw_spline.c + */ + +/* + * FIG : Facility for Interactive Generation of figures + * Copyright (c) 1985-1988 by Supoj Sutanthavibul + * Parts Copyright (c) 1989-2002 by Brian V. Smith + * Parts Copyright (c) 1991 by Paul King + * + * Any party obtaining a copy of these files is granted, free of charge, a + * full and unrestricted irrevocable, world-wide, paid up, royalty-free, + * nonexclusive right and license to deal in this software and + * documentation files (the "Software"), including without limitation the + * rights to use, copy, modify, merge, publish and/or distribute copies of + * the Software, and to permit persons who receive copies from any such + * party to do so, with the only requirement being that this copyright + * notice remain intact. + * + */ + +/* THIS FILE IS #included FROM u_draw.c and u_geom.c */ + +/********************* CURVES FOR SPLINES ***************************** + + The following spline drawing routines are from + + "X-splines : A Spline Model Designed for the End User" + + by Carole BLANC and Christophe SCHLICK, + in Proceedings of SIGGRAPH ' 95 + +***********************************************************************/ + +#define HIGH_PRECISION 0.5 +#define LOW_PRECISION 1.0 +#define ZOOM_PRECISION 5.0 +#define ARROW_START 4 +#define MAX_SPLINE_STEP 0.2 + +/***********************************************************************/ + +#define Q(s) (-(s)) +#define EQN_NUMERATOR(dim) \ + (A_blend[0]*dim[0]+A_blend[1]*dim[1]+A_blend[2]*dim[2]+A_blend[3]*dim[3]) + +static double +f_blend(double numerator, double denominator) +{ + double p = 2 * denominator * denominator; + double u = numerator / denominator; + double u2 = u * u; + + return (u * u2 * (10 - p + (2*p - 15)*u + (6 - p)*u2)); +} + +static double +g_blend(double u, double q) /* p equals 2 */ +{ + return(u*(q + u*(2*q + u*(8 - 12*q + u*(14*q - 11 + u*(4 - 5*q)))))); +} + +static double +h_blend(double u, double q) +{ + double u2=u*u; + return (u * (q + u * (2 * q + u2 * (-2*q - u*q)))); +} + +static void +negative_s1_influence(double t, double s1, double *A0, double *A2) +{ + *A0 = h_blend(-t, Q(s1)); + *A2 = g_blend(t, Q(s1)); +} + +static void +negative_s2_influence(double t, double s2, double *A1, double *A3) +{ + *A1 = g_blend(1-t, Q(s2)); + *A3 = h_blend(t-1, Q(s2)); +} + +static void +positive_s1_influence(double k, double t, double s1, double *A0, double *A2) +{ + double Tk; + + Tk = k+1+s1; + *A0 = (t+k+1<Tk) ? f_blend(t+k+1-Tk, k-Tk) : 0.0; + + Tk = k+1-s1; + *A2 = f_blend(t+k+1-Tk, k+2-Tk); +} + +static void +positive_s2_influence(double k, double t, double s2, double *A1, double *A3) +{ + double Tk; + + Tk = k+2+s2; + *A1 = f_blend(t+k+1-Tk, k+1-Tk); + + Tk = k+2-s2; + *A3 = (t+k+1>Tk) ? f_blend(t+k+1-Tk, k+3-Tk) : 0.0; +} + +static void +point_adding(double *A_blend, double *px, double *py, + pGEDevDesc dd) +{ + double weights_sum; + + weights_sum = A_blend[0] + A_blend[1] + A_blend[2] + A_blend[3]; + add_point(EQN_NUMERATOR(px) / (weights_sum), + EQN_NUMERATOR(py) / (weights_sum), + dd); +} + +static void +point_computing(double *A_blend, + double *px, double *py, + double *x, double *y) +{ + double weights_sum; + + weights_sum = A_blend[0] + A_blend[1] + A_blend[2] + A_blend[3]; + + *x = EQN_NUMERATOR(px) / (weights_sum); + *y = EQN_NUMERATOR(py) / (weights_sum); +} + +static double +step_computing(int k, + double *px, double *py, + double s1, double s2, + double precision, + pGEDevDesc dd) +{ + double A_blend[4]; + double xstart, ystart, xend, yend, xmid, ymid, xlength, ylength; + double start_to_end_dist, devWidth, devHeight, devDiag, number_of_steps; + double step, angle_cos, scal_prod, xv1, xv2, yv1, yv2, sides_length_prod; + + /* This function computes the step used to draw the segment (p1, p2) + (xv1, yv1) : coordinates of the vector from middle to origin + (xv2, yv2) : coordinates of the vector from middle to extremity */ + + if ((s1 == 0) && (s2 == 0)) + return(1.0); /* only one step in case of linear segment */ + + /* compute coordinates of the origin */ + if (s1>0) { + if (s2<0) { + positive_s1_influence(k, 0.0, s1, &A_blend[0], &A_blend[2]); + negative_s2_influence(0.0, s2, &A_blend[1], &A_blend[3]); + } else { + positive_s1_influence(k, 0.0, s1, &A_blend[0], &A_blend[2]); + positive_s2_influence(k, 0.0, s2, &A_blend[1], &A_blend[3]); + } + point_computing(A_blend, px, py, &xstart, &ystart); + } else { + xstart = px[1]; + ystart = py[1]; + } + + /* compute coordinates of the extremity */ + if (s2>0) { + if (s1<0) { + negative_s1_influence(1.0, s1, &A_blend[0], &A_blend[2]); + positive_s2_influence(k, 1.0, s2, &A_blend[1], &A_blend[3]); + } else { + positive_s1_influence(k, 1.0, s1, &A_blend[0], &A_blend[2]); + positive_s2_influence(k, 1.0, s2, &A_blend[1], &A_blend[3]); + } + point_computing(A_blend, px, py, &xend, ¥d); + } else { + xend = px[2]; + yend = py[2]; + } + + /* compute coordinates of the middle */ + if (s2>0) { + if (s1<0) { + negative_s1_influence(0.5, s1, &A_blend[0], &A_blend[2]); + positive_s2_influence(k, 0.5, s2, &A_blend[1], &A_blend[3]); + } else { + positive_s1_influence(k, 0.5, s1, &A_blend[0], &A_blend[2]); + positive_s2_influence(k, 0.5, s2, &A_blend[1], &A_blend[3]); + } + } else if (s1<0) { + negative_s1_influence(0.5, s1, &A_blend[0], &A_blend[2]); + negative_s2_influence(0.5, s2, &A_blend[1], &A_blend[3]); + } else { + positive_s1_influence(k, 0.5, s1, &A_blend[0], &A_blend[2]); + negative_s2_influence(0.5, s2, &A_blend[1], &A_blend[3]); + } + point_computing(A_blend, px, py, &xmid, &ymid); + + xv1 = xstart - xmid; + yv1 = ystart - ymid; + xv2 = xend - xmid; + yv2 = yend - ymid; + + scal_prod = xv1*xv2 + yv1*yv2; + + sides_length_prod = sqrt((xv1*xv1 + yv1*yv1)*(xv2*xv2 + yv2*yv2)); + + /* compute cosinus of origin-middle-extremity angle, which approximates the + curve of the spline segment */ + if (sides_length_prod == 0.0) + angle_cos = 0.0; + else + angle_cos = scal_prod/sides_length_prod; + + xlength = xend - xstart; + ylength = yend - ystart; + + start_to_end_dist = sqrt(xlength*xlength + ylength*ylength); + + /* Paul 2009-01-25 + * It is possible for origin and extremity to be very remote + * indeed (if the control points are located WAY off the device). + * In order to avoid having ridiculously many steps, limit + * the start_to_end_dist to being the length of the diagonal of the + * device. + */ + devWidth = fromDeviceWidth(toDeviceWidth(1, GE_NDC, dd), + GE_INCHES, dd)*1200; + devHeight = fromDeviceHeight(toDeviceHeight(1, GE_NDC, dd), + GE_INCHES, dd)*1200; + devDiag = sqrt(devWidth* devWidth + devHeight*devHeight); + if (start_to_end_dist > devDiag) + start_to_end_dist = devDiag; + + /* more steps if segment's origin and extremity are remote */ + number_of_steps = sqrt(start_to_end_dist)/2; + + /* more steps if the curve is high */ + number_of_steps += (int)((1 + angle_cos)*10); + + if (number_of_steps == 0) + step = 1; + else + step = precision/number_of_steps; + + if ((step > MAX_SPLINE_STEP) || (step == 0)) + step = MAX_SPLINE_STEP; + + return (step); +} + +static void +spline_segment_computing(double step, int k, + double *px, double *py, + double s1, double s2, + pGEDevDesc dd) +{ + double A_blend[4]; + double t; + + if (s1<0) { + if (s2<0) { + for (t=0.0 ; t<1 ; t+=step) { + negative_s1_influence(t, s1, &A_blend[0], &A_blend[2]); + negative_s2_influence(t, s2, &A_blend[1], &A_blend[3]); + + point_adding(A_blend, px, py, dd); + } + } else { + for (t=0.0 ; t<1 ; t+=step) { + negative_s1_influence(t, s1, &A_blend[0], &A_blend[2]); + positive_s2_influence(k, t, s2, &A_blend[1], &A_blend[3]); + + point_adding(A_blend, px, py, dd); + } + } + } else if (s2<0) { + for (t=0.0 ; t<1 ; t+=step) { + positive_s1_influence(k, t, s1, &A_blend[0], &A_blend[2]); + negative_s2_influence(t, s2, &A_blend[1], &A_blend[3]); + + point_adding(A_blend, px, py, dd); + } + } else { + for (t=0.0 ; t<1 ; t+=step) { + positive_s1_influence(k, t, s1, &A_blend[0], &A_blend[2]); + positive_s2_influence(k, t, s2, &A_blend[1], &A_blend[3]); + + point_adding(A_blend, px, py, dd); + } + } +} + +/* + * For adding last line segment when computing open spline + * WITHOUT end control points repeated + * (i.e., can't just connect to last control point) + */ +static void +spline_last_segment_computing(double step, int k, + double *px, double *py, + double s1, double s2, + pGEDevDesc dd) +{ + double A_blend[4]; + double t = 1; + + if (s1<0) { + if (s2<0) { + negative_s1_influence(t, s1, &A_blend[0], &A_blend[2]); + negative_s2_influence(t, s2, &A_blend[1], &A_blend[3]); + + point_adding(A_blend, px, py, dd); + } else { + negative_s1_influence(t, s1, &A_blend[0], &A_blend[2]); + positive_s2_influence(k, t, s2, &A_blend[1], &A_blend[3]); + + point_adding(A_blend, px, py, dd); + } + } else if (s2<0) { + positive_s1_influence(k, t, s1, &A_blend[0], &A_blend[2]); + negative_s2_influence(t, s2, &A_blend[1], &A_blend[3]); + + point_adding(A_blend, px, py, dd); + } else { + positive_s1_influence(k, t, s1, &A_blend[0], &A_blend[2]); + positive_s2_influence(k, t, s2, &A_blend[1], &A_blend[3]); + + point_adding(A_blend, px, py, dd); + } +} + +/********************* MAIN METHODS *************************************/ + +/* + * x and y are in DEVICE coordinates + * xfig works in 1200ppi + * (http://www.csit.fsu.edu/~burkardt/data/fig/fig_format.html) + * so convert to 1200ppi so that step calculations are correct + */ +#define COPY_CONTROL_POINT(PI, I, N) \ + px[PI] = fromDeviceX(x[(I) % N], GE_INCHES, dd) * 1200; \ + py[PI] = fromDeviceY(y[(I) % N], GE_INCHES, dd) * 1200; \ + ps[PI] = s[(I) % N] + +#define NEXT_CONTROL_POINTS(K, N) \ + COPY_CONTROL_POINT(0, K, N); \ + COPY_CONTROL_POINT(1, K + 1, N); \ + COPY_CONTROL_POINT(2, K + 2, N); \ + COPY_CONTROL_POINT(3, K + 3, N) + +#define INIT_CONTROL_POINTS(N) \ + COPY_CONTROL_POINT(0, N - 1, N); \ + COPY_CONTROL_POINT(1, 0, N); \ + COPY_CONTROL_POINT(2, 1, N); \ + COPY_CONTROL_POINT(3, 2, N) + +#define SPLINE_SEGMENT_LOOP(K, PX, PY, S1, S2, PREC) \ + step = step_computing(K, PX, PY, S1, S2, PREC, dd); \ + spline_segment_computing(step, K, PX, PY, S1, S2, dd) + +static Rboolean +compute_open_spline(int n, double *x, double *y, double *s, + Rboolean repEnds, + double precision, + pGEDevDesc dd) +{ + int k; + double step = 0.0 /* -Wall */; + double px[4]; + double py[4]; + double ps[4]={0.,0.,0.,0.}; + + max_points = 0; + npoints = 0; + xpoints = NULL; + ypoints = NULL; + + if (repEnds && n < 2) + error(_("there must be at least two control points")); + if (!repEnds && n < 4) + error(_("there must be at least four control points")); + + if (repEnds) { + /* first control point is needed twice for the first segment */ + COPY_CONTROL_POINT(0, 0, n); + COPY_CONTROL_POINT(1, 0, n); + COPY_CONTROL_POINT(2, 1, n); + + if (n == 2) { + COPY_CONTROL_POINT(3, 1, n); + } else { + COPY_CONTROL_POINT(3, 2, n); + } + + for (k = 0 ; ; k++) { + SPLINE_SEGMENT_LOOP(k, px, py, ps[1], ps[2], precision); + /* Paul 2008-12-05 + * >= rather than == to handle special case of n == 2 + */ + if (k + 3 >= n) + break; + NEXT_CONTROL_POINTS(k, n); + } + + /* last control point is needed twice for the last segment */ + COPY_CONTROL_POINT(0, n - 3, n); + COPY_CONTROL_POINT(1, n - 2, n); + COPY_CONTROL_POINT(2, n - 1, n); + COPY_CONTROL_POINT(3, n - 1, n); + SPLINE_SEGMENT_LOOP(k, px, py, ps[1], ps[2], precision); + + add_point(px[3], py[3], dd); + } else { + for (k = 0 ; k + 3 < n ; k++) { + NEXT_CONTROL_POINTS(k, n); + SPLINE_SEGMENT_LOOP(k, px, py, ps[1], ps[2], precision); + } + spline_last_segment_computing(step, n - 4, px, py, ps[1], ps[2], dd); + } + + return TRUE; +} + +static Rboolean +compute_closed_spline(int n, double *x, double *y, double *s, + double precision, + pGEDevDesc dd) +{ + int k; + double step; + double px[4]; + double py[4]; + double ps[4]; + + max_points = 0; + npoints = 0; + xpoints = NULL; + ypoints = NULL; + + if (n < 3) + error(_("There must be at least three control points")); + + INIT_CONTROL_POINTS(n); + + for (k = 0 ; k < n ; k++) { + SPLINE_SEGMENT_LOOP(k, px, py, ps[1], ps[2], precision); + NEXT_CONTROL_POINTS(k, n); + } + + return TRUE; +} diff --git a/com.oracle.truffle.r.native/gnur/sedEtcMakeconf b/com.oracle.truffle.r.native/gnur/sedEtcMakeconf deleted file mode 100644 index da16497888..0000000000 --- a/com.oracle.truffle.r.native/gnur/sedEtcMakeconf +++ /dev/null @@ -1,2 +0,0 @@ -/^BLAS_LIBS =.*/ w platform.mk.temp2 -/^LAPACK_LIBS =.*/ w platform.mk.temp2 diff --git a/com.oracle.truffle.r.native/gnur/sedMakeconf b/com.oracle.truffle.r.native/gnur/sedMakeconf index fb2c3c0640..c6839bf166 100644 --- a/com.oracle.truffle.r.native/gnur/sedMakeconf +++ b/com.oracle.truffle.r.native/gnur/sedMakeconf @@ -1,8 +1,10 @@ -/^CC =.*/ w platform.mk.temp1 -/^CFLAGS =.*/ w platform.mk.temp1 -/^DYLIB_.* =.*/ w platform.mk.temp1 -/^F77 =.*/ w platform.mk.temp1 -/^FFLAGS =.*/ w platform.mk.temp1 -/^FPICFLAGS =.*/ w platform.mk.temp1 -/^FLIBS_IN_SO =.*/ w platform.mk.temp1 -/^SHLIB_.* = .*/ w platform.mk.temp1 +/^CC =.*/ w platform.mk.temp +/^CFLAGS =.*/ w platform.mk.temp +/^DYLIB_.* =.*/ w platform.mk.temp +/^F77 =.*/ w platform.mk.temp +/^FFLAGS =.*/ w platform.mk.temp +/^FPICFLAGS =.*/ w platform.mk.temp +/^FLIBS_IN_SO =.*/ w platform.mk.temp +/^SHLIB_.* = .*/ w platform.mk.temp +/^BLAS_LIBS =.*/ w platform.mk.temp +/^LAPACK_LIBS =.*/ w platform.mk.temp diff --git a/com.oracle.truffle.r.native/include/Makefile b/com.oracle.truffle.r.native/include/Makefile index b4b5ba423b..b0311e0450 100644 --- a/com.oracle.truffle.r.native/include/Makefile +++ b/com.oracle.truffle.r.native/include/Makefile @@ -38,7 +38,7 @@ R_HEADERS := $(wildcard $(GNUR_HOME)/include/*.h) R_HEADERS_FILENAMES := $(notdir $(R_HEADERS)) #$(info R_HEADERS_FILENAMES=$(R_HEADERS_FILENAMES)) R_HEADERS_LOCAL := src/Rinternals.h src/Rinterface.h -#$(info R_HEADERS_LOCAL=$(R_HEADERS_LOCAL))> +#$(info R_HEADERS_LOCAL=$(R_HEADERS_LOCAL)) R_HEADERS_TO_LINK := $(filter-out $(notdir $(R_HEADERS_LOCAL)),$(R_HEADERS_FILENAMES)) #$(info R_HEADERS_TO_LINK=$(R_HEADERS_TO_LINK)) @@ -52,6 +52,7 @@ linked: # cp $(R_EXT_HEADERS_LOCAL) R_ext touch linked +$(info R_HEADERS_FILENAMES: $(R_HEADERS_FILENAMES)) clean: rm -rf include linked $(foreach file,$(R_HEADERS_FILENAMES),rm -f $(file);) diff --git a/com.oracle.truffle.r.native/library/grid/Makefile b/com.oracle.truffle.r.native/library/grid/Makefile deleted file mode 100644 index 4ef8f605d9..0000000000 --- a/com.oracle.truffle.r.native/library/grid/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -.PHONY: cleanpkg - -OBJ = lib - -GNUR_C_FILES := gpar.c just.c layout.c matrix.c register.c unit.c util.c viewport.c - -GNUR_GRID = $(addprefix $(GNUR_HOME)/src/library/grid/src/, grid.c) -GRID_OBJECT = $(addprefix $(OBJ)/, grid.o) - -GNUR_GRID_STATE = $(addprefix $(GNUR_HOME)/src/library/grid/src/, state.c) -GRID_STATE_OBJECT = $(addprefix $(OBJ)/, state.o) - -GNUR_C_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_C_FILES:.c=.o)) $(GRID_OBJECT) $(GRID_STATE_OBJECT) -LIB_PKG_PRE = $(GRID_OBJECT) $(GRID_STATE_OBJECT) -CLEAN_PKG := cleanpkg - -# This is necessary so that #include "grid.h" works -PKG_INCLUDES = -I $(GNUR_SRC) - -include ../lib.mk - -# Why is this necessary? Because if grid.c and state.c have been created by editing, -# lib.mk will include them in C_OBJECTS but they're already in GNUR_C_OBJECTS (uncreated case) -C_OBJECTS := $(filter-out $(GRID_OBJECT) $(GRID_STATE_OBJECT), $(C_OBJECTS)) - -$(C_OBJECTS): | $(OBJ) - -$(SRC)/grid.c: $(GNUR_GRID) src/sed_grid - sed -f src/sed_grid $(GNUR_GRID) > src/grid.c - -$(SRC)/state.c: $(GNUR_GRID_STATE) src/sed_state - sed -f src/sed_state $(GNUR_GRID_STATE) > src/state.c - -# obj files from c.o.t.r.n/library/grid/src are handled in lib.mk -# obj files from gnur to c.o.t.r.n/library/grid/lib are handled here -$(OBJ)/%.o: $(GNUR_SRC)/%.c - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ - -cleanpkg: - rm -f $(SRC)/grid.c $(SRC)/state.c diff --git a/com.oracle.truffle.r.native/library/grid/src/sed_grid b/com.oracle.truffle.r.native/library/grid/src/sed_grid deleted file mode 100644 index 705c960875..0000000000 --- a/com.oracle.truffle.r.native/library/grid/src/sed_grid +++ /dev/null @@ -1,10 +0,0 @@ -# L_initGrid gets environment from its caller, which is .External, and saves it -# into a static variable R_gridEvalEnv without calling R_PreserveObject. In the -# Gnu R world, the environment actually cannot be garbage collected, because it -# is grid's environment and there are references to it. -# -# Moreover, grid also uses this environment to "preserve" other objects just by -# adding them to that environment. See ed_state where we fix code doing this to -# also call R_PreserveObject and R_ReleaseObject. -# -#s/R_gridEvalEnv = \([[:alnum:]]*\);/R_gridEvalEnv = R_PreserveObject(\1);/g diff --git a/com.oracle.truffle.r.native/library/grid/src/sed_state b/com.oracle.truffle.r.native/library/grid/src/sed_state deleted file mode 100644 index 4db22d493e..0000000000 --- a/com.oracle.truffle.r.native/library/grid/src/sed_state +++ /dev/null @@ -1,18 +0,0 @@ -# see ed_grid for description of what is going on here. -# -# Note: the state cannot be 'preserved' in globaliseState(SEXP) -# function, which would seem as appropriate place, because the -# state is stored into a global variable before globaliseState -# is invoked. -# -# prepend R_PreserveObject call to any sd->systemSpecific assignment -# in form of sd->systemSpecific = (void*) variablename; -#s/sd->systemSpecific[[:space:]]*=[[:space:]]*(void\*)[[:space:]]*\([[:alnum:]_]*\);/\1 = R_PreserveObject(\1); sd->systemSpecific = (void*)\1;/g -# -# rename deglobaliseState to deglobaliseStateOriginal and prepend a -# new definition of deglobaliseState that calls R_ReleaseObject and -# the original function (note we need deglobaliseStateOriginal -# forward declaration) -#s/static void deglobaliseState(SEXP state)/static void deglobaliseStateOriginal(SEXP state);\ -#static void deglobaliseState(SEXP state) { deglobaliseStateOriginal(state); R_ReleaseObject(state); }\ -#static void deglobaliseStateOriginal(SEXP state)/g diff --git a/com.oracle.truffle.r.native/library/methods/Makefile b/com.oracle.truffle.r.native/library/methods/Makefile deleted file mode 100644 index 5f351596d4..0000000000 --- a/com.oracle.truffle.r.native/library/methods/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -OBJ = lib - -GNUR_C_FILES = init.c - -GNUR_C_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_C_FILES:.c=.o)) - -include ../lib.mk - -$(C_OBJECTS): | $(OBJ) - -$(OBJ)/%.o: $(GNUR_SRC)/%.c - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ diff --git a/com.oracle.truffle.r.native/library/parallel/Makefile b/com.oracle.truffle.r.native/library/parallel/Makefile deleted file mode 100644 index 5d2ca990c9..0000000000 --- a/com.oracle.truffle.r.native/library/parallel/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -OBJ = lib - -GNUR_C_FILES = init.c - -GNUR_C_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_C_FILES:.c=.o)) - -PKG_INCLUDES = -I $(GNUR_SRC) - -include ../lib.mk - -$(C_OBJECTS): | $(OBJ) - -$(OBJ)/%.o: $(GNUR_SRC)/%.c - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ diff --git a/com.oracle.truffle.r.native/library/parallel/RSHAREDnode.R b/com.oracle.truffle.r.native/library/parallel/RSHAREDnode.R deleted file mode 100644 index fb0c28ded5..0000000000 --- a/com.oracle.truffle.r.native/library/parallel/RSHAREDnode.R +++ /dev/null @@ -1,26 +0,0 @@ -makeSHAREDmaster <- function(key) { - channel <- .fastr.channel.get(as.integer(key)) - structure(list(channel=channel), class = "SHAREDnode") -} - -local({ - port <- "" - outfile <- Sys.getenv("R_SNOW_OUTFILE") ##**** defaults to ""; document - - args <- commandArgs() - pos <- match("--args", args) - args <- args[-(1 : pos)] - for (a in args) { - pos <- regexpr("=", a) - name <- substr(a, 1, pos - 1) - value <- substr(a,pos + 1, nchar(a)) - switch(name, - PORT = port <- value, - OUT = outfile <- value) - } - - if (port == "") port <- getClusterOption("port") - - parallel:::sinkWorkerOutput(outfile) - parallel:::slaveLoop(makeSHAREDmaster(port)) -}) diff --git a/com.oracle.truffle.r.native/library/parallel/src/glpi.h b/com.oracle.truffle.r.native/library/parallel/src/glpi.h deleted file mode 100644 index 4957b8aa71..0000000000 --- a/com.oracle.truffle.r.native/library/parallel/src/glpi.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Mingw.org headers are missing this */ - -typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP { - RelationProcessorCore, - RelationNumaNode, - RelationCache, - RelationProcessorPackage, - RelationGroup, - RelationAll=0xffff -} LOGICAL_PROCESSOR_RELATIONSHIP; - -typedef enum _PROCESSOR_CACHE_TYPE { - CacheUnified,CacheInstruction,CacheData,CacheTrace -} PROCESSOR_CACHE_TYPE; - -typedef struct _CACHE_DESCRIPTOR { - BYTE Level; - BYTE Associativity; - WORD LineSize; - DWORD Size; - PROCESSOR_CACHE_TYPE Type; -} CACHE_DESCRIPTOR,*PCACHE_DESCRIPTOR; - -typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION { - ULONG_PTR ProcessorMask; - LOGICAL_PROCESSOR_RELATIONSHIP Relationship; - union { - struct { - BYTE Flags; - } ProcessorCore; - struct { - DWORD NodeNumber; - } NumaNode; - CACHE_DESCRIPTOR Cache; - ULONGLONG Reserved[2]; - }; -} SYSTEM_LOGICAL_PROCESSOR_INFORMATION,*PSYSTEM_LOGICAL_PROCESSOR_INFORMATION; - -WINBASEAPI WINBOOL WINAPI -GetLogicalProcessorInformation(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION Buffer, - PDWORD ReturnedLength); diff --git a/com.oracle.truffle.r.native/library/parallel/src/rngstream.c b/com.oracle.truffle.r.native/library/parallel/src/rngstream.c deleted file mode 100644 index c39ff48825..0000000000 --- a/com.oracle.truffle.r.native/library/parallel/src/rngstream.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2011 The R Core Team. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, a copy is available at - * http://www.r-project.org/Licenses/ - */ - -#include "parallel.h" -#include <stdint.h> - -typedef uint_least64_t Uint64; - -static Uint64 A1p76[3][3] = { - { 82758667, 1871391091, 4127413238 }, - { 3672831523, 69195019, 1871391091 }, - { 3672091415, 3528743235, 69195019 } - }; - -static Uint64 A2p76[3][3] = { - { 1511326704, 3759209742, 1610795712 }, - { 4292754251, 1511326704, 3889917532 }, - { 3859662829, 4292754251, 3708466080 } - }; - -static Uint64 A1p127[3][3] = { - { 2427906178, 3580155704, 949770784 }, - { 226153695, 1230515664, 3580155704 }, - { 1988835001, 986791581, 1230515664 } - }; - -static Uint64 A2p127[3][3] = { - { 1464411153, 277697599, 1610723613 }, - { 32183930, 1464411153, 1022607788 }, - { 2824425944, 32183930, 2093834863 } - }; - -SEXP nextStream(SEXP x) -{ - Uint64 seed[6], nseed[6], tmp; - for (int i = 0; i < 6; i++) seed[i] = (unsigned int)INTEGER(x)[i+1]; - for (int i = 0; i < 3; i++) { - tmp = 0; - for(int j = 0; j < 3; j++) { - tmp += A1p127[i][j] * seed[j]; - tmp %= 4294967087; - } - nseed[i] = tmp; - } - for (int i = 0; i < 3; i++) { - tmp = 0; - for(int j = 0; j < 3; j++) { - tmp += A2p127[i][j] * seed[j+3]; - tmp %= 4294944443; - } - nseed[i+3] = tmp; - } - SEXP ans = allocVector(INTSXP, 7); - INTEGER(ans)[0] = INTEGER(x)[0]; - for (int i = 0; i < 6; i++) INTEGER(ans)[i+1] = (int) nseed[i]; - return ans; -} - -SEXP nextSubStream(SEXP x) -{ - Uint64 seed[6], nseed[6], tmp; - for (int i = 0; i < 6; i++) seed[i] = (unsigned int)INTEGER(x)[i+1]; - for (int i = 0; i < 3; i++) { - tmp = 0; - for(int j = 0; j < 3; j++) { - tmp += A1p76[i][j] * seed[j]; - tmp %= 4294967087; - } - nseed[i] = tmp; - } - for (int i = 0; i < 3; i++) { - tmp = 0; - for(int j = 0; j < 3; j++) { - tmp += A2p76[i][j] * seed[j+3]; - tmp %= 4294944443; - } - nseed[i+3] = tmp; - } - SEXP ans = allocVector(INTSXP, 7); - INTEGER(ans)[0] = INTEGER(x)[0]; - for (int i = 0; i < 6; i++) INTEGER(ans)[i+1] = (int) nseed[i]; - return ans; -} diff --git a/com.oracle.truffle.r.native/library/splines/src/splines.c b/com.oracle.truffle.r.native/library/splines/src/splines.c deleted file mode 100644 index ccfaecb2d1..0000000000 --- a/com.oracle.truffle.r.native/library/splines/src/splines.c +++ /dev/null @@ -1,246 +0,0 @@ -/* Routines for manipulating B-splines. These are intended for use with - * S or S-PLUS or R. - * - * Copyright (C) 1998 Douglas M. Bates and William N. Venables. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * These functions are distributed in the hope that they will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, a copy is available at - * http://www.r-project.org/Licenses/ - * - * The routines are loosely based on the pseudo-code in Schumacher (Wiley, - * 1981) and the CMLIB library DBSPLINES. - */ - -#include <R.h> -#include <Rinternals.h> - -#ifdef ENABLE_NLS -#include <libintl.h> -#define _(String) dgettext ("splines", String) -#else -#define _(String) (String) -#endif - -typedef struct spl_struct { - int order, /* order of the spline */ - ordm1, /* order - 1 (3 for cubic splines) */ - nknots, /* number of knots */ - curs, /* current position in knots vector */ - boundary; /* must have knots[curs] <= x < knots[curs+1] */ - /* except for the boundary case */ - - double *ldel, /* differences from knots on the left */ - *rdel, /* differences from knots on the right */ - *knots, /* knot vector */ - *coeff, /* coefficients */ - *a; /* scratch array */ -} *splPTR; - -/* Exports */ -SEXP spline_basis(SEXP knots, SEXP order, SEXP xvals, SEXP derivs); -SEXP spline_value(SEXP knots, SEXP coeff, SEXP order, SEXP x, SEXP deriv); - - -/* set sp->curs to the index of the first knot position > x. - Special handling for x == sp->knots[sp->nknots - sp-order + 1] */ -static int -set_cursor(splPTR sp, double x) -{ - int i; - /* don't assume x's are sorted */ - - sp->curs = -1; /* Wall */ - sp->boundary = 0; - for (i = 0; i < sp->nknots; i++) { - if (sp->knots[i] >= x) sp->curs = i; - if (sp->knots[i] > x) break; - } - if (sp->curs > sp->nknots - sp->order) { - int lastLegit = sp->nknots - sp->order; - if (x == sp->knots[lastLegit]) { - sp->boundary = 1; sp->curs = lastLegit; - } - } - return sp->curs; -} - -static void -diff_table(splPTR sp, double x, int ndiff) -{ - int i; - for (i = 0; i < ndiff; i++) { - sp->rdel[i] = sp->knots[sp->curs + i] - x; - sp->ldel[i] = x - sp->knots[sp->curs - (i + 1)]; - } -} - -/* fast evaluation of basis functions */ -static void -basis_funcs(splPTR sp, double x, double *b) -{ - int j, r; - double saved, term; - - diff_table(sp, x, sp->ordm1); - b[0] = 1.; - for (j = 1; j <= sp->ordm1; j++) { - saved = 0.; - for (r = 0; r < j; r++) { // FIXME: divides by zero - term = b[r]/(sp->rdel[r] + sp->ldel[j - 1 - r]); - b[r] = saved + sp->rdel[r] * term; - saved = sp->ldel[j - 1 - r] * term; - } - b[j] = saved; - } -} - -/* "slow" evaluation of (derivative of) basis functions */ -static double -evaluate(splPTR sp, double x, int nder) -{ - register double *lpt, *rpt, *apt, *ti = sp->knots + sp->curs; - int inner, outer = sp->ordm1; - - if (sp->boundary && nder == sp->ordm1) { /* value is arbitrary */ - return 0.0; - } - while(nder--) { // FIXME: divides by zero - for(inner = outer, apt = sp->a, lpt = ti - outer; inner--; apt++, lpt++) - *apt = outer * (*(apt + 1) - *apt)/(*(lpt + outer) - *lpt); - outer--; - } - diff_table(sp, x, outer); - while(outer--) - for(apt = sp->a, lpt = sp->ldel + outer, rpt = sp->rdel, inner = outer + 1; - inner--; lpt--, rpt++, apt++) - // FIXME: divides by zero - *apt = (*(apt + 1) * *lpt + *apt * *rpt)/(*rpt + *lpt); - return sp->a[0]; -} - -/* called from predict.bSpline() and predict.pbSpline() : */ -SEXP -spline_value(SEXP knots, SEXP coeff, SEXP order, SEXP x, SEXP deriv) -{ - SEXP val; - splPTR sp; - double *xx, *kk; - int der, i, n, nk; - - PROTECT(knots = coerceVector(knots, REALSXP)); - kk = REAL(knots); nk = length(knots); - PROTECT(coeff = coerceVector(coeff, REALSXP)); - PROTECT(x = coerceVector(x, REALSXP)); - n = length(x); - xx = REAL(x); - PROTECT(order = coerceVector(order, INTSXP)); - PROTECT(deriv = coerceVector(deriv, INTSXP)); - der = INTEGER(deriv)[0]; - PROTECT(val = allocVector(REALSXP, n)); - - /* populate the spl_struct */ - - sp = (struct spl_struct *) R_alloc(1, sizeof(struct spl_struct)); - sp->order = INTEGER(order)[0]; - if (sp->order <= 0) { error(_("'ord' must be a positive integer")); } - sp->ordm1 = sp->order - 1; - sp->ldel = (double *) R_alloc(sp->ordm1, sizeof(double)); - sp->rdel = (double *) R_alloc(sp->ordm1, sizeof(double)); - sp->knots = kk; sp->nknots = nk; - sp->coeff = REAL(coeff); - sp->a = (double *) R_alloc(sp->order, sizeof(double)); - - for (i = 0; i < n; i++) { - set_cursor(sp, xx[i]); - if (sp->curs < sp->order || sp->curs > (nk - sp->order)) { - REAL(val)[i] = R_NaN; - } else { - Memcpy(sp->a, REAL(coeff) + sp->curs - sp->order, sp->order); - REAL(val)[i] = evaluate(sp, xx[i], der); - } - } - UNPROTECT(6); - return val; -} - -/* called from splineDesign() : */ -SEXP -spline_basis(SEXP knots, SEXP order, SEXP xvals, SEXP derivs) -{ -/* evaluate the non-zero B-spline basis functions (or their derivatives) - * at xvals. */ - int nd, nk, nx, i, j, *ders; - double *kk, *xx; - SEXP val, offsets; - splPTR sp = (struct spl_struct *) R_alloc(1, sizeof(struct spl_struct)); - - PROTECT(knots = coerceVector(knots, REALSXP)); - kk = REAL(knots); nk = length(knots); - PROTECT(order = coerceVector(order, INTSXP)); - PROTECT(xvals = coerceVector(xvals, REALSXP)); - xx = REAL(xvals); nx = length(xvals); - PROTECT(derivs = coerceVector(derivs, INTSXP)); - ders = INTEGER(derivs); nd = length(derivs); - - /* fill sp : */ - sp->order = INTEGER(order)[0]; - sp->ordm1 = sp->order - 1; - sp->rdel = (double *) R_alloc(sp->ordm1, sizeof(double)); - sp->ldel = (double *) R_alloc(sp->ordm1, sizeof(double)); - sp->knots = kk; sp->nknots = nk; - sp->a = (double *) R_alloc(sp->order, sizeof(double)); - PROTECT(val = allocMatrix(REALSXP, sp->order, nx)); - PROTECT(offsets = allocVector(INTSXP, nx)); - - for(i = 0; i < nx; i++) { - set_cursor(sp, xx[i]); - INTEGER(offsets)[i] = j = sp->curs - sp->order; - if (j < 0 || j > nk) { - for (j = 0; j < sp->order; j++) { - REAL(val)[i * sp->order + j] = R_NaN; - } - } else { - if (ders[i % nd] > 0) { /* slow method for derivatives */ - int ii; - for(ii = 0; ii < sp->order; ii++) { - for(j = 0; j < sp->order; j++) sp->a[j] = 0; - sp->a[ii] = 1; - REAL(val)[i * sp->order + ii] = - evaluate(sp, xx[i], ders[i % nd]); - } - } else { /* fast method for value */ - basis_funcs(sp, xx[i], REAL(val) + i * sp->order); - } - } - } - setAttrib(val, install("Offsets"), offsets); - UNPROTECT(6); - return val; -} - -#include <R_ext/Rdynload.h> - -const static R_CallMethodDef R_CallDef[] = { - {"spline_basis", (DL_FUNC)&spline_basis, 4}, - {"spline_value", (DL_FUNC)&spline_value, 5}, - {NULL, NULL, 0} -}; - - -void -R_init_splines(DllInfo *dll) -{ - R_registerRoutines(dll, NULL, R_CallDef, NULL, NULL); - R_useDynamicSymbols(dll, FALSE); -// R_forceSymbols(dll, TRUE); // too few to worry about, used in cobs* -} diff --git a/com.oracle.truffle.r.native/library/stats/Makefile b/com.oracle.truffle.r.native/library/stats/Makefile deleted file mode 100644 index 70d012c0e1..0000000000 --- a/com.oracle.truffle.r.native/library/stats/Makefile +++ /dev/null @@ -1,74 +0,0 @@ -# -# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# -# Completeness of the stats package is a work in progress -# Currently we compile a subset of the .c and .f files from the -# GnuR stats library source - those that do not depend on GnuR internals (always true for .f) -# Also do some necessary modifications to a copy of fft.c. - -.PHONY: cleanpkg - -GNUR_FFT = $(addprefix $(GNUR_HOME)/src/library/stats/src/, fft.c) -FFT_OBJECT = $(addprefix $(OBJ)/, fft.o) -LIB_PKG_PRE = $(FFT_OBJECT) -CLEAN_PKG := cleanpkg - - -# have to include this here for PKG_LIBS -ifneq ($(MAKECMDGOALS),clean) -include $(TOPDIR)/platform.mk -endif - -PKG_LIBS := $(LAPACK_LIBS) $(BLAS_LIBS) -L$(FASTR_LIB_DIR) $(FLIBS) -PKG_INCLUDES = -I $(GNUR_SRC) - -OBJ = lib - -GNUR_F_FILES = bsplvd.f bvalue.f bvalus.f eureka.f hclust.f kmns.f lminfl.f loessf.f ppr.f qsbart.f sgram.f \ - sinerp.f sslvrg.f stl.f stxwx.f - -GNUR_F_OBJECTS = $(addprefix $(OBJ)/, $(GNUR_F_FILES:.f=.o)) - -GNUR_C_FILES = init.c isoreg.c kmeans.c loessc.c monoSpl.c sbart.c - -GNUR_C_OBJECTS := $(addprefix $(OBJ)/, $(GNUR_C_FILES:.c=.o)) $(FFT_OBJECT) - -include ../lib.mk - -# Why is this necessary? Because if fft.c has been created by editing, lib.mk will -# include it in C_OBJECTS but it's already in GNUR_C_OBJECTS (uncreated case) -C_OBJECTS := $(filter-out $(FFT_OBJECT), $(C_OBJECTS)) - -$(C_OBJECTS): | $(OBJ) - -$(SRC)/fft.c: $(GNUR_FFT) src/ed_fft - ed $(GNUR_FFT) < src/ed_fft - -$(OBJ)/%.o: $(GNUR_SRC)/%.c - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ - -$(OBJ)/%.o: $(GNUR_SRC)/%.f - $(F77) $(FFLAGS) $(FPICFLAGS) -c $< -o $@ - -cleanpkg: - rm -f $(SRC)/fft.c diff --git a/com.oracle.truffle.r.native/library/stats/src/ed_fft b/com.oracle.truffle.r.native/library/stats/src/ed_fft deleted file mode 100644 index 2e90457178..0000000000 --- a/com.oracle.truffle.r.native/library/stats/src/ed_fft +++ /dev/null @@ -1,33 +0,0 @@ -/HAVE_CONFIG.H/ -s!^!//! -+1 -s!^!//! -+1 -s!^!//! -/include <Rmath.h>/ -s!^!//! -+1 -s!^!//! -a -#define imax2(_x,_y) ((_x<_y) ? _y : _x) -#define imin2(_x,_y) ((_x<_y) ? _x : _y) -#define Rboolean int -#define FALSE 0 -#define TRUE 1 -#define M_SQRT_3 1.732050807568877293527446341506 -. -/^void fft_factor(int n/ -/fft_work(double/ -d -i -// signature modification: -// we need to do pointer shift for imaginary parts on the callee side (below) -// rather than on the caller side as in GNU R -Rboolean fft_work(double *a, int nseg, int n, int nspn, int isn, -. -/int nf/ -i - double *b=&(a[1]); -. - -w src/fft.c diff --git a/com.oracle.truffle.r.native/library/stats/src/modreg.h b/com.oracle.truffle.r.native/library/stats/src/modreg.h deleted file mode 100644 index 86b634d03b..0000000000 --- a/com.oracle.truffle.r.native/library/stats/src/modreg.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2001-2 The R Core Team. - * Copyright (C) 2003 The R Foundation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, a copy is available at - * http://www.r-project.org/Licenses/ - */ - -#ifndef R_MODREG_H -#define R_MODREG_H - -#include <R.h> -#include <Rinternals.h> -#ifdef ENABLE_NLS -#include <libintl.h> -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif - -SEXP isoreg(SEXP y); - -/* monoSpl.c : */ -SEXP monoFC_m(SEXP m, SEXP Sx); -void monoFC_mod(double *m, double Sx[], int n); - -void -loess_raw(double *y, double *x, double *weights, double *robust, int *d, - int *n, double *span, int *degree, int *nonparametric, - int *drop_square, int *sum_drop_sqr, double *cell, - char **surf_stat, double *surface, int *parameter, - int *a, double *xi, double *vert, double *vval, double *diagonal, - double *trL, double *one_delta, double *two_delta, int *setLf); -void -loess_dfit(double *y, double *x, double *x_evaluate, double *weights, - double *span, int *degree, int *nonparametric, - int *drop_square, int *sum_drop_sqr, - int *d, int *n, int *m, double *fit); -void -loess_dfitse(double *y, double *x, double *x_evaluate, double *weights, - double *robust, int *family, double *span, int *degree, - int *nonparametric, int *drop_square, - int *sum_drop_sqr, - int *d, int *n, int *m, double *fit, double *L); -void -loess_ifit(int *parameter, int *a, double *xi, double *vert, - double *vval, int *m, double *x_evaluate, double *fit); -void -loess_ise(double *y, double *x, double *x_evaluate, double *weights, - double *span, int *degree, int *nonparametric, - int *drop_square, int *sum_drop_sqr, double *cell, - int *d, int *n, int *m, double *fit, double *L); - -void kmeans_Lloyd(double *x, int *pn, int *pp, double *cen, int *pk, int *cl, - int *pmaxiter, int *nc, double *wss); - -void kmeans_MacQueen(double *x, int *pn, int *pp, double *cen, int *pk, - int *cl, int *pmaxiter, int *nc, double *wss); - -/* Fortran : */ - -void F77_SUB(lowesw)(double *res, int *n, double *rw, int *pi); -void F77_SUB(lowesp)(int *n, double *y, double *yhat, double *pwgts, - double *rwgts, int *pi, double *ytilde); -void F77_SUB(setppr)(double *span1, double *alpha1, - int *optlevel, int *ism, double *df1, double *gcvpen1); -void F77_SUB(smart)(int *m, int *mu, int *p, int * q, int *n, - double *w, double *x, double *y, - double *ww, double *smod, int *nsmod, double *sp, - int *nsp, double *dp, int *ndp, double *edf); -void F77_SUB(setsmu)(void); -void F77_SUB(pppred)(int *np, double *x, double *smod, - double *y, double *sc); -void F77_SUB(rbart)(double *penalt, double *dofoff, - double *xs, double *ys, double *ws, double *ssw, - int *n, double *knot, int *nk, double *coef, - double *sz, double *lev, double *crit, int *iparms, - double *spar, double *parms, - double *scrtch, int *ld4, int *ldnk, int *ier); - -void F77_NAME(sbart) - (double *penalt, double *dofoff, - double *xs, double *ys, double *ws, double *ssw, - int *n, double *knot, int *nk, double *coef, - double *sz, double *lev, double *crit, int *icrit, - double *spar, int *ispar, int *iter, double *lspar, - double *uspar, double *tol, double *eps, int *isetup, - double *xwy, double *hs0, double *hs1, double *hs2, - double *hs3, double *sg0, double *sg1, double *sg2, - double *sg3, double *abd, double *p1ip, double *p2ip, - int *ld4, int *ldnk, int *ier); - -void F77_NAME(sgram)(double *sg0, double *sg1, double *sg2, double *sg3, - double *tb, int *nb); -void F77_NAME(stxwx)(double *x, double *z, double *w, - int *k, double *xknot, int *n, double *y, - double *hs0, double *hs1, double *hs2, double *hs3); -void F77_NAME(sslvrg)(double *penalt, double *dofoff, - double *x, double *y, double *w, double *ssw, int *n, - double *knot, int *nk, double *coef, double *sz, - double *lev, double *crit, int *icrit, double *lambda, - double *xwy, - double *hs0, double *hs1, double *hs2, double *hs3, - double *sg0, double *sg1, double *sg2, double *sg3, - double *abd, double *p1ip, double *p2ip, - int *ld4, int *ldnk, int *info); - -void F77_SUB(bvalus)(int *n, double *knot, double *coef, - int *nk, double *x, double *s, int *order); -void F77_SUB(supsmu)(int *n, double *x, double *y, - double *w, int *iper, double *span, double *alpha, - double *smo, double *sc, double *edf); -#endif diff --git a/com.oracle.truffle.r.native/library/stats/src/port.h b/com.oracle.truffle.r.native/library/stats/src/port.h deleted file mode 100644 index d8e9dd172e..0000000000 --- a/com.oracle.truffle.r.native/library/stats/src/port.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2005 The R Core Team. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, a copy is available at - * http://www.r-project.org/Licenses/ - */ - -#ifndef PORT_PORT_H -#define PORT_PORT_H - -/* Header file for the C utilities to accompany the Fortran - * optimization routines for the port library. - * - * Copyright (C) 2005-5 the R Core Team - * Licensed under the GNU General Public License, version 2 or later. - */ - -#include <Rinternals.h> -#include <R_ext/RS.h> - -#ifdef ENABLE_NLS -#include <libintl.h> -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif - -/* PORT interface functions - reverse communication */ - -/* DRMNF(D, FX, IV, LIV, LV, N, V, X) */ -void F77_NAME(drmnf)(double d[], double *fx, - int iv[], int *liv, int *lv, int *n, double v[], double x[]); - -/* DRMNG(D, FX, G, IV, LIV, LV, N, V, X) */ -void F77_NAME(drmng)(double d[], double *fx, double g[], - int iv[], int *liv, int *lv, int *n, double v[], double x[]); - -/* DRMNH(D, FX, G, H, IV, LH, LIV, LV, N, V, X) */ -void F77_NAME(drmnh)(double d[], double *fx, double g[], double h[], - int iv[], int *lh, int *liv, int *lv, int *n, double v[], double x[]); - -/* DRMNFB(B, D, FX, IV, LIV, LV, N, V, X) */ -void F77_NAME(drmnfb)(double b[], double d[], double *fx, - int *liv, int *lv, int *n, double v[], double x[]); - -/* DRMNGB(B, D, FX, G, IV, LIV, LV, N, V, X) */ -void F77_NAME(drmngb)(double b[], double d[], double *fx, double g[], - int iv[], int *liv, int *lv, int *n, double v[], double x[]); - -/* DRMNH(B, D, FX, G, H, IV, LH, LIV, LV, N, V, X) */ -void F77_NAME(drmnhb)(double b[], double d[], double *fx, double g[], double h[], - int iv[], int *lh, int *liv, int *lv, int *n, double v[], double x[]); - -/* DRN2GB(B, D, DR, IV, LIV, LV, N, ND, N1, N2, P, R, RD, V, X) */ -void F77_NAME(drn2gb)(double b[], double d[], double dr[], - int iv[], int *liv, int *lv, int *n, int *nd, int *n1, int *n2, int *p, - double r[], double rd[], double v[], double x[]); - -/* DRN2G(D, DR, IV, LIV, LV, N, ND, N1, N2, P, R, RD, V, X) */ -void F77_NAME(drn2g)(double d[], double dr[], - int iv[], int *liv, int *lv, int *n, int *nd, int *n1, int *n2, int *p, - double r[], double rd[], double v[], double x[]); - -/* DRNSGB(A, ALF, B, C, DA, IN, IV, L, L1, LA, LIV, LV, N, NDA, P, V, Y) */ -void F77_NAME(drnsgb)(double a[], double alf[], double b[], double c [], double da[], - int in[], int iv[], int *l, int *l1, int *la, int *liv, - int *lv, int *n, int *nda, int *p, - double v[], double y[]); - -/* DRNSG(A, ALF, C, DA, IN, IV, L, L1, LA, LIV, LV, N, NDA, P, V, Y) */ -void F77_NAME(drnsg)(double a[], double alf[], double c[], double da[], - int in[], int iv[], int *l, int *l1, int *la, int *liv, - int *lv, int *n, int *nda, int *p, - double v[], double y[]); - -SEXP port_ivset(SEXP kind, SEXP iv, SEXP v) { return NULL; } - -SEXP port_nlminb(SEXP fn, SEXP gr, SEXP hs, SEXP rho, - SEXP lowerb, SEXP upperb, SEXP d, SEXP iv, SEXP v) { return NULL; } - -SEXP port_nlsb(SEXP m, SEXP d, SEXP gg, SEXP iv, SEXP v, - SEXP lowerb, SEXP upperb) { return NULL; } - -void Rf_divset(int alg, int iv[], int liv, int lv, double v[]) { } - -void -nlminb_iterate(double b[], double d[], double fx, double g[], double h[], - int iv[], int liv, int lv, int n, double v[], double x[]) { } - -void -nlsb_iterate(double b[], double d[], double dr[], int iv[], int liv, - int lv, int n, int nd, int p, double r[], double rd[], - double v[], double x[]) { } - -#endif diff --git a/com.oracle.truffle.r.native/library/stats/src/stats.h b/com.oracle.truffle.r.native/library/stats/src/stats.h deleted file mode 100644 index 9b69416e68..0000000000 --- a/com.oracle.truffle.r.native/library/stats/src/stats.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2005-12 The R Core Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, a copy is available at - * http://www.r-project.org/Licenses/ - */ - -#ifndef R_STATS_H -#define R_STATS_H - -/* definitions not involving SEXPs, plus _() */ - -#ifdef ENABLE_NLS -//#include <libintl.h> -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif - -#include <R_ext/RS.h> -void -F77_SUB(hclust)(int *n, int *len, int *iopt, int *ia, int *ib, - double *crit, double *membr, int *nn, - double *disnn, int *flag, double *diss); - -void -F77_SUB(hcass2)(int *n, int *ia, int *ib, int *iorder, int *iia, int *iib); - -void -F77_SUB(kmns)(double *a, int *m, int *n, double *c, int *k, - int *ic1, int *ic2, int *nc, double * an1, double *an2, - int *ncp, double *d, int *itran, - int *live, int *iter, double *wss, int *ifault); - - -void rcont2(int *nrow, int *ncol, int *nrowt, int *ncolt, int *ntotal, - double *fact, int *jwork, int *matrix) { } - -#endif diff --git a/com.oracle.truffle.r.native/run/Makefile b/com.oracle.truffle.r.native/run/Makefile index b793c3585c..4f6aa77dec 100644 --- a/com.oracle.truffle.r.native/run/Makefile +++ b/com.oracle.truffle.r.native/run/Makefile @@ -43,15 +43,15 @@ FASTR_ETC_DIR := $(FASTR_R_HOME)/etc FASTR_SHARE_DIR := $(FASTR_R_HOME)/share FASTR_INCLUDE_DIR := $(FASTR_R_HOME)/include -R_SCRIPT := $(addprefix $(GNUR_HOME)/bin/,R) -BIN_FILES := $(wildcard $(GNUR_HOME)/bin/*) +R_SCRIPT := $(addprefix $(GNUR_HOME_BINARY)/bin/,R) +BIN_FILES := $(wildcard $(GNUR_HOME_BINARY)/bin/*) -DOC_FILES := $(wildcard $(GNUR_HOME)/doc/*) +DOC_FILES := $(wildcard $(GNUR_HOME_BINARY)/doc/*) # Not all of these work unchanged -ETC_FILES := $(addprefix $(GNUR_HOME)/etc/,javaconf ldpaths Renviron repositories) +ETC_FILES := $(addprefix $(GNUR_HOME_BINARY)/etc/,javaconf ldpaths Renviron repositories) -SHARE_FILES := $(addprefix $(GNUR_HOME)/share/,R Rd make java encodings) +SHARE_FILES := $(addprefix $(GNUR_HOME_BINARY)/share/,R Rd make java encodings) LLVM_TOOLS := $(wildcard $(FASTR_NATIVE_DIR)/llvm_tools/*) @@ -81,11 +81,11 @@ $(FASTR_BIN_DIR)/R: Makefile R.sh Rscript.sh Rscript_exec.sh Rclasspath.sh (sed -e 's!^\(R_HOME_DIR=\)\(.*\)!\1"$(FASTR_R_HOME)"!' | sed -e 's/ -h.--help./ --r-help\)/') < $(R_SCRIPT) > $(FASTR_BIN_DIR)/R chmod +x $(FASTR_BIN_DIR)/R touch $(FASTR_ETC_DIR)/ldpaths - sed -e "s|\(R_LIBS_USER=.*-'\)\(.*\)'}|\1$(FASTR_R_HOME)/library'}|" < $(GNUR_HOME)/etc/Renviron > $(FASTR_ETC_DIR)/Renviron - cp $(GNUR_HOME)/etc/Makeconf Makeconf.etc - cp $(GNUR_HOME)/etc/javaconf $(FASTR_ETC_DIR)/javaconf - cp $(GNUR_HOME)/etc/repositories $(FASTR_ETC_DIR)/repositories - cp $(GNUR_HOME)/etc/ldpaths $(FASTR_ETC_DIR)/ldpaths + sed -e "s|\(R_LIBS_USER=.*-'\)\(.*\)'}|\1$(FASTR_R_HOME)/library'}|" < $(GNUR_HOME_BINARY)/etc/Renviron > $(FASTR_ETC_DIR)/Renviron + cp $(GNUR_HOME_BINARY)/etc/Makeconf Makeconf.etc + cp $(GNUR_HOME_BINARY)/etc/javaconf $(FASTR_ETC_DIR)/javaconf + cp $(GNUR_HOME_BINARY)/etc/repositories $(FASTR_ETC_DIR)/repositories + cp $(GNUR_HOME_BINARY)/etc/ldpaths $(FASTR_ETC_DIR)/ldpaths ed Makeconf.etc < edMakeconf.etc ifeq ($(FASTR_RFFI),llvm) ed Makeconf.etc < edMakeconf.etc.llvm diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java index 1300b87938..50b30322b0 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java @@ -40,6 +40,7 @@ import java.util.TimeZone; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.vm.PolyglotEngine; import com.oracle.truffle.r.launcher.RCmdOptions; +import com.oracle.truffle.r.launcher.RVersionNumber; import com.oracle.truffle.r.launcher.RCmdOptions.RCmdOption; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.ffi.BaseRFFI; @@ -140,12 +141,18 @@ public final class REnvVars implements RContext.ContextState { } private static final String R_HOME = "R_HOME"; + private static final String GNUR_R_HOME = "GNUR_HOME_BINARY"; /** * Cached value of {@code R_HOME}. */ private static String rHome; + /** + * Cached value of {@code GNUR_HOME}. + */ + private static String gnurHome; + /** * Returns a file that serves to distinguish a FastR {@code R_HOME}. */ @@ -176,6 +183,20 @@ public final class REnvVars implements RContext.ContextState { return rHome; } + /** + * @return the original GNUR home directory. This directory is needed for building FastR and + * testing. + */ + public static String gnurHome() { + if (gnurHome == null) { + gnurHome = System.getenv(GNUR_R_HOME); + if (gnurHome == null) { + gnurHome = FileSystems.getDefault().getPath(REnvVars.rHome(), "libdownloads", RVersionNumber.R_HYPHEN_FULL).toString(); + } + } + return gnurHome; + } + private static final CodeSource codeSource = REnvVars.class.getProtectionDomain().getCodeSource(); /** diff --git a/com.oracle.truffle.r.test.native/packages/Makefile b/com.oracle.truffle.r.test.native/packages/Makefile index 501b4d81f6..80eaa9284f 100644 --- a/com.oracle.truffle.r.test.native/packages/Makefile +++ b/com.oracle.truffle.r.test.native/packages/Makefile @@ -24,10 +24,14 @@ .PHONY: all clean make_subdirs clean_subdirs clean_recommended SUBDIRS = testrffi vanilla tests4 -NATIVE_PROJECT = $(subst test.native,native,$(TOPDIR)) -R_VERSION := $(notdir $(wildcard $(NATIVE_PROJECT)/gnur/R-*)) -export GNUR_HOME := $(NATIVE_PROJECT)/gnur/$(R_VERSION) -GNUR_RECOMMENDED := $(wildcard $(GNUR_HOME)/src/library/Recommended/*.tgz) +NATIVE_RECOMMENDED_PROJECT = $(subst test.native,native.recommended,$(TOPDIR)) +ifndef GNUR_HOME_BINARY +FASTR_R_HOME = $(abspath $(TOPDIR)/..) +R_VERSION = $(subst R-,,$(notdir $(basename $(basename $(wildcard $(FASTR_R_HOME)/libdownloads/R-*.gz))))) +export GNUR_HOME_BINARY = $(FASTR_R_HOME)/libdownloads/R-$(R_VERSION) +$(info GNUR_HOME_BINARY not set. Assuming the default location at $(GNUR_HOME_BINARY)) +endif +GNUR_RECOMMENDED := $(wildcard $(GNUR_HOME_BINARY)/src/library/Recommended/*.tgz) # We have to copy the GNU R recommended packages into this project # to keep the mx archiver happy, which asserts that every path diff --git a/com.oracle.truffle.r.test.native/packages/package.mk b/com.oracle.truffle.r.test.native/packages/package.mk index e98e4d3f6d..f1eec60a19 100644 --- a/com.oracle.truffle.r.test.native/packages/package.mk +++ b/com.oracle.truffle.r.test.native/packages/package.mk @@ -45,11 +45,11 @@ TEMPLATE_FILE := ../Rutils/template.R all: $(RIN_R_FILES) $(PKG_TAR) $(PKG_TAR): $(PKG_FILES) - (cd $(REPO_DIR); TZDIR=/usr/share/zoneinfo/ $(GNUR_HOME)/bin/R CMD build $(CURDIR)/$(PACKAGE)) + (cd $(REPO_DIR); TZDIR=/usr/share/zoneinfo/ $(GNUR_HOME_BINARY)/bin/R CMD build $(CURDIR)/$(PACKAGE)) $(RIN_R_FILES): $(RIN_FILES) for rf in $(RIN_FILES); do \ - TEMPLATE_FILE=$(TEMPLATE_FILE) $(GNUR_HOME)/bin/Rscript $$rf $$rf || exit 1; \ + TEMPLATE_FILE=$(TEMPLATE_FILE) $(GNUR_HOME_BINARY)/bin/Rscript $$rf $$rf || exit 1; \ done clean: diff --git a/com.oracle.truffle.r.test.packages/r/install.packages.R b/com.oracle.truffle.r.test.packages/r/install.packages.R index 799db01552..2c13fef37b 100644 --- a/com.oracle.truffle.r.test.packages/r/install.packages.R +++ b/com.oracle.truffle.r.test.packages/r/install.packages.R @@ -751,7 +751,11 @@ gnu_rscript <- function() { } else { rv <- R.Version() dirv <- paste0('R-', rv$major, '.', rv$minor) - file.path("com.oracle.truffle.r.native/gnur", dirv, 'bin', 'Rscript') + gnurHome <- Sys.getenv("GNUR_HOME_BINARY") + if (gnurHome == "") { + gnurHome <- "libdownloads" + } + file.path(gnurHome, dirv, 'bin', 'Rscript') } } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/GnuROneShotRSession.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/GnuROneShotRSession.java index bc65c7c631..26d783f600 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/GnuROneShotRSession.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/generate/GnuROneShotRSession.java @@ -76,8 +76,7 @@ public class GnuROneShotRSession implements RSession { } String testGenGnuR = System.getenv(FASTR_TESTGEN_GNUR); if (testGenGnuR == null || testGenGnuR.equals("internal")) { - Path gnuRPath = FileSystems.getDefault().getPath(REnvVars.rHome(), NATIVE_PROJECT, "gnur", RVersionNumber.R_HYPHEN_FULL, "bin", "R"); - GNUR_COMMANDLINE[0] = gnuRPath.toString(); + GNUR_COMMANDLINE[0] = FileSystems.getDefault().getPath(REnvVars.gnurHome(), "bin", "R").toString(); } else { GNUR_COMMANDLINE[0] = FileSystems.getDefault().getPath(testGenGnuR, "bin", "R").toString(); } diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tools/RBuiltinCheck.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tools/RBuiltinCheck.java index bc922bc30e..e30cf3a0a3 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tools/RBuiltinCheck.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tools/RBuiltinCheck.java @@ -25,6 +25,7 @@ package com.oracle.truffle.r.test.tools; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; import java.util.EnumSet; @@ -39,9 +40,9 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; -import com.oracle.truffle.r.launcher.RVersionNumber; import com.oracle.truffle.r.nodes.builtin.RBuiltinFactory; import com.oracle.truffle.r.nodes.builtin.base.BasePackage; +import com.oracle.truffle.r.runtime.REnvVars; import com.oracle.truffle.r.runtime.RVisibility; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.builtins.RBuiltinKind; @@ -63,7 +64,7 @@ import com.oracle.truffle.r.test.TestBase.Ignored; */ public final class RBuiltinCheck { - private static final String DEFAULT_NAMESC = "com.oracle.truffle.r.native/gnur/" + RVersionNumber.R_HYPHEN_FULL + "/src/main/names.c"; + private static final Path DEFAULT_NAMESC = Paths.get(REnvVars.gnurHome(), "src", "main", "names.c"); private static final String BUILTIN_TEST_PATH = "com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_%s.java"; // old-style code annotation to get rid of javadoc error. @@ -166,7 +167,7 @@ public final class RBuiltinCheck { final Map<String, BuiltinInfo> fastr = extractFastRBuiltins(); final Map<String, BuiltinInfo> gnur; try { - gnur = extractGnuRBuiltins(suitePath); + gnur = extractGnuRBuiltins(); } catch (IOException ex) { System.err.println("Cannot read names.c file from GNU R distribution. \n" + ex.getClass().getName() + ":" + ex.getMessage()); System.exit(1); @@ -281,8 +282,8 @@ public final class RBuiltinCheck { return result; } - private static Map<String, BuiltinInfo> extractGnuRBuiltins(String suiteDir) throws IOException { - String content = Files.lines(Paths.get(suiteDir, DEFAULT_NAMESC)).collect(Collectors.joining("\n")); + private static Map<String, BuiltinInfo> extractGnuRBuiltins() throws IOException { + String content = Files.lines(DEFAULT_NAMESC).collect(Collectors.joining("\n")); Matcher matcher = Pattern.compile(FUNTAB_REGEXP).matcher(content); Map<String, BuiltinInfo> result = new TreeMap<>(); while (matcher.find()) { diff --git a/documentation/dev/build-process.md b/documentation/dev/build-process.md index 98864394ef..4efe86888f 100644 --- a/documentation/dev/build-process.md +++ b/documentation/dev/build-process.md @@ -31,9 +31,38 @@ See also [building](building.md), [release](../../com.oracle.truffle.r.release/R * `['make']` for the patched GNUR in `$(FASTR_R_HOME)/com.oracle.truffle.r.native` ## Integrating GNUR + + The original GNUR distribution is needed for a couple of reasons: + + * To compile the FastR specific and patched native sources with the original ones (e.g. header files, the built-in package sources etc.) + * To arrange the FastR's directory structure according to the GNUR layout + * To test the FastR functionality by comparing its output with that of GNUR + + In contrast to the previous build architecture, which extracted the necessary original + sources needed by FastR from the GNUR distribution during the build, the current build + architecture maintains the required original sources as part of the project in the `com.oracle.truffle.r.native/gnur/patch` + directory. The `patch` directory contains both the original and FastR specific native sources. + Some of the original sources are patched, but the original ones are still available via the GIT history. + + Note: All the original (non-patched) files were added to GIT in a single commit (`a2d8b606a8f7a61c65ec96545644f28dd4af7a71`). + Their modifications are made in subsequent commits. + + Thera are many original GNUR files that are just taken without any modification from GNUR + and copied to their respective location in the FastR directory layout (See the section *Building `run`* for details). + + Contrary to the previous build process, the current one does not remove the GNUR build when cleaning the project, + which makes the build much faster. GNUR typically needs to be re-built only occasionally. + The default build behaviour downloads the corresponding GNUR distribution to the `libdownloads` directory and installs it there. + The GNUR home directory is available through the `GNUR_HOME_BINARY` environment variable. + + Note: The `libdownloads` is not removed when cleaning the project. + Note: The GNUR distribution must be built by the FastR build process that uses special compiler options. + + #### The outline of the native build process: + * executes `make` in `com.oracle.truffle.r.native` - * makes the subfolders: `gnur`, `include`, `fficall`, `library`, `run` + * makes the subfolders: `gnur`, `include`, `fficall`, `gnur/patch-build/src/library`, `run` * updates file `version.built` to be the same as `version.source` (that is manually upgraded and stored in git) * `platform.mk` * created and populated during the gnur build (`gnur/Makefile.platform`) @@ -46,36 +75,40 @@ See also [building](building.md), [release](../../com.oracle.truffle.r.release/R #### `Makefile.gnur` + * copies `com.oracle.truffle.r.native/gnur/patch` to `com.oracle.truffle.r.native/gnur/patch-build` * unpacks `libdownloads/R-$(R_VERSION).tar.gz` * optionally (Solaris) unpacks `libdownloads/$(ICONV).tar.gz` * Note: `libdownloads` must not contain multiple GNUR binary distributions, otherwise `R_VERSION` contains all version numbers extracted from those distribution files * `GNUR_CONFIG_FLAGS` constructed and passed over to the configure utility that generates the `Makeconf` file for GNUR - * the output in `$(GNUR_HOME)/gnur_configure.log` - * optionally (Linux, SunOS) patches the generated `$(GNUR_HOME)/Makeconf` by `$(GNUR_HOME)/Makeconf < edMakeconf` (adds `-fPIC` to `CFLAGS` and `FFLAGS`, i.e. enables Position Independent Code) - * builds GNUR + * the output in `$(GNUR_HOME_BINARY)/gnur_configure.log` + * optionally (Linux, SunOS) patches the generated `$(GNUR_HOME_BINARY)/Makeconf` by `$(GNUR_HOME_BINARY)/Makeconf < edMakeconf` (adds `-fPIC` to `CFLAGS` and `FFLAGS`, i.e. enables Position Independent Code) + * builds GNUR in `libdownloads/R-$(R_VERSION)` using special compiler options * A special configuration for Solaris: 1. the default `iconv` utility is inadequate and has to be replaced by GNU `iconv` 2. the solaris studio compilers must be used, assumed to be on the `PATH` 3. Solaris runs on x64 and Sparc and the configure options are different + * makes `com.oracle.truffle.r.native/gnur/patch-build/src/include` creating `com.oracle.truffle.r.native/gnur/patch-build/include`. + Some headers are already patched to conform the FastR needs (in the previous system, the patching was done by `mx.fastr/mx_fastr_edinclude.py`). + The header files in the resulting `include` directory are later linked from `com.oracle.truffle.r.native/include`. See *Building `include`*. _Patched files_: - * The generated `$(GNUR_HOME)/Makeconf` using `edMakeconf` + * The generated `$(GNUR_HOME_BINARY)/Makeconf` using `edMakeconf` #### `Makefile.platform` It extracts relevant parts of the generated GnuR `Makeconf` file into FastR's `platform.mk`. The `platform.mk` file is included in many places such as the `Makefile`s for the standard packages built for FastR. -* `sedMakeconf` extracts various flags from `$(GNUR_HOME)/Makeconf` -* `sedEtcMakeconf` extracts `LPACBLAS_LIBS` and `LAPACK_LIBS` from `$(GNUR_HOME)/etc/Makeconf` +* `sedMakeconf` extracts various flags from `$(GNUR_HOME_BINARY)/Makeconf` +* `sedEtcMakeconf` extracts `LPACBLAS_LIBS` and `LAPACK_LIBS` from `$(GNUR_HOME_BINARY)/etc/Makeconf` * `edAddFASTR` adds `-DFASTR` to `CFLAGS` and replaces `R_HOME` by `FASTR_R_HOME` The code extracted by all scripts and some other stuff is stored into `../platform.mk` #### `Makefile.libs` -* Copies the `Blas` and `lapack` libraries. Also copies: `pcre`, `z`, `gfortran`, `quadmath` and `gcc_s` +* Copies the `Blas` and `lapack` libraries from `$(GNUR_HOME_BINARY)/src`. Also copies: `pcre`, `z`, `gfortran`, `quadmath` and `gcc_s` (from various system locations) * Invokes `mx rcopylib` to copy individual libraries. (The `rcopylib` function is in `mx.fastr/mx_copylib.py`). * On OS X it uses `install_name_tool` to set the library paths * Note: `rcopylib.done`, a "sentinel" file, indicates that dependencies were checked (and possibly copied) @@ -92,14 +125,7 @@ Note: The header files in this directory and its subdirectory are not in git: Th /com.oracle.truffle.r.native/include/linked ``` -All header files are symbolically linked to their originals in `$(GNUR_HOME)/include`, -except `Rinternals.h`, `Rinterface.h`, and `R_ext/GraphicsEngine.h`. - -The makefile invokes script `mx.fastr/mx_fastr_edinclude.py` to patch `Rinternals.h`, -`Rinterface.h`, `Rconfig.h` and `R_ext/GraphicsEngine.h`. - -Except `Rconfig.h`, the other three patched header files are copied from GNUR. For `Rconfig.h` -and other header files, symbolic links are created pointing to their originals in the GNUR `include` directory. +All header files are symbolically linked to their sources in `com.oracle.truffle.r.native/gnur/patch-build/include`. The file `linked` is just a sentinel file indicating that the links have been made. @@ -111,7 +137,7 @@ _Patched files_: _Other required sources_: - * `$(GNUR_HOME)/include/*.h`, `$(GNUR_HOME)/include/R_ext/*.h` + * `com.oracle.truffle.r.native/gnur/patch-build/include/*.h`, `com.oracle.truffle.r.native/gnur/patch-build/include/R_ext/*.h` ### Building `fficall` @@ -120,20 +146,17 @@ It builds `libR` and optionally (JNI) `libjniboot`. See: * [ffi](ffi.md) - * [jni ffi](jni_ffi.md) * [managed ffi](managed_ffi.md) * [truffle llvm ffi](truffle_llvm_ffi.md) * [truffle nfi](truffle_nfi.md) -The `FASTR_RFFI` variable controls which version of FFI is build: `managed` (i.e. no native), `llvm`, `nfi` or `jni`. +The `FASTR_RFFI` variable controls which version of FFI is build: `managed` (i.e. no native), `llvm` and `nfi`. The `common` part is built (see `common/Makefile`) prior to handing over the control to the corresponding FFI subdirectory (except the `managed` FFI). Then the dynamic library `libR` is built from the object files made in the previous step, which are stored into `lib`. -The `libjniboot` is built only when `FASTR_RFFI` is `jni` by invoking `jniboot/Makefile`. - In the end, on Darwin, the installation paths of `libRblas.dylib`, `libRlapack.dylib` and `libR.dylib` are updated using `install_name_tool`. Also the paths of `libpcre` and `libz` are updated using `mx rupdatelib` (defined in `mx.fastr/mx_copylib.py`). @@ -141,21 +164,19 @@ using `install_name_tool`. Also the paths of `libpcre` and `libz` are updated us This builds selected GNUR files and local overrides (`*.c` and `*.f`): -* compiles the selected `main` and `appl` C sources in `$(GNUR_HOME)/src/main` and `$(GNUR_HOME)/src/appl` +* compiles the selected `main` and `appl` C sources in `com.oracle.truffle.r.native/gnur/patch-build/src/main` and `com.oracle.truffle.r.native/gnur/patch-build/src/appl` * main: `colors.c devices.c engine.c format.c graphics.c plot.c plot3d.c plotmath.c rlocale.c sort.c` * appl: `pretty.c interv.c` -* the Fortran sources in `$(GNUR_HOME)/src/appl` are NOT recompiled. Instead, unless -the FFI mode is LLVM, a subset of Fortran object files, which are already built, are -just copied from GNUR. The subset is selected using the pattern `$(GNUR_APPL_SRC)/d*`. +* compiles the Fortran sources in `com.oracle.truffle.r.native/gnur/patch-build/src/appl` * compiles the local overrides (`*.c, *.f`) -* `../include/gnurheaders.mk` is included to define `GNUR_HEADER_DEFS` consisting of headers that we refer to indirectly -* all objects are compiled into `../../lib` (i.e. `fficall/lib`) + * `../include/gnurheaders.mk` is included to define `GNUR_HEADER_DEFS` consisting of headers that we refer to indirectly +* all objects are compiled into `../../lib` (i.e. `com.oracle.truffle.r.native/fficall/lib`) _Other required sources_: * From `$(GNUR_HOME)/src/main`: `colors.c, devices.c, engine.c, format.c, graphics.c, plot.c, plot3d.c, plotmath.c, rlocale.c, sort.c` - * From `$(GNUR_HOME)/src/appl`: `pretty.c, interv.c, d*.f` (currently not built, just copied the corresponding object files) + * From `$(GNUR_HOME)/src/appl`: `pretty.c, interv.c, d*.f` #### Building `llvm` FFI @@ -171,21 +192,14 @@ Analogous to the `llvm` build, except it: * includes headers from `NFI_INCLUDES`, which is set in environment (by `mx`) -#### Building `jni` FFI - -Analogous to the `llvm` and `nfi` builds, except it: +### Building `library` (built-in packages) -* includes JNI headers from `$(JAVA_HOME)/include` and `$(JAVA_HOME)/include/$(JDK_OS_DIR)` -* DOES NOT include `../common/rffi_upcallsindex.h` +All sources needed to build the built-in packages are maintained as part of the project and are +stored in GIT. The source location corresponds to the standard GNUR location for the built-in packages, +which is `src/library` relative to the root of the distribution, i.e. `com.oracle.truffle.r.native/gnur/patch` +in the case of the FastR project. -#### Building `jniboot` - -The functions in `jniboot` sources, while defined in `JNI_Base` are stored in a seperate library, `jniboot`, -in order to be able to bootstrap the system as `libR` has to be loaded using these functions. - -* Exported functions: `dlopen, dlsym, dlclose` - -### Building `library` +However, the packages are built in the working copy of the `patch` directory, i.e. `patch-build`. The following packages are currently patched: `base, compiler, datasets, utils, grDevices, graphics, grid, parallel, splines, stats, stats4, methods, tools`. @@ -195,23 +209,22 @@ The `lib.mk` file is included into the package makefiles. It contains the common all subordinate package builds. This common logic consists of copying the original GNUR library (binary) files to the FastR library directory. It also defines a couple of extension targets `LIB_PKG_PRE`, `LIB_PKG` and `LIB_PKG_POST`, `CLEAN_PKG` that are overridden by the package makefiles. -Individual packages may define their own source files in the package home directory as well as select some sources from the original -GNUR package (via `GNUR_C_OBJECTS` and `GNUR_C_OBJECTS` variables). Those sources are then compiled and linked into the corresponding dynamic library (`<package>.so`). +The package sources are compiled and linked into the corresponding dynamic library (`<package>.so`). Finally and optionally (Darwin, non-LLVM), the library is installed using the system tools. #### Package `base` -In the pre-build stage, it changes GnuR's build script `makebasedb.R` so that it does not -compress the lazy load database, then it (re)builds GnuR. The original `makebasedb.R` is -saved to `makebasedb.R.tmp`, which is reused in the post-build stage. +In the pre-build stage, it changes GnuR's build script `$(GNUR_HOME_BINARY)/src/library/base/makebasedb.R` +so that it does not compress the lazy load database, then it (re)builds GnuR. The original `makebasedb.R` is +saved to `$(GNUR_HOME_BINARY)/src/library/base/makebasedb.R.tmp`, which is reused in the post-build stage. -In the post-build stage, the R script `$(FASTR_R_HOME)R/base` is patched and `makebasedb.R` -is restored from the copy (`$(GNUR_HOME)/src/library/base/makebasedb.R`). Then, the GNUR -is rebuilt to undo the changes made by the auxiliary GNUR build in the pre-build stage. +In the post-build stage, the R script `$(FASTR_R_HOME)R/base` is patched and `$(GNUR_HOME_BINARY)/src/library/base/makebasedb.R` +is restored from the copy. Then, the GNUR is rebuilt to undo the changes made by the auxiliary +GNUR build in the pre-build stage. _Patched files_: - * `$(GNUR_HOME)/src/library/base/makebasedb.R` using `sed 's|compress = TRUE|compress = FALSE|g'` + * `$(GNUR_HOME_BINARY)/src/library/base/makebasedb.R` using `sed 's|compress = TRUE|compress = FALSE|g'` * the generated file `R/base.R` #### Package `graphics` @@ -254,7 +267,7 @@ _Other required sources_: _Patched files_: - * `glpi.h`, `rngstream.c` maintained in git + * `glpi.h`, `rngstream.c` _Other required sources_: @@ -265,14 +278,14 @@ _Other required sources_: _Patched files_: - * `splines.c` maintained in git + * `splines.c` #### Package `stats` _Patched files_: * `fft.c` using `ed_fft` - * `modreg.h`, `nls.h`, `port.h`, `stats.h`, `ts.h` maintained in git + * `modreg.h`, `nls.h`, `port.h`, `stats.h`, `ts.h` _Other required sources_: @@ -284,7 +297,7 @@ _Other required sources_: _Patched files_: - * `gramRd.c` using `mx.fastr/mx_fastr_mkgramrd.py` + * `gramRd.c` _Other required sources_: @@ -332,6 +345,8 @@ It installs the `recommended` packages that are bundled with GNU R. It has to be from the native project that contains the packages because that is built first and before FastR is completely built. +The tar balls of packages sources are taken from the GNUR distribution (i.e. `$(GNUR_HOME_BINARY)/src/library/Recommended`). + The command used to install a package: `$(FASTR_R_HOME)/bin/R CMD INSTALL --library=$(FASTR_R_HOME)/library $$pkgtar;` As this takes quite a while the building is conditional on the `FASTR_RELEASE` environment variable. @@ -339,28 +354,71 @@ As this takes quite a while the building is conditional on the `FASTR_RELEASE` e N.B. this flag is not set for "normal" FastR gate builds defined in `ci.hocon`. It is set only in the post-merge "stories" build defined in `ci.overlays/fastr.hocon` * It always installs `codetools`, as it is required by `S4` -* If `FASTR_RELEASE` is `true`, the following packages are installed: `MASS boot class cluster lattice nnet spatial Matrix survival KernSmooth foreign nlme rpart` +* If `FASTR_RELEASE` is `true`, the following packages are also installed: `MASS boot class cluster lattice nnet spatial Matrix survival KernSmooth foreign nlme rpart` *Â `$(NATIVE_PROJECT_DIR)/platform.mk` is included * Weak symbol refs used (i.e. `-undefined dynamic_lookup`) so that `libR.dylib` (which loads the package libraries) does not have to be specified when building the package -## Refactoring of the build process +### Appendix 1: Making the built-in packages separately (i.e. out of the main build process) -The pre-generated `configure` script must be patched to include only the following targets: +#### Prerequisites - * `ac_config_files="Makeconf doc/Makefile doc/html/Makefile doc/manual/Makefile etc/Makefile etc/Makeconf etc/Renviron etc/javaconf etc/ldpaths src/include/Makefile src/include/Rmath.h0 src/include/R_ext/Makefile src/scripts/mkinstalldirs share/Makefile"` +``` +export FASTR_HOME=~/work/fastr +``` -#### Making the R includes: - * Run `configure` - * Run `make -C src/include` +To make a package `pkg` the working directory must be changed to `$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build/src/library/pkg`. -TODO: +#### Making base +``` +make PACKAGE=base TOPDIR=$FASTR_HOME/com.oracle.truffle.r.native GNUR_HOME=$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build FASTR_LIBRARY_DIR=$FASTR_HOME/library GNUR_HOME_BINARY=$FASTR_HOME/libdownloads/R-3.4.0 +``` -_Other required sources_: +#### Making grDevices +``` +make PACKAGE=grDevices TOPDIR=$FASTR_HOME/com.oracle.truffle.r.native GNUR_HOME=$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build FASTR_LIBRARY_DIR=$FASTR_HOME/library GNUR_HOME_BINARY=$FASTR_HOME/libdownloads/R-3.4.0 +``` - * The pre-generated `$(GNUR_HOME)/configure` - * `$(GNUR_HOME)/src/include`, `$(GNUR_HOME)/tools`, `$(GNUR_HOME)/etc`, `$(GNUR_HOME)/tools`, `$(GNUR_HOME)/doc`, `$(GNUR_HOME)/share` - * `$(GNUR_HOME)/VERSION`, `$(GNUR_HOME)/SVN-VERSION`, `$(GNUR_HOME)/VERSION-NICK` +#### building graphics +``` +make PACKAGE=graphics TOPDIR=$FASTR_HOME/com.oracle.truffle.r.native GNUR_HOME=$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build FASTR_LIBRARY_DIR=$FASTR_HOME/library GNUR_HOME_BINARY=$FASTR_HOME/libdownloads/R-3.4.0 +``` + +#### Making grid +``` +make PACKAGE=grid TOPDIR=$FASTR_HOME/com.oracle.truffle.r.native GNUR_HOME=$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build FASTR_LIBRARY_DIR=$FASTR_HOME/library GNUR_HOME_BINARY=$FASTR_HOME/libdownloads/R-3.4.0 +``` + +#### Making methods +``` +make PACKAGE=methods TOPDIR=$FASTR_HOME/com.oracle.truffle.r.native GNUR_HOME=$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build FASTR_LIBRARY_DIR=$FASTR_HOME/library GNUR_HOME_BINARY=$FASTR_HOME/libdownloads/R-3.4.0 +``` + +#### Making parallel +``` +make PACKAGE=parallel TOPDIR=$FASTR_HOME/com.oracle.truffle.r.native GNUR_HOME=$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build FASTR_LIBRARY_DIR=$FASTR_HOME/library GNUR_HOME_BINARY=$FASTR_HOME/libdownloads/R-3.4.0 +``` + +#### Makining splines +``` +make PACKAGE=splines TOPDIR=$FASTR_HOME/com.oracle.truffle.r.native GNUR_HOME=$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build FASTR_LIBRARY_DIR=$FASTR_HOME/library GNUR_HOME_BINARY=$FASTR_HOME/libdownloads/R-3.4.0 +``` + +#### Making stats +``` +make PACKAGE=stats TOPDIR=$FASTR_HOME/com.oracle.truffle.r.native GNUR_HOME=$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build FASTR_LIBRARY_DIR=$FASTR_HOME/library FASTR_LIB_DIR=$FASTR_HOME/library GNUR_HOME_BINARY=$FASTR_HOME/libdownloads/R-3.4.0 FASTR_R_HOME=$FASTR_HOME +``` + +#### Making stats4 +``` +make PACKAGE=stats4 TOPDIR=$FASTR_HOME/com.oracle.truffle.r.native GNUR_HOME=$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build FASTR_LIBRARY_DIR=$FASTR_HOME/library GNUR_HOME_BINARY=$FASTR_HOME/libdownloads/R-3.4.0 +``` + +#### Making tools +``` +make PACKAGE=tools TOPDIR=$FASTR_HOME/com.oracle.truffle.r.native GNUR_HOME=$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build FASTR_LIBRARY_DIR=$FASTR_HOME/library GNUR_HOME_BINARY=$FASTR_HOME/libdownloads/R-3.4.0 FASTR_RFFI=nfi +``` -## Notes on building GNUR on Darwin: - * export `PKG_LDFLAGS_OVERRIDE="-L/usr/local/lib -L/usr/local/opt/zlib/lib"` - * needed to create the symbolic link `gcc_s`: `ln -s /usr/local/gfortran/lib/libgcc_s_x86_64.1.dylib /usr/local/lib/libgcc_s.dylib` +#### Making utils +``` +make PACKAGE=utils TOPDIR=$FASTR_HOME/com.oracle.truffle.r.native GNUR_HOME=$FASTR_HOME/com.oracle.truffle.r.native/gnur/patch-build FASTR_LIBRARY_DIR=$FASTR_HOME/library GNUR_HOME_BINARY=$FASTR_HOME/libdownloads/R-3.4.0 +``` diff --git a/mx.fastr/copyrights/gnu_r.language.star b/mx.fastr/copyrights/gnu_r.language.star new file mode 100644 index 0000000000..b6234688f7 --- /dev/null +++ b/mx.fastr/copyrights/gnu_r.language.star @@ -0,0 +1,18 @@ +/* + * R : A Computer Language for Statistical Data Analysis + * Copyright (C) 1995-2014 The R Core Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, a copy is available at + * https://www.R-project.org/Licenses/ + */ diff --git a/mx.fastr/copyrights/gnu_r.language.star.regex b/mx.fastr/copyrights/gnu_r.language.star.regex new file mode 100644 index 0000000000..0acbbb3416 --- /dev/null +++ b/mx.fastr/copyrights/gnu_r.language.star.regex @@ -0,0 +1 @@ +\/\*\n \* R : A Computer Language for Statistical Data Analysis\n \* Copyright \(C\) (?:[1-2][09][0-9][0-9]--?)?(:?[1-2][09])?[0-9]?[0-9] [ ]?The [ ]?R Core Team\n \*\n \* This program is free software; you can redistribute it and\/or modify\n \* it under the terms of the GNU General Public License as published by\n \* the Free Software Foundation; either version 2 of the License, or\n \* \(at your option\) any later version\.\n \*\n \* This program is distributed in the hope that it will be useful,\n \* but WITHOUT ANY WARRANTY; without even the implied warranty of\n \* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\. See the\n \* GNU General Public License for more details.\n \*\n \* You should have received a copy of the GNU General Public License\n \* along with this program; if not, a copy is available at\n \* https:\/\/www\.R-project\.org\/Licenses.* \ No newline at end of file diff --git a/mx.fastr/copyrights/overrides b/mx.fastr/copyrights/overrides index ed356eca1a..7676e3a4aa 100644 --- a/mx.fastr/copyrights/overrides +++ b/mx.fastr/copyrights/overrides @@ -81,22 +81,22 @@ com.oracle.truffle.r.native/fficall/src/include/Rgraphics.h,gnu_r_gentleman_ihak com.oracle.truffle.r.native/fficall/src/include/rlocale.h,gnu_r_gentleman_ihaka.copyright com.oracle.truffle.r.native/fficall/src/truffle_llvm/Memory.c,gnu_r.copyright com.oracle.truffle.r.native/fficall/src/truffle_nfi/Memory.c,gnu_r.copyright -com.oracle.truffle.r.native/library/base/src/registration.c,no.copyright -com.oracle.truffle.r.native/library/grDevices/src/gzio.c,gnu_r_gentleman_ihaka.copyright -com.oracle.truffle.r.native/library/methods/src/methods_dummy.c,no.copyright -com.oracle.truffle.r.native/library/parallel/src/glpi.h,no.copyright -com.oracle.truffle.r.native/library/parallel/src/parallel_dummy.c,no.copyright -com.oracle.truffle.r.native/library/parallel/src/rngstream.c,no.copyright -com.oracle.truffle.r.native/library/splines/src/splines.c,no.copyright -com.oracle.truffle.r.native/library/stats/src/gnur_extracts.c,no.copyright -com.oracle.truffle.r.native/library/stats/src/modreg.h,no.copyright -com.oracle.truffle.r.native/library/stats/src/nls.h,no.copyright -com.oracle.truffle.r.native/library/stats/src/port.h,no.copyright -com.oracle.truffle.r.native/library/stats/src/stats.h,no.copyright -com.oracle.truffle.r.native/library/stats/src/statsR_dummy.c,no.copyright -com.oracle.truffle.r.native/library/stats/src/ts.h,no.copyright -com.oracle.truffle.r.native/library/tools/src/tools_dummy.c,no.copyright -com.oracle.truffle.r.native/library/utils/src/utils_dummy.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/base/src/registration.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/gzio.c,gnu_r_gentleman_ihaka.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/methods/src/methods_dummy.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/glpi.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/parallel_dummy.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/rngstream.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/splines/src/splines.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/gnur_extracts.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/modreg.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/nls.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/port.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/stats.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/statsR_dummy.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/ts.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/tools_dummy.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/utils/src/utils_dummy.c,no.copyright com.oracle.truffle.r.native/run/R.sh,oracle_bash.copyright com.oracle.truffle.r.native/run/Rclasspath.sh,oracle_bash.copyright com.oracle.truffle.r.native/run/Rscript_exec.sh,oracle_bash.copyright @@ -774,3 +774,148 @@ com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/library/base/TestSimpleV com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/data/tree2/incx.r,no.copyright com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/simple/data/tree2/setx.r,no.copyright com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/TestBase.java,purdue.copyright +com.oracle.truffle.r.native/gnur/patch/src/appl/interv.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/appl/pretty.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Defn.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Errormsg.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Fileio.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Graphics.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/GraphicsBase.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/IOStuff.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Internal.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Parse.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Print.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Applic.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Arith.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/BLAS.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Boolean.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Callbacks.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Complex.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Connections.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Constants.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Error.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/GetX11Image.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/GraphicsDevice.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/GraphicsEngine.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Itermacros.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Lapack.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Linpack.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/MathThreads.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Memory.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Parse.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Print.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/PrtUtil.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/QuartzDevice.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/R-ftp-http.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/RS.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/RStartup.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Rallocators.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Random.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Rdynload.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Riconv.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Utils.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/Visibility.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/eventloop.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/libextern.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/stats_package.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/R_ext/stats_stubs.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Rconnections.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Rdefines.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Rdynpriv.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Rembedded.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Rgraphics.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Rinlinedfuns.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Rinterface.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Rinternals.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Rmodules/RX11.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Rmodules/Rinternet.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Rmodules/Rlapack.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/S.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/Startup.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/rlocale.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/vg/memcheck.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/include/vg/valgrind.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/axis_scales.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/cairo/cairoBM.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/cairo/cairoBM.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/cairo/cairoFns.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/chull.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/colors.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/devCairo.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/devPS.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/devPicTeX.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/devQuartz.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/devWindows.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/devices.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/grDevices.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/init.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/qdBitmap.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/qdCocoa.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/qdPDF.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/stubs.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grDevices/src/winbitmap.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/graphics/src/base.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/graphics/src/graphics.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/graphics/src/graphics.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/graphics/src/init.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/graphics/src/par-common.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/graphics/src/par.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/graphics/src/plot.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/graphics/src/plot3d.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/graphics/src/stem.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grid/src/gpar.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grid/src/grid.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grid/src/grid.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grid/src/just.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grid/src/layout.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grid/src/matrix.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grid/src/register.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grid/src/state.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grid/src/unit.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grid/src/util.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/grid/src/viewport.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/methods/src/init.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/methods/src/methods.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/glpi.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/init.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/parallel.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/parallel/src/rngstream.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/splines/src/splines.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/fft.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/init.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/isoreg.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/kmeans.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/loessc.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/modreg.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/monoSpl.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/nls.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/port.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/sbart.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/stats.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/statsR.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/ts.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/gramRd.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/init.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/tools/src/tools.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/utils/src/init.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/utils/src/utils.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/nls.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/port.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/stats.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/library/stats/src/ts.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/colors.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/contour-common.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/devices.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/engine.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/format.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/graphics.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/gzio.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/plot.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/plot3d.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/plotmath.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/rlocale.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/rlocale_data.h,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/sort.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/main/xspline.c,no.copyright +com.oracle.truffle.r.native/gnur/patch/src/nmath/nmath.h,no.copyright diff --git a/mx.fastr/mx_fastr.py b/mx.fastr/mx_fastr.py index 08bbcb01fa..32ded70122 100644 --- a/mx.fastr/mx_fastr.py +++ b/mx.fastr/mx_fastr.py @@ -29,7 +29,6 @@ import mx_fastr_pkgs import mx_fastr_dists from mx_fastr_dists import FastRReleaseProject, FastRNativeRecommendedProject #pylint: disable=unused-import import mx_copylib -import mx_fastr_mkgramrd import mx_fastr_edinclude import mx_unittest @@ -440,8 +439,8 @@ def rbdiag(args): mx.run_java(vmArgs + args) def _gnur_path(): - np = mx.project('com.oracle.truffle.r.native') - return join(np.dir, 'gnur', r_version(), 'bin') + gnurHome = os.environ.get('GNUR_HOME_BINARY', 'libdownloads') + return join(gnurHome, r_version(), 'bin') def gnu_r(args): ''' @@ -553,7 +552,6 @@ _commands = { 'r-findtop100' : [mx_fastr_pkgs.find_top100, ['options']], 'r-duppkgs' : [mx_fastr_pkgs.remove_dup_pkgs, ['options']], 'installpkgs' : [mx_fastr_pkgs.installpkgs, '[options]'], - 'mkgramrd': [mx_fastr_mkgramrd.mkgramrd, '[options]'], 'rcopylib' : [mx_copylib.copylib, '[]'], 'rupdatelib' : [mx_copylib.updatelib, '[]'], 'edinclude' : [mx_fastr_edinclude.edinclude, '[]'], diff --git a/mx.fastr/mx_fastr_edinclude.py b/mx.fastr/mx_fastr_edinclude.py index 8cfc59d183..a132401b39 100644 --- a/mx.fastr/mx_fastr_edinclude.py +++ b/mx.fastr/mx_fastr_edinclude.py @@ -146,7 +146,9 @@ extern int R_isEqual(void*, void*); #else ''' -interactive_rewrite = '''#ifdef FASTR +interactive_rewrite = ''' +#include <R_ext/RStartup.h> +#ifdef FASTR extern Rboolean FASTR_R_Interactive(); #define R_Interactive FASTR_R_Interactive() #else diff --git a/mx.fastr/mx_fastr_mkgramrd.py b/mx.fastr/mx_fastr_mkgramrd.py deleted file mode 100644 index 244c3b4a62..0000000000 --- a/mx.fastr/mx_fastr_mkgramrd.py +++ /dev/null @@ -1,166 +0,0 @@ -# -# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -def mkgramrd(args): - ''' - converts GNU R gramRd.c into one suitable for invoking via FastR - ''' - parse_defs = ''' -extern SEXP R_SrcrefSymbol; -extern SEXP R_SrcfileSymbol; -extern int R_ParseContextLast; -#define R_EOF -1 -#define PARSE_ERROR_SIZE 256 -#define PARSE_CONTEXT_SIZE 256 -static char R_ParseErrorMsg[PARSE_ERROR_SIZE]; -static char R_ParseContext[PARSE_CONTEXT_SIZE]; -int R_ParseContextLast; -int R_ParseContextLine; -int R_ParseError; -extern SEXP R_EmptyEnv; -extern SEXP R_NewHashedEnv(SEXP a, SEXP b); - -char *dgettext(const char *p, const char *msgid) { -return (char *)msgid; -} - -int imax2(int x, int y) -{ - return (x < y) ? y : x; -} -''' - - connect_defs = ''' -typedef SEXP Rconnection; -static int Rconn_fgetc(Rconnection con) { - return -1; -} - -''' - - c_parserd = ''' - If there is text then that is read and the other arguments are ignored. - - This is derived fron the function of the same name in the GnuR version. - Argument checking has already been performed, however, the types of the - arguments are as per the GnuR version, just passed explicitly (.Call style) - rather then as a list. -*/ -SEXP parseRd(SEXP call, SEXP op, SEXP args, SEXP env) { - args = CDR(args); // arg 0 skipped - - SEXP s = R_NilValue, source; - Rconnection con; - SEXP conArg; - Rboolean fragment; - int ifile; - int wcall; - ParseStatus status; - SEXP macros; - -#if DEBUGMODE - yydebug = 1; -#endif - - R_ParseError = 0; - R_ParseErrorMsg[0] = '\\0'; - - PushState(); - - conArg = CAR(args); // arg 1 - ifile = asInteger(conArg); - - con = R_GetFastRConnection(conArg); - - args = CDR(args); - - source = CAR(args); // arg 2 - args = CDR(args); - /* encoding is unused */ - args = CDR(args); - if(!isLogical(CAR(args)) || LENGTH(CAR(args)) != 1) // arg 4 - error(_("invalid '%s' value"), "verbose"); - parseState.xxDebugTokens = asInteger(CAR(args)); // arg 4 - args = CDR(args); - parseState.xxBasename = CHAR(STRING_ELT(CAR(args), 0)); // arg 5 - args = CDR(args); - fragment = asLogical(CAR(args)); // arg 6 - args = CDR(args); - wcall = asLogical(CAR(args)); // arg 7 - args = CDR(args); - if (wcall == NA_LOGICAL) - error(_("invalid '%s' value"), "warningCalls"); - wCalls = wcall; - macros = CAR(args); // arg 8 - args = CDR(args); - warnDups = asLogical(CAR(args)); // arg 9 - - if (ifile >= 3) {/* file != "" */ - s = R_ParseRd(con, &status, source, fragment, macros); - PopState(); - } - return s; -} - -// TODO deparseRd -''' - with open(args[0]) as f: - lines = f.readlines() - - with open(args[1], 'w') as f: - i = 0 - while i < len(lines): - line = lines[i] - sline = line.rstrip() - if sline == '#include <Defn.h>': - line = '//' + line - f.write(line) - f.write('#include <Rinternals.h>\n') - elif sline == '#include <Parse.h>': - f.write('#include <R_ext/Parse.h>\n') - elif 'bison creates a non-static symbol yylloc' in sline: - f.write(parse_defs) - f.write(line) - elif '#include <Rmath.h>' in sline: - line = '//' + line - f.write(line) - f.write('#include "gramRd_fastr.h"\n') - elif sline == '#include "Rconnections.h"': - line = '//' + line - f.write(line) - f.write(connect_defs) - elif 'c = Rconn_fgetc(con_parse);' in sline: - f.write(' c = callGetCMethod(con_parse);\n') - elif sline == 'static void con_cleanup(void *data)': - # skip - i = i + 5 - elif 'installTrChar(STRING_ELT(thename, 0))' in line: - line = line.replace('installTrChar(STRING_ELT(thename, 0))', 'install(CHAR(STRING_ELT(thename, 0)))') - f.write(line) - elif '.External2(C_parseRd' in sline: - f.write(line) - f.write(c_parserd) - break - else: - f.write(line) - i = i + 1 -- GitLab