Lines Matching +full:1 +full:p
14 * 1. Redistributions of source code must retain the above copyright
57 #define LHMASK (LHSZ - 1)
94 {'a', 1, TEXT},
103 {'i', 1, TEXT},
107 {'p', 2, EMPTY},
108 {'P', 2, EMPTY},
109 {'q', 1, EMPTY},
110 {'r', 1, RFILE},
119 {'=', 1, EMPTY},
140 err(1, "malloc"); in compile()
141 if ((match = malloc((maxnsub + 1) * sizeof(regmatch_t))) == NULL) in compile()
142 err(1, "malloc"); in compile()
146 if (p) \
147 while (*p && isspace((unsigned char)*p)) \
148 p++; \
154 char *p; in compile_stream() local
155 static char lbuf[_POSIX2_LINE_MAX + 1]; /* To save stack */ in compile_stream()
158 char re[_POSIX2_LINE_MAX + 1]; in compile_stream()
163 if ((p = cu_fgets(lbuf, sizeof(lbuf), NULL)) == NULL) { in compile_stream()
165 errx(1, "%lu: %s: unexpected EOF (pending }'s)", in compile_stream()
171 if (p) { in compile_stream()
172 if (*p == '#' || *p == '\0') in compile_stream()
174 else if (*p == ';') { in compile_stream()
175 p++; in compile_stream()
180 err(1, "malloc"); in compile_stream()
188 if (addrchar(*p)) { in compile_stream()
191 err(1, "malloc"); in compile_stream()
192 p = compile_addr(p, cmd->a1); in compile_stream()
194 if (*p == ',') { in compile_stream()
195 p++; in compile_stream()
200 err(1, "malloc"); in compile_stream()
201 p = compile_addr(p, cmd->a2); in compile_stream()
209 if (!*p) in compile_stream()
210 errx(1, "%lu: %s: command expected", linenum, fname); in compile_stream()
211 cmd->code = *p; in compile_stream()
213 if (fp->code == *p) in compile_stream()
216 errx(1, "%lu: %s: invalid command code %c", linenum, fname, *p); in compile_stream()
218 errx(1, in compile_stream()
220 linenum, fname, *p, fp->naddr, naddr); in compile_stream()
223 p++; in compile_stream()
225 cmd->nonsel = 1; in compile_stream()
228 p++; in compile_stream()
233 if (*p) in compile_stream()
241 cmd->nonsel = 1; in compile_stream()
243 errx(1, "%lu: %s: unexpected }", linenum, fname); in compile_stream()
248 case EMPTY: /* d D g G h H l n N p P q x = \0 */ in compile_stream()
249 p++; in compile_stream()
251 if (*p == ';') { in compile_stream()
252 p++; in compile_stream()
256 if (*p) in compile_stream()
257 errx(1, "%lu: %s: extra characters at the end of %c command", in compile_stream()
261 p++; in compile_stream()
263 if (*p != '\\') in compile_stream()
264 errx(1, in compile_stream()
266 p++; in compile_stream()
268 if (*p) in compile_stream()
269 errx(1, in compile_stream()
277 p++; in compile_stream()
279 if (*p == '\0') in compile_stream()
280 errx(1, "%lu: %s: filename expected", linenum, fname); in compile_stream()
281 cmd->t = duptoeol(p, "w command"); in compile_stream()
283 cmd->u.fd = -1; in compile_stream()
284 else if ((cmd->u.fd = open(p, in compile_stream()
286 DEFFILEMODE)) == -1) in compile_stream()
287 err(1, "%s", p); in compile_stream()
290 p++; in compile_stream()
292 if (*p == '\0') in compile_stream()
293 errx(1, "%lu: %s: filename expected", linenum, fname); in compile_stream()
295 cmd->t = duptoeol(p, "read command"); in compile_stream()
298 p++; in compile_stream()
300 if (*p == '\0') in compile_stream()
303 cmd->t = duptoeol(p, "branch"); in compile_stream()
306 p++; in compile_stream()
308 cmd->t = duptoeol(p, "label"); in compile_stream()
309 if (strlen(p) == 0) in compile_stream()
310 errx(1, "%lu: %s: empty label", linenum, fname); in compile_stream()
314 p++; in compile_stream()
315 if (*p == '\0' || *p == '\\') in compile_stream()
316 errx(1, in compile_stream()
319 if ((cmd->u.s = calloc(1, sizeof(struct s_subst))) == NULL) in compile_stream()
320 err(1, "malloc"); in compile_stream()
321 p = compile_delimited(p, re, 0); in compile_stream()
322 if (p == NULL) in compile_stream()
323 errx(1, in compile_stream()
331 --p; in compile_stream()
332 p = compile_subst(p, cmd->u.s); in compile_stream()
333 p = compile_flags(p, cmd->u.s); in compile_stream()
341 if (*p == ';') { in compile_stream()
342 p++; in compile_stream()
348 p++; in compile_stream()
349 p = compile_tr(p, &cmd->u.y); in compile_stream()
351 if (*p == ';') { in compile_stream()
352 p++; in compile_stream()
356 if (*p) in compile_stream()
357 errx(1, in compile_stream()
371 hexbuf[1] = len > 1 ? in[1] : '\0'; in hex2char()
398 tmplen = 1; in dohex()
399 if (hexdigit(in[1])) in dohex()
410 * Get a delimited string. P points to the delimiter of the string; d points
419 compile_delimited(char *p, char *d, int is_tr) in compile_delimited() argument
424 c = *p++; in compile_delimited()
428 errx(1, "%lu: %s: \\ can not be used as a string delimiter", in compile_delimited()
431 errx(1, "%lu: %s: newline can not be used as a string delimiter", in compile_delimited()
433 while (*p) { in compile_delimited()
434 if (*p == '[' && *p != c) { in compile_delimited()
436 if ((d = compile_ccl(&p, d)) == NULL) { in compile_delimited()
437 errx(1, in compile_delimited()
443 } else if (*p == '\\' && p[1] == '[') { in compile_delimited()
445 p++; in compile_delimited()
447 *d++ = *p++; in compile_delimited()
448 } else if (*p == '\\' && p[1] == c) { in compile_delimited()
449 p++; in compile_delimited()
450 } else if (*p == '\\' && in compile_delimited()
451 (p[1] == 'n' || p[1] == 'r' || p[1] == 't')) { in compile_delimited()
452 switch (p[1]) { in compile_delimited()
463 p += 2; in compile_delimited()
465 } else if (*p == '\\' && p[1] == 'x') { in compile_delimited()
466 if (dohex(&p[2], d, &hexlen)) { in compile_delimited()
468 p += hexlen + 2; in compile_delimited()
471 } else if (*p == '\\' && p[1] == '\\') { in compile_delimited()
473 p++; in compile_delimited()
475 *d++ = *p++; in compile_delimited()
476 } else if (*p == c) { in compile_delimited()
478 return (p + 1); in compile_delimited()
480 *d++ = *p++; in compile_delimited()
499 if (*s == '[' && ((d = *(s+1)) == '.' || d == ':' || d == '=')) { in compile_ccl()
505 switch (s[1]) { in compile_ccl()
520 s += hexlen + 1; in compile_ccl()
544 err(1, "malloc"); in compile_re()
546 errx(1, "%lu: %s: RE error: %s", in compile_re()
559 compile_subst(char *p, struct s_subst *s) in compile_subst() argument
561 static char lbuf[_POSIX2_LINE_MAX + 1]; in compile_subst()
565 int more = 1, sawesc = 0; in compile_subst()
567 c = *p++; /* Terminator character */ in compile_subst()
573 asize = 2 * _POSIX2_LINE_MAX + 1; in compile_subst()
575 err(1, "malloc"); in compile_subst()
579 for (; *p; p++) { in compile_subst()
580 if (*p == '\\' || sawesc) { in compile_subst()
589 p++; in compile_subst()
591 if (*p == '\0') { in compile_subst()
599 sawesc = 1; in compile_subst()
600 p--; in compile_subst()
602 } else if (strchr("123456789", *p) != NULL) { in compile_subst()
604 ref = *p - '0'; in compile_subst()
607 errx(1, "%lu: %s: \\%c not defined in the RE", in compile_subst()
608 linenum, fname, *p); in compile_subst()
612 switch (*p) { in compile_subst()
618 *p = '\n'; in compile_subst()
621 *p = '\r'; in compile_subst()
624 *p = '\t'; in compile_subst()
630 while (*(adv + (n) - 1) != '\0') { \ in compile_subst()
636 if (dohex(&p[1], p, &hexlen)) { in compile_subst()
637 ADVANCE_N(p + 1, in compile_subst()
643 } else if (*p == c) { in compile_subst()
644 if (*++p == '\0' && more) { in compile_subst()
646 p = lbuf; in compile_subst()
651 err(1, "realloc"); in compile_subst()
652 return (p); in compile_subst()
653 } else if (*p == '\n') { in compile_subst()
654 errx(1, in compile_subst()
658 *sp++ = *p; in compile_subst()
661 if (asize - size < _POSIX2_LINE_MAX + 1) { in compile_subst()
664 err(1, "realloc"); in compile_subst()
666 } while (cu_fgets(p = lbuf, sizeof(lbuf), &more) != NULL); in compile_subst()
667 errx(1, "%lu: %s: unterminated substitute in regular expression", in compile_subst()
676 compile_flags(char *p, struct s_subst *s) in compile_flags() argument
680 char wfile[_POSIX2_LINE_MAX + 1], *q, *eq; in compile_flags()
682 s->n = 1; /* Default */ in compile_flags()
683 s->p = 0; in compile_flags()
685 s->wfd = -1; in compile_flags()
689 switch (*p) { in compile_flags()
692 errx(1, in compile_flags()
694 gn = 1; in compile_flags()
700 return (p); in compile_flags()
701 case 'p': in compile_flags()
702 s->p = 1; in compile_flags()
706 s->icase = 1; in compile_flags()
708 case '1': case '2': case '3': in compile_flags()
712 errx(1, in compile_flags()
714 gn = 1; in compile_flags()
716 nval = strtol(p, &p, 10); in compile_flags()
718 errx(1, in compile_flags()
721 p--; in compile_flags()
724 p++; in compile_flags()
726 if (*p != ' ') { in compile_flags()
728 return (p); in compile_flags()
733 eq = wfile + sizeof(wfile) - 1; in compile_flags()
734 while (*p) { in compile_flags()
735 if (*p == '\n') in compile_flags()
738 err(1, "wfile too long"); in compile_flags()
739 *q++ = *p++; in compile_flags()
743 errx(1, "%lu: %s: no wfile specified", linenum, fname); in compile_flags()
747 DEFFILEMODE)) == -1) in compile_flags()
748 err(1, "%s", wfile); in compile_flags()
749 return (p); in compile_flags()
751 errx(1, "%lu: %s: bad flag in substitute command: '%c'", in compile_flags()
752 linenum, fname, *p); in compile_flags()
755 p++; in compile_flags()
763 compile_tr(char *p, struct s_tr **py) in compile_tr() argument
768 char old[_POSIX2_LINE_MAX + 1]; in compile_tr()
769 char new[_POSIX2_LINE_MAX + 1]; in compile_tr()
774 err(1, NULL); in compile_tr()
778 if (*p == '\0' || *p == '\\') in compile_tr()
779 errx(1, in compile_tr()
782 p = compile_delimited(p, old, 1); in compile_tr()
783 if (p == NULL) in compile_tr()
784 errx(1, "%lu: %s: unterminated transform source string", in compile_tr()
786 p = compile_delimited(p - 1, new, 1); in compile_tr()
787 if (p == NULL) in compile_tr()
788 errx(1, "%lu: %s: unterminated transform target string", in compile_tr()
793 if (oldlen == (size_t)-1) in compile_tr()
794 err(1, NULL); in compile_tr()
797 if (newlen == (size_t)-1) in compile_tr()
798 err(1, NULL); in compile_tr()
800 errx(1, "%lu: %s: transform strings are not the same length", in compile_tr()
802 if (MB_CUR_MAX == 1) { in compile_tr()
825 if (oclen == (size_t)-1 || oclen == (size_t)-2) in compile_tr()
826 errc(1, EILSEQ, NULL); in compile_tr()
828 if (nclen == (size_t)-1 || nclen == (size_t)-2) in compile_tr()
829 errc(1, EILSEQ, NULL); in compile_tr()
830 if (oclen == 1 && nclen == 1) in compile_tr()
835 (y->nmultis + 1) * sizeof(*y->multis)); in compile_tr()
837 err(1, NULL); in compile_tr()
848 return (p); in compile_tr()
858 char *text, *p, *op, *s; in compile_text() local
859 char lbuf[_POSIX2_LINE_MAX + 1]; in compile_text()
861 asize = 2 * _POSIX2_LINE_MAX + 1; in compile_text()
863 err(1, "malloc"); in compile_text()
867 p = lbuf; in compile_text()
871 for (esc_nl = 0; *p != '\0'; p++) { in compile_text()
872 if (*p == '\\' && p[1] != '\0' && *++p == '\n') in compile_text()
873 esc_nl = 1; in compile_text()
874 *s++ = *p; in compile_text()
881 if (asize - size < _POSIX2_LINE_MAX + 1) { in compile_text()
884 err(1, "realloc"); in compile_text()
888 if ((p = realloc(text, size + 1)) == NULL) in compile_text()
889 err(1, "realloc"); in compile_text()
890 return (p); in compile_text()
898 compile_addr(char *p, struct s_addr *a) in compile_addr() argument
900 char *end, re[_POSIX2_LINE_MAX + 1]; in compile_addr()
906 switch (*p) { in compile_addr()
908 ++p; in compile_addr()
911 p = compile_delimited(p, re, 0); in compile_addr()
912 if (p == NULL) in compile_addr()
913 errx(1, "%lu: %s: unterminated regular expression", linenum, fname); in compile_addr()
915 if (*p == 'I') { in compile_addr()
916 icase = 1; in compile_addr()
917 p++; in compile_addr()
924 return (p); in compile_addr()
928 return (p + 1); in compile_addr()
932 p++; in compile_addr()
935 case '0': case '1': case '2': case '3': case '4': in compile_addr()
939 a->u.l = strtol(p, &end, 10); in compile_addr()
942 errx(1, "%lu: %s: expected context address", linenum, fname); in compile_addr()
956 char *p, *start; in duptoeol() local
964 len = s - start + 1; in duptoeol()
965 if ((p = malloc(len)) == NULL) in duptoeol()
966 err(1, "malloc"); in duptoeol()
967 return (memmove(p, start, len)); in duptoeol()
995 errx(1, "%lu: %s: undefined label '%s'", linenum, fname, cp->t); in fixuplabel()
1012 u_char *p; in enterlabel() local
1015 for (h = 0, p = (u_char *)cp->t; (c = *p) != 0; p++) in enterlabel()
1020 errx(1, "%lu: %s: duplicate label '%s'", linenum, fname, cp->t); in enterlabel()
1022 err(1, "malloc"); in enterlabel()
1038 u_char *p; in findlabel() local
1041 for (h = 0, p = (u_char *)name; (c = *p) != 0; p++) in findlabel()
1045 lh->lh_ref = 1; in findlabel()