mirror of
https://github.com/curl/curl.git
synced 2026-07-30 16:48:03 +03:00
source cleanup: unify look, style and indent levels
By the use of a the new lib/checksrc.pl script that checks that our basic source style rules are followed.
This commit is contained in:
parent
592eda8e3f
commit
b903186fa0
88 changed files with 1411 additions and 1577 deletions
154
lib/mprintf.c
154
lib/mprintf.c
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1999 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1999 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
|
|
@ -547,67 +547,65 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
|||
#endif
|
||||
|
||||
/* Read the arg list parameters into our data list */
|
||||
for (i=0; i<max_param; i++) {
|
||||
if((i + 1 < max_param) && (vto[i + 1].type == FORMAT_WIDTH))
|
||||
{
|
||||
/* Width/precision arguments must be read before the main argument
|
||||
* they are attached to
|
||||
*/
|
||||
vto[i + 1].data.num.as_signed = (mp_intmax_t)va_arg(arglist, int);
|
||||
}
|
||||
for(i=0; i<max_param; i++) {
|
||||
if((i + 1 < max_param) && (vto[i + 1].type == FORMAT_WIDTH)) {
|
||||
/* Width/precision arguments must be read before the main argument
|
||||
* they are attached to
|
||||
*/
|
||||
vto[i + 1].data.num.as_signed = (mp_intmax_t)va_arg(arglist, int);
|
||||
}
|
||||
|
||||
switch (vto[i].type)
|
||||
{
|
||||
case FORMAT_STRING:
|
||||
vto[i].data.str = va_arg(arglist, char *);
|
||||
break;
|
||||
switch (vto[i].type) {
|
||||
case FORMAT_STRING:
|
||||
vto[i].data.str = va_arg(arglist, char *);
|
||||
break;
|
||||
|
||||
case FORMAT_INTPTR:
|
||||
case FORMAT_UNKNOWN:
|
||||
case FORMAT_PTR:
|
||||
vto[i].data.ptr = va_arg(arglist, void *);
|
||||
break;
|
||||
case FORMAT_INTPTR:
|
||||
case FORMAT_UNKNOWN:
|
||||
case FORMAT_PTR:
|
||||
vto[i].data.ptr = va_arg(arglist, void *);
|
||||
break;
|
||||
|
||||
case FORMAT_INT:
|
||||
case FORMAT_INT:
|
||||
#ifdef HAVE_LONG_LONG_TYPE
|
||||
if((vto[i].flags & FLAGS_LONGLONG) && (vto[i].flags & FLAGS_UNSIGNED))
|
||||
vto[i].data.num.as_unsigned =
|
||||
(mp_uintmax_t)va_arg(arglist, mp_uintmax_t);
|
||||
else if(vto[i].flags & FLAGS_LONGLONG)
|
||||
vto[i].data.num.as_signed =
|
||||
(mp_intmax_t)va_arg(arglist, mp_intmax_t);
|
||||
else
|
||||
if((vto[i].flags & FLAGS_LONGLONG) && (vto[i].flags & FLAGS_UNSIGNED))
|
||||
vto[i].data.num.as_unsigned =
|
||||
(mp_uintmax_t)va_arg(arglist, mp_uintmax_t);
|
||||
else if(vto[i].flags & FLAGS_LONGLONG)
|
||||
vto[i].data.num.as_signed =
|
||||
(mp_intmax_t)va_arg(arglist, mp_intmax_t);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if((vto[i].flags & FLAGS_LONG) && (vto[i].flags & FLAGS_UNSIGNED))
|
||||
vto[i].data.num.as_unsigned =
|
||||
(mp_uintmax_t)va_arg(arglist, unsigned long);
|
||||
else if(vto[i].flags & FLAGS_LONG)
|
||||
vto[i].data.num.as_signed =
|
||||
(mp_intmax_t)va_arg(arglist, long);
|
||||
else if(vto[i].flags & FLAGS_UNSIGNED)
|
||||
vto[i].data.num.as_unsigned =
|
||||
(mp_uintmax_t)va_arg(arglist, unsigned int);
|
||||
else
|
||||
vto[i].data.num.as_signed =
|
||||
(mp_intmax_t)va_arg(arglist, int);
|
||||
}
|
||||
break;
|
||||
|
||||
case FORMAT_DOUBLE:
|
||||
vto[i].data.dnum = va_arg(arglist, double);
|
||||
break;
|
||||
|
||||
case FORMAT_WIDTH:
|
||||
/* Argument has been read. Silently convert it into an integer
|
||||
* for later use
|
||||
*/
|
||||
vto[i].type = FORMAT_INT;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
{
|
||||
if((vto[i].flags & FLAGS_LONG) && (vto[i].flags & FLAGS_UNSIGNED))
|
||||
vto[i].data.num.as_unsigned =
|
||||
(mp_uintmax_t)va_arg(arglist, unsigned long);
|
||||
else if(vto[i].flags & FLAGS_LONG)
|
||||
vto[i].data.num.as_signed =
|
||||
(mp_intmax_t)va_arg(arglist, long);
|
||||
else if(vto[i].flags & FLAGS_UNSIGNED)
|
||||
vto[i].data.num.as_unsigned =
|
||||
(mp_uintmax_t)va_arg(arglist, unsigned int);
|
||||
else
|
||||
vto[i].data.num.as_signed =
|
||||
(mp_intmax_t)va_arg(arglist, int);
|
||||
}
|
||||
break;
|
||||
|
||||
case FORMAT_DOUBLE:
|
||||
vto[i].data.dnum = va_arg(arglist, double);
|
||||
break;
|
||||
|
||||
case FORMAT_WIDTH:
|
||||
/* Argument has been read. Silently convert it into an integer
|
||||
* for later use
|
||||
*/
|
||||
vto[i].type = FORMAT_INT;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return max_param;
|
||||
|
|
@ -914,7 +912,7 @@ static int dprintf_formatf(
|
|||
if(p->flags & FLAGS_LEFT)
|
||||
while(width-- > 0)
|
||||
OUTCHAR(' ');
|
||||
for (point = strnil; *point != '\0'; ++point)
|
||||
for(point = strnil; *point != '\0'; ++point)
|
||||
OUTCHAR(*point);
|
||||
if(! (p->flags & FLAGS_LEFT))
|
||||
while(width-- > 0)
|
||||
|
|
@ -1202,45 +1200,3 @@ int curl_mvfprintf(FILE *whereto, const char *format, va_list ap_save)
|
|||
{
|
||||
return dprintf_formatf(whereto, fputc, format, ap_save);
|
||||
}
|
||||
|
||||
#ifdef DPRINTF_DEBUG
|
||||
int main()
|
||||
{
|
||||
char buffer[129];
|
||||
char *ptr;
|
||||
#ifdef HAVE_LONG_LONG_TYPE
|
||||
LONG_LONG_TYPE one=99;
|
||||
LONG_LONG_TYPE two=100;
|
||||
LONG_LONG_TYPE test = 0x1000000000LL;
|
||||
curl_mprintf("%lld %lld %lld\n", one, two, test);
|
||||
#endif
|
||||
|
||||
curl_mprintf("%3d %5d\n", 10, 1998);
|
||||
|
||||
ptr=curl_maprintf("test this then baby %s%s%s%s%s%s %d %d %d loser baby get a kiss in yer face now!", "", "pretty long string pretty long string pretty long string pretty long string pretty long string", "/", "/", "/", "pretty long string", 1998, 1999, 2001);
|
||||
|
||||
puts(ptr);
|
||||
|
||||
memset(ptr, 55, strlen(ptr)+1);
|
||||
|
||||
free(ptr);
|
||||
|
||||
#if 1
|
||||
curl_mprintf(buffer, "%s %s %d", "daniel", "stenberg", 19988);
|
||||
puts(buffer);
|
||||
|
||||
curl_mfprintf(stderr, "%s %#08x\n", "dummy", 65);
|
||||
|
||||
printf("%s %#08x\n", "dummy", 65);
|
||||
{
|
||||
double tryout = 3.14156592;
|
||||
curl_mprintf(buffer, "%.2g %G %f %e %E", tryout, tryout, tryout, tryout, tryout);
|
||||
puts(buffer);
|
||||
printf("%.2g %G %f %e %E\n", tryout, tryout, tryout, tryout, tryout);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue