44 |
#ifndef CHAR_BIT |
#ifndef CHAR_BIT |
45 |
# define CHAR_BIT 8 |
# define CHAR_BIT 8 |
46 |
#endif |
#endif |
47 |
|
#ifndef SIZE_MAX |
48 |
|
# define SIZE_MAX ((size_t) -1) |
49 |
|
#endif |
50 |
#ifndef UCHAR_MAX |
#ifndef UCHAR_MAX |
51 |
# define UCHAR_MAX ((unsigned char) -1) |
# define UCHAR_MAX ((unsigned char) -1) |
52 |
#endif |
#endif |
53 |
|
#ifndef UINT_MAX |
54 |
|
# define UINT_MAX ((unsigned int) -1) |
55 |
|
#endif |
56 |
|
|
57 |
#if HAVE_C_BACKSLASH_A |
#if HAVE_C_BACKSLASH_A |
58 |
# define ALERT_CHAR '\a' |
# define ALERT_CHAR '\a' |
545 |
one small component of a "memory exhausted" message in slot 0. */ |
one small component of a "memory exhausted" message in slot 0. */ |
546 |
static char slot0[256]; |
static char slot0[256]; |
547 |
static unsigned int nslots = 1; |
static unsigned int nslots = 1; |
548 |
|
unsigned int n0 = n; |
549 |
struct slotvec |
struct slotvec |
550 |
{ |
{ |
551 |
size_t size; |
size_t size; |
554 |
static struct slotvec slotvec0 = {sizeof slot0, slot0}; |
static struct slotvec slotvec0 = {sizeof slot0, slot0}; |
555 |
static struct slotvec *slotvec = &slotvec0; |
static struct slotvec *slotvec = &slotvec0; |
556 |
|
|
557 |
if (nslots <= n) |
if (n < 0) |
558 |
|
abort (); |
559 |
|
|
560 |
|
if (nslots <= n0) |
561 |
{ |
{ |
562 |
int n1 = n + 1; |
unsigned int n1 = n0 + 1; |
563 |
size_t s = n1 * sizeof (struct slotvec); |
size_t s = n1 * sizeof *slotvec; |
564 |
if (! (0 < n1 && n1 == s / sizeof (struct slotvec))) |
|
565 |
abort (); |
if (SIZE_MAX / UINT_MAX <= sizeof *slotvec |
566 |
|
&& n1 != s / sizeof *slotvec) |
567 |
|
xalloc_die (); |
568 |
|
|
569 |
if (slotvec == &slotvec0) |
if (slotvec == &slotvec0) |
570 |
{ |
{ |
571 |
slotvec = (struct slotvec *) xmalloc (sizeof (struct slotvec)); |
slotvec = (struct slotvec *) xmalloc (sizeof *slotvec); |
572 |
*slotvec = slotvec0; |
*slotvec = slotvec0; |
573 |
} |
} |
574 |
slotvec = (struct slotvec *) xrealloc (slotvec, s); |
slotvec = (struct slotvec *) xrealloc (slotvec, s); |
575 |
memset (slotvec + nslots, 0, (n1 - nslots) * sizeof (struct slotvec)); |
memset (slotvec + nslots, 0, (n1 - nslots) * sizeof *slotvec); |
576 |
nslots = n; |
nslots = n1; |
577 |
} |
} |
578 |
|
|
579 |
{ |
{ |
593 |
} |
} |
594 |
|
|
595 |
char * |
char * |
596 |
quotearg_n (unsigned int n, char const *arg) |
quotearg_n (int n, char const *arg) |
597 |
{ |
{ |
598 |
return quotearg_n_options (n, arg, &default_quoting_options); |
return quotearg_n_options (n, arg, &default_quoting_options); |
599 |
} |
} |
605 |
} |
} |
606 |
|
|
607 |
char * |
char * |
608 |
quotearg_n_style (unsigned int n, enum quoting_style s, char const *arg) |
quotearg_n_style (int n, enum quoting_style s, char const *arg) |
609 |
{ |
{ |
610 |
struct quoting_options o; |
struct quoting_options o; |
611 |
o.style = s; |
o.style = s; |