# else
/* We don't have enough input for another complete input
character. */
- while (inptr < inend)
- state->__value.__wchb[inlen++] = *inptr++;
+ size_t inlen_after = inlen + (inend - inptr);
+ assert (inlen_after <= sizeof (state->__value.__wchb));
+ for (; inlen < inlen_after; inlen++)
+ state->__value.__wchb[inlen] = *inptr++;
# endif
return __GCONV_INCOMPLETE_INPUT;
/* We don't have enough input for another complete input
character. */
assert (inend - inptr > (state->__count & ~7));
- assert (inend - inptr <= sizeof (state->__value));
+ assert (inend - inptr <= sizeof (state->__value.__wchb));
state->__count = (state->__count & ~7) | (inend - inptr);
- inlen = 0;
- while (inptr < inend)
- state->__value.__wchb[inlen++] = *inptr++;
+ for (inlen = 0; inlen < inend - inptr; inlen++)
+ state->__value.__wchb[inlen] = inptr[inlen];
+ inptr = inend;
# endif
}
# else
/* Make sure the remaining bytes fit into the state objects
buffer. */
- assert (inend - *inptrp < 4);
+ size_t cnt_after = inend - *inptrp;
+ assert (cnt_after <= sizeof (data->__statep->__value.__wchb));
size_t cnt;
- for (cnt = 0; *inptrp < inend; ++cnt)
- data->__statep->__value.__wchb[cnt] = *(*inptrp)++;
+ for (cnt = 0; cnt < cnt_after; ++cnt)
+ data->__statep->__value.__wchb[cnt] = (*inptrp)[cnt];
+ *inptrp = inend;
data->__statep->__count &= ~7;
data->__statep->__count |= cnt;
# endif