removed old code and made briefer
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1632 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
		@@ -191,46 +191,28 @@ vsnprintf (char *str, size_t sz, const char *format, va_list args)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					 | 
				
			||||||
sn_append_char (struct state *state, char c)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  if(state->s < state->theend) {
 | 
					 | 
				
			||||||
    *state->s++ = c;
 | 
					 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    *state->s++ = '\0';
 | 
					 | 
				
			||||||
    return 1;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
sn_reserve (struct state *state, size_t n)
 | 
					sn_reserve (struct state *state, size_t n)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  return state->s + n >= state->theend;
 | 
					  return state->s + n > state->theend;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
as_append_char (struct state *state, char c)
 | 
					sn_append_char (struct state *state, char c)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (state->s >= state->theend) {
 | 
					  if (sn_reserve (state, 1)) {
 | 
				
			||||||
    int off = state->s - state->str;
 | 
					    *state->s++ = '\0';
 | 
				
			||||||
 | 
					 | 
				
			||||||
    state->sz *= 2;
 | 
					 | 
				
			||||||
    state->str = realloc (state->str, state->sz);
 | 
					 | 
				
			||||||
    if (state->str == NULL) {
 | 
					 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
    }
 | 
					  } else {
 | 
				
			||||||
    state->s = state->str + off;
 | 
					 | 
				
			||||||
    state->theend = state->str + state->sz - 1;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
    *state->s++ = c;
 | 
					    *state->s++ = c;
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
as_reserve (struct state *state, size_t n)
 | 
					as_reserve (struct state *state, size_t n)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  while (state->s + n >= state->theend) {
 | 
					  while (state->s + n > state->theend) {
 | 
				
			||||||
    int off = state->s - state->str;
 | 
					    int off = state->s - state->str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    state->sz *= 2;
 | 
					    state->sz *= 2;
 | 
				
			||||||
@@ -243,19 +225,16 @@ as_reserve (struct state *state, size_t n)
 | 
				
			|||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0 /* old code */
 | 
					 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
append_char (char **s, char *theend, char c)
 | 
					as_append_char (struct state *state, char c)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (*s < theend) {
 | 
					  if(as_reserve (state, 1))
 | 
				
			||||||
    *(*s)++ = c;
 | 
					 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    *(*s)++ = '\0';
 | 
					 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
 | 
					  else {
 | 
				
			||||||
 | 
					    *state->s++ = c;
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
append_number (struct state *state,
 | 
					append_number (struct state *state,
 | 
				
			||||||
@@ -291,38 +270,15 @@ append_number (struct state *state,
 | 
				
			|||||||
    state->s[-len+i] = c;
 | 
					    state->s[-len+i] = c;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if 0 /* old */
 | 
					 | 
				
			||||||
  for (i = 0; i < len / 2; ++i) {
 | 
					 | 
				
			||||||
    char c;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    c = beg[i];
 | 
					 | 
				
			||||||
    beg[i] = beg[len-i-1];
 | 
					 | 
				
			||||||
    beg[len-i-1] = c;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (width > len) {
 | 
					  if (width > len) {
 | 
				
			||||||
    if ((*state->reserve) (state, width - len))
 | 
					    if ((*state->reserve) (state, width - len))
 | 
				
			||||||
      return 1;
 | 
					      return 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
    if (*s + width - len >= theend) {
 | 
					 | 
				
			||||||
      *(*s)++ = '\0';
 | 
					 | 
				
			||||||
      return 1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
    memmove (state->s + width - 2 * len, state->s - len, len);
 | 
					    memmove (state->s + width - 2 * len, state->s - len, len);
 | 
				
			||||||
    for (i = 0; i < width - len; ++i)
 | 
					    for (i = 0; i < width - len; ++i)
 | 
				
			||||||
      state->s[-len+i] = (zerop ? '0' : ' ');
 | 
					      state->s[-len+i] = (zerop ? '0' : ' ');
 | 
				
			||||||
    state->s += width - len;
 | 
					    state->s += width - len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if 0
 | 
					 | 
				
			||||||
    memmove (beg + width - len, beg, len);
 | 
					 | 
				
			||||||
    for (i = 0; i < width - len; ++i)
 | 
					 | 
				
			||||||
      beg[i] = (zerop ? '0' : ' ');
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user