1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into osx-functional

This commit is contained in:
James Booth 2016-07-25 00:42:00 +01:00
commit e548ce6583
7 changed files with 29 additions and 9 deletions

View File

@ -107,7 +107,7 @@ api_cons_bad_cmd_usage(const char *const cmd)
void void
api_register_command(const char *const plugin_name, const char *command_name, int min_args, int max_args, api_register_command(const char *const plugin_name, const char *command_name, int min_args, int max_args,
const char **synopsis, const char *description, const char *arguments[][2], const char **examples, char **synopsis, const char *description, char *arguments[][2], char **examples,
void *callback, void(*callback_exec)(PluginCommand *command, gchar **args), void(*callback_destroy)(void *callback)) void *callback, void(*callback_exec)(PluginCommand *command, gchar **args), void(*callback_destroy)(void *callback))
{ {
PluginCommand *command = malloc(sizeof(PluginCommand)); PluginCommand *command = malloc(sizeof(PluginCommand));

View File

@ -51,7 +51,7 @@ char* api_get_current_nick(void);
char** api_get_current_occupants(void); char** api_get_current_occupants(void);
void api_register_command(const char *const plugin_name, const char *command_name, int min_args, int max_args, void api_register_command(const char *const plugin_name, const char *command_name, int min_args, int max_args,
const char **synopsis, const char *description, const char *arguments[][2], const char **examples, char **synopsis, const char *description, char *arguments[][2], char **examples,
void *callback, void(*callback_func)(PluginCommand *command, gchar **args), void(*callback_destroy)(void *callback)); void *callback, void(*callback_func)(PluginCommand *command, gchar **args), void(*callback_destroy)(void *callback));
void api_register_timed(const char *const plugin_name, void *callback, int interval_seconds, void api_register_timed(const char *const plugin_name, void *callback, int interval_seconds,
void (*callback_func)(PluginTimedFunction *timed_function), void(*callback_destroy)(void *callback)); void (*callback_func)(PluginTimedFunction *timed_function), void(*callback_destroy)(void *callback));

View File

@ -82,7 +82,7 @@ c_api_cons_bad_cmd_usage(const char *const cmd)
static void static void
c_api_register_command(const char *filename, const char *command_name, int min_args, int max_args, c_api_register_command(const char *filename, const char *command_name, int min_args, int max_args,
const char **synopsis, const char *description, const char *arguments[][2], const char **examples, char **synopsis, const char *description, char *arguments[][2], char **examples,
void(*callback)(char **args)) void(*callback)(char **args))
{ {
char *plugin_name = _c_plugin_name(filename); char *plugin_name = _c_plugin_name(filename);

View File

@ -43,7 +43,7 @@ int (*prof_cons_show_themed)(const char *const group, const char *const item, co
int (*prof_cons_bad_cmd_usage)(const char *const cmd) = NULL; int (*prof_cons_bad_cmd_usage)(const char *const cmd) = NULL;
void (*_prof_register_command)(const char *filename, const char *command_name, int min_args, int max_args, void (*_prof_register_command)(const char *filename, const char *command_name, int min_args, int max_args,
const char **synopsis, const char *description, const char *arguments[][2], const char **examples, char **synopsis, const char *description, char *arguments[][2], char **examples,
void(*callback)(char **args)) = NULL; void(*callback)(char **args)) = NULL;
void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds) = NULL; void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds) = NULL;

View File

@ -50,7 +50,7 @@ int (*prof_cons_show_themed)(const char *const group, const char *const item, co
int (*prof_cons_bad_cmd_usage)(const char *const cmd); int (*prof_cons_bad_cmd_usage)(const char *const cmd);
void (*_prof_register_command)(const char *filename, const char *command_name, int min_args, int max_args, void (*_prof_register_command)(const char *filename, const char *command_name, int min_args, int max_args,
const char **synopsis, const char *description, const char *arguments[][2], const char **examples, char **synopsis, const char *description, char *arguments[][2], char **examples,
void(*callback)(char **args)); void(*callback)(char **args));
void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds); void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds);

View File

@ -148,7 +148,7 @@ python_api_register_command(PyObject *self, PyObject *args)
if (p_callback && PyCallable_Check(p_callback)) { if (p_callback && PyCallable_Check(p_callback)) {
Py_ssize_t len = PyList_Size(synopsis); Py_ssize_t len = PyList_Size(synopsis);
const char *c_synopsis[len == 0 ? 0 : len+1]; char *c_synopsis[len == 0 ? 0 : len+1];
Py_ssize_t i = 0; Py_ssize_t i = 0;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
PyObject *item = PyList_GetItem(synopsis, i); PyObject *item = PyList_GetItem(synopsis, i);
@ -158,7 +158,7 @@ python_api_register_command(PyObject *self, PyObject *args)
c_synopsis[len] = NULL; c_synopsis[len] = NULL;
Py_ssize_t args_len = PyList_Size(arguments); Py_ssize_t args_len = PyList_Size(arguments);
const char *c_arguments[args_len == 0 ? 0 : args_len+1][2]; char *c_arguments[args_len == 0 ? 0 : args_len+1][2];
i = 0; i = 0;
for (i = 0; i < args_len; i++) { for (i = 0; i < args_len; i++) {
PyObject *item = PyList_GetItem(arguments, i); PyObject *item = PyList_GetItem(arguments, i);
@ -179,7 +179,7 @@ python_api_register_command(PyObject *self, PyObject *args)
c_arguments[args_len][1] = NULL; c_arguments[args_len][1] = NULL;
len = PyList_Size(examples); len = PyList_Size(examples);
const char *c_examples[len == 0 ? 0 : len+1]; char *c_examples[len == 0 ? 0 : len+1];
i = 0; i = 0;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
PyObject *item = PyList_GetItem(examples, i); PyObject *item = PyList_GetItem(examples, i);
@ -193,6 +193,20 @@ python_api_register_command(PyObject *self, PyObject *args)
description_str, c_arguments, c_examples, p_callback, python_command_callback, NULL); description_str, c_arguments, c_examples, p_callback, python_command_callback, NULL);
free(command_name_str); free(command_name_str);
free(description_str); free(description_str);
i = 0;
while (c_synopsis[i] != NULL) {
free(c_synopsis[i++]);
}
i = 0;
while (c_arguments[i] != NULL && c_arguments[i][0] != NULL) {
free(c_arguments[i][0]);
free(c_arguments[i][1]);
i++;
}
i = 0;
while (c_examples[i] != NULL) {
free(c_examples[i++]);
}
disable_python_threads(); disable_python_threads();
} }
@ -254,6 +268,10 @@ python_api_completer_add(PyObject *self, PyObject *args)
allow_python_threads(); allow_python_threads();
api_completer_add(plugin_name, key_str, c_items); api_completer_add(plugin_name, key_str, c_items);
free(key_str); free(key_str);
i = 0;
while (c_items[i] != NULL) {
free(c_items[i++]);
}
disable_python_threads(); disable_python_threads();
free(plugin_name); free(plugin_name);
@ -993,8 +1011,9 @@ _python_plugin_name(void)
{ {
PyThreadState *ts = PyThreadState_Get(); PyThreadState *ts = PyThreadState_Get();
PyFrameObject *frame = ts->frame; PyFrameObject *frame = ts->frame;
char const* filename = python_str_or_unicode_to_string(frame->f_code->co_filename); char* filename = python_str_or_unicode_to_string(frame->f_code->co_filename);
gchar **split = g_strsplit(filename, "/", 0); gchar **split = g_strsplit(filename, "/", 0);
free(filename);
char *plugin_name = strdup(split[g_strv_length(split)-1]); char *plugin_name = strdup(split[g_strv_length(split)-1]);
g_strfreev(split); g_strfreev(split);

View File

@ -81,6 +81,7 @@ _get_icons(void)
char *icons_dir_s = files_get_config_path(DIR_ICONS); char *icons_dir_s = files_get_config_path(DIR_ICONS);
icons_dir = g_string_new(icons_dir_s); icons_dir = g_string_new(icons_dir_s);
free(icons_dir_s);
GError *err = NULL; GError *err = NULL;
if (!g_file_test(icons_dir->str, G_FILE_TEST_IS_DIR)) { if (!g_file_test(icons_dir->str, G_FILE_TEST_IS_DIR)) {
return; return;