mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 09:17:20 +00:00
f924bebd83
In a long printf call with many placeholders, it's hard to see which argument belongs to which placeholder. The long printf-like calls in the INFO and CLIENT commands are rewritten into pairs of (format, argument). These pairs are then rewritten to a single call with a long format string and a long list of arguments, using a macro called FMTARGS. The file `fmtargs.h` is added to the repo. Co-authored-by: Madelyn Olson <34459052+madolson@users.noreply.github.com>
23 lines
835 B
Python
Executable File
23 lines
835 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# Outputs the generated part of src/fmtargs.h
|
|
MAX_ARGS = 120
|
|
|
|
import os
|
|
print("/* Everything below this line is automatically generated by")
|
|
print(" * %s. Do not manually edit. */\n" % os.path.basename(__file__))
|
|
|
|
print('#define ARG_N(' + ', '.join(['_' + str(i) for i in range(1, MAX_ARGS + 1, 1)]) + ', N, ...) N')
|
|
|
|
print('\n#define RSEQ_N() ' + ', '.join([str(i) for i in range(MAX_ARGS, -1, -1)]))
|
|
|
|
print('\n#define COMPACT_FMT_2(fmt, value) fmt')
|
|
for i in range(4, MAX_ARGS + 1, 2):
|
|
print('#define COMPACT_FMT_{}(fmt, value, ...) fmt COMPACT_FMT_{}(__VA_ARGS__)'.format(i, i - 2))
|
|
|
|
print('\n#define COMPACT_VALUES_2(fmt, value) value')
|
|
for i in range(4, MAX_ARGS + 1, 2):
|
|
print('#define COMPACT_VALUES_{}(fmt, value, ...) value, COMPACT_VALUES_{}(__VA_ARGS__)'.format(i, i - 2))
|
|
|
|
print("\n#endif")
|