aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile2
-rw-r--r--src/lua_interface.c3
-rw-r--r--src/textadept.c29
3 files changed, 10 insertions, 24 deletions
diff --git a/src/Makefile b/src/Makefile
index e7680839..07adba53 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -22,7 +22,7 @@ LUA_OBJS = lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
all: textadept
.c.o:
- gcc $(GTKFLAGS) $(INCLUDEDIRS) $(CXXFLAGS) -c $< -o $@
+ gcc -std=c99 $(GTKFLAGS) $(INCLUDEDIRS) $(CXXFLAGS) -c $< -o $@
$(LUA_OBJS): lua/src/*.c
gcc $(INCLUDEDIRS) -DLUA_USE_LINUX -c lua/src/*.c
gcocoadialog.o: gcocoadialog/gcocoadialog.c
diff --git a/src/lua_interface.c b/src/lua_interface.c
index 5b680956..58a237fe 100644
--- a/src/lua_interface.c
+++ b/src/lua_interface.c
@@ -1244,12 +1244,11 @@ static int l_cf_view_goto_buffer(lua_State *lua) {
static int l_cf_ta_dialog(lua_State *lua) {
GCDialogType type = gcocoadialog_type(luaL_checkstring(lua, 1));
int i, argc = lua_gettop(lua) - 1;
- const char **argv = malloc(argc * sizeof(char *));
+ const char *argv[argc];
for (i = 0; i < argc; i++) argv[i] = luaL_checkstring(lua, i + 2);
char *out = gcocoadialog(type, argc, argv);
lua_pushstring(lua, out);
free(out);
- free(argv);
return 1;
}
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;