__asm__(".ident\t\"" "$FreeBSD: src/lib/libc/stdio/vfprintf.c,v 1.59 2003/04/19 23:53:19 das Exp $" "\""); typedef signed char __int8_t; typedef unsigned char __uint8_t; typedef short __int16_t; typedef unsigned short __uint16_t; typedef int __int32_t; typedef unsigned int __uint32_t; typedef long __int64_t; typedef unsigned long __uint64_t; typedef __int32_t __clock_t; typedef __int64_t __critical_t; typedef double __double_t; typedef double __float_t; typedef __int64_t __intfptr_t; typedef __int64_t __intmax_t; typedef __int64_t __intptr_t; typedef __int32_t __int_fast8_t; typedef __int32_t __int_fast16_t; typedef __int32_t __int_fast32_t; typedef __int64_t __int_fast64_t; typedef __int8_t __int_least8_t; typedef __int16_t __int_least16_t; typedef __int32_t __int_least32_t; typedef __int64_t __int_least64_t; typedef __int64_t __ptrdiff_t; typedef __int64_t __register_t; typedef __int64_t __segsz_t; typedef __uint64_t __size_t; typedef __int64_t __ssize_t; typedef __int64_t __time_t; typedef __uint64_t __uintfptr_t; typedef __uint64_t __uintmax_t; typedef __uint64_t __uintptr_t; typedef __uint32_t __uint_fast8_t; typedef __uint32_t __uint_fast16_t; typedef __uint32_t __uint_fast32_t; typedef __uint64_t __uint_fast64_t; typedef __uint8_t __uint_least8_t; typedef __uint16_t __uint_least16_t; typedef __uint32_t __uint_least32_t; typedef __uint64_t __uint_least64_t; typedef __uint64_t __u_register_t; typedef __uint64_t __vm_offset_t; typedef __int64_t __vm_ooffset_t; typedef __uint64_t __vm_paddr_t; typedef __uint64_t __vm_pindex_t; typedef __uint64_t __vm_size_t; typedef __builtin_va_list __va_list; typedef __va_list __gnuc_va_list; typedef __int32_t __clockid_t; typedef __uint32_t __fflags_t; typedef __uint64_t __fsblkcnt_t; typedef __uint64_t __fsfilcnt_t; typedef __uint32_t __gid_t; typedef __int64_t __id_t; typedef __uint32_t __ino_t; typedef long __key_t; typedef __uint16_t __mode_t; typedef int __nl_item; typedef __uint16_t __nlink_t; typedef __int64_t __off_t; typedef __int32_t __pid_t; typedef __int64_t __rlim_t; typedef __uint8_t __sa_family_t; typedef __uint32_t __socklen_t; typedef long __suseconds_t; typedef __int32_t __timer_t; typedef __uint32_t __udev_t; typedef __uint32_t __uid_t; typedef unsigned int __useconds_t; typedef int __ct_rune_t; typedef __ct_rune_t __rune_t; typedef __ct_rune_t __wchar_t; typedef __ct_rune_t __wint_t; typedef __udev_t __dev_t; typedef union { char __mbstate8[128]; __int64_t _mbstateL; } __mbstate_t; static __inline __uint64_t __bswap64(__uint64_t _x) { return (__extension__ ({ register __uint64_t __X = (_x); __asm ("bswap %0" : "+r" (__X)); __X; })); } static __inline __uint32_t __bswap32(__uint32_t _x) { return (__extension__ ({ register __uint32_t __X = (_x); __asm ("bswap %0" : "+r" (__X)); __X; })); } static __inline __uint16_t __bswap16(__uint16_t _x) { return (__extension__ ({ register __uint16_t __X = (_x); __asm ("xchgb %h0, %b0" : "+Q" (__X)); __X; })); } typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; typedef unsigned short ushort; typedef unsigned int uint; typedef __int8_t int8_t; typedef __int16_t int16_t; typedef __int32_t int32_t; typedef __int64_t int64_t; typedef __uint8_t uint8_t; typedef __uint16_t uint16_t; typedef __uint32_t uint32_t; typedef __uint64_t uint64_t; typedef __intptr_t intptr_t; typedef __uintptr_t uintptr_t; typedef __uint8_t u_int8_t; typedef __uint16_t u_int16_t; typedef __uint32_t u_int32_t; typedef __uint64_t u_int64_t; typedef __uint64_t u_quad_t; typedef __int64_t quad_t; typedef quad_t * qaddr_t; typedef char * caddr_t; typedef const char * c_caddr_t; typedef volatile char *v_caddr_t; typedef __clock_t clock_t; typedef __clockid_t clockid_t; typedef __critical_t critical_t; typedef __int64_t daddr_t; typedef __dev_t dev_t; typedef __fflags_t fflags_t; typedef __uint32_t fixpt_t; typedef __fsblkcnt_t fsblkcnt_t; typedef __fsfilcnt_t fsfilcnt_t; typedef __gid_t gid_t; typedef __uint32_t in_addr_t; typedef __uint16_t in_port_t; typedef __id_t id_t; typedef __ino_t ino_t; typedef __key_t key_t; typedef __mode_t mode_t; typedef __nlink_t nlink_t; typedef __off_t off_t; typedef __pid_t pid_t; typedef __register_t register_t; typedef __rlim_t rlim_t; typedef __segsz_t segsz_t; typedef __size_t size_t; typedef __ssize_t ssize_t; typedef __suseconds_t suseconds_t; typedef __time_t time_t; typedef __timer_t timer_t; typedef __u_register_t u_register_t; typedef __udev_t udev_t; typedef __uid_t uid_t; typedef __useconds_t useconds_t; typedef __vm_offset_t vm_offset_t; typedef __vm_ooffset_t vm_ooffset_t; typedef __vm_paddr_t vm_paddr_t; typedef __vm_pindex_t vm_pindex_t; typedef __vm_size_t vm_size_t; typedef struct __sigset { __uint32_t __bits[4]; } __sigset_t; struct timeval { long tv_sec; suseconds_t tv_usec; }; struct timespec { time_t tv_sec; long tv_nsec; }; typedef unsigned long __fd_mask; typedef __fd_mask fd_mask; typedef __sigset_t sigset_t; typedef struct fd_set { __fd_mask __fds_bits[(((1024U) + (((sizeof(__fd_mask) * 8)) - 1)) / ((sizeof(__fd_mask) * 8)))]; } fd_set; int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *); int _select(int, fd_set *, fd_set *, fd_set *, struct timeval *); int ftruncate(int, off_t); off_t lseek(int, off_t, int); void * mmap(void *, size_t, int, int, int, off_t); int truncate(const char *, off_t); int isalnum(int); int isalpha(int); int iscntrl(int); int isdigit(int); int isgraph(int); int islower(int); int isprint(int); int ispunct(int); int isspace(int); int isupper(int); int isxdigit(int); int tolower(int); int toupper(int); int _tolower(int); int _toupper(int); int isascii(int); int toascii(int); int digittoint(int); int isblank(int); int ishexnumber(int); int isideogram(int); int isnumber(int); int isphonogram(int); int isrune(int); int isspecial(int); unsigned long ___runetype(__ct_rune_t); __ct_rune_t ___tolower(__ct_rune_t); __ct_rune_t ___toupper(__ct_rune_t); typedef struct { __rune_t min; __rune_t max; __rune_t map; unsigned long *types; } _RuneEntry; typedef struct { int nranges; _RuneEntry *ranges; } _RuneRange; typedef struct { char magic[8]; char encoding[32]; __rune_t (*sgetrune)(const char *, __size_t, char const **); int (*sputrune)(__rune_t, char *, __size_t, char **); __rune_t invalid_rune; unsigned long runetype[(1 <<8 )]; __rune_t maplower[(1 <<8 )]; __rune_t mapupper[(1 <<8 )]; _RuneRange runetype_ext; _RuneRange maplower_ext; _RuneRange mapupper_ext; void *variable; int variable_len; } _RuneLocale; extern _RuneLocale _DefaultRuneLocale; extern _RuneLocale *_CurrentRuneLocale; static __inline int __maskrune(__ct_rune_t _c, unsigned long _f) { return ((_c < 0 || _c >= (1 <<8 )) ? ___runetype(_c) : _CurrentRuneLocale->runetype[_c]) & _f; } static __inline int __istype(__ct_rune_t _c, unsigned long _f) { return (!!__maskrune(_c, _f)); } static __inline int __isctype(__ct_rune_t _c, unsigned long _f) { return (_c < 0 || _c >= (1 <<8 )) ? 0 : !!(_DefaultRuneLocale.runetype[_c] & _f); } static __inline __ct_rune_t __toupper(__ct_rune_t _c) { return (_c < 0 || _c >= (1 <<8 )) ? ___toupper(_c) : _CurrentRuneLocale->mapupper[_c]; } static __inline __ct_rune_t __tolower(__ct_rune_t _c) { return (_c < 0 || _c >= (1 <<8 )) ? ___tolower(_c) : _CurrentRuneLocale->maplower[_c]; } struct lconv { char *decimal_point; char *thousands_sep; char *grouping; char *int_curr_symbol; char *currency_symbol; char *mon_decimal_point; char *mon_thousands_sep; char *mon_grouping; char *positive_sign; char *negative_sign; char int_frac_digits; char frac_digits; char p_cs_precedes; char p_sep_by_space; char n_cs_precedes; char n_sep_by_space; char p_sign_posn; char n_sign_posn; char int_p_cs_precedes; char int_n_cs_precedes; char int_p_sep_by_space; char int_n_sep_by_space; char int_p_sign_posn; char int_n_sign_posn; }; struct lconv *localeconv(void); char *setlocale(int, const char *); typedef __ptrdiff_t ptrdiff_t; typedef __rune_t rune_t; typedef __wchar_t wchar_t; typedef __int_least8_t int_least8_t; typedef __int_least16_t int_least16_t; typedef __int_least32_t int_least32_t; typedef __int_least64_t int_least64_t; typedef __uint_least8_t uint_least8_t; typedef __uint_least16_t uint_least16_t; typedef __uint_least32_t uint_least32_t; typedef __uint_least64_t uint_least64_t; typedef __int_fast8_t int_fast8_t; typedef __int_fast16_t int_fast16_t; typedef __int_fast32_t int_fast32_t; typedef __int_fast64_t int_fast64_t; typedef __uint_fast8_t uint_fast8_t; typedef __uint_fast16_t uint_fast16_t; typedef __uint_fast32_t uint_fast32_t; typedef __uint_fast64_t uint_fast64_t; typedef __intmax_t intmax_t; typedef __uintmax_t uintmax_t; typedef __off_t fpos_t; typedef __va_list va_list; struct __sbuf { unsigned char *_base; int _size; }; struct __sFILEX; typedef struct __sFILE { unsigned char *_p; int _r; int _w; short _flags; short _file; struct __sbuf _bf; int _lbfsize; void *_cookie; int (*_close)(void *); int (*_read)(void *, char *, int); fpos_t (*_seek)(void *, fpos_t, int); int (*_write)(void *, const char *, int); struct __sbuf _ub; struct __sFILEX *_extra; int _ur; unsigned char _ubuf[3]; unsigned char _nbuf[1]; struct __sbuf _lb; int _blksize; fpos_t _offset; } FILE; extern FILE *__stdinp; extern FILE *__stdoutp; extern FILE *__stderrp; void clearerr(FILE *); int fclose(FILE *); int feof(FILE *); int ferror(FILE *); int fflush(FILE *); int fgetc(FILE *); int fgetpos(FILE * , fpos_t * ); char *fgets(char * , int, FILE * ); FILE *fopen(const char * , const char * ); int fprintf(FILE * , const char * , ...); int fputc(int, FILE *); int fputs(const char * , FILE * ); size_t fread(void * , size_t, size_t, FILE * ); FILE *freopen(const char * , const char * , FILE * ); int fscanf(FILE * , const char * , ...); int fseek(FILE *, long, int); int fsetpos(FILE *, const fpos_t *); long ftell(FILE *); size_t fwrite(const void * , size_t, size_t, FILE * ); int getc(FILE *); int getchar(void); char *gets(char *); void perror(const char *); int printf(const char * , ...); int putc(int, FILE *); int putchar(int); int puts(const char *); int remove(const char *); int rename(const char *, const char *); void rewind(FILE *); int scanf(const char * , ...); void setbuf(FILE * , char * ); int setvbuf(FILE * , char * , int, size_t); int sprintf(char * , const char * , ...); int sscanf(const char * , const char * , ...); FILE *tmpfile(void); char *tmpnam(char *); int ungetc(int, FILE *); int vfprintf(FILE * , const char * , __va_list); int vprintf(const char * , __va_list); int vsprintf(char * , const char * , __va_list); int snprintf(char * , size_t, const char * , ...) __attribute__((__format__ (__printf__, 3, 4))); int vfscanf(FILE * , const char * , __va_list) __attribute__((__format__ (__scanf__, 2, 0))); int vscanf(const char * , __va_list) __attribute__((__format__ (__scanf__, 1, 0))); int vsnprintf(char * , size_t, const char * , __va_list) __attribute__((__format__ (__printf__, 3, 0))); int vsscanf(const char * , const char * , __va_list) __attribute__((__format__ (__scanf__, 2, 0))); char *ctermid(char *); FILE *fdopen(int, const char *); int fileno(FILE *); int pclose(FILE *); FILE *popen(const char *, const char *); int ftrylockfile(FILE *); void _flockfile(FILE *); void _funlockfile(FILE *); int getc_unlocked(FILE *); int getchar_unlocked(void); int putc_unlocked(int, FILE *); int putchar_unlocked(int); void clearerr_unlocked(FILE *); int feof_unlocked(FILE *); int ferror_unlocked(FILE *); int fileno_unlocked(FILE *); int fseeko(FILE *, __off_t, int); __off_t ftello(FILE *); int getw(FILE *); int putw(int, FILE *); char *tempnam(const char *, const char *); int asprintf(char **, const char *, ...) __attribute__((__format__ (__printf__, 2, 3))); char *ctermid_r(char *); char *fgetln(FILE *, size_t *); const char *fmtcheck(const char *, const char *) __attribute__((__format_arg__(2))); int fpurge(FILE *); void setbuffer(FILE *, char *, int); int setlinebuf(FILE *); int vasprintf(char **, const char *, __va_list) __attribute__((__format__ (__printf__, 2, 0))); extern const int sys_nerr; extern const char *const sys_errlist[]; FILE *funopen(const void *, int (*)(void *, char *, int), int (*)(void *, const char *, int), fpos_t (*)(void *, fpos_t, int), int (*)(void *)); int __srget(FILE *); int __swbuf(int, FILE *); static __inline int __sputc(int _c, FILE *_p) { if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) return (*_p->_p++ = _c); else return (__swbuf(_c, _p)); } typedef struct { int quot; int rem; } div_t; typedef struct { long quot; long rem; } ldiv_t; extern int __mb_cur_max; void abort(void) __attribute__((__noreturn__)); int abs(int) __attribute__((__const__)); int atexit(void (*)(void)); double atof(const char *); int atoi(const char *); long atol(const char *); void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void *, const void *)); void *calloc(size_t, size_t); div_t div(int, int) __attribute__((__const__)); void exit(int) __attribute__((__noreturn__)); void free(void *); char *getenv(const char *); long labs(long) __attribute__((__const__)); ldiv_t ldiv(long, long) __attribute__((__const__)); void *malloc(size_t); int mblen(const char *, size_t); size_t mbstowcs(wchar_t * , const char * , size_t); int mbtowc(wchar_t * , const char * , size_t); void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); int rand(void); void *realloc(void *, size_t); void srand(unsigned); double strtod(const char * , char ** ); float strtof(const char * , char ** ); long strtol(const char * , char ** , int); long double strtold(const char * , char ** ); unsigned long strtoul(const char * , char ** , int); int system(const char *); int wctomb(char *, wchar_t); size_t wcstombs(char * , const wchar_t * , size_t); typedef struct { long long quot; long long rem; } lldiv_t; long long atoll(const char *); long long llabs(long long) __attribute__((__const__)); lldiv_t lldiv(long long, long long) __attribute__((__const__)); long long strtoll(const char * , char ** , int); unsigned long long strtoull(const char * , char ** , int); void _Exit(int) __attribute__((__noreturn__)); int rand_r(unsigned *); int setenv(const char *, const char *, int); void unsetenv(const char *); double drand48(void); double erand48(unsigned short[3]); int getsubopt(char **, char *const *, char **); int grantpt(int); char *initstate(unsigned long , char *, long); long jrand48(unsigned short[3]); void lcong48(unsigned short[7]); long lrand48(void); int mkstemp(char *); char *mktemp(char *); long mrand48(void); long nrand48(unsigned short[3]); int posix_openpt(int); char *ptsname(int); int putenv(const char *); long random(void); char *realpath(const char *, char resolved_path[]); unsigned short *seed48(unsigned short[3]); int setkey(const char *); char *setstate( char *); void srand48(long); void srandom(unsigned long); int unlockpt(int); extern const char *_malloc_options; extern void (*_malloc_message)(const char *, const char *, const char *, const char *); void *alloca(size_t); __uint32_t arc4random(void); void arc4random_addrandom(unsigned char *dat, int datlen); void arc4random_stir(void); char *getbsize(int *, long *); char *cgetcap(char *, const char *, int); int cgetclose(void); int cgetent(char **, char **, const char *); int cgetfirst(char **, char **); int cgetmatch(const char *, const char *); int cgetnext(char **, char **); int cgetnum(char *, const char *, long *); int cgetset(const char *); int cgetstr(char *, const char *, char **); int cgetustr(char *, const char *, char **); int daemon(int, int); char *devname(int, int); int getloadavg(double [], int); const char * _getprogname(void); int heapsort(void *, size_t, size_t, int (*)(const void *, const void *)); int mergesort(void *, size_t, size_t, int (*)(const void *, const void *)); void qsort_r(void *, size_t, size_t, void *, int (*)(void *, const void *, const void *)); int radixsort(const unsigned char **, int, const unsigned char *, unsigned); void *reallocf(void *, size_t); void setprogname(const char *); int sradixsort(const unsigned char **, int, const unsigned char *, unsigned); void sranddev(void); void srandomdev(void); __int64_t strtoq(const char *, char **, int); __uint64_t strtouq(const char *, char **, int); int bcmp(const void *, const void *, size_t); void bcopy(const void *, void *, size_t); void bzero(void *, size_t); int ffs(int); char *index(const char *, int); char *rindex(const char *, int); int strcasecmp(const char *, const char *); int strncasecmp(const char *, const char *, size_t); void *memccpy(void * , const void * , int, size_t); void *memchr(const void *, int, size_t); int memcmp(const void *, const void *, size_t); void *memcpy(void * , const void * , size_t); void *memmove(void *, const void *, size_t); void *memset(void *, int, size_t); char *stpcpy(char *, const char *); char *strcasestr(const char *, const char *); char *strcat(char * , const char * ); char *strchr(const char *, int); int strcmp(const char *, const char *); int strcoll(const char *, const char *); char *strcpy(char * , const char * ); size_t strcspn(const char *, const char *); char *strdup(const char *); char *strerror(int); int strerror_r(int, char *, size_t); size_t strlcat(char *, const char *, size_t); size_t strlcpy(char *, const char *, size_t); size_t strlen(const char *); void strmode(int, char *); char *strncat(char * , const char * , size_t); int strncmp(const char *, const char *, size_t); char *strncpy(char * , const char * , size_t); char *strnstr(const char *, const char *, size_t); char *strpbrk(const char *, const char *); char *strrchr(const char *, int); char *strsep(char **, const char *); char *strsignal(int); size_t strspn(const char *, const char *); char *strstr(const char *, const char *); char *strtok(char * , const char * ); char *strtok_r(char *, const char *, char **); size_t strxfrm(char * , const char * , size_t); void swab(const void *, void *, size_t); typedef __mbstate_t mbstate_t; typedef __wint_t wint_t; struct __sFILE; struct tm; wint_t btowc(int); wint_t fgetwc(struct __sFILE *); wchar_t * fgetws(wchar_t * , int, struct __sFILE * ); wint_t fputwc(wchar_t, struct __sFILE *); int fputws(const wchar_t * , struct __sFILE * ); int fwide(struct __sFILE *, int); int fwprintf(struct __sFILE * , const wchar_t * , ...); int fwscanf(struct __sFILE * , const wchar_t * , ...); wint_t getwc(struct __sFILE *); wint_t getwchar(void); size_t mbrlen(const char * , size_t, mbstate_t * ); size_t mbrtowc(wchar_t * , const char * , size_t, mbstate_t * ); int mbsinit(const mbstate_t *); size_t mbsrtowcs(wchar_t * , const char ** , size_t, mbstate_t * ); wint_t putwc(wchar_t, struct __sFILE *); wint_t putwchar(wchar_t); int swprintf(wchar_t * , size_t n, const wchar_t * , ...); int swscanf(const wchar_t * , const wchar_t * , ...); wint_t ungetwc(wint_t, struct __sFILE *); int vfwprintf(struct __sFILE * , const wchar_t * , __va_list); int vswprintf(wchar_t * , size_t n, const wchar_t * , __va_list); int vwprintf(const wchar_t * , __va_list); size_t wcrtomb(char * , wchar_t, mbstate_t * ); wchar_t *wcscat(wchar_t * , const wchar_t * ); wchar_t *wcschr(const wchar_t *, wchar_t); int wcscmp(const wchar_t *, const wchar_t *); int wcscoll(const wchar_t *, const wchar_t *); wchar_t *wcscpy(wchar_t * , const wchar_t * ); size_t wcscspn(const wchar_t *, const wchar_t *); size_t wcsftime(wchar_t * , size_t, const wchar_t * , const struct tm * ); size_t wcslen(const wchar_t *); wchar_t *wcsncat(wchar_t * , const wchar_t * , size_t); int wcsncmp(const wchar_t *, const wchar_t *, size_t); wchar_t *wcsncpy(wchar_t * , const wchar_t * , size_t); wchar_t *wcspbrk(const wchar_t *, const wchar_t *); wchar_t *wcsrchr(const wchar_t *, wchar_t); size_t wcsrtombs(char * , const wchar_t ** , size_t, mbstate_t * ); size_t wcsspn(const wchar_t *, const wchar_t *); wchar_t *wcsstr(const wchar_t * , const wchar_t * ); size_t wcsxfrm(wchar_t * , const wchar_t * , size_t); int wctob(wint_t); double wcstod(const wchar_t * , wchar_t ** ); wchar_t *wcstok(wchar_t * , const wchar_t * , wchar_t ** ); long wcstol(const wchar_t * , wchar_t ** , int); unsigned long wcstoul(const wchar_t * , wchar_t ** , int); wchar_t *wmemchr(const wchar_t *, wchar_t, size_t); int wmemcmp(const wchar_t *, const wchar_t *, size_t); wchar_t *wmemcpy(wchar_t * , const wchar_t * , size_t); wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t); wchar_t *wmemset(wchar_t *, wchar_t, size_t); int wprintf(const wchar_t * , ...); int wscanf(const wchar_t * , ...); int vfwscanf(struct __sFILE * , const wchar_t * , __va_list); int vswscanf(const wchar_t * , const wchar_t * , __va_list); int vwscanf(const wchar_t * , __va_list); float wcstof(const wchar_t * , wchar_t ** ); long double wcstold(const wchar_t * , wchar_t ** ); long long wcstoll(const wchar_t * , wchar_t ** , int); unsigned long long wcstoull(const wchar_t * , wchar_t ** , int); int wcswidth(const wchar_t *, size_t); int wcwidth(wchar_t); size_t wcslcat(wchar_t *, const wchar_t *, size_t); size_t wcslcpy(wchar_t *, const wchar_t *, size_t); extern int __isthreaded; typedef enum { PJT_COND_BROADCAST, PJT_COND_DESTROY, PJT_COND_INIT, PJT_COND_SIGNAL, PJT_COND_WAIT, PJT_GETSPECIFIC, PJT_KEY_CREATE, PJT_KEY_DELETE, PJT_MAIN_NP, PJT_MUTEX_DESTROY, PJT_MUTEX_INIT, PJT_MUTEX_LOCK, PJT_MUTEX_TRYLOCK, PJT_MUTEX_UNLOCK, PJT_MUTEXATTR_DESTROY, PJT_MUTEXATTR_INIT, PJT_MUTEXATTR_SETTYPE, PJT_ONCE, PJT_RWLOCK_DESTROY, PJT_RWLOCK_INIT, PJT_RWLOCK_RDLOCK, PJT_RWLOCK_TRYRDLOCK, PJT_RWLOCK_TRYWRLOCK, PJT_RWLOCK_UNLOCK, PJT_RWLOCK_WRLOCK, PJT_SELF, PJT_SETSPECIFIC, PJT_SIGMASK, PJT_MAX } pjt_index_t; typedef int (*pthread_func_t)(void); typedef pthread_func_t pthread_func_entry_t[2]; extern pthread_func_entry_t __thr_jtable[]; int _yp_check(char **); extern const char *__progname; struct timezone { int tz_minuteswest; int tz_dsttime; }; struct bintime { time_t sec; uint64_t frac; }; static __inline void bintime_addx(struct bintime *bt, uint64_t x) { uint64_t u; u = bt->frac; bt->frac += x; if (u > bt->frac) bt->sec++; } static __inline void bintime_add(struct bintime *bt, struct bintime *bt2) { uint64_t u; u = bt->frac; bt->frac += bt2->frac; if (u > bt->frac) bt->sec++; bt->sec += bt2->sec; } static __inline void bintime_sub(struct bintime *bt, struct bintime *bt2) { uint64_t u; u = bt->frac; bt->frac -= bt2->frac; if (u < bt->frac) bt->sec--; bt->sec -= bt2->sec; } static __inline void bintime2timespec(struct bintime *bt, struct timespec *ts) { ts->tv_sec = bt->sec; ts->tv_nsec = ((uint64_t)1000000000 * (uint32_t)(bt->frac >> 32)) >> 32; } static __inline void timespec2bintime(struct timespec *ts, struct bintime *bt) { bt->sec = ts->tv_sec; bt->frac = ts->tv_nsec * (uint64_t)18446744073LL; } static __inline void bintime2timeval(struct bintime *bt, struct timeval *tv) { tv->tv_sec = bt->sec; tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(bt->frac >> 32)) >> 32; } static __inline void timeval2bintime(struct timeval *tv, struct bintime *bt) { bt->sec = tv->tv_sec; bt->frac = tv->tv_usec * (uint64_t)18446744073709LL; } struct itimerval { struct timeval it_interval; struct timeval it_value; }; struct clockinfo { int hz; int tick; int spare; int stathz; int profhz; }; struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }; extern char *tzname[]; char *asctime(const struct tm *); clock_t clock(void); char *ctime(const time_t *); double difftime(time_t, time_t); struct tm *gmtime(const time_t *); struct tm *localtime(const time_t *); time_t mktime(struct tm *); size_t strftime(char * , size_t, const char * , const struct tm * ); time_t time(time_t *); void tzset(void); int clock_getres(clockid_t, struct timespec *); int clock_gettime(clockid_t, struct timespec *); int clock_settime(clockid_t, const struct timespec *); int nanosleep(const struct timespec *, struct timespec *); char *asctime_r(const struct tm *, char *); char *ctime_r(const time_t *, char *); struct tm *gmtime_r(const time_t *, struct tm *); struct tm *localtime_r(const time_t *, struct tm *); char *strptime(const char * , const char * , struct tm * ); char *timezone(int, int); void tzsetwall(void); time_t timelocal(struct tm * const); time_t timegm(struct tm * const); int adjtime(const struct timeval *, struct timeval *); int futimes(int, const struct timeval *); int getitimer(int, struct itimerval *); int gettimeofday(struct timeval *, struct timezone *); int lutimes(const char *, const struct timeval *); int setitimer(int, const struct itimerval *, struct itimerval *); int settimeofday(const struct timeval *, const struct timezone *); int utimes(const char *, const struct timeval *); typedef long sig_atomic_t; struct sigcontext { struct __sigset sc_mask; long sc_onstack; long sc_r15; long sc_r14; long sc_r13; long sc_r12; long sc_r11; long sc_r10; long sc_r9; long sc_r8; long sc_rdi; long sc_rsi; long sc_rbp; long sc_rbx; long sc_rdx; long sc_rcx; long sc_rax; long sc_trapno; long sc_err; long sc_rip; long sc_cs; long sc_rflags; long sc_rsp; long sc_ss; long sc_len; long sc_fpformat; long sc_ownedfp; long sc_spare1[1]; long sc_fpstate[128] __attribute__((__aligned__(16))); long sc_spare2[8]; }; typedef void __sighandler_t(int); union sigval { int sigval_int; void *sigval_ptr; }; struct sigevent { int sigev_notify; union { int __sigev_signo; int __sigev_notify_kqueue; } __sigev_u; union sigval sigev_value; }; typedef struct __siginfo { int si_signo; int si_errno; int si_code; __pid_t si_pid; __uid_t si_uid; int si_status; void *si_addr; union sigval si_value; long si_band; int __spare__[7]; } siginfo_t; struct __siginfo; struct sigaction { union { void (*__sa_handler)(int); void (*__sa_sigaction)(int, struct __siginfo *, void *); } __sigaction_u; int sa_flags; sigset_t sa_mask; }; typedef __sighandler_t *sig_t; typedef void __siginfohandler_t(int, struct __siginfo *, void *); typedef struct sigaltstack { char *ss_sp; __size_t ss_size; int ss_flags; } stack_t; struct sigvec { __sighandler_t *sv_handler; int sv_mask; int sv_flags; }; struct sigstack { char *ss_sp; int ss_onstack; }; __sighandler_t *signal(int, __sighandler_t *); struct sched_param { int sched_priority; }; struct timespec; int sched_get_priority_max(int); int sched_get_priority_min(int); int sched_getparam(pid_t, struct sched_param *); int sched_getscheduler(pid_t); int sched_rr_get_interval(pid_t, struct timespec *); int sched_setparam(pid_t, const struct sched_param *); int sched_setscheduler(pid_t, int, const struct sched_param *); int sched_yield(void); struct pthread; struct pthread_attr; struct pthread_cond; struct pthread_cond_attr; struct pthread_mutex; struct pthread_mutex_attr; struct pthread_once; struct pthread_rwlock; struct pthread_rwlockattr; typedef struct pthread *pthread_t; typedef struct pthread_attr *pthread_attr_t; typedef struct pthread_mutex *pthread_mutex_t; typedef struct pthread_mutex_attr *pthread_mutexattr_t; typedef struct pthread_cond *pthread_cond_t; typedef struct pthread_cond_attr *pthread_condattr_t; typedef int pthread_key_t; typedef struct pthread_once pthread_once_t; typedef struct pthread_rwlock *pthread_rwlock_t; typedef struct pthread_rwlockattr *pthread_rwlockattr_t; typedef void *pthread_addr_t; typedef void *(*pthread_startroutine_t)(void *); struct pthread_once { int state; pthread_mutex_t mutex; }; enum pthread_mutextype { PTHREAD_MUTEX_ERRORCHECK = 1, PTHREAD_MUTEX_RECURSIVE = 2, PTHREAD_MUTEX_NORMAL = 3, MUTEX_TYPE_MAX }; int pthread_attr_destroy(pthread_attr_t *); int pthread_attr_getstack(const pthread_attr_t * , void ** stackaddr, size_t * stacksize); int pthread_attr_getstacksize(const pthread_attr_t *, size_t *); int pthread_attr_getguardsize(const pthread_attr_t *, size_t *); int pthread_attr_getstackaddr(const pthread_attr_t *, void **); int pthread_attr_getdetachstate(const pthread_attr_t *, int *); int pthread_attr_init(pthread_attr_t *); int pthread_attr_setstacksize(pthread_attr_t *, size_t); int pthread_attr_setguardsize(pthread_attr_t *, size_t); int pthread_attr_setstack(pthread_attr_t *, void *, size_t); int pthread_attr_setstackaddr(pthread_attr_t *, void *); int pthread_attr_setdetachstate(pthread_attr_t *, int); void pthread_cleanup_pop(int); void pthread_cleanup_push(void (*) (void *), void *routine_arg); int pthread_condattr_destroy(pthread_condattr_t *); int pthread_condattr_init(pthread_condattr_t *); int pthread_cond_broadcast(pthread_cond_t *); int pthread_cond_destroy(pthread_cond_t *); int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *); int pthread_cond_signal(pthread_cond_t *); int pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *, const struct timespec *); int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *); int pthread_create(pthread_t *, const pthread_attr_t *, void *(*) (void *), void *); int pthread_detach(pthread_t); int pthread_equal(pthread_t, pthread_t); void pthread_exit(void *) __attribute__((__noreturn__)); void *pthread_getspecific(pthread_key_t); int pthread_join(pthread_t, void **); int pthread_key_create(pthread_key_t *, void (*) (void *)); int pthread_key_delete(pthread_key_t); int pthread_kill(pthread_t, int); int pthread_mutexattr_init(pthread_mutexattr_t *); int pthread_mutexattr_destroy(pthread_mutexattr_t *); int pthread_mutexattr_gettype(pthread_mutexattr_t *, int *); int pthread_mutexattr_settype(pthread_mutexattr_t *, int); int pthread_mutex_destroy(pthread_mutex_t *); int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *); int pthread_mutex_lock(pthread_mutex_t *); int pthread_mutex_trylock(pthread_mutex_t *); int pthread_mutex_unlock(pthread_mutex_t *); int pthread_once(pthread_once_t *, void (*) (void)); int pthread_rwlock_destroy(pthread_rwlock_t *); int pthread_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *); int pthread_rwlock_rdlock(pthread_rwlock_t *); int pthread_rwlock_tryrdlock(pthread_rwlock_t *); int pthread_rwlock_trywrlock(pthread_rwlock_t *); int pthread_rwlock_unlock(pthread_rwlock_t *); int pthread_rwlock_wrlock(pthread_rwlock_t *); int pthread_rwlockattr_init(pthread_rwlockattr_t *); int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *, int *); int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int); int pthread_rwlockattr_destroy(pthread_rwlockattr_t *); pthread_t pthread_self(void); int pthread_setspecific(pthread_key_t, const void *); int pthread_sigmask(int, const sigset_t *, sigset_t *); int pthread_cancel(pthread_t); int pthread_setcancelstate(int, int *); int pthread_setcanceltype(int, int *); void pthread_testcancel(void); int pthread_getprio(pthread_t); int pthread_setprio(pthread_t, int); void pthread_yield(void); int pthread_mutexattr_getprioceiling(pthread_mutexattr_t *, int *); int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int); int pthread_mutex_getprioceiling(pthread_mutex_t *, int *); int pthread_mutex_setprioceiling(pthread_mutex_t *, int, int *); int pthread_mutexattr_getprotocol(pthread_mutexattr_t *, int *); int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int); int pthread_attr_getinheritsched(const pthread_attr_t *, int *); int pthread_attr_getschedparam(const pthread_attr_t *, struct sched_param *); int pthread_attr_getschedpolicy(const pthread_attr_t *, int *); int pthread_attr_getscope(const pthread_attr_t *, int *); int pthread_attr_setinheritsched(pthread_attr_t *, int); int pthread_attr_setschedparam(pthread_attr_t *, const struct sched_param *); int pthread_attr_setschedpolicy(pthread_attr_t *, int); int pthread_attr_setscope(pthread_attr_t *, int); int pthread_getschedparam(pthread_t pthread, int *, struct sched_param *); int pthread_setschedparam(pthread_t, int, const struct sched_param *); int pthread_getconcurrency(void); int pthread_setconcurrency(int); extern int _sread(FILE *, char *, int); extern int _swrite(FILE *, char const *, int); extern fpos_t _sseek(FILE *, fpos_t, int); extern int _ftello(FILE *, fpos_t *); extern int _fseeko(FILE *, off_t, int, int); extern int __fflush(FILE *fp); extern wint_t __fgetwc(FILE *); extern wint_t __fputwc(wchar_t, FILE *); extern int __sflush(FILE *); extern FILE *__sfp(void); extern int __srefill(FILE *); extern int __sread(void *, char *, int); extern int __swrite(void *, char const *, int); extern fpos_t __sseek(void *, fpos_t, int); extern int __sclose(void *); extern void __sinit(void); extern void _cleanup(void); extern void (*__cleanup)(void); extern void __smakebuf(FILE *); extern int __swhatbuf(FILE *, size_t *, int *); extern int _fwalk(int (*)(FILE *)); extern int __svfscanf(FILE *, const char *, __va_list); extern int __swsetup(FILE *); extern int __sflags(const char *, int *); extern int __ungetc(int, FILE *); extern wint_t __ungetwc(wint_t, FILE *); extern int __vfprintf(FILE *, const char *, __va_list); extern int __vfscanf(FILE *, const char *, __va_list); extern int __vfwprintf(FILE *, const wchar_t *, __va_list); extern int __vfwscanf(FILE * , const wchar_t * , __va_list); extern int __sdidinit; struct __sFILEX { unsigned char *_up; pthread_mutex_t fl_mutex; pthread_t fl_owner; int fl_count; int orientation; }; struct __siov { void *iov_base; size_t iov_len; }; struct __suio { struct __siov *uio_iov; int uio_iovcnt; int uio_resid; }; extern int __sfvwrite(FILE *, struct __suio *); union arg { int intarg; u_int uintarg; long longarg; u_long ulongarg; long long longlongarg; unsigned long long ulonglongarg; ptrdiff_t ptrdiffarg; size_t sizearg; intmax_t intmaxarg; uintmax_t uintmaxarg; void *pvoidarg; char *pchararg; signed char *pschararg; short *pshortarg; int *pintarg; long *plongarg; long long *plonglongarg; ptrdiff_t *pptrdiffarg; size_t *psizearg; intmax_t *pintmaxarg; double doublearg; long double longdoublearg; wint_t wintarg; wchar_t *pwchararg; }; enum typeid { T_UNUSED, TP_SHORT, T_INT, T_U_INT, TP_INT, T_LONG, T_U_LONG, TP_LONG, T_LLONG, T_U_LLONG, TP_LLONG, T_PTRDIFFT, TP_PTRDIFFT, T_SIZET, TP_SIZET, T_INTMAXT, T_UINTMAXT, TP_INTMAXT, TP_VOID, TP_CHAR, TP_SCHAR, T_DOUBLE, T_LONG_DOUBLE, T_WINT, TP_WCHAR }; static int __sprint(FILE *, struct __suio *); static int __sbprintf(FILE *, const char *, va_list) __attribute__((__format__ (__printf__, 2, 0))); static char *__ujtoa(uintmax_t, char *, int, int, const char *, int, char, const char *); static char *__ultoa(u_long, char *, int, int, const char *, int, char, const char *); static char *__wcsconv(wchar_t *, int); static void __find_arguments(const char *, va_list, union arg **); static void __grow_type_table(int, enum typeid **, int *); static int __sprint(FILE *fp, struct __suio *uio) { int err; if (uio->uio_resid == 0) { uio->uio_iovcnt = 0; return (0); } err = __sfvwrite(fp, uio); uio->uio_resid = 0; uio->uio_iovcnt = 0; return (err); } static int __sbprintf(FILE *fp, const char *fmt, va_list ap) { int ret; FILE fake; unsigned char buf[1024]; fake._flags = fp->_flags & ~0x0002; fake._file = fp->_file; fake._cookie = fp->_cookie; fake._write = fp->_write; fake._extra = fp->_extra; fake._bf._base = fake._p = buf; fake._bf._size = fake._w = sizeof(buf); fake._lbfsize = 0; ret = __vfprintf(&fake, fmt, ap); if (ret >= 0 && __fflush(&fake)) ret = (-1); if (fake._flags & 0x0040) fp->_flags |= 0x0040; return (ret); } static char * __ultoa(u_long val, char *endp, int base, int octzero, const char *xdigs, int needgrp, char thousep, const char *grp) { char *cp = endp; long sval; int ndig; switch (base) { case 10: if (val < 10) { *--cp = ((val) + '0'); return (cp); } ndig = 0; if (val > 0x7fffffffffffffffL) { *--cp = ((val % 10) + '0'); ndig++; sval = val / 10; } else sval = val; do { *--cp = ((sval % 10) + '0'); ndig++; if (needgrp && ndig == *grp && *grp != 0x7f && sval > 9) { *--cp = thousep; ndig = 0; if (*(grp+1) != '\0') grp++; } sval /= 10; } while (sval != 0); break; case 8: do { *--cp = ((val & 7) + '0'); val >>= 3; } while (val); if (octzero && *cp != '0') *--cp = '0'; break; case 16: do { *--cp = xdigs[val & 15]; val >>= 4; } while (val); break; default: abort(); } return (cp); } static char * __ujtoa(uintmax_t val, char *endp, int base, int octzero, const char *xdigs, int needgrp, char thousep, const char *grp) { char *cp = endp; intmax_t sval; int ndig; if (val <= 0xffffffffffffffffUL) return (__ultoa((u_long)val, endp, base, octzero, xdigs, needgrp, thousep, grp)); switch (base) { case 10: if (val < 10) { *--cp = ((val % 10) + '0'); return (cp); } ndig = 0; if (val > 0x7fffffffffffffffL) { *--cp = ((val % 10) + '0'); ndig++; sval = val / 10; } else sval = val; do { *--cp = ((sval % 10) + '0'); ndig++; if (needgrp && *grp != 0x7f && ndig == *grp && sval > 9) { *--cp = thousep; ndig = 0; if (*(grp+1) != '\0') grp++; } sval /= 10; } while (sval != 0); break; case 8: do { *--cp = ((val & 7) + '0'); val >>= 3; } while (val); if (octzero && *cp != '0') *--cp = '0'; break; case 16: do { *--cp = xdigs[val & 15]; val >>= 4; } while (val); break; default: abort(); } return (cp); } static char * __wcsconv(wchar_t *wcsarg, int prec) { char buf[6]; wchar_t *p; char *convbuf, *mbp; size_t clen, nbytes; mbstate_t mbs; memset(&mbs, 0, sizeof(mbs)); if (prec >= 0) { nbytes = 0; p = wcsarg; for (;;) { clen = wcrtomb(buf, *p++, &mbs); if (clen == 0 || clen == (size_t)-1 || nbytes + clen > prec) break; nbytes += clen; } } else { p = wcsarg; nbytes = wcsrtombs(0, (const wchar_t **)&p, 0, &mbs); if (nbytes == (size_t)-1) return (0); } if ((convbuf = malloc(nbytes + 1)) == 0) return (0); mbp = convbuf; p = wcsarg; memset(&mbs, 0, sizeof(mbs)); while (mbp - convbuf < nbytes) { clen = wcrtomb(mbp, *p++, &mbs); if (clen == 0 || clen == (size_t)-1) break; mbp += clen; } if (clen == (size_t)-1) { free(convbuf); return (0); } *mbp = '\0'; return (convbuf); } int vfprintf(FILE * fp, const char * fmt0, va_list ap) { int ret; if (__isthreaded) _flockfile(fp); ret = __vfprintf(fp, fmt0, ap); if (__isthreaded) _funlockfile(fp); return (ret); } extern const union __infinity_un { unsigned char __uc[8]; double __ud; } __infinity; extern const union __nan_un { unsigned char __uc[sizeof(float)]; float __uf; } __nan; typedef __double_t double_t; typedef __float_t float_t; extern int signgam; enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix}; extern enum fdversion _fdlib_version; struct exception { int type; char *name; double arg1; double arg2; double retval; }; int __fpclassifyd(double) __attribute__((__const__)); int __fpclassifyf(float) __attribute__((__const__)); int __fpclassifyl(long double) __attribute__((__const__)); int __signbit(double) __attribute__((__const__)); double acos(double); double asin(double); double atan(double); double atan2(double, double); double cos(double); double sin(double); double tan(double); double cosh(double); double sinh(double); double tanh(double); double exp(double); double frexp(double, int *); double ldexp(double, int); double log(double); double log10(double); double modf(double, double *); double pow(double, double); double sqrt(double); double ceil(double); double fabs(double); double floor(double); double fmod(double, double); double erf(double); double erfc(double) __attribute__((__const__)); int finite(double) __attribute__((__const__)); double gamma(double); double hypot(double, double); double j0(double); double j1(double); double jn(int, double); double lgamma(double); double y0(double); double y1(double); double yn(int, double); double acosh(double); double asinh(double); double atanh(double); double cbrt(double) __attribute__((__const__)); double logb(double) __attribute__((__const__)); double nextafter(double, double); double remainder(double, double); double scalb(double, double); double tgamma(double); int matherr(struct exception *); double significand(double); double copysign(double, double) __attribute__((__const__)); int ilogb(double); double rint(double) __attribute__((__const__)); double scalbn(double, int); double drem(double, double); double expm1(double) __attribute__((__const__)); double log1p(double) __attribute__((__const__)); double gamma_r(double, int *); double lgamma_r(double, int *); float acosf(float); float asinf(float); float atanf(float); float atan2f(float, float); float cosf(float); float sinf(float); float tanf(float); float coshf(float); float sinhf(float); float tanhf(float); float expf(float); float frexpf(float, int *); float ldexpf(float, int); float logf(float); float log10f(float); float modff(float, float *); float powf(float, float); float sqrtf(float); float ceilf(float); float fabsf(float); float floorf(float); float fmodf(float, float); float erff(float); float erfcf(float) __attribute__((__const__)); int finitef(float) __attribute__((__const__)); float gammaf(float); float hypotf(float, float) __attribute__((__const__)); float j0f(float); float j1f(float); float jnf(int, float); float lgammaf(float); float y0f(float); float y1f(float); float ynf(int, float); float acoshf(float); float asinhf(float); float atanhf(float); float cbrtf(float) __attribute__((__const__)); float logbf(float) __attribute__((__const__)); float nextafterf(float, float); float remainderf(float, float); float scalbf(float, float); float significandf(float); float copysignf(float, float) __attribute__((__const__)); int ilogbf(float); float rintf(float); float scalbnf(float, int); float dremf(float, float); float expm1f(float) __attribute__((__const__)); float log1pf(float) __attribute__((__const__)); float gammaf_r(float, int *); float lgammaf_r(float, int *); char *__ldtoa(long double *, int, int, int *, int *, char **); typedef unsigned long ULong; typedef unsigned short UShort; enum { STRTOG_Zero = 0, STRTOG_Normal = 1, STRTOG_Denormal = 2, STRTOG_Infinite = 3, STRTOG_NaN = 4, STRTOG_NaNbits = 5, STRTOG_NoNumber = 6, STRTOG_Retmask = 7, STRTOG_Neg = 0x08, STRTOG_Inexlo = 0x10, STRTOG_Inexhi = 0x20, STRTOG_Inexact = 0x30, STRTOG_Underflow= 0x40, STRTOG_Overflow = 0x80 }; typedef struct FPI { int nbits; int emin; int emax; int rounding; int sudden_underflow; } FPI; enum { FPI_Round_zero = 0, FPI_Round_near = 1, FPI_Round_up = 2, FPI_Round_down = 3 }; extern char* __dtoa (double d, int mode, int ndigits, int *decpt, int *sign, char **rve); extern char* gdtoa (FPI *fpi, int be, ULong *bits, int *kindp, int mode, int ndigits, int *decpt, char **rve); extern void __freedtoa (char*); extern float strtof (const char *, char **); extern double strtod (const char *, char **); extern int strtodg (const char*, char**, FPI*, long*, ULong*); extern char* g_ddfmt (char*, double*, int, unsigned); extern char* g_dfmt (char*, double*, int, unsigned); extern char* g_ffmt (char*, float*, int, unsigned); extern char* g_Qfmt (char*, void*, int, unsigned); extern char* g_xfmt (char*, void*, int, unsigned); extern char* g_xLfmt (char*, void*, int, unsigned); extern int strtoId (const char*, char**, double*, double*); extern int strtoIdd (const char*, char**, double*, double*); extern int strtoIf (const char*, char**, float*, float*); extern int strtoIQ (const char*, char**, void*, void*); extern int strtoIx (const char*, char**, void*, void*); extern int strtoIxL (const char*, char**, void*, void*); extern int strtord (const char*, char**, int, double*); extern int strtordd (const char*, char**, int, double*); extern int strtorf (const char*, char**, int, float*); extern int strtorQ (const char*, char**, int, void*); extern int strtorx (const char*, char**, int, void*); extern int strtorxL (const char*, char**, int, void*); extern int strtodI (const char*, char**, double*); extern int strtopd (const char*, char**, double*); extern int strtopdd (const char*, char**, double*); extern int strtopf (const char*, char**, float*); extern int strtopQ (const char*, char**, void*); extern int strtopx (const char*, char**, void*); extern int strtopxL (const char*, char**, void*); static int exponent(char *, int, int); int __vfprintf(FILE *fp, const char *fmt0, va_list ap) { char *fmt; int ch; int n, n2; char *cp; struct __siov *iovp; int flags; int ret; int width; int prec; char sign; char thousands_sep; const char *grouping; char *decimal_point; int signflag; double dbl; long double ldbl; int expt; char expchar; char *dtoaend; int expsize; int lead; int ndig; char expstr[6 +2]; char *dtoaresult; int nseps; int nrepeats; u_long ulval; uintmax_t ujval; int base; int dprec; int realsz; int size; int prsize; const char *xdigs; struct __suio uio; struct __siov iov[8]; char buf[100]; char ox[2]; union arg *argtable; union arg statargtable [8]; int nextarg; va_list orgap; char *convbuf; static char blanks[16] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}; static char zeroes[16] = {'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; static const char xdigs_lower[16] = "0123456789abcdef"; static const char xdigs_upper[16] = "0123456789ABCDEF"; thousands_sep = '\0'; grouping = 0; convbuf = 0; dtoaresult = 0; decimal_point = localeconv()->decimal_point; if (((((fp)->_flags & 0x0008) == 0 || ((fp)->_bf._base == 0 && ((fp)->_flags & 0x0200) == 0)) && __swsetup(fp))) return ((-1)); if ((fp->_flags & (0x0002|0x0008|0x0010)) == (0x0002|0x0008) && fp->_file >= 0) return (__sbprintf(fp, fmt0, ap)); fmt = (char *)fmt0; argtable = 0; nextarg = 1; __builtin_va_copy((orgap), (ap)); uio.uio_iov = iovp = iov; uio.uio_resid = 0; uio.uio_iovcnt = 0; ret = 0; for (;;) { for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++) ; if ((n = fmt - cp) != 0) { if ((unsigned)ret + n > 0x7fffffff) { ret = (-1); goto error; } { iovp->iov_base = (cp); iovp->iov_len = (n); uio.uio_resid += (n); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; ret += n; } if (ch == '\0') goto done; fmt++; flags = 0; dprec = 0; width = 0; prec = -1; sign = '\0'; ox[1] = '\0'; rflag: ch = *fmt++; reswitch: switch (ch) { case ' ': if (!sign) sign = ' '; goto rflag; case '#': flags |= 0x001; goto rflag; case '*': n2 = 0; cp = fmt; while (((unsigned)((*cp) - '0') <= 9)) { n2 = 10 * n2 + ((*cp) - '0'); cp++; } if (*cp == '$') { int hold = nextarg; if (argtable == 0) { argtable = statargtable; __find_arguments (fmt0, orgap, &argtable); } nextarg = n2; width = ((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))); nextarg = hold; fmt = ++cp; } else { width = ((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))); }; if (width >= 0) goto rflag; width = -width; case '-': flags |= 0x004; goto rflag; case '+': sign = '+'; goto rflag; case '\'': flags |= 0x200; thousands_sep = *(localeconv()->thousands_sep); grouping = localeconv()->grouping; goto rflag; case '.': if ((ch = *fmt++) == '*') { n2 = 0; cp = fmt; while (((unsigned)((*cp) - '0') <= 9)) { n2 = 10 * n2 + ((*cp) - '0'); cp++; } if (*cp == '$') { int hold = nextarg; if (argtable == 0) { argtable = statargtable; __find_arguments (fmt0, orgap, &argtable); } nextarg = n2; prec = ((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))); nextarg = hold; fmt = ++cp; } else { prec = ((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))); }; goto rflag; } prec = 0; while (((unsigned)((ch) - '0') <= 9)) { prec = 10 * prec + ((ch) - '0'); ch = *fmt++; } goto reswitch; case '0': flags |= 0x080; goto rflag; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': n = 0; do { n = 10 * n + ((ch) - '0'); ch = *fmt++; } while (((unsigned)((ch) - '0') <= 9)); if (ch == '$') { nextarg = n; if (argtable == 0) { argtable = statargtable; __find_arguments (fmt0, orgap, &argtable); } goto rflag; } width = n; goto reswitch; case 'L': flags |= 0x008; goto rflag; case 'h': if (flags & 0x040) { flags &= ~0x040; flags |= 0x2000; } else flags |= 0x040; goto rflag; case 'j': flags |= 0x1000; goto rflag; case 'l': if (flags & 0x010) { flags &= ~0x010; flags |= 0x020; } else flags |= 0x010; goto rflag; case 'q': flags |= 0x020; goto rflag; case 't': flags |= 0x800; goto rflag; case 'z': flags |= 0x400; goto rflag; case 'C': flags |= 0x010; case 'c': if (flags & 0x010) { mbstate_t mbs; size_t mbseqlen; memset(&mbs, 0, sizeof(mbs)); mbseqlen = wcrtomb(cp = buf, (wchar_t)((argtable != 0) ? *((wint_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), wint_t))), &mbs); if (mbseqlen == (size_t)-1) { fp->_flags |= 0x0040; goto error; } size = (int)mbseqlen; } else { *(cp = buf) = ((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))); size = 1; } sign = '\0'; break; case 'D': flags |= 0x010; case 'd': case 'i': if (flags & (0x1000|0x400|0x800|0x020)) { ujval = (flags&0x1000 ? ((argtable != 0) ? *((intmax_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), intmax_t))) : flags&0x400 ? (intmax_t)((argtable != 0) ? *((size_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), size_t))) : flags&0x800 ? (intmax_t)((argtable != 0) ? *((ptrdiff_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), ptrdiff_t))) : (intmax_t)((argtable != 0) ? *((long long*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), long long)))); if ((intmax_t)ujval < 0) { ujval = -ujval; sign = '-'; } } else { ulval = (flags&0x010 ? ((argtable != 0) ? *((long*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), long))) : flags&0x040 ? (long)(short)((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))) : flags&0x2000 ? (long)(signed char)((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))) : (long)((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int)))); if ((long)ulval < 0) { ulval = -ulval; sign = '-'; } } base = 10; goto number; case 'e': case 'E': expchar = ch; if (prec < 0) prec = 6 + 1; else prec++; goto fp_begin; case 'f': case 'F': expchar = '\0'; goto fp_begin; case 'g': case 'G': expchar = ch - ('g' - 'e'); if (prec == 0) prec = 1; fp_begin: if (prec < 0) prec = 6; if (dtoaresult != 0) __freedtoa(dtoaresult); if (flags & 0x008) { ldbl = ((argtable != 0) ? *((long double*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), long double))); dtoaresult = cp = __ldtoa(&ldbl, expchar ? 2 : 3, prec, &expt, &signflag, &dtoaend); } else { dbl = ((argtable != 0) ? *((double*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), double))); dtoaresult = cp = __dtoa(dbl, expchar ? 2 : 3, prec, &expt, &signflag, &dtoaend); if (expt == 9999) expt = 0x7fffffff; { int Q; char Qbuf[80]; for (Q = 0; Q < 8; Q++) { sprintf(Qbuf + Q * 2, "%02x\n", ((unsigned char *)&dbl)[Q]); } write(2, Qbuf, 17); } } if (signflag) sign = '-'; if (expt == 0x7fffffff) { if (*cp == 'N') { cp = (ch >= 'a') ? "nan" : "NAN"; sign = '\0'; } else cp = (ch >= 'a') ? "inf" : "INF"; size = 3; break; } flags |= 0x100; ndig = dtoaend - cp; if (ch == 'g' || ch == 'G') { if (expt > -4 && expt <= prec) { expchar = '\0'; if (flags & 0x001) prec -= expt; else prec = ndig - expt; if (prec < 0) prec = 0; } else { if (!(flags & 0x001)) prec = ndig; } } if (expchar) { expsize = exponent(expstr, expt - 1, expchar); size = expsize + prec; if (prec > 1 || flags & 0x001) ++size; } else { if (expt > 0) size = expt; else size = 1; if (prec || flags & 0x001) size += prec + 1; if (grouping && expt > 0) { nseps = nrepeats = 0; lead = expt; while (*grouping != 0x7f) { if (lead <= *grouping) break; lead -= *grouping; if (*(grouping+1)) { nseps++; grouping++; } else nrepeats++; } size += nseps + nrepeats; } else lead = expt; } break; case 'n': if (flags & 0x020) *((argtable != 0) ? *((long long **)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), long long *))) = ret; else if (flags & 0x400) *((argtable != 0) ? *((ssize_t **)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), ssize_t *))) = (ssize_t)ret; else if (flags & 0x800) *((argtable != 0) ? *((ptrdiff_t **)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), ptrdiff_t *))) = ret; else if (flags & 0x1000) *((argtable != 0) ? *((intmax_t **)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), intmax_t *))) = ret; else if (flags & 0x010) *((argtable != 0) ? *((long **)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), long *))) = ret; else if (flags & 0x040) *((argtable != 0) ? *((short **)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), short *))) = ret; else if (flags & 0x2000) *((argtable != 0) ? *((signed char **)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), signed char *))) = ret; else *((argtable != 0) ? *((int **)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int *))) = ret; continue; case 'O': flags |= 0x010; case 'o': if (flags & (0x1000|0x400|0x800|0x020)) ujval = (flags&0x1000 ? ((argtable != 0) ? *((uintmax_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), uintmax_t))) : flags&0x400 ? (uintmax_t)((argtable != 0) ? *((size_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), size_t))) : flags&0x800 ? (uintmax_t)((argtable != 0) ? *((ptrdiff_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), ptrdiff_t))) : (uintmax_t)((argtable != 0) ? *((unsigned long long*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), unsigned long long)))); else ulval = (flags&0x010 ? ((argtable != 0) ? *((u_long*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), u_long))) : flags&0x040 ? (u_long)(u_short)((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))) : flags&0x2000 ? (u_long)(u_char)((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))) : (u_long)((argtable != 0) ? *((u_int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), u_int)))); base = 8; goto nosign; case 'p': ujval = (uintmax_t)(uintptr_t)((argtable != 0) ? *((void **)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), void *))); base = 16; xdigs = xdigs_lower; flags = flags | 0x1000; ox[1] = 'x'; goto nosign; case 'S': flags |= 0x010; case 's': if (flags & 0x010) { wchar_t *wcp; if (convbuf != 0) free(convbuf); if ((wcp = ((argtable != 0) ? *((wchar_t **)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), wchar_t *)))) == 0) cp = "(null)"; else { convbuf = __wcsconv(wcp, prec); if (convbuf == 0) { fp->_flags |= 0x0040; goto error; } cp = convbuf; } } else if ((cp = ((argtable != 0) ? *((char **)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), char *)))) == 0) cp = "(null)"; if (prec >= 0) { char *p = memchr(cp, 0, (size_t)prec); if (p != 0) { size = p - cp; if (size > prec) size = prec; } else size = prec; } else size = strlen(cp); sign = '\0'; break; case 'U': flags |= 0x010; case 'u': if (flags & (0x1000|0x400|0x800|0x020)) ujval = (flags&0x1000 ? ((argtable != 0) ? *((uintmax_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), uintmax_t))) : flags&0x400 ? (uintmax_t)((argtable != 0) ? *((size_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), size_t))) : flags&0x800 ? (uintmax_t)((argtable != 0) ? *((ptrdiff_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), ptrdiff_t))) : (uintmax_t)((argtable != 0) ? *((unsigned long long*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), unsigned long long)))); else ulval = (flags&0x010 ? ((argtable != 0) ? *((u_long*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), u_long))) : flags&0x040 ? (u_long)(u_short)((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))) : flags&0x2000 ? (u_long)(u_char)((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))) : (u_long)((argtable != 0) ? *((u_int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), u_int)))); base = 10; goto nosign; case 'X': xdigs = xdigs_upper; goto hex; case 'x': xdigs = xdigs_lower; hex: if (flags & (0x1000|0x400|0x800|0x020)) ujval = (flags&0x1000 ? ((argtable != 0) ? *((uintmax_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), uintmax_t))) : flags&0x400 ? (uintmax_t)((argtable != 0) ? *((size_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), size_t))) : flags&0x800 ? (uintmax_t)((argtable != 0) ? *((ptrdiff_t*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), ptrdiff_t))) : (uintmax_t)((argtable != 0) ? *((unsigned long long*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), unsigned long long)))); else ulval = (flags&0x010 ? ((argtable != 0) ? *((u_long*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), u_long))) : flags&0x040 ? (u_long)(u_short)((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))) : flags&0x2000 ? (u_long)(u_char)((argtable != 0) ? *((int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), int))) : (u_long)((argtable != 0) ? *((u_int*)(&argtable[nextarg++])) : (nextarg++, __builtin_va_arg((ap), u_int)))); base = 16; if (flags & 0x001 && (flags & (0x1000|0x400|0x800|0x020) ? ujval != 0 : ulval != 0)) ox[1] = ch; flags &= ~0x200; nosign: sign = '\0'; number: if ((dprec = prec) >= 0) flags &= ~0x080; cp = buf + 100; if (flags & (0x1000|0x400|0x800|0x020)) { if (ujval != 0 || prec != 0) cp = __ujtoa(ujval, cp, base, flags & 0x001, xdigs, flags & 0x200, thousands_sep, grouping); } else { if (ulval != 0 || prec != 0) cp = __ultoa(ulval, cp, base, flags & 0x001, xdigs, flags & 0x200, thousands_sep, grouping); } size = buf + 100 - cp; if (size > 100) abort(); break; default: if (ch == '\0') goto done; cp = buf; *cp = ch; size = 1; sign = '\0'; break; } realsz = dprec > size ? dprec : size; if (sign) realsz++; else if (ox[1]) realsz += 2; prsize = width > realsz ? width : realsz; if ((unsigned)ret + prsize > 0x7fffffff) { ret = (-1); goto error; } if ((flags & (0x004|0x080)) == 0) { if ((n = (width - realsz)) > 0) { while (n > 16) { { iovp->iov_base = (blanks); iovp->iov_len = (16); uio.uio_resid += (16); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; n -= 16; } { iovp->iov_base = (blanks); iovp->iov_len = (n); uio.uio_resid += (n); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } }; if (sign) { { iovp->iov_base = (&sign); iovp->iov_len = (1); uio.uio_resid += (1); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } else if (ox[1]) { ox[0] = '0'; { iovp->iov_base = (ox); iovp->iov_len = (2); uio.uio_resid += (2); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } if ((flags & (0x004|0x080)) == 0x080) { if ((n = (width - realsz)) > 0) { while (n > 16) { { iovp->iov_base = (zeroes); iovp->iov_len = (16); uio.uio_resid += (16); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; n -= 16; } { iovp->iov_base = (zeroes); iovp->iov_len = (n); uio.uio_resid += (n); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } }; { if ((n = (dprec - size)) > 0) { while (n > 16) { { iovp->iov_base = (zeroes); iovp->iov_len = (16); uio.uio_resid += (16); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; n -= 16; } { iovp->iov_base = (zeroes); iovp->iov_len = (n); uio.uio_resid += (n); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } }; if ((flags & 0x100) == 0) { { iovp->iov_base = (cp); iovp->iov_len = (size); uio.uio_resid += (size); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } else { if (!expchar) { if (expt <= 0) { { iovp->iov_base = (zeroes); iovp->iov_len = (1); uio.uio_resid += (1); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; if (prec || flags & 0x001) { iovp->iov_base = (decimal_point); iovp->iov_len = (1); uio.uio_resid += (1); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; { if ((n = (-expt)) > 0) { while (n > 16) { { iovp->iov_base = (zeroes); iovp->iov_len = (16); uio.uio_resid += (16); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; n -= 16; } { iovp->iov_base = (zeroes); iovp->iov_len = (n); uio.uio_resid += (n); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } }; prec += expt; } else { do { n2 = (dtoaend) - (cp); if (n2 > (lead)) n2 = (lead); if (n2 > 0) { iovp->iov_base = ((cp)); iovp->iov_len = (n2); uio.uio_resid += (n2); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; { if ((n = ((lead) - (n2 > 0 ? n2 : 0))) > 0) { while (n > 16) { { iovp->iov_base = ((zeroes)); iovp->iov_len = (16); uio.uio_resid += (16); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; n -= 16; } { iovp->iov_base = ((zeroes)); iovp->iov_len = (n); uio.uio_resid += (n); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } }; } while(0); cp += lead; if (grouping) { while (nseps>0 || nrepeats>0) { if (nrepeats > 0) nrepeats--; else { grouping--; nseps--; } { iovp->iov_base = (&thousands_sep); iovp->iov_len = (1); uio.uio_resid += (1); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; do { n2 = (dtoaend) - (cp); if (n2 > (*grouping)) n2 = (*grouping); if (n2 > 0) { iovp->iov_base = ((cp)); iovp->iov_len = (n2); uio.uio_resid += (n2); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; { if ((n = ((*grouping) - (n2 > 0 ? n2 : 0))) > 0) { while (n > 16) { { iovp->iov_base = ((zeroes)); iovp->iov_len = (16); uio.uio_resid += (16); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; n -= 16; } { iovp->iov_base = ((zeroes)); iovp->iov_len = (n); uio.uio_resid += (n); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } }; } while(0); cp += *grouping; } if (cp > dtoaend) cp = dtoaend; } if (prec || flags & 0x001) { iovp->iov_base = (decimal_point); iovp->iov_len = (1); uio.uio_resid += (1); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } do { n2 = (dtoaend) - (cp); if (n2 > (prec)) n2 = (prec); if (n2 > 0) { iovp->iov_base = ((cp)); iovp->iov_len = (n2); uio.uio_resid += (n2); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; { if ((n = ((prec) - (n2 > 0 ? n2 : 0))) > 0) { while (n > 16) { { iovp->iov_base = ((zeroes)); iovp->iov_len = (16); uio.uio_resid += (16); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; n -= 16; } { iovp->iov_base = ((zeroes)); iovp->iov_len = (n); uio.uio_resid += (n); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } }; } while(0); } else { if (prec > 1 || flags & 0x001) { buf[0] = *cp++; buf[1] = *decimal_point; { iovp->iov_base = (buf); iovp->iov_len = (2); uio.uio_resid += (2); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; { iovp->iov_base = (cp); iovp->iov_len = (ndig-1); uio.uio_resid += (ndig-1); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; { if ((n = (prec - ndig)) > 0) { while (n > 16) { { iovp->iov_base = (zeroes); iovp->iov_len = (16); uio.uio_resid += (16); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; n -= 16; } { iovp->iov_base = (zeroes); iovp->iov_len = (n); uio.uio_resid += (n); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } }; } else { iovp->iov_base = (cp); iovp->iov_len = (1); uio.uio_resid += (1); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; { iovp->iov_base = (expstr); iovp->iov_len = (expsize); uio.uio_resid += (expsize); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } } if (flags & 0x004) { if ((n = (width - realsz)) > 0) { while (n > 16) { { iovp->iov_base = (blanks); iovp->iov_len = (16); uio.uio_resid += (16); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; n -= 16; } { iovp->iov_base = (blanks); iovp->iov_len = (n); uio.uio_resid += (n); iovp++; if (++uio.uio_iovcnt >= 8) { if (__sprint(fp, &uio)) goto error; iovp = iov; } }; } }; ret += prsize; { if (uio.uio_resid && __sprint(fp, &uio)) goto error; uio.uio_iovcnt = 0; iovp = iov; }; } done: { if (uio.uio_resid && __sprint(fp, &uio)) goto error; uio.uio_iovcnt = 0; iovp = iov; }; error: if (dtoaresult != 0) __freedtoa(dtoaresult); if (convbuf != 0) free(convbuf); if ((((fp)->_flags & 0x0040) != 0)) ret = (-1); if ((argtable != 0) && (argtable != statargtable)) free (argtable); return (ret); } static void __find_arguments (const char *fmt0, va_list ap, union arg **argtable) { char *fmt; int ch; int n, n2; char *cp; int flags; int width; enum typeid *typetable; enum typeid stattypetable [8]; int tablesize; int tablemax; int nextarg; fmt = (char *)fmt0; typetable = stattypetable; tablesize = 8; tablemax = 0; nextarg = 1; memset (typetable, T_UNUSED, 8); for (;;) { for (cp = fmt; (ch = *fmt) != '\0' && ch != '%'; fmt++) ; if (ch == '\0') goto done; fmt++; flags = 0; width = 0; rflag: ch = *fmt++; reswitch: switch (ch) { case ' ': case '#': goto rflag; case '*': n2 = 0; cp = fmt; while (((unsigned)((*cp) - '0') <= 9)) { n2 = 10 * n2 + ((*cp) - '0'); cp++; } if (*cp == '$') { int hold = nextarg; nextarg = n2; ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_INT); nextarg = hold; fmt = ++cp; } else { ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_INT); }; goto rflag; case '-': case '+': case '\'': goto rflag; case '.': if ((ch = *fmt++) == '*') { n2 = 0; cp = fmt; while (((unsigned)((*cp) - '0') <= 9)) { n2 = 10 * n2 + ((*cp) - '0'); cp++; } if (*cp == '$') { int hold = nextarg; nextarg = n2; ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_INT); nextarg = hold; fmt = ++cp; } else { ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_INT); }; goto rflag; } while (((unsigned)((ch) - '0') <= 9)) { ch = *fmt++; } goto reswitch; case '0': goto rflag; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': n = 0; do { n = 10 * n + ((ch) - '0'); ch = *fmt++; } while (((unsigned)((ch) - '0') <= 9)); if (ch == '$') { nextarg = n; goto rflag; } width = n; goto reswitch; case 'L': flags |= 0x008; goto rflag; case 'h': if (flags & 0x040) { flags &= ~0x040; flags |= 0x2000; } else flags |= 0x040; goto rflag; case 'j': flags |= 0x1000; goto rflag; case 'l': if (flags & 0x010) { flags &= ~0x010; flags |= 0x020; } else flags |= 0x010; goto rflag; case 'q': flags |= 0x020; goto rflag; case 't': flags |= 0x800; goto rflag; case 'z': flags |= 0x400; goto rflag; case 'C': flags |= 0x010; case 'c': if (flags & 0x010) ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_WINT); else ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_INT); break; case 'D': flags |= 0x010; case 'd': case 'i': ((flags&0x1000) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_INTMAXT) : ((flags&0x400) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_SIZET) : ((flags&0x800) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_PTRDIFFT) : ((flags&0x020) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_LLONG) : ((flags&0x010) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_LONG) : ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_INT)))))); break; case 'e': case 'E': case 'f': case 'g': case 'G': if (flags & 0x008) ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_LONG_DOUBLE); else ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_DOUBLE); break; case 'n': if (flags & 0x1000) ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = TP_INTMAXT); else if (flags & 0x800) ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = TP_PTRDIFFT); else if (flags & 0x400) ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = TP_SIZET); else if (flags & 0x020) ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = TP_LLONG); else if (flags & 0x010) ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = TP_LONG); else if (flags & 0x040) ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = TP_SHORT); else if (flags & 0x2000) ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = TP_SCHAR); else ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = TP_INT); continue; case 'O': flags |= 0x010; case 'o': ((flags&0x1000) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_UINTMAXT) : ((flags&0x400) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_SIZET) : ((flags&0x800) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_PTRDIFFT) : ((flags&0x020) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_U_LLONG) : ((flags&0x010) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_U_LONG) : ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_U_INT)))))); break; case 'p': ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = TP_VOID); break; case 'S': flags |= 0x010; case 's': if (flags & 0x010) ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = TP_WCHAR); else ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = TP_CHAR); break; case 'U': flags |= 0x010; case 'u': case 'X': case 'x': ((flags&0x1000) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_UINTMAXT) : ((flags&0x400) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_SIZET) : ((flags&0x800) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_PTRDIFFT) : ((flags&0x020) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_U_LLONG) : ((flags&0x010) ? ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_U_LONG) : ((nextarg >= tablesize) ? __grow_type_table(nextarg, &typetable, &tablesize) : 0, (nextarg > tablemax) ? tablemax = nextarg : 0, typetable[nextarg++] = T_U_INT)))))); break; default: if (ch == '\0') goto done; break; } } done: if (tablemax >= 8) { *argtable = (union arg *) malloc (sizeof (union arg) * (tablemax + 1)); } (*argtable) [0].intarg = 0; for (n = 1; n <= tablemax; n++) { switch (typetable [n]) { case T_UNUSED: (*argtable) [n].intarg = __builtin_va_arg((ap), int); break; case TP_SCHAR: (*argtable) [n].pschararg = __builtin_va_arg((ap), signed char *); break; case TP_SHORT: (*argtable) [n].pshortarg = __builtin_va_arg((ap), short *); break; case T_INT: (*argtable) [n].intarg = __builtin_va_arg((ap), int); break; case T_U_INT: (*argtable) [n].uintarg = __builtin_va_arg((ap), unsigned int); break; case TP_INT: (*argtable) [n].pintarg = __builtin_va_arg((ap), int *); break; case T_LONG: (*argtable) [n].longarg = __builtin_va_arg((ap), long); break; case T_U_LONG: (*argtable) [n].ulongarg = __builtin_va_arg((ap), unsigned long); break; case TP_LONG: (*argtable) [n].plongarg = __builtin_va_arg((ap), long *); break; case T_LLONG: (*argtable) [n].longlongarg = __builtin_va_arg((ap), long long); break; case T_U_LLONG: (*argtable) [n].ulonglongarg = __builtin_va_arg((ap), unsigned long long); break; case TP_LLONG: (*argtable) [n].plonglongarg = __builtin_va_arg((ap), long long *); break; case T_PTRDIFFT: (*argtable) [n].ptrdiffarg = __builtin_va_arg((ap), ptrdiff_t); break; case TP_PTRDIFFT: (*argtable) [n].pptrdiffarg = __builtin_va_arg((ap), ptrdiff_t *); break; case T_SIZET: (*argtable) [n].sizearg = __builtin_va_arg((ap), size_t); break; case TP_SIZET: (*argtable) [n].psizearg = __builtin_va_arg((ap), ssize_t *); break; case T_INTMAXT: (*argtable) [n].intmaxarg = __builtin_va_arg((ap), intmax_t); break; case T_UINTMAXT: (*argtable) [n].uintmaxarg = __builtin_va_arg((ap), uintmax_t); break; case TP_INTMAXT: (*argtable) [n].pintmaxarg = __builtin_va_arg((ap), intmax_t *); break; case T_DOUBLE: (*argtable) [n].doublearg = __builtin_va_arg((ap), double); break; case T_LONG_DOUBLE: (*argtable) [n].longdoublearg = __builtin_va_arg((ap), long double); break; case TP_CHAR: (*argtable) [n].pchararg = __builtin_va_arg((ap), char *); break; case TP_VOID: (*argtable) [n].pvoidarg = __builtin_va_arg((ap), void *); break; case T_WINT: (*argtable) [n].wintarg = __builtin_va_arg((ap), wint_t); break; case TP_WCHAR: (*argtable) [n].pwchararg = __builtin_va_arg((ap), wchar_t *); break; } } if ((typetable != 0) && (typetable != stattypetable)) free (typetable); } static void __grow_type_table (int nextarg, enum typeid **typetable, int *tablesize) { enum typeid *const oldtable = *typetable; const int oldsize = *tablesize; enum typeid *newtable; int newsize = oldsize * 2; if (newsize < nextarg + 1) newsize = nextarg + 1; if (oldsize == 8) { if ((newtable = malloc(newsize)) == 0) abort(); bcopy(oldtable, newtable, oldsize); } else { if ((newtable = reallocf(oldtable, newsize)) == 0) abort(); } memset(&newtable[oldsize], T_UNUSED, newsize - oldsize); *typetable = newtable; *tablesize = newsize; } static int exponent(char *p0, int exp, int fmtch) { char *p, *t; char expbuf[6]; p = p0; *p++ = fmtch; if (exp < 0) { exp = -exp; *p++ = '-'; } else *p++ = '+'; t = expbuf + 6; if (exp > 9) { do { *--t = ((exp % 10) + '0'); } while ((exp /= 10) > 9); *--t = ((exp) + '0'); for (; t < expbuf + 6; *p++ = *t++); } else { if (fmtch == 'e' || fmtch == 'E') *p++ = '0'; *p++ = ((exp) + '0'); } return (p - p0); }