diff options
author | Christian Weisgerber <naddy@cvs.openbsd.org> | 2000-10-22 00:16:28 +0000 |
---|---|---|
committer | Christian Weisgerber <naddy@cvs.openbsd.org> | 2000-10-22 00:16:28 +0000 |
commit | 4c2cf9511dbe39cdd370e8136631689ff7d4c8f0 (patch) | |
tree | ea2e29422a583ebfec6e9b53d37447f33c4801fd | |
parent | a0b79d6bf57475c09eef9a068977e5dfe08b8a3d (diff) |
Fix noprint/print/octal options; from NetBSD.
reviewed by millert@
-rw-r--r-- | usr.bin/vi/common/options.c | 50 | ||||
-rw-r--r-- | usr.bin/vi/common/options.h | 1 |
2 files changed, 41 insertions, 10 deletions
diff --git a/usr.bin/vi/common/options.c b/usr.bin/vi/common/options.c index 973778c78bb..44cc37c7197 100644 --- a/usr.bin/vi/common/options.c +++ b/usr.bin/vi/common/options.c @@ -124,11 +124,11 @@ OPTLIST const optlist[] = { /* O_MSGCAT 4.4BSD */ {"msgcat", f_msgcat, OPT_STR, 0}, /* O_NOPRINT 4.4BSD */ - {"noprint", f_print, OPT_STR, 0}, + {"noprint", f_print, OPT_STR, OPT_EARLYSET}, /* O_NUMBER 4BSD */ {"number", f_reformat, OPT_0BOOL, 0}, /* O_OCTAL 4.4BSD */ - {"octal", f_print, OPT_0BOOL, 0}, + {"octal", f_print, OPT_0BOOL, OPT_EARLYSET}, /* O_OPEN 4BSD */ {"open", NULL, OPT_1BOOL, 0}, /* O_OPTIMIZE 4BSD */ @@ -138,7 +138,7 @@ OPTLIST const optlist[] = { /* O_PATH 4.4BSD */ {"path", NULL, OPT_STR, 0}, /* O_PRINT 4.4BSD */ - {"print", f_print, OPT_STR, 0}, + {"print", f_print, OPT_STR, OPT_EARLYSET}, /* O_PROMPT 4BSD */ {"prompt", NULL, OPT_1BOOL, 0}, /* O_READONLY 4BSD (undocumented) */ @@ -561,6 +561,14 @@ opts_set(sp, argv, usage) break; } + if (F_ISSET(op, OPT_EARLYSET)) { + /* Set the value. */ + if (turnoff) + O_CLR(sp, offset); + else + O_SET(sp, offset); + } + /* Report to subsystems. */ if (op->func != NULL && op->func(sp, spo, NULL, &turnoff) || @@ -571,11 +579,13 @@ opts_set(sp, argv, usage) break; } - /* Set the value. */ - if (turnoff) + if (!F_ISSET(op, OPT_EARLYSET)) { + /* Set the value. */ + if (turnoff) O_CLR(sp, offset); - else + else O_SET(sp, offset); + } break; case OPT_NUM: if (turnoff) { @@ -646,6 +656,14 @@ badnum: p = msg_print(sp, name, &nf); O_VAL(sp, offset) == value) break; + if (F_ISSET(op, OPT_EARLYSET)) { + /* Set the value. */ + if (o_set(sp, offset, 0, NULL, value)) { + rval = 1; + break; + } + } + /* Report to subsystems. */ if (op->func != NULL && op->func(sp, spo, sep, &value) || @@ -656,9 +674,11 @@ badnum: p = msg_print(sp, name, &nf); break; } - /* Set the value. */ - if (o_set(sp, offset, 0, NULL, value)) + if (!F_ISSET(op, OPT_EARLYSET)) { + /* Set the value. */ + if (o_set(sp, offset, 0, NULL, value)) rval = 1; + } break; case OPT_STR: if (turnoff) { @@ -683,6 +703,14 @@ badnum: p = msg_print(sp, name, &nf); !strcmp(O_STR(sp, offset), sep)) break; + if (F_ISSET(op, OPT_EARLYSET)) { + /* Set the value. */ + if (o_set(sp, offset, OS_STRDUP, sep, 0)) { + rval = 1; + break; + } + } + /* Report to subsystems. */ if (op->func != NULL && op->func(sp, spo, sep, NULL) || @@ -693,9 +721,11 @@ badnum: p = msg_print(sp, name, &nf); break; } - /* Set the value. */ - if (o_set(sp, offset, OS_STRDUP, sep, 0)) + if (!F_ISSET(op, OPT_EARLYSET)) { + /* Set the value. */ + if (o_set(sp, offset, OS_STRDUP, sep, 0)) rval = 1; + } break; default: abort(); diff --git a/usr.bin/vi/common/options.h b/usr.bin/vi/common/options.h index 2646dc301b5..ca321655dff 100644 --- a/usr.bin/vi/common/options.h +++ b/usr.bin/vi/common/options.h @@ -89,6 +89,7 @@ struct _optlist { #define OPT_NOSET 0x010 /* Option may not be set. */ #define OPT_NOUNSET 0x020 /* Option may not be unset. */ #define OPT_NOZERO 0x040 /* Option may not be set to 0. */ +#define OPT_EARLYSET 0x080 /* Func called after value is set */ u_int8_t flags; }; |