Use a single, consistent isblank in vi

2015-03-27 Thread Brian Callahan
Hi tech@ --

Noticed this yesterday reviewing brynet@'s vi diff.
We have the appropriate isblank(3) in ctype.h but the header
wasn't being included in all the files that used it so vi was
falling back to a #define in common/key.h for one set of files and
using isblank(3) from ctype.h in other files.

This diff removes the #define from common/key.h and adds the header
to the .c files that need it.

OK?

~Brian

Index: common/key.h
===
RCS file: /cvs/src/usr.bin/vi/common/key.h,v
retrieving revision 1.4
diff -u -p -r1.4 key.h
--- common/key.h8 Jan 2006 21:05:39 -   1.4
+++ common/key.h28 Mar 2015 04:10:46 -
@@ -136,19 +136,6 @@ extern KEYLIST keylist[];
(KEYS_WAITING(sp) \
F_ISSET((sp)-gp-i_event[(sp)-gp-i_next].e_ch, CH_MAPPED))
 
-/*
- * Ex/vi commands are generally separated by whitespace characters.  We
- * can't use the standard isspace(3) macro because it returns true for
- * characters like ^K in the ASCII character set.  The 4.4BSD isblank(3)
- * macro does exactly what we want, but it's not portable yet.
- *
- * XXX
- * Note side effect, ch is evaluated multiple times.
- */
-#ifndef isblank
-#defineisblank(ch) ((ch) == ' ' || (ch) == '\t')
-#endif
-
 /* The standard tab width, for displaying things to users. */
 #defineSTANDARD_TAB6
 
Index: common/util.c
===
RCS file: /cvs/src/usr.bin/vi/common/util.c,v
retrieving revision 1.10
diff -u -p -r1.10 util.c
--- common/util.c   16 Jan 2015 06:40:14 -  1.10
+++ common/util.c   28 Mar 2015 04:10:46 -
@@ -14,6 +14,7 @@
 #include sys/queue.h
 
 #include bitstring.h
+#include ctype.h
 #include errno.h
 #include limits.h
 #include stdio.h
Index: ex/ex_shell.c
===
RCS file: /cvs/src/usr.bin/vi/ex/ex_shell.c,v
retrieving revision 1.14
diff -u -p -r1.14 ex_shell.c
--- ex/ex_shell.c   16 Jan 2015 06:40:14 -  1.14
+++ ex/ex_shell.c   28 Mar 2015 04:10:46 -
@@ -15,6 +15,7 @@
 #include sys/wait.h
 
 #include bitstring.h
+#include ctype.h
 #include errno.h
 #include limits.h
 #include signal.h
Index: vi/v_match.c
===
RCS file: /cvs/src/usr.bin/vi/vi/v_match.c,v
retrieving revision 1.7
diff -u -p -r1.7 v_match.c
--- vi/v_match.c12 Nov 2014 04:28:41 -  1.7
+++ vi/v_match.c28 Mar 2015 04:10:46 -
@@ -16,6 +16,7 @@
 #include sys/time.h
 
 #include bitstring.h
+#include ctype.h
 #include limits.h
 #include stdio.h
 #include string.h



Re: Use a single, consistent isblank in vi

2015-03-27 Thread Bryan Steele
On Sat, Mar 28, 2015 at 12:22:10AM -0400, Brian Callahan wrote:
 Hi tech@ --
 
 Noticed this yesterday reviewing brynet@'s vi diff.
 We have the appropriate isblank(3) in ctype.h but the header
 wasn't being included in all the files that used it so vi was
 falling back to a #define in common/key.h for one set of files and
 using isblank(3) from ctype.h in other files.
 
 This diff removes the #define from common/key.h and adds the header
 to the .c files that need it.
 
 OK?
 
 ~Brian
 

 -/*
 - * Ex/vi commands are generally separated by whitespace characters.  We
 - * can't use the standard isspace(3) macro because it returns true for
 - * characters like ^K in the ASCII character set.  The 4.4BSD isblank(3)
 - * macro does exactly what we want, but it's not portable yet.

Well, isblank(3) is portable now.. so if anything, the comment is
at least wrong. :-)

ok brynet@