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

1 /* snprintf - compatibility implementation of snprintf, vsnprintf
60 * mostly in formatting and range (e+-16), for %f and %g.
62 * %s, %d, %u, %i, %x, %c, %n and %% are fully supported.
63 * This includes width, precision, flags 0- +, and *(arg for wid,prec).
81 while(num--) { in print_pad()
84 (*left)--; in print_pad()
95 return '-'; in get_negsign()
106 print_dec(char* buf, int max, unsigned int value) in print_dec() argument
110 if(max > 0) { in print_dec()
114 } else while(value && i < max) { in print_dec()
123 print_dec_l(char* buf, int max, unsigned long value) in print_dec_l() argument
127 if(max > 0) { in print_dec_l()
131 } else while(value && i < max) { in print_dec_l()
140 print_dec_ll(char* buf, int max, unsigned long long value) in print_dec_ll() argument
144 if(max > 0) { in print_dec_ll()
148 } else while(value && i < max) { in print_dec_ll()
157 print_hex(char* buf, int max, unsigned int value) in print_hex() argument
162 if(max > 0) { in print_hex()
166 } else while(value && i < max) { in print_hex()
175 print_hex_l(char* buf, int max, unsigned long value) in print_hex_l() argument
180 if(max > 0) { in print_hex_l()
184 } else while(value && i < max) { in print_hex_l()
193 print_hex_ll(char* buf, int max, unsigned long long value) in print_hex_ll() argument
198 if(max > 0) { in print_hex_ll()
202 } else while(value && i < max) { in print_hex_ll()
216 *(*at)++ = buf[--i]; in spool_str_rev()
217 (*left)--; in spool_str_rev()
218 } else --i; in spool_str_rev()
231 (*left)--; in spool_str()
261 print_pad(at, left, ret, '0', precision - w); in print_num()
266 print_pad(at, left, ret, ' ', minw - numw); in print_num()
278 print_pad(at, left, ret, ' ', minw - numw); in print_num()
282 numw--; in print_num()
286 print_pad(at, left, ret, '0', numw - w); in print_num()
304 (unsigned int)(negative?-value:value)); in print_num_d()
319 (unsigned long)(negative?-value:value)); in print_num_ld()
334 (unsigned long long)(negative?-value:value)); in print_num_lld()
381 /** print %x */
447 /* put '0x' in front of the (reversed) buffer result */ in print_num_llp()
449 buf[len++] = 'x'; in print_num_llp()
457 #define PRINT_FLOAT_BUFSZ 64 /* xx.yy with 20.20 about the max */
460 print_remainder(char* buf, int max, double r, int prec) in print_remainder() argument
465 if(prec > 19) prec = 19; /* max we can do */ in print_remainder()
466 if(max < prec) return 0; in print_remainder()
473 if(((unsigned long long)((r - (double)value)*10.0)) >= 5) { in print_remainder()
478 value = cap-1; in print_remainder()
480 len = print_dec_ll(buf, max, value); in print_remainder()
484 if(len < max) in print_remainder()
491 print_float(char* buf, int max, double value, int prec) in print_float() argument
495 linking with -lm. */ in print_float()
497 * which makes 19 digits before and after the decimal point the max */ in print_float()
499 double remain = value - (double)whole; in print_float()
502 len = print_remainder(buf, max, remain, prec); in print_float()
503 len += print_dec_ll(buf+len, max-len, whole); in print_float()
518 len = print_float(buf, (int)sizeof(buf), negative?-value:value, in print_num_f()
526 print_float_g(char* buf, int max, double value, int prec) in print_float_g() argument
529 double remain = value - (double)whole; in print_float_g()
542 len = print_remainder(buf, max, remain, prec-before); in print_float_g()
544 memmove(buf, buf+1, --len); in print_float_g()
547 len += print_dec_ll(buf+len, max-len, whole); in print_float_g()
564 len = print_float_g(buf, (int)sizeof(buf), negative?-value:value, in print_num_g()
573 my_strnlen(const char* s, int max) in my_strnlen() argument
576 for(i=0; i<max; i++) in my_strnlen()
579 return max; in my_strnlen()
588 /* with prec: no more than x characters from this string, stop at 0 */ in print_str()
593 print_pad(at, left, ret, ' ', minw - w); in print_str()
596 print_pad(at, left, ret, ' ', minw - w); in print_str()
605 print_pad(at, left, ret, ' ', minw - 1); in print_char()
608 print_pad(at, left, ret, ' ', minw - 1); in print_char()
623 * %s, %u, %d, %x, %i, %f, %g, %c, %p, %n.
624 * length: l, ll (for d, u, x).
625 * precision: 6.6d (for d, u, x)
642 left--; in vsnprintf()
661 * conversion specifier: x, d, u, s, c, m, p in vsnprintf()
664 * - left adjust (right by default) in vsnprintf()
665 * ' ' printspace for positive number (in - position). in vsnprintf()
667 * fieldwidth: [1-9][0-9]* minimum field width. in vsnprintf()
669 * if this is negative, the - flag is set (with positive width). in vsnprintf()
670 * precision: period[digits]*, %.2x. in vsnprintf()
673 * this is mindigits to print for d, i, u, x in vsnprintf()
675 * this is max number significant digits for g in vsnprintf()
677 * length: 0-none (int), 1-l (long), 2-ll (long long) in vsnprintf()
680 * Does not support %#x in vsnprintf()
696 else if(*fmt == '-') in vsnprintf()
712 minw = -minw; in vsnprintf()
715 minw = minw*10 + (*fmt++)-'0'; in vsnprintf()
729 precision = precision*10 + (*fmt++)-'0'; in vsnprintf()
778 case 'x': in vsnprintf()
864 int x = 0; in main() local
891 DOTEST(1024, "-1", 2, "%d", -1); in main()
892 DOTEST(1024, "-12", 3, "%3d", -12); in main()
893 DOTEST(1024, " -2", 3, "%3d", -2); in main()
894 DOTEST(1024, "-012", 4, "%.3d", -12); in main()
895 DOTEST(1024, "-012", 4, "%3.3d", -12); in main()
896 DOTEST(1024, "-012", 4, "%4.3d", -12); in main()
897 DOTEST(1024, " -012", 5, "%5.3d", -12); in main()
898 DOTEST(1024, "-12", 3, "%03d", -12); in main()
899 DOTEST(1024, "-02", 3, "%03d", -2); in main()
900 DOTEST(1024, "-15", 3, "%d", -15); in main()
901 DOTEST(1024, "-7307", 5, "%d", -7307); in main()
902 DOTEST(1024, "-12 ", 5, "%-5d", -12); in main()
903 DOTEST(1024, "-00012", 6, "%-.5d", -12); in main()
914 /* test %x */ in main()
915 DOTEST(1024, "0", 1, "%x", 0); in main()
916 DOTEST(1024, "c", 1, "%x", 12); in main()
917 DOTEST(1024, "12ab34cd", 8, "%x", 0x12ab34cd); in main()
922 DOTEST(1024, "-9223372036854775808", 20, "%lld", in main()
930 DOTEST(1024, "hello ", 10, "%-10s", "hello"); in main()
942 DOTEST(1024, "hello", 5, "hello%n", &x); in main()
943 if(x != 5) { printf("the %%n failed\n"); exit(1); } in main()
959 /* differs, "-0.00" DOTEST(1024, "0.00", 4, "%.2f", -0.0); */ in main()
962 DOTEST(1024, "-12.000000", 10, "%f", -12.0); in main()
981 DOTEST(1024, "12345", 5, "%x", 0x12345); in main()
994 DOTEST(1024, "-012", 4, "%3.3d", -12); in main()
999 DOTEST(1024, "hello ", 7, "%*s", -7, "hello"); in main()
1005 DOTEST(1024, "0a", 2, "%02x", 0x0a); in main()
1006 DOTEST(1024, "bd", 2, "%02x", 0xbd); in main()
1016 DOTEST(1024, "0123", 4, "%.4x", 0x0123); in main()
1017 DOTEST(1024, "00000123", 8, "%.8x", 0x0123); in main()
1018 DOTEST(1024, "ffeb0cde", 8, "%.8x", 0xffeb0cde); in main()
1022 DOTEST(1024, "-87654321", 9, "%i", -87654321); in main()
1023 DOTEST(1024, "hello ", 16, "%-16s", "hello"); in main()
1024 DOTEST(1024, " ", 16, "%-16s", ""); in main()
1025 DOTEST(1024, "a ", 16, "%-16s", "a"); in main()
1026 DOTEST(1024, "foobarfoobar ", 16, "%-16s", "foobarfoobar"); in main()
1027 DOTEST(1024, "foobarfoobarfoobar", 18, "%-16s", "foobarfoobarfoobar"); in main()
1035 "packet %2.2x%2.2x%2.2x%2.2x id", 0x12, 0x03, 0xce, 0xff); in main()