[2/2] batctl: Fix (skipped) substitutions of mac addresses

Message ID 1290462354-17246-2-git-send-email-linus.luessing@ascom.ch (mailing list archive)
State Superseded, archived
Headers

Commit Message

Linus Lüssing Nov. 22, 2010, 9:45 p.m. UTC
  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(-)
  

Comments

Marek Lindner Nov. 22, 2010, 11:48 p.m. UTC | #1
On Monday 22 November 2010 22:45:54 Linus Lüssing wrote:
> 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 ')'.

Would you mind splitting these changes into 2 different patches ?

Regards,
Marek
  

Patch

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;
 		}