diff options
| author | Michael Kerrisk <mtk.manpages@gmail.com> | 2007-04-05 13:29:41 +0000 |
|---|---|---|
| committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2007-04-05 13:29:41 +0000 |
| commit | 7295b7eda04d4d80f032988cb15d22a3610f8780 (patch) | |
| tree | 5e25f36c92af177438fdfbb131d9015b552236ff /man3/stdarg.3 | |
| parent | 1bef0ec2656f45fa7bee0ac03103eb5ea920ae8e (diff) | |
| download | man-pages-7295b7eda04d4d80f032988cb15d22a3610f8780.tar.gz | |
Replaced tabs with spaces
Diffstat (limited to 'man3/stdarg.3')
| -rw-r--r-- | man3/stdarg.3 | 83 |
1 files changed, 44 insertions, 39 deletions
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 <stdio.h> #include <stdarg.h> -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 <varargs.h> -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 |
