[AD] Fix build with GCC 3.1 and later

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


This patch fixes the build of the whole distribution with GCC 3.1 and later. 
It removes 4 calls to deprecated functions from a few demo, tool and 
example programs.

Applied to mainline.

-- 
Eric Botcazou
Index: demo/demo.c
===================================================================
RCS file: /cvsroot/alleg/allegro/demo/demo.c,v
retrieving revision 1.18
diff -u -r1.18 demo.c
--- demo/demo.c	14 Oct 2002 00:25:06 -0000	1.18
+++ demo/demo.c	14 May 2003 18:42:13 -0000
@@ -1348,7 +1348,7 @@
 
 
 /* reads credit info from a source file */
-void parse_source(AL_CONST char *filename, int attrib, int param)
+int parse_source(AL_CONST char *filename, int attrib, void *param)
 {
    char buf[256];
    PACKFILE *f;
@@ -1367,7 +1367,7 @@
 	 put_backslash(buf);
 	 strcat(buf, "*.*");
 
-	 for_each_file(buf, FA_ARCH | FA_RDONLY | FA_DIREC, parse_source, param);
+	 for_each_file_ex(buf, 0, ~(FA_ARCH | FA_RDONLY | FA_DIREC), parse_source, param);
       }
    }
    else {
@@ -1380,9 +1380,9 @@
 	 /* parse a source file */
 	 f = pack_fopen(filename, F_READ);
 	 if (!f)
-	    return;
+	    return -1;
 
-	 textprintf_centre_ex(screen, font, SCREEN_W/2, SCREEN_H/2+8, makecol(160, 160, 160), 0, "                %s                ", filename+param);
+	 textprintf_centre_ex(screen, font, SCREEN_W/2, SCREEN_H/2+8, makecol(160, 160, 160), 0, "                %s                ", filename+(int)(unsigned long)param);
 
 	 while (pack_fgets(buf, sizeof(buf)-1, f) != 0) {
 	    if (strstr(buf, "*/"))
@@ -1393,14 +1393,14 @@
 	    while (c) {
 	       if (strstr(buf, c->name)) {
 		  for (d=c->files; d; d=d->next) {
-		     if (strcmp(d->text, filename+param) == 0)
+		     if (strcmp(d->text, filename+(int)(unsigned long)param) == 0)
 			break;
 		  }
 
 		  if (!d) {
 		     d = malloc(sizeof(TEXT_LIST));
-		     d->text = malloc(strlen(filename+param)+1);
-		     strcpy(d->text, filename+param);
+		     d->text = malloc(strlen(filename+(int)(unsigned long)param)+1);
+		     strcpy(d->text, filename+(int)(unsigned long)param);
 		     d->next = c->files;
 		     c->files = d;
 		  }
@@ -1413,6 +1413,8 @@
 	 pack_fclose(f);
       }
    }
+
+   return 0;
 }
 
 
@@ -1571,7 +1573,7 @@
    get_executable_name(buf, sizeof(buf));
    replace_filename(buf2, buf, "../*.*", sizeof(buf2));
 
-   for_each_file(buf2, FA_ARCH | FA_RDONLY | FA_DIREC, parse_source, strlen(buf2)-3);
+   for_each_file_ex(buf2, 0, ~(FA_ARCH | FA_RDONLY | FA_DIREC), parse_source, (void *)(unsigned long)(strlen(buf2)-3));
 
    /* sort the lists */
    sort_credit_list();
Index: examples/exconfig.c
===================================================================
RCS file: /cvsroot/alleg/allegro/examples/exconfig.c,v
retrieving revision 1.2
diff -u -r1.2 exconfig.c
--- examples/exconfig.c	20 Mar 2003 07:41:41 -0000	1.2
+++ examples/exconfig.c	14 May 2003 18:42:13 -0000
@@ -143,8 +143,7 @@
       allegro_message("%s not found\n", filename); 
    }
 
-   text_mode(-1);
-   textout_centre(screen, font, title, SCREEN_W/2, 20, makecol(r,g,b));
+   textout_centre_ex(screen, font, title, SCREEN_W/2, 20, makecol(r,g,b), -1);
 
    readkey();
 
Index: tools/dat.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/dat.c,v
retrieving revision 1.20
diff -u -r1.20 dat.c
--- tools/dat.c	1 Oct 2002 09:49:43 -0000	1.20
+++ tools/dat.c	14 May 2003 18:42:17 -0000
@@ -391,7 +391,7 @@
 
 
 /* adds a file to the archive */
-static void do_add_file(AL_CONST char *filename, int attrib, int param)
+static int do_add_file(AL_CONST char *filename, int attrib, void *param)
 {
    char fname[256];
    char name[256];
@@ -414,21 +414,27 @@
    for (c=0; datafile[c].type != DAT_END; c++) {
       if (stricmp(name, get_datafile_property(datafile+c, DAT_NAME)) == 0) {
 	 printf("Replacing %s -> %s\n", fname, name);
-	 if (!datedit_grabreplace(datafile+c, fname, name, opt_objecttype, opt_colordepth, opt_gridx, opt_gridy, opt_gridw, opt_gridh))
-	    errno = err = 1;
-	 else
+	 if (!datedit_grabreplace(datafile+c, fname, name, opt_objecttype, opt_colordepth, opt_gridx, opt_gridy, opt_gridw, opt_gridh)) {
+	    err = 1;
+	    return -1;
+	 }
+	 else {
 	    changed = TRUE;
-	 return;
+	    return 0;
+	 }
       }
    }
 
    printf("Inserting %s -> %s\n", fname, name);
    d = datedit_grabnew(datafile, fname, name, opt_objecttype, opt_colordepth, opt_gridx, opt_gridy, opt_gridw, opt_gridh);
-   if (!d)
-      errno = err = 1;
+   if (!d) {
+      err = 1;
+      return -1;
+   }
    else {
       datafile = d;
       changed = TRUE;
+      return 0;
    }
 }
 
@@ -925,9 +931,8 @@
 	       }
 	       else {
 		  for (c=0; c<opt_numnames; c++) {
-		     if (for_each_file(opt_namelist[c], FA_ARCH | FA_RDONLY, do_add_file, 0) <= 0) {
-			if (errno)
-			   fprintf(stderr, "Error: %s not found\n", opt_namelist[c]);
+		     if (for_each_file_ex(opt_namelist[c], 0, ~(FA_ARCH | FA_RDONLY), do_add_file, NULL) <= 0) {
+			fprintf(stderr, "Error: %s not found\n", opt_namelist[c]);
 			err = 1;
 			break;
 		     }
Index: tools/pat2dat.c
===================================================================
RCS file: /cvsroot/alleg/allegro/tools/pat2dat.c,v
retrieving revision 1.15
diff -u -r1.15 pat2dat.c
--- tools/pat2dat.c	1 Oct 2002 10:55:06 -0000	1.15
+++ tools/pat2dat.c	14 May 2003 18:42:22 -0000
@@ -410,7 +410,7 @@
 
 
 /* reads a MIDI file to see what patches it requires */
-static void read_midi(AL_CONST char *filename, int attrib, int param)
+static int read_midi(AL_CONST char *filename, int attrib, void *param)
 {
    char patches[128], drums[128];
    char fname[256];
@@ -425,8 +425,8 @@
    midi = load_midi(fname);
    if (!midi) {
       fprintf(stderr, "Error reading %s\n", fname);
-      errno = err = 1;
-      return;
+      err = 1;
+      return -1;
    }
 
    scan_patches(midi, patches, drums);
@@ -454,6 +454,7 @@
    }
 
    destroy_midi(midi);
+   return 0;
 }
 
 
@@ -2401,11 +2402,8 @@
       need_patches[0] = TRUE;    /* always load the piano */
 
       for (c=0; c<opt_numnames; c++) {
-	 if (for_each_file(opt_namelist[c], FA_ARCH | FA_RDONLY, read_midi, 0) <= 0) {
+	 if (for_each_file_ex(opt_namelist[c], 0, ~(FA_ARCH | FA_RDONLY), read_midi, NULL) <= 0) {
 	    fprintf(stderr, "Error: %s not found\n", opt_namelist[c]);
-	    err = 1;
-	 }
-	 if (errno) {
 	    err = 1;
 	    break;
 	 }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/