mirror of https://gerrit.osmocom.org/libosmocore
vty: Simplify char escaping in asciidoc output
Change-Id: I7df6858bb98abffc1d5bf420f991ae5854b24638
This commit is contained in:
parent
28a198f9c0
commit
e1e1ec31a3
|
@ -515,7 +515,7 @@ char *osmo_asciidoc_escape(const char *inp)
|
||||||
{
|
{
|
||||||
int _strlen;
|
int _strlen;
|
||||||
char *out, *out_ptr;
|
char *out, *out_ptr;
|
||||||
int len = 0, i, j;
|
int len = 0, i;
|
||||||
|
|
||||||
if (!inp)
|
if (!inp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -538,23 +538,18 @@ char *osmo_asciidoc_escape(const char *inp)
|
||||||
|
|
||||||
out_ptr = out;
|
out_ptr = out;
|
||||||
|
|
||||||
#define ADD(out, str) \
|
|
||||||
for (j = 0; j < strlen(str); ++j) \
|
|
||||||
*(out++) = str[j];
|
|
||||||
|
|
||||||
for (i = 0; i < _strlen; ++i) {
|
for (i = 0; i < _strlen; ++i) {
|
||||||
switch (inp[i]) {
|
switch (inp[i]) {
|
||||||
case '|':
|
case '|':
|
||||||
ADD(out_ptr, "\\|");
|
/* Prepend escape character "\": */
|
||||||
break;
|
*(out_ptr++) = '\\';
|
||||||
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
*(out_ptr++) = inp[i];
|
*(out_ptr++) = inp[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef ADD
|
|
||||||
|
|
||||||
out_ptr[0] = '\0';
|
out_ptr[0] = '\0';
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue