Add the q (quit) option
This commit is contained in:
parent
f3bd7c4631
commit
bed4033e96
@ -265,6 +265,7 @@ static int parse_subst_cmd(sed_cmd_t * const sed_cmd, const char *substr)
|
|||||||
case 'g':
|
case 'g':
|
||||||
sed_cmd->sub_g = 1;
|
sed_cmd->sub_g = 1;
|
||||||
break;
|
break;
|
||||||
|
/* Hmm, i dont see the I option mentioned in the standard */
|
||||||
case 'I':
|
case 'I':
|
||||||
cflags |= REG_ICASE;
|
cflags |= REG_ICASE;
|
||||||
break;
|
break;
|
||||||
@ -381,7 +382,7 @@ static char *parse_cmd_str(sed_cmd_t * const sed_cmd, char *cmdstr)
|
|||||||
{
|
{
|
||||||
/* if it was a single-letter command that takes no arguments (such as 'p'
|
/* if it was a single-letter command that takes no arguments (such as 'p'
|
||||||
* or 'd') all we need to do is increment the index past that command */
|
* or 'd') all we need to do is increment the index past that command */
|
||||||
if (strchr("pd=", sed_cmd->cmd)) {
|
if (strchr("pqd=", sed_cmd->cmd)) {
|
||||||
cmdstr++;
|
cmdstr++;
|
||||||
}
|
}
|
||||||
/* handle (s)ubstitution command */
|
/* handle (s)ubstitution command */
|
||||||
@ -400,7 +401,6 @@ static char *parse_cmd_str(sed_cmd_t * const sed_cmd, char *cmdstr)
|
|||||||
error_msg_and_die("Command only uses one address");
|
error_msg_and_die("Command only uses one address");
|
||||||
cmdstr += parse_file_cmd(sed_cmd, cmdstr);
|
cmdstr += parse_file_cmd(sed_cmd, cmdstr);
|
||||||
}
|
}
|
||||||
/* handle grouped commands */
|
|
||||||
else {
|
else {
|
||||||
error_msg_and_die("Unsupported command %c", sed_cmd->cmd);
|
error_msg_and_die("Unsupported command %c", sed_cmd->cmd);
|
||||||
}
|
}
|
||||||
@ -804,6 +804,9 @@ static void process_file(FILE *file)
|
|||||||
altered++;
|
altered++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'q': /* Branch to end of script and quit */
|
||||||
|
free(line);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user