Subject: bin/8093: [PATCH] Bcd const/unsigned fixes
To: None <gnats-bugs@gnats.netbsd.org>
From: Joseph Myers <jsm28@cam.ac.uk>
List: netbsd-bugs
Date: 07/27/1999 11:15:00
>Number:         8093
>Category:       bin
>Synopsis:       [PATCH] Bcd const/unsigned fixes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 27 10:20:03 1999
>Last-Modified:
>Originator:     Joseph S. Myers
>Organization:
Trinity College, University of Cambridge, UK
>Release:        NetBSD anoncvs of 1999-07-26
>Environment:
[
System: Linux decomino 2.2.10 #1 Mon Jun 14 07:48:53 UTC 1999 i686 unknown
Architecture: i686
]
>Description:

This patch makes bcd(6) use `const' where appropriate, and use
unsigned char rather than char for values that end up passed to
isascii() and also used as array indices.

>How-To-Repeat:

>Fix:

diff -ruN bcd/bcd.c bcd+/bcd.c
--- bcd/bcd.c	Wed Jul 21 03:59:41 1999
+++ bcd+/bcd.c	Tue Jul 27 16:13:57 1999
@@ -87,7 +87,7 @@
 #include <ctype.h>
 #include <unistd.h>
 
-u_short holes[256] = {
+const u_short holes[256] = {
     0x0,	 0x0,	  0x0,	   0x0,	    0x0,     0x0,     0x0,     0x0,
     0x0,	 0x0,	  0x0,	   0x0,	    0x0,     0x0,     0x0,     0x0,
     0x0,	 0x0,	  0x0,	   0x0,	    0x0,     0x0,     0x0,     0x0,
@@ -160,9 +160,9 @@
 printcard(str)
 	char *str;
 {
-	static char rowchars[] = "   123456789";
+	static const char rowchars[] = "   123456789";
 	int i, row;
-	char *p;
+	unsigned char *p;
 
 	/* ruthlessly remove newlines and truncate at 48 characters. */
 	if ((p = strchr(str, '\n')))
>Audit-Trail:
>Unformatted: