Lines Matching +full:x +full:- +full:max

1 /* snprintf - compatibility implementation of snprintf, vsnprintf
59 * mostly in formatting and range (e+-16), for %f and %g.
61 * %s, %d, %u, %i, %x, %c, %n and %% are fully supported.
62 * This includes width, precision, flags 0- +, and *(arg for wid,prec).
80 while(num--) { in print_pad()
83 (*left)--; in print_pad()
94 return '-'; in get_negsign()
105 print_dec(char* buf, int max, unsigned int value) in print_dec() argument
109 if(max > 0) { in print_dec()
113 } else while(value && i < max) { in print_dec()
122 print_dec_l(char* buf, int max, unsigned long value) in print_dec_l() argument
126 if(max > 0) { in print_dec_l()
130 } else while(value && i < max) { in print_dec_l()
139 print_dec_ll(char* buf, int max, unsigned long long value) in print_dec_ll() argument
143 if(max > 0) { in print_dec_ll()
147 } else while(value && i < max) { in print_dec_ll()
156 print_hex(char* buf, int max, unsigned int value) in print_hex() argument
161 if(max > 0) { in print_hex()
165 } else while(value && i < max) { in print_hex()
174 print_hex_l(char* buf, int max, unsigned long value) in print_hex_l() argument
179 if(max > 0) { in print_hex_l()
183 } else while(value && i < max) { in print_hex_l()
192 print_hex_ll(char* buf, int max, unsigned long long value) in print_hex_ll() argument
197 if(max > 0) { in print_hex_ll()
201 } else while(value && i < max) { in print_hex_ll()
215 *(*at)++ = buf[--i]; in spool_str_rev()
216 (*left)--; in spool_str_rev()
217 } else --i; in spool_str_rev()
230 (*left)--; in spool_str()
260 print_pad(at, left, ret, '0', precision - w); in print_num()
265 print_pad(at, left, ret, ' ', minw - numw); in print_num()
277 print_pad(at, left, ret, ' ', minw - numw); in print_num()
281 numw--; in print_num()
285 print_pad(at, left, ret, '0', numw - w); in print_num()
303 (unsigned int)(negative?-value:value)); in print_num_d()
318 (unsigned long)(negative?-value:value)); in print_num_ld()
333 (unsigned long long)(negative?-value:value)); in print_num_lld()
380 /** print %x */
446 /* put '0x' in front of the (reversed) buffer result */ in print_num_llp()
448 buf[len++] = 'x'; in print_num_llp()
456 #define PRINT_FLOAT_BUFSZ 64 /* xx.yy with 20.20 about the max */
459 print_remainder(char* buf, int max, double r, int prec) in print_remainder() argument
464 if(prec > 19) prec = 19; /* max we can do */ in print_remainder()
465 if(max < prec) return 0; in print_remainder()
472 if(((unsigned long long)((r - (double)value)*10.0)) >= 5) { in print_remainder()
477 value = cap-1; in print_remainder()
479 len = print_dec_ll(buf, max, value); in print_remainder()
483 if(len < max) in print_remainder()
490 print_float(char* buf, int max, double value, int prec) in print_float() argument
494 linking with -lm. */ in print_float()
496 * which makes 19 digits before and after the decimal point the max */ in print_float()
498 double remain = value - (double)whole; in print_float()
501 len = print_remainder(buf, max, remain, prec); in print_float()
502 len += print_dec_ll(buf+len, max-len, whole); in print_float()
517 len = print_float(buf, (int)sizeof(buf), negative?-value:value, in print_num_f()
525 print_float_g(char* buf, int max, double value, int prec) in print_float_g() argument
528 double remain = value - (double)whole; in print_float_g()
541 len = print_remainder(buf, max, remain, prec-before); in print_float_g()
543 memmove(buf, buf+1, --len); in print_float_g()
546 len += print_dec_ll(buf+len, max-len, whole); in print_float_g()
563 len = print_float_g(buf, (int)sizeof(buf), negative?-value:value, in print_num_g()
572 my_strnlen(const char* s, int max) in my_strnlen() argument
575 for(i=0; i<max; i++) in my_strnlen()
578 return max; in my_strnlen()
587 /* with prec: no more than x characters from this string, stop at 0 */ in print_str()
592 print_pad(at, left, ret, ' ', minw - w); in print_str()
595 print_pad(at, left, ret, ' ', minw - w); in print_str()
604 print_pad(at, left, ret, ' ', minw - 1); in print_char()
607 print_pad(at, left, ret, ' ', minw - 1); in print_char()
622 * %s, %u, %d, %x, %i, %f, %g, %c, %p, %n.
623 * length: l, ll (for d, u, x).
624 * precision: 6.6d (for d, u, x)
641 left--; in vsnprintf()
660 * conversion specifier: x, d, u, s, c, n, m, p in vsnprintf()
663 * - left adjust (right by default) in vsnprintf()
664 * ' ' printspace for positive number (in - position). in vsnprintf()
666 * fieldwidth: [1-9][0-9]* minimum field width. in vsnprintf()
668 * if this is negative, the - flag is set (with positive width). in vsnprintf()
669 * precision: period[digits]*, %.2x. in vsnprintf()
672 * this is mindigits to print for d, i, u, x in vsnprintf()
674 * this is max number significant digits for g in vsnprintf()
676 * length: 0-none (int), 1-l (long), 2-ll (long long) in vsnprintf()
679 * Does not support %#x in vsnprintf()
695 else if(*fmt == '-') in vsnprintf()
711 minw = -minw; in vsnprintf()
714 minw = minw*10 + (*fmt++)-'0'; in vsnprintf()
728 precision = precision*10 + (*fmt++)-'0'; in vsnprintf()
777 case 'x': in vsnprintf()
860 int x = 0; in main() local
887 DOTEST(1024, "-1", 2, "%d", -1); in main()
888 DOTEST(1024, "-12", 3, "%3d", -12); in main()
889 DOTEST(1024, " -2", 3, "%3d", -2); in main()
890 DOTEST(1024, "-012", 4, "%.3d", -12); in main()
891 DOTEST(1024, "-012", 4, "%3.3d", -12); in main()
892 DOTEST(1024, "-012", 4, "%4.3d", -12); in main()
893 DOTEST(1024, " -012", 5, "%5.3d", -12); in main()
894 DOTEST(1024, "-12", 3, "%03d", -12); in main()
895 DOTEST(1024, "-02", 3, "%03d", -2); in main()
896 DOTEST(1024, "-15", 3, "%d", -15); in main()
897 DOTEST(1024, "-7307", 5, "%d", -7307); in main()
898 DOTEST(1024, "-12 ", 5, "%-5d", -12); in main()
899 DOTEST(1024, "-00012", 6, "%-.5d", -12); in main()
910 /* test %x */ in main()
911 DOTEST(1024, "0", 1, "%x", 0); in main()
912 DOTEST(1024, "c", 1, "%x", 12); in main()
913 DOTEST(1024, "12ab34cd", 8, "%x", 0x12ab34cd); in main()
918 DOTEST(1024, "-9223372036854775808", 20, "%lld", in main()
926 DOTEST(1024, "hello ", 10, "%-10s", "hello"); in main()
938 DOTEST(1024, "hello", 5, "hello%n", &x); in main()
939 if(x != 5) { printf("the %%n failed\n"); exit(1); } in main()
955 /* differs, "-0.00" DOTEST(1024, "0.00", 4, "%.2f", -0.0); */ in main()
958 DOTEST(1024, "-12.000000", 10, "%f", -12.0); in main()
977 DOTEST(1024, "12345", 5, "%x", 0x12345); in main()
990 DOTEST(1024, "-012", 4, "%3.3d", -12); in main()
995 DOTEST(1024, "hello ", 7, "%*s", -7, "hello"); in main()
1001 DOTEST(1024, "0a", 2, "%02x", 0x0a); in main()
1002 DOTEST(1024, "bd", 2, "%02x", 0xbd); in main()
1012 DOTEST(1024, "0123", 4, "%.4x", 0x0123); in main()
1013 DOTEST(1024, "00000123", 8, "%.8x", 0x0123); in main()
1014 DOTEST(1024, "ffeb0cde", 8, "%.8x", 0xffeb0cde); in main()
1018 DOTEST(1024, "-87654321", 9, "%i", -87654321); in main()
1019 DOTEST(1024, "hello ", 16, "%-16s", "hello"); in main()
1020 DOTEST(1024, " ", 16, "%-16s", ""); in main()
1021 DOTEST(1024, "a ", 16, "%-16s", "a"); in main()
1022 DOTEST(1024, "foobarfoobar ", 16, "%-16s", "foobarfoobar"); in main()
1023 DOTEST(1024, "foobarfoobarfoobar", 18, "%-16s", "foobarfoobarfoobar"); in main()
1031 "packet %2.2x%2.2x%2.2x%2.2x id", 0x12, 0x03, 0xce, 0xff); in main()