blob: 6ab1b63af869bf27164e04ed98e1ca93024ff28b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;
|