rename internal constant radix arrays

This commit is contained in:
Daniel Mendler 2019-10-17 16:59:02 +02:00
parent 55acc6ab5b
commit 20dcc923f6
No known key found for this signature in database
GPG Key ID: D88ADB2A2693CA43
5 changed files with 11 additions and 11 deletions

View File

@ -30,11 +30,11 @@ mp_err mp_fread(mp_int *a, int radix, FILE *stream)
do {
int y;
unsigned pos = (unsigned)(ch - (int)'(');
if (mp_s_rmap_reverse_sz < pos) {
if (MP_RMAP_REVERSE_SIZE < pos) {
break;
}
y = (int)mp_s_rmap_reverse[pos];
y = (int)s_mp_rmap_reverse[pos];
if ((y == 0xff) || (y >= radix)) {
break;

View File

@ -4,8 +4,8 @@
/* SPDX-License-Identifier: Unlicense */
/* chars used in radix conversions */
const char *const mp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
const uint8_t mp_s_rmap_reverse[] = {
const char s_mp_rmap[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/";
const uint8_t s_mp_rmap_reverse[] = {
0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, /* ()*+,-./ */
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 01234567 */
0x08, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 89:;<=>? */
@ -18,5 +18,5 @@ const uint8_t mp_s_rmap_reverse[] = {
0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, /* pqrstuvw */
0x3b, 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, /* xyz{|}~. */
};
const size_t mp_s_rmap_reverse_sz = sizeof(mp_s_rmap_reverse);
MP_STATIC_ASSERT(correct_rmap_reverse_size, sizeof(s_mp_rmap_reverse) == MP_RMAP_REVERSE_SIZE)
#endif

View File

@ -43,10 +43,10 @@ mp_err mp_read_radix(mp_int *a, const char *str, int radix)
*/
ch = (radix <= 36) ? (char)MP_TOUPPER((int)*str) : *str;
pos = (unsigned)(ch - '(');
if (mp_s_rmap_reverse_sz < pos) {
if (MP_RMAP_REVERSE_SIZE < pos) {
break;
}
y = (int)mp_s_rmap_reverse[pos];
y = (int)s_mp_rmap_reverse[pos];
/* if the char was found in the map
* and is less than the given radix add it

View File

@ -60,7 +60,7 @@ mp_err mp_to_radix(const mp_int *a, char *str, size_t maxlen, size_t *written, i
if ((err = mp_div_d(&t, (mp_digit)radix, &t, &d)) != MP_OKAY) {
goto LBL_ERR;
}
*str++ = mp_s_rmap[d];
*str++ = s_mp_rmap[d];
++digs;
}
/* reverse the digits of the string. In this case _s points

View File

@ -215,9 +215,9 @@ MP_PRIVATE mp_err s_mp_prime_is_divisible(const mp_int *a, mp_bool *result);
MP_PRIVATE mp_err s_mp_rand_jenkins(void *p, size_t n) MP_WUR;
MP_PRIVATE void s_mp_rand_jenkins_init(uint64_t seed);
extern MP_PRIVATE const char *const mp_s_rmap;
extern MP_PRIVATE const uint8_t mp_s_rmap_reverse[];
extern MP_PRIVATE const size_t mp_s_rmap_reverse_sz;
#define MP_RMAP_REVERSE_SIZE 88
extern MP_PRIVATE const char s_mp_rmap[];
extern MP_PRIVATE const uint8_t s_mp_rmap_reverse[];
extern MP_PRIVATE const mp_digit s_mp_prime_tab[];
/* number of primes */