Here are some changes to lineoperations; adding selection support.
If a selection is made in the file, the line operation will be applied to the lines within the selection, rather than the whole file.
Like usual, I'm open to hear any suggestions/improvements.
You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany-plugins/pull/378
-- Commit Summary --
* lineoperations: combined similar code * lineoperations: added selection support * lineoperations: removed unnecessary parameters * lineoperations: added selection to documentation * lineoperations: added some ui changes * lineoperations: minor formatting
-- File Changes --
M lineoperations/ChangeLog (6) M lineoperations/README (14) M lineoperations/src/linefunctions.c (340) M lineoperations/src/linefunctions.h (28) M lineoperations/src/lineoperations.c (237)
-- Patch Links --
https://github.com/geany/geany-plugins/pull/378.patch https://github.com/geany/geany-plugins/pull/378.diff
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany-plugins/pull/378
frlan commented on this pull request.
/* loop through **lines, join first occurances into one str (new_file) */ - for(i = 0; i < total_num_lines; i++) + for(i = 0; i < num_lines; i++)
You should check earlier, whether num_lines is > 0
/* allocate and set *to_remove to all FALSE * to_remove[i] represents whether lines[i] should be removed */ - to_remove = g_malloc(sizeof(gboolean) * total_num_lines); - for(i = 0; i < (total_num_lines); i++) + to_remove = g_malloc(sizeof(gboolean) * num_lines); + for(i = 0; i < (num_lines); i++)
Same as before: You should check whether num_lines > 0 even you might only call it from your code
- /* copy **lines into 'new_file' if it is not FALSE(not duplicate) */ - for(i = 0; i < total_num_lines; i++) + /* copy **lines into 'new_file' if it is not FALSE (not duplicate) */ + for(i = 0; i < num_lines; i++)
num_lines > 0
/* allocate and set *to_remove to all TRUE * to_remove[i] represents whether lines[i] should be removed */ - to_remove = g_malloc(sizeof(gboolean) * total_num_lines); - for(i = 0; i < total_num_lines; i++) + to_remove = g_malloc(sizeof(gboolean) * num_lines); + for(i = 0; i < num_lines; i++)
num_lines > 0
Merged #378.
github-comments@lists.geany.org