Skip site navigation (1)Skip section navigation (2)
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
This is a multi-part message in MIME format.
--------------7DCAC7D3BEC3426529FB44A0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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 );
> }
--------------7DCAC7D3BEC3426529FB44A0
Content-Type: text/x-vcard; charset=iso-8859-1;
 name="mmercer.vcf"
Content-Transfer-Encoding: base64
Content-Description: Card for Michael E. Mercer
Content-Disposition: attachment;
 filename="mmercer.vcf"

YmVnaW46dmNhcmQgCm46TWVyY2VyO01pY2hhZWwKeC1tb3ppbGxhLWh0bWw6RkFMU0UKYWRy
Ojs7NDMwOS8xNTE4IFdhdGVyZm9yZCBWYWxsZXkgRHJpdmU7RHVyaGFtO05vcnRoIENhcm9s
aW5hOzI3NzEzO1VTQQp2ZXJzaW9uOjIuMQplbWFpbDtpbnRlcm5ldDptbWVyY2VyQGlwYXNz
Lm5ldAp4LW1vemlsbGEtY3B0OjswCnRlbDt3b3JrOig5MTkpIDk5MS00NTU1CmZuOk1pY2hh
ZWwgTWVyY2VyCmVuZDp2Y2FyZAo=
--------------7DCAC7D3BEC3426529FB44A0--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3660481C.19450731>