- case 'p': p(inputt, errnum, 0);
- break;
- case 'n': p(inputt, errnum, 1);
- break;
- /* an EOF means 'q' unless we're still in the middle
- * of a global command, in whcih case it was just
- * the end of the command list found
- */
- case EOF: clearerr(inputt);
- if (g_flag > 0)
- return;
- ss = 'q';
- case 'q':
- case 'Q': q(inputt, errnum);
- break;
- case 'r': r(inputt, errnum);
- break;
- case 's': s(inputt, errnum);
- break;
- case 't': t(inputt, errnum);
- break;
- case 'u': u(inputt, errnum);
- break;
- case 'w':
- case 'W': w(inputt, errnum);
- break;
- case 'z': z(inputt, errnum);
- break;
- case '!': bang (inputt, errnum);
- break;
- case '=': equal (inputt, errnum);
- break;
- /* control of address forms from here down */
- /* It's a head-game to understand why ";" and ","
- * look as they do below, but a lot of it has to
- * do with ";" and "," being special address pair
- * forms themselves and the compatibility for
- * address "chains".
- */
- case ';': if ((End_default == 1) && (start_default == 1))
- {
- start = current;
- End = bottom;
- start_default = End_default = 0;
- }
- else
- {
- start = current = End;
- start_default = 0;
- End_default = 1;
- }
- l_tempp = NULL;
- break;
- /* note address ".,x" where x is a cmd is legal;
- * not a bug - for backward compatability */
- case ',': if ((End_default == 1) && (start_default == 1))
- {
- start = top;
- End = bottom;
- start_default = End_default = 0;
- }
- else
- {
- start = End;
- start_default = 0;
- End_default = 1;
- }
- l_tempp = NULL;
- break;
- case '%': if (End_default == 0)
- {
- strcpy(help_msg, "'%' is an address pair");
- *errnum = -1;
- break;
- }
- start = top;
- End = bottom;
- start_default = End_default = 0;
- l_tempp = NULL;
- break;
- case ' ': /* within address_conv=>l_last='+', foobar, but
- historical and now POSIX... */
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '-':
- case '^':
- case '+':
- case '\'':
- case '$':
- case '?':
- case '/':
- case '.': ungetc(ss, inputt);
- if ((start_default == 0) && (End_default == 0))
- {
- strcpy(help_msg, "badly formed address");
- *errnum = -1;
- break;
- }
- ss = l_last;
- l_tempp = address_conv(l_tempp, inputt, errnum);
- if (*errnum < 0)
- break;
- End = l_tempp;
- End_default = 0;
- if (start_default == 0)
- *errnum = address_check(start, End);
- break;
- default: *errnum = -1;
- strcpy(help_msg, "unknown command");
- break;
- } /* end-switch(ss) */
+ case 'p':
+ p(inputt, errnum, 0);
+ break;
+ case 'n':
+ p(inputt, errnum, 1);
+ break;
+ /*
+ * An EOF means 'q' unless we're still in the middle
+ * of a global command, in which case it was just the
+ * end of the command list found.
+ */
+ case EOF:
+ clearerr(inputt);
+ if (g_flag > 0)
+ return;
+ ss = 'q';
+ case 'q':
+ case 'Q':
+ q(inputt, errnum);
+ break;
+ case 'r':
+ r(inputt, errnum);
+ break;
+ case 's':
+ s(inputt, errnum);
+ break;
+ case 't':
+ t(inputt, errnum);
+ break;
+ case 'u':
+ u(inputt, errnum);
+ break;
+ case 'w':
+ case 'W':
+ w(inputt, errnum);
+ break;
+ case 'z':
+ z(inputt, errnum);
+ break;
+ case '!':
+ bang(inputt, errnum);
+ break;
+ case '=':
+ equal(inputt, errnum);
+ break;
+ /*
+ * Control of address forms from here down.
+ *
+ * It's a head-game to understand why ";" and "," look
+ * as they do below, but a lot of it has to do with ";"
+ * and "," being special address pair forms themselves
+ * and the compatibility for address "chains".
+ */
+ case ';':
+ if (End_default == 1 && start_default == 1) {
+ start = current;
+ End = bottom;
+ start_default = End_default = 0;
+ } else {
+ start = current = End;
+ start_default = 0;
+ End_default = 1;
+ }
+ l_tempp = NULL;
+ break;
+ /*
+ * Note address ".,x" where x is a cmd is legal; not a
+ * bug - for backward compatability.
+ */
+ case ',':
+ if (End_default == 1 && start_default == 1) {
+ start = top;
+ End = bottom;
+ start_default = End_default = 0;
+ } else {
+ start = End;
+ start_default = 0;
+ End_default = 1;
+ }
+ l_tempp = NULL;
+ break;
+ case '%':
+ if (End_default == 0) {
+ strcpy(help_msg,
+ "'%' is an address pair");
+ *errnum = -1;
+ break;
+ }
+ start = top;
+ End = bottom;
+ start_default = End_default = 0;
+ l_tempp = NULL;
+ break;
+ /*
+ * Within address_conv => l_last = '+', foobar, but
+ * historical and now POSIX...
+ */
+ case ' ':
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '-':
+ case '^':
+ case '+':
+ case '\'':
+ case '$':
+ case '?':
+ case '/':
+ case '.':
+ ungetc(ss, inputt);
+ if (start_default == 0 && End_default == 0) {
+ strcpy(help_msg,
+ "badly formed address");
+ *errnum = -1;
+ break;
+ }
+ ss = l_last;
+ l_tempp = address_conv(l_tempp, inputt, errnum);
+ if (*errnum < 0)
+ break;
+ End = l_tempp;
+ End_default = 0;
+ if (start_default == 0)
+ *errnum = address_check(start, End);
+ break;
+ default:
+ *errnum = -1;
+ strcpy(help_msg, "unknown command");
+ break;
+ } /* end-switch(ss) */
+
+ /* Things came out okay with the last command. */
+ if (*errnum > 0) {
+ if (GV_flag == 1)
+ return;
+ /* Do the suffixes if there were any. */
+ if (printsfx > 0) {
+ start = End = current;
+ ungetc(ss, inputt);
+ if (printsfx == 1)
+ p(inputt, errnum, 0);
+ else
+ if (printsfx == 2)
+ p(inputt, errnum, 1);
+ else if (printsfx == 4)
+ l(inputt, errnum);
+ /* Unlikely it's needed, but... */
+ if (*errnum < 0)
+ goto errmsg;
+ }
+ break;
+ }
+ /* There was a problem with the last command. */
+ else if (*errnum < 0) {
+errmsg: while (((ss = getc(inputt)) != '\n') &&
+ (ss != EOF));
+ if (help_flag == 1)
+ printf("%?: %s\n", help_msg);
+ else
+ printf("?\n");
+ if (g_flag > 0)
+ return;
+ break;
+ }
+ l_last = ss;
+ ss = getc(inputt);
+ }
+ }
+}