diff options
Diffstat (limited to 'sed.c')
-rw-r--r-- | sed.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -215,14 +215,14 @@ static int get_address(const char *str, int *line, regex_t **regex) | |||
215 | else if (my_str[idx] == '/') { | 215 | else if (my_str[idx] == '/') { |
216 | idx = index_of_next_unescaped_slash(my_str, ++idx); | 216 | idx = index_of_next_unescaped_slash(my_str, ++idx); |
217 | if (idx == -1) | 217 | if (idx == -1) |
218 | fatalError("unterminated match expression\n"); | 218 | error_msg_and_die("unterminated match expression\n"); |
219 | my_str[idx] = '\0'; | 219 | my_str[idx] = '\0'; |
220 | *regex = (regex_t *)xmalloc(sizeof(regex_t)); | 220 | *regex = (regex_t *)xmalloc(sizeof(regex_t)); |
221 | xregcomp(*regex, my_str+1, 0); | 221 | xregcomp(*regex, my_str+1, 0); |
222 | idx++; /* so it points to the next character after the last '/' */ | 222 | idx++; /* so it points to the next character after the last '/' */ |
223 | } | 223 | } |
224 | else { | 224 | else { |
225 | errorMsg("get_address: no address found in string\n" | 225 | error_msg("get_address: no address found in string\n" |
226 | "\t(you probably didn't check the string you passed me)\n"); | 226 | "\t(you probably didn't check the string you passed me)\n"); |
227 | idx = -1; | 227 | idx = -1; |
228 | } | 228 | } |
@@ -258,13 +258,13 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr) | |||
258 | 258 | ||
259 | /* verify that the 's' is followed by a 'slash' */ | 259 | /* verify that the 's' is followed by a 'slash' */ |
260 | if (substr[++idx] != '/') | 260 | if (substr[++idx] != '/') |
261 | fatalError("bad format in substitution expression\n"); | 261 | error_msg_and_die("bad format in substitution expression\n"); |
262 | 262 | ||
263 | /* save the match string */ | 263 | /* save the match string */ |
264 | oldidx = idx+1; | 264 | oldidx = idx+1; |
265 | idx = index_of_next_unescaped_slash(substr, ++idx); | 265 | idx = index_of_next_unescaped_slash(substr, ++idx); |
266 | if (idx == -1) | 266 | if (idx == -1) |
267 | fatalError("bad format in substitution expression\n"); | 267 | error_msg_and_die("bad format in substitution expression\n"); |
268 | match = strdup_substr(substr, oldidx, idx); | 268 | match = strdup_substr(substr, oldidx, idx); |
269 | 269 | ||
270 | /* determine the number of back references in the match string */ | 270 | /* determine the number of back references in the match string */ |
@@ -283,7 +283,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr) | |||
283 | oldidx = idx+1; | 283 | oldidx = idx+1; |
284 | idx = index_of_next_unescaped_slash(substr, ++idx); | 284 | idx = index_of_next_unescaped_slash(substr, ++idx); |
285 | if (idx == -1) | 285 | if (idx == -1) |
286 | fatalError("bad format in substitution expression\n"); | 286 | error_msg_and_die("bad format in substitution expression\n"); |
287 | sed_cmd->replace = strdup_substr(substr, oldidx, idx); | 287 | sed_cmd->replace = strdup_substr(substr, oldidx, idx); |
288 | 288 | ||
289 | /* process the flags */ | 289 | /* process the flags */ |
@@ -303,7 +303,7 @@ static int parse_subst_cmd(struct sed_cmd *sed_cmd, const char *substr) | |||
303 | if (strchr("; \t\v\n\r", substr[idx])) | 303 | if (strchr("; \t\v\n\r", substr[idx])) |
304 | goto out; | 304 | goto out; |
305 | /* else */ | 305 | /* else */ |
306 | fatalError("bad option in substitution expression\n"); | 306 | error_msg_and_die("bad option in substitution expression\n"); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
@@ -345,7 +345,7 @@ static int parse_edit_cmd(struct sed_cmd *sed_cmd, const char *editstr) | |||
345 | */ | 345 | */ |
346 | 346 | ||
347 | if (editstr[1] != '\\' && (editstr[2] != '\n' || editstr[2] != '\r')) | 347 | if (editstr[1] != '\\' && (editstr[2] != '\n' || editstr[2] != '\r')) |
348 | fatalError("bad format in edit expression\n"); | 348 | error_msg_and_die("bad format in edit expression\n"); |
349 | 349 | ||
350 | /* store the edit line text */ | 350 | /* store the edit line text */ |
351 | /* make editline big enough to accomodate the extra '\n' we will tack on | 351 | /* make editline big enough to accomodate the extra '\n' we will tack on |
@@ -409,9 +409,9 @@ static char *parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) | |||
409 | 409 | ||
410 | /* last part (mandatory) will be a command */ | 410 | /* last part (mandatory) will be a command */ |
411 | if (cmdstr[idx] == '\0') | 411 | if (cmdstr[idx] == '\0') |
412 | fatalError("missing command\n"); | 412 | error_msg_and_die("missing command\n"); |
413 | if (!strchr("pdsaic", cmdstr[idx])) /* <-- XXX add new commands here */ | 413 | if (!strchr("pdsaic", cmdstr[idx])) /* <-- XXX add new commands here */ |
414 | fatalError("invalid command\n"); | 414 | error_msg_and_die("invalid command\n"); |
415 | sed_cmd->cmd = cmdstr[idx]; | 415 | sed_cmd->cmd = cmdstr[idx]; |
416 | 416 | ||
417 | /* special-case handling for (s)ubstitution */ | 417 | /* special-case handling for (s)ubstitution */ |
@@ -421,7 +421,7 @@ static char *parse_cmd_str(struct sed_cmd *sed_cmd, const char *cmdstr) | |||
421 | /* special-case handling for (a)ppend, (i)nsert, and (c)hange */ | 421 | /* special-case handling for (a)ppend, (i)nsert, and (c)hange */ |
422 | else if (strchr("aic", cmdstr[idx])) { | 422 | else if (strchr("aic", cmdstr[idx])) { |
423 | if (sed_cmd->end_line || sed_cmd->end_match) | 423 | if (sed_cmd->end_line || sed_cmd->end_match) |
424 | fatalError("only a beginning address can be specified for edit commands\n"); | 424 | error_msg_and_die("only a beginning address can be specified for edit commands\n"); |
425 | idx += parse_edit_cmd(sed_cmd, &cmdstr[idx]); | 425 | idx += parse_edit_cmd(sed_cmd, &cmdstr[idx]); |
426 | } | 426 | } |
427 | /* if it was a single-letter command (such as 'p' or 'd') we need to | 427 | /* if it was a single-letter command (such as 'p' or 'd') we need to |
@@ -757,7 +757,7 @@ extern int sed_main(int argc, char **argv) | |||
757 | for (i = optind; i < argc; i++) { | 757 | for (i = optind; i < argc; i++) { |
758 | file = fopen(argv[i], "r"); | 758 | file = fopen(argv[i], "r"); |
759 | if (file == NULL) { | 759 | if (file == NULL) { |
760 | errorMsg("%s: %s\n", argv[i], strerror(errno)); | 760 | error_msg("%s: %s\n", argv[i], strerror(errno)); |
761 | } else { | 761 | } else { |
762 | process_file(file); | 762 | process_file(file); |
763 | fclose(file); | 763 | fclose(file); |