]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
SSID printing: escape space at beginning end, backslash
authorJohannes Berg <johannes.berg@intel.com>
Sun, 16 Oct 2011 15:04:37 +0000 (17:04 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Sun, 16 Oct 2011 15:04:37 +0000 (17:04 +0200)
To make SSID printing point out spaces at the beginning
and end explicitly escape them with \x20. Also escape
the backslash itself so that it's unambiguous.

util.c

diff --git a/util.c b/util.c
index afffeb6b62100c5c23c776f051fde435476d2db4..e03ec2c02fd16a78e490cfadaa925a15c87bcf00 100644 (file)
--- a/util.c
+++ b/util.c
@@ -250,8 +250,11 @@ void print_ssid_escaped(const uint8_t len, const uint8_t *data)
        int i;
 
        for (i = 0; i < len; i++) {
-               if (isprint(data[i]))
+               if (isprint(data[i]) && data[i] != ' ' && data[i] != '\\')
                        printf("%c", data[i]);
+               else if (data[i] == ' ' &&
+                        (i != 0 && i != len -1))
+                       printf(" ");
                else
                        printf("\\x%.2x", data[i]);
        }