Linux bluetooth development
 help / color / mirror / Atom feed
* [Bluez-devel] [PATCH] Replaced isprint() with a more multibyte friendly check
@ 2006-11-25 21:35 Daniel Gollub
  2006-11-26 10:18 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Gollub @ 2006-11-25 21:35 UTC (permalink / raw)
  To: bluez-devel

[-- 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Bluez-devel] [PATCH] Replaced isprint() with a more multibyte friendly check
  2006-11-25 21:35 [Bluez-devel] [PATCH] Replaced isprint() with a more multibyte friendly check Daniel Gollub
@ 2006-11-26 10:18 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2006-11-26 10:18 UTC (permalink / raw)
  To: BlueZ development

Hi Daniel,

> 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.

the patch has been applied to the CVS. Thanks.

Regards

Marcel



-------------------------------------------------------------------------
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
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-11-26 10:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-25 21:35 [Bluez-devel] [PATCH] Replaced isprint() with a more multibyte friendly check Daniel Gollub
2006-11-26 10:18 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox