Home | History | Annotate | Download | only in strace

Lines Matching refs:spec

277 	     struct printf_spec spec)
284 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10);
289 if (i < spec.field_width)
290 i = spec.field_width;
295 // if (spec.flags & LEFT)
296 // spec.flags &= ~ZEROPAD;
298 if (spec.flags & SIGN) {
302 spec.field_width--;
303 // } else if (spec.flags & PLUS) {
305 // spec.field_width--;
306 // } else if (spec.flags & SPACE) {
308 // spec.field_width--;
312 spec.field_width--;
313 if (spec.base == 16)
314 spec.field_width--;
319 if (num < spec.base)
326 else if (spec.base != 10) { /* 8 or 16 */
327 int mask = spec.base - 1;
330 if (spec.base == 16)
340 //spec.precision is assumed 0 ("not specified")
342 // if (i > spec.precision)
343 // spec.precision = i;
345 // spec.field_width -= spec.precision;
346 spec.field_width -= i;
347 if (!(spec.flags & (ZEROPAD+LEFT))) {
348 while (--spec.field_width >= 0) {
365 if (spec.base == 16) {
372 if (!(spec.flags & LEFT)) {
373 char c = (spec.flags & ZEROPAD) ? '0' : ' ';
374 while (--spec.field_width >= 0) {
381 // while (i <= --spec.precision) {
393 while (--spec.field_width >= 0) {
403 char *string(char *buf, char *end, const char *s, struct printf_spec spec)
410 len = strnlen(s, spec.precision);
414 if (i < spec.field_width)
415 i = spec.field_width;
419 if (!(spec.flags & LEFT)) {
420 while (len < spec.field_width--) {
431 while (len < spec.field_width--) {
442 struct printf_spec spec)
444 // spec.flags |= SMALL;
445 if (spec.field_width == -1) {
446 spec.field_width = 2 * sizeof(void *);
447 spec.flags |= ZEROPAD;
449 spec.base = 16;
451 return number(buf, end, (unsigned long) ptr, spec);
475 int format_decode(const char *fmt, struct printf_spec *spec)
480 if (spec->type == FORMAT_TYPE_WIDTH) {
481 if (spec->field_width < 0) {
482 spec->field_width = -spec->field_width;
483 spec->flags |= LEFT;
485 spec->type = FORMAT_TYPE_NONE;
490 if (spec->type == FORMAT_TYPE_PRECISION) {
491 if (spec->precision < 0)
492 spec->precision = 0;
494 spec->type = FORMAT_TYPE_NONE;
499 spec->type = FORMAT_TYPE_NONE;
514 spec->flags = 0;
522 case '-': spec->flags |= LEFT; break;
523 // case '+': spec->flags |= PLUS; break;
524 // case ' ': spec->flags |= SPACE; break;
525 case '#': spec->flags |= SPECIAL; break;
526 case '0': spec->flags |= ZEROPAD; break;
535 spec->field_width = -1;
538 spec->field_width = skip_atoi(&fmt);
541 spec->type = FORMAT_TYPE_WIDTH;
547 spec->precision = -1;
551 spec->precision = skip_atoi(&fmt);
552 // if (spec->precision < 0)
553 // spec->precision = 0;
556 spec->type = FORMAT_TYPE_PRECISION;
563 spec->qualifier = -1;
565 spec->qualifier = *fmt++;
566 if (unlikely(spec->qualifier == *fmt)) {
567 spec->qualifier = 'L';
573 spec->base = 10;
576 spec->type = FORMAT_TYPE_CHAR;
580 spec->type = FORMAT_TYPE_STR;
584 spec->type = FORMAT_TYPE_PTR;
588 spec->type = FORMAT_TYPE_PERCENT_CHAR;
593 spec->base = 8;
597 // spec->flags |= SMALL;
600 spec->base = 16;
605 spec->flags |= SIGN;
610 spec->type = FORMAT_TYPE_INVALID;
614 if (spec->qualifier == 'L')
615 spec->type = FORMAT_TYPE_LONG_LONG;
616 else if (spec->qualifier == 'l') {
617 if (spec->flags & SIGN)
618 spec->type = FORMAT_TYPE_LONG;
620 spec->type = FORMAT_TYPE_ULONG;
622 if (spec->flags & SIGN)
623 spec->type = FORMAT_TYPE_INT;
625 spec->type = FORMAT_TYPE_UINT;
653 struct printf_spec spec = {0};
660 int read = format_decode(fmt, &spec);
664 switch (spec.type) {
677 spec.field_width = va_arg(args, int);
681 spec.precision = va_arg(args, int);
687 if (!(spec.flags & LEFT)) {
688 while (--spec.field_width > 0) {
699 while (--spec.field_width > 0) {
708 str = string(str, end, va_arg(args, char *), spec);
713 spec);
731 switch (spec.type) {
748 str = number(str, end, num, spec);