diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-11-26 09:17:15 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-11-26 09:17:15 +0000 |
commit | 59a4bc3afb004d7aeef69461987307738a9fe4af (patch) | |
tree | 5bc3711b14cddf2fb540cd857b010d694d25dc64 /tools | |
parent | 6834de18b98fea0e7d370a296318115a659047af (diff) |
Use multibyte friendly checks instead of isprint()
Diffstat (limited to 'tools')
-rw-r--r-- | tools/hciconfig.c | 12 | ||||
-rw-r--r-- | tools/hcitool.c | 16 |
2 files changed, 18 insertions, 10 deletions
diff --git a/tools/hciconfig.c b/tools/hciconfig.c index 3e7a5fbc..18601d77 100644 --- a/tools/hciconfig.c +++ b/tools/hciconfig.c @@ -473,9 +473,11 @@ static void cmd_name(int ctl, int hdev, char *opt) exit(1); } - for (i = 0; i < 248 && name[i]; i++) - if (!isprint(name[i])) + for (i = 0; i < 248 && name[i]; i++) { + if ((unsigned char) name[i] < 32 || name[i] == 127) name[i] = '.'; + } + name[248] = '\0'; print_dev_hdr(&di); @@ -1002,9 +1004,11 @@ static void cmd_inq_data(int ctl, int hdev, char *opt) str = malloc(len); if (str) { snprintf(str, len, "%s", ptr); - for (i = 0; i < len - 1; i++) - if (!isprint(str[i])) + for (i = 0; i < len - 1; i++) { + if ((unsigned char) str[i] < 32 || str[i] == 127) str[i] = '.'; + } + printf("\t%s local name: \'%s\'\n", type == 0x08 ? "Shortened" : "Complete", str); free(str); diff --git a/tools/hcitool.c b/tools/hcitool.c index dfa3e48e..9449e7c6 100644 --- a/tools/hcitool.c +++ b/tools/hcitool.c @@ -546,9 +546,11 @@ static void cmd_scan(int dev_id, int argc, char **argv) sizeof(name), name, 100000) < 0) strcpy(name, "n/a"); - for (n = 0; n < 248 && name[n]; n++) - if (!isprint(name[n])) - name[n] = '.'; + for (n = 0; n < 248 && name[n]; n++) { + if ((unsigned char) name[i] < 32 || name[i] == 127) + name[i] = '.'; + } + name[248] = '\0'; printf("\t%s\t%s\n", addr, name); @@ -605,9 +607,11 @@ static void cmd_scan(int dev_id, int argc, char **argv) if (!nc) strcpy(name, "n/a"); } else { - for (n = 0; n < 248 && name[n]; n++) - if (!isprint(name[n])) - name[n] = '.'; + for (n = 0; n < 248 && name[n]; n++) { + if ((unsigned char) name[i] < 32 || name[i] == 127) + name[i] = '.'; + } + name[248] = '\0'; nc = 0; } |