summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal.h1
-rw-r--r--pack.c2
-rw-r--r--sprintf.c2
-rw-r--r--util.c5
-rw-r--r--vsnprintf.c14
5 files changed, 17 insertions, 7 deletions
diff --git a/internal.h b/internal.h
index 1666884ef9..6c22f372fb 100644
--- a/internal.h
+++ b/internal.h
@@ -1157,6 +1157,7 @@ VALUE rb_setup_fake_str(struct RString *fake_str, const char *name, long len, rb
/* util.c (export) */
extern const signed char ruby_digit36_to_number_table[];
+extern const char ruby_hexdigits[];
/* variable.c (export) */
void rb_gc_mark_global_tbl(void);
diff --git a/pack.c b/pack.c
index 54f53036c8..73974b76f0 100644
--- a/pack.c
+++ b/pack.c
@@ -1204,7 +1204,7 @@ infected_str_new(const char *ptr, long len, VALUE str)
static VALUE
pack_unpack(VALUE str, VALUE fmt)
{
- static const char hexdigits[] = "0123456789abcdef";
+#define hexdigits ruby_hexdigits
char *s, *send;
char *p, *pend;
VALUE ary;
diff --git a/sprintf.c b/sprintf.c
index d91d850c9d..376285476d 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -1252,6 +1252,8 @@ fmt_setup(char *buf, size_t size, int c, int flags, int width, int prec)
#ifdef RUBY_PRI_VALUE_MARK
# define PRI_EXTRA_MARK RUBY_PRI_VALUE_MARK
#endif
+#define lower_hexdigits (ruby_hexdigits+0)
+#define upper_hexdigits (ruby_hexdigits+16)
#include "vsnprintf.c"
typedef struct {
diff --git a/util.c b/util.c
index 3d476a8d75..807f43f29e 100644
--- a/util.c
+++ b/util.c
@@ -23,6 +23,9 @@
#include "ruby/util.h"
+const char ruby_hexdigits[] = "0123456789abcdef0123456789ABCDEF";
+#define hexdigit ruby_hexdigits
+
unsigned long
ruby_scan_oct(const char *start, size_t len, size_t *retlen)
{
@@ -40,7 +43,6 @@ ruby_scan_oct(const char *start, size_t len, size_t *retlen)
unsigned long
ruby_scan_hex(const char *start, size_t len, size_t *retlen)
{
- static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
register const char *s = start;
register unsigned long retval = 0;
const char *tmp;
@@ -1993,7 +1995,6 @@ ruby_strtod(const char *s00, char **se)
break2:
if (*s == '0') {
if (s[1] == 'x' || s[1] == 'X') {
- static const char hexdigit[] = "0123456789abcdef0123456789ABCDEF";
s0 = ++s;
adj = 0;
aadj = 1.0;
diff --git a/vsnprintf.c b/vsnprintf.c
index 36f6f25465..76178fed5e 100644
--- a/vsnprintf.c
+++ b/vsnprintf.c
@@ -510,6 +510,12 @@ static int exponent(char *, int, int);
#endif /* FLOATING_POINT */
+#ifndef lower_hexdigits
+# define lower_hexdigits "0123456789abcdef"
+#endif
+#ifndef upper_hexdigits
+# define upper_hexdigits "0123456789ABCDEF"
+#endif
/*
* Flags used during conversion.
@@ -993,7 +999,7 @@ fp_begin: _double = va_arg(ap, double);
#endif /* _HAVE_SANE_QUAD_ */
#endif
base = 16;
- xdigs = "0123456789abcdef";
+ xdigs = lower_hexdigits;
ch = 'x';
goto nosign;
case 's':
@@ -1031,10 +1037,10 @@ fp_begin: _double = va_arg(ap, double);
base = 10;
goto nosign;
case 'X':
- xdigs = "0123456789ABCDEF";
+ xdigs = upper_hexdigits;
goto hex;
case 'x':
- xdigs = "0123456789abcdef";
+ xdigs = lower_hexdigits;
hex:
#ifdef _HAVE_SANE_QUAD_
if (flags & QUADINT)
@@ -1251,7 +1257,7 @@ cvt(double value, int ndigits, int flags, char *sign, int *decpt, int ch, int *l
}
if (ch == 'a' || ch =='A') {
digits = BSD__hdtoa(value,
- ch == 'a' ? "0123456789abcdef" : "0123456789ABCDEF",
+ ch == 'a' ? lower_hexdigits : upper_hexdigits,
ndigits, decpt, &dsgn, &rve);
}
else {