option.c (a5f0fb151d90effe79714de0fa059954725fe57f) | option.c (c9346414d95d69f958210e825deb3b086dac3529) |
---|---|
1/* 2 * Copyright (C) 1984-2000 Mark Nudelman 3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information about less, or for information on how to 8 * contact the author, see the README file. --- 102 unchanged lines hidden (view full) --- 111 /* 112 * An option prefixed by a "+" is ungotten, so 113 * that it is interpreted as less commands 114 * processed at the start of the first input file. 115 * "++" means process the commands at the start of 116 * EVERY input file. 117 */ 118 plusoption = TRUE; | 1/* 2 * Copyright (C) 1984-2000 Mark Nudelman 3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information about less, or for information on how to 8 * contact the author, see the README file. --- 102 unchanged lines hidden (view full) --- 111 /* 112 * An option prefixed by a "+" is ungotten, so 113 * that it is interpreted as less commands 114 * processed at the start of the first input file. 115 * "++" means process the commands at the start of 116 * EVERY input file. 117 */ 118 plusoption = TRUE; |
119 if (*s == '+') 120 every_first_cmd = save(++s); | 119 str = s; 120 s = optstring(s, propt('+'), NULL); 121 if (*str == '+') 122 every_first_cmd = save(++str); |
121 else | 123 else |
122 ungetsc(s); 123 s = optstring(s, propt('+')); | 124 ungetsc(str); |
124 continue; 125 case '0': case '1': case '2': case '3': case '4': 126 case '5': case '6': case '7': case '8': case '9': 127 /* 128 * Special "more" compatibility form "-<number>" 129 * instead of -z<number> to set the scrolling 130 * window size. 131 */ --- 88 unchanged lines hidden (view full) --- 220 return; 221 } 222 /* 223 * Don't do anything here. 224 * All processing of STRING options is done by 225 * the handling function. 226 */ 227 str = s; | 125 continue; 126 case '0': case '1': case '2': case '3': case '4': 127 case '5': case '6': case '7': case '8': case '9': 128 /* 129 * Special "more" compatibility form "-<number>" 130 * instead of -z<number> to set the scrolling 131 * window size. 132 */ --- 88 unchanged lines hidden (view full) --- 221 return; 222 } 223 /* 224 * Don't do anything here. 225 * All processing of STRING options is done by 226 * the handling function. 227 */ 228 str = s; |
228 s = optstring(s, printopt); | 229 s = optstring(s, printopt, o->odesc[1]); |
229 break; 230 case NUMBER: 231 if (*s == '\0') 232 { 233 pendopt = o; 234 return; 235 } 236 *(o->ovar) = getnum(&s, printopt, (int*)NULL); --- 301 unchanged lines hidden (view full) --- 538} 539 540/* 541 * Scan to end of string or to an END_OPTION_STRING character. 542 * In the latter case, replace the char with a null char. 543 * Return a pointer to the remainder of the string, if any. 544 */ 545 static char * | 230 break; 231 case NUMBER: 232 if (*s == '\0') 233 { 234 pendopt = o; 235 return; 236 } 237 *(o->ovar) = getnum(&s, printopt, (int*)NULL); --- 301 unchanged lines hidden (view full) --- 539} 540 541/* 542 * Scan to end of string or to an END_OPTION_STRING character. 543 * In the latter case, replace the char with a null char. 544 * Return a pointer to the remainder of the string, if any. 545 */ 546 static char * |
546optstring(s, printopt) | 547optstring(s, printopt, validchars) |
547 char *s; 548 char *printopt; | 548 char *s; 549 char *printopt; |
550 char *validchars; |
|
549{ 550 register char *p; | 551{ 552 register char *p; |
553 PARG parg; |
|
551 552 if (*s == '\0') 553 { 554 nostring(printopt); 555 quit(QUIT_ERROR); 556 } 557 for (p = s; *p != '\0'; p++) | 554 555 if (*s == '\0') 556 { 557 nostring(printopt); 558 quit(QUIT_ERROR); 559 } 560 for (p = s; *p != '\0'; p++) |
558 if (*p == END_OPTION_STRING) | 561 if (*p == END_OPTION_STRING || 562 (validchars != NULL && strchr(validchars, *p) == NULL)) |
559 { | 563 { |
564 switch (*p) 565 { 566 case END_OPTION_STRING: 567 case ' ': case '\t': case '-': 568 break; 569 default: 570 parg.p_string = p; 571 error("Option string needs delimiter before %s", &parg); 572 break; 573 } |
|
560 *p = '\0'; 561 return (p+1); 562 } 563 return (p); 564} 565 566/* 567 * Translate a string into a number. --- 43 unchanged lines hidden --- | 574 *p = '\0'; 575 return (p+1); 576 } 577 return (p); 578} 579 580/* 581 * Translate a string into a number. --- 43 unchanged lines hidden --- |