lists.geany.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
List overview
Plugins-Commits
January 2016
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
plugins-commits@lists.geany.org
1 participants
56 discussions
Start a n
N
ew thread
[geany/geany-plugins] 13da57: lineoperations: fix comment style to match project
by Sylvan Mostert
15 Jan '16
15 Jan '16
Branch: refs/heads/master Author: Sylvan Mostert <smostert.dev(a)gmail.com> Committer: Sylvan Mostert <smostert.dev(a)gmail.com> Date: Fri, 15 Jan 2016 22:32:47 UTC Commit: 13da575f15422fa30acf19113dfb857af08c3e07
https://github.com/geany/geany-plugins/commit/13da575f15422fa30acf19113dfb8…
Log Message: ----------- lineoperations: fix comment style to match project Modified Paths: -------------- lineoperations/src/linefunctions.c lineoperations/src/linefunctions.h lineoperations/src/lineoperations.c Modified: lineoperations/src/linefunctions.c 151 lines changed, 74 insertions(+), 77 deletions(-) =================================================================== @@ -22,29 +22,29 @@ #include "linefunctions.h" -// comparison function to be used in qsort +/* comparison function to be used in qsort */ static gint compare_asc(const void * a, const void * b) { return g_strcmp0(*(const gchar **) a, *(const gchar **) b); } -// comparison function to be used in qsort +/* comparison function to be used in qsort */ static gint compare_desc(const void * a, const void * b) { return g_strcmp0(*(const gchar **) b, *(const gchar **) a); } -// Remove Duplicate Lines, sorted +/* Remove Duplicate Lines, sorted */ void rmdupst(GeanyDocument *doc) { - gint total_num_chars; // number of characters in the document - gint total_num_lines; // number of lines in the document - gchar **lines; // array to hold all lines in the document - gchar *new_file; // *final* string to replace current document - gchar *nf_end; // points to end of new_file - gchar *lineptr; // temporary line pointer - gint i; // iterator + gint total_num_chars; /* number of characters in the document */ + gint total_num_lines; /* number of lines in the document */ + gchar **lines; /* array to hold all lines in the document */ + gchar *new_file; /* *final* string to replace current document */ + gchar *nf_end; /* points to end of new_file */ + gchar *lineptr; /* temporary line pointer */ + gint i; /* iterator */ total_num_chars = sci_get_length(doc->editor->sci); total_num_lines = sci_get_line_count(doc->editor->sci); @@ -53,25 +53,25 @@ void rmdupst(GeanyDocument *doc) { nf_end = new_file; lineptr = (gchar *)""; - // copy *all* lines into **lines array + /* copy *all* lines into **lines array */ for(i = 0; i < total_num_lines; i++) lines[i] = sci_get_line(doc->editor->sci, i); - // sort **lines ascending + /* sort **lines ascending */ qsort(lines, total_num_lines, sizeof(gchar *), compare_asc); - // loop through **lines, join first occurances into one str (new_file) + /* loop through **lines, join first occurances into one str (new_file) */ for(i = 0; i < total_num_lines; i++) if(strcmp(lines[i], lineptr) != 0) { lineptr = lines[i]; nf_end = g_stpcpy(nf_end, lines[i]); - } + } - // set new document + /* set new document */ sci_set_text(doc->editor->sci, new_file); - // free used memory + /* free used memory */ for(i = 0; i < total_num_lines; i++) g_free(lines[i]); g_free(lines); @@ -79,16 +79,16 @@ void rmdupst(GeanyDocument *doc) { } -// Remove Duplicate Lines, ordered +/* Remove Duplicate Lines, ordered */ void rmdupln(GeanyDocument *doc) { - gint total_num_chars; // number of characters in the document - gint total_num_lines; // number of lines in the document - gchar **lines; // array to hold all lines in the document - gchar *new_file; // *final* string to replace current document - gchar *nf_end; // points to end of new_file - gint i; // iterator - gint j; // iterator - gboolean *to_remove; // flag to 'mark' which lines to remove + gint total_num_chars; /* number of characters in the document */ + gint total_num_lines; /* number of lines in the document */ + gchar **lines; /* array to hold all lines in the document */ + gchar *new_file; /* *final* string to replace current document */ + gchar *nf_end; /* points to end of new_file */ + gint i; /* iterator */ + gint j; /* iterator */ + gboolean *to_remove; /* flag to 'mark' which lines to remove */ total_num_chars = sci_get_length(doc->editor->sci); total_num_lines = sci_get_line_count(doc->editor->sci); @@ -98,36 +98,34 @@ void rmdupln(GeanyDocument *doc) { - // copy *all* lines into **lines array + /* copy *all* lines into **lines array */ for(i = 0; i < total_num_lines; i++) lines[i] = sci_get_line(doc->editor->sci, i); - // allocate and set *to_remove to all FALSE - // to_remove[i] represents whether lines[i] should be removed + /* 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[i] = FALSE; - // find which **lines are duplicate, and mark them as duplicate - for(i = 0; i < total_num_lines; i++) // loop through **lines - // make sure that the line is not already duplicate + /* find which **lines are duplicate, and mark them as duplicate */ + for(i = 0; i < total_num_lines; i++) /* loop through **lines */ + /* make sure that the line is not already duplicate */ if(!to_remove[i]) - // find the rest of same lines + /* find the rest of same lines */ for(j = (i+1); j < total_num_lines; j++) if(!to_remove[j] && strcmp(lines[i], lines[j]) == 0) - to_remove[j] = TRUE; // line is duplicate, mark to remove + to_remove[j] = TRUE; /* line is duplicate, mark to remove */ - // copy **lines into 'new_file' if it is not FALSE(not duplicate) + /* copy **lines into 'new_file' if it is not FALSE(not duplicate) */ for(i = 0; i < total_num_lines; i++) if(!to_remove[i]) nf_end = g_stpcpy(nf_end, lines[i]); - - - // set new document + /* set new document */ sci_set_text(doc->editor->sci, new_file); - // free used memory + /* free used memory */ for(i = 0; i < total_num_lines; i++) g_free(lines[i]); g_free(lines); @@ -136,16 +134,16 @@ void rmdupln(GeanyDocument *doc) { } -// Remove Unique Lines +/* Remove Unique Lines */ void rmunqln(GeanyDocument *doc) { - gint total_num_chars; // number of characters in the document - gint total_num_lines; // number of lines in the document - gchar **lines; // array to hold all lines in the document - gchar *new_file; // *final* string to replace current document - gchar *nf_end; // points to end of new_file - gint i; // iterator - gint j; // iterator - gboolean *to_remove; // to 'mark' which lines to remove + gint total_num_chars; /* number of characters in the document */ + gint total_num_lines; /* number of lines in the document */ + gchar **lines; /* array to hold all lines in the document */ + gchar *new_file; /* *final* string to replace current document */ + gchar *nf_end; /* points to end of new_file */ + gint i; /* iterator */ + gint j; /* iterator */ + gboolean *to_remove; /* to 'mark' which lines to remove */ total_num_chars = sci_get_length(doc->editor->sci); total_num_lines = sci_get_line_count(doc->editor->sci); @@ -153,19 +151,20 @@ void rmunqln(GeanyDocument *doc) { new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); nf_end = new_file; - // copy *all* lines into **lines array + /* copy *all* lines into **lines array */ for(i = 0; i < total_num_lines; i++) lines[i] = sci_get_line(doc->editor->sci, i); - // allocate and set *to_remove to all TRUE - // to_remove[i] represents whether lines[i] should be removed + + /* 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[i] = TRUE; - // find all unique lines and set them to FALSE (not to be removed) + /* find all unique lines and set them to FALSE (not to be removed) */ for(i = 0; i < total_num_lines; i++) - // make sure that the line is not already determined to be unique + /* make sure that the line is not already determined to be unique */ if(to_remove[i]) for(j = (i+1); j < total_num_lines; j++) if(to_remove[j] && strcmp(lines[i], lines[j]) == 0) @@ -174,18 +173,15 @@ void rmunqln(GeanyDocument *doc) { to_remove[j] = FALSE; } - - // copy **lines into 'new_file' if it is not FALSE(not duplicate) + /* copy **lines into 'new_file' if it is not FALSE(not duplicate) */ for(i = 0; i < total_num_lines; i++) if(!to_remove[i]) nf_end = g_stpcpy(nf_end, lines[i]); - - - // set new document + /* set new document */ sci_set_text(doc->editor->sci, new_file); - // free used memory + /* free used memory */ for(i = 0; i < total_num_lines; i++) g_free(lines[i]); g_free(lines); @@ -194,16 +190,16 @@ void rmunqln(GeanyDocument *doc) { } -// Remove Empty Lines +/* Remove Empty Lines */ void rmemtyln(GeanyDocument *doc) { - gint total_num_lines; // number of lines in the document - gint i; // iterator + gint total_num_lines; /* number of lines in the document */ + gint i; /* iterator */ total_num_lines = sci_get_line_count(doc->editor->sci); sci_start_undo_action(doc->editor->sci); - for(i = 0; i < total_num_lines; i++) // loop through opened doc + for(i = 0; i < total_num_lines; i++) /* loop through opened doc */ { if(sci_get_position_from_line(doc->editor->sci, i) == sci_get_line_end_position(doc->editor->sci, i)) @@ -223,16 +219,16 @@ void rmemtyln(GeanyDocument *doc) { -// Remove Whitespace Lines +/* Remove Whitespace Lines */ void rmwhspln(GeanyDocument *doc) { - gint total_num_lines; // number of lines in the document - gint i; // iterator + gint total_num_lines; /* number of lines in the document */ + gint i; /* iterator */ total_num_lines = sci_get_line_count(doc->editor->sci); sci_start_undo_action(doc->editor->sci); - for(i = 0; i < total_num_lines; i++) // loop through opened doc + for(i = 0; i < total_num_lines; i++) /* loop through opened doc */ { if(sci_get_line_end_position(doc->editor->sci, i) - @@ -246,43 +242,44 @@ void rmwhspln(GeanyDocument *doc) { total_num_lines--; i--; } + } sci_end_undo_action(doc->editor->sci); } -// Sort Lines Ascending and Descending +/* Sort Lines Ascending and Descending */ void sortlines(GeanyDocument *doc, gboolean asc) { - gint total_num_chars; // number of characters in the document - gint total_num_lines; // number of lines in the document - gchar **lines; // array to hold all lines in the document - gchar *new_file; // *final* string to replace current document - gint i; // iterator + gint total_num_chars; /* number of characters in the document */ + gint total_num_lines; /* number of lines in the document */ + gchar **lines; /* array to hold all lines in the document */ + gchar *new_file; /* *final* string to replace current document */ + gint i; /* iterator */ total_num_chars = sci_get_length(doc->editor->sci); total_num_lines = sci_get_line_count(doc->editor->sci); lines = g_malloc(sizeof(gchar *) * total_num_lines+1); new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); - // copy *all* lines into **lines array + /* copy *all* lines into **lines array */ for(i = 0; i < total_num_lines; i++) lines[i] = sci_get_line(doc->editor->sci, i); - // sort **lines array + /* sort **lines array */ if(asc) qsort(lines, total_num_lines, sizeof(gchar *), compare_asc); else qsort(lines, total_num_lines, sizeof(gchar *), compare_desc); - // join **lines into one string (new_file) + /* join **lines into one string (new_file) */ lines[total_num_lines] = NULL; new_file = g_strjoinv("", lines); - // set new document + /* set new document */ sci_set_text(doc->editor->sci, new_file); - // free used memory + /* free used memory */ for(i = 0; i < total_num_lines; i++) g_free(lines[i]); g_free(lines); Modified: lineoperations/src/linefunctions.h 12 lines changed, 6 insertions(+), 6 deletions(-) =================================================================== @@ -29,27 +29,27 @@ #include <stdlib.h> /* qsort */ -// Remove Duplicate Lines, sorted +/* Remove Duplicate Lines, sorted */ void rmdupst(GeanyDocument *doc); -// Remove Duplicate Lines, ordered +/* Remove Duplicate Lines, ordered */ void rmdupln(GeanyDocument *doc); -// Remove Unique Lines +/* Remove Unique Lines */ void rmunqln(GeanyDocument *doc); -// Remove Empty Lines +/* Remove Empty Lines */ void rmemtyln(GeanyDocument *doc); -// Remove Whitespace Lines +/* Remove Whitespace Lines */ void rmwhspln(GeanyDocument *doc); -// Sort Lines Ascending and Descending +/* Sort Lines Ascending and Descending */ void sortlines(GeanyDocument *doc, gboolean asc); #endif Modified: lineoperations/src/lineoperations.c 14 lines changed, 7 insertions(+), 7 deletions(-) =================================================================== @@ -27,7 +27,7 @@ static GtkWidget *main_menu_item = NULL; -// Remove Duplicate Lines, sorted +/* Remove Duplicate Lines, sorted */ static void action_rmdupst_item(GtkMenuItem *menuitem, gpointer gdata) { @@ -38,7 +38,7 @@ action_rmdupst_item(GtkMenuItem *menuitem, gpointer gdata) } -// Remove Duplicate Lines, ordered +/* Remove Duplicate Lines, ordered */ static void action_rmdupln_item(GtkMenuItem *menuitem, gpointer gdata) { @@ -49,7 +49,7 @@ action_rmdupln_item(GtkMenuItem *menuitem, gpointer gdata) } -// Remove Unique Lines +/* Remove Unique Lines */ static void action_rmunqln_item(GtkMenuItem *menuitem, gpointer gdata) { @@ -60,7 +60,7 @@ action_rmunqln_item(GtkMenuItem *menuitem, gpointer gdata) } -// Remove Empty Lines +/* Remove Empty Lines */ static void action_rmemtyln_item(GtkMenuItem *menuitem, gpointer gdata) { @@ -71,7 +71,7 @@ action_rmemtyln_item(GtkMenuItem *menuitem, gpointer gdata) } -// Remove Whitespace Lines +/* Remove Whitespace Lines */ static void action_rmwhspln_item(GtkMenuItem *menuitem, gpointer gdata) { @@ -82,7 +82,7 @@ action_rmwhspln_item(GtkMenuItem *menuitem, gpointer gdata) } -// Sort Lines Ascending +/* Sort Lines Ascending */ static void action_sortasc_item(GtkMenuItem *menuitem, gpointer gdata) { @@ -93,7 +93,7 @@ action_sortasc_item(GtkMenuItem *menuitem, gpointer gdata) } -// Sort Lines Descending +/* Sort Lines Descending */ static void action_sortdesc_item(GtkMenuItem *menuitem, gpointer gdata) { -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 53a594: lineoperations: fixes to plugin API
by Sylvan Mostert
15 Jan '16
15 Jan '16
Branch: refs/heads/master Author: Sylvan Mostert <smostert.dev(a)gmail.com> Committer: Sylvan Mostert <smostert.dev(a)gmail.com> Date: Fri, 15 Jan 2016 22:14:52 UTC Commit: 53a59417f22cf4567cbc5f35b90173a40400e0b9
https://github.com/geany/geany-plugins/commit/53a59417f22cf4567cbc5f35b9017…
Log Message: ----------- lineoperations: fixes to plugin API Modified Paths: -------------- lineoperations/src/lineoperations.c Modified: lineoperations/src/lineoperations.c 42 lines changed, 25 insertions(+), 17 deletions(-) =================================================================== @@ -24,19 +24,6 @@ #include "linefunctions.h" -GeanyPlugin *geany_plugin; -GeanyData *geany_data; - - -PLUGIN_VERSION_CHECK(225) - -PLUGIN_SET_INFO(_("Line Operations"), - _("Line Operations provides a handful of functions that can be applied to a document such as, removing duplicate lines, removing empty lines, removing lines with only whitespace, and sorting lines."), - "0.1", - "Sylvan Mostert") - - - static GtkWidget *main_menu_item = NULL; @@ -117,8 +104,11 @@ action_sortdesc_item(GtkMenuItem *menuitem, gpointer gdata) } -void plugin_init(GeanyData *data) +static gboolean lo_init(GeanyPlugin *plugin, gpointer gdata) { + GeanyData *geany_data = plugin->geany_data; + + GtkWidget *submenu; GtkWidget *sep1; GtkWidget *sep2; @@ -130,10 +120,8 @@ void plugin_init(GeanyData *data) GtkWidget *sortasc_item; GtkWidget *sortdesc_item; - /* Add an item to the Tools menu */ main_menu_item = gtk_menu_item_new_with_mnemonic(_("_Line Operations")); gtk_widget_show(main_menu_item); - ui_add_document_sensitive(main_menu_item); submenu = gtk_menu_new(); gtk_widget_show(submenu); @@ -170,6 +158,8 @@ void plugin_init(GeanyData *data) gtk_menu_item_set_submenu(GTK_MENU_ITEM(main_menu_item), submenu); gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), main_menu_item); + + g_signal_connect(rmdupst_item, "activate", G_CALLBACK(action_rmdupst_item), NULL); g_signal_connect(rmdupln_item, "activate", G_CALLBACK(action_rmdupln_item), NULL); g_signal_connect(rmunqln_item, "activate", G_CALLBACK(action_rmunqln_item), NULL); @@ -185,11 +175,29 @@ void plugin_init(GeanyData *data) ui_add_document_sensitive(rmwhspln_item); ui_add_document_sensitive(sortasc_item); ui_add_document_sensitive(sortdesc_item); + + return TRUE; } void -plugin_cleanup(void) +lo_cleanup(void) { if(main_menu_item) gtk_widget_destroy(main_menu_item); } + + +G_MODULE_EXPORT +void geany_load_module(GeanyPlugin *plugin) +{ + plugin->info->name = _("Line Operations"); + plugin->info->description = _("Line Operations provides a handful of functions that can be applied to a document such as, removing duplicate lines, removing empty lines, removing lines with only whitespace, and sorting lines."); + plugin->info->version = "0.1"; + plugin->info->author = _("Sylvan Mostert <smostert.dev(a)gmail.com>"); + + plugin->funcs->init = lo_init; + plugin->funcs->cleanup = lo_cleanup; + + GEANY_PLUGIN_REGISTER(plugin, 225); +} + -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] f1889a: GeanyCtags: Follow symbolic links
by Jiří Techet
15 Jan '16
15 Jan '16
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Fri, 15 Jan 2016 17:33:32 UTC Commit: f1889ab92d55ed0e3db317e228c1fea72320babd
https://github.com/geany/geany-plugins/commit/f1889ab92d55ed0e3db317e228c1f…
Log Message: ----------- GeanyCtags: Follow symbolic links Modified Paths: -------------- geanyctags/src/geanyctags.c Modified: geanyctags/src/geanyctags.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -192,7 +192,7 @@ static gchar *generate_find_string(GeanyProject *prj) { gchar *ret; - ret = g_strdup("find . -not -path '*/\\.*'"); + ret = g_strdup("find -L . -not -path '*/\\.*'"); if (!EMPTY(prj->file_patterns)) { -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] c4f427: GeanyCtags: Use ellipsis for menu item showing a dialog
by Jiří Techet
15 Jan '16
15 Jan '16
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Fri, 15 Jan 2016 17:33:26 UTC Commit: c4f42701d3ad00d89cb1b123efe60a3f2a9ee360
https://github.com/geany/geany-plugins/commit/c4f42701d3ad00d89cb1b123efe60…
Log Message: ----------- GeanyCtags: Use ellipsis for menu item showing a dialog Modified Paths: -------------- geanyctags/src/geanyctags.c Modified: geanyctags/src/geanyctags.c 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -650,7 +650,7 @@ void plugin_init(G_GNUC_UNUSED GeanyData * data) keybindings_set_item(key_group, KB_GENERATE_TAGS, NULL, 0, 0, "generate_tags", _("Generate tags"), s_gt_item); - s_ft_item = gtk_menu_item_new_with_mnemonic(_("Find tag")); + s_ft_item = gtk_menu_item_new_with_mnemonic(_("Find tag...")); gtk_widget_show(s_ft_item); gtk_container_add(GTK_CONTAINER(geany->main_widgets->project_menu), s_ft_item); g_signal_connect((gpointer) s_ft_item, "activate", G_CALLBACK(on_find_tag), NULL); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] 20b545: ProjectOrganizer: correctly show tags from external directories
by Jiří Techet
15 Jan '16
15 Jan '16
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Fri, 15 Jan 2016 16:41:00 UTC Commit: 20b545069cf1133c1a33cc333a65d428cd86917d
https://github.com/geany/geany-plugins/commit/20b545069cf1133c1a33cc333a65d…
Log Message: ----------- ProjectOrganizer: correctly show tags from external directories Use an absolute path in the msgwindow for an external directory outside the project path. Modified Paths: -------------- projectorganizer/src/prjorg-sidebar.c Modified: projectorganizer/src/prjorg-sidebar.c 5 lines changed, 2 insertions(+), 3 deletions(-) =================================================================== @@ -618,9 +618,8 @@ static void find_tags(const gchar *name, gboolean declaration, gboolean case_sen gchar *relpath; relpath = get_relative_path(utf8_base_path, utf8_fname); - if (relpath) - msgwin_msg_add(COLOR_BLACK, -1, NULL, "%s:%lu:\n\t[%s]\t %s%s%s", relpath, - tag->line, tm_tag_type_name(tag), scopestr, tag->name, tag->arglist ? tag->arglist : ""); + msgwin_msg_add(COLOR_BLACK, -1, NULL, "%s:%lu:\n\t[%s]\t %s%s%s", relpath ? relpath : utf8_fname, + tag->line, tm_tag_type_name(tag), scopestr, tag->name, tag->arglist ? tag->arglist : ""); g_free(scopestr); g_free(relpath); g_free(utf8_fname); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] e71d26: ProjectOrganizer: Fix too aggressive symlink cycle detection
by Jiří Techet
15 Jan '16
15 Jan '16
Branch: refs/heads/master Author: Jiří Techet <techet(a)gmail.com> Committer: Jiří Techet <techet(a)gmail.com> Date: Fri, 15 Jan 2016 15:53:06 UTC Commit: e71d268faceb8bbbb71bd09e176173e02e373f56
https://github.com/geany/geany-plugins/commit/e71d268faceb8bbbb71bd09e17617…
Log Message: ----------- ProjectOrganizer: Fix too aggressive symlink cycle detection The previous symlink cycle detection would check if the child directory is within parent. This however breaks the case where in the root of the project there are symlinks to directories outside the project directory. Fix this by simply recording the resolved real paths during the tree creation. Skip subtree creation if the path was visited previously. Modified Paths: -------------- projectorganizer/src/prjorg-project.c Modified: projectorganizer/src/prjorg-project.c 43 lines changed, 16 insertions(+), 27 deletions(-) =================================================================== @@ -70,19 +70,24 @@ static void collect_source_files(gchar *filename, TMSourceFile *sf, gpointer use /* path - absolute path in locale, returned list in locale */ -static GSList *get_file_list(const gchar *utf8_path, GSList *patterns, GSList *ignored_dirs_patterns, GSList *ignored_file_patterns) +static GSList *get_file_list(const gchar *utf8_path, GSList *patterns, + GSList *ignored_dirs_patterns, GSList *ignored_file_patterns, GHashTable *visited_paths) { GSList *list = NULL; GDir *dir; gchar *locale_path = utils_get_locale_from_utf8(utf8_path); + gchar *real_path = tm_get_real_path(locale_path); dir = g_dir_open(locale_path, 0, NULL); - if (!dir) + if (!dir || !real_path || g_hash_table_contains(visited_paths, real_path)) { g_free(locale_path); + g_free(real_path); return NULL; } + g_hash_table_insert(visited_paths, real_path, GINT_TO_POINTER(1)); + while (TRUE) { const gchar *locale_name; @@ -99,32 +104,13 @@ static GSList *get_file_list(const gchar *utf8_path, GSList *patterns, GSList *i if (g_file_test(locale_filename, G_FILE_TEST_IS_DIR)) { GSList *lst; - gchar *relative, *locale_parent_realpath, *locale_child_realpath, - *utf8_parent_realpath, *utf8_child_realpath; - - /* symlink cycle avoidance - test if directory within parent directory */ - locale_parent_realpath = tm_get_real_path(locale_path); - locale_child_realpath = tm_get_real_path(locale_filename); - utf8_parent_realpath = utils_get_utf8_from_locale(locale_parent_realpath); - utf8_child_realpath = utils_get_utf8_from_locale(locale_child_realpath); - - relative = get_relative_path(utf8_parent_realpath, utf8_child_realpath); - - g_free(locale_parent_realpath); - g_free(locale_child_realpath); - g_free(utf8_parent_realpath); - g_free(utf8_child_realpath); - if (relative) + if (!patterns_match(ignored_dirs_patterns, utf8_name)) { - g_free(relative); - - if (!patterns_match(ignored_dirs_patterns, utf8_name)) - { - lst = get_file_list(utf8_filename, patterns, ignored_dirs_patterns, ignored_file_patterns); - if (lst) - list = g_slist_concat(list, lst); - } + lst = get_file_list(utf8_filename, patterns, ignored_dirs_patterns, + ignored_file_patterns, visited_paths); + if (lst) + list = g_slist_concat(list, lst); } } else if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR)) @@ -151,6 +137,7 @@ static gint prjorg_project_rescan_root(PrjOrgRoot *root) GSList *pattern_list = NULL; GSList *ignored_dirs_list = NULL; GSList *ignored_file_list = NULL; + GHashTable *visited_paths; GSList *lst; GSList *elem; gint filenum = 0; @@ -173,7 +160,9 @@ static gint prjorg_project_rescan_root(PrjOrgRoot *root) ignored_dirs_list = get_precompiled_patterns(prj_org->ignored_dirs_patterns); ignored_file_list = get_precompiled_patterns(prj_org->ignored_file_patterns); - lst = get_file_list(root->base_dir, pattern_list, ignored_dirs_list, ignored_file_list); + visited_paths = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); + lst = get_file_list(root->base_dir, pattern_list, ignored_dirs_list, ignored_file_list, visited_paths); + g_hash_table_destroy(visited_paths); foreach_slist(elem, lst) { -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] bb76f3: Merge pull request #326 from kugel-/geanypy-encodings
by Frank Lanitz
15 Jan '16
15 Jan '16
Branch: refs/heads/master Author: Frank Lanitz <frank(a)frank.uvena.de> Committer: Frank Lanitz <frank(a)frank.uvena.de> Date: Thu, 14 Jan 2016 23:09:25 UTC Commit: bb76f3f8ed4aa533753fcabe852b0341a053aaf6
https://github.com/geany/geany-plugins/commit/bb76f3f8ed4aa533753fcabe852b0…
Log Message: ----------- Merge pull request #326 from kugel-/geanypy-encodings geanypy: disable some part of geanypy-encodings.[ch] which are not pa… Modified Paths: -------------- geanypy/src/geanypy-encoding.c geanypy/src/geanypy-encoding.h Modified: geanypy/src/geanypy-encoding.c 109 lines changed, 0 insertions(+), 109 deletions(-) =================================================================== @@ -5,94 +5,6 @@ #include "geanypy.h" -static void -Encoding_dealloc(Encoding *self) -{ - g_return_if_fail(self != NULL); - self->ob_type->tp_free((PyObject *) self); -} - - -static int -Encoding_init(Encoding *self) -{ - g_return_val_if_fail(self != NULL, -1); - self->encoding = NULL; - return 0; -} - - -static PyObject * -Encoding_get_property(Encoding *self, const gchar *prop_name) -{ - g_return_val_if_fail(self != NULL, NULL); - g_return_val_if_fail(prop_name != NULL, NULL); - - if (!self->encoding) - { - PyErr_SetString(PyExc_RuntimeError, - "Encoding instance not initialized properly"); - return NULL; - } - - if (g_str_equal(prop_name, "charset") && self->encoding->charset) - return PyString_FromString(self->encoding->charset); - else if (g_str_equal(prop_name, "group")) - return PyInt_FromLong((glong) self->encoding->group); - else if (g_str_equal(prop_name, "idx")) - return PyInt_FromLong((glong) self->encoding->idx); - else if (g_str_equal(prop_name, "name") && self->encoding->name) - return PyString_FromString(self->encoding->name); - else if (g_str_equal(prop_name, "order")) - return PyInt_FromLong((glong) self->encoding->order); - - Py_RETURN_NONE; -} -GEANYPY_PROPS_READONLY(Encoding); - - -static PyGetSetDef Encoding_getseters[] = { - GEANYPY_GETSETDEF(Encoding, "charset", - "String representation of the encoding, ex. 'ISO-8859-3'."), - GEANYPY_GETSETDEF(Encoding, "group", - "Internally used member for grouping (see encoding.GROUP_* constants)."), - GEANYPY_GETSETDEF(Encoding, "idx", - "The index of the encoding, (see encoding.* constants, not encoding.GROUP_*)."), - GEANYPY_GETSETDEF(Encoding, "name", - "Translatable and descriptive name of the encoding, ex 'South European'."), - GEANYPY_GETSETDEF(Encoding, "order", - "Internally used member for grouping."), - { NULL } -}; - - -PyTypeObject EncodingType = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - "geany.encoding.Encoding", /* tp_name */ - sizeof(Encoding), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) Encoding_dealloc, /* tp_dealloc */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* tp_print - tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Wrapper around a GeanyEncoding structure.", /* tp_doc */ - 0, 0, 0, 0, 0, 0, 0, 0, /* tp_traverse - tp_members */ - Encoding_getseters, /* tp_getset */ - 0, 0, 0, 0, 0, /* tp_base - tp_dictoffset */ - (initproc) Encoding_init, /* tp_init */ - 0, 0, /* tp_alloc - tp_new */ -}; - - -Encoding *Encoding_create_new_from_geany_encoding(GeanyEncoding *enc) -{ - Encoding *self; - self = (Encoding *) PyObject_CallObject((PyObject *) &EncodingType, NULL); - self->encoding = enc; - return self; -} - - static PyObject * Encodings_convert_to_utf8(PyObject *module, PyObject *args, PyObject *kwargs) { @@ -160,17 +72,6 @@ Encodings_get_charset_from_index(PyObject *module, PyObject *args, PyObject *kwa } -static const gchar *encoding_groups[] = { - "GROUP_NONE", - "GROUP_WEST_EUROPEAN", - "GROUP_EAST_EUROPEAN", - "GROUP_EAST_ASIAN", - "GROUP_ASIAN", - "GROUP_MIDDLE_EASTERN", - "GROUP_UNICODE" -}; - - static const gchar *encoding_names[] = { "ISO_8859_1", "ISO_8859_2", @@ -296,19 +197,9 @@ initencoding(void) int i; PyObject *m; - EncodingType.tp_new = PyType_GenericNew; - if (PyType_Ready(&EncodingType) < 0) - return; - m = Py_InitModule3("encoding", EncodingsModule_methods, "Encoding conversion functions."); - Py_INCREF(&EncodingType); - PyModule_AddObject(m, "Encoding", (PyObject *) &EncodingType); - for (i = 0; i < GEANY_ENCODINGS_MAX; i++) PyModule_AddIntConstant(m, encoding_names[i], (glong) i); - - for (i = 0; i < GEANY_ENCODING_GROUPS_MAX; i++) - PyModule_AddIntConstant(m, encoding_groups[i], (glong) i); } Modified: geanypy/src/geanypy-encoding.h 10 lines changed, 0 insertions(+), 10 deletions(-) =================================================================== @@ -1,14 +1,4 @@ #ifndef GEANYPY_ENCODING_H__ #define GEANYPY_ENCODING_H__ -extern PyTypeObject EncodingType; - -typedef struct -{ - PyObject_HEAD - GeanyEncoding *encoding; -} Encoding; - -Encoding *Encoding_create_new_from_geany_encoding(GeanyEncoding *enc); - #endif /* GEANYPY_ENCODING_H__ */ -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] a171c7: lineoperations: re-wrote rmempln()/rmwhspln()
by Sylvan Mostert
12 Jan '16
12 Jan '16
Branch: refs/heads/master Author: Sylvan Mostert <smostert.dev(a)gmail.com> Committer: Sylvan Mostert <smostert.dev(a)gmail.com> Date: Tue, 12 Jan 2016 17:48:58 UTC Commit: a171c7e6b5e43d7ac699e07301212f538f6c9efa
https://github.com/geany/geany-plugins/commit/a171c7e6b5e43d7ac699e07301212…
Log Message: ----------- lineoperations: re-wrote rmempln()/rmwhspln() The functions to remove whitespace lines and empty lines now use direct scintilla manipulation. The functions is_sp() and is_whitespace_line() are no longer needed and are deleted. Modified Paths: -------------- lineoperations/src/linefunctions.c Modified: lineoperations/src/linefunctions.c 125 lines changed, 27 insertions(+), 98 deletions(-) =================================================================== @@ -22,26 +22,6 @@ #include "linefunctions.h" -// isspace() -gboolean is_sp(gchar c) -{ - return (c == ' ' || c == '\t' || c == '\f' || - c == '\v' || c == '\r' || c == '\n'); -} - - -// is_whitespace_line(gchar* line) checks if line is a whitespace line -gboolean is_whitespace_line(gchar* line) -{ - gint i; - - for(i = 0; line[i] != '\0'; i++) - if(!is_sp(line[i])) - return FALSE; - return TRUE; -} - - // comparison function to be used in qsort static gint compare_asc(const void * a, const void * b) { @@ -216,110 +196,59 @@ void rmunqln(GeanyDocument *doc) { // Remove Empty Lines void rmemtyln(GeanyDocument *doc) { - gint total_num_chars; // number of characters in the document - gint total_num_lines; // number of lines in the document - gchar *line; // temporary line - gint linelen; // length of *line - gchar *new_file; // *final* string to replace current document - gint nfposn; // position to the last character in new_file - gint i; // temporary iterator number - gint j; // iterator + gint total_num_lines; // number of lines in the document + gint i; // iterator - - total_num_chars = sci_get_length(doc->editor->sci); total_num_lines = sci_get_line_count(doc->editor->sci); - /* - * Allocate space for the new document (same amount as open document. - * If the document contains lines with only whitespace, - * not all of this space will be used.) - */ - new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); - nfposn = 0; + sci_start_undo_action(doc->editor->sci); - - for(i = 0; i < total_num_lines; i++) // loop through opened doc char by char + for(i = 0; i < total_num_lines; i++) // loop through opened doc { - linelen = sci_get_line_length(doc->editor->sci, i); - - if(linelen == 2) + if(sci_get_position_from_line(doc->editor->sci, i) == + sci_get_line_end_position(doc->editor->sci, i)) { - line = sci_get_line(doc->editor->sci, i); - - if(line[0] != '\r') - // copy current line into *new_file - for(j = 0; line[j] != '\0'; j++) - new_file[nfposn++] = line[j]; - } - else if(linelen != 1) - { - line = sci_get_line(doc->editor->sci, i); - - // copy current line into *new_file - for(j = 0; line[j] != '\0'; j++) - new_file[nfposn++] = line[j]; + scintilla_send_message(doc->editor->sci, + SCI_DELETERANGE, + sci_get_position_from_line(doc->editor->sci, i), + sci_get_line_length(doc->editor->sci, i)); + total_num_lines--; + i--; } } - new_file[nfposn] = '\0'; - sci_set_text(doc->editor->sci, new_file); // set new document - - - g_free(new_file); + sci_end_undo_action(doc->editor->sci); } + // Remove Whitespace Lines void rmwhspln(GeanyDocument *doc) { - gint total_num_chars; // number of characters in the document gint total_num_lines; // number of lines in the document - gchar *line; // temporary line - gint linelen; // length of *line - gchar *new_file; // *final* string to replace current document - gint nfposn; // position to the last character in new_file - gint i; // temporary iterator number - gint j; // iterator - + gint i; // iterator - total_num_chars = sci_get_length(doc->editor->sci); total_num_lines = sci_get_line_count(doc->editor->sci); - /* - * Allocate space for the new document (same amount as open document. - * If the document contains lines with only whitespace, - * not all of this space will be used.) - */ - new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); - nfposn = 0; + + sci_start_undo_action(doc->editor->sci); for(i = 0; i < total_num_lines; i++) // loop through opened doc { - linelen = sci_get_line_length(doc->editor->sci, i); - if(linelen == 2) + if(sci_get_line_end_position(doc->editor->sci, i) - + sci_get_position_from_line(doc->editor->sci, i) == + sci_get_line_indentation(doc->editor->sci, i)) { - line = sci_get_line(doc->editor->sci, i); - - if(line[0] != '\r') - // copy current line into *new_file - for(j = 0; line[j] != '\0'; j++) - new_file[nfposn++] = line[j]; + scintilla_send_message(doc->editor->sci, + SCI_DELETERANGE, + sci_get_position_from_line(doc->editor->sci, i), + sci_get_line_length(doc->editor->sci, i)); + total_num_lines--; + i--; } - else if(linelen != 1) - { - line = sci_get_line(doc->editor->sci, i); - - if(!is_whitespace_line(line)) - // copy current line into *new_file - for(j = 0; line[j] != '\0'; j++) - new_file[nfposn++] = line[j]; - } - } - new_file[nfposn] = '\0'; - sci_set_text(doc->editor->sci, new_file); // set new document - g_free(new_file); + sci_end_undo_action(doc->editor->sci); } -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] ec551c: lineoperations: add g_stpcpy() & other builtin fns
by Sylvan Mostert
12 Jan '16
12 Jan '16
Branch: refs/heads/master Author: Sylvan Mostert <smostert.dev(a)gmail.com> Committer: Sylvan Mostert <smostert.dev(a)gmail.com> Date: Tue, 12 Jan 2016 17:33:27 UTC Commit: ec551c926b1dbc18357d5610457c8fa34ea2df7c
https://github.com/geany/geany-plugins/commit/ec551c926b1dbc18357d5610457c8…
Log Message: ----------- lineoperations: add g_stpcpy() & other builtin fns For-loops were replaced with g_stpcpy or g_strjoinv when joining the lines array to one new_file string. strcmp in compare_asc()/compare_desc() was replace with g_strcmp0. These builtin functions improve readability and rely on glib. Modified Paths: -------------- lineoperations/src/linefunctions.c Modified: lineoperations/src/linefunctions.c 163 lines changed, 68 insertions(+), 95 deletions(-) =================================================================== @@ -45,14 +45,14 @@ gboolean is_whitespace_line(gchar* line) // comparison function to be used in qsort static gint compare_asc(const void * a, const void * b) { - return strcmp(*(const gchar **) a, *(const gchar **) b); + return g_strcmp0(*(const gchar **) a, *(const gchar **) b); } // comparison function to be used in qsort static gint compare_desc(const void * a, const void * b) { - return strcmp(*(const gchar **) b, *(const gchar **) a); + return g_strcmp0(*(const gchar **) b, *(const gchar **) a); } @@ -62,43 +62,34 @@ void rmdupst(GeanyDocument *doc) { gint total_num_lines; // number of lines in the document gchar **lines; // array to hold all lines in the document gchar *new_file; // *final* string to replace current document - gint nfposn; // keeps track of the position of new_file string + gchar *nf_end; // points to end of new_file + gchar *lineptr; // temporary line pointer gint i; // iterator - gint j; // iterator - gint k; // iterator total_num_chars = sci_get_length(doc->editor->sci); total_num_lines = sci_get_line_count(doc->editor->sci); lines = g_malloc(sizeof(gchar *) * total_num_lines); - new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); - nfposn = 0; - k = 0; - - + new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); + nf_end = new_file; + lineptr = (gchar *)""; // copy *all* lines into **lines array for(i = 0; i < total_num_lines; i++) lines[i] = sci_get_line(doc->editor->sci, i); + // sort **lines ascending qsort(lines, total_num_lines, sizeof(gchar *), compare_asc); - if(total_num_lines > 0) // copy the first line into *new_file - for(j = 0; lines[0][j] != '\0'; j++) - new_file[nfposn++] = lines[0][j]; - - for(i = 0; i < total_num_lines; i++) // copy 1st occurance of each line - // into *new_file - if(strcmp(lines[k], lines[i]) != 0) + // loop through **lines, join first occurances into one str (new_file) + for(i = 0; i < total_num_lines; i++) + if(strcmp(lines[i], lineptr) != 0) { - for(j = 0; lines[i][j] != '\0'; j++) - new_file[nfposn++] = lines[i][j]; - k = i; - } - - new_file[nfposn] = '\0'; - sci_set_text(doc->editor->sci, new_file); // set new document - + lineptr = lines[i]; + nf_end = g_stpcpy(nf_end, lines[i]); + } + // set new document + sci_set_text(doc->editor->sci, new_file); // free used memory for(i = 0; i < total_num_lines; i++) @@ -114,7 +105,7 @@ void rmdupln(GeanyDocument *doc) { gint total_num_lines; // number of lines in the document gchar **lines; // array to hold all lines in the document gchar *new_file; // *final* string to replace current document - gint nfposn; // keeps track of the position of new_file string + gchar *nf_end; // points to end of new_file gint i; // iterator gint j; // iterator gboolean *to_remove; // flag to 'mark' which lines to remove @@ -123,8 +114,7 @@ void rmdupln(GeanyDocument *doc) { total_num_lines = sci_get_line_count(doc->editor->sci); lines = g_malloc(sizeof(gchar *) * total_num_lines); new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); - nfposn = 0; - to_remove = NULL; + nf_end = new_file; @@ -133,106 +123,98 @@ void rmdupln(GeanyDocument *doc) { lines[i] = sci_get_line(doc->editor->sci, i); // 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[i] = FALSE; - // find which lines are duplicate - for(i = 0; i < total_num_lines; i++) + // find which **lines are duplicate, and mark them as duplicate + for(i = 0; i < total_num_lines; i++) // loop through **lines // make sure that the line is not already duplicate if(!to_remove[i]) + // find the rest of same lines for(j = (i+1); j < total_num_lines; j++) - if(!to_remove[j]) - if(strcmp(lines[i], lines[j]) == 0) { - to_remove[j] = TRUE; // this line is duplicate, - // mark to remove - //to_remove[i] = TRUE; //remove all occurrances - } - - // copy line into 'new_file' if it is not FALSE(not duplicate) + if(!to_remove[j] && strcmp(lines[i], lines[j]) == 0) + to_remove[j] = TRUE; // line is duplicate, mark to remove + + // copy **lines into 'new_file' if it is not FALSE(not duplicate) for(i = 0; i < total_num_lines; i++) - { if(!to_remove[i]) - for(j = 0; lines[i][j] != '\0'; j++) - new_file[nfposn++] = lines[i][j]; - g_free(lines[i]); - } + nf_end = g_stpcpy(nf_end, lines[i]); - new_file[nfposn] = '\0'; - sci_set_text(doc->editor->sci, new_file); // set new document + // set new document + sci_set_text(doc->editor->sci, new_file); - // each line is freed in above for-loop + // free used memory + for(i = 0; i < total_num_lines; i++) + g_free(lines[i]); g_free(lines); g_free(new_file); g_free(to_remove); } - +// Remove Unique Lines void rmunqln(GeanyDocument *doc) { - gint total_num_chars; // number of characters in the document - gint total_num_lines; // number of lines in the document - gchar **lines; // array to hold all lines in the document - gchar *new_file; // *final* string to replace current document - gint nfposn; // keeps track of the position of new_file string - gint i; // iterator - gint j; // iterator - gboolean *to_remove; // to 'mark' which lines to remove + gint total_num_chars; // number of characters in the document + gint total_num_lines; // number of lines in the document + gchar **lines; // array to hold all lines in the document + gchar *new_file; // *final* string to replace current document + gchar *nf_end; // points to end of new_file + gint i; // iterator + gint j; // iterator + gboolean *to_remove; // to 'mark' which lines to remove total_num_chars = sci_get_length(doc->editor->sci); total_num_lines = sci_get_line_count(doc->editor->sci); lines = g_malloc(sizeof(gchar *) * total_num_lines); new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); - nfposn = 0; - to_remove = NULL; - + nf_end = new_file; // copy *all* lines into **lines array for(i = 0; i < total_num_lines; i++) lines[i] = sci_get_line(doc->editor->sci, i); // 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++) + for(i = 0; i < total_num_lines; i++) to_remove[i] = TRUE; - // set all unique rows to FALSE - // to_remove[i] corresponds to lines[i] + // find all unique lines and set them to FALSE (not to be removed) for(i = 0; i < total_num_lines; i++) + // make sure that the line is not already determined to be unique if(to_remove[i]) for(j = (i+1); j < total_num_lines; j++) - if(to_remove[j]) - if(strcmp(lines[i], lines[j]) == 0) - { - to_remove[i] = FALSE; - to_remove[j] = FALSE; - } + if(to_remove[j] && strcmp(lines[i], lines[j]) == 0) + { + to_remove[i] = FALSE; + to_remove[j] = FALSE; + } - // copy line into 'new_file' if it is not FALSE(unique) + // copy **lines into 'new_file' if it is not FALSE(not duplicate) for(i = 0; i < total_num_lines; i++) - { if(!to_remove[i]) - for(j = 0; lines[i][j] != '\0'; j++) - new_file[nfposn++] = lines[i][j]; - g_free(lines[i]); - } + nf_end = g_stpcpy(nf_end, lines[i]); - new_file[nfposn] = '\0'; - sci_set_text(doc->editor->sci, new_file); // set new document + // set new document + sci_set_text(doc->editor->sci, new_file); - // each line is freed in above for-loop + // free used memory + for(i = 0; i < total_num_lines; i++) + g_free(lines[i]); g_free(lines); g_free(new_file); g_free(to_remove); } - +// Remove Empty Lines void rmemtyln(GeanyDocument *doc) { gint total_num_chars; // number of characters in the document gint total_num_lines; // number of lines in the document @@ -347,17 +329,12 @@ void sortlines(GeanyDocument *doc, gboolean asc) { gint total_num_lines; // number of lines in the document gchar **lines; // array to hold all lines in the document gchar *new_file; // *final* string to replace current document - gint nfposn; // keeps track of the position of new_file string gint i; // iterator - gint j; // iterator total_num_chars = sci_get_length(doc->editor->sci); total_num_lines = sci_get_line_count(doc->editor->sci); - lines = g_malloc(sizeof(gchar *) * total_num_lines); + lines = g_malloc(sizeof(gchar *) * total_num_lines+1); new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); - nfposn = 0; - - // copy *all* lines into **lines array for(i = 0; i < total_num_lines; i++) @@ -369,20 +346,16 @@ void sortlines(GeanyDocument *doc, gboolean asc) { else qsort(lines, total_num_lines, sizeof(gchar *), compare_desc); - // copy **lines array into *new_file - for(i = 0; i < total_num_lines; i++) - { - for(j = 0; lines[i][j] != '\0'; j++) - new_file[nfposn++] = lines[i][j]; + // join **lines into one string (new_file) + lines[total_num_lines] = NULL; + new_file = g_strjoinv("", lines); + + // set new document + sci_set_text(doc->editor->sci, new_file); + // free used memory + for(i = 0; i < total_num_lines; i++) g_free(lines[i]); - } - new_file[nfposn] = '\0'; - sci_set_text(doc->editor->sci, new_file); // set new document - - - - // each line is freed in above for-loop g_free(lines); g_free(new_file); } -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany-plugins] f369c8: lineoperations: cleaned up var names & unused vars
by Sylvan Mostert
12 Jan '16
12 Jan '16
Branch: refs/heads/master Author: Sylvan Mostert <smostert.dev(a)gmail.com> Committer: Sylvan Mostert <smostert.dev(a)gmail.com> Date: Tue, 12 Jan 2016 17:19:08 UTC Commit: f369c8421022ac2e53edd003ba32ad48da92048b
https://github.com/geany/geany-plugins/commit/f369c8421022ac2e53edd003ba32a…
Log Message: ----------- lineoperations: cleaned up var names & unused vars The variable 'numlines' was removed since it was unnecessary. Variable names and function are changed to have consistent naming. Now they have underscore between each distinct word. Modified Paths: -------------- lineoperations/src/linefunctions.c Modified: lineoperations/src/linefunctions.c 294 lines changed, 143 insertions(+), 151 deletions(-) =================================================================== @@ -23,34 +23,34 @@ // isspace() -gboolean issp(gchar c) +gboolean is_sp(gchar c) { return (c == ' ' || c == '\t' || c == '\f' || c == '\v' || c == '\r' || c == '\n'); } -// iswhitespaceline(gchar* line) checks if line is a whitespace line -gboolean iswhitespaceline(gchar* line) +// is_whitespace_line(gchar* line) checks if line is a whitespace line +gboolean is_whitespace_line(gchar* line) { gint i; for(i = 0; line[i] != '\0'; i++) - if(!issp(line[i])) + if(!is_sp(line[i])) return FALSE; return TRUE; } // comparison function to be used in qsort -static gint compareasc(const void * a, const void * b) +static gint compare_asc(const void * a, const void * b) { return strcmp(*(const gchar **) a, *(const gchar **) b); } // comparison function to be used in qsort -static gint comparedesc(const void * a, const void * b) +static gint compare_desc(const void * a, const void * b) { return strcmp(*(const gchar **) b, *(const gchar **) a); } @@ -58,52 +58,50 @@ static gint comparedesc(const void * a, const void * b) // Remove Duplicate Lines, sorted void rmdupst(GeanyDocument *doc) { - gint totalnumchars; // number of characters in the document - gint totalnumlines; // number of lines in the document + gint total_num_chars; // number of characters in the document + gint total_num_lines; // number of lines in the document gchar **lines; // array to hold all lines in the document - gint numlines; // number of lines in **lines array - gchar *newfile; // *final* string to replace current document - gint nfposn; // keeps track of the position of newfile string + gchar *new_file; // *final* string to replace current document + gint nfposn; // keeps track of the position of new_file string gint i; // iterator gint j; // iterator gint k; // iterator - totalnumchars = sci_get_length(doc->editor->sci); - totalnumlines = sci_get_line_count(doc->editor->sci); - lines = g_malloc(sizeof(gchar *) * totalnumlines); - newfile = g_malloc(sizeof(gchar) * (totalnumchars+1)); - numlines = 0; - nfposn = 0; - k = 0; + total_num_chars = sci_get_length(doc->editor->sci); + total_num_lines = sci_get_line_count(doc->editor->sci); + lines = g_malloc(sizeof(gchar *) * total_num_lines); + new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); + nfposn = 0; + k = 0; // copy *all* lines into **lines array - for(i = 0; i < totalnumlines; i++) - lines[numlines++] = sci_get_line(doc->editor->sci, i); + for(i = 0; i < total_num_lines; i++) + lines[i] = sci_get_line(doc->editor->sci, i); - qsort(lines, numlines, sizeof(gchar *), compareasc); + qsort(lines, total_num_lines, sizeof(gchar *), compare_asc); - if(numlines > 0) // copy the first line into *newfile + if(total_num_lines > 0) // copy the first line into *new_file for(j = 0; lines[0][j] != '\0'; j++) - newfile[nfposn++] = lines[0][j]; + new_file[nfposn++] = lines[0][j]; - for(i = 0; i < numlines; i++) // copy 1st occurance of each line - // into *newfile + for(i = 0; i < total_num_lines; i++) // copy 1st occurance of each line + // into *new_file if(strcmp(lines[k], lines[i]) != 0) { for(j = 0; lines[i][j] != '\0'; j++) - newfile[nfposn++] = lines[i][j]; + new_file[nfposn++] = lines[i][j]; k = i; } - newfile[nfposn] = '\0'; - sci_set_text(doc->editor->sci, newfile); // set new document + new_file[nfposn] = '\0'; + sci_set_text(doc->editor->sci, new_file); // set new document // free used memory - for(i = 0; i < numlines; i++) + for(i = 0; i < total_num_lines; i++) g_free(lines[i]); g_free(lines); g_free(new_file); @@ -112,58 +110,56 @@ void rmdupst(GeanyDocument *doc) { // Remove Duplicate Lines, ordered void rmdupln(GeanyDocument *doc) { - gint totalnumchars; // number of characters in the document - gint totalnumlines; // number of lines in the document + gint total_num_chars; // number of characters in the document + gint total_num_lines; // number of lines in the document gchar **lines; // array to hold all lines in the document - gint numlines; // number of lines in lines - gchar *newfile; // *final* string to replace current document - gint nfposn; // keeps track of the position of newfile string + gchar *new_file; // *final* string to replace current document + gint nfposn; // keeps track of the position of new_file string gint i; // iterator gint j; // iterator - gboolean *toremove; // flag to 'mark' which lines to remove + gboolean *to_remove; // flag to 'mark' which lines to remove - totalnumchars = sci_get_length(doc->editor->sci); - totalnumlines = sci_get_line_count(doc->editor->sci); - lines = g_malloc(sizeof(gchar *) * totalnumlines); - newfile = g_malloc(sizeof(gchar) * (totalnumchars+1)); - numlines = 0; - nfposn = 0; - toremove = NULL; + total_num_chars = sci_get_length(doc->editor->sci); + total_num_lines = sci_get_line_count(doc->editor->sci); + lines = g_malloc(sizeof(gchar *) * total_num_lines); + new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); + nfposn = 0; + to_remove = NULL; // copy *all* lines into **lines array - for(i = 0; i < totalnumlines; i++) - lines[numlines++] = sci_get_line(doc->editor->sci, i); + for(i = 0; i < total_num_lines; i++) + lines[i] = sci_get_line(doc->editor->sci, i); - // allocate and set *toremove to all FALSE - toremove = g_malloc(sizeof(gboolean) * numlines); - for(i = 0; i < (numlines); i++) - toremove[i] = FALSE; + // allocate and set *to_remove to all FALSE + to_remove = g_malloc(sizeof(gboolean) * total_num_lines); + for(i = 0; i < (total_num_lines); i++) + to_remove[i] = FALSE; // find which lines are duplicate - for(i = 0; i < numlines; i++) + for(i = 0; i < total_num_lines; i++) // make sure that the line is not already duplicate - if(!toremove[i]) - for(j = (i+1); j < numlines; j++) - if(!toremove[j]) + if(!to_remove[i]) + for(j = (i+1); j < total_num_lines; j++) + if(!to_remove[j]) if(strcmp(lines[i], lines[j]) == 0) { - toremove[j] = TRUE; // this line is duplicate, - // mark to remove - //toremove[i] = TRUE; //remove all occurrances + to_remove[j] = TRUE; // this line is duplicate, + // mark to remove + //to_remove[i] = TRUE; //remove all occurrances } - // copy line into 'newfile' if it is not FALSE(not duplicate) - for(i = 0; i < numlines; i++) + // copy line into 'new_file' if it is not FALSE(not duplicate) + for(i = 0; i < total_num_lines; i++) { - if(!toremove[i]) + if(!to_remove[i]) for(j = 0; lines[i][j] != '\0'; j++) - newfile[nfposn++] = lines[i][j]; + new_file[nfposn++] = lines[i][j]; g_free(lines[i]); } - newfile[nfposn] = '\0'; - sci_set_text(doc->editor->sci, newfile); // set new document + new_file[nfposn] = '\0'; + sci_set_text(doc->editor->sci, new_file); // set new document @@ -176,58 +172,56 @@ void rmdupln(GeanyDocument *doc) { void rmunqln(GeanyDocument *doc) { - gint totalnumchars; // number of characters in the document - gint totalnumlines; // number of lines in the document - gchar **lines; // array to hold all lines in the document - gint numlines; // number of lines in lines - gchar *newfile; // *final* string to replace current document - gint nfposn; // keeps track of the position of newfile string - gint i; // iterator - gint j; // iterator - gboolean *toremove; // to 'mark' which lines to remove - - totalnumchars = sci_get_length(doc->editor->sci); - totalnumlines = sci_get_line_count(doc->editor->sci); - lines = g_malloc(sizeof(gchar *) * totalnumlines); - newfile = g_malloc(sizeof(gchar) * (totalnumchars+1)); - numlines = 0; - nfposn = 0; - toremove = NULL; + gint total_num_chars; // number of characters in the document + gint total_num_lines; // number of lines in the document + gchar **lines; // array to hold all lines in the document + gchar *new_file; // *final* string to replace current document + gint nfposn; // keeps track of the position of new_file string + gint i; // iterator + gint j; // iterator + gboolean *to_remove; // to 'mark' which lines to remove + + total_num_chars = sci_get_length(doc->editor->sci); + total_num_lines = sci_get_line_count(doc->editor->sci); + lines = g_malloc(sizeof(gchar *) * total_num_lines); + new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); + nfposn = 0; + to_remove = NULL; // copy *all* lines into **lines array - for(i = 0; i < totalnumlines; i++) - lines[numlines++] = sci_get_line(doc->editor->sci, i); + for(i = 0; i < total_num_lines; i++) + lines[i] = sci_get_line(doc->editor->sci, i); - // allocate and set *toremove to all TRUE - toremove = g_malloc(sizeof(gboolean) * numlines); - for(i = 0; i < (numlines); i++) - toremove[i] = TRUE; + // allocate and set *to_remove to all TRUE + to_remove = g_malloc(sizeof(gboolean) * total_num_lines); + for(i = 0; i < (total_num_lines); i++) + to_remove[i] = TRUE; // set all unique rows to FALSE - // toremove[i] corresponds to lines[i] - for(i = 0; i < numlines; i++) - if(toremove[i]) - for(j = (i+1); j < numlines; j++) - if(toremove[j]) + // to_remove[i] corresponds to lines[i] + for(i = 0; i < total_num_lines; i++) + if(to_remove[i]) + for(j = (i+1); j < total_num_lines; j++) + if(to_remove[j]) if(strcmp(lines[i], lines[j]) == 0) { - toremove[i] = FALSE; - toremove[j] = FALSE; + to_remove[i] = FALSE; + to_remove[j] = FALSE; } - // copy line into 'newfile' if it is not FALSE(unique) - for(i = 0; i < numlines; i++) + // copy line into 'new_file' if it is not FALSE(unique) + for(i = 0; i < total_num_lines; i++) { - if(!toremove[i]) + if(!to_remove[i]) for(j = 0; lines[i][j] != '\0'; j++) - newfile[nfposn++] = lines[i][j]; + new_file[nfposn++] = lines[i][j]; g_free(lines[i]); } - newfile[nfposn] = '\0'; - sci_set_text(doc->editor->sci, newfile); // set new document + new_file[nfposn] = '\0'; + sci_set_text(doc->editor->sci, new_file); // set new document @@ -240,29 +234,29 @@ void rmunqln(GeanyDocument *doc) { void rmemtyln(GeanyDocument *doc) { - gint totalnumchars; // number of characters in the document - gint totalnumlines; // number of lines in the document + gint total_num_chars; // number of characters in the document + gint total_num_lines; // number of lines in the document gchar *line; // temporary line gint linelen; // length of *line - gchar *newfile; // *final* string to replace current document - gint nfposn; // position to the last character in newfile + gchar *new_file; // *final* string to replace current document + gint nfposn; // position to the last character in new_file gint i; // temporary iterator number gint j; // iterator - totalnumchars = sci_get_length(doc->editor->sci); - totalnumlines = sci_get_line_count(doc->editor->sci); + total_num_chars = sci_get_length(doc->editor->sci); + total_num_lines = sci_get_line_count(doc->editor->sci); /* * Allocate space for the new document (same amount as open document. * If the document contains lines with only whitespace, * not all of this space will be used.) */ - newfile = g_malloc(sizeof(gchar) * (totalnumchars+1)); - nfposn = 0; + new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); + nfposn = 0; - for(i = 0; i < totalnumlines; i++) // loop through opened doc char by char + for(i = 0; i < total_num_lines; i++) // loop through opened doc char by char { linelen = sci_get_line_length(doc->editor->sci, i); @@ -271,52 +265,52 @@ void rmemtyln(GeanyDocument *doc) { line = sci_get_line(doc->editor->sci, i); if(line[0] != '\r') - // copy current line into *newfile + // copy current line into *new_file for(j = 0; line[j] != '\0'; j++) - newfile[nfposn++] = line[j]; + new_file[nfposn++] = line[j]; } else if(linelen != 1) { line = sci_get_line(doc->editor->sci, i); - // copy current line into *newfile + // copy current line into *new_file for(j = 0; line[j] != '\0'; j++) - newfile[nfposn++] = line[j]; + new_file[nfposn++] = line[j]; } } - newfile[nfposn] = '\0'; - sci_set_text(doc->editor->sci, newfile); // set new document + new_file[nfposn] = '\0'; + sci_set_text(doc->editor->sci, new_file); // set new document - g_free(newfile); + g_free(new_file); } // Remove Whitespace Lines void rmwhspln(GeanyDocument *doc) { - gint totalnumchars; // number of characters in the document - gint totalnumlines; // number of lines in the document + gint total_num_chars; // number of characters in the document + gint total_num_lines; // number of lines in the document gchar *line; // temporary line gint linelen; // length of *line - gchar *newfile; // *final* string to replace current document - gint nfposn; // position to the last character in newfile + gchar *new_file; // *final* string to replace current document + gint nfposn; // position to the last character in new_file gint i; // temporary iterator number - gint j; // iterator + gint j; // iterator - totalnumchars = sci_get_length(doc->editor->sci); - totalnumlines = sci_get_line_count(doc->editor->sci); + total_num_chars = sci_get_length(doc->editor->sci); + total_num_lines = sci_get_line_count(doc->editor->sci); /* * Allocate space for the new document (same amount as open document. * If the document contains lines with only whitespace, * not all of this space will be used.) */ - newfile = g_malloc(sizeof(gchar) * (totalnumchars+1)); - nfposn = 0; + new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); + nfposn = 0; - for(i = 0; i < totalnumlines; i++) // loop through opened doc + for(i = 0; i < total_num_lines; i++) // loop through opened doc { linelen = sci_get_line_length(doc->editor->sci, i); @@ -325,68 +319,66 @@ void rmwhspln(GeanyDocument *doc) { line = sci_get_line(doc->editor->sci, i); if(line[0] != '\r') - // copy current line into *newfile + // copy current line into *new_file for(j = 0; line[j] != '\0'; j++) - newfile[nfposn++] = line[j]; + new_file[nfposn++] = line[j]; } else if(linelen != 1) { line = sci_get_line(doc->editor->sci, i); - if(!iswhitespaceline(line)) - // copy current line into *newfile + if(!is_whitespace_line(line)) + // copy current line into *new_file for(j = 0; line[j] != '\0'; j++) - newfile[nfposn++] = line[j]; + new_file[nfposn++] = line[j]; } } - newfile[nfposn] = '\0'; - sci_set_text(doc->editor->sci, newfile); // set new document + new_file[nfposn] = '\0'; + sci_set_text(doc->editor->sci, new_file); // set new document - g_free(newfile); + g_free(new_file); } // Sort Lines Ascending and Descending void sortlines(GeanyDocument *doc, gboolean asc) { - gint totalnumchars; // number of characters in the document - gint totalnumlines; // number of lines in the document + gint total_num_chars; // number of characters in the document + gint total_num_lines; // number of lines in the document gchar **lines; // array to hold all lines in the document - gint numlines; // number of lines in **lines array - gchar *newfile; // *final* string to replace current document - gint nfposn; // keeps track of the position of newfile string + gchar *new_file; // *final* string to replace current document + gint nfposn; // keeps track of the position of new_file string gint i; // iterator gint j; // iterator - totalnumchars = sci_get_length(doc->editor->sci); - totalnumlines = sci_get_line_count(doc->editor->sci); - lines = g_malloc(sizeof(gchar *) * totalnumlines); - newfile = g_malloc(sizeof(gchar) * (totalnumchars+1)); - numlines = 0; - nfposn = 0; + total_num_chars = sci_get_length(doc->editor->sci); + total_num_lines = sci_get_line_count(doc->editor->sci); + lines = g_malloc(sizeof(gchar *) * total_num_lines); + new_file = g_malloc(sizeof(gchar) * (total_num_chars+1)); + nfposn = 0; // copy *all* lines into **lines array - for(i = 0; i < totalnumlines; i++) - lines[numlines++] = sci_get_line(doc->editor->sci, i); + for(i = 0; i < total_num_lines; i++) + lines[i] = sci_get_line(doc->editor->sci, i); // sort **lines array if(asc) - qsort(lines, numlines, sizeof(gchar *), compareasc); + qsort(lines, total_num_lines, sizeof(gchar *), compare_asc); else - qsort(lines, numlines, sizeof(gchar *), comparedesc); + qsort(lines, total_num_lines, sizeof(gchar *), compare_desc); - // copy **lines array into *newfile - for(i = 0; i < numlines; i++) + // copy **lines array into *new_file + for(i = 0; i < total_num_lines; i++) { for(j = 0; lines[i][j] != '\0'; j++) - newfile[nfposn++] = lines[i][j]; + new_file[nfposn++] = lines[i][j]; g_free(lines[i]); } - newfile[nfposn] = '\0'; - sci_set_text(doc->editor->sci, newfile); // set new document + new_file[nfposn] = '\0'; + sci_set_text(doc->editor->sci, new_file); // set new document -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
← Newer
1
2
3
4
5
6
Older →
Jump to page:
1
2
3
4
5
6
Results per page:
10
25
50
100
200