diff options
author | Tor Lillqvist <tml@novell.com> | 2005-11-26 11:51:16 +0800 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2005-11-26 11:51:16 +0800 |
commit | 18c08853768cc4cae9125aaf185268b90a0f23cf (patch) | |
tree | 611bfb0f360ffa8f3100d038d97df56c628055a1 | |
parent | 9fa1e996bc1a3249c0d5ee59752f7117a490d40d (diff) | |
download | gsoc2013-evolution-18c08853768cc4cae9125aaf185268b90a0f23cf.tar gsoc2013-evolution-18c08853768cc4cae9125aaf185268b90a0f23cf.tar.gz gsoc2013-evolution-18c08853768cc4cae9125aaf185268b90a0f23cf.tar.bz2 gsoc2013-evolution-18c08853768cc4cae9125aaf185268b90a0f23cf.tar.lz gsoc2013-evolution-18c08853768cc4cae9125aaf185268b90a0f23cf.tar.xz gsoc2013-evolution-18c08853768cc4cae9125aaf185268b90a0f23cf.tar.zst gsoc2013-evolution-18c08853768cc4cae9125aaf185268b90a0f23cf.zip |
Use g_get_tmp_dir() instead of hardcoding /tmp.
2005-11-26 Tor Lillqvist <tml@novell.com>
* e-menu.c (emph_construct_menu): Use g_get_tmp_dir() instead of
hardcoding /tmp.
* e-util.c (e_strstrcase): Use g_ascii_strncasecmp() instead of
the deprecated g_strncasecmp(). What kinds of strings this
function is supposed to be used on (UTF-8 or some random single-
or multi-byte encoding) is anybody's guess. This function isn't
used in Evolution and should probably go away, though. And this is
one of the files that have a partially duplicated copy in
e-d-s/libedataserver, too, so doubly so.
(e_filename_make_safe): Mark more bytes as unsafe on Win32. Add
comments. This function is really under-specified and weird, one
wonders whether it really does what the author thought it should
do.
(fsync): Add Win32 implementation of fsync().
* e-xml-utils.c (e_xml_get_bool_prop_by_name_with_default): Use
g_ascii_strcasecmp() instead of the deprecated g_strcasecmp(),
especially as we are comparing to literal ASCII strings.
svn path=/trunk/; revision=30684
-rw-r--r-- | e-util/ChangeLog | 20 | ||||
-rw-r--r-- | e-util/e-menu.c | 2 | ||||
-rw-r--r-- | e-util/e-util.c | 59 | ||||
-rw-r--r-- | e-util/e-xml-utils.c | 8 |
4 files changed, 80 insertions, 9 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 15396534e3..fe3b5357a0 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -3,6 +3,26 @@ * e-dialog-utils.c * e-gtk-utils.c: Conditionalize X11 specific code on GDK_WINDOWING_X11. + * e-menu.c (emph_construct_menu): Use g_get_tmp_dir() instead of + hardcoding /tmp. + + * e-util.c (e_strstrcase): Use g_ascii_strncasecmp() instead of + the deprecated g_strncasecmp(). What kinds of strings this + function is supposed to be used on (UTF-8 or some random single- + or multi-byte encoding) is anybody's guess. This function isn't + used in Evolution and should probably go away, though. And this is + one of the files that have a partially duplicated copy in + e-d-s/libedataserver, too, so doubly so. + (e_filename_make_safe): Mark more bytes as unsafe on Win32. Add + comments. This function is really under-specified and weird, one + wonders whether it really does what the author thought it should + do. + (fsync): Add Win32 implementation of fsync(). + + * e-xml-utils.c (e_xml_get_bool_prop_by_name_with_default): Use + g_ascii_strcasecmp() instead of the deprecated g_strcasecmp(), + especially as we are comparing to literal ASCII strings. + 2005-11-25 Tor Lillqvist <tml@novell.com> * e-util-private.h: Sort the stuff in the Win32 part for diff --git a/e-util/e-menu.c b/e-util/e-menu.c index 68c1f65c5e..7ed8b12483 100644 --- a/e-util/e-menu.c +++ b/e-util/e-menu.c @@ -785,7 +785,7 @@ emph_construct_menu(EPluginHook *eph, xmlNodePtr root) EMenuUIFile *ui = g_malloc0(sizeof(*ui)); ui->filename = tmp; - ui->appdir = g_strdup("/tmp"); + ui->appdir = g_strdup(g_get_tmp_dir()); ui->appname = g_strdup("Evolution"); menu->uis = g_slist_append(menu->uis, ui); } diff --git a/e-util/e-util.c b/e-util/e-util.c index bf4fe6292b..f1444a2a64 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -40,6 +40,10 @@ #include <gtk/gtk.h> #include <libgnome/gnome-util.h> +#ifdef G_OS_WIN32 +#include <windows.h> +#endif + #include "e-i18n.h" #include "e-util.h" #include "e-util-private.h" @@ -432,18 +436,35 @@ e_strstrcase (const gchar *haystack, const gchar *needle) return (gchar *) haystack; for (ptr = haystack; *(ptr + len - 1) != '\0'; ptr++) - if (!g_strncasecmp (ptr, needle, len)) + if (!g_ascii_strncasecmp (ptr, needle, len)) return (gchar *) ptr; return NULL; } /* This only makes a filename safe for usage as a filename. It still may have shell meta-characters in it. */ + +/* This code is rather misguided and mostly pointless, but can't be + * changed because of backward compatibility, I guess. + * + * It replaces some perfectly safe characters like '%' with an + * underscore. (Recall that on Unix, the only bytes not allowed in a + * file name component are '\0' and '/'.) On the other hand, the UTF-8 + * for a printable non-ASCII Unicode character (that thus consists of + * several very nonprintable non-ASCII bytes) is let through as + * such. But those bytes are of course also allowed in filenames, so + * it doesn't matter as such... + */ void e_filename_make_safe (gchar *string) { gchar *p, *ts; gunichar c; +#ifdef G_OS_WIN32 + const char *unsafe_chars = " /'\"`&();|<>$%{}!\\:*?"; +#else + const char *unsafe_chars = " /'\"`&();|<>$%{}!"; +#endif g_return_if_fail (string != NULL); p = string; @@ -452,7 +473,11 @@ e_filename_make_safe (gchar *string) c = g_utf8_get_char (p); ts = p; p = g_utf8_next_char (p); - if (!g_unichar_isprint(c) || ( c < 0xff && strchr (" /'\"`&();|<>$%{}!", c&0xff ))) { + /* I wonder what this code is supposed to actually + * achieve, and whether it does that as currently + * written? + */ + if (!g_unichar_isprint(c) || ( c < 0xff && strchr (unsafe_chars, c&0xff ))) { while (ts<p) *ts++ = '_'; } @@ -1252,3 +1277,33 @@ e_gettext (const char *msgid) return dgettext (E_I18N_DOMAIN, msgid); } +#ifdef G_OS_WIN32 + +int +fsync (int fd) +{ + int handle; + struct stat st; + + handle = _get_osfhandle (fd); + if (handle == -1) + return -1; + + fstat (fd, &st); + + /* FlushFileBuffers() fails if called on a handle to the + * console output. As we cannot know whether fd refers to the + * console output or not, punt, and call FlushFileBuffers() + * only for regular files and pipes. + */ + if (!(S_ISREG (st.st_mode) || S_ISFIFO (st.st_mode))) + return 0; + + if (FlushFileBuffers ((HANDLE) handle)) + return 0; + + errno = EIO; + return -1; +} + +#endif diff --git a/e-util/e-xml-utils.c b/e-util/e-xml-utils.c index 4f919fcacd..5ac741a278 100644 --- a/e-util/e-xml-utils.c +++ b/e-util/e-xml-utils.c @@ -44,10 +44,6 @@ #include "e-util.h" #include "e-xml-utils.h" -#ifdef G_OS_WIN32 -#define fsync(fd) 0 /* No fsync() in Microsoft's C library */ -#endif - xmlNode * e_xml_get_child_by_name (const xmlNode *parent, const xmlChar *child_name) { @@ -316,9 +312,9 @@ e_xml_get_bool_prop_by_name_with_default(const xmlNode *parent, prop = xmlGetProp ((xmlNode *) parent, prop_name); if (prop != NULL) { - if (g_strcasecmp (prop, "true") == 0) { + if (g_ascii_strcasecmp (prop, "true") == 0) { ret_val = TRUE; - } else if (g_strcasecmp (prop, "false") == 0) { + } else if (g_ascii_strcasecmp (prop, "false") == 0) { ret_val = FALSE; } xmlFree(prop); |