#include "xmalloc.h"
#include "lc_printf.h"
-#include "lc_defines.h"
#include "hashptr.h"
+#include "util.h"
#include "set.h"
/* printf implementation */
arg.letter = letter;
arg.handler = handler;
- if (isupper(letter)) {
+ if (isupper((unsigned char)letter)) {
map = env->upper;
base = 'A';
}
- else if (islower(letter)) {
+ else if (islower((unsigned char)letter)) {
map = env->lower;
base = 'a';
}
- ent = (lc_arg_t*)set_insert(env->args, &arg, sizeof(arg), HASH_STR(name, strlen(name)));
+ ent = set_insert(lc_arg_t, env->args, &arg, sizeof(arg), hash_str(name));
if (ent && base != 0)
map[letter - base] = ent;
if (!occ->flag_minus && occ->flag_zero)
pad = '0';
- return lc_appendable_snwadd(app, str, len, LC_MAX(0, occ->width), occ->flag_minus, pad);
+ return lc_appendable_snwadd(app, str, len, MAX(0, occ->width), occ->flag_minus, pad);
}
assert(occ->modifier && "modifier must not be NULL");
strncpy(mod, occ->modifier, sizeof(mod) - 1);
- mod[LC_MIN(sizeof(mod) - 1, occ->modifier_length)] = '\0';
+ mod[MIN(sizeof(mod) - 1, occ->modifier_length)] = '\0';
#ifdef _MSC_VER
/* work-around for buggy mscrt not supporting z, j, and t modifier */
default:
{
- int len = LC_MAX(128, occ->width + 1);
+ int len = MAX(128, occ->width + 1);
char *buf = XMALLOCN(char, len);
res = dispatch_snprintf(buf, len, fmt, occ->lc_arg_type, val);
res = lc_appendable_snadd(app, buf, res);
/* Negative or lacking precision after a '.' is treated as
* precision 0. */
- occ.precision = LC_MAX(0, precision);
+ occ.precision = MAX(0, precision);
}
/*
name[n] = '\0';
tmp.name = name;
- arg = (lc_arg_t*)set_find(env->args, &tmp, sizeof(tmp), HASH_STR(named, n));
+ arg = set_find(lc_arg_t, env->args, &tmp, sizeof(tmp), hash_str(named));
occ.modifier = "";
occ.modifier_length = 0;
const char *mod = s;
/* Read, as long there are letters */
- while (isalpha(ch) && !arg) {
+ while (isalpha((unsigned char)ch) && !arg) {
int base = 'a';
lc_arg_t * const *map = env->lower;
/* If uppercase, select the uppercase map from the environment */
- if (isupper(ch)) {
+ if (isupper((unsigned char)ch)) {
base = 'A';
map = env->upper;
}