Lines Matching refs:command

28     -n	No default output (use the p command to output matched lines)
39 Each COMMAND may be preceded by an address which limits the command to
66 of input early (using the n and N command), but other than that command
72 ! Run this command when the test _didn't_ match.
74 { Start a new command block, continuing until a corresponding "}".
78 } End command block (this command cannot have an address)
83 D Delete one line of input and restart command SCRIPT (same as "d"
150 t [label] Test, jump to :label only if an "s" command found a match in
168 2-address anywhere an address is allowed, "T" command, multiline
201 int arg1, arg2, w; // offset of two arguments per command, plus s//w filename
244 static void *get_regex(void *command, int offset)
251 return TT.lastregex = offset+(char *)command;
264 struct sedcmd *command;
286 // otherwise N as last command would restart script
287 command = TT.restart ? ((struct sedcmd *)TT.restart)-1 : (void *)TT.pattern;
290 while (command) {
291 char *str, c = command->c;
294 if (*command->lmatch || *command->rmatch) {
299 if (command->hit) {
300 if (!(lm = command->lmatch[1])) {
301 if (!command->rmatch[1]) command->hit = 0;
303 void *rm = get_regex(command, command->rmatch[1]);
308 } else if (lm > 0 && lm < TT.count) command->hit = 0;
309 else if (lm < -1 && TT.count == command->hit+(-lm-1)) command->hit = 0;
313 if (!(lm = *command->lmatch)) {
314 void *rm = get_regex(command, *command->rmatch);
317 command->hit = TT.count;
319 command->hit = TT.count;
321 if (!command->lmatch[1] && !command->rmatch[1]) miss = 1;
325 lm = !(command->not^!!command->hit);
328 if (miss || command->lmatch[1] == TT.count) command->hit = 0;
331 // Handle skipping curly bracket command group
336 command = command->next;
337 if (command->c == '{') curly++;
338 if (command->c == '}') curly--;
341 command = command->next;
348 command = command->next;
352 // Process command
356 if (command->arg1) a->str = command->arg1+(char *)command;
364 if (!command->arg1) break;
365 str = command->arg1+(char *)command;
366 for (command = (void *)TT.pattern; command; command = command->next)
367 if (command->c == ':' && !strcmp(command->arg1+(char *)command, str))
369 if (!command) error_exit("no :%s", str);
372 str = command->arg1+(char *)command;
373 if (!command->hit) emit(str, strlen(str), 1);
395 command = (void *)TT.pattern;
417 str = command->arg1+(char *)command;
445 TT.restart = command->next+1;
452 TT.restart = command->next+1;
469 if (!toys.exitval && command->arg1)
470 toys.exitval = atoi(command->arg1+(char *)command);
477 char *rline = line, *new = command->arg2 + (char *)command, *l2 = 0;
479 regex_t *reg = get_regex(command, command->arg1);
497 off = command->sflags>>3;
560 if (!(command->sflags & 2)) break;
575 if (command->sflags & 4) emit(line, len, eol);
578 if (command->w) goto writenow;
590 name = command->w + (char *)command;
597 perror_exit("w '%s'", command->arg1+(char *)command);
610 char *from, *to = (char *)command;
613 from = to+command->arg1;
614 to += command->arg2;
625 command = command->next;
658 struct sedcmd *command;
663 for (command = (void *)TT.pattern; command; command = command->next)
664 command->hit = 0;
746 // Translate pattern strings into command structures. Each command structure
750 struct sedcmd *command = (void *)TT.pattern;
757 // Append this line to previous multiline command? (hit indicates type.)
759 // sed_line() it means the match range attached to this command
761 if (command && command->prev->hit) {
764 command = dlist_pop(&TT.pattern);
765 c = command->c;
766 reg = (char *)command;
767 reg += command->arg1 + strlen(reg + command->arg1);
769 // Resume parsing for 'a' or 's' command. (Only two that can do this.)
772 if (command->hit < 256) goto resume_s;
778 command = 0;
780 if (command) dlist_add_nomalloc(&TT.pattern, (void *)command);
794 command = (void *)toybuf;
804 command->lmatch[i] = -2-strtol(line, &line, 0);
805 } else if (isdigit(*line)) command->lmatch[i] = strtol(line, &line, 0);
807 command->lmatch[i] = -1;
813 if (!*s) command->rmatch[i] = 0;
816 command->rmatch[i] = reg-toybuf;
827 command->not = 1;
833 c = command->c = *(line++);
838 command = xmemdup(toybuf, reg-toybuf);
839 reg = (reg-toybuf) + (char *)command;
841 // Parse arguments by command type
855 command->arg2 = reg - (char *)command;
860 command->arg1 = reg-(char *)command;
861 command->hit = delim;
866 while (*end != command->hit) {
877 reg = extend_string((void *)&command, line, reg-(char *)command,end-line);
880 if (*line == command->hit) command->hit = 0;
889 i = command->arg1;
890 command->arg1 = command->arg2;
891 command->arg2 = i;
899 if (0 <= (l = stridx("igp", *line))) command->sflags |= 1<<l;
900 else if (!(command->sflags>>3) && 0<(l = strtol(line, &line, 10))) {
901 command->sflags |= l << 3;
908 if (!*TT.remember) command->arg1 = 0;
909 else xregcomp((void *)(command->arg1 + (char *)command), TT.remember,
910 (REG_EXTENDED*!!FLAG(r))|((command->sflags&1)*REG_ICASE));
935 command->w = reg - (char *)command;
936 command = xrealloc(command, command->w+(cc-line)+6);
937 reg = command->w + (char *)command;
953 command->arg1 = reg-(char *)command;
955 reg = extend_string((void *)&command, s, reg-(char *)command, len);
957 command->arg2 = reg-(char *)command;
960 reg = extend_string((void *)&command, s, reg-(char*)command, len);
971 command->hit = 0;
977 else if (!command->arg1) break;
991 if (!command->arg1) command->arg1 = reg - (char*)command;
992 else if (*(command->arg1+(char *)command)) *(reg++) = '\n';
994 command->arg1 = 0;
997 reg = extend_string((void *)&command, line, reg - (char *)command, end);
1013 command->hit = 256;