mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-24 12:20:59 +01:00
MINOR: standard: make indent_msg() support empty messages
indent_msg() is called with dynamically generated messages, so these may be empty (NULL) when an empty list is being dumped. Support this and return a NULL too.
This commit is contained in:
parent
21faa91be6
commit
70eec3832f
@ -1840,7 +1840,8 @@ char *memprintf(char **out, const char *format, ...)
|
|||||||
|
|
||||||
/* Used to add <level> spaces before each line of <out>, unless there is only one line.
|
/* Used to add <level> spaces before each line of <out>, unless there is only one line.
|
||||||
* The input argument is automatically freed and reassigned. The result will have to be
|
* The input argument is automatically freed and reassigned. The result will have to be
|
||||||
* freed by the caller.
|
* freed by the caller. It also supports being passed a NULL which results in the same
|
||||||
|
* output.
|
||||||
* Example of use :
|
* Example of use :
|
||||||
* parse(cmd, &err); (callee: memprintf(&err, ...))
|
* parse(cmd, &err); (callee: memprintf(&err, ...))
|
||||||
* fprintf(stderr, "Parser said: %s\n", indent_error(&err));
|
* fprintf(stderr, "Parser said: %s\n", indent_error(&err));
|
||||||
@ -1854,6 +1855,9 @@ char *indent_msg(char **out, int level)
|
|||||||
int lastlf = 0;
|
int lastlf = 0;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
if (!out || !*out)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
in = *out - 1;
|
in = *out - 1;
|
||||||
while ((in = strchr(in + 1, '\n')) != NULL) {
|
while ((in = strchr(in + 1, '\n')) != NULL) {
|
||||||
lastlf = in - *out;
|
lastlf = in - *out;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user