Fri Dec 1 20:01:31 2017 UTC ()
Compare ap->len wide chars, not ap->len bytes.


(rin)
diff -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/ex_usage.c

cvs diff -r1.3 -r1.4 src/external/bsd/nvi/dist/ex/ex_usage.c (expand / switch to unified diff)

--- src/external/bsd/nvi/dist/ex/ex_usage.c 2014/01/26 21:43:45 1.3
+++ src/external/bsd/nvi/dist/ex/ex_usage.c 2017/12/01 20:01:31 1.4
@@ -1,32 +1,32 @@ @@ -1,32 +1,32 @@
1/* $NetBSD: ex_usage.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */ 1/* $NetBSD: ex_usage.c,v 1.4 2017/12/01 20:01:31 rin Exp $ */
2/*- 2/*-
3 * Copyright (c) 1992, 1993, 1994 3 * Copyright (c) 1992, 1993, 1994
4 * The Regents of the University of California. All rights reserved. 4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1992, 1993, 1994, 1995, 1996 5 * Copyright (c) 1992, 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved. 6 * Keith Bostic. All rights reserved.
7 * 7 *
8 * See the LICENSE file for redistribution information. 8 * See the LICENSE file for redistribution information.
9 */ 9 */
10 10
11#include "config.h" 11#include "config.h"
12 12
13#include <sys/cdefs.h> 13#include <sys/cdefs.h>
14#if 0 14#if 0
15#ifndef lint 15#ifndef lint
16static const char sccsid[] = "Id: ex_usage.c,v 10.15 2001/06/25 15:19:21 skimo Exp (Berkeley) Date: 2001/06/25 15:19:21 "; 16static const char sccsid[] = "Id: ex_usage.c,v 10.15 2001/06/25 15:19:21 skimo Exp (Berkeley) Date: 2001/06/25 15:19:21 ";
17#endif /* not lint */ 17#endif /* not lint */
18#else 18#else
19__RCSID("$NetBSD: ex_usage.c,v 1.3 2014/01/26 21:43:45 christos Exp $"); 19__RCSID("$NetBSD: ex_usage.c,v 1.4 2017/12/01 20:01:31 rin Exp $");
20#endif 20#endif
21 21
22#include <sys/types.h> 22#include <sys/types.h>
23#include <sys/queue.h> 23#include <sys/queue.h>
24#include <sys/time.h> 24#include <sys/time.h>
25 25
26#include <bitstring.h> 26#include <bitstring.h>
27#include <ctype.h> 27#include <ctype.h>
28#include <limits.h> 28#include <limits.h>
29#include <stdio.h> 29#include <stdio.h>
30#include <stdlib.h> 30#include <stdlib.h>
31#include <string.h> 31#include <string.h>
32 32
@@ -68,27 +68,27 @@ ex_usage(SCR *sp, EXCMD *cmdp) @@ -68,27 +68,27 @@ ex_usage(SCR *sp, EXCMD *cmdp)
68 int newscreen; 68 int newscreen;
69 CHAR_T *p, nb[MAXCMDNAMELEN + 5]; 69 CHAR_T *p, nb[MAXCMDNAMELEN + 5];
70 const CHAR_T *name; 70 const CHAR_T *name;
71 71
72 switch (cmdp->argc) { 72 switch (cmdp->argc) {
73 case 1: 73 case 1:
74 ap = cmdp->argv[0]; 74 ap = cmdp->argv[0];
75 if (ISUPPER((UCHAR_T)ap->bp[0])) { 75 if (ISUPPER((UCHAR_T)ap->bp[0])) {
76 newscreen = 1; 76 newscreen = 1;
77 ap->bp[0] = TOLOWER((UCHAR_T)ap->bp[0]); 77 ap->bp[0] = TOLOWER((UCHAR_T)ap->bp[0]);
78 } else 78 } else
79 newscreen = 0; 79 newscreen = 0;
80 for (cp = cmds; cp->name != NULL && 80 for (cp = cmds; cp->name != NULL &&
81 memcmp(ap->bp, cp->name, ap->len); ++cp); 81 MEMCMP(ap->bp, cp->name, ap->len); ++cp);
82 if (cp->name == NULL || 82 if (cp->name == NULL ||
83 (newscreen && !F_ISSET(cp, E_NEWSCREEN))) { 83 (newscreen && !F_ISSET(cp, E_NEWSCREEN))) {
84 const char *nstr; 84 const char *nstr;
85 size_t nlen; 85 size_t nlen;
86 86
87 if (newscreen) 87 if (newscreen)
88 ap->bp[0] = TOUPPER((UCHAR_T)ap->bp[0]); 88 ap->bp[0] = TOUPPER((UCHAR_T)ap->bp[0]);
89 89
90 INT2CHAR(sp, ap->bp, ap->len + 1, nstr, nlen); 90 INT2CHAR(sp, ap->bp, ap->len + 1, nstr, nlen);
91 (void)ex_printf(sp, "The %.*s command is unknown\n", 91 (void)ex_printf(sp, "The %.*s command is unknown\n",
92 (int)ap->len, nstr); 92 (int)ap->len, nstr);
93 } else { 93 } else {
94 (void)ex_printf(sp, 94 (void)ex_printf(sp,