From a28a4733c40fbe3e686c14f238faec2e6c559169 Mon Sep 17 00:00:00 2001 From: Vinyl Darkscratch Date: Mon, 5 Mar 2018 14:10:47 -0800 Subject: [PATCH] Reduce warning count --- binding-mri/binding-util.h | 2 +- src/eventthread.cpp | 2 +- src/oneshot.cpp | 283 +++++++++++++++++++------------------ src/settingsmenu.cpp | 4 +- 4 files changed, 146 insertions(+), 145 deletions(-) diff --git a/binding-mri/binding-util.h b/binding-mri/binding-util.h index 83589f7..915c6d6 100644 --- a/binding-mri/binding-util.h +++ b/binding-mri/binding-util.h @@ -90,7 +90,7 @@ raiseRbExc(const Exception &exc); template static VALUE classAllocate(VALUE klass) { - return rb_data_typed_object_alloc(klass, 0, rbType); + return rb_data_typed_object_wrap(klass, 0, rbType); } template diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 4fb6349..ab1cd75 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -283,7 +283,7 @@ void EventThread::process(RGSSThreadData &rtData) break; case SDL_TEXTINPUT: - if (rtData.inputText.length() < rtData.inputTextLimit) rtData.inputText += event.text.text; + if (rtData.inputText.length() < (size_t)(rtData.inputTextLimit)) rtData.inputText += event.text.text; break; case SDL_KEYDOWN : diff --git a/src/oneshot.cpp b/src/oneshot.cpp index dbda57f..95a2242 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -68,148 +68,148 @@ GTK_RESPONSE_APPLY = -10, GTK_RESPONSE_HELP = -11 } GtkResponseType; + + /** + * xdg_user_dir_lookup_with_fallback: + * @type: a string specifying the type of directory + * @fallback: value to use if the directory isn't specified by the user + * @returns: a newly allocated absolute pathname + * + * Looks up a XDG user directory of the specified type. + * Example of types are "DESKTOP" and "DOWNLOAD". + * + * In case the user hasn't specified any directory for the specified + * type the value returned is @fallback. + * + * The return value is newly allocated and must be freed with + * free(). The return value is never NULL if @fallback != NULL, unless + * out of memory. + **/ + static char * + xdg_user_dir_lookup_with_fallback (const char *type, const char *fallback) + { + FILE *file; + char *home_dir, *config_home, *config_file; + char buffer[512]; + char *user_dir; + char *p, *d; + int len; + int relative; + + home_dir = getenv ("HOME"); + + if (home_dir == NULL) + goto error; + + config_home = getenv ("XDG_CONFIG_HOME"); + if (config_home == NULL || config_home[0] == 0) + { + config_file = (char*) malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1); + if (config_file == NULL) + goto error; + + strcpy (config_file, home_dir); + strcat (config_file, "/.config/user-dirs.dirs"); + } + else + { + config_file = (char*) malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1); + if (config_file == NULL) + goto error; + + strcpy (config_file, config_home); + strcat (config_file, "/user-dirs.dirs"); + } + + file = fopen (config_file, "r"); + free (config_file); + if (file == NULL) + goto error; + + user_dir = NULL; + while (fgets (buffer, sizeof (buffer), file)) + { + /* Remove newline at end */ + len = strlen (buffer); + if (len > 0 && buffer[len-1] == '\n') + buffer[len-1] = 0; + + p = buffer; + while (*p == ' ' || *p == '\t') + p++; + + if (strncmp (p, "XDG_", 4) != 0) + continue; + p += 4; + if (strncmp (p, type, strlen (type)) != 0) + continue; + p += strlen (type); + if (strncmp (p, "_DIR", 4) != 0) + continue; + p += 4; + + while (*p == ' ' || *p == '\t') + p++; + + if (*p != '=') + continue; + p++; + + while (*p == ' ' || *p == '\t') + p++; + + if (*p != '"') + continue; + p++; + + relative = 0; + if (strncmp (p, "$HOME/", 6) == 0) + { + p += 6; + relative = 1; + } + else if (*p != '/') + continue; + + if (relative) + { + user_dir = (char*) malloc (strlen (home_dir) + 1 + strlen (p) + 1); + if (user_dir == NULL) + goto error2; + + strcpy (user_dir, home_dir); + strcat (user_dir, "/"); + } + else + { + user_dir = (char*) malloc (strlen (p) + 1); + if (user_dir == NULL) + goto error2; + + *user_dir = 0; + } + + d = user_dir + strlen (user_dir); + while (*p && *p != '"') + { + if ((*p == '\\') && (*(p+1) != 0)) + p++; + *d++ = *p++; + } + *d = 0; + } + error2: + fclose (file); + + if (user_dir) + return user_dir; + + error: + if (fallback) + return strdup (fallback); + return NULL; + } #endif - - /** - * xdg_user_dir_lookup_with_fallback: - * @type: a string specifying the type of directory - * @fallback: value to use if the directory isn't specified by the user - * @returns: a newly allocated absolute pathname - * - * Looks up a XDG user directory of the specified type. - * Example of types are "DESKTOP" and "DOWNLOAD". - * - * In case the user hasn't specified any directory for the specified - * type the value returned is @fallback. - * - * The return value is newly allocated and must be freed with - * free(). The return value is never NULL if @fallback != NULL, unless - * out of memory. - **/ - static char * - xdg_user_dir_lookup_with_fallback (const char *type, const char *fallback) - { - FILE *file; - char *home_dir, *config_home, *config_file; - char buffer[512]; - char *user_dir; - char *p, *d; - int len; - int relative; - - home_dir = getenv ("HOME"); - - if (home_dir == NULL) - goto error; - - config_home = getenv ("XDG_CONFIG_HOME"); - if (config_home == NULL || config_home[0] == 0) - { - config_file = (char*) malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1); - if (config_file == NULL) - goto error; - - strcpy (config_file, home_dir); - strcat (config_file, "/.config/user-dirs.dirs"); - } - else - { - config_file = (char*) malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1); - if (config_file == NULL) - goto error; - - strcpy (config_file, config_home); - strcat (config_file, "/user-dirs.dirs"); - } - - file = fopen (config_file, "r"); - free (config_file); - if (file == NULL) - goto error; - - user_dir = NULL; - while (fgets (buffer, sizeof (buffer), file)) - { - /* Remove newline at end */ - len = strlen (buffer); - if (len > 0 && buffer[len-1] == '\n') - buffer[len-1] = 0; - - p = buffer; - while (*p == ' ' || *p == '\t') - p++; - - if (strncmp (p, "XDG_", 4) != 0) - continue; - p += 4; - if (strncmp (p, type, strlen (type)) != 0) - continue; - p += strlen (type); - if (strncmp (p, "_DIR", 4) != 0) - continue; - p += 4; - - while (*p == ' ' || *p == '\t') - p++; - - if (*p != '=') - continue; - p++; - - while (*p == ' ' || *p == '\t') - p++; - - if (*p != '"') - continue; - p++; - - relative = 0; - if (strncmp (p, "$HOME/", 6) == 0) - { - p += 6; - relative = 1; - } - else if (*p != '/') - continue; - - if (relative) - { - user_dir = (char*) malloc (strlen (home_dir) + 1 + strlen (p) + 1); - if (user_dir == NULL) - goto error2; - - strcpy (user_dir, home_dir); - strcat (user_dir, "/"); - } - else - { - user_dir = (char*) malloc (strlen (p) + 1); - if (user_dir == NULL) - goto error2; - - *user_dir = 0; - } - - d = user_dir + strlen (user_dir); - while (*p && *p != '"') - { - if ((*p == '\\') && (*(p+1) != 0)) - p++; - *d++ = *p++; - } - *d = 0; - } - error2: - fclose (file); - - if (user_dir) - return user_dir; - - error: - if (fallback) - return strdup (fallback); - return NULL; - } #else #error "Operating system not detected." #endif @@ -949,6 +949,7 @@ std::string Oneshot::textinput(const char* prompt, int char_limit, const char* f // gInputTextTexture.loadFromRenderedText(threadData.inputText.c_str(), textColor, gRenderer, gFont); std::vector *fontNames = new std::vector(); + fontNames->push_back(fontName); fontNames->push_back("VL Gothic"); Font *font = new Font(fontNames, 18); diff --git a/src/settingsmenu.cpp b/src/settingsmenu.cpp index a874aae..d889f03 100644 --- a/src/settingsmenu.cpp +++ b/src/settingsmenu.cpp @@ -1099,8 +1099,8 @@ SettingsMenu::SettingsMenu(RGSSThreadData &rtData) const int bWidgetH = 64; const int bWidgetY = winSize.y - layoutH*bWidgetH - 48; - for (int y = 0; y < layoutH; ++y) - for (int x = 0; x < layoutW; ++x) + for (int y = 0; y < (int)(layoutH); ++y) + for (int x = 0; x < (int)(layoutW); ++x) { int i = x*layoutH+y; BindingWidget w(i, p, IntRect(x*bWidgetW, bWidgetY+y*bWidgetH,