diff --git a/app/app_procs.c b/app/app_procs.c index b59941fa94..f5ea8d5e89 100644 --- a/app/app_procs.c +++ b/app/app_procs.c @@ -15,15 +15,26 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" #include #include #include #include +#ifdef HAVE_SYS_PARAM_H #include +#endif #include +#ifdef HAVE_DIRENT_H #include +#endif +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef _MSC_VER +#include /* For _getpid() */ +#endif + #include #include "libgimp/gimpfeatures.h" @@ -73,8 +84,6 @@ #include "color_notebook.h" #include "color_select.h" -#include "config.h" - #include "libgimp/gimpintl.h" #define LOGO_WIDTH_MIN 300 @@ -169,21 +178,22 @@ splash_logo_load_size (GtkWidget *window) if (logo_pixmap) return TRUE; - g_snprintf (buf, sizeof(buf), "%s/gimp1_1_splash.ppm", DATADIR); + g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp1_1_splash.ppm", + DATADIR); fp = fopen (buf, "rb"); if (!fp) return 0; - fgets (buf, 1024, fp); + fgets (buf, sizeof (buf), fp); if (strcmp (buf, "P6\n") != 0) { fclose (fp); return 0; } - fgets (buf, 1024, fp); - fgets (buf, 1024, fp); + fgets (buf, sizeof (buf), fp); + fgets (buf, sizeof (buf), fp); sscanf (buf, "%d %d", &logo_width, &logo_height); fclose (fp); @@ -204,24 +214,25 @@ splash_logo_load (GtkWidget *window) if (logo_pixmap) return TRUE; - g_snprintf (buf, sizeof(buf), "%s/gimp1_1_splash.ppm", DATADIR); + g_snprintf (buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gimp1_1_splash.ppm", + DATADIR); fp = fopen (buf, "rb"); if (!fp) return 0; - fgets (buf, 1024, fp); + fgets (buf, sizeof (buf), fp); if (strcmp (buf, "P6\n") != 0) { fclose (fp); return 0; } - fgets (buf, 1024, fp); - fgets (buf, 1024, fp); + fgets (buf, sizeof (buf), fp); + fgets (buf, sizeof (buf), fp); sscanf (buf, "%d %d", &logo_width, &logo_height); - fgets (buf, 1024, fp); + fgets (buf, sizeof (buf), fp); if (strcmp (buf, "255\n") != 0) { fclose (fp); @@ -273,6 +284,7 @@ splash_text_draw (GtkWidget *widget) ((logo_area_width - gdk_string_width (font, NAME)) / 2), (0.25 * logo_area_height), NAME); + gdk_font_unref (font); font = gdk_font_load ("-Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-*"); gdk_draw_string (widget->window, @@ -293,6 +305,7 @@ splash_text_draw (GtkWidget *widget) ((logo_area_width - gdk_string_width (font, AUTHORS)) / 2), (0.80 * logo_area_height), AUTHORS); + gdk_font_unref (font); } static void @@ -424,7 +437,7 @@ app_init_update_status(char *label1val, { while ( strlen (label2val) > max_label_length ) { - temp = strchr (label2val, '/'); + temp = strchr (label2val, G_DIR_SEPARATOR); if (temp == NULL) /* for sanity */ break; temp++; @@ -462,7 +475,7 @@ app_init (void) gimp_dir = gimp_directory (); if (gimp_dir[0] != '\000') { - g_snprintf (filename, MAXPATHLEN, "%s/gtkrc", gimp_dir); + g_snprintf (filename, MAXPATHLEN, "%s" G_DIR_SEPARATOR_S "gtkrc", gimp_dir); if ((be_verbose == TRUE) || (no_splash == TRUE)) g_print (_("parsing \"%s\"\n"), filename); @@ -539,7 +552,8 @@ app_init (void) if (swap_path == NULL) swap_path = "/tmp"; toast_old_temp_files (); - path = g_strdup_printf ("%s/gimpswap.%ld", swap_path, (long)getpid ()); + path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimpswap.%ld", + swap_path, (long)getpid ()); tile_swap_add (path, NULL, NULL); g_free (path); @@ -759,9 +773,17 @@ toast_old_temp_files (void) */ int pid = atoi (entry->d_name + 9); +#ifndef NATIVE_WIN32 if (kill (pid, 0)) +#else + /* On Windows, you can't remove open files anyhow, + * so no harm trying. + */ +#endif + { - g_string_sprintf (filename, "%s/%s", swap_path, entry->d_name); + g_string_sprintf (filename, "%s" G_DIR_SEPARATOR_S "%s", + swap_path, entry->d_name); unlink (filename->str); } } diff --git a/app/appenv.h b/app/appenv.h index bdd91bd4bc..1bef566c6a 100644 --- a/app/appenv.h +++ b/app/appenv.h @@ -19,11 +19,23 @@ #define __APPENV_H__ #include "glib.h" + +/* The GIMP shouldn't need to know much about X11 (or Windows), so + * I'll remove this inclusion of gdkx.h. This will speed up compilations + * a bit, too. If some source file needs gdkx.h, it can include it. + */ +#if 0 #include "gdk/gdkx.h" +#endif + #include "gtk/gtk.h" #include "gimpsetF.h" #include "colormap_dialog.t.h" + +/* Without gdkx.h no GDK_DISPLAY() */ +#if 0 #define DISPLAY ((Display *) GDK_DISPLAY()) +#endif /* important macros - we reuse the ones from glib */ #define BOUNDS(a,x,y) CLAMP(a,x,y) diff --git a/app/asupsample.c b/app/asupsample.c index 29d63d5fdb..7121b10848 100644 --- a/app/asupsample.c +++ b/app/asupsample.c @@ -30,6 +30,7 @@ #include +#include #include "appenv.h" #include "asupsample.h" diff --git a/app/base/temp-buf.c b/app/base/temp-buf.c index ca3b6a6268..af4faa1caa 100644 --- a/app/base/temp-buf.c +++ b/app/base/temp-buf.c @@ -15,12 +15,22 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include + +#ifdef _MSC_VER +#include /* For _getpid() */ +#endif + #include "appenv.h" #include "drawable.h" #include "errors.h" @@ -416,7 +426,8 @@ generate_unique_filename (void) { pid_t pid; pid = getpid (); - return g_strdup_printf ("%s/gimp%d.%d", temp_path, (int) pid, swap_index++); + return g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimp%d.%d", + temp_path, (int) pid, swap_index++); } diff --git a/app/base/tile-manager.c b/app/base/tile-manager.c index 05aa0588c8..f4e56f305a 100644 --- a/app/base/tile-manager.c +++ b/app/base/tile-manager.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #include "tile_cache.h" #include "tile_manager.h" #include "tile_swap.h" diff --git a/app/base/tile-swap.c b/app/base/tile-swap.c index fbff8e511e..b94f520f1a 100644 --- a/app/base/tile-swap.c +++ b/app/base/tile-swap.c @@ -1,13 +1,21 @@ +#include "config.h" + #include #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #ifdef USE_PTHREADS #include #endif +#ifdef _MSC_VER +#include +#endif + #include "libgimp/gimpintl.h" #define MAX_OPEN_SWAP_FILES 16 @@ -352,7 +360,11 @@ tile_swap_open (SwapFile *swap_file) nopen_swap_files -= 1; } +#ifndef NATIVE_WIN32 swap_file->fd = open (swap_file->filename, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR); +#else + swap_file->fd = open (swap_file->filename, O_CREAT|O_RDWR|_O_BINARY, _S_IREAD|_S_IWRITE); +#endif if (swap_file->fd == -1) { g_message (_("unable to open swap file...BAD THINGS WILL HAPPEN SOON")); diff --git a/app/batch.c b/app/batch.c index 896b86e4f8..9dd9d9d57f 100644 --- a/app/batch.c +++ b/app/batch.c @@ -1,9 +1,13 @@ +#include "config.h" + #include #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include "appenv.h" #include "app_procs.h" @@ -43,10 +47,14 @@ batch_init () { if (!read_from_stdin) { +#ifndef NATIVE_WIN32 /* for now */ g_print (_("reading batch commands from stdin\n")); gdk_input_add (STDIN_FILENO, GDK_INPUT_READ, batch_read, NULL); read_from_stdin = TRUE; } +#else + g_error ("Batch mode from standard input not implemented on Win32"); +#endif } else { diff --git a/app/blob.c b/app/blob.c index 71e960e55b..d62a34b4b2 100644 --- a/app/blob.c +++ b/app/blob.c @@ -31,6 +31,10 @@ #define ROUND(A) floor((A)+0.5) +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif /* M_PI */ + static Blob * blob_new (int y, int height) { diff --git a/app/clone.c b/app/clone.c index 05882eb3a5..0ad87e64dd 100644 --- a/app/clone.c +++ b/app/clone.c @@ -235,7 +235,7 @@ clone_paint_func (PaintCore *paint_core, y2 = paint_core->lasty; /* If the control key is down, move the src target and return */ - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { src_x = x1; src_y = y1; @@ -269,7 +269,7 @@ clone_paint_func (PaintCore *paint_core, break; case INIT_PAINT : - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; clone_set_src_drawable(drawable); diff --git a/app/color_area.c b/app/color_area.c index ae86ca4355..cfdec2506d 100644 --- a/app/color_area.c +++ b/app/color_area.c @@ -17,6 +17,7 @@ */ #include +#include #include "appenv.h" #include "color_area.h" #include "color_notebook.h" diff --git a/app/color_select.c b/app/color_select.c index eaee373af3..757daf9db5 100644 --- a/app/color_select.c +++ b/app/color_select.c @@ -17,6 +17,7 @@ */ #include #include +#include #include "appenv.h" #include "actionarea.h" #include "color_select.h" diff --git a/app/colormap_dialog.i.c b/app/colormap_dialog.i.c index de4bc30d60..a8675a2d69 100644 --- a/app/colormap_dialog.i.c +++ b/app/colormap_dialog.i.c @@ -429,9 +429,11 @@ ipal_clear (GimpColormapDialog* ipal) palette = GTK_WIDGET(ipal->palette); - width = palette->allocation.width; - height = palette->allocation.height; - row = g_new(guchar, width * 3); + /* Watch out for negative values (at least on Win32) */ + width = (int) (gint16) palette->allocation.width; + height = (int) (gint16) palette->allocation.height; + if (width > 0) + row = g_new(guchar, width * 3); gtk_preview_size(ipal->palette, width, height); @@ -448,7 +450,8 @@ ipal_clear (GimpColormapDialog* ipal) for (j = 0; j < 4 && i+j < height; j++) gtk_preview_draw_row (ipal->palette, row, 0, i + j, width); } - g_free (row); + if (width > 0) + g_free (row); gtk_widget_draw (palette, NULL); } diff --git a/app/core/gimpbrushgenerated-load.c b/app/core/gimpbrushgenerated-load.c index 162ac4b320..d273fdcf9f 100644 --- a/app/core/gimpbrushgenerated-load.c +++ b/app/core/gimpbrushgenerated-load.c @@ -18,12 +18,24 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + +#include +#include +#include + +#ifndef HAVE_RINT +#define rint(x) floor (x + 0.5) +#endif + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + #include "appenv.h" #include "gimpbrushgenerated.h" #include "paint_core.h" #include "gimprc.h" -#include -#include #define OVERSAMPLING 5 @@ -228,7 +240,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush) register double exponent; register guchar a; register int length; - register char *lookup; + register guchar *lookup; double buffer[OVERSAMPLING]; register double sum, c, s, tx, ty; int width, height; diff --git a/app/core/gimpbrushgenerated-save.c b/app/core/gimpbrushgenerated-save.c index 162ac4b320..d273fdcf9f 100644 --- a/app/core/gimpbrushgenerated-save.c +++ b/app/core/gimpbrushgenerated-save.c @@ -18,12 +18,24 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + +#include +#include +#include + +#ifndef HAVE_RINT +#define rint(x) floor (x + 0.5) +#endif + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + #include "appenv.h" #include "gimpbrushgenerated.h" #include "paint_core.h" #include "gimprc.h" -#include -#include #define OVERSAMPLING 5 @@ -228,7 +240,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush) register double exponent; register guchar a; register int length; - register char *lookup; + register guchar *lookup; double buffer[OVERSAMPLING]; register double sum, c, s, tx, ty; int width, height; diff --git a/app/core/gimpbrushgenerated.c b/app/core/gimpbrushgenerated.c index 162ac4b320..d273fdcf9f 100644 --- a/app/core/gimpbrushgenerated.c +++ b/app/core/gimpbrushgenerated.c @@ -18,12 +18,24 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + +#include +#include +#include + +#ifndef HAVE_RINT +#define rint(x) floor (x + 0.5) +#endif + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + #include "appenv.h" #include "gimpbrushgenerated.h" #include "paint_core.h" #include "gimprc.h" -#include -#include #define OVERSAMPLING 5 @@ -228,7 +240,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush) register double exponent; register guchar a; register int length; - register char *lookup; + register guchar *lookup; double buffer[OVERSAMPLING]; register double sum, c, s, tx, ty; int width, height; diff --git a/app/core/gimpdatafiles.c b/app/core/gimpdatafiles.c index da558448b9..74aba57d30 100644 --- a/app/core/gimpdatafiles.c +++ b/app/core/gimpdatafiles.c @@ -18,15 +18,29 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - +#include "config.h" #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include +#ifdef HAVE_DIRENT_H #include +#endif + +#ifdef _MSC_VER +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) +#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) +#endif +#ifndef S_IXUSR +#define S_IXUSR _S_IEXEC +#endif +#endif #include #include "datafiles.h" @@ -70,7 +84,7 @@ datafiles_read_directories (char *path_str, next_token = local_path; - token = xstrsep(&next_token, ":"); + token = xstrsep(&next_token, G_SEARCHPATH_SEPARATOR_S); while (token) { @@ -90,8 +104,8 @@ datafiles_read_directories (char *path_str, if (!err && S_ISDIR(filestat.st_mode)) { - if (path[strlen(path) - 1] != '/') - strcat(path, "/"); + if (path[strlen(path) - 1] != G_DIR_SEPARATOR) + strcat(path, G_DIR_SEPARATOR_S); /* Open directory */ dir = opendir(path); @@ -124,7 +138,7 @@ datafiles_read_directories (char *path_str, g_free(path); - token = xstrsep(&next_token, ":"); + token = xstrsep(&next_token, G_SEARCHPATH_SEPARATOR_S); } /* while */ g_free(local_path); diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index 738d35fd8e..f9cd6dbd6d 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include "gimpdrawableP.h" #include "gimpsignal.h" #include "gimage.h" diff --git a/app/core/gimpparasitelist.c b/app/core/gimpparasitelist.c index 95d9678ce9..11cc0b1c39 100644 --- a/app/core/gimpparasitelist.c +++ b/app/core/gimpparasitelist.c @@ -15,6 +15,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #include "gimpobjectP.h" #include "gimpobject.h" #include "gimpsignal.h" diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index 1d00870219..45a4f91db0 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -17,6 +17,7 @@ */ #include #include +#include #include "appenv.h" #include "buildmenu.h" #include "channels_dialog.h" diff --git a/app/datafiles.c b/app/datafiles.c index da558448b9..74aba57d30 100644 --- a/app/datafiles.c +++ b/app/datafiles.c @@ -18,15 +18,29 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - +#include "config.h" #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include +#ifdef HAVE_DIRENT_H #include +#endif + +#ifdef _MSC_VER +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) +#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) +#endif +#ifndef S_IXUSR +#define S_IXUSR _S_IEXEC +#endif +#endif #include #include "datafiles.h" @@ -70,7 +84,7 @@ datafiles_read_directories (char *path_str, next_token = local_path; - token = xstrsep(&next_token, ":"); + token = xstrsep(&next_token, G_SEARCHPATH_SEPARATOR_S); while (token) { @@ -90,8 +104,8 @@ datafiles_read_directories (char *path_str, if (!err && S_ISDIR(filestat.st_mode)) { - if (path[strlen(path) - 1] != '/') - strcat(path, "/"); + if (path[strlen(path) - 1] != G_DIR_SEPARATOR) + strcat(path, G_DIR_SEPARATOR_S); /* Open directory */ dir = opendir(path); @@ -124,7 +138,7 @@ datafiles_read_directories (char *path_str, g_free(path); - token = xstrsep(&next_token, ":"); + token = xstrsep(&next_token, G_SEARCHPATH_SEPARATOR_S); } /* while */ g_free(local_path); diff --git a/app/dialogs/module-dialog.c b/app/dialogs/module-dialog.c index fc168c339c..85ba129503 100644 --- a/app/dialogs/module-dialog.c +++ b/app/dialogs/module-dialog.c @@ -18,10 +18,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif +#include #include "appenv.h" #include "module_db.h" @@ -335,16 +340,14 @@ module_info_free (module_info *mod) /* helper functions */ -/* name must be of the form lib*.so */ -/* TODO: need support for WIN32-style dll names. Maybe this function - * should live in libgmodule? */ +/* name must be of the form lib*.so (Unix) or *.dll (Win32) */ static gboolean valid_module_name (const char *filename) { const char *basename; int len; - basename = strrchr (filename, '/'); + basename = strrchr (filename, G_DIR_SEPARATOR); if (basename) basename++; else @@ -352,6 +355,7 @@ valid_module_name (const char *filename) len = strlen (basename); +#ifndef WIN32 if (len < 3 + 1 + 3) return FALSE; @@ -360,6 +364,10 @@ valid_module_name (const char *filename) if (strcmp (basename + len - 3, ".so")) return FALSE; +#else + if (g_strcasecmp (basename + len - 4, ".dll")) + return FALSE; +#endif return TRUE; } diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 3d353f49a6..ddf5b0d825 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -1,5 +1,7 @@ #include #include +#include + #include "appenv.h" #include "about_dialog.h" #include "actionarea.h" diff --git a/app/dialogs/tips-dialog.c b/app/dialogs/tips-dialog.c index ca89dcaf62..956d7977cd 100644 --- a/app/dialogs/tips-dialog.c +++ b/app/dialogs/tips-dialog.c @@ -45,9 +45,11 @@ tips_dialog_create () if (tips_count == 0) { if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL) - temp = (char *) g_strdup_printf ("%s/%s", gimp_data_dir, TIPS_FILE_NAME); + temp = (char *) g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", + gimp_data_dir, TIPS_FILE_NAME); else - temp = (char *) g_strdup_printf ("%s/%s", DATADIR, TIPS_FILE_NAME); + temp = (char *) g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", + DATADIR, TIPS_FILE_NAME); read_tips_file ((char *)temp); g_free (temp); } @@ -219,7 +221,7 @@ read_tips_file (char *filename) char *tip = NULL; char *str = NULL; - fp = fopen (filename, "rb"); + fp = fopen (filename, "r"); if (!fp) { store_tip (_("Your GIMP tips file appears to be missing!\n" diff --git a/app/disp_callbacks.c b/app/disp_callbacks.c index 80efbf0e81..b49d7bd380 100644 --- a/app/disp_callbacks.c +++ b/app/disp_callbacks.c @@ -329,7 +329,7 @@ gdisplay_canvas_events (GtkWidget *canvas, /* if the first mouse button is down, check for automatic * scrolling... */ - if ((mevent->state & Button1Mask) && !active_tool->scroll_lock) + if ((mevent->state & GDK_BUTTON1_MASK) && !active_tool->scroll_lock) { if (mevent->x < 0 || mevent->y < 0 || mevent->x > gdisp->disp_width || diff --git a/app/display/gimpdisplay-callbacks.c b/app/display/gimpdisplay-callbacks.c index 80efbf0e81..b49d7bd380 100644 --- a/app/display/gimpdisplay-callbacks.c +++ b/app/display/gimpdisplay-callbacks.c @@ -329,7 +329,7 @@ gdisplay_canvas_events (GtkWidget *canvas, /* if the first mouse button is down, check for automatic * scrolling... */ - if ((mevent->state & Button1Mask) && !active_tool->scroll_lock) + if ((mevent->state & GDK_BUTTON1_MASK) && !active_tool->scroll_lock) { if (mevent->x < 0 || mevent->y < 0 || mevent->x > gdisp->disp_width || diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index 1d00870219..45a4f91db0 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -17,6 +17,7 @@ */ #include #include +#include #include "appenv.h" #include "buildmenu.h" #include "channels_dialog.h" diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index 80efbf0e81..b49d7bd380 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -329,7 +329,7 @@ gdisplay_canvas_events (GtkWidget *canvas, /* if the first mouse button is down, check for automatic * scrolling... */ - if ((mevent->state & Button1Mask) && !active_tool->scroll_lock) + if ((mevent->state & GDK_BUTTON1_MASK) && !active_tool->scroll_lock) { if (mevent->x < 0 || mevent->y < 0 || mevent->x > gdisp->disp_width || diff --git a/app/docindex.c b/app/docindex.c index e8217c70b2..de6d16fa90 100644 --- a/app/docindex.c +++ b/app/docindex.c @@ -13,14 +13,15 @@ * GNU General Public License for more details. */ -#include "docindexif.h" -#include "docindex.h" - -#include #include #include #include +#include + +#include "docindexif.h" +#include "docindex.h" + idea_manager *ideas = NULL; static GList *idea_list = NULL; /* of gchar *. */ static gint x = 0, y = 0, width = 0, height = 0; diff --git a/app/docindexif.h b/app/docindexif.h index 7fca830e41..684b4e4ba6 100644 --- a/app/docindexif.h +++ b/app/docindexif.h @@ -18,7 +18,6 @@ #include -#include #include #include "libgimp/gimpintl.h" diff --git a/app/errorconsole.c b/app/errorconsole.c index 7badb122c4..004eb8fb32 100644 --- a/app/errorconsole.c +++ b/app/errorconsole.c @@ -19,15 +19,32 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include #include +#ifdef HAVE_DIRENT_H #include +#endif +#ifdef HAVE_UNISTD_H #include +#endif #include #include #include -#include "gtk/gtk.h" + +#ifdef _MSC_VER +#include +#ifndef S_IRUSR +#define S_IRUSR _S_IREAD +#endif +#ifndef S_IWUSR +#define S_IWUSR _S_IWRITE +#endif +#endif + +#include #include "commands.h" #include "session.h" diff --git a/app/errors.c b/app/errors.c index 6a920c6d1d..7d63cf486a 100644 --- a/app/errors.c +++ b/app/errors.c @@ -15,14 +15,24 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include +#include +#ifdef HAVE_SYS_TIME_H #include +#endif +#ifdef HAVE_SYS_TIMES_H #include +#endif #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include "appenv.h" diff --git a/app/fileops.c b/app/fileops.c index d8be7fd469..899114466c 100644 --- a/app/fileops.c +++ b/app/fileops.c @@ -16,16 +16,29 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include #include #include +#ifdef HAVE_SYS_PARAM_H #include +#endif #include +#ifdef HAVE_UNISTD_H #include +#endif #include +#ifdef _MSC_VER +#include /* For _getpid() */ +#include /* For _mkdir() */ +#define mkdir(path,mode) _mkdir(path) +#endif + #include "appenv.h" #include "actionarea.h" #include "cursorutil.h" @@ -534,7 +547,8 @@ file_open_callback (GtkWidget *w, if (GTK_WIDGET_VISIBLE (fileload)) return; - gtk_file_selection_set_filename (GTK_FILE_SELECTION(fileload), "./"); + gtk_file_selection_set_filename (GTK_FILE_SELECTION(fileload), + "." G_DIR_SEPARATOR_S); gtk_window_set_title (GTK_WINDOW (fileload), _("Load Image")); } @@ -707,7 +721,8 @@ file_save_as_callback (GtkWidget *w, if (GTK_WIDGET_VISIBLE (filesave)) return; - gtk_file_selection_set_filename (GTK_FILE_SELECTION(filesave), "./"); + gtk_file_selection_set_filename (GTK_FILE_SELECTION(filesave), + "." G_DIR_SEPARATOR_S); gtk_window_set_title (GTK_WINDOW (filesave), _("Save Image")); } @@ -1386,9 +1401,9 @@ file_open_ok_callback (GtkWidget *w, if (err == 0 && (buf.st_mode & S_IFDIR)) { GString *s = g_string_new (filename); - if (s->str[s->len - 1] != '/') + if (s->str[s->len - 1] != G_DIR_SEPARATOR) { - g_string_append_c (s, '/'); + g_string_append_c (s, G_DIR_SEPARATOR); } gtk_file_selection_set_filename (fs, s->str); g_string_free (s, TRUE); @@ -1549,7 +1564,7 @@ file_save_ok_callback (GtkWidget *w, if (buf.st_mode & S_IFDIR) { GString *s = g_string_new (filename); - g_string_append_c (s, '/'); + g_string_append_c (s, G_DIR_SEPARATOR); gtk_file_selection_set_filename (fs, s->str); g_string_free (s, TRUE); return; @@ -2106,7 +2121,8 @@ file_temp_name_invoker (Argument *args) if (id == 0) pid = getpid(); - g_string_sprintf (s, "%s/gimp_temp.%d%d.%s", temp_path, pid, id++, (char*)args[0].value.pdb_pointer); + g_string_sprintf (s, "%s" G_DIR_SEPARATOR_S "gimp_temp.%d%d.%s", + temp_path, pid, id++, (char*)args[0].value.pdb_pointer); return_args = procedural_db_return_args (&file_temp_name_proc, TRUE); diff --git a/app/gdisplay.c b/app/gdisplay.c index 1d00870219..45a4f91db0 100644 --- a/app/gdisplay.c +++ b/app/gdisplay.c @@ -17,6 +17,7 @@ */ #include #include +#include #include "appenv.h" #include "buildmenu.h" #include "channels_dialog.h" diff --git a/app/general.c b/app/general.c index 70ddee2d06..3d5b563811 100644 --- a/app/general.c +++ b/app/general.c @@ -22,6 +22,13 @@ #include #include #include + +#ifdef _MSC_VER +#ifndef S_ISREG +#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) +#endif +#endif + #include "general.h" char* @@ -34,14 +41,14 @@ search_in_path (char *search_path, int err; local_path = g_strdup (search_path); - token = strtok (local_path, ":"); + token = strtok (local_path, G_SEARCHPATH_SEPARATOR_S); while (token) { sprintf (path, "%s", token); - if (token[strlen (token) - 1] != '/') - strcat (path, "/"); + if (token[strlen (token) - 1] != G_DIR_SEPARATOR) + strcat (path, G_DIR_SEPARATOR_S); strcat (path, filename); err = stat (path, &buf); @@ -51,7 +58,7 @@ search_in_path (char *search_path, break; } - token = strtok (NULL, ":"); + token = strtok (NULL, G_SEARCHPATH_SEPARATOR_S); } g_free (local_path); diff --git a/app/gimpbrushgenerated.c b/app/gimpbrushgenerated.c index 162ac4b320..d273fdcf9f 100644 --- a/app/gimpbrushgenerated.c +++ b/app/gimpbrushgenerated.c @@ -18,12 +18,24 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + +#include +#include +#include + +#ifndef HAVE_RINT +#define rint(x) floor (x + 0.5) +#endif + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + #include "appenv.h" #include "gimpbrushgenerated.h" #include "paint_core.h" #include "gimprc.h" -#include -#include #define OVERSAMPLING 5 @@ -228,7 +240,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush) register double exponent; register guchar a; register int length; - register char *lookup; + register guchar *lookup; double buffer[OVERSAMPLING]; register double sum, c, s, tx, ty; int width, height; diff --git a/app/gimpbrushlist.c b/app/gimpbrushlist.c index 6d54b3c883..5b802db08c 100644 --- a/app/gimpbrushlist.c +++ b/app/gimpbrushlist.c @@ -15,14 +15,22 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_DIRENT_H #include +#endif #include #include #include + #include "appenv.h" #include "gimpbrushgenerated.h" #include "brush_header.h" diff --git a/app/gimpdrawable.c b/app/gimpdrawable.c index 738d35fd8e..f9cd6dbd6d 100644 --- a/app/gimpdrawable.c +++ b/app/gimpdrawable.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include "gimpdrawableP.h" #include "gimpsignal.h" #include "gimage.h" diff --git a/app/gradient.c b/app/gradient.c index 0730bdc4f9..787c3fda79 100644 --- a/app/gradient.c +++ b/app/gradient.c @@ -148,12 +148,15 @@ * - Add a Gradient brush mode (color changes as you move it). */ +#include "config.h" #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include "appenv.h" #include "colormaps.h" @@ -168,7 +171,6 @@ #include "session.h" #include "gradient_header.h" -#include "config.h" #include "libgimp/gimpintl.h" /***** Magic numbers *****/ @@ -5970,17 +5972,20 @@ build_user_filename(char *name, char *path_str) home = g_get_home_dir (); local_path = g_strdup(path_str); first_token = local_path; - token = xstrsep(&first_token, ":"); + token = xstrsep(&first_token, G_SEARCHPATH_SEPARATOR_S); filename = NULL; if (token) { if (*token == '~') { + if (!home) + return NULL; path = g_strdup_printf("%s%s", home, token + 1); } else { path = g_strdup(token); } /* else */ - filename = g_strdup_printf("%s/%s", path, name); + filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", + path, name); g_free(path); } /* if */ diff --git a/app/gradient_editor.c b/app/gradient_editor.c index 0730bdc4f9..787c3fda79 100644 --- a/app/gradient_editor.c +++ b/app/gradient_editor.c @@ -148,12 +148,15 @@ * - Add a Gradient brush mode (color changes as you move it). */ +#include "config.h" #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include "appenv.h" #include "colormaps.h" @@ -168,7 +171,6 @@ #include "session.h" #include "gradient_header.h" -#include "config.h" #include "libgimp/gimpintl.h" /***** Magic numbers *****/ @@ -5970,17 +5972,20 @@ build_user_filename(char *name, char *path_str) home = g_get_home_dir (); local_path = g_strdup(path_str); first_token = local_path; - token = xstrsep(&first_token, ":"); + token = xstrsep(&first_token, G_SEARCHPATH_SEPARATOR_S); filename = NULL; if (token) { if (*token == '~') { + if (!home) + return NULL; path = g_strdup_printf("%s%s", home, token + 1); } else { path = g_strdup(token); } /* else */ - filename = g_strdup_printf("%s/%s", path, name); + filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", + path, name); g_free(path); } /* if */ diff --git a/app/gradient_select.c b/app/gradient_select.c index b4a44c643a..98a017c379 100644 --- a/app/gradient_select.c +++ b/app/gradient_select.c @@ -34,11 +34,15 @@ * the structures so we can find which one we are taking about. */ +#include "config.h" + #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include "appenv.h" #include "colormaps.h" diff --git a/app/gui/color-area.c b/app/gui/color-area.c index ae86ca4355..cfdec2506d 100644 --- a/app/gui/color-area.c +++ b/app/gui/color-area.c @@ -17,6 +17,7 @@ */ #include +#include #include "appenv.h" #include "color_area.h" #include "color_notebook.h" diff --git a/app/gui/color-select.c b/app/gui/color-select.c index eaee373af3..757daf9db5 100644 --- a/app/gui/color-select.c +++ b/app/gui/color-select.c @@ -17,6 +17,7 @@ */ #include #include +#include #include "appenv.h" #include "actionarea.h" #include "color_select.h" diff --git a/app/gui/gradient-editor.c b/app/gui/gradient-editor.c index 0730bdc4f9..787c3fda79 100644 --- a/app/gui/gradient-editor.c +++ b/app/gui/gradient-editor.c @@ -148,12 +148,15 @@ * - Add a Gradient brush mode (color changes as you move it). */ +#include "config.h" #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include "appenv.h" #include "colormaps.h" @@ -168,7 +171,6 @@ #include "session.h" #include "gradient_header.h" -#include "config.h" #include "libgimp/gimpintl.h" /***** Magic numbers *****/ @@ -5970,17 +5972,20 @@ build_user_filename(char *name, char *path_str) home = g_get_home_dir (); local_path = g_strdup(path_str); first_token = local_path; - token = xstrsep(&first_token, ":"); + token = xstrsep(&first_token, G_SEARCHPATH_SEPARATOR_S); filename = NULL; if (token) { if (*token == '~') { + if (!home) + return NULL; path = g_strdup_printf("%s%s", home, token + 1); } else { path = g_strdup(token); } /* else */ - filename = g_strdup_printf("%s/%s", path, name); + filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", + path, name); g_free(path); } /* if */ diff --git a/app/gui/gradient-select.c b/app/gui/gradient-select.c index b4a44c643a..98a017c379 100644 --- a/app/gui/gradient-select.c +++ b/app/gui/gradient-select.c @@ -34,11 +34,15 @@ * the structures so we can find which one we are taking about. */ +#include "config.h" + #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include "appenv.h" #include "colormaps.h" diff --git a/app/gui/module-browser.c b/app/gui/module-browser.c index fc168c339c..85ba129503 100644 --- a/app/gui/module-browser.c +++ b/app/gui/module-browser.c @@ -18,10 +18,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif +#include #include "appenv.h" #include "module_db.h" @@ -335,16 +340,14 @@ module_info_free (module_info *mod) /* helper functions */ -/* name must be of the form lib*.so */ -/* TODO: need support for WIN32-style dll names. Maybe this function - * should live in libgmodule? */ +/* name must be of the form lib*.so (Unix) or *.dll (Win32) */ static gboolean valid_module_name (const char *filename) { const char *basename; int len; - basename = strrchr (filename, '/'); + basename = strrchr (filename, G_DIR_SEPARATOR); if (basename) basename++; else @@ -352,6 +355,7 @@ valid_module_name (const char *filename) len = strlen (basename); +#ifndef WIN32 if (len < 3 + 1 + 3) return FALSE; @@ -360,6 +364,10 @@ valid_module_name (const char *filename) if (strcmp (basename + len - 3, ".so")) return FALSE; +#else + if (g_strcasecmp (basename + len - 4, ".dll")) + return FALSE; +#endif return TRUE; } diff --git a/app/gui/palette-editor.c b/app/gui/palette-editor.c index 5ebaa47c78..ceb9186ad7 100644 --- a/app/gui/palette-editor.c +++ b/app/gui/palette-editor.c @@ -15,11 +15,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_DIRENT_H #include +#endif #include #include #include "appenv.h" @@ -1257,20 +1264,25 @@ palette_create_entries(gpointer client_data, home = g_get_home_dir (); local_path = g_strdup (palette_path); first_token = local_path; - token = xstrsep(&first_token, ":"); + token = xstrsep(&first_token, G_SEARCHPATH_SEPARATOR_S); if (token) { if (*token == '~') { - path = g_strdup_printf("%s%s", home, token + 1); + if (home) + path = g_strdup_printf("%s%s", home, token + 1); + else + /* Just ignore the ~ if no HOME ??? */ + path = g_strdup(token + 1); } else { path = g_strdup(token); } - entries->filename = g_strdup_printf ("%s/%s", path, palette_name); + entries->filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", + path, palette_name); g_free (path); } diff --git a/app/gui/palette-select.c b/app/gui/palette-select.c index c15ec9d9f9..80c5c58239 100644 --- a/app/gui/palette-select.c +++ b/app/gui/palette-select.c @@ -17,13 +17,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include -#include +#endif #include #include + #include "appenv.h" #include "actionarea.h" #include "buildmenu.h" diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index 3d353f49a6..ddf5b0d825 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -1,5 +1,7 @@ #include #include +#include + #include "appenv.h" #include "about_dialog.h" #include "actionarea.h" diff --git a/app/gui/tips-dialog.c b/app/gui/tips-dialog.c index ca89dcaf62..956d7977cd 100644 --- a/app/gui/tips-dialog.c +++ b/app/gui/tips-dialog.c @@ -45,9 +45,11 @@ tips_dialog_create () if (tips_count == 0) { if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL) - temp = (char *) g_strdup_printf ("%s/%s", gimp_data_dir, TIPS_FILE_NAME); + temp = (char *) g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", + gimp_data_dir, TIPS_FILE_NAME); else - temp = (char *) g_strdup_printf ("%s/%s", DATADIR, TIPS_FILE_NAME); + temp = (char *) g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", + DATADIR, TIPS_FILE_NAME); read_tips_file ((char *)temp); g_free (temp); } @@ -219,7 +221,7 @@ read_tips_file (char *filename) char *tip = NULL; char *str = NULL; - fp = fopen (filename, "rb"); + fp = fopen (filename, "r"); if (!fp) { store_tip (_("Your GIMP tips file appears to be missing!\n" diff --git a/app/main.c b/app/main.c index 8950853f0a..91affb2db6 100644 --- a/app/main.c +++ b/app/main.c @@ -22,8 +22,13 @@ #include #include #include +#ifdef HAVE_SYS_WAIT_H #include +#endif +#ifdef HAVE_UNISTD_H #include +#endif + #include "libgimp/gserialize.h" #ifndef WAIT_ANY @@ -40,7 +45,9 @@ #include "libgimp/gimpintl.h" static RETSIGTYPE on_signal (int); +#ifdef SIGCHLD static RETSIGTYPE on_sig_child (int); +#endif static void init (void); static void test_gserialize(); static void on_error (const gchar* domain, @@ -137,7 +144,7 @@ main (int argc, char **argv) no_data = FALSE; no_splash = FALSE; no_splash_image = FALSE; -#ifdef HAVE_SHM_H +#if defined (HAVE_SHM_H) || defined (NATIVE_WIN32) use_shm = TRUE; #else use_shm = FALSE; @@ -274,7 +281,7 @@ main (int argc, char **argv) if (show_help) { - g_print (_("\007Usage: %s [option ...] [files ...]\n"), argv[0]); + g_print (_("Usage: %s [option ...] [files ...]\n"), argv[0]); g_print (_("Valid options are:\n")); g_print (_(" -h --help Output this help.\n")); g_print (_(" -v --version Output version info.\n")); @@ -300,18 +307,38 @@ main (int argc, char **argv) g_set_message_handler ((GPrintFunc) message_func); /* Handle some signals */ +#ifdef SIGHUP signal (SIGHUP, on_signal); +#endif +#ifdef SIGINT signal (SIGINT, on_signal); +#endif +#ifdef SIGQUIT signal (SIGQUIT, on_signal); +#endif +#ifdef SIGABRT signal (SIGABRT, on_signal); +#endif +#ifdef SIGBUS signal (SIGBUS, on_signal); +#endif +#ifdef SIGSEGV signal (SIGSEGV, on_signal); +#endif +#ifdef SIGPIPE signal (SIGPIPE, on_signal); +#endif +#ifdef SIGTERM signal (SIGTERM, on_signal); +#endif +#ifdef SIGFPE signal (SIGFPE, on_signal); +#endif +#ifdef SIGCHLD /* Handle child exits */ signal (SIGCHLD, on_sig_child); +#endif g_log_set_handler(NULL, G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL, @@ -332,6 +359,18 @@ main (int argc, char **argv) return 0; } +#ifdef NATIVE_WIN32 + +/* In case we build this as a windowed application */ + +int _stdcall +WinMain (int hInstance, int hPrevInstance, char *lpszCmdLine, int nCmdShow) +{ + return main (__argc, __argv); +} + +#endif + static void init () { @@ -356,45 +395,67 @@ static RETSIGTYPE on_signal (int sig_num) { if (caught_fatal_sig) -/* raise (sig_num);*/ +#ifdef NATIVE_WIN32 + raise (sig_num); +#else kill (getpid (), sig_num); +#endif caught_fatal_sig = 1; switch (sig_num) { +#ifdef SIGHUP case SIGHUP: terminate (_("sighup caught")); break; +#endif +#ifdef SIGINT case SIGINT: terminate (_("sigint caught")); break; +#endif +#ifdef SIGQUIT case SIGQUIT: terminate (_("sigquit caught")); break; +#endif +#ifdef SIGABRT case SIGABRT: terminate (_("sigabrt caught")); break; +#endif +#ifdef SIGBUS case SIGBUS: fatal_error (_("sigbus caught")); break; +#endif +#ifdef SIGSEGV case SIGSEGV: fatal_error (_("sigsegv caught")); break; +#endif +#ifdef SIGPIPE case SIGPIPE: terminate (_("sigpipe caught")); break; +#endif +#ifdef SIGTERM case SIGTERM: terminate (_("sigterm caught")); break; +#endif +#ifdef SIGFPE case SIGFPE: fatal_error (_("sigfpe caught")); break; +#endif default: fatal_error (_("unknown signal")); break; } } +#ifdef SIGCHLD static RETSIGTYPE on_sig_child (int sig_num) { @@ -408,6 +469,7 @@ on_sig_child (int sig_num) break; } } +#endif typedef struct { diff --git a/app/module_db.c b/app/module_db.c index fc168c339c..85ba129503 100644 --- a/app/module_db.c +++ b/app/module_db.c @@ -18,10 +18,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif +#include #include "appenv.h" #include "module_db.h" @@ -335,16 +340,14 @@ module_info_free (module_info *mod) /* helper functions */ -/* name must be of the form lib*.so */ -/* TODO: need support for WIN32-style dll names. Maybe this function - * should live in libgmodule? */ +/* name must be of the form lib*.so (Unix) or *.dll (Win32) */ static gboolean valid_module_name (const char *filename) { const char *basename; int len; - basename = strrchr (filename, '/'); + basename = strrchr (filename, G_DIR_SEPARATOR); if (basename) basename++; else @@ -352,6 +355,7 @@ valid_module_name (const char *filename) len = strlen (basename); +#ifndef WIN32 if (len < 3 + 1 + 3) return FALSE; @@ -360,6 +364,10 @@ valid_module_name (const char *filename) if (strcmp (basename + len - 3, ".so")) return FALSE; +#else + if (g_strcasecmp (basename + len - 4, ".dll")) + return FALSE; +#endif return TRUE; } diff --git a/app/paint-funcs/paint-funcs.c b/app/paint-funcs/paint-funcs.c index 2e7d61bf88..38ed8ea034 100644 --- a/app/paint-funcs/paint-funcs.c +++ b/app/paint-funcs/paint-funcs.c @@ -15,10 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include +#ifndef HAVE_RINT +#define rint(x) floor (x + 0.5) +#endif + #include "appenv.h" #include "gimprc.h" #include "paint_funcs.h" diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c index 05882eb3a5..0ad87e64dd 100644 --- a/app/paint/gimpclone.c +++ b/app/paint/gimpclone.c @@ -235,7 +235,7 @@ clone_paint_func (PaintCore *paint_core, y2 = paint_core->lasty; /* If the control key is down, move the src target and return */ - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { src_x = x1; src_y = y1; @@ -269,7 +269,7 @@ clone_paint_func (PaintCore *paint_core, break; case INIT_PAINT : - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; clone_set_src_drawable(drawable); diff --git a/app/paint/gimpink-blob.c b/app/paint/gimpink-blob.c index 71e960e55b..d62a34b4b2 100644 --- a/app/paint/gimpink-blob.c +++ b/app/paint/gimpink-blob.c @@ -31,6 +31,10 @@ #define ROUND(A) floor((A)+0.5) +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif /* M_PI */ + static Blob * blob_new (int y, int height) { diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c index 05882eb3a5..0ad87e64dd 100644 --- a/app/paint/gimpsourcecore.c +++ b/app/paint/gimpsourcecore.c @@ -235,7 +235,7 @@ clone_paint_func (PaintCore *paint_core, y2 = paint_core->lasty; /* If the control key is down, move the src target and return */ - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { src_x = x1; src_y = y1; @@ -269,7 +269,7 @@ clone_paint_func (PaintCore *paint_core, break; case INIT_PAINT : - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; clone_set_src_drawable(drawable); diff --git a/app/paint_funcs.c b/app/paint_funcs.c index 2e7d61bf88..38ed8ea034 100644 --- a/app/paint_funcs.c +++ b/app/paint_funcs.c @@ -15,10 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include +#ifndef HAVE_RINT +#define rint(x) floor (x + 0.5) +#endif + #include "appenv.h" #include "gimprc.h" #include "paint_funcs.h" diff --git a/app/palette.c b/app/palette.c index 5ebaa47c78..ceb9186ad7 100644 --- a/app/palette.c +++ b/app/palette.c @@ -15,11 +15,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_DIRENT_H #include +#endif #include #include #include "appenv.h" @@ -1257,20 +1264,25 @@ palette_create_entries(gpointer client_data, home = g_get_home_dir (); local_path = g_strdup (palette_path); first_token = local_path; - token = xstrsep(&first_token, ":"); + token = xstrsep(&first_token, G_SEARCHPATH_SEPARATOR_S); if (token) { if (*token == '~') { - path = g_strdup_printf("%s%s", home, token + 1); + if (home) + path = g_strdup_printf("%s%s", home, token + 1); + else + /* Just ignore the ~ if no HOME ??? */ + path = g_strdup(token + 1); } else { path = g_strdup(token); } - entries->filename = g_strdup_printf ("%s/%s", path, palette_name); + entries->filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", + path, palette_name); g_free (path); } diff --git a/app/palette_select.c b/app/palette_select.c index c15ec9d9f9..80c5c58239 100644 --- a/app/palette_select.c +++ b/app/palette_select.c @@ -17,13 +17,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include -#include +#endif #include #include + #include "appenv.h" #include "actionarea.h" #include "buildmenu.h" diff --git a/app/parasitelist.c b/app/parasitelist.c index 95d9678ce9..11cc0b1c39 100644 --- a/app/parasitelist.c +++ b/app/parasitelist.c @@ -15,6 +15,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #include "gimpobjectP.h" #include "gimpobject.h" #include "gimpsignal.h" diff --git a/app/patterns.c b/app/patterns.c index 51f0dc5b17..46a2eb353c 100644 --- a/app/patterns.c +++ b/app/patterns.c @@ -15,13 +15,21 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_DIRENT_H #include +#endif #include #include + #include "appenv.h" #include "colormaps.h" #include "datafiles.h" diff --git a/app/posterize.c b/app/posterize.c index 9c241dcc3c..6eae632102 100644 --- a/app/posterize.c +++ b/app/posterize.c @@ -15,9 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include + +#ifndef HAVE_RINT +#define rint(x) floor (x + 0.5) +#endif + #include "appenv.h" #include "actionarea.h" #include "drawable.h" diff --git a/app/preferences_dialog.c b/app/preferences_dialog.c index 3d353f49a6..ddf5b0d825 100644 --- a/app/preferences_dialog.c +++ b/app/preferences_dialog.c @@ -1,5 +1,7 @@ #include #include +#include + #include "appenv.h" #include "about_dialog.h" #include "actionarea.h" diff --git a/app/procedural_db.c b/app/procedural_db.c index d5eef51f97..1c66be4679 100644 --- a/app/procedural_db.c +++ b/app/procedural_db.c @@ -854,7 +854,7 @@ procedural_db_dump (Argument *args) if (filename) { - if (! (procedural_db_out = fopen (filename, "wb"))) + if (! (procedural_db_out = fopen (filename, "w"))) success = FALSE; } else diff --git a/app/rotate_tool.c b/app/rotate_tool.c index 00fdf6d972..04dc420776 100644 --- a/app/rotate_tool.c +++ b/app/rotate_tool.c @@ -319,7 +319,7 @@ rotate_tool_motion (tool, gdisp_ptr) /* constrain the angle to 15-degree multiples if ctrl is held down */ - if (transform_core->state & ControlMask) + if (transform_core->state & GDK_CONTROL_MASK) transform_core->trans_info[ANGLE] = FIFTEEN_DEG * (int) ((transform_core->trans_info[REAL_ANGLE] + FIFTEEN_DEG / 2.0) / FIFTEEN_DEG); diff --git a/app/scale_tool.c b/app/scale_tool.c index aeef1093d2..386d216be4 100644 --- a/app/scale_tool.c +++ b/app/scale_tool.c @@ -310,10 +310,10 @@ scale_tool_motion (tool, gdisp_ptr) } /* if just the control key is down, affect only the height */ - if (transform_core->state & ControlMask && ! (transform_core->state & ShiftMask)) + if (transform_core->state & GDK_CONTROL_MASK && ! (transform_core->state & GDK_SHIFT_MASK)) diff_x = 0; /* if just the shift key is down, affect only the width */ - else if (transform_core->state & ShiftMask && ! (transform_core->state & ControlMask)) + else if (transform_core->state & GDK_SHIFT_MASK && ! (transform_core->state & GDK_CONTROL_MASK)) diff_y = 0; *x1 += diff_x; diff --git a/app/temp_buf.c b/app/temp_buf.c index ca3b6a6268..af4faa1caa 100644 --- a/app/temp_buf.c +++ b/app/temp_buf.c @@ -15,12 +15,22 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include + +#ifdef _MSC_VER +#include /* For _getpid() */ +#endif + #include "appenv.h" #include "drawable.h" #include "errors.h" @@ -416,7 +426,8 @@ generate_unique_filename (void) { pid_t pid; pid = getpid (); - return g_strdup_printf ("%s/gimp%d.%d", temp_path, (int) pid, swap_index++); + return g_strdup_printf ("%s" G_DIR_SEPARATOR_S "gimp%d.%d", + temp_path, (int) pid, swap_index++); } diff --git a/app/text_tool.c b/app/text_tool.c index 3863a76823..23d779eb60 100644 --- a/app/text_tool.c +++ b/app/text_tool.c @@ -447,6 +447,7 @@ text_gdk_image_to_region (GdkImage *image, int scale, PixelRegion *textPR) { + GdkColor black; int black_pixel; int pixel; int value; @@ -457,7 +458,9 @@ text_gdk_image_to_region (GdkImage *image, unsigned char * data; scale2 = scale * scale; - black_pixel = BlackPixel (DISPLAY, DefaultScreen (DISPLAY)); + black.red = black.green = black.blue = 0; + gdk_colormap_alloc_color (gdk_colormap_get_system (), &black, FALSE, TRUE); + black_pixel = black.pixel; data = textPR->data; for (y = 0, scaley = 0; y < textPR->h; y++, scaley += scale) @@ -587,8 +590,10 @@ text_render (GImage *gimage, gdk_gc_set_font (gc, font); /* get black and white pixels for this gdisplay */ - black.pixel = BlackPixel (DISPLAY, DefaultScreen (DISPLAY)); - white.pixel = WhitePixel (DISPLAY, DefaultScreen (DISPLAY)); + black.red = black.green = black.blue = 0; + gdk_colormap_alloc_color (gdk_colormap_get_system (), &black, FALSE, TRUE); + white.red = white.green = white.blue = 65535; + gdk_colormap_alloc_color (gdk_colormap_get_system (), &white, FALSE, TRUE); /* Render the text into the pixmap. * Since the pixmap may not fully bound the text (because we limit its size) diff --git a/app/tile_manager.c b/app/tile_manager.c index 05aa0588c8..f4e56f305a 100644 --- a/app/tile_manager.c +++ b/app/tile_manager.c @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #include "tile_cache.h" #include "tile_manager.h" #include "tile_swap.h" diff --git a/app/tile_swap.c b/app/tile_swap.c index fbff8e511e..b94f520f1a 100644 --- a/app/tile_swap.c +++ b/app/tile_swap.c @@ -1,13 +1,21 @@ +#include "config.h" + #include #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #ifdef USE_PTHREADS #include #endif +#ifdef _MSC_VER +#include +#endif + #include "libgimp/gimpintl.h" #define MAX_OPEN_SWAP_FILES 16 @@ -352,7 +360,11 @@ tile_swap_open (SwapFile *swap_file) nopen_swap_files -= 1; } +#ifndef NATIVE_WIN32 swap_file->fd = open (swap_file->filename, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR); +#else + swap_file->fd = open (swap_file->filename, O_CREAT|O_RDWR|_O_BINARY, _S_IREAD|_S_IWRITE); +#endif if (swap_file->fd == -1) { g_message (_("unable to open swap file...BAD THINGS WILL HAPPEN SOON")); diff --git a/app/tips_dialog.c b/app/tips_dialog.c index ca89dcaf62..956d7977cd 100644 --- a/app/tips_dialog.c +++ b/app/tips_dialog.c @@ -45,9 +45,11 @@ tips_dialog_create () if (tips_count == 0) { if ((gimp_data_dir = getenv ("GIMP_DATADIR")) != NULL) - temp = (char *) g_strdup_printf ("%s/%s", gimp_data_dir, TIPS_FILE_NAME); + temp = (char *) g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", + gimp_data_dir, TIPS_FILE_NAME); else - temp = (char *) g_strdup_printf ("%s/%s", DATADIR, TIPS_FILE_NAME); + temp = (char *) g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", + DATADIR, TIPS_FILE_NAME); read_tips_file ((char *)temp); g_free (temp); } @@ -219,7 +221,7 @@ read_tips_file (char *filename) char *tip = NULL; char *str = NULL; - fp = fopen (filename, "rb"); + fp = fopen (filename, "r"); if (!fp) { store_tip (_("Your GIMP tips file appears to be missing!\n" diff --git a/app/tools/blob.c b/app/tools/blob.c index 71e960e55b..d62a34b4b2 100644 --- a/app/tools/blob.c +++ b/app/tools/blob.c @@ -31,6 +31,10 @@ #define ROUND(A) floor((A)+0.5) +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif /* M_PI */ + static Blob * blob_new (int y, int height) { diff --git a/app/tools/clone.c b/app/tools/clone.c index 05882eb3a5..0ad87e64dd 100644 --- a/app/tools/clone.c +++ b/app/tools/clone.c @@ -235,7 +235,7 @@ clone_paint_func (PaintCore *paint_core, y2 = paint_core->lasty; /* If the control key is down, move the src target and return */ - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { src_x = x1; src_y = y1; @@ -269,7 +269,7 @@ clone_paint_func (PaintCore *paint_core, break; case INIT_PAINT : - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; clone_set_src_drawable(drawable); diff --git a/app/tools/gimpclonetool.c b/app/tools/gimpclonetool.c index 05882eb3a5..0ad87e64dd 100644 --- a/app/tools/gimpclonetool.c +++ b/app/tools/gimpclonetool.c @@ -235,7 +235,7 @@ clone_paint_func (PaintCore *paint_core, y2 = paint_core->lasty; /* If the control key is down, move the src target and return */ - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { src_x = x1; src_y = y1; @@ -269,7 +269,7 @@ clone_paint_func (PaintCore *paint_core, break; case INIT_PAINT : - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; clone_set_src_drawable(drawable); diff --git a/app/tools/gimpinktool-blob.c b/app/tools/gimpinktool-blob.c index 71e960e55b..d62a34b4b2 100644 --- a/app/tools/gimpinktool-blob.c +++ b/app/tools/gimpinktool-blob.c @@ -31,6 +31,10 @@ #define ROUND(A) floor((A)+0.5) +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif /* M_PI */ + static Blob * blob_new (int y, int height) { diff --git a/app/tools/gimpposterizetool.c b/app/tools/gimpposterizetool.c index 9c241dcc3c..6eae632102 100644 --- a/app/tools/gimpposterizetool.c +++ b/app/tools/gimpposterizetool.c @@ -15,9 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include + +#ifndef HAVE_RINT +#define rint(x) floor (x + 0.5) +#endif + #include "appenv.h" #include "actionarea.h" #include "drawable.h" diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c index 00fdf6d972..04dc420776 100644 --- a/app/tools/gimprotatetool.c +++ b/app/tools/gimprotatetool.c @@ -319,7 +319,7 @@ rotate_tool_motion (tool, gdisp_ptr) /* constrain the angle to 15-degree multiples if ctrl is held down */ - if (transform_core->state & ControlMask) + if (transform_core->state & GDK_CONTROL_MASK) transform_core->trans_info[ANGLE] = FIFTEEN_DEG * (int) ((transform_core->trans_info[REAL_ANGLE] + FIFTEEN_DEG / 2.0) / FIFTEEN_DEG); diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c index aeef1093d2..386d216be4 100644 --- a/app/tools/gimpscaletool.c +++ b/app/tools/gimpscaletool.c @@ -310,10 +310,10 @@ scale_tool_motion (tool, gdisp_ptr) } /* if just the control key is down, affect only the height */ - if (transform_core->state & ControlMask && ! (transform_core->state & ShiftMask)) + if (transform_core->state & GDK_CONTROL_MASK && ! (transform_core->state & GDK_SHIFT_MASK)) diff_x = 0; /* if just the shift key is down, affect only the width */ - else if (transform_core->state & ShiftMask && ! (transform_core->state & ControlMask)) + else if (transform_core->state & GDK_SHIFT_MASK && ! (transform_core->state & GDK_CONTROL_MASK)) diff_y = 0; *x1 += diff_x; diff --git a/app/tools/gimpsourcetool.c b/app/tools/gimpsourcetool.c index 05882eb3a5..0ad87e64dd 100644 --- a/app/tools/gimpsourcetool.c +++ b/app/tools/gimpsourcetool.c @@ -235,7 +235,7 @@ clone_paint_func (PaintCore *paint_core, y2 = paint_core->lasty; /* If the control key is down, move the src target and return */ - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { src_x = x1; src_y = y1; @@ -269,7 +269,7 @@ clone_paint_func (PaintCore *paint_core, break; case INIT_PAINT : - if (paint_core->state & ControlMask) + if (paint_core->state & GDK_CONTROL_MASK) { the_src_gdisp = gdisp; clone_set_src_drawable(drawable); diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c index 3863a76823..23d779eb60 100644 --- a/app/tools/gimptexttool.c +++ b/app/tools/gimptexttool.c @@ -447,6 +447,7 @@ text_gdk_image_to_region (GdkImage *image, int scale, PixelRegion *textPR) { + GdkColor black; int black_pixel; int pixel; int value; @@ -457,7 +458,9 @@ text_gdk_image_to_region (GdkImage *image, unsigned char * data; scale2 = scale * scale; - black_pixel = BlackPixel (DISPLAY, DefaultScreen (DISPLAY)); + black.red = black.green = black.blue = 0; + gdk_colormap_alloc_color (gdk_colormap_get_system (), &black, FALSE, TRUE); + black_pixel = black.pixel; data = textPR->data; for (y = 0, scaley = 0; y < textPR->h; y++, scaley += scale) @@ -587,8 +590,10 @@ text_render (GImage *gimage, gdk_gc_set_font (gc, font); /* get black and white pixels for this gdisplay */ - black.pixel = BlackPixel (DISPLAY, DefaultScreen (DISPLAY)); - white.pixel = WhitePixel (DISPLAY, DefaultScreen (DISPLAY)); + black.red = black.green = black.blue = 0; + gdk_colormap_alloc_color (gdk_colormap_get_system (), &black, FALSE, TRUE); + white.red = white.green = white.blue = 65535; + gdk_colormap_alloc_color (gdk_colormap_get_system (), &white, FALSE, TRUE); /* Render the text into the pixmap. * Since the pixmap may not fully bound the text (because we limit its size) diff --git a/app/tools/posterize.c b/app/tools/posterize.c index 9c241dcc3c..6eae632102 100644 --- a/app/tools/posterize.c +++ b/app/tools/posterize.c @@ -15,9 +15,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include + +#ifndef HAVE_RINT +#define rint(x) floor (x + 0.5) +#endif + #include "appenv.h" #include "actionarea.h" #include "drawable.h" diff --git a/app/tools/rotate_tool.c b/app/tools/rotate_tool.c index 00fdf6d972..04dc420776 100644 --- a/app/tools/rotate_tool.c +++ b/app/tools/rotate_tool.c @@ -319,7 +319,7 @@ rotate_tool_motion (tool, gdisp_ptr) /* constrain the angle to 15-degree multiples if ctrl is held down */ - if (transform_core->state & ControlMask) + if (transform_core->state & GDK_CONTROL_MASK) transform_core->trans_info[ANGLE] = FIFTEEN_DEG * (int) ((transform_core->trans_info[REAL_ANGLE] + FIFTEEN_DEG / 2.0) / FIFTEEN_DEG); diff --git a/app/tools/scale_tool.c b/app/tools/scale_tool.c index aeef1093d2..386d216be4 100644 --- a/app/tools/scale_tool.c +++ b/app/tools/scale_tool.c @@ -310,10 +310,10 @@ scale_tool_motion (tool, gdisp_ptr) } /* if just the control key is down, affect only the height */ - if (transform_core->state & ControlMask && ! (transform_core->state & ShiftMask)) + if (transform_core->state & GDK_CONTROL_MASK && ! (transform_core->state & GDK_SHIFT_MASK)) diff_x = 0; /* if just the shift key is down, affect only the width */ - else if (transform_core->state & ShiftMask && ! (transform_core->state & ControlMask)) + else if (transform_core->state & GDK_SHIFT_MASK && ! (transform_core->state & GDK_CONTROL_MASK)) diff_y = 0; *x1 += diff_x; diff --git a/app/tools/text_tool.c b/app/tools/text_tool.c index 3863a76823..23d779eb60 100644 --- a/app/tools/text_tool.c +++ b/app/tools/text_tool.c @@ -447,6 +447,7 @@ text_gdk_image_to_region (GdkImage *image, int scale, PixelRegion *textPR) { + GdkColor black; int black_pixel; int pixel; int value; @@ -457,7 +458,9 @@ text_gdk_image_to_region (GdkImage *image, unsigned char * data; scale2 = scale * scale; - black_pixel = BlackPixel (DISPLAY, DefaultScreen (DISPLAY)); + black.red = black.green = black.blue = 0; + gdk_colormap_alloc_color (gdk_colormap_get_system (), &black, FALSE, TRUE); + black_pixel = black.pixel; data = textPR->data; for (y = 0, scaley = 0; y < textPR->h; y++, scaley += scale) @@ -587,8 +590,10 @@ text_render (GImage *gimage, gdk_gc_set_font (gc, font); /* get black and white pixels for this gdisplay */ - black.pixel = BlackPixel (DISPLAY, DefaultScreen (DISPLAY)); - white.pixel = WhitePixel (DISPLAY, DefaultScreen (DISPLAY)); + black.red = black.green = black.blue = 0; + gdk_colormap_alloc_color (gdk_colormap_get_system (), &black, FALSE, TRUE); + white.red = white.green = white.blue = 65535; + gdk_colormap_alloc_color (gdk_colormap_get_system (), &white, FALSE, TRUE); /* Render the text into the pixmap. * Since the pixmap may not fully bound the text (because we limit its size) diff --git a/app/widgets/gimpgradienteditor.c b/app/widgets/gimpgradienteditor.c index 0730bdc4f9..787c3fda79 100644 --- a/app/widgets/gimpgradienteditor.c +++ b/app/widgets/gimpgradienteditor.c @@ -148,12 +148,15 @@ * - Add a Gradient brush mode (color changes as you move it). */ +#include "config.h" #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include "appenv.h" #include "colormaps.h" @@ -168,7 +171,6 @@ #include "session.h" #include "gradient_header.h" -#include "config.h" #include "libgimp/gimpintl.h" /***** Magic numbers *****/ @@ -5970,17 +5972,20 @@ build_user_filename(char *name, char *path_str) home = g_get_home_dir (); local_path = g_strdup(path_str); first_token = local_path; - token = xstrsep(&first_token, ":"); + token = xstrsep(&first_token, G_SEARCHPATH_SEPARATOR_S); filename = NULL; if (token) { if (*token == '~') { + if (!home) + return NULL; path = g_strdup_printf("%s%s", home, token + 1); } else { path = g_strdup(token); } /* else */ - filename = g_strdup_printf("%s/%s", path, name); + filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", + path, name); g_free(path); } /* if */ diff --git a/app/widgets/gimppaletteeditor.c b/app/widgets/gimppaletteeditor.c index 5ebaa47c78..ceb9186ad7 100644 --- a/app/widgets/gimppaletteeditor.c +++ b/app/widgets/gimppaletteeditor.c @@ -15,11 +15,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "config.h" + #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif +#ifdef HAVE_DIRENT_H #include +#endif #include #include #include "appenv.h" @@ -1257,20 +1264,25 @@ palette_create_entries(gpointer client_data, home = g_get_home_dir (); local_path = g_strdup (palette_path); first_token = local_path; - token = xstrsep(&first_token, ":"); + token = xstrsep(&first_token, G_SEARCHPATH_SEPARATOR_S); if (token) { if (*token == '~') { - path = g_strdup_printf("%s%s", home, token + 1); + if (home) + path = g_strdup_printf("%s%s", home, token + 1); + else + /* Just ignore the ~ if no HOME ??? */ + path = g_strdup(token + 1); } else { path = g_strdup(token); } - entries->filename = g_strdup_printf ("%s/%s", path, palette_name); + entries->filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", + path, palette_name); g_free (path); } diff --git a/app/widgets/gimptoolbox-color-area.c b/app/widgets/gimptoolbox-color-area.c index ae86ca4355..cfdec2506d 100644 --- a/app/widgets/gimptoolbox-color-area.c +++ b/app/widgets/gimptoolbox-color-area.c @@ -17,6 +17,7 @@ */ #include +#include #include "appenv.h" #include "color_area.h" #include "color_notebook.h" diff --git a/app/xcf.c b/app/xcf.c index ef85f3ad67..3489c0b700 100644 --- a/app/xcf.c +++ b/app/xcf.c @@ -1,11 +1,17 @@ +#include "config.h" + #include #include #include #include #include +#ifdef HAVE_SYS_PARAM_H #include +#endif #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c index ef85f3ad67..3489c0b700 100644 --- a/app/xcf/xcf.c +++ b/app/xcf/xcf.c @@ -1,11 +1,17 @@ +#include "config.h" + #include #include #include #include #include +#ifdef HAVE_SYS_PARAM_H #include +#endif #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include diff --git a/libgimpbase/gimpdatafiles.c b/libgimpbase/gimpdatafiles.c index da558448b9..74aba57d30 100644 --- a/libgimpbase/gimpdatafiles.c +++ b/libgimpbase/gimpdatafiles.c @@ -18,15 +18,29 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - +#include "config.h" #include #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include +#ifdef HAVE_DIRENT_H #include +#endif + +#ifdef _MSC_VER +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) +#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) +#endif +#ifndef S_IXUSR +#define S_IXUSR _S_IEXEC +#endif +#endif #include #include "datafiles.h" @@ -70,7 +84,7 @@ datafiles_read_directories (char *path_str, next_token = local_path; - token = xstrsep(&next_token, ":"); + token = xstrsep(&next_token, G_SEARCHPATH_SEPARATOR_S); while (token) { @@ -90,8 +104,8 @@ datafiles_read_directories (char *path_str, if (!err && S_ISDIR(filestat.st_mode)) { - if (path[strlen(path) - 1] != '/') - strcat(path, "/"); + if (path[strlen(path) - 1] != G_DIR_SEPARATOR) + strcat(path, G_DIR_SEPARATOR_S); /* Open directory */ dir = opendir(path); @@ -124,7 +138,7 @@ datafiles_read_directories (char *path_str, g_free(path); - token = xstrsep(&next_token, ":"); + token = xstrsep(&next_token, G_SEARCHPATH_SEPARATOR_S); } /* while */ g_free(local_path); diff --git a/libgimpwidgets/gimpcolorselect.c b/libgimpwidgets/gimpcolorselect.c index eaee373af3..757daf9db5 100644 --- a/libgimpwidgets/gimpcolorselect.c +++ b/libgimpwidgets/gimpcolorselect.c @@ -17,6 +17,7 @@ */ #include #include +#include #include "appenv.h" #include "actionarea.h" #include "color_select.h"