Skip to content

Commit

Permalink
Remove M_PRINT_ARG macro to simplify maintenance
Browse files Browse the repository at this point in the history
(M_FPRINT_MACRO with stdout can be used instead)
  • Loading branch information
P-p-H-d committed Dec 22, 2023
1 parent fecece1 commit d318493
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6376,20 +6376,15 @@ Theses macros are only valid if the program is built in C11 mode:
Return the printf format associated to the type of 'x'.
'x' shall be a basic C variable, printable with printf.
##### M\_PRINT\_ARG(x)
##### M\_FPRINT\_ARG(file, x)
Print using printf the variable 'x'.
Print into a file 'file' using fprintf the variable 'x'.
The format of 'x' is deduced provided that it is a standard numerical C type.
If m-string is included, it supports also the type 'string\_t' natively.
If the argument is extended (i.e. in the format '(var, optype)' with optype being either an oplist or a type
with a globally registered oplist), then it will call the OUT\_STR method of the oplist on the variable 'var'.
##### M\_FPRINT\_ARG(file, x)
Print into a file 'file' using fprintf the variable 'x'.
See M\_PRINT\_ARG for details on the supported variable.
##### M\_GET\_STRING\_ARG(string,x,append)
Print into the string\_t 'string' the variable 'x'.
Expand Down
11 changes: 1 addition & 10 deletions m-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -2629,15 +2629,6 @@ m_core_fopen(const char filename[], const char opt[])
/* Can be overloaded by m-string to support string output too */
#define M_CORE_PRINTF_ARG(x) x

/* Print a C variable if it is a standard type (or extension) to stdout
If a variable is extended (i.e. like (x, type) ) it will use the
method associated to the OUT_STR operator.
*/
#define M_PRINT_ARG(x) \
M_IF(M_PARENTHESIS_P(x)) \
( M_FPRINT_ARG_OUT_STR(stdout, M_PAIR_2 x, M_PAIR_1 x), \
printf(M_PRINTF_FORMAT(x), M_CORE_PRINTF_ARG(x) ) )

/* Print a C variable if it is a standard type to the given file 'f'.
If a variable is extended (i.e. like (x, type) ) it will use the
method associated to the OUT_STR operator.
Expand Down Expand Up @@ -2812,7 +2803,7 @@ M_PARSE_DEFAULT_TYPE_DEF(m_core_parse_ldouble, long double, strtold, )

/* Generic PRINT macro: print all its inputs regardless of the type
provided it is a generic "non-struct" type. */
#define M_PRINT(...) do { M_REDUCE(M_PRINT_ARG, M_SEPARATE_PER_SEMICOLON, __VA_ARGS__); } while (0)
#define M_PRINT(...) do { M_REDUCE2(M_FPRINT_ARG, M_SEPARATE_PER_SEMICOLON, stdout, __VA_ARGS__); } while (0)

/* Generic FPRINT macro: print all its inputs regardless of the type
provided it is a generic "non-struct" type into the file 'f'. */
Expand Down

0 comments on commit d318493

Please sign in to comment.