summaryrefslogtreecommitdiff
path: root/wm/afterstep/patches/patch-libAfterImage_import.c
blob: be7a5d3a6ecb211a7a1d56a8c6d10f110e8b3f8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
$NetBSD: patch-libAfterImage_import.c,v 1.3 2016/05/01 19:26:35 dholland Exp $

- use ctype.h correctly
- fix for png-1.5

--- libAfterImage/import.c.orig	2010-09-23 20:57:57.000000000 +0000
+++ libAfterImage/import.c
@@ -221,7 +221,7 @@ char *locate_image_file_in_path( const c
 		if( realfilename == NULL )
 		{ /* let's try and see if we have subimage number appended */
 			for( i = filename_len-1 ; i > 0; i-- )
-				if( !isdigit( (int)tmp[i] ) )
+				if( !isdigit( (unsigned char)tmp[i] ) )
 					break;
 			if( i < filename_len-1 && i > 0 )
 				if( tmp[i] == '.' )                 /* we have possible subimage number */
@@ -878,7 +878,7 @@ load_asimage_list_entry_data( ASImageLis
 		int i = entry->buffer->size ; 
 		register char *ptr = entry->buffer->data ;
 		while ( --i >= 0 )	
-			if( !isprint(ptr[i]) && ptr[i] != '\n'&& ptr[i] != '\r'&& ptr[i] != '\t' )	
+			if( !isprint((unsigned char)ptr[i]) && ptr[i] != '\n'&& ptr[i] != '\r'&& ptr[i] != '\t' )	
 				break;
 		binary = (i >= 0);				
 	}else
@@ -980,7 +980,7 @@ check_image_type( const char *realfilena
 				type = ASIT_Gif;
 			else if (head[0] == head[1] && (head[0] == 'I' || head[0] == 'M'))
 				type = ASIT_Tiff;
-			else if (head[0] == 'P' && isdigit(head[1]))
+			else if (head[0] == 'P' && isdigit((unsigned char)head[1]))
 				type = (head[1]!='5' && head[1]!='6')?ASIT_Pnm:ASIT_Ppm;
 			else if (head[0] == 0xa && head[1] <= 5 && head[2] == 1)
 				type = ASIT_Pcx;
@@ -1014,13 +1014,13 @@ check_image_type( const char *realfilena
 				int i ;
 
 				type = ASIT_XMLScript ;
-				for( i = 0 ; i < bytes_in ; ++i ) if( !isspace(head[i]) ) break;
+				for( i = 0 ; i < bytes_in ; ++i ) if( !isspace((unsigned char)head[i]) ) break;
 				while( bytes_in > 0 && type == ASIT_XMLScript )
 				{
 					if( i >= bytes_in )
 					{	
 						bytes_in = fread( &(head[0]), sizeof(CARD8), FILE_HEADER_SIZE, fp );
-						for( i = 0 ; i < bytes_in ; ++i ) if( !isspace(head[i]) ) break;
+						for( i = 0 ; i < bytes_in ; ++i ) if( !isspace((unsigned char)head[i]) ) break;
 					}
 					else if( head[i] != '<' )
 						type = ASIT_Unknown ;
@@ -1030,7 +1030,7 @@ check_image_type( const char *realfilena
 					}else if( mystrncasecmp( &(head[i]), "<!DOCTYPE ", 10 ) == 0 ) 
 					{	
 						type = ASIT_XML ;
-						for( i += 9 ; i < bytes_in ; ++i ) if( !isspace(head[i]) ) break;
+						for( i += 9 ; i < bytes_in ; ++i ) if( !isspace((unsigned char)head[i]) ) break;
 						if( i < bytes_in ) 
 						{
 					 		if( mystrncasecmp( &(head[i]), "afterstep-image-xml", 19 ) == 0 ) 			
@@ -1044,9 +1044,9 @@ check_image_type( const char *realfilena
 						while( bytes_in > 0 && type == ASIT_XMLScript )
 						{
 							while( ++i < bytes_in )
-								if( !isspace(head[i]) )
+								if( !isspace((unsigned char)head[i]) )
 								{
-									if( !isprint(head[i]) )
+									if( !isprint((unsigned char)head[i]) )
 									{
 										type = ASIT_Unknown ;
 										break ;
@@ -1251,7 +1251,7 @@ png2ASImage_int( void *data, png_rw_ptr 
 			 * the normal method of doing things with libpng).  REQUIRED unless you
 			 * set up your own error handlers in the png_create_read_struct() earlier.
 			 */
-			if ( !setjmp (png_ptr->jmpbuf))
+			if ( !setjmp (png_jmpbuf(png_ptr)))
 			{
 				ASFlagType rgb_flags = ASStorage_RLEDiffCompress|ASStorage_32Bit ;
 
@@ -1447,8 +1447,8 @@ png2ASImage_int( void *data, png_rw_ptr 
 		}
 		/* clean up after the read, and free any memory allocated - REQUIRED */
 		png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp) NULL);
-		if (info_ptr)
-			free (info_ptr);
+//		if (info_ptr)
+//			free (info_ptr);
 	}
 
 #if defined(LOCAL_DEBUG) && !defined(NO_DEBUG_OUTPUT)
@@ -1468,7 +1468,7 @@ typedef struct ASImPNGReadBuffer
 
 static void asim_png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
 {
-   ASImPNGReadBuffer *buf = (ASImPNGReadBuffer *)png_ptr->io_ptr;
+   ASImPNGReadBuffer *buf = (ASImPNGReadBuffer *)png_get_io_ptr(png_ptr);
    memcpy(data, buf->buffer, length);
    buf->buffer += length;
 }
@@ -1828,8 +1828,8 @@ ppm2ASImage( const char * path, ASImageI
 						break;
 					}
 					width = atoi( &(buffer[i]) );
-					while ( buffer[i] != '\0' && !isspace((int)buffer[i]) ) ++i;
-					while ( isspace((int)buffer[i]) ) ++i;
+					while ( buffer[i] != '\0' && !isspace((unsigned char)buffer[i]) ) ++i;
+					while ( isspace((unsigned char)buffer[i]) ) ++i;
 					if( buffer[i] != '\0')
 						height = atoi(&(buffer[i]));
 				}