From f0667db7c9dc5160ce7b3188544766ac6ee63618 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Fri, 10 Jul 2009 21:24:37 -0400 Subject: Compile as C99. --- src/textadept.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'src/textadept.c') 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 mitchellcaladbolg.net. See LICENSE. #include "textadept.h" -#if !(WIN32 || MAC) -#include -#elif WIN32 -#include "Windows.h" -#define strcasecmp _stricmp -#else +#if WIN32 +#include +#elif MAC #include #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; -- cgit v1.2.3