Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/vi/common Correct behavior of options octal, print a...



details:   https://anonhg.NetBSD.org/src/rev/89ae104a15d1
branches:  trunk
changeset: 488156:89ae104a15d1
user:      aymeric <aymeric%NetBSD.org@localhost>
date:      Mon Jun 19 20:09:37 2000 +0000

description:
Correct behavior of options octal, print and noprint
This fixes PR #6800

diffstat:

 usr.bin/vi/common/options.c |  53 +++++++++++++++++++++++++++++++++++---------
 usr.bin/vi/common/options.h |   3 +-
 2 files changed, 44 insertions(+), 12 deletions(-)

diffs (140 lines):

diff -r 68744524c3e9 -r 89ae104a15d1 usr.bin/vi/common/options.c
--- a/usr.bin/vi/common/options.c       Mon Jun 19 20:05:17 2000 +0000
+++ b/usr.bin/vi/common/options.c       Mon Jun 19 20:09:37 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: options.c,v 1.3 1999/01/08 06:16:54 abs Exp $  */
+/*     $NetBSD: options.c,v 1.4 2000/06/19 20:09:37 aymeric Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -130,11 +130,11 @@
 /* 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 */
@@ -142,7 +142,7 @@
 /* O_PARAGRAPHS            4BSD */
        {"paragraphs",  f_paragraph,    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) */
@@ -565,6 +565,14 @@
                                                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) ||
@@ -575,11 +583,13 @@
                                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) {
@@ -650,6 +660,14 @@
                            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) ||
@@ -660,9 +678,11 @@
                                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) {
@@ -687,6 +707,15 @@
                            !strcmp(O_STR(sp, offset), sep))
                                break;
 
+                       if (F_ISSET(op, OPT_EARLYSET)) {
+                           /* Set the value. */
+                           if (o_set(sp, offset,
+                                       OS_FREE | OS_STRDUP, sep, 0)) {
+                               rval = 1;
+                               break;
+                           }
+                       }
+
                        /* Report to subsystems. */
                        if (op->func != NULL &&
                            op->func(sp, spo, sep, NULL) ||
@@ -697,9 +726,11 @@
                                break;
                        }
 
-                       /* Set the value. */
-                       if (o_set(sp, offset, OS_FREE | OS_STRDUP, sep, 0))
+                       if (!F_ISSET(op, OPT_EARLYSET)) {
+                           /* Set the value. */
+                           if (o_set(sp, offset, OS_FREE | OS_STRDUP, sep, 0))
                                rval = 1;
+                       }
                        break;
                default:
                        abort();
diff -r 68744524c3e9 -r 89ae104a15d1 usr.bin/vi/common/options.h
--- a/usr.bin/vi/common/options.h       Mon Jun 19 20:05:17 2000 +0000
+++ b/usr.bin/vi/common/options.h       Mon Jun 19 20:09:37 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: options.h,v 1.2 1998/01/09 08:07:00 perry Exp $        */
+/*     $NetBSD: options.h,v 1.3 2000/06/19 20:09:37 aymeric Exp $      */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -88,6 +88,7 @@
 #define        OPT_NOSET       0x010           /* Option may not be unset. */
 #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;
 };
 



Home | Main Index | Thread Index | Old Index