while ((p = *++av) != NULL) { if (*p != '-' || !p[1]) { morefiles++; if (*p == '-') ip->fp = stdin; else if ((ip->fp = fopen(p, "r")) == NULL) err(1, p); ip->pad = P; if (!ip->sepstring) ip->sepstring = (S ? (ip-1)->sepstring : ""); if (!ip->format) ip->format = ((P || F) ? (ip-1)->format : "%s"); if (!ip->eol) ip->eol = (T ? (ip-1)->eol : '\n'); ip++; continue; } switch (*(c = ++p) | 040) { case 's': if (*++p || (p = *++av)) ip->sepstring = p; else error("Need string after -%s", c); S = (*c == 'S' ? 1 : 0);
while (optind < argc) { switch (ch = getopt(argc, argv, "F:f:P:p:S:s:T:t:")) { case 'F': case 'f': F = (ch == 'F');  for (p = optarg; *p != '\0'; p++) if (!isdigit(*p) && *p != '.' && *p != '-') errx(1, "%s: invalid width specified", optarg);  siz = p - optarg + 3; if ((p = realloc(ip->format, siz)) == NULL) err(1, NULL); snprintf(p, siz, "%%%ss", optarg); ip->format = p;
getargs(char *av[]){	struct	openfile *ip = input;	char *p;	char *c;	static char fmtbuf[BUFSIZ];	char *fmtp = fmtbuf;	int P, S, F, T;	P = S = F = T = 0;		/* capitalized options */	while ((p = *++av) != NULL) {		if (*p != '-' || !p[1]) {			morefiles++;			if (*p == '-')				ip->fp = stdin;			else if ((ip->fp = fopen(p, "r")) == NULL)				err(1, p);			ip->pad = P;			if (!ip->sepstring)				ip->sepstring = (S ? (ip-1)->sepstring : "");			if (!ip->format)				ip->format = ((P || F) ? (ip-1)->format : "%s");			if (!ip->eol)				ip->eol = (T ? (ip-1)->eol : '\n');			ip++;			continue;		}		switch (*(c = ++p) | 040) {		case 's':			if (*++p || (p = *++av))				ip->sepstring = p;			else				error("Need string after -%s", c);			S = (*c == 'S' ? 1 : 0);			break;		case 't':			if (*++p || (p = *++av))				ip->eol = *p;			else				error("Need character after -%s", c);			T = (*c == 'T' ? 1 : 0);			nofinalnl = 1;			break;		case 'p':			ip->pad = 1;			P = (*c == 'P' ? 1 : 0);		case 'f':			F = (*c == 'F' ? 1 : 0);			if (*++p || (p = *++av)) {				fmtp += strlen(fmtp) + 1;				if (fmtp >= fmtbuf + BUFSIZ)					error("No more format space", "");				snprintf(fmtp, fmtbuf + BUFSIZ - fmtp,				    "%%%ss", p);				ip->format = fmtp;			}			else				error("Need string after -%s", c);			break;		default:			error("What do you mean by -%s?", c);			break;		}	}	ip->fp = NULL;	if (!ip->sepstring)		ip->sepstring = "";}