Lines Matching refs:command
191 static void *get_regex(void *command, int offset) in get_regex() argument
198 return TT.lastregex = offset+(char *)command; in get_regex()
211 struct sedcmd *command; in sed_line() local
234 command = TT.restart ? ((struct sedcmd *)TT.restart)-1 : (void *)TT.pattern; in sed_line()
237 while (command) { in sed_line()
238 char *str, c = command->c; in sed_line()
241 if (*command->lmatch || *command->rmatch) { in sed_line()
246 if (command->hit) { in sed_line()
247 if (!(lm = command->lmatch[1])) { in sed_line()
248 if (!command->rmatch[1]) command->hit = 0; in sed_line()
250 void *rm = get_regex(command, command->rmatch[1]); in sed_line()
255 } else if (lm > 0 && lm < TT.count) command->hit = 0; in sed_line()
256 else if (lm < -1 && TT.count == command->hit+(-lm-1)) command->hit = 0; in sed_line()
260 if (!(lm = *command->lmatch)) { in sed_line()
261 void *rm = get_regex(command, *command->rmatch); in sed_line()
264 command->hit = TT.count; in sed_line()
266 command->hit = TT.count; in sed_line()
268 if (!command->lmatch[1] && !command->rmatch[1]) miss = 1; in sed_line()
272 lm = !(command->not^!!command->hit); in sed_line()
275 if (miss || command->lmatch[1] == TT.count) command->hit = 0; in sed_line()
283 command = command->next; in sed_line()
284 if (command->c == '{') curly++; in sed_line()
285 if (command->c == '}') curly--; in sed_line()
288 command = command->next; in sed_line()
295 command = command->next; in sed_line()
303 if (command->arg1) a->str = command->arg1+(char *)command; in sed_line()
311 if (!command->arg1) break; in sed_line()
312 str = command->arg1+(char *)command; in sed_line()
313 for (command = (void *)TT.pattern; command; command = command->next) in sed_line()
314 if (command->c == ':' && !strcmp(command->arg1+(char *)command, str)) in sed_line()
316 if (!command) error_exit("no :%s", str); in sed_line()
319 str = command->arg1+(char *)command; in sed_line()
320 if (!command->hit) emit(str, strlen(str), 1); in sed_line()
342 command = (void *)TT.pattern; in sed_line()
364 str = command->arg1+(char *)command; in sed_line()
392 TT.restart = command->next+1; in sed_line()
399 TT.restart = command->next+1; in sed_line()
416 if (!toys.exitval && command->arg1) in sed_line()
417 toys.exitval = atoi(command->arg1+(char *)command); in sed_line()
424 char *rline = line, *new = command->arg2 + (char *)command, *l2 = 0; in sed_line()
426 regex_t *reg = get_regex(command, command->arg1); in sed_line()
444 off = command->sflags>>4; in sed_line()
507 if (!(command->sflags & 2)) break; in sed_line()
522 if (command->sflags & 4) emit(line, len, eol); in sed_line()
525 if (command->w) goto writenow; in sed_line()
537 name = command->w + (char *)command; in sed_line()
544 perror_exit("w '%s'", command->arg1+(char *)command); in sed_line()
557 char *from, *to = (char *)command; in sed_line()
560 from = to+command->arg1; in sed_line()
561 to += command->arg2; in sed_line()
572 command = command->next; in sed_line()
609 struct sedcmd *command; in do_sed_file() local
612 for (command = (void *)TT.pattern; command; command = command->next) in do_sed_file()
613 command->hit = 0; in do_sed_file()
699 struct sedcmd *command = (void *)TT.pattern; in parse_pattern() local
710 if (command && command->prev->hit) { in parse_pattern()
713 command = dlist_pop(&TT.pattern); in parse_pattern()
714 c = command->c; in parse_pattern()
715 reg = (char *)command; in parse_pattern()
716 reg += command->arg1 + strlen(reg + command->arg1); in parse_pattern()
721 if (command->hit < 256) goto resume_s; in parse_pattern()
727 command = 0; in parse_pattern()
729 if (command) dlist_add_nomalloc(&TT.pattern, (void *)command); in parse_pattern()
743 command = (void *)toybuf; in parse_pattern()
753 command->lmatch[i] = -2-strtol(line, &line, 0); in parse_pattern()
754 } else if (isdigit(*line)) command->lmatch[i] = strtol(line, &line, 0); in parse_pattern()
756 command->lmatch[i] = -1; in parse_pattern()
762 if (!*s) command->rmatch[i] = 0; in parse_pattern()
765 command->rmatch[i] = reg-toybuf; in parse_pattern()
776 command->not = 1; in parse_pattern()
782 c = command->c = *(line++); in parse_pattern()
787 command = xmemdup(toybuf, reg-toybuf); in parse_pattern()
788 reg = (reg-toybuf) + (char *)command; in parse_pattern()
805 command->arg2 = reg - (char *)command; in parse_pattern()
810 command->arg1 = reg-(char *)command; in parse_pattern()
811 command->hit = delim; in parse_pattern()
816 while (*end != command->hit) { in parse_pattern()
827 reg = extend_string((void *)&command, line, reg-(char *)command,end-line); in parse_pattern()
830 if (*line == command->hit) command->hit = 0; in parse_pattern()
839 i = command->arg1; in parse_pattern()
840 command->arg1 = command->arg2; in parse_pattern()
841 command->arg2 = i; in parse_pattern()
849 if (0 <= (l = stridx("igpx", *line))) command->sflags |= 1<<l; in parse_pattern()
850 else if (*line == 'I') command->sflags |= 1<<0; in parse_pattern()
851 else if (!(command->sflags>>4) && 0<(l = strtol(line, &line, 10))) { in parse_pattern()
852 command->sflags |= l << 4; in parse_pattern()
856 flags = (FLAG(r) || (command->sflags&8)) ? REG_EXTENDED : 0; in parse_pattern()
857 if (command->sflags&1) flags |= REG_ICASE; in parse_pattern()
861 if (!*TT.remember) command->arg1 = 0; in parse_pattern()
862 else xregcomp((void *)(command->arg1+(char *)command),TT.remember,flags); in parse_pattern()
887 command->w = reg - (char *)command; in parse_pattern()
888 command = xrealloc(command, command->w+(cc-line)+6); in parse_pattern()
889 reg = command->w + (char *)command; in parse_pattern()
905 command->arg1 = reg-(char *)command; in parse_pattern()
907 reg = extend_string((void *)&command, s, reg-(char *)command, len); in parse_pattern()
909 command->arg2 = reg-(char *)command; in parse_pattern()
912 reg = extend_string((void *)&command, s, reg-(char*)command, len); in parse_pattern()
923 command->hit = 0; in parse_pattern()
929 else if (!command->arg1) break; in parse_pattern()
943 if (!command->arg1) command->arg1 = reg - (char*)command; in parse_pattern()
944 else if (*(command->arg1+(char *)command)) *(reg++) = '\n'; in parse_pattern()
946 command->arg1 = 0; in parse_pattern()
949 reg = extend_string((void *)&command, line, reg - (char *)command, end); in parse_pattern()
965 command->hit = 256; in parse_pattern()