cpstripped (charstring_t dest, size_t max, char *str)
{
static bool deja_vu;
- static char *oddchar;
+ static char oddchar[MB_LEN_MAX * 2];
static size_t oddlen;
- static char *spacechar;
+ static char spacechar[MB_LEN_MAX * 2];
static size_t spacelen;
char *end;
bool squash;
int w;
if (!deja_vu) {
- size_t two;
-
deja_vu = true;
- two = MB_CUR_MAX * 2; /* Varies at run-time. */
-
- oddchar = mh_xmalloc(two);
- oddlen = wcstombs(oddchar, L"?", two);
+ oddlen = wcstombs(oddchar, L"?", sizeof oddchar);
assert(oddlen > 0);
-
assert(wcwidth(L' ') == 1); /* Need to pad in ones. */
- spacechar = mh_xmalloc(two);
- spacelen = wcstombs(spacechar, L" ", two);
+ spacelen = wcstombs(spacechar, L" ", sizeof spacechar);
assert(spacelen > 0);
}
value *= fmt->f_value;
break;
case FT_LV_DIVIDE_L:
- if (fmt->f_value)
- value /= fmt->f_value;
- else
+ if (fmt->f_value == 0 || (fmt->f_value == -1 && value == INT_MIN)) {
+ // FIXME: Tell the user, and probably stop.
value = 0;
+ } else {
+ value /= fmt->f_value;
+ }
break;
case FT_LV_MODULO_L:
if (fmt->f_value)
value %= fmt->f_value;
else
+ // FIXME: Tell the user, and probably stop.
value = 0;
break;
case FT_SAVESTR:
comp->c_mn will be run through
FT_LS_ADDR, which will strip off any
pers name. */
- free (comp->c_text);
+ /* NB: We remove the call to free() here
+ because it interferes with the buffer
+ management in scansbr.c. Revisit this
+ when we clean up memory handling */
+ /* free (comp->c_text); */
comp->c_text = str = strdup (mn->m_text);
comp->c_mn = mn;
}