"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Data/String/universal.cpp" between
TeXmacs-1.99.4-src.tar.gz and TeXmacs-1.99.5-src.tar.gz

About: GNU TeXmacs is a what-you-see-is-what-you-get scientific text editor, which was both inspired by TeX and GNU Emacs.

universal.cpp  (TeXmacs-1.99.4-src):universal.cpp  (TeXmacs-1.99.5-src)
skipping to change at line 14 skipping to change at line 14
* DESCRIPTION: Internationalization for the universal character encoding * DESCRIPTION: Internationalization for the universal character encoding
* COPYRIGHT : (C) 2015 Joris van der Hoeven * COPYRIGHT : (C) 2015 Joris van der Hoeven
******************************************************************************* *******************************************************************************
* This software falls under the GNU general public license version 3 or later. * This software falls under the GNU general public license version 3 or later.
* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>. * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
******************************************************************************/ ******************************************************************************/
#include "universal.hpp" #include "universal.hpp"
#include "hashmap.hpp" #include "hashmap.hpp"
#include "converter.hpp"
/****************************************************************************** /******************************************************************************
* Transliteration * Transliteration
******************************************************************************/ ******************************************************************************/
hashmap<string,string> translit_table (""); static hashmap<string,string>&
get_translit_table () {
static hashmap<string,string> t ("");
return t;
}
hashmap<string,string> &translit_table = get_translit_table();
extern char Cork_unaccented[128]; extern char Cork_unaccented[128];
static void static void
translit_set (int i, string s) { translit_set (int i, string s) {
string h= as_hexadecimal (i); string h= as_hexadecimal (i);
translit_table ("<#" * locase_all (h) * ">")= s; translit_table ("<#" * locase_all (h) * ">")= s;
translit_table ("<#" * upcase_all (h) * ">")= s; translit_table ("<#" * upcase_all (h) * ">")= s;
} }
static void static void
skipping to change at line 126 skipping to change at line 132
string ss= s (start, i); string ss= s (start, i);
if (translit_table->contains (ss)) r << translit_table [ss]; if (translit_table->contains (ss)) r << translit_table [ss];
else r << ss; else r << ss;
} }
return r; return r;
} }
/****************************************************************************** /******************************************************************************
* Changing the case * Changing the case
******************************************************************************/ ******************************************************************************/
static hashmap<string,string>&
get_locase_tab () {
static hashmap<string,string> t ("");
return t;
}
static hashmap<string,string>&
get_upcase_tab () {
static hashmap<string,string> t ("");
return t;
}
hashmap<string,string> locase_tab (""); hashmap<string,string> locase_tab = get_locase_tab ();
hashmap<string,string> upcase_tab (""); hashmap<string,string> upcase_tab = get_upcase_tab ();
static void static void
add_greek (string sym) { add_greek (string sym) {
locase_tab ("<" * upcase_first (sym) * ">")= "<" * sym * ">"; locase_tab ("<" * upcase_first (sym) * ">")= "<" * sym * ">";
upcase_tab ("<" * sym * ">")= "<" * upcase_first (sym) * ">"; upcase_tab ("<" * sym * ">")= "<" * upcase_first (sym) * ">";
upcase_tab ("<var" * sym * ">")= "<" * upcase_first (sym) * ">"; upcase_tab ("<var" * sym * ">")= "<" * upcase_first (sym) * ">";
} }
static void static void
init_case_tables () { init_case_tables () {
skipping to change at line 271 skipping to change at line 287
uni_upcase_all (string s) { uni_upcase_all (string s) {
string r; string r;
int i=0, n=N(s); int i=0, n=N(s);
while (i<n) { while (i<n) {
int start= i; int start= i;
tm_char_forwards (s, i); tm_char_forwards (s, i);
r << uni_upcase_char (s (start, i)); r << uni_upcase_char (s (start, i));
} }
return r; return r;
} }
/******************************************************************************
* Retrieving accents
******************************************************************************/
static array<string> accented_list;
static hashmap<string,string> unaccent_table;
static hashmap<string,string> get_accent_table;
static void
fill (array<int> a, int start, int kind) {
for (int i=0; i<N(a); i++)
if (a[i] != -1) {
int code= start + i;
string c= utf8_to_cork (encode_as_utf8 (code));
string v= utf8_to_cork (encode_as_utf8 (a[i]));
if (kind == 0) accented_list << c;
if (kind == 0) unaccent_table (c)= v;
else get_accent_table (c)= v;
}
}
array<string>
get_accented_list () {
(void) uni_unaccent_char ("a");
return accented_list;
}
string
uni_unaccent_char (string s) {
if (N(unaccent_table) != 0) return unaccent_table[s];
array<int> a;
a << 0x41 << 0x41 << 0x41 << 0x41 << 0x41 << 0x41 << -1 << 0x43
<< 0x45 << 0x45 << 0x45 << 0x45 << 0x49 << 0x49 << 0x49 << 0x49
<< 0x44 << 0x4E << 0x4F << 0x4F << 0x4F << 0x4F << 0x4F << -1
<< 0x4F << 0x55 << 0x55 << 0x55 << 0x55 << 0x59 << -1 << -1
<< 0x61 << 0x61 << 0x61 << 0x61 << 0x61 << 0x61 << -1 << 0x63
<< 0x65 << 0x65 << 0x65 << 0x65 << 0x69 << 0x69 << 0x69 << 0x69
<< 0x64 << 0x6E << 0x6F << 0x6F << 0x6F << 0x6F << 0x6F << -1
<< 0x6F << 0x75 << 0x75 << 0x75 << 0x75 << 0x79 << -1 << 0x79;
fill (a, 0xC0, 0);
return unaccent_table[s];
}
string
uni_get_accent_char (string s) {
if (N(get_accent_table) != 0) return get_accent_table[s];
array<int> a;
a << 0x60 << 0x0B4 << 0x2C6 << 0x2DC << 0x0A8 << 0x2DA << -1 << 0xB8
<< 0x60 << 0x0B4 << 0x2C6 << 0x0A8 << 0x060 << 0x0B4 << 0x2C6 << 0xA8
<< -1 << 0x2DC << 0x060 << 0x0B4 << 0x2C6 << 0x2DC << 0x0A8 << -1
<< -1 << 0x060 << 0x0B4 << 0x2C6 << 0x0A8 << 0x0B4 << -1 << -1
<< 0x60 << 0x0B4 << 0x2C6 << 0x2DC << 0x0A8 << 0x2DA << -1 << 0xB8
<< 0x60 << 0x0B4 << 0x2C6 << 0x0A8 << 0x060 << 0x0B4 << 0x2C6 << 0xA8
<< -1 << 0x2DC << 0x060 << 0x0B4 << 0x2C6 << 0x2DC << 0x0A8 << -1
<< -1 << 0x060 << 0x0B4 << 0x2C6 << 0x0A8 << 0x0B4 << -1 << 0xA8;
fill (a, 0xC0, 1);
return get_accent_table[s];
}
 End of changes. 5 change blocks. 
3 lines changed or deleted 19 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS