/* Read, classify, and fill other details about the next option. 'psize' is filled with option's size, 'notoalign' with its alignment requirements. Local variable 'size' gets the size to be aligned. (Kpadal option always gets its full alignment, other options are limited by the maximum alignment ('maxalign'). Kchar option needs no alignment despite its size.  */
static KOption getdetails(Header *h, size_t totalsize, const char **fmt, int *psize, int *ntoalign)
/* Read, classify, and fill other details about the next option. 'psize' is filled with option's size, 'notoalign' with its alignment requirements. Local variable 'size' gets the size to be aligned. (Kpadal option always gets its full alignment, other options are limited by the maximum alignment ('maxalign'). Kchar option needs no alignment despite its size.  */
static KOption getdetails(Header *h, size_t totalsize, const char **fmt, int *psize, int *ntoalign)
{
  KOption opt = getoption(h, fmt, psize);
  int align = *psize;
  if (opt == Kpaddalign) {
    if (**fmt == '\0' || getoption(h, fmt, &align) == Kchar || align == 0)
      luaL_argerror(h->L, 1, "invalid next option for option 'X'");
  }
  if (align <= 1 || opt == Kchar)
    *ntoalign = 0;
  else {
    if (align > h->maxalign)
      align = h->maxalign;
    if ((align & (align - 1)) != 0)
      luaL_argerror(h->L, 1, "format asks for alignment not power of 2");
    *ntoalign = (align - (int)(totalsize & (align - 1))) & (align - 1);
  }
  return opt;
}