| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: globalcmds.c,v 1.14 2009/04/13 23:20:27 lukem Exp $ */ | | 1 | /* $NetBSD: globalcmds.c,v 1.15 2009/11/01 22:08:14 dsl Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1999 | | 4 | * Copyright (c) 1999 |
5 | * The NetBSD Foundation, Inc. All rights reserved. | | 5 | * The NetBSD Foundation, Inc. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -24,27 +24,27 @@ | | | @@ -24,27 +24,27 @@ |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | */ | | 33 | */ |
34 | | | 34 | |
35 | #include <sys/cdefs.h> | | 35 | #include <sys/cdefs.h> |
36 | #ifndef lint | | 36 | #ifndef lint |
37 | __RCSID("$NetBSD: globalcmds.c,v 1.14 2009/04/13 23:20:27 lukem Exp $"); | | 37 | __RCSID("$NetBSD: globalcmds.c,v 1.15 2009/11/01 22:08:14 dsl Exp $"); |
38 | #endif /* not lint */ | | 38 | #endif /* not lint */ |
39 | | | 39 | |
40 | #include <curses.h> | | 40 | #include <curses.h> |
41 | #include <stdlib.h> | | 41 | #include <stdlib.h> |
42 | #include <string.h> | | 42 | #include <string.h> |
43 | #include <unistd.h> | | 43 | #include <unistd.h> |
44 | | | 44 | |
45 | #include "systat.h" | | 45 | #include "systat.h" |
46 | #include "extern.h" | | 46 | #include "extern.h" |
47 | | | 47 | |
48 | static char *shortname(const char *, const char *); | | 48 | static char *shortname(const char *, const char *); |
49 | | | 49 | |
50 | static char * | | 50 | static char * |
| @@ -84,27 +84,28 @@ global_help(char *args) | | | @@ -84,27 +84,28 @@ global_help(char *args) |
84 | move(CMDLINE, col = 0); | | 84 | move(CMDLINE, col = 0); |
85 | name = prev = NULL; | | 85 | name = prev = NULL; |
86 | for (p = modes; p->c_name; p++) { | | 86 | for (p = modes; p->c_name; p++) { |
87 | if ((name = shortname(args, p->c_name)) == NULL) | | 87 | if ((name = shortname(args, p->c_name)) == NULL) |
88 | continue; | | 88 | continue; |
89 | if (name && prev && strcmp(name, prev) == 0) { | | 89 | if (name && prev && strcmp(name, prev) == 0) { |
90 | free(name); | | 90 | free(name); |
91 | name = NULL; | | 91 | name = NULL; |
92 | continue; | | 92 | continue; |
93 | } | | 93 | } |
94 | len = strlen(name); | | 94 | len = strlen(name); |
95 | if (col + len > COLS) | | 95 | if (col + len > COLS) |
96 | break; | | 96 | break; |
97 | addstr(name); col += len; | | 97 | addstr(name); |
| | | 98 | col += len + 1; |
98 | if (col + 1 < COLS) | | 99 | if (col + 1 < COLS) |
99 | addch(' '); | | 100 | addch(' '); |
100 | if (prev) | | 101 | if (prev) |
101 | free(prev); | | 102 | free(prev); |
102 | prev = name; | | 103 | prev = name; |
103 | name = NULL; | | 104 | name = NULL; |
104 | } | | 105 | } |
105 | if (col == 0 && args) { | | 106 | if (col == 0 && args) { |
106 | standout(); | | 107 | standout(); |
107 | if ((int)strlen(args) < COLS - 25) | | 108 | if ((int)strlen(args) < COLS - 25) |
108 | printw("help: no matches for `%s.*'", args); | | 109 | printw("help: no matches for `%s.*'", args); |
109 | else | | 110 | else |
110 | printw("help: no matches"); | | 111 | printw("help: no matches"); |