unsigned long num, unsigned base, char *rep,
unsigned long num, unsigned base, unsigned char *rep,
append_number(struct state *state,	      unsigned long num, unsigned base, char *rep,	      int width, int prec, int flags, int minusp){  int len = 0;  int i;  /* given precision, ignore zero flag */  if(prec != -1)    flags &= ~zero_flag;  else    prec = 1;  /* zero value with zero precision -> "" */  if(prec == 0 && num == 0)    return 0;  do{    if((*state->append_char)(state, rep[num % base]))      return 1;    len++;    num /= base;  }while(num);  prec -= len;  /* pad with prec zeros */  while(prec-- > 0){    if((*state->append_char)(state, '0'))      return 1;    len++;  }  /* add length of alternate prefix (added later) to len */  if(flags & alternate_flag && (base == 16 || base == 8))    len += base / 8;  /* pad with zeros */  if(flags & zero_flag){    width -= len;    if(minusp || (flags & space_flag) || (flags & plus_flag))      width--;    while(width-- > 0){      if((*state->append_char)(state, '0'))	return 1;      len++;    }  }  /* add alternate prefix */  if(flags & alternate_flag && (base == 16 || base == 8)){    if(base == 16)      if((*state->append_char)(state, rep[10] + 23)) /* XXX */	return 1;    if((*state->append_char)(state, '0'))      return 1;  }  /* add sign */  if(minusp){    if((*state->append_char)(state, '-'))      return 1;    len++;  } else if(flags & plus_flag) {    if((*state->append_char)(state, '+'))      return 1;    len++;  } else if(flags & space_flag) {    if((*state->append_char)(state, ' '))      return 1;    len++;  }  if(flags & minus_flag)    /* swap before padding with spaces */    for(i = 0; i < len / 2; i++){      char c = state->s[-i-1];      state->s[-i-1] = state->s[-len+i];      state->s[-len+i] = c;    }  width -= len;  while(width-- > 0){    if((*state->append_char)(state,  ' '))      return 1;    len++;  }  if(!(flags & minus_flag))    /* swap after padding with spaces */    for(i = 0; i < len / 2; i++){      char c = state->s[-i-1];      state->s[-i-1] = state->s[-len+i];      state->s[-len+i] = c;    }      return 0;}