trim trailing spaces

This commit is contained in:
Steffen Jaeckel
2017-07-04 15:25:19 +02:00
committed by Dmitry Podgorny
parent 3feed16e2e
commit abd1b08a97
28 changed files with 180 additions and 180 deletions

View File

@@ -35,9 +35,9 @@
* original. Also, there is now a builtin-test, just compile with:
* gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
* and run snprintf for results.
*
*
* Thomas Roessler <roessler@guug.de> 01/27/98 for mutt 0.89i
* The PGP code was using unsigned hexadecimal formats.
* The PGP code was using unsigned hexadecimal formats.
* Unfortunately, unsigned formats simply didn't work.
*
* Michael Elkins <me@cs.hmc.edu> 03/05/98 for mutt 0.90.8
@@ -85,7 +85,7 @@
#define LDOUBLE double
#endif
static int dopr (char *buffer, size_t maxlen, const char *format,
static int dopr (char *buffer, size_t maxlen, const char *format,
va_list args);
static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
char *value, int flags, int min, int max);
@@ -140,7 +140,7 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
int cflags;
int total;
size_t currlen;
state = DP_S_DEFAULT;
currlen = flags = cflags = min = 0;
max = -1;
@@ -152,17 +152,17 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
if (ch == '\0')
state = DP_S_DONE;
switch(state)
switch(state)
{
case DP_S_DEFAULT:
if (ch == '%')
if (ch == '%')
state = DP_S_FLAGS;
else
else
total += dopr_outch (buffer, &currlen, maxlen, ch);
ch = *format++;
break;
case DP_S_FLAGS:
switch (ch)
switch (ch)
{
case '-':
flags |= DP_F_MINUS;
@@ -190,49 +190,49 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
}
break;
case DP_S_MIN:
if (isdigit(ch))
if (isdigit(ch))
{
min = 10*min + char_to_int (ch);
ch = *format++;
}
else if (ch == '*')
}
else if (ch == '*')
{
min = va_arg (args, int);
ch = *format++;
state = DP_S_DOT;
}
else
}
else
state = DP_S_DOT;
break;
case DP_S_DOT:
if (ch == '.')
if (ch == '.')
{
state = DP_S_MAX;
ch = *format++;
}
else
}
else
state = DP_S_MOD;
break;
case DP_S_MAX:
if (isdigit(ch))
if (isdigit(ch))
{
if (max < 0)
max = 0;
max = 10*max + char_to_int (ch);
ch = *format++;
}
else if (ch == '*')
}
else if (ch == '*')
{
max = va_arg (args, int);
ch = *format++;
state = DP_S_MOD;
}
else
}
else
state = DP_S_MOD;
break;
case DP_S_MOD:
/* Currently, we don't support Long Long, bummer */
switch (ch)
switch (ch)
{
case 'h':
cflags = DP_C_SHORT;
@@ -252,11 +252,11 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
state = DP_S_CONV;
break;
case DP_S_CONV:
switch (ch)
switch (ch)
{
case 'd':
case 'i':
if (cflags == DP_C_SHORT)
if (cflags == DP_C_SHORT)
value = va_arg (args, int);
else if (cflags == DP_C_LONG)
value = va_arg (args, long int);
@@ -336,19 +336,19 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
max, flags);
break;
case 'n':
if (cflags == DP_C_SHORT)
if (cflags == DP_C_SHORT)
{
short int *num;
num = va_arg (args, short int *);
*num = currlen;
}
else if (cflags == DP_C_LONG)
}
else if (cflags == DP_C_LONG)
{
long int *num;
num = va_arg (args, long int *);
*num = currlen;
}
else
}
else
{
int *num;
num = va_arg (args, int *);
@@ -380,9 +380,9 @@ static int dopr (char *buffer, size_t maxlen, const char *format, va_list args)
}
if (buffer != NULL && maxlen > 0)
{
if (currlen < maxlen - 1)
if (currlen < maxlen - 1)
buffer[currlen] = '\0';
else
else
buffer[maxlen - 1] = '\0';
}
return total;
@@ -394,7 +394,7 @@ static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
int padlen, strln; /* amount to pad */
int cnt = 0;
int total = 0;
if (value == 0)
{
value = "<NULL>";
@@ -404,9 +404,9 @@ static int fmtstr (char *buffer, size_t *currlen, size_t maxlen,
if (max >= 0 && max < strln)
strln = max;
padlen = min - strln;
if (padlen < 0)
if (padlen < 0)
padlen = 0;
if (flags & DP_F_MINUS)
if (flags & DP_F_MINUS)
padlen = -padlen; /* Left Justify */
while (padlen > 0)
@@ -440,7 +440,7 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
int zpadlen = 0; /* amount to zero pad */
int caps = 0;
int total = 0;
if (max < 0)
max = 0;
@@ -459,7 +459,7 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
if (flags & DP_F_SPACE)
signvalue = ' ';
}
if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
do {
@@ -480,7 +480,7 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
zpadlen = MAX(zpadlen, spadlen);
spadlen = 0;
}
if (flags & DP_F_MINUS)
if (flags & DP_F_MINUS)
spadlen = -spadlen; /* Left Justifty */
#ifdef DEBUG_SNPRINTF
@@ -489,18 +489,18 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
#endif
/* Spaces */
while (spadlen > 0)
while (spadlen > 0)
{
total += dopr_outch (buffer, currlen, maxlen, ' ');
--spadlen;
}
/* Sign */
if (signvalue)
if (signvalue)
total += dopr_outch (buffer, currlen, maxlen, signvalue);
/* Zeros */
if (zpadlen > 0)
if (zpadlen > 0)
{
while (zpadlen > 0)
{
@@ -510,9 +510,9 @@ static int fmtint (char *buffer, size_t *currlen, size_t maxlen,
}
/* Digits */
while (place > 0)
while (place > 0)
total += dopr_outch (buffer, currlen, maxlen, convert[--place]);
/* Left Justified spaces */
while (spadlen < 0) {
total += dopr_outch (buffer, currlen, maxlen, ' ');
@@ -541,7 +541,7 @@ static LDOUBLE _snp_pow10 (int exp)
result *= 10;
exp--;
}
return result;
}
@@ -567,13 +567,13 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
int iplace = 0;
int fplace = 0;
int padlen = 0; /* amount to pad */
int zpadlen = 0;
int zpadlen = 0;
int caps = 0;
int total = 0;
long intpart;
long fracpart;
/*
/*
* AIX manpage says the default is 0, but Solaris says the default
* is 6, and sprintf on AIX defaults to 6
*/
@@ -597,8 +597,8 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
intpart = ufvalue;
/*
* Sorry, we only support 9 digits past the decimal because of our
/*
* Sorry, we only support 9 digits past the decimal because of our
* conversion method
*/
if (max > 9)
@@ -638,18 +638,18 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
fconvert[fplace] = 0;
/* -1 for decimal point, another -1 if we are printing a sign */
padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
zpadlen = max - fplace;
if (zpadlen < 0)
zpadlen = 0;
if (padlen < 0)
if (padlen < 0)
padlen = 0;
if (flags & DP_F_MINUS)
if (flags & DP_F_MINUS)
padlen = -padlen; /* Left Justifty */
if ((flags & DP_F_ZERO) && (padlen > 0))
if ((flags & DP_F_ZERO) && (padlen > 0))
{
if (signvalue)
if (signvalue)
{
total += dopr_outch (buffer, currlen, maxlen, signvalue);
--padlen;
@@ -666,10 +666,10 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
total += dopr_outch (buffer, currlen, maxlen, ' ');
--padlen;
}
if (signvalue)
if (signvalue)
total += dopr_outch (buffer, currlen, maxlen, signvalue);
while (iplace > 0)
while (iplace > 0)
total += dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
/*
@@ -680,7 +680,7 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
{
total += dopr_outch (buffer, currlen, maxlen, '.');
while (fplace > 0)
while (fplace > 0)
total += dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
}
@@ -690,7 +690,7 @@ static int fmtfp (char *buffer, size_t *currlen, size_t maxlen,
--zpadlen;
}
while (padlen < 0)
while (padlen < 0)
{
total += dopr_outch (buffer, currlen, maxlen, ' ');
++padlen;
@@ -720,7 +720,7 @@ int xmpp_snprintf (char *str,size_t count,const char *fmt,...)
{
VA_LOCAL_DECL;
int total;
VA_START (fmt);
total = xmpp_vsnprintf(str, count, fmt, ap);
VA_END;