Skip to content

Commit fe3bd2d

Browse files
committed
Returns MP_VAL if not supported
1 parent 0227d84 commit fe3bd2d

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

doc/bn.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2447,8 +2447,8 @@ \subsection{To ASCII}
24472447
printf("In hex: %kN and in decimal: %N\textbackslash{}n", &a, &a);
24482448
printf("In bin: %bN and in base 64: %@N\textbackslash{}n", &a, &a);
24492449
printf("And finally octal: %oN \textbackslash{}n", &a);
2450-
24512450
\end{alltt}
2451+
Returns \texttt{MP\_VAL} if that function is not supported.
24522452

24532453
\subsection{From ASCII}
24542454
\index{mp\_read\_radix}

mp_printf_extension.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
55
/* SPDX-License-Identifier: Unlicense */
66

7-
#ifdef _MSC_VER
8-
mp_err mp_printf_extension(void)
9-
{
10-
return MP_VAL;
11-
}
127

13-
#else
14-
15-
/* TODO: find min version of glibc. Seems to be >2.9, check */
16-
#if (!(defined MP_NO_FILE) && (defined __GLIBC__))
8+
#if ((defined(__GLIBC__)) && (defined(__GLIBC_MINOR__)) )
9+
#define GLIBC_VERSION (__GLIBC__ * 1000 + __GLIBC_MINOR__)
10+
#endif
1711

12+
#if (!(defined(_MSC_VER)) && !(defined(MP_NO_FILE)) && (defined(GLIBC_VERSION)) && (GLIBC_VERSION > 2009) )
1813
/* The functions in printf.h are not threadsafe to begin with */
1914
static int mp_hexmod = 0;
2015
static int mp_octmod = 0;
@@ -27,12 +22,9 @@ static int s_mp_print_mp_int(FILE *stream, const struct printf_info *info, con
2722
mp_err err = MP_OKAY;
2823
const mp_int *a;
2924
char *buf, *start_buf;
30-
int base;
31-
size_t size, written;
32-
int len;
33-
size_t extra_len = 0u;
34-
int idx = 0;
3525
char *prefixed_zero = "";
26+
int base, len, idx = 0;
27+
size_t size, written, extra_len = 0u;
3628

3729
/* Fiddle our bigint out of the argument list */
3830
a = *((const mp_int * const *)(args[0]));
@@ -178,6 +170,10 @@ mp_err mp_printf_extension(void)
178170

179171
return err;
180172
}
181-
#endif
173+
#else
174+
mp_err mp_printf_extension(void)
175+
{
176+
return MP_VAL;
177+
}
182178
#endif
183179
#endif

0 commit comments

Comments
 (0)