{
sed_cmd_t *sed_cmd = bbg.sed_cmd_head.next;
- llist_free_contents(bbg.append_head);
+ llist_free(bbg.append_head, free);
while (sed_cmd) {
sed_cmd_t *sed_cmd_next = sed_cmd->next;
parse_escapes(match,match,strlen(match),i,i);
parse_escapes(replace,replace,strlen(replace),i,i);
- sed_cmd->string = xcalloc(1, (strlen(match) + 1) * 2);
+ sed_cmd->string = xzalloc((strlen(match) + 1) * 2);
for (i = 0; match[i] && replace[i]; i++) {
sed_cmd->string[i * 2] = match[i];
sed_cmd->string[(i * 2) + 1] = replace[i];
cmdstr = bb_xasprintf("%s\n%s", bbg.add_cmd_line, cmdstr);
free(bbg.add_cmd_line);
bbg.add_cmd_line = cmdstr;
- } else bbg.add_cmd_line=NULL;
+ }
/* If this line ends with backslash, request next line. */
temp=strlen(cmdstr);
* part1 part2 part3
*/
- sed_cmd = xcalloc(1, sizeof(sed_cmd_t));
+ sed_cmd = xzalloc(sizeof(sed_cmd_t));
/* first part (if present) is an address: either a '$', a number or a /regex/ */
cmdstr += get_address(cmdstr, &sed_cmd->beg_line, &sed_cmd->beg_match);
static void append(char *s)
{
- bbg.append_head = llist_add_to_end(bbg.append_head, bb_xstrdup(s));
+ llist_add_to_end(&bbg.append_head, bb_xstrdup(s));
}
static void flush_append(void)
if(!no_newline) fputc('\n',file);
if(ferror(file)) {
- fprintf(stderr,"Write failed.\n");
- exit(4); /* It's what gnu sed exits with... */
+ bb_default_error_retval = 4; /* It's what gnu sed exits with... */
+ bb_error_msg_and_die(bb_msg_write_error);
}
return no_newline;
* files were specified or '-' was specified, take input from stdin.
* Otherwise, we process all the files specified. */
if (argv[optind] == NULL) {
- if(bbg.in_place) bb_error_msg_and_die("Filename required for -i");
+ if(bbg.in_place) bb_error_msg_and_die(bb_msg_requires_arg, "-i");
add_input_file(stdin);
process_files();
} else {