$NetBSD: patch-an,v 1.1 2005/03/16 18:32:50 rillig Exp $

gcc-2.95.3 cannot handle declarations intermixed with code.

--- app/look_profile.c.orig	Tue Nov 23 12:58:14 2004
+++ app/look_profile.c	Wed Mar 16 18:45:54 2005
@@ -90,9 +90,10 @@ look_profile_change_image_height(GImage 
     list = gimage->channels;
     list = g_slist_append(list, gimage->selection_mask);
     while (list)
-    {   channel = (Channel *) list->data;
+    {
         PixelArea src_area, dest_area;
 	Canvas *new_canvas;
+        channel = (Channel *) list->data;
 
 	/*  Update the old channel position  */
 	drawable_update (GIMP_DRAWABLE(channel),
@@ -194,13 +195,16 @@ look_profile_change_layer_height(Layer *
     
       /*  If there is a layer mask, make sure it gets resized also  */
       if (layer->mask) 
-      {   GIMP_DRAWABLE(layer->mask)->offset_x = GIMP_DRAWABLE(layer)->offset_x;
+      {
+          Channel *channel;
+	  PixelArea src_area, dest_area;
+	  Canvas *new_canvas;
+	  
+          GIMP_DRAWABLE(layer->mask)->offset_x = GIMP_DRAWABLE(layer)->offset_x;
           GIMP_DRAWABLE(layer->mask)->offset_y = GIMP_DRAWABLE(layer)->offset_y;
 
 
-	  Channel* channel = GIMP_CHANNEL(layer->mask);
-	  PixelArea src_area, dest_area;
-	  Canvas *new_canvas;
+	  channel = GIMP_CHANNEL(layer->mask);
 
 	  /*  Update the old channel position  */
 	  drawable_update (GIMP_DRAWABLE(channel),
@@ -253,6 +257,18 @@ look_profile_change_layer_height(Layer *
 LookProfile *
 look_profile_create(GImage *image, gint sample_depth)
 {   LookProfile *look_profile;
+    PixelArea sample_area;
+    CMSProfile *lab_profile, *input_profile;
+    GSList *profiles = NULL;
+    DWORD lcms_format_out;
+    CMSTransform *transform;
+    guint16 Lab[3];
+    guint8 rgb[3];
+    PixelRow row_buffer;
+    void *pag;
+    gint col_index;
+    guint8 *row_data;
+    gint sample_step;
             
     gint num_pix = pow(sample_depth, 3);
        
@@ -267,37 +283,32 @@ look_profile_create(GImage *image, gint 
 #endif
 
     
-    PixelArea sample_area;
     pixelarea_init(&sample_area, look_profile->canvas, 
 		   0, 0, canvas_width(look_profile->canvas), 1, TRUE);
   
     /* get a lab->rgb transform 
        (the reference strip is calculated iterating over Lab, the image is rgb) */
-    CMSProfile *lab_profile = cms_get_lab_profile(NULL);
-    CMSProfile *input_profile = gimage_get_cms_profile(image);
+    lab_profile = cms_get_lab_profile(NULL);
+    input_profile = gimage_get_cms_profile(image);
     if (!input_profile) 
     {   input_profile = cms_get_srgb_profile();
     }
 
-    GSList *profiles = NULL;
     profiles = g_slist_append(profiles, lab_profile);
     profiles = g_slist_append(profiles, input_profile);
-    DWORD lcms_format_out= cms_get_lcms_format(gimage_tag(image),input_profile);
-    CMSTransform *transform = cms_get_transform(profiles, TYPE_Lab_16,
+    lcms_format_out= cms_get_lcms_format(gimage_tag(image),input_profile);
+    transform = cms_get_transform(profiles, TYPE_Lab_16,
 						lcms_format_out,
 						INTENT_PERCEPTUAL,
                                                 cms_default_flags);
     g_slist_free(profiles);
 
     /* iterate over Lab space, converting to rgb, filling into picture */
-    guint16 Lab[3];
-    guint8 rgb[3];
-    PixelRow row_buffer;
-    void *pag = pixelarea_register (1, &sample_area);
+    pag = pixelarea_register (1, &sample_area);
     pixelarea_getdata (&sample_area, &row_buffer, 0);
-    gint col_index = pixelrow_width(&row_buffer);
-    guint8 *row_data = pixelrow_data(&row_buffer);
-    gint sample_step = 65535/(sample_depth-1);
+    col_index = pixelrow_width(&row_buffer);
+    row_data = pixelrow_data(&row_buffer);
+    sample_step = 65535/(sample_depth-1);
 
     Lab[0]=Lab[1]=Lab[2]=0;
     while (TRUE)
@@ -384,8 +395,10 @@ look_profile_new_dialog ()
 void 
 look_profile_include (LookProfile *profile, ImageMapApplyFunc func, void *data)
 {   PixelArea src_area, dest_area;
+    Canvas *new_canvas;
+    void *pag;
     pixelarea_init(&src_area, profile->canvas, 0,0, canvas_width(profile->canvas), 1, FALSE);
-    Canvas *new_canvas= canvas_new (canvas_tag(profile->canvas), canvas_width(profile->canvas), 1,
+    new_canvas= canvas_new (canvas_tag(profile->canvas), canvas_width(profile->canvas), 1,
 #ifdef NO_TILES						  
 						  STORAGE_FLAT);
 #else
@@ -393,7 +406,6 @@ look_profile_include (LookProfile *profi
 #endif
     pixelarea_init(&dest_area, new_canvas, 0,0, canvas_width(profile->canvas), 1, TRUE);
 
-    void *pag;
     for (pag = pixelarea_register (2, &src_area, &dest_area);
 	 pag != NULL;
 	 pag = pixelarea_process (pag))
@@ -431,6 +443,13 @@ void
 look_profile_save (LookProfile *profile,
 		   gchar *file_name, int intent, DWORD flags)
 {   /* create a new profile, abstract, Lab */
+    LPLUT AToB0;
+    SampleInfo *sample_info;
+    CMSProfile *input_profile, *lab_profile;
+    Tag t;
+    GSList *profiles = NULL;
+    PixelRow row_buffer;
+
     cmsHPROFILE saved_profile = cmsOpenProfileFromFile(file_name, "w");
     cmsSetColorSpace(saved_profile, icSigLabData);
     cmsSetPCS(saved_profile, icSigLabData);
@@ -438,22 +457,21 @@ look_profile_save (LookProfile *profile,
 
     cmsSetDeviceClass(saved_profile, icSigAbstractClass);
 
-    LPLUT AToB0 = cmsAllocLUT();
+    AToB0 = cmsAllocLUT();
     cmsAlloc3DGrid(AToB0, profile->sample_depth, 3, 3);
     
-    SampleInfo *sample_info = g_new(SampleInfo, 1);
+    sample_info = g_new(SampleInfo, 1);
     sample_info->profile = profile;
 
     /* create a transform from image space to lab (the space of the 
        new abstract profile, just the other way from  before)*/
-    CMSProfile *input_profile = gimage_get_cms_profile(sample_info->profile->image);
+    input_profile = gimage_get_cms_profile(sample_info->profile->image);
     if (!input_profile) 
     {   input_profile = cms_get_srgb_profile();
     }
-    CMSProfile *lab_profile = cms_get_lab_profile(NULL);
+    lab_profile = cms_get_lab_profile(NULL);
 
-    Tag t = gimage_tag(sample_info->profile->image);
-    GSList *profiles = NULL;
+    t = gimage_tag(sample_info->profile->image);
     profiles = g_slist_append(profiles, input_profile);
     profiles = g_slist_append(profiles, lab_profile);
     sample_info->transform = cms_get_transform(profiles,
@@ -466,7 +484,6 @@ look_profile_save (LookProfile *profile,
 		   canvas_width(profile->canvas), 1,FALSE);
 
     sample_info->pag = pixelarea_register (1, &sample_info->sample_area);
-    PixelRow row_buffer;
     pixelarea_getdata (&sample_info->sample_area, &row_buffer, 0);
     sample_info->col_index = pixelrow_width (&row_buffer);
     sample_info->current_pixel = pixelrow_data(&row_buffer);
@@ -700,28 +717,33 @@ _look_profile_gui_free_row_data(gpointer
 
 static void 
 _look_profile_gui_update_list(_LookProfileGui *data)
-{   data->row_count=0;    
+{
+    GSList *profile_file_names, *iterator;
+    gint path_length;
+    char *file_path;
+    _LookProfileGuiRowData *row_data = NULL;
+
+    data->row_count=0;    
     gtk_clist_clear(GTK_CLIST(data->profile_list));
 
-    GSList *profile_file_names = cms_read_icc_profile_dir(look_profile_path, icSigAbstractClass);     
+    profile_file_names = cms_read_icc_profile_dir(look_profile_path, icSigAbstractClass);     
     if (!profile_file_names)
     {   return;
     }
 
-    gint path_length = strlen(look_profile_path); 
-    gchar *file_path;
+    path_length = strlen(look_profile_path); 
     /* row_data[0] contains the path of the profile,
        row_data[1] is NULL if off, profile handle if on */
-    _LookProfileGuiRowData *row_data = NULL;
 
-    GSList *iterator = profile_file_names; 
+    iterator = profile_file_names; 
     while (iterator != NULL)      
-    {   file_path = (gchar *)iterator->data;
+    {
+	/* the text to display in the row, one element per column */
+	gchar *row_text[2] = {NULL, NULL};
+        file_path = (gchar *)iterator->data;
         row_data = g_new(_LookProfileGuiRowData, 1);
         row_data->file_name = file_path;
 	row_data->handle = NULL;
-	/* the text to display in the row, one element per column */
-	gchar *row_text[2] = {NULL, NULL};
         /* strdup(file_path + path_length + 1) extracts the filename from the path */
 	row_text[1] = strdup(file_path + path_length + 1);
         gtk_clist_insert(GTK_CLIST(data->profile_list), data->row_count, row_text);	    
@@ -813,10 +835,10 @@ _look_profile_gui_open_cb (GtkWidget *wi
 
 static void 
 _look_profile_gui_open_ok_cb(GtkWidget *widget, _LookProfileGui *data) 
-{   look_profile_path = strdup(gtk_file_selection_get_filename (GTK_FILE_SELECTION(data->file_selector)));
-
+{
     GList *update_settings = NULL;
     GList *remove_settings = NULL;
+    look_profile_path = strdup(gtk_file_selection_get_filename (GTK_FILE_SELECTION(data->file_selector)));
     update_settings = g_list_append(update_settings, "look-profile-path");
     save_gimprc(&update_settings, &remove_settings); 
     g_list_free(update_settings);
@@ -829,6 +851,10 @@ void 
 _look_profile_gui_apply(_LookProfileGui *data)
 {   GSList *profiles = NULL;
     CMSProfile *image_profile = gimage_get_cms_profile(data->display->gimage);
+    DWORD lcms_format;
+    CMSTransform *transform;
+    int i;
+
     if (image_profile == NULL)
     {   image_profile = cms_get_srgb_profile();
     }
@@ -836,9 +862,9 @@ _look_profile_gui_apply(_LookProfileGui 
     profiles = g_slist_append(profiles, (gpointer)image_profile);
     profiles = g_slist_concat(profiles, g_slist_copy(gdisplay_get_look_profile_pipe(data->display)));
     profiles = g_slist_append(profiles, (gpointer)image_profile);
-    DWORD lcms_format = cms_get_lcms_format(gimage_tag(data->display->gimage),
+    lcms_format = cms_get_lcms_format(gimage_tag(data->display->gimage),
                                             image_profile);
-    CMSTransform *transform = cms_get_transform(profiles,
+    transform = cms_get_transform(profiles,
                                         lcms_format, lcms_format,
                                         gdisplay_get_cms_intent(data->display),
                                         gdisplay_get_cms_flags(data->display));
@@ -847,7 +873,6 @@ _look_profile_gui_apply(_LookProfileGui 
     cms_return_transform(transform);
 
     /* resets all the selections */
-    int i;
     for (i=0; i<data->row_count; i++)
     {   _look_profile_gui_profile_set_active(data, i, FALSE);
     }
@@ -855,13 +880,22 @@ _look_profile_gui_apply(_LookProfileGui 
 
 void 
 _look_profile_gui_apply_flipbook (_LookProfileGui *data)
-{   if (data->display->bfm == NULL)
+{
+    GSList *profiles = NULL;
+    CMSProfile *image_profile;
+    DWORD lcms_format;
+    CMSTransform *transform;
+    GtkWidget *progress_dialog, *vbox, *progress_bar;
+    GSList *iterator;
+    gint num_images, count;
+    int i;
+
+    if (data->display->bfm == NULL)
     {   g_message("This display has no flipbook. Application to flipbook stores not possible");
         return;
     }
 
-    GSList *profiles = NULL;
-    CMSProfile *image_profile = gimage_get_cms_profile(data->display->gimage);
+    image_profile = gimage_get_cms_profile(data->display->gimage);
     if (image_profile == NULL)
     {   image_profile = cms_get_srgb_profile();
     }
@@ -869,23 +903,23 @@ _look_profile_gui_apply_flipbook (_LookP
     profiles = g_slist_append(profiles, (gpointer)image_profile);
     profiles = g_slist_concat(profiles, g_slist_copy(gdisplay_get_look_profile_pipe(data->display)));
     profiles = g_slist_append(profiles, (gpointer)image_profile);
-    DWORD lcms_format = cms_get_lcms_format(gimage_tag(data->display->gimage), image_profile);
-    CMSTransform *transform = cms_get_transform(profiles,
+    lcms_format = cms_get_lcms_format(gimage_tag(data->display->gimage), image_profile);
+    transform = cms_get_transform(profiles,
                                         lcms_format, lcms_format,
                                         gdisplay_get_cms_intent(data->display),
                                         gdisplay_get_cms_flags(data->display));
     g_slist_free(profiles);
 
     /* create progress dialog */
-    GtkWidget *progress_dialog = gtk_window_new(GTK_WINDOW_DIALOG);    
+    progress_dialog = gtk_window_new(GTK_WINDOW_DIALOG);    
     gtk_window_set_wmclass (GTK_WINDOW (progress_dialog), "progress", PROGRAM_NAME);
     gtk_window_set_title (GTK_WINDOW (progress_dialog), "Applying look to flipbook stores...");
     gtk_window_set_position(GTK_WINDOW(progress_dialog), GTK_WIN_POS_CENTER);
 
-    GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
+    vbox = gtk_vbox_new(FALSE, 0);
     gtk_container_add (GTK_CONTAINER (progress_dialog), vbox);
 
-    GtkWidget *progress_bar = gtk_progress_bar_new();
+    progress_bar = gtk_progress_bar_new();
     gtk_box_pack_start (GTK_BOX(vbox), progress_bar, TRUE, TRUE, 0);
     gtk_widget_set_usize(progress_bar, 250,-1);
     gtk_widget_show_all(progress_dialog);
@@ -894,9 +928,9 @@ _look_profile_gui_apply_flipbook (_LookP
     gtk_widget_draw(progress_bar, NULL);
     gdk_flush();
 
-    GSList *iterator = data->display->bfm->sfm->stores;
-    gint num_images = g_slist_length(iterator);
-    gint count = 0;
+    iterator = data->display->bfm->sfm->stores;
+    num_images = g_slist_length(iterator);
+    count = 0;
     while (iterator != NULL)
     {   store *store = iterator->data;
 	gimage_transform_colors(store->gimage, transform, FALSE);
@@ -914,7 +948,6 @@ _look_profile_gui_apply_flipbook (_LookP
     cms_return_transform(transform);
 
     /* resets all the selections */
-    int i;
     for (i=0; i<data->row_count; i++)
     {   _look_profile_gui_profile_set_active(data, i, FALSE);
     }
