summaryrefslogtreecommitdiffstats
path: root/mpi-patches/eliminate-locale-dependencies
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-03-29 22:10:02 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-03-29 22:10:02 -0700
commit53d6cd8562ff76f742fe72c62046928188e9478e (patch)
treeeda0d97506692f294aac8e5e085769e83e79683f /mpi-patches/eliminate-locale-dependencies
parentc6e5383217c70914a933f1911bf48a1e54b26595 (diff)
downloadtxr-53d6cd8562ff76f742fe72c62046928188e9478e.tar.gz
txr-53d6cd8562ff76f742fe72c62046928188e9478e.tar.bz2
txr-53d6cd8562ff76f742fe72c62046928188e9478e.zip
* mpi-patches/eliminate-locale-dependencies: New patch.
(s_mp_tovalue): Eliminate use of isupper, islower. * mpi-patches/series: Add patch.
Diffstat (limited to 'mpi-patches/eliminate-locale-dependencies')
-rw-r--r--mpi-patches/eliminate-locale-dependencies45
1 files changed, 45 insertions, 0 deletions
diff --git a/mpi-patches/eliminate-locale-dependencies b/mpi-patches/eliminate-locale-dependencies
new file mode 100644
index 00000000..6ab1b63a
--- /dev/null
+++ b/mpi-patches/eliminate-locale-dependencies
@@ -0,0 +1,45 @@
+Index: mpi-1.8.6/mpi.c
+===================================================================
+--- mpi-1.8.6.orig/mpi.c 2015-03-29 22:04:45.548237064 -0700
++++ mpi-1.8.6/mpi.c 2015-03-30 08:17:35.252749065 -0700
+@@ -4693,17 +4693,22 @@
+ int s_mp_tovalue(int ch, int r)
+ {
+ int val, xch;
+-
+- if(r > 36)
+- xch = ch;
++
++ /* For bases up to 36, the letters of the alphabet are
++ case-insensitive and denote digits valued 10 through 36.
++ For bases greater than 36, the lower case letters have
++ their own meaning and denote values past 36. */
++
++ if (r <= 36 && ch >= 'a' && ch <= 'z')
++ xch = ch - 'a' + 'A';
+ else
+- xch = toupper(ch);
++ xch = ch;
+
+- if(isdigit(xch))
++ if(xch >= '0' && xch <= '9')
+ val = xch - '0';
+- else if(isupper(xch))
++ else if(xch >= 'A' && xch <= 'Z')
+ val = xch - 'A' + 10;
+- else if(islower(xch))
++ else if(xch >= 'a' && xch <= 'z')
+ val = xch - 'a' + 36;
+ else if(xch == '+')
+ val = 62;
+@@ -4741,8 +4746,8 @@
+
+ ch = s_dmap_1[val];
+
+- if(r <= 36 && low)
+- ch = tolower(ch);
++ if(low && val > 9 && r <= 36)
++ ch = ch - 'A' + 'a';
+
+ return ch;
+