mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +01:00
all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
This commit is contained in:
59
py/mpprint.c
59
py/mpprint.c
@@ -269,14 +269,14 @@ int mp_print_mp_int(const mp_print_t *print, mp_obj_t x, int base, int base_char
|
||||
// We add the pad in this function, so since the pad goes after
|
||||
// the sign & prefix, we format without a prefix
|
||||
str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size,
|
||||
x, base, NULL, base_char, comma);
|
||||
x, base, NULL, base_char, comma);
|
||||
if (*str == '-') {
|
||||
sign = *str++;
|
||||
fmt_size--;
|
||||
}
|
||||
} else {
|
||||
str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size,
|
||||
x, base, prefix, base_char, comma);
|
||||
x, base, prefix, base_char, comma);
|
||||
}
|
||||
|
||||
int spaces_before = 0;
|
||||
@@ -347,8 +347,7 @@ int mp_print_float(const mp_print_t *print, mp_float_t f, char fmt, int flags, c
|
||||
|
||||
if (flags & PF_FLAG_SHOW_SIGN) {
|
||||
sign = '+';
|
||||
}
|
||||
else
|
||||
} else
|
||||
if (flags & PF_FLAG_SPACE_SIGN) {
|
||||
sign = ' ';
|
||||
}
|
||||
@@ -411,14 +410,20 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
|
||||
int flags = 0;
|
||||
char fill = ' ';
|
||||
while (*fmt != '\0') {
|
||||
if (*fmt == '-') flags |= PF_FLAG_LEFT_ADJUST;
|
||||
else if (*fmt == '+') flags |= PF_FLAG_SHOW_SIGN;
|
||||
else if (*fmt == ' ') flags |= PF_FLAG_SPACE_SIGN;
|
||||
else if (*fmt == '!') flags |= PF_FLAG_NO_TRAILZ;
|
||||
else if (*fmt == '0') {
|
||||
if (*fmt == '-') {
|
||||
flags |= PF_FLAG_LEFT_ADJUST;
|
||||
} else if (*fmt == '+') {
|
||||
flags |= PF_FLAG_SHOW_SIGN;
|
||||
} else if (*fmt == ' ') {
|
||||
flags |= PF_FLAG_SPACE_SIGN;
|
||||
} else if (*fmt == '!') {
|
||||
flags |= PF_FLAG_NO_TRAILZ;
|
||||
} else if (*fmt == '0') {
|
||||
flags |= PF_FLAG_PAD_AFTER_SIGN;
|
||||
fill = '0';
|
||||
} else break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
++fmt;
|
||||
}
|
||||
|
||||
@@ -470,26 +475,23 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
|
||||
chrs += mp_print_strn(print, "false", 5, flags, fill, width);
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
{
|
||||
case 'c': {
|
||||
char str = va_arg(args, int);
|
||||
chrs += mp_print_strn(print, &str, 1, flags, fill, width);
|
||||
break;
|
||||
}
|
||||
case 'q':
|
||||
{
|
||||
case 'q': {
|
||||
qstr qst = va_arg(args, qstr);
|
||||
size_t len;
|
||||
const char *str = (const char*)qstr_data(qst, &len);
|
||||
const char *str = (const char *)qstr_data(qst, &len);
|
||||
if (prec < 0) {
|
||||
prec = len;
|
||||
}
|
||||
chrs += mp_print_strn(print, str, prec, flags, fill, width);
|
||||
break;
|
||||
}
|
||||
case 's':
|
||||
{
|
||||
const char *str = va_arg(args, const char*);
|
||||
case 's': {
|
||||
const char *str = va_arg(args, const char *);
|
||||
#ifndef NDEBUG
|
||||
// With debugging enabled, catch printing of null string pointers
|
||||
if (prec != 0 && str == NULL) {
|
||||
@@ -532,26 +534,25 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
|
||||
// Use unsigned long int to work on both ILP32 and LP64 systems
|
||||
chrs += mp_print_int(print, va_arg(args, unsigned long int), 0, 16, 'a', flags, fill, width);
|
||||
break;
|
||||
#if MICROPY_PY_BUILTINS_FLOAT
|
||||
#if MICROPY_PY_BUILTINS_FLOAT
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
case 'F':
|
||||
case 'g':
|
||||
case 'G':
|
||||
{
|
||||
#if ((MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT) || (MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE))
|
||||
case 'G': {
|
||||
#if ((MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT) || (MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE))
|
||||
mp_float_t f = va_arg(args, double);
|
||||
chrs += mp_print_float(print, f, *fmt, flags, fill, width, prec);
|
||||
#else
|
||||
#error Unknown MICROPY FLOAT IMPL
|
||||
#endif
|
||||
#else
|
||||
#error Unknown MICROPY FLOAT IMPL
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
// Because 'l' is eaten above, another 'l' means %ll. We need to support
|
||||
// this length specifier for OBJ_REPR_D (64-bit NaN boxing).
|
||||
// TODO Either enable this unconditionally, or provide a specific config var.
|
||||
#endif
|
||||
// Because 'l' is eaten above, another 'l' means %ll. We need to support
|
||||
// this length specifier for OBJ_REPR_D (64-bit NaN boxing).
|
||||
// TODO Either enable this unconditionally, or provide a specific config var.
|
||||
#if (MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D) || defined(_WIN64)
|
||||
case 'l': {
|
||||
unsigned long long int arg_value = va_arg(args, unsigned long long int);
|
||||
|
||||
Reference in New Issue
Block a user