diff options
Diffstat (limited to 'sed.c')
-rw-r--r-- | sed.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -169,7 +169,7 @@ static int get_address(struct sed_cmd *sed_cmd, const char *str, int *line, rege | |||
169 | else if (my_str[idx] == '/') { | 169 | else if (my_str[idx] == '/') { |
170 | idx = index_of_next_unescaped_regexp_delim(sed_cmd, my_str, ++idx); | 170 | idx = index_of_next_unescaped_regexp_delim(sed_cmd, my_str, ++idx); |
171 | if (idx == -1) | 171 | if (idx == -1) |
172 | error_msg_and_die("unterminated match expression\n"); | 172 | error_msg_and_die("unterminated match expression"); |
173 | my_str[idx] = '\0'; | 173 | my_str[idx] = '\0'; |
174 | *regex = (regex_t *)xmalloc(sizeof(regex_t)); | 174 | *regex = (regex_t *)xmalloc(sizeof(regex_t)); |
175 | xregcomp(*regex, my_str+1, 0); | 175 | xregcomp(*regex, my_str+1, 0); |
@@ -177,7 +177,7 @@ static int get_address(struct sed_cmd *sed_cmd, const char *str, int *line, rege | |||
177 | } | 177 | } |
178 | else { | 178 | else { |
179 | error_msg("get_address: no address found in string\n" | 179 | error_msg("get_address: no address found in string\n" |
180 | "\t(you probably didn't check the string you passed me)\n"); | 180 | "\t(you probably didn't check the string you passed me)"); |
181 | idx = -1; | 181 | idx = -1; |
182 | } | 182 | } |
183 | 183 | ||
@@ -213,7 +213,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr) | |||
213 | /* verify that the 's' is followed by something. That something | 213 | /* verify that the 's' is followed by something. That something |
214 | * (typically a 'slash') is now our regexp delimiter... */ | 214 | * (typically a 'slash') is now our regexp delimiter... */ |
215 | if (!substr[++idx]) | 215 | if (!substr[++idx]) |
216 | error_msg_and_die("bad format in substitution expression\n"); | 216 | error_msg_and_die("bad format in substitution expression"); |
217 | else | 217 | else |
218 | sed_cmd->delimiter=substr[idx]; | 218 | sed_cmd->delimiter=substr[idx]; |
219 | 219 | ||
@@ -221,7 +221,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr) | |||
221 | oldidx = idx+1; | 221 | oldidx = idx+1; |
222 | idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx); | 222 | idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx); |
223 | if (idx == -1) | 223 | if (idx == -1) |
224 | error_msg_and_die("bad format in substitution expression\n"); | 224 | error_msg_and_die("bad format in substitution expression"); |
225 | match = strdup_substr(substr, oldidx, idx); | 225 | match = strdup_substr(substr, oldidx, idx); |
226 | 226 | ||
227 | /* determine the number of back references in the match string */ | 227 | /* determine the number of back references in the match string */ |
@@ -240,7 +240,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr) | |||
240 | oldidx = idx+1; | 240 | oldidx = idx+1; |
241 | idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx); | 241 | idx = index_of_next_unescaped_regexp_delim(sed_cmd, substr, ++idx); |
242 | if (idx == -1) | 242 | if (idx == -1) |
243 | error_msg_and_die("bad format in substitution expression\n"); | 243 | error_msg_and_die("bad format in substitution expression"); |
244 | sed_cmd->replace = strdup_substr(substr, oldidx, idx); | 244 | sed_cmd->replace = strdup_substr(substr, oldidx, idx); |
245 | 245 | ||
246 | /* process the flags */ | 246 | /* process the flags */ |
@@ -260,7 +260,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr) | |||
260 | if (strchr("; \t\v\n\r", substr[idx])) | 260 | if (strchr("; \t\v\n\r", substr[idx])) |
261 | goto out; | 261 | goto out; |
262 | /* else */ | 262 | /* else */ |
263 | error_msg_and_die("bad option in substitution expression\n"); | 263 | error_msg_and_die("bad option in substitution expression"); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
@@ -302,7 +302,7 @@ static int parse_edit_cmd(struct sed_cmd *sed_cmd, const char *editstr) | |||
302 | */ | 302 | */ |
303 | 303 | ||
304 | if (editstr[1] != '\\' && (editstr[2] != '\n' || editstr[2] != '\r')) | 304 | if (editstr[1] != '\\' && (editstr[2] != '\n' || editstr[2] != '\r')) |
305 | error_msg_and_die("bad format in edit expression\n"); | 305 | error_msg_and_die("bad format in edit expression"); |
306 | 306 | ||
307 | /* store the edit line text */ | 307 | /* store the edit line text */ |
308 | /* make editline big enough to accomodate the extra '\n' we will tack on | 308 | /* make editline big enough to accomodate the extra '\n' we will tack on |
@@ -366,9 +366,9 @@ static char *parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) | |||
366 | 366 | ||
367 | /* last part (mandatory) will be a command */ | 367 | /* last part (mandatory) will be a command */ |
368 | if (cmdstr[idx] == '\0') | 368 | if (cmdstr[idx] == '\0') |
369 | error_msg_and_die("missing command\n"); | 369 | error_msg_and_die("missing command"); |
370 | if (!strchr("pdsaic", cmdstr[idx])) /* <-- XXX add new commands here */ | 370 | if (!strchr("pdsaic", cmdstr[idx])) /* <-- XXX add new commands here */ |
371 | error_msg_and_die("invalid command\n"); | 371 | error_msg_and_die("invalid command"); |
372 | sed_cmd->cmd = cmdstr[idx]; | 372 | sed_cmd->cmd = cmdstr[idx]; |
373 | 373 | ||
374 | /* special-case handling for (s)ubstitution */ | 374 | /* special-case handling for (s)ubstitution */ |
@@ -378,7 +378,7 @@ static char *parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) | |||
378 | /* special-case handling for (a)ppend, (i)nsert, and (c)hange */ | 378 | /* special-case handling for (a)ppend, (i)nsert, and (c)hange */ |
379 | else if (strchr("aic", cmdstr[idx])) { | 379 | else if (strchr("aic", cmdstr[idx])) { |
380 | if (sed_cmd->end_line || sed_cmd->end_match) | 380 | if (sed_cmd->end_line || sed_cmd->end_match) |
381 | error_msg_and_die("only a beginning address can be specified for edit commands\n"); | 381 | error_msg_and_die("only a beginning address can be specified for edit commands"); |
382 | idx += parse_edit_cmd(sed_cmd, &cmdstr[idx]); | 382 | idx += parse_edit_cmd(sed_cmd, &cmdstr[idx]); |
383 | } | 383 | } |
384 | /* if it was a single-letter command (such as 'p' or 'd') we need to | 384 | /* if it was a single-letter command (such as 'p' or 'd') we need to |