Date: Sat, 28 Nov 1998 13:59:40 -0500 From: "Michael E. Mercer" <mmercer@ipass.net> To: "freebsd-questions@FreeBSD.ORG" <freebsd-questions@FreeBSD.ORG> Subject: Re: stdarg.h - weird infinite loop. Message-ID: <3660481C.19450731@ipass.net> References: <365F98FD.8AED5C78@ipass.net>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
I found the problem...an unset bool in my code.
sorry to have bothered you all.
later
Michael
"Michael E. Mercer" wrote:
>
> here'a my code...what am I doing wrong?
> I tried using vsprintf first..it is an infinite loop as well.
>
> Notice I included stdarg.h ... va_end has no definition??
>
> Thanks
> Michael
>
> #ifndef _STDARG_H_
> #define _STDARG_H_
>
> typedef char *va_list;
>
> #define __va_size(type) \
> (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
>
> #ifdef __GNUC__
> #define va_start(ap, last) \
> ((ap) = (va_list)__builtin_next_arg(last))
> #else
> #define va_start(ap, last) \
> ((ap) = (va_list)&(last) + __va_size(last))
> #endif
>
> #define va_arg(ap, type) \
> (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
>
> #define va_end(ap)
>
> #endif /* !_STDARG_H_ */
>
> ---------------------------------------------------
> create_and_print_string ( const int size, ... )
> {
> short rc = 0;
> char line[2000];
> char tmp[50];
> char *fmt = NULL;
> va_list ap;
> int i = 0;
> int len = 0;
>
> bzero ( line , sizeof ( char ) * 2000 );
>
> va_start(ap, size);
>
> fmt = va_arg ( ap , char * );
>
> len = strlen ( fmt );
>
> for ( i = 0; i < len ; i++ )
> {
> switch ( fmt[i] )
> {
> case '%':
> i++;
> switch ( fmt[i] )
> {
> case 'd': sprintf( tmp , "%d", va_arg ( ap , int ));
> strcat ( line , tmp );
> break;
> case 's': sprintf( tmp , "%s", va_arg ( ap , char * ));
> strcat ( line , tmp );
> break;
> default: sprintf( tmp , "%%%c", fmt[i] );
> strcat ( line, tmp );
> break; }
> break;
> default: sprintf( tmp , "%c", fmt[i] );
> strcat ( line , tmp );
> break;
> }
> }
>
> va_end ( ap );
>
> rc = print_string ( line );
>
> return ( rc );
> }
[-- Attachment #2 --]
begin:vcard
n:Mercer;Michael
x-mozilla-html:FALSE
adr:;;4309/1518 Waterford Valley Drive;Durham;North Carolina;27713;USA
version:2.1
email;internet:mmercer@ipass.net
x-mozilla-cpt:;0
tel;work:(919) 991-4555
fn:Michael Mercer
end:vcard
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3660481C.19450731>
