URL:
https://github.com/SSSD/sssd/pull/902
Title: #902: Added ERROR and PRINT macros to the tools
mzidek-rh commented:
"""
Hi @alexal!
I have found these issues:
1. do not nest "ERROR()" and "PRINT()" macros with the macro
"_()".
2. It does not make sense to wrap text that can not be translated into any if these
macros. So the messages that were not wrapped by _() macro should also not be wrapped by
ERROR() or PRINT() macros. For example here:
```
if (commands[i].description == NULL) {
- fprintf(stderr, "* %40s\n", commands[i].command);
+ ERROR("* %40s\n", commands[i].command);
} else {
- fprintf(stderr, "* %-*s\t %s\n",
+ ERROR("* %-*s\t %s\n",
min_len, commands[i].command, commands[i].description);
}
}
}
```
There is no reason to wrap those strings in gettext.
For the reference here are definitions of the PRINT(), ERROR() and _() macros:
```
src/util/util.h:54:#define _(STRING) gettext (STRING)
src/util/debug.h:#define ERROR(fmt, ...) fprintf(stderr, gettext(fmt), ##__VA_ARGS__)
src/util/debug.h:#define PRINT(fmt, ...) fprintf(stdout, gettext(fmt), ##__VA_ARGS__)
```
So you can use format string with ERROR and PRINT.
In general I agree that converting "fprintf + _()" into ERROR or PRINT results
in nicer looking code, so I am not against the patches if the above issues are
addressed.
Michal
"""
See the full comment at
https://github.com/SSSD/sssd/pull/902#issuecomment-542631510