Change in ...libosmocore[master]: vty: Simplify char escaping in asciidoc output

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Tue Jun 25 21:46:44 UTC 2019


pespin has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/libosmocore/+/14538 )

Change subject: vty: Simplify char escaping in asciidoc output
......................................................................

vty: Simplify char escaping in asciidoc output

Change-Id: I7df6858bb98abffc1d5bf420f991ae5854b24638
---
M src/vty/command.c
1 file changed, 4 insertions(+), 9 deletions(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  osmith: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/vty/command.c b/src/vty/command.c
index 89a2bc1..454a10c 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -515,7 +515,7 @@
 {
 	int _strlen;
 	char *out, *out_ptr;
-	int len = 0, i, j;
+	int len = 0, i;
 
 	if (!inp)
 		return NULL;
@@ -538,23 +538,18 @@
 
 	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;
 }

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/14538
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I7df6858bb98abffc1d5bf420f991ae5854b24638
Gerrit-Change-Number: 14538
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190625/7aa1cf36/attachment.htm>


More information about the gerrit-log mailing list