summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-09-19 22:37:09 +0000
committerKarl Berry <karl@freefriends.org>2022-09-19 22:37:09 +0000
commitdff4219c36e130b2384e70abff6930025cfe87b6 (patch)
treee46582654ad19c56fa4a7f2054f2a098c95da3d6 /Master/texmf-dist/source
parent3dfc7b446aa172f6643e8a654a351b1a49f673a5 (diff)
texaccents (20sep22)
git-svn-id: svn://tug.org/texlive/trunk@64447 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/support/texaccents/compiler.inc14
-rw-r--r--Master/texmf-dist/source/support/texaccents/delete.inc21
-rw-r--r--Master/texmf-dist/source/support/texaccents/grepl.inc63
-rw-r--r--Master/texmf-dist/source/support/texaccents/newline.inc23
-rw-r--r--Master/texmf-dist/source/support/texaccents/systype.inc17
5 files changed, 138 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/support/texaccents/compiler.inc b/Master/texmf-dist/source/support/texaccents/compiler.inc
new file mode 100644
index 00000000000..1360dd38347
--- /dev/null
+++ b/Master/texmf-dist/source/support/texaccents/compiler.inc
@@ -0,0 +1,14 @@
+* Compiler.inc
+* Gregory White <glwhite@netconnect.com.au>
+* Posted to the Snobol list (March 2003)
+* and adapted as a function
+
+ DEFINE('COMPILER()') :(COMPILER_END)
+compiler
+IDprocessor :($('COMPILER' SIZE(DATE())))
+COMPILER17 compiler = 'SPITBOL' :(return)
+COMPILER19 compiler = 'CSNOBOL4' :(return)
+COMPILER20 compiler = 'SNOBOL4+' :(return)
+compiler_end
+* Uses the different size of DATE() to detect the compiler used
+
diff --git a/Master/texmf-dist/source/support/texaccents/delete.inc b/Master/texmf-dist/source/support/texaccents/delete.inc
new file mode 100644
index 00000000000..c6d510fe7c0
--- /dev/null
+++ b/Master/texmf-dist/source/support/texaccents/delete.inc
@@ -0,0 +1,21 @@
+******************************************
+* DELETE
+* Deletes String in Text
+******************************************
+#################################################################
+# MIT License - Copyright (c) 2009 Guido Milanese
+# See file LICENSE in this package
+#################################################################
+* Guido Milanese 2004
+* removed error message, 2009
+* <guido.milanese@unicatt.it>
+* Example:
+* String = delete(String,";,:.") ;* deletes any char listed in "..."
+ define('delete(String,Txt)') :(delete_end)
+delete
+ ~(String ? any(Txt)) :s(freturn)
+delete_loop
+ String ? any(Txt) = '' :s(delete_loop)f(delete_return)
+delete_return delete = String :(return)
+delete_end
+
diff --git a/Master/texmf-dist/source/support/texaccents/grepl.inc b/Master/texmf-dist/source/support/texaccents/grepl.inc
new file mode 100644
index 00000000000..76ad8bb0f07
--- /dev/null
+++ b/Master/texmf-dist/source/support/texaccents/grepl.inc
@@ -0,0 +1,63 @@
+* Function GREPL
+* replaces all the items in SET1 with all the items in SET2
+* SET1/2 must have the form "ITEM ITEM ITEM " -- space at the end
+* guido.milanese@unicatt.it
+* requires "repl.inc"
+* 31.07.2022
+#################################################################
+# MIT License - Copyright (c) 2022 Guido Milanese
+# See file LICENSE in this package
+#################################################################
+ define("grepl(Pass,Set1,Set2)datum,I,N,T1,T2,A1,A2")
+-include "repl.inc"
+ :(grepl_end)
+grepl
+grepl_bg
+ T1 = TABLE()
+ T2 = TABLE()
+ N = 0
+grepl1 N = N + 1
+ Set1 ? break(' ') . datum len(1) rem . Set1 :f(grepl1_nd)
+ T1[N] = datum :(grepl1)
+grepl1_nd
+
+ N = 0
+grepl2 N = N + 1
+ Set2 ? break(' ') . datum len(1) rem . Set2 :f(grepl2_nd)
+ T2[N] = datum :(grepl2)
+grepl2_nd
+ A1 = convert(T1,"ARRAY")
+ A2 = convert(T2,"ARRAY")
+grepl3_bg I = I + 1
+ Pass = repl(Pass,A1[I,2],A2[I,2]) :S(grepl3_bg)F(grepl3_nd)
+grepl3_nd
+grepl_rt grepl = Pass :(return)
+grepl_end
+
+*********************************************************************
+* This function, as Phil Budne's "repl", replaces string/string
+* but, as standard "replace", can replace a set with another set.
+* In this way also Unicode chars can be replaced with no limitation
+* since they are treated as strings.
+* Text = "aiuole"
+* S1 = "a e i o u "
+* S2 = "1 2 3 4 5 "
+* Text2 = grepl(Text,S1,S2)
+* will output: "1354l2"
+* But also:
+* Text = "aiuole"
+* S1 = "a e i o u "
+* S2 = "ā ē ī ō ū "
+* will output: "āīūōlē"
+* the standard REPLACE ("aeiou" / "āēīōū") will fail
+* because Unicode chars (>127 ASCII) do not have the same length of chars <127.
+* Step by step:
+* create two tables for sets: T1 and T2
+* feed the tables scanning thes two sets (items must be separeted by spaces)
+* convert from tables to arrays
+* use REPL converting string/string in PASS:
+* each item of SET1 is replaced by the corresponding item in S2
+* if SET2 is shorter the exceeding item in SET1 is left unchanged
+* if SET1 is shorter the exceeding item in SET2 is not used
+* Please notice that separating items by spaces makes it possible to substitute
+* also sets of strings, such as e.g. LaTeX accents.
diff --git a/Master/texmf-dist/source/support/texaccents/newline.inc b/Master/texmf-dist/source/support/texaccents/newline.inc
new file mode 100644
index 00000000000..8c685791cc8
--- /dev/null
+++ b/Master/texmf-dist/source/support/texaccents/newline.inc
@@ -0,0 +1,23 @@
+* NEWLINE
+* Checks OS and compiler type to set newline
+* Part of this function uses code posted by
+* Gregory White <glwhite@netconnect.com.au>
+* on the Snobol list in March 2003
+* Guido Milanese <guido.milanese@unicatt.it>
+#################################################################
+# MIT License - Copyright (c) 2003 Guido Milanese
+# See file LICENSE in this package
+#################################################################
+ define('newline()compiler_type')
+-include "compiler.inc"
+-include "systype.inc"
+ :(newline_end)
+newline
+* Compiler being used. If it is Snobol4+, that does not have
+* the HOST() function, assumes that the newline is Dos type
+snobol4 (compiler_type = compiler()) ? "SNOBOL4+" :f(other)
+ newline = char(13) char(10) :(return)
+* otherwise finds through HOST the OS type and sets newline
+* accordingly
+other newline = systype() :(return)
+newline_end
diff --git a/Master/texmf-dist/source/support/texaccents/systype.inc b/Master/texmf-dist/source/support/texaccents/systype.inc
new file mode 100644
index 00000000000..4932f82c581
--- /dev/null
+++ b/Master/texmf-dist/source/support/texaccents/systype.inc
@@ -0,0 +1,17 @@
+* SYSTYPE
+* Sets new_line value according to OS
+* Guido Milanese <guido.milanese@unicatt.it>
+* March 2003
+#################################################################
+# MIT License - Copyright (c) 2003 Guido Milanese
+# See file LICENSE in this package
+#################################################################
+ DEFINE('SYSTYPE()os') :(SYSTYPE_END)
+SYSTYPE os = replace(host(),&UCASE,&LCASE)
+UNIX os ? ('nix' | 'nux') :f(DOS)
+ systype = char(10) :(return)
+DOS systype = char(13) char(10) :s(return)
+ :(freturn)
+SYSTYPE_END
+* 'os' is the string returned by host().
+* The function does not work under snobol4+, requires Spitbol or CSnobol4.