tweaks: frob two statements, condense another, and add a comment
Also, remove two superfluous closings of file descriptors. The second one has most likely already been closed by send_data(), by closing the tube, and the first one will be closed by exiting from the process.master
parent
3b3a6b12a7
commit
1a28b08694
12
src/text.c
12
src/text.c
|
@ -289,7 +289,7 @@ void handle_indent_action(undostruct *u, bool undoing, bool add_indent)
|
||||||
goto_line_posx(u->head_lineno, u->head_x);
|
goto_line_posx(u->head_lineno, u->head_x);
|
||||||
|
|
||||||
/* For each line in the group, add or remove the individual indent. */
|
/* For each line in the group, add or remove the individual indent. */
|
||||||
while (line && line->lineno <= group->bottom_line) {
|
while (line != NULL && line->lineno <= group->bottom_line) {
|
||||||
char *blanks = group->indentations[line->lineno - group->top_line];
|
char *blanks = group->indentations[line->lineno - group->top_line];
|
||||||
|
|
||||||
if (undoing ^ add_indent)
|
if (undoing ^ add_indent)
|
||||||
|
@ -468,10 +468,7 @@ void handle_comment_action(undostruct *u, bool undoing, bool add_comment)
|
||||||
/* Undo a cut, or redo a paste. */
|
/* Undo a cut, or redo a paste. */
|
||||||
void undo_cut(undostruct *u)
|
void undo_cut(undostruct *u)
|
||||||
{
|
{
|
||||||
if (u->xflags & WAS_WHOLE_LINE)
|
goto_line_posx(u->tail_lineno, (u->xflags & WAS_WHOLE_LINE) ? 0 : u->tail_x);
|
||||||
goto_line_posx(u->tail_lineno, 0);
|
|
||||||
else
|
|
||||||
goto_line_posx(u->tail_lineno, u->tail_x);
|
|
||||||
|
|
||||||
copy_from_buffer(u->cutbuffer);
|
copy_from_buffer(u->cutbuffer);
|
||||||
|
|
||||||
|
@ -910,7 +907,7 @@ void send_data(const linestruct *line, int fd)
|
||||||
FILE *tube = fdopen(fd, "w");
|
FILE *tube = fdopen(fd, "w");
|
||||||
|
|
||||||
if (tube == NULL)
|
if (tube == NULL)
|
||||||
return;
|
exit(4);
|
||||||
|
|
||||||
/* Send each line, except a final empty line. */
|
/* Send each line, except a final empty line. */
|
||||||
while (line != NULL && (line->next != NULL || line->data[0] != '\0')) {
|
while (line != NULL && (line->next != NULL || line->data[0] != '\0')) {
|
||||||
|
@ -1000,10 +997,9 @@ bool execute_command(const char *command)
|
||||||
update_undo(CUT);
|
update_undo(CUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create a separate process for piping the data to the command. */
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
close(to_fd[0]);
|
|
||||||
send_data(cutbuffer != NULL ? cutbuffer : openfile->filetop, to_fd[1]);
|
send_data(cutbuffer != NULL ? cutbuffer : openfile->filetop, to_fd[1]);
|
||||||
close(to_fd[1]);
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue