summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-06-19 14:55:45 +0200
committerpespin <pespin@sysmocom.de>2019-06-25 21:46:44 +0000
commite1e1ec31a3c5085c2774c4b04b5fafd602ae0d30 (patch)
tree202b76aa4e0a05465e06b68be83feffa29b624e6 /src
parent28a198f9c0a65a5158cf8d9c3e79dcf9fb1e4d93 (diff)
vty: Simplify char escaping in asciidoc output
Change-Id: I7df6858bb98abffc1d5bf420f991ae5854b24638
Diffstat (limited to 'src')
-rw-r--r--src/vty/command.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/vty/command.c b/src/vty/command.c
index 89a2bc10..454a10c3 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -515,7 +515,7 @@ char *osmo_asciidoc_escape(const char *inp)
{
int _strlen;
char *out, *out_ptr;
- int len = 0, i, j;
+ int len = 0, i;
if (!inp)
return NULL;
@@ -538,23 +538,18 @@ char *osmo_asciidoc_escape(const char *inp)
out_ptr = out;
-#define ADD(out, str) \
- for (j = 0; j < strlen(str); ++j) \
- *(out++) = str[j];
-
for (i = 0; i < _strlen; ++i) {
switch (inp[i]) {
case '|':
- ADD(out_ptr, "\\|");
- break;
+ /* Prepend escape character "\": */
+ *(out_ptr++) = '\\';
+ /* fall through */
default:
*(out_ptr++) = inp[i];
break;
}
}
-#undef ADD
-
out_ptr[0] = '\0';
return out;
}