From: Daniel Gollub <dgollub@suse.de>
To: bluez-devel@lists.sourceforge.net
Subject: [Bluez-devel] [PATCH] Replaced isprint() with a more multibyte friendly check
Date: Sat, 25 Nov 2006 22:35:25 +0100 [thread overview]
Message-ID: <200611252235.25637.dgollub@suse.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 343 bytes --]
Hi,
there is a problem with multibyte chars when scanning with hcitool scan.
This problem appears only when the device name was not stored in the adapters
name list. I replace some isprint() with a more multibyte friendly check.
This should avoid this problem and print also full names with multibyte chars
included.
best regards,
Daniel
[-- Attachment #2: bluez-hcitool-mb.diff --]
[-- Type: text/x-diff, Size: 1984 bytes --]
Index: tools/hciconfig.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/hciconfig.c,v
retrieving revision 1.83
diff -u -r1.83 hciconfig.c
--- tools/hciconfig.c 21 Nov 2006 15:44:56 -0000 1.83
+++ tools/hciconfig.c 25 Nov 2006 21:24:16 -0000
@@ -473,9 +473,11 @@
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 @@
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);
Index: tools/hcitool.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/hcitool.c,v
retrieving revision 1.91
diff -u -r1.91 hcitool.c
--- tools/hcitool.c 29 Sep 2006 11:42:14 -0000 1.91
+++ tools/hcitool.c 25 Nov 2006 21:24:16 -0000
@@ -546,9 +546,11 @@
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 @@
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;
}
[-- Attachment #3: Type: text/plain, Size: 347 bytes --]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
next reply other threads:[~2006-11-25 21:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-25 21:35 Daniel Gollub [this message]
2006-11-26 10:18 ` [Bluez-devel] [PATCH] Replaced isprint() with a more multibyte friendly check Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200611252235.25637.dgollub@suse.de \
--to=dgollub@suse.de \
--cc=bluez-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox