944{
945 int rc;
947 char * str, * end;
949
951
952 rc = 0;
953 goto err_oor;
954 }
955
956 str = buf;
957 end = buf + size;
958
959
960 if (end < buf) {
961 end = ((void *)-1);
962 size = (
xwsz_t)(end - buf);
963 }
964
965 while (*fmt) {
966 const char * oldfmt = fmt;
968 fmt += read;
971 int copy = read;
972 if (str < end) {
973 if (copy > end - str) {
974 copy = end - str;
975 }
976 memcpy(str, oldfmt, (
xwsz_t)copy);
977 }
978 str += read;
979 break;
980 }
981
984 break;
985
988 break;
989
991 char c;
992
995 if (str < end) {
996 *str = ' ';
997 }
998 ++str;
999 }
1000 }
1001 c = (char)va_arg(args, int);
1002 if (str < end) {
1003 *str = c;
1004 }
1005 ++str;
1007 if (str < end) {
1008 *str = ' ';
1009 }
1010 ++str;
1011 }
1012 break;
1013 }
1014
1017 spec);
1018 break;
1019
1022 va_arg(args, void *), spec);
1023 while (isalnum((int)(*fmt))) {
1024 fmt++;
1025 }
1026 break;
1027
1029 if (str < end) {
1030 *str = '%';
1031 }
1032 ++str;
1033 break;
1034
1036 if (str < end) {
1037 *str = '%';
1038 }
1039 ++str;
1040 break;
1041
1045 break;
1046
1050 break;
1051
1052 default:
1053 switch (spec.
type) {
1055 num = (
xwu64_t)va_arg(args,
long long);
1056 break;
1058 num = (
xwu64_t)va_arg(args,
unsigned long);
1059 break;
1061 num = (
xwu64_t)va_arg(args,
long);
1062 break;
1066 } else {
1068 }
1069 break;
1071 num = (
xwu64_t)va_arg(args, ptrdiff_t);
1072 break;
1074 num = (
xwu64_t)va_arg(args,
int);
1075 break;
1077 num = (
xwu64_t)va_arg(args,
int);
1078 break;
1080 num = (
xwu64_t)va_arg(args,
int);
1081 break;
1083 num = (
xwu64_t)va_arg(args,
int);
1084 break;
1086 num = (
xwu64_t)va_arg(args,
int);
1087 break;
1088 default:
1089 num = (
xwu64_t)va_arg(args,
unsigned int);
1090 }
1092 }
1093 }
1094
1095 if (size > 0) {
1096 if (str < end) {
1097 *str = '\0';
1098 } else {
1099 end[-1] = '\0';
1100 }
1101 }
1102 rc = str - buf;
1103err_oor:
1104 return rc;
1105}
static int xwvsnpf_format_decode(const char *fmt, struct xwvsnpf_format_spec *spec)
static char * xwvsnpf_format_string(char *buf, char *end, const char *s, struct xwvsnpf_format_spec spec)
static char * xwvsnpf_format_pointer(const char *fmt, char *buf, char *end, void *ptr, struct xwvsnpf_format_spec spec)
@ XWVSNPF_FT_PERCENT_CHAR
@ XWVSNPF_FT_LONG_DOUBLE_SCI
static char * xwvsnpf_format_long_double(char *buf, char *end, long double num, struct xwvsnpf_format_spec spec)
static char * xwvsnpf_format_number(char *buf, char *end, xwu64_t num, struct xwvsnpf_format_spec spec)
static char * xwvsnpf_format_float(char *buf, char *end, double num, struct xwvsnpf_format_spec spec)