| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: keyword.c,v 1.59 2021/09/14 22:01:17 christos Exp $ */ | | 1 | /* $NetBSD: keyword.c,v 1.60 2021/09/15 13:16:57 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1990, 1993, 1994 | | 4 | * Copyright (c) 1990, 1993, 1994 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. 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 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | #ifndef lint | | 33 | #ifndef lint |
34 | #if 0 | | 34 | #if 0 |
35 | static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94"; | | 35 | static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94"; |
36 | #else | | 36 | #else |
37 | __RCSID("$NetBSD: keyword.c,v 1.59 2021/09/14 22:01:17 christos Exp $"); | | 37 | __RCSID("$NetBSD: keyword.c,v 1.60 2021/09/15 13:16:57 christos Exp $"); |
38 | #endif | | 38 | #endif |
39 | #endif /* not lint */ | | 39 | #endif /* not lint */ |
40 | | | 40 | |
41 | #include <sys/param.h> | | 41 | #include <sys/param.h> |
42 | #include <sys/time.h> | | 42 | #include <sys/time.h> |
43 | #include <sys/lwp.h> | | 43 | #include <sys/lwp.h> |
44 | #include <sys/proc.h> | | 44 | #include <sys/proc.h> |
45 | #include <sys/resource.h> | | 45 | #include <sys/resource.h> |
46 | #include <sys/sysctl.h> | | 46 | #include <sys/sysctl.h> |
47 | #include <sys/ucred.h> | | 47 | #include <sys/ucred.h> |
48 | | | 48 | |
49 | #include <err.h> | | 49 | #include <err.h> |
50 | #include <errno.h> | | 50 | #include <errno.h> |
| @@ -373,45 +373,44 @@ findvar(const char *p) | | | @@ -373,45 +373,44 @@ findvar(const char *p) |
373 | if (v && v->flag & ALIAS) | | 373 | if (v && v->flag & ALIAS) |
374 | v = findvar(v->header); | | 374 | v = findvar(v->header); |
375 | if (!v) { | | 375 | if (!v) { |
376 | warnx("%s: keyword not found", p); | | 376 | warnx("%s: keyword not found", p); |
377 | eval = 1; | | 377 | eval = 1; |
378 | return NULL; | | 378 | return NULL; |
379 | } | | 379 | } |
380 | | | 380 | |
381 | if (!hp && *p == *pp) | | 381 | if (!hp && *p == *pp) |
382 | return v; | | 382 | return v; |
383 | | | 383 | |
384 | struct var *newvar = emalloc(sizeof(*newvar)); | | 384 | struct var *newvar = emalloc(sizeof(*newvar)); |
385 | *newvar = *v; | | 385 | *newvar = *v; |
386 | v = newvar; | | | |
387 | | | 386 | |
388 | if (hp) { | | 387 | if (hp) { |
389 | /* | | 388 | /* |
390 | * Override the header. | | 389 | * Override the header. |
391 | * | | 390 | * |
392 | * We need to copy the entry first, and override the | | 391 | * We need to copy the entry first, and override the |
393 | * header in the copy, because the same field might be | | 392 | * header in the copy, because the same field might be |
394 | * used multiple times with different headers. We also | | 393 | * used multiple times with different headers. We also |
395 | * need to strdup the header. | | 394 | * need to strdup the header. |
396 | */ | | 395 | */ |
397 | newvar->header = estrdup(hp); | | 396 | newvar->header = estrdup(hp); |
398 | /* | | 397 | /* |
399 | * According to P1003.1-2004, if the header text is null, | | 398 | * According to P1003.1-2004, if the header text is null, |
400 | * such as -o user=, the field width will be at least as | | 399 | * such as -o user=, the field width will be at least as |
401 | * wide as the default header text. | | 400 | * wide as the default header text. |
402 | */ | | 401 | */ |
403 | if (*hp == '\0') | | 402 | if (*hp == '\0') |
404 | newvar->width = strlen(v->header); | | 403 | newvar->width = strlen(v->header); |
405 | } | | 404 | } |
406 | | | 405 | |
407 | if (*p != *pp) | | 406 | if (*p != *pp) |
408 | newvar->flag |= ALTPR|LJUST; | | 407 | newvar->flag |= ALTPR|LJUST; |
409 | | | 408 | |
410 | return v; | | 409 | return newvar; |
411 | } | | 410 | } |
412 | | | 411 | |
413 | static int | | 412 | static int |
414 | vcmp(const void *a, const void *b) | | 413 | vcmp(const void *a, const void *b) |
415 | { | | 414 | { |
416 | return strcmp(a, ((const VAR *)b)->name); | | 415 | return strcmp(a, ((const VAR *)b)->name); |
417 | } | | 416 | } |