[geany/geany-plugins] dd87a7: GeanyLua Fix some compiler warnings
Matthew Brush
git-noreply at xxxxx
Wed Sep 3 22:45:22 UTC 2014
Branch: refs/heads/master
Author: Matthew Brush <matt at geany.org>
Committer: Matthew Brush <matt at geany.org>
Date: Wed, 21 May 2014 03:23:03 UTC
Commit: dd87a7ba226a36eeb6c601b806e7d3f0b0f3badd
https://github.com/geany/geany-plugins/commit/dd87a7ba226a36eeb6c601b806e7d3f0b0f3badd
Log Message:
-----------
GeanyLua Fix some compiler warnings
* Replace shadowed "app" variable name with still quite short
"geany->app" and avoid the variable altogether.
* Avoid re-defining C99 "isblank()" function/macro by renaming to
"is_blank()". Could add some pre-processor checks and only define
"isblank" pre-C99 but this behaves same as before I think.
* Avoid storing allocated string in SciTextToFind's const member since
it needs to be passed to g_free() later. Temp var used to store
non-const pointer but could instead add a cast in the g_free() call
but I find this a little cleaner somehow.
Modified Paths:
--------------
geanylua/glspi_app.c
geanylua/glspi_init.c
geanylua/glspi_sci.c
Modified: geanylua/glspi_app.c
12 lines changed, 5 insertions(+), 7 deletions(-)
===================================================================
@@ -77,13 +77,11 @@ static const gchar *glspi_script_dir = NULL;
static gint glspi_appinfo(lua_State* L)
{
- GeanyApp *app = geany->app;
-
lua_newtable(L);
- SetTableBool("debug", app->debug_mode);
- SetTableStr("configdir", app->configdir);
- SetTableStr("datadir", app->datadir);
- SetTableStr("docdir", app->docdir);
+ SetTableBool("debug", geany->app->debug_mode);
+ SetTableStr("configdir", geany->app->configdir);
+ SetTableStr("datadir", geany->app->datadir);
+ SetTableStr("docdir", geany->app->docdir);
SetTableStr("scriptdir", glspi_script_dir);
lua_pushstring(L,"template");
glspi_template(L);
@@ -93,7 +91,7 @@ static gint glspi_appinfo(lua_State* L)
glspi_tools(L);
lua_rawset(L,1);
- if (app->project) {
+ if (geany->app->project) {
lua_pushstring(L,"project");
glspi_project(L);
lua_rawset(L,1);
Modified: geanylua/glspi_init.c
35 lines changed, 17 insertions(+), 18 deletions(-)
===================================================================
@@ -264,7 +264,8 @@ static void menu_item_activate(GtkMenuItem * menuitem, gpointer gdata)
}
-#define isblank(c) ( (c==32) || (c==9) )
+#define is_blank(c) ( (c==32) || (c==9) )
+
/*
Check if the script file begins with a special comment in the form:
@@ -282,15 +283,15 @@ static void assign_accel(GtkWidget*w, char*fn)
if (len>0) {
gchar*p1=buf;
buf[len]='\0';
- while (*p1 && isblank(*p1)) p1++;
+ while (*p1 && is_blank(*p1)) p1++;
if ( strncmp(p1,"--", 2) == 0 ) {
p1+=2;
- while (*p1 && isblank(*p1)) p1++;
+ while (*p1 && is_blank(*p1)) p1++;
if ( strncmp(p1,"@ACCEL@", 7) == 0 ) {
guint key=0;
GdkModifierType mods=0;
p1+=7;
- while (*p1 && isblank(*p1)) p1++;
+ while (*p1 && is_blank(*p1)) p1++;
if (*p1) {
gchar*p2=p1;
while ( (*p2) && (!isspace(*p2)) ) { p2++; }
@@ -408,14 +409,12 @@ static gchar *get_data_dir(void)
PLUGIN_EXPORT
void glspi_init (GeanyData *data, GeanyFunctions *functions, GeanyPlugin *plugin)
{
- GeanyApp *app = data->app;
-
glspi_geany_data = data;
glspi_geany_functions = functions;
glspi_geany_plugin = plugin;
local_data.script_dir =
- g_strconcat(app->configdir, USER_SCRIPT_FOLDER, NULL);
+ g_strconcat(geany->app->configdir, USER_SCRIPT_FOLDER, NULL);
if (!g_file_test(local_data.script_dir, G_FILE_TEST_IS_DIR)) {
gchar *datadir = get_data_dir();
@@ -424,30 +423,30 @@ void glspi_init (GeanyData *data, GeanyFunctions *functions, GeanyPlugin *plugin
g_build_path(G_DIR_SEPARATOR_S, datadir, "geany-plugins", "geanylua", NULL);
g_free(datadir);
}
- if (app->debug_mode) {
+ if (geany->app->debug_mode) {
g_printerr(_(" ==>> %s: Building menu from '%s'\n"),
PLUGIN_NAME, local_data.script_dir);
}
local_data.on_saved_script =
- g_strconcat(app->configdir, ON_SAVED_SCRIPT, NULL);
+ g_strconcat(geany->app->configdir, ON_SAVED_SCRIPT, NULL);
local_data.on_opened_script =
- g_strconcat(app->configdir, ON_OPENED_SCRIPT, NULL);
+ g_strconcat(geany->app->configdir, ON_OPENED_SCRIPT, NULL);
local_data.on_created_script =
- g_strconcat(app->configdir, ON_CREATED_SCRIPT, NULL);
+ g_strconcat(geany->app->configdir, ON_CREATED_SCRIPT, NULL);
local_data.on_activated_script =
- g_strconcat(app->configdir, ON_ACTIVATED_SCRIPT, NULL);
+ g_strconcat(geany->app->configdir, ON_ACTIVATED_SCRIPT, NULL);
local_data.on_init_script =
- g_strconcat(app->configdir, ON_INIT_SCRIPT, NULL);
+ g_strconcat(geany->app->configdir, ON_INIT_SCRIPT, NULL);
local_data.on_cleanup_script =
- g_strconcat(app->configdir, ON_CLEANUP_SCRIPT, NULL);
+ g_strconcat(geany->app->configdir, ON_CLEANUP_SCRIPT, NULL);
local_data.on_configure_script =
- g_strconcat(app->configdir, ON_CONFIGURE_SCRIPT, NULL);
+ g_strconcat(geany->app->configdir, ON_CONFIGURE_SCRIPT, NULL);
local_data.on_proj_opened_script =
- g_strconcat(app->configdir, ON_PROJ_OPENED_SCRIPT, NULL);
+ g_strconcat(geany->app->configdir, ON_PROJ_OPENED_SCRIPT, NULL);
local_data.on_proj_saved_script =
- g_strconcat(app->configdir, ON_PROJ_SAVED_SCRIPT, NULL);
+ g_strconcat(geany->app->configdir, ON_PROJ_SAVED_SCRIPT, NULL);
local_data.on_proj_closed_script =
- g_strconcat(app->configdir, ON_PROJ_CLOSED_SCRIPT, NULL);
+ g_strconcat(geany->app->configdir, ON_PROJ_CLOSED_SCRIPT, NULL);
glspi_set_sci_cmd_hash(TRUE);
glspi_set_key_cmd_hash(TRUE);
Modified: geanylua/glspi_sci.c
8 lines changed, 5 insertions(+), 3 deletions(-)
===================================================================
@@ -758,6 +758,7 @@ static gint glspi_find(lua_State* L)
gint flags=0;
gint i,n;
+ gchar *text;
DOC_REQUIRED
switch (lua_gettop(L)) {
case 0:return FAIL_STRING_ARG(1);
@@ -771,7 +772,8 @@ static gint glspi_find(lua_State* L)
if (!lua_isnumber(L,3)) { return FAIL_NUMERIC_ARG(3); }
if (!lua_istable(L,4)) { return FAIL_TABLE_ARG(4); }
- ttf.lpstrText=g_strdup(lua_tostring(L,1));
+ text=g_strdup(lua_tostring(L,1));
+ ttf.lpstrText=text;
ttf.chrg.cpMin=lua_tonumber(L,2);
ttf.chrg.cpMax=lua_tonumber(L,3);
@@ -805,10 +807,10 @@ static gint glspi_find(lua_State* L)
if (scintilla_send_message(doc->editor->sci,SCI_FINDTEXT,flags,(sptr_t)&ttf)!=-1) {
push_number(L,ttf.chrgText.cpMin);
push_number(L,ttf.chrgText.cpMax);
- g_free(ttf.lpstrText);
+ g_free(text);
return 2;
} else {
- g_free(ttf.lpstrText);
+ g_free(text);
return 0;
}
}
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list