diff options
author | 2009-07-10 21:24:37 -0400 | |
---|---|---|
committer | 2009-07-10 21:24:37 -0400 | |
commit | f0667db7c9dc5160ce7b3188544766ac6ee63618 (patch) | |
tree | d384931a0e51ae584d795e6b973ff6677bed69c1 /src/textadept.c | |
parent | e4b4d124e52ec85799f8a581f3bf968ceb431cdc (diff) | |
download | textadept-f0667db7c9dc5160ce7b3188544766ac6ee63618.tar.gz textadept-f0667db7c9dc5160ce7b3188544766ac6ee63618.zip |
Compile as C99.
Diffstat (limited to 'src/textadept.c')
-rw-r--r-- | src/textadept.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/textadept.c b/src/textadept.c index 0f52e16c..31c08448 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -1,12 +1,9 @@ // Copyright 2007-2009 Mitchell mitchell<att>caladbolg.net. See LICENSE. #include "textadept.h" -#if !(WIN32 || MAC) -#include <unistd.h> -#elif WIN32 -#include "Windows.h" -#define strcasecmp _stricmp -#else +#if WIN32 +#include <Windows.h> +#elif MAC #include <Carbon/Carbon.h> #include "ige-mac-menu.h" #define CFURL_TO_STR(u) \ @@ -85,11 +82,7 @@ static gbool c_keypress(GtkWidget *, GdkEventKey *, gpointer); */ int main(int argc, char **argv) { #if !(WIN32 || MAC) - textadept_home = malloc(FILENAME_MAX); - sprintf(textadept_home, "/proc/%i/exe", getpid()); - readlink(textadept_home, textadept_home, FILENAME_MAX); - char *last_slash = strrchr(textadept_home, '/'); - if (last_slash) *last_slash = '\0'; + textadept_home = g_file_read_link("/proc/self/exe", NULL); #elif MAC CFBundleRef bundle = CFBundleGetMainBundle(); if (bundle) { @@ -654,18 +647,12 @@ static int pm_search_equal_func(GtkTreeModel *model, int col, const char *key, */ static int pm_sort_iter_compare_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer udata) { - char *a_text, *b_text; + char *a_text, *b_text, *p; gtk_tree_model_get(model, a, 1, &a_text, -1); gtk_tree_model_get(model, b, 1, &b_text, -1); - int retval; - if (a_text == NULL && b_text == NULL) - retval = 0; - else if (a_text == NULL) - retval = -1; - else if (b_text == NULL) - retval = 1; - else - retval = strcasecmp(a_text, b_text); + if (a_text) for (p = a_text; *p != '\0'; p++) *p = g_ascii_tolower(*p); + if (b_text) for (p = b_text; *p != '\0'; p++) *p = g_ascii_tolower(*p); + int retval = g_strcmp0(a_text, b_text); g_free(a_text); g_free(b_text); return retval; |