From 7295b7eda04d4d80f032988cb15d22a3610f8780 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Thu, 5 Apr 2007 13:29:41 +0000 Subject: Replaced tabs with spaces --- man3/stdarg.3 | 83 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 39 deletions(-) (limited to 'man3/stdarg.3') diff --git a/man3/stdarg.3 b/man3/stdarg.3 index 9560b272e5..dd56df80a4 100644 --- a/man3/stdarg.3 +++ b/man3/stdarg.3 @@ -154,15 +154,15 @@ In such a setup (by far the most common) there seems nothing against an assignment .RS .nf - va_list aq = ap; + va_list aq = ap; .fi .RE Unfortunately, there are also systems that make it an array of pointers (of length 1), and there one needs .RS .nf - va_list aq; - *aq = *ap; + va_list aq; + *aq = *ap; .fi .RE Finally, on systems where parameters are passed in registers, @@ -179,10 +179,10 @@ To accommodate this situation, C99 adds a macro so that the above assignment can be replaced by .RS .nf - va_list aq; - va_copy(aq, ap); - ... - va_end(aq); + va_list aq; + va_copy(aq, ap); + ... + va_end(aq); .fi .RE Each invocation of @@ -205,30 +205,32 @@ with each format character based on the type. #include #include -void foo(char *fmt, ...) { - va_list ap; - int d; - char c, *s; +void +foo(char *fmt, ...) +{ + va_list ap; + int d; + char c, *s; - va_start(ap, fmt); - while (*fmt) - switch(*fmt++) { - case 's': /* string */ - s = va_arg(ap, char *); - printf("string %s\en", s); - break; - case 'd': /* int */ - d = va_arg(ap, int); - printf("int %d\en", d); - break; - case 'c': /* char */ - /* need a cast here since va_arg only - takes fully promoted types */ - c = (char) va_arg(ap, int); - printf("char %c\en", c); - break; - } - va_end(ap); + va_start(ap, fmt); + while (*fmt) + switch(*fmt++) { + case 's': /* string */ + s = va_arg(ap, char *); + printf("string %s\en", s); + break; + case 'd': /* int */ + d = va_arg(ap, int); + printf("int %d\en", d); + break; + case 'c': /* char */ + /* need a cast here since va_arg only + takes fully promoted types */ + c = (char) va_arg(ap, int); + printf("char %c\en", c); + break; + } + va_end(ap); } .fi .RE @@ -254,16 +256,19 @@ The historic setup is: .nf #include -void foo(va_alist) va_dcl { - va_list ap; +void +foo(va_alist) + va_dcl +{ + va_list ap; - va_start(ap); - while(...) { - ... - x = va_arg(ap, type); - ... - } - va_end(ap); + va_start(ap); + while(...) { + ... + x = va_arg(ap, type); + ... + } + va_end(ap); } .fi .RE -- cgit 1.2.3-korg