diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2013-03-18 16:56:14 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2013-03-18 16:56:14 +0100 |
commit | 9f6bfcaf9985dd9f6911c95b5df95e1d72a63f0f (patch) | |
tree | 2a9984e56e95b822d38d638f12659944c86de0fe | |
parent | 9886eaf7fd5170bb037df177848c6b5c7df745c2 (diff) | |
download | sciteco-9f6bfcaf9985dd9f6911c95b5df95e1d72a63f0f.tar.gz |
make sure a (void*)0 is used as sentinels
since including glib.h on LLVM-Clang (32-bit) results in NULL being
redefined to 0 and compiler warnings being emitted when NULL is used
as sentinels
-rw-r--r-- | src/cmdline.cpp | 4 | ||||
-rw-r--r-- | src/interface-ncurses.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | src/ring.cpp | 6 | ||||
-rw-r--r-- | src/sciteco.h | 8 | ||||
-rw-r--r-- | src/search.cpp | 6 |
6 files changed, 18 insertions, 12 deletions
diff --git a/src/cmdline.cpp b/src/cmdline.cpp index e0be9cf..c6dcf2a 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -364,12 +364,12 @@ filename_complete(const gchar *filename, gchar completed) *dirname = '\0'; while ((basename = (gchar *)g_dir_read_name(dir))) { - gchar *filename = g_build_filename(dirname, basename, NULL); + gchar *filename = g_build_filename(dirname, basename, NIL); if (g_file_test(filename, G_FILE_TEST_IS_DIR)) { gchar *new_filename; new_filename = g_strconcat(filename, - G_DIR_SEPARATOR_S, NULL); + G_DIR_SEPARATOR_S, NIL); g_free(filename); filename = new_filename; } diff --git a/src/interface-ncurses.cpp b/src/interface-ncurses.cpp index e078005..639c594 100644 --- a/src/interface-ncurses.cpp +++ b/src/interface-ncurses.cpp @@ -257,7 +257,7 @@ InterfaceNCurses::popup_add(PopupEntryType type __attribute__((unused)), if (isendwin()) /* batch mode */ return; - entry = g_strconcat(highlight ? "*" : " ", name, NULL); + entry = g_strconcat(highlight ? "*" : " ", name, NIL); popup.longest = MAX(popup.longest, (gint)strlen(name)); popup.length++; diff --git a/src/main.cpp b/src/main.cpp index e0d573b..968b816 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -101,7 +101,7 @@ static inline gchar * get_teco_ini(const gchar *program) { gchar *bin_dir = g_path_get_dirname(program); - gchar *ini = g_build_filename(bin_dir, INI_FILE, NULL); + gchar *ini = g_build_filename(bin_dir, INI_FILE, NIL); g_free(bin_dir); return ini; } @@ -118,7 +118,7 @@ get_teco_ini(const gchar *program __attribute__((unused))) #else home = g_get_user_config_dir(); #endif - return g_build_filename(home, INI_FILE, NULL); + return g_build_filename(home, INI_FILE, NIL); } #endif /* !G_OS_WIN32 */ diff --git a/src/ring.cpp b/src/ring.cpp index 1715559..c082381 100644 --- a/src/ring.cpp +++ b/src/ring.cpp @@ -349,7 +349,7 @@ make_savepoint(Buffer *buffer) ".teco-%s-%d", basename, buffer->savepoint_id); g_free(basename); dirname = g_path_get_dirname(buffer->filename); - savepoint = g_build_filename(dirname, savepoint_basename, NULL); + savepoint = g_build_filename(dirname, savepoint_basename, NIL); g_free(dirname); if (!g_rename(buffer->filename, savepoint)) { @@ -529,7 +529,7 @@ get_absolute_path(const gchar *path) resolved = g_strdup(path); } else { gchar *cwd = g_get_current_dir(); - resolved = g_build_filename(cwd, path, NULL); + resolved = g_build_filename(cwd, path, NIL); g_free(cwd); } } else { @@ -690,7 +690,7 @@ StateEditFile::done(const gchar *str) throw (Error) filename = g_build_filename(dirname, basename, - NULL); + NIL); do_edit(filename); g_free(filename); } diff --git a/src/sciteco.h b/src/sciteco.h index f22842c..b7f92fd 100644 --- a/src/sciteco.h +++ b/src/sciteco.h @@ -46,6 +46,12 @@ namespace Flags { extern sig_atomic_t sigint_occurred; +/* + * for sentinels: NULL might not be defined as a + * pointer type (LLVM/CLang) + */ +#define NIL ((void *)0) + #define INIT_PRIO(X) __attribute__((init_priority(X))) #define PRIO_INTERFACE 1000 #define PRIO_SYMBOLS 1000 @@ -69,7 +75,7 @@ static inline void append(gchar *&str1, const gchar *str2) { /* FIXME: optimize */ - gchar *new_str = g_strconcat(str1 ? : "", str2, NULL); + gchar *new_str = g_strconcat(str1 ? : "", str2, NIL); g_free(str1); str1 = new_str; } diff --git a/src/search.cpp b/src/search.cpp index de16b4f..7562096 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -250,7 +250,7 @@ StateSearch::pattern2regexp(const gchar *&pattern, temp = class2regexp(state, pattern); if (temp) { - new_re = g_strconcat(re ? : "", "[", temp, "]", NULL); + new_re = g_strconcat(re ? : "", "[", temp, "]", NIL); g_free(temp); g_free(re); re = new_re; @@ -275,7 +275,7 @@ StateSearch::pattern2regexp(const gchar *&pattern, temp = class2regexp(state, pattern, true); if (!temp) goto error; - new_re = g_strconcat(re ? : "", "[^", temp, "]", NULL); + new_re = g_strconcat(re ? : "", "[^", temp, "]", NIL); g_free(temp); g_free(re); re = new_re; @@ -303,7 +303,7 @@ StateSearch::pattern2regexp(const gchar *&pattern, temp = pattern2regexp(pattern, true); if (!temp) goto error; - new_re = g_strconcat(re ? : "", "(", temp, ")+", NULL); + new_re = g_strconcat(re ? : "", "(", temp, ")+", NIL); g_free(temp); g_free(re); re = new_re; |