Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Various fixes #4

Merged
merged 5 commits into from

2 participants

@b4n

No description provided.

b4n added some commits
@b4n b4n Fix a few missing return values 7e9895f
@b4n b4n Always use literals as the format argument for printf-style functions
Passing a string literal as the format argument of a printf-style
function allows some compilers (GCC) to check the format and the
format's arguments.  This helps at spotting missing arguments or
incorrect formats which could be security issues (if e.g. reading
uninitialized memory).
41a402f
@b4n b4n Fix for a few ISO C violations
1) ISO C does not allows extra `;` outside of a function;
2) ISO C99 requires the ... in a variadic macro to be used.
846ccdb
@b4n b4n Remove a few unused variables f883acb
@b4n b4n Small indentation fix 51334a0
@codebrainz codebrainz merged commit 51334a0 into from
@codebrainz
Owner

Thanks dude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 22, 2012
  1. @b4n

    Fix a few missing return values

    b4n authored
  2. @b4n

    Always use literals as the format argument for printf-style functions

    b4n authored
    Passing a string literal as the format argument of a printf-style
    function allows some compilers (GCC) to check the format and the
    format's arguments.  This helps at spotting missing arguments or
    incorrect formats which could be security issues (if e.g. reading
    uninitialized memory).
  3. @b4n

    Fix for a few ISO C violations

    b4n authored
    1) ISO C does not allows extra `;` outside of a function;
    2) ISO C99 requires the ... in a variadic macro to be used.
  4. @b4n

    Remove a few unused variables

    b4n authored
  5. @b4n

    Small indentation fix

    b4n authored
This page is out of date. Refresh to see the latest.
Showing with 90 additions and 91 deletions.
  1. +4 −5 src/plugin.c
  2. +1 −2  src/zen-controller.c
  3. +85 −84 src/zen-editor.c
View
9 src/plugin.c
@@ -58,7 +58,7 @@ PLUGIN_VERSION_CHECK(200)
PLUGIN_SET_INFO(_("Zen Coding"),
_("Zen Coding plugin for Geany"),
"1.0",
- "Matthew Brush <mbrush@codebrainz.ca>");
+ "Matthew Brush <mbrush@codebrainz.ca>")
static struct ZenCodingPlugin
@@ -150,7 +150,7 @@ static void action_activate(guint key_id)
}
-static guint on_action_item_activate(GObject *object, gpointer id_ptr)
+static void on_action_item_activate(GObject *object, gpointer id_ptr)
{
gint id = GPOINTER_TO_INT(id_ptr);
ZenCodingAction action;
@@ -335,7 +335,7 @@ static void reload_zen_coding_notice(const gchar *msg)
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
- msg, NULL);
+ "%s", msg);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
@@ -444,8 +444,7 @@ static void recursively_copy(const char *src, const char *dst)
static void init_config(struct ZenCodingPlugin *plugin)
{
- gint i;
- gchar *tmp, *settings, *sys_path, *user_path, *code = NULL;
+ gchar *tmp, *settings, *sys_path;
g_free(plugin->config_dir);
plugin->config_dir = g_build_filename(geany->app->configdir, "plugins", "zencoding", NULL);
View
3  src/zen-controller.c
@@ -69,7 +69,7 @@ ZenController *zen_controller_new(const char *zendir, const char *profiles_dir)
{
ZenController *result;
char zen_path[PATH_MAX + 20] = { 0 };
- PyObject *module, *cls;
+ PyObject *module, *cls, *res;
result = malloc(sizeof(ZenController));
result->editor = NULL;
@@ -201,7 +201,6 @@ ZenController *zen_controller_new(const char *zendir, const char *profiles_dir)
}
/* Initialize/setup profiles */
- PyObject *res;
res = PyObject_CallMethod(result->editor, "init_profiles", "(s)", profiles_dir);
if (res == NULL)
{
View
169 src/zen-editor.c
@@ -56,12 +56,12 @@ static void _debug_print(const char *file, int line, const char *function, const
g_free(format);
}
-#define dbg(fmt, ...) _debug_print(__FILE__, __LINE__, NULL, fmt, ##__VA_ARGS__)
-#define dbgf(fmt, ...) _debug_print(__FILE__, __LINE__, __FUNCTION__, fmt, ##__VA_ARGS__)
+#define dbg(...) _debug_print(__FILE__, __LINE__, NULL, __VA_ARGS__)
+#define dbgf(...) _debug_print(__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
#define print_called() _debug_print(__FILE__, __LINE__, __FUNCTION__, "%s", "called")
#else
-#define dbg(fmt, ...)
-#define dbgf(fmt, ...)
+#define dbg(...)
+#define dbgf(...)
#define print_called()
#endif
@@ -286,7 +286,6 @@ ZenEditor_replace_caret_placeholder(const gchar *placeholder,
static gchar *
ZenEditor_replace_range(const gchar *text)
{
- gint ret;
gchar *start_str, *end_str;
gchar *repl;
regex_t re;
@@ -325,9 +324,8 @@ ZenEditor_replace_range(const gchar *text)
static PyObject *
ZenEditor_replace_content(ZenEditor *self, PyObject *args)
{
- PyObject *result;
gint sel_start = -1, sel_end = -1, ph_pos;
- gchar *text, *ph, *tmp, *tmp2;
+ gchar *text, *tmp, *tmp2;
ScintillaObject *sci;
print_called();
@@ -442,7 +440,8 @@ ZenEditor_prompt(ZenEditor *self, PyObject *args)
{
PyObject *result;
GtkWidget *dialog, *input, *content_area, *vbox;
- gchar *abbr = NULL, *title = NULL;
+ gchar *abbr = NULL;
+ const gchar *title = NULL;
print_called();
@@ -571,42 +570,42 @@ ZenEditor_init_profiles(ZenEditor *self, PyObject *args)
gint result = -1;
gchar *profiles_dir = NULL, *runcode = NULL;
static gboolean has_run = 0;
- static const gchar *runfmt =
- "import os\n"
- "from ConfigParser import SafeConfigParser\n"
- "import zencoding.utils\n"
- "for cfg_file in os.listdir('%s'):\n"
- " if cfg_file.endswith('.conf'):\n"
- " cfg_file = os.path.join('%s', cfg_file)\n"
- " p = SafeConfigParser()\n"
- " p.read(cfg_file)\n"
- " if p.has_section('profile') and p.has_option('profile', 'name'):\n"
- " d = {}\n"
- " name = p.get('profile', 'name')\n"
- " if not name: continue\n"
- " if p.has_option('profile', 'tag_case'):\n"
- " d['case'] = p.get('profile', 'tag_case').lower()\n"
- " if p.has_option('profile', 'attr_case'):\n"
- " d['attr_case'] = p.get('profile', 'attr_case').lower()\n"
- " if p.has_option('profile', 'attr_quotes'):\n"
- " d['attr_quotes'] = p.get('profile', 'attr_quotes').lower()\n"
- " if p.has_option('profile', 'tag_nl'):\n"
- " if p.get('profile', 'tag_nl').lower() == 'decide':\n"
- " d['tag_nl'] = 'decide'\n"
- " else:\n"
- " d['tag_nl'] = p.getboolean('profile', 'tag_nl')\n"
- " if p.has_option('profile', 'place_cursor'):\n"
- " d['place_cursor'] = p.getboolean('profile', 'place_cursor')\n"
- " if p.has_option('profile', 'indent'):\n"
- " d['indent'] = p.getboolean('profile', 'indent')\n"
- " if p.has_option('profile', 'self_closing_tag'):\n"
- " if p.get('profile', 'self_closing_tag').lower() == 'xhtml':\n"
- " d['self_closing_tag'] = 'xhtml'\n"
- " else:\n"
- " d['self_closing_tag'] = p.getboolean('profile', \n"
- " 'self_closing_tag')\n"
- " d['filters'] = None\n"
- " zencoding.utils.setup_profile(name, d)\n";
+#define RUNFMT \
+ "import os\n" \
+ "from ConfigParser import SafeConfigParser\n" \
+ "import zencoding.utils\n" \
+ "for cfg_file in os.listdir('%s'):\n" \
+ " if cfg_file.endswith('.conf'):\n" \
+ " cfg_file = os.path.join('%s', cfg_file)\n" \
+ " p = SafeConfigParser()\n" \
+ " p.read(cfg_file)\n" \
+ " if p.has_section('profile') and p.has_option('profile', 'name'):\n" \
+ " d = {}\n" \
+ " name = p.get('profile', 'name')\n" \
+ " if not name: continue\n" \
+ " if p.has_option('profile', 'tag_case'):\n" \
+ " d['case'] = p.get('profile', 'tag_case').lower()\n" \
+ " if p.has_option('profile', 'attr_case'):\n" \
+ " d['attr_case'] = p.get('profile', 'attr_case').lower()\n" \
+ " if p.has_option('profile', 'attr_quotes'):\n" \
+ " d['attr_quotes'] = p.get('profile', 'attr_quotes').lower()\n" \
+ " if p.has_option('profile', 'tag_nl'):\n" \
+ " if p.get('profile', 'tag_nl').lower() == 'decide':\n" \
+ " d['tag_nl'] = 'decide'\n" \
+ " else:\n" \
+ " d['tag_nl'] = p.getboolean('profile', 'tag_nl')\n" \
+ " if p.has_option('profile', 'place_cursor'):\n" \
+ " d['place_cursor'] = p.getboolean('profile', 'place_cursor')\n" \
+ " if p.has_option('profile', 'indent'):\n" \
+ " d['indent'] = p.getboolean('profile', 'indent')\n" \
+ " if p.has_option('profile', 'self_closing_tag'):\n" \
+ " if p.get('profile', 'self_closing_tag').lower() == 'xhtml':\n" \
+ " d['self_closing_tag'] = 'xhtml'\n" \
+ " else:\n" \
+ " d['self_closing_tag'] = p.getboolean('profile', \n" \
+ " 'self_closing_tag')\n" \
+ " d['filters'] = None\n" \
+ " zencoding.utils.setup_profile(name, d)\n"
print_called();
@@ -617,7 +616,7 @@ ZenEditor_init_profiles(ZenEditor *self, PyObject *args)
{
py_return_none_if_null(profiles_dir);
- runcode = g_strdup_printf(runfmt, profiles_dir, profiles_dir);
+ runcode = g_strdup_printf(RUNFMT, profiles_dir, profiles_dir);
result = PyRun_SimpleString(runcode);
g_free(runcode);
}
@@ -629,6 +628,8 @@ ZenEditor_init_profiles(ZenEditor *self, PyObject *args)
}
Py_RETURN_FALSE;
+
+#undef RUNFMT
}
@@ -782,44 +783,44 @@ static PyMemberDef ZenEditor_members[] = {
static PyTypeObject ZenEditorType = {
PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "geany.ZenEditor", /*tp_name*/
- sizeof(ZenEditor), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)ZenEditor_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash */
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
- "Zen Coding ZenEditor", /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- ZenEditor_methods, /* tp_methods */
- ZenEditor_members, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)ZenEditor_init, /* tp_init */
- 0, /* tp_alloc */
- ZenEditor_new, /* tp_new */
+ 0, /*ob_size*/
+ "geany.ZenEditor", /*tp_name*/
+ sizeof(ZenEditor), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)ZenEditor_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+ "Zen Coding ZenEditor", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ ZenEditor_methods, /* tp_methods */
+ ZenEditor_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ZenEditor_init, /* tp_init */
+ 0, /* tp_alloc */
+ ZenEditor_new, /* tp_new */
};
@@ -832,7 +833,7 @@ PyObject *zen_editor_module_init(void)
ZenEditorType.tp_new = PyType_GenericNew;
if (PyType_Ready(&ZenEditorType) < 0)
- return;
+ return NULL;
m = Py_InitModule3("geany", Module_methods, "Geany Zen Coding module");
Something went wrong with that request. Please try again.