This patch fixes two parts: For one thing "batctl l" won't remove commas anymore if it cannot find the mac address in the bat-hosts file. For another, it now allows the correct substitution of mac addresses which have the suffix ')'.
Signed-off-by: Linus Lüssing linus.luessing@ascom.ch --- functions.c | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/functions.c b/functions.c index ce046ba..52cfe4b 100644 --- a/functions.c +++ b/functions.c @@ -177,9 +177,17 @@ read: *space_ptr = '\0'; extra_char = '\0';
- if ((strlen(buff_ptr) == ETH_STR_LEN + 1) && (buff_ptr[ETH_STR_LEN] == ',')) { - extra_char = ','; - buff_ptr[ETH_STR_LEN] = '\0'; + if (strlen(buff_ptr) == ETH_STR_LEN + 1) { + extra_char = buff_ptr[ETH_STR_LEN]; + switch (extra_char) { + case ',': + case ')': + buff_ptr[ETH_STR_LEN] = '\0'; + break; + default: + extra_char = '\0'; + break; + } }
if (strlen(buff_ptr) != ETH_STR_LEN) @@ -201,16 +209,16 @@ read: /* keep table format */ printf("%17s", bat_host->name);
- if (extra_char != '\0') - printf("%c", extra_char); - - printf(" "); goto written;
print_plain_buff: - printf("%s ", buff_ptr); + printf("%s", buff_ptr);
written: + if (extra_char != '\0') + printf("%c", extra_char); + + printf(" "); buff_ptr = space_ptr + 1; }