Skip to content

Commit

Permalink
Apply new .clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed May 28, 2023
1 parent 9e2214c commit 7cbb1b0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 54 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ AlignConsecutiveBitFields:
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: Align
SortIncludes: false
SortIncludes: true
InsertBraces: true # Control statements must have curly brackets
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
Expand Down
16 changes: 8 additions & 8 deletions lwprintf/src/include/lwprintf/lwprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ uint8_t lwprintf_unprotect_ex(lwprintf_t* const lwobj);
* \return `1` on success, `0` otherwise
* \sa lwprintf_init_ex
*/
#define lwprintf_init(out_fn) lwprintf_init_ex(NULL, (out_fn))
#define lwprintf_init(out_fn) lwprintf_init_ex(NULL, (out_fn))

/**
* \brief Print formatted data from variable argument list to the output with default LwPRINTF instance
Expand All @@ -122,7 +122,7 @@ uint8_t lwprintf_unprotect_ex(lwprintf_t* const lwobj);
* \return The number of characters that would have been written if `n` had been sufficiently large,
* not counting the terminating null character.
*/
#define lwprintf_vprintf(format, arg) lwprintf_vprintf_ex(NULL, (format), (arg))
#define lwprintf_vprintf(format, arg) lwprintf_vprintf_ex(NULL, (format), (arg))

/**
* \brief Print formatted data to the output with default LwPRINTF instance
Expand All @@ -131,7 +131,7 @@ uint8_t lwprintf_unprotect_ex(lwprintf_t* const lwobj);
* \return The number of characters that would have been written if `n` had been sufficiently large,
* not counting the terminating null character.
*/
#define lwprintf_printf(format, ...) lwprintf_printf_ex(NULL, (format), ##__VA_ARGS__)
#define lwprintf_printf(format, ...) lwprintf_printf_ex(NULL, (format), ##__VA_ARGS__)

/**
* \brief Write formatted data from variable argument list to sized buffer with default LwPRINTF instance
Expand All @@ -146,7 +146,7 @@ uint8_t lwprintf_unprotect_ex(lwprintf_t* const lwobj);
* \return The number of characters that would have been written if `n` had been sufficiently large,
* not counting the terminating null character.
*/
#define lwprintf_vsnprintf(s, n, format, arg) lwprintf_vsnprintf_ex(NULL, (s), (n), (format), (arg))
#define lwprintf_vsnprintf(s, n, format, arg) lwprintf_vsnprintf_ex(NULL, (s), (n), (format), (arg))

/**
* \brief Write formatted data from variable argument list to sized buffer with default LwPRINTF instance
Expand All @@ -160,7 +160,7 @@ uint8_t lwprintf_unprotect_ex(lwprintf_t* const lwobj);
* \return The number of characters that would have been written if `n` had been sufficiently large,
* not counting the terminating null character.
*/
#define lwprintf_snprintf(s, n, format, ...) lwprintf_snprintf_ex(NULL, (s), (n), (format), ##__VA_ARGS__)
#define lwprintf_snprintf(s, n, format, ...) lwprintf_snprintf_ex(NULL, (s), (n), (format), ##__VA_ARGS__)

/**
* \brief Write formatted data from variable argument list to sized buffer with default LwPRINTF instance
Expand All @@ -171,19 +171,19 @@ uint8_t lwprintf_unprotect_ex(lwprintf_t* const lwobj);
* \return The number of characters that would have been written,
* not counting the terminating null character.
*/
#define lwprintf_sprintf(s, format, ...) lwprintf_sprintf_ex(NULL, (s), (format), ##__VA_ARGS__)
#define lwprintf_sprintf(s, format, ...) lwprintf_sprintf_ex(NULL, (s), (format), ##__VA_ARGS__)

/**
* \brief Manually enable mutual exclusion
* \return `1` if protected, `0` otherwise
*/
#define lwprintf_protect() lwprintf_protect_ex(NULL)
#define lwprintf_protect() lwprintf_protect_ex(NULL)

/**
* \brief Manually disable mutual exclusion
* \return `1` if protected, `0` otherwise
*/
#define lwprintf_unprotect() lwprintf_unprotect_ex(NULL)
#define lwprintf_unprotect() lwprintf_unprotect_ex(NULL)

#if LWPRINTF_CFG_ENABLE_SHORTNAMES || __DOXYGEN__

Expand Down
60 changes: 16 additions & 44 deletions lwprintf/src/lwprintf/lwprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,27 +870,13 @@ prv_format(lwprintf_int_t* p, va_list arg) {
detected = 1;
do {
switch (*fmt) {
case '-':
p->m.flags.left_align = 1;
break;
case '+':
p->m.flags.plus = 1;
break;
case ' ':
p->m.flags.space = 1;
break;
case '0':
p->m.flags.zero = 1;
break;
case '\'':
p->m.flags.thousands = 1;
break;
case '#':
p->m.flags.alt = 1;
break;
default:
detected = 0;
break;
case '-': p->m.flags.left_align = 1; break;
case '+': p->m.flags.plus = 1; break;
case ' ': p->m.flags.space = 1; break;
case '0': p->m.flags.zero = 1; break;
case '\'': p->m.flags.thousands = 1; break;
case '#': p->m.flags.alt = 1; break;
default: detected = 0; break;
}
if (detected) {
++fmt;
Expand Down Expand Up @@ -943,8 +929,7 @@ prv_format(lwprintf_int_t* p, va_list arg) {
++fmt;
}
break;
case 'L':
break;
case 'L': break;
case 'z':
p->m.flags.sz_t = 1; /* Size T flag */
++fmt;
Expand All @@ -953,10 +938,8 @@ prv_format(lwprintf_int_t* p, va_list arg) {
p->m.flags.umax_t = 1; /* uintmax_t flag */
++fmt;
break;
case 't':
break;
default:
detected = 0;
case 't': break;
default: detected = 0;
}

/* Check type */
Expand All @@ -971,9 +954,7 @@ prv_format(lwprintf_int_t* p, va_list arg) {
(void)va_arg(arg, double); /* Read argument to ignore it and move to next one */
prv_out_str_raw(p, "NaN", 3); /* Print string */
break;
case 'c':
p->out_fn(p, (char)va_arg(arg, int));
break;
case 'c': p->out_fn(p, (char)va_arg(arg, int)); break;
#if LWPRINTF_CFG_SUPPORT_TYPE_INT
case 'd':
case 'i': {
Expand Down Expand Up @@ -1017,15 +998,9 @@ prv_format(lwprintf_int_t* p, va_list arg) {
} else if (p->m.flags.longlong == 0 || p->m.base == 2) {
unsigned int v;
switch (p->m.flags.char_short) {
case 2:
v = (unsigned int)((unsigned char)va_arg(arg, unsigned int));
break;
case 1:
v = (unsigned int)((unsigned short int)va_arg(arg, unsigned int));
break;
default:
v = (unsigned int)((unsigned int)va_arg(arg, unsigned int));
break;
case 2: v = (unsigned int)((unsigned char)va_arg(arg, unsigned int)); break;
case 1: v = (unsigned int)((unsigned short int)va_arg(arg, unsigned int)); break;
default: v = (unsigned int)((unsigned int)va_arg(arg, unsigned int)); break;
}
prv_unsigned_int_to_str(p, v);
} else if (p->m.flags.longlong == 1) {
Expand Down Expand Up @@ -1083,9 +1058,7 @@ prv_format(lwprintf_int_t* p, va_list arg) {

break;
}
case '%':
p->out_fn(p, '%');
break;
case '%': p->out_fn(p, '%'); break;
#if LWPRINTF_CFG_SUPPORT_TYPE_BYTE_ARRAY
/*
* This is to print unsigned-char formatted pointer in hex string
Expand Down Expand Up @@ -1133,8 +1106,7 @@ prv_format(lwprintf_int_t* p, va_list arg) {
break;
}
#endif /* LWPRINTF_CFG_SUPPORT_TYPE_BYTE_ARRAY */
default:
p->out_fn(p, *fmt);
default: p->out_fn(p, *fmt);
}
++fmt;
}
Expand Down

0 comments on commit 7cbb1b0

Please sign in to comment.