View | Details | Raw Unified | Return to bug 22182
Collapse All | Expand All

(-)nvi/common/options.c (-10 / +40 lines)
Lines 128-138 Link Here
128
/* O_MSGCAT	  4.4BSD */
128
/* O_MSGCAT	  4.4BSD */
129
	{"msgcat",	f_msgcat,	OPT_STR,	0},
129
	{"msgcat",	f_msgcat,	OPT_STR,	0},
130
/* O_NOPRINT	  4.4BSD */
130
/* O_NOPRINT	  4.4BSD */
131
	{"noprint",	f_print,	OPT_STR,	0},
131
	{"noprint",	f_print,	OPT_STR,	OPT_EARLYSET},
132
/* O_NUMBER	    4BSD */
132
/* O_NUMBER	    4BSD */
133
	{"number",	f_reformat,	OPT_0BOOL,	0},
133
	{"number",	f_reformat,	OPT_0BOOL,	0},
134
/* O_OCTAL	  4.4BSD */
134
/* O_OCTAL	  4.4BSD */
135
	{"octal",	f_print,	OPT_0BOOL,	0},
135
	{"octal",	f_print,	OPT_0BOOL,	OPT_EARLYSET},
136
/* O_OPEN	    4BSD */
136
/* O_OPEN	    4BSD */
137
	{"open",	NULL,		OPT_1BOOL,	0},
137
	{"open",	NULL,		OPT_1BOOL,	0},
138
/* O_OPTIMIZE	    4BSD */
138
/* O_OPTIMIZE	    4BSD */
Lines 142-148 Link Here
142
/* O_PATH	  4.4BSD */
142
/* O_PATH	  4.4BSD */
143
	{"path",	NULL,		OPT_STR,	0},
143
	{"path",	NULL,		OPT_STR,	0},
144
/* O_PRINT	  4.4BSD */
144
/* O_PRINT	  4.4BSD */
145
	{"print",	f_print,	OPT_STR,	0},
145
	{"print",	f_print,	OPT_STR,	OPT_EARLYSET},
146
/* O_PROMPT	    4BSD */
146
/* O_PROMPT	    4BSD */
147
	{"prompt",	NULL,		OPT_1BOOL,	0},
147
	{"prompt",	NULL,		OPT_1BOOL,	0},
148
/* O_READONLY	    4BSD (undocumented) */
148
/* O_READONLY	    4BSD (undocumented) */
Lines 568-573 Link Here
568
						break;
568
						break;
569
				}
569
				}
570
570
571
			if (F_ISSET(op, OPT_EARLYSET)) {
572
			    /* Set the value. */
573
			    if (turnoff)
574
				O_CLR(sp, offset);
575
			    else
576
				O_SET(sp, offset);
577
			}
578
571
			/* Report to subsystems. */
579
			/* Report to subsystems. */
572
			if (op->func != NULL &&
580
			if (op->func != NULL &&
573
			    op->func(sp, spo, NULL, &turnoff) ||
581
			    op->func(sp, spo, NULL, &turnoff) ||
Lines 578-588 Link Here
578
				break;
586
				break;
579
			}
587
			}
580
588
581
			/* Set the value. */
589
			if (!F_ISSET(op, OPT_EARLYSET)) {
582
			if (turnoff)
590
			    /* Set the value. */
591
			    if (turnoff)
583
				O_CLR(sp, offset);
592
				O_CLR(sp, offset);
584
			else
593
			    else
585
				O_SET(sp, offset);
594
				O_SET(sp, offset);
595
			}
586
			break;
596
			break;
587
		case OPT_NUM:
597
		case OPT_NUM:
588
			if (turnoff) {
598
			if (turnoff) {
Lines 653-658 Link Here
653
			    O_VAL(sp, offset) == value)
663
			    O_VAL(sp, offset) == value)
654
				break;
664
				break;
655
665
666
			if (F_ISSET(op, OPT_EARLYSET)) {
667
			    /* Set the value. */
668
			    if (o_set(sp, offset, 0, NULL, value)) {
669
				rval = 1;
670
				break;
671
			    }
672
			}
673
656
			/* Report to subsystems. */
674
			/* Report to subsystems. */
657
			if (op->func != NULL &&
675
			if (op->func != NULL &&
658
			    op->func(sp, spo, sep, &value) ||
676
			    op->func(sp, spo, sep, &value) ||
Lines 663-671 Link Here
663
				break;
681
				break;
664
			}
682
			}
665
683
666
			/* Set the value. */
684
			if (!F_ISSET(op, OPT_EARLYSET)) {
667
			if (o_set(sp, offset, 0, NULL, value))
685
			    /* Set the value. */
686
			    if (o_set(sp, offset, 0, NULL, value))
668
				rval = 1;
687
				rval = 1;
688
			}
669
			break;
689
			break;
670
		case OPT_STR:
690
		case OPT_STR:
671
			if (turnoff) {
691
			if (turnoff) {
Lines 690-695 Link Here
690
			    !strcmp(O_STR(sp, offset), sep))
710
			    !strcmp(O_STR(sp, offset), sep))
691
				break;
711
				break;
692
712
713
			if (F_ISSET(op, OPT_EARLYSET)) {
714
			    /* Set the value. */
715
			    if (o_set(sp, offset, OS_STRDUP, sep, 0)) {
716
				rval = 1;
717
				break;
718
			    }
719
			}
720
693
			/* Report to subsystems. */
721
			/* Report to subsystems. */
694
			if (op->func != NULL &&
722
			if (op->func != NULL &&
695
			    op->func(sp, spo, sep, NULL) ||
723
			    op->func(sp, spo, sep, NULL) ||
Lines 700-708 Link Here
700
				break;
728
				break;
701
			}
729
			}
702
730
703
			/* Set the value. */
731
			if (!F_ISSET(op, OPT_EARLYSET)) {
704
			if (o_set(sp, offset, OS_STRDUP, sep, 0))
732
			    /* Set the value. */
733
			    if (o_set(sp, offset, OS_STRDUP, sep, 0))
705
				rval = 1;
734
				rval = 1;
735
			}
706
			break;
736
			break;
707
		default:
737
		default:
708
			abort();
738
			abort();
(-)nvi/common/options.h (+1 lines)
Lines 89-94 Link Here
89
#define	OPT_NOSET	0x010		/* Option may not be set. */
89
#define	OPT_NOSET	0x010		/* Option may not be set. */
90
#define	OPT_NOUNSET	0x020		/* Option may not be unset. */
90
#define	OPT_NOUNSET	0x020		/* Option may not be unset. */
91
#define	OPT_NOZERO	0x040		/* Option may not be set to 0. */
91
#define	OPT_NOZERO	0x040		/* Option may not be set to 0. */
92
#define	OPT_EARLYSET	0x080		/* Func called after value is set */
92
	u_int8_t flags;
93
	u_int8_t flags;
93
};
94
};

Return to bug 22182