summarylogtreecommitdiffstats
path: root/alfont-2.0.9-remove-alfont_get_string.patch
blob: df7d623652f3b6f5041b703a181f4d4d1d583f0b (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
Remove alfont_get_string

alfont_get_string has a weird, weird API where its destination is char **out,
yet it does not return an allocated buffer in out, instead it uses _msize
on it to check if the passed in buffer is big enough ?? Which means the
parameter could have been a char * just as well ??

Anyways we don't have _msize on Linux, and no alfont using apps actually use
alfont_get_string(), so this patch just removes it completely, fixing the
_msize problem.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
diff -up alfont-2.0.9/include/alfont.h~ alfont-2.0.9/include/alfont.h
--- alfont-2.0.9/include/alfont.h~	2012-07-29 11:51:08.000000000 +0200
+++ alfont-2.0.9/include/alfont.h	2012-07-29 11:58:53.194121909 +0200
@@ -103,8 +103,6 @@ ALFONT_DLL_DECLSPEC int alfont_ugetc(ALF
 ALFONT_DLL_DECLSPEC int alfont_ugetx(ALFONT_FONT *f, char **s);									//Returns the character pointered by `s' in the current encoding format, and advances the pointer to the next character after the one just returned
 ALFONT_DLL_DECLSPEC int alfont_ugetxc(ALFONT_FONT *f, const char **s);							//Returns the character pointered by `s' in the current encoding format, and advances the pointer to the next character after the one just returned
 
-ALFONT_DLL_DECLSPEC void alfont_get_string(ALFONT_FONT *f, const char *s , char **out);			//Gets the converted string pointered by `s' in the current encoding format
-
 ALFONT_DLL_DECLSPEC void alfont_set_font_outline_top(ALFONT_FONT *f, int w);					//Sets Font top outline width
 ALFONT_DLL_DECLSPEC int alfont_get_font_outline_top(ALFONT_FONT *f);							//Returns Font top outline width
 ALFONT_DLL_DECLSPEC void alfont_set_font_outline_bottom(ALFONT_FONT *f, int w);					//Sets Font bottom outline width
diff -up alfont-2.0.9/src/alfont.c~ alfont-2.0.9/src/alfont.c
--- alfont-2.0.9/src/alfont.c~	2012-07-29 11:51:08.000000000 +0200
+++ alfont-2.0.9/src/alfont.c	2012-07-29 11:58:44.277233388 +0200
@@ -4156,256 +4156,6 @@ int alfont_ugetxc(ALFONT_FONT *f, const
   return character;
 }
 
-void alfont_get_string(ALFONT_FONT *f, const char *s , char **out){
-  char *lpszW;
-  char *lpszW_pointer=NULL; //used for freeing string
-  char *s_pointer=NULL; //used for original string fixed by autofix
-  char *s_pointer_temp=NULL; //temporary used for autofix string
-  char *precedingchar_pointer=NULL; //used for precedingchar character
-  int nLen;
-  int ret; //decide that if the ASCII Code convert to Unicode Code is all OK when used for autofix string or used for general convert.
-  int curr_uformat;
-
-  #ifdef ALFONT_DOS
-  iconv_t c_pt;
-  size_t fromlen, tolen;
-  char *sin, *sout;
-  #endif
-  
-  if (s == NULL) {
-	return;
-  }
-
-  nLen = strlen(s) + 1;
-  s_pointer = (char *)malloc(nLen*sizeof(char));
-  memset(s_pointer, 0, nLen);
-  strcpy(s_pointer, s);
-  
-  //Auto Fix for cutted string
-  //For ASCII convert to unicode
-  //Add the previous character to the s string
-  //If find the cutted character, store it from the converted s string and remove it from the original s string
-  if (f->autofix==TRUE) {
-	if (f->type==2) {
-		curr_uformat=get_uformat();
-
-		#ifdef ALFONT_DOS
-		if ((c_pt = iconv_open("UTF-16LE", f->language)) != (iconv_t)-1) {
-  			
-			fromlen  = strlen(s) + 1;
-			tolen = MB_CUR_MAX * fromlen * (sizeof(wchar_t) + 1);
-			
-			//add the previous character to the s string
-			if (f->precedingchar != 0) {
-				free(s_pointer);
-				fromlen  = strlen(s) + 1 + 1;
-				tolen = MB_CUR_MAX * fromlen * (sizeof(wchar_t) + 1);
-				s_pointer = (char *)malloc(tolen*sizeof(char));
-				memset(s_pointer, 0, tolen);		
-				precedingchar_pointer=(char *)malloc(2*sizeof(char));
-				memset(precedingchar_pointer, 0, 2);
-				sprintf(precedingchar_pointer, "%c", f->precedingchar);
-				strcpy(s_pointer,precedingchar_pointer);
-				if (precedingchar_pointer) {
-					free(precedingchar_pointer);
-					precedingchar_pointer = NULL;
-				}
-				strcat(s_pointer, s);
-				f->precedingchar = 0;
-			}
-
-			iconv(c_pt, NULL, NULL, NULL, NULL);
-  			lpszW = (char *)malloc(tolen*sizeof(char));
-			memset(lpszW, 0, tolen);
-  			sin = s;
-  			sout = lpszW;
-  			ret = iconv(c_pt, &sin, &fromlen, &sout, &tolen);
-  			iconv_close(c_pt);
-
-			s_pointer_temp = s_pointer;
-
-			if (ret == -1) { //If the ret is -1, the final one will can be a shortcutted character.
-				//store the last character to precedingchar character
-				//get the final character
-				set_uformat(curr_uformat);
-				while (*s_pointer_temp != '\0') {
-					f->precedingchar = *s_pointer_temp;
-					s_pointer_temp++;
-				}
-				//remove the final character
-				s_pointer_temp--;
-				*s_pointer_temp = '\0';
-        	}
-			if (lpszW) {
-				free(lpszW);
-				lpszW = NULL;
-			}
-  		}
-		#else
-		
-
-		#ifdef ALFONT_LINUX
-		nLen = strlen(s_pointer) * 5 + 1;
-		#else
-		nLen = strlen(s_pointer) + 1;
-		#endif
-		
-		//add the previous character to the s string
-		if (f->precedingchar != 0) {
-			free(s_pointer);
-			nLen = strlen(s) + 1 + 1;
-			s_pointer = (char *)malloc(nLen*sizeof(char));
-			memset(s_pointer, 0, nLen);
-			precedingchar_pointer=(char *)malloc(2*sizeof(char));
-			memset(precedingchar_pointer, 0, 2);
-			sprintf(precedingchar_pointer, "%c", f->precedingchar);
-			strcpy(s_pointer,precedingchar_pointer);
-			if (precedingchar_pointer) {
-				free(precedingchar_pointer);
-				precedingchar_pointer = NULL;
-			}
-			strcat(s_pointer, s);
-			f->precedingchar = 0;
-		}
-		
-		setlocale(LC_CTYPE,f->language);
-		set_uformat(U_UNICODE);
-
-		lpszW = (char *)malloc(nLen*sizeof(wchar_t));
-		memset(lpszW, 0, nLen);
-		ret = mbstowcs((wchar_t *)lpszW, s_pointer, nLen);
-
-		s_pointer_temp = s_pointer;
-
-		if (ret == -1) { //If the ret is -1, the final one will can be a shortcutted character.
-			//store the last character to precedingchar character
-			//get the final character
-			set_uformat(curr_uformat);
-			while (*s_pointer_temp != '\0') {
-				f->precedingchar = *s_pointer_temp;
-				s_pointer_temp++;
-			}
-			//remove the final character
-			s_pointer_temp--;
-			*s_pointer_temp = '\0';
-		}
-		if (lpszW) {
-			free(lpszW);
-			lpszW = NULL;
-		}
-		#endif
-		//recover to original codepage
-		set_uformat(curr_uformat);
-	}
-  }
-
-
-  //Font Code Convert
-
-  
-  if (f->type==1) {
-  	
-	#ifdef ALFONT_DOS
-	if ((c_pt = iconv_open(f->language, "UTF-16LE")) == (iconv_t)-1) {
-     	lpszW = (char *)s_pointer;
-  	}
-  	else {
-		iconv(c_pt, NULL, NULL, NULL, NULL);
-  		fromlen  = strlen(s_pointer) + 1;
-		tolen = MB_CUR_MAX * fromlen * (sizeof(wchar_t) + 1);
-  		lpszW = (char *)malloc(tolen*sizeof(char));
-		memset(lpszW, 0, tolen);
-  		sin = s_pointer;
-  		sout = lpszW;
-  		ret = iconv(c_pt, &sin, &fromlen, &sout, &tolen);
-  		iconv_close(c_pt);
-  		if (ret == -1) {
-           	lpszW = (char *)s_pointer;
-        }
-	}
-	#else
-	setlocale(LC_CTYPE,f->language);
-	nLen= MB_CUR_MAX * wcslen((const wchar_t*)s_pointer) + 1;
-	lpszW = (char *)malloc(nLen*sizeof(char));
-	memset(lpszW, 0, nLen);
-	wcstombs(lpszW, (const wchar_t *)s_pointer, nLen);
-	#endif
-  }
-  else if(f->type==2) {
-  	curr_uformat=get_uformat();
-  	
-  	#ifdef ALFONT_DOS
-	if ((c_pt = iconv_open("UTF-16LE", f->language)) == (iconv_t)-1) {	
-     	lpszW = (char *)s_pointer;
-  	}
-  	else {
-  		iconv(c_pt, NULL, NULL, NULL, NULL);
-  		fromlen  = strlen(s_pointer) + 1;
-		tolen = MB_CUR_MAX * fromlen * (sizeof(wchar_t) + 1);
-  		lpszW = (char *)malloc(tolen*sizeof(char));
-		memset(lpszW, 0, tolen);
-  		sin = s_pointer;
-  		sout = lpszW;
-  		ret = iconv(c_pt, &sin, &fromlen, &sout, &tolen);
-  		iconv_close(c_pt);
-  		if (ret == -1) {
-           	lpszW = (char *)s_pointer;
-        }
-        else {
-			set_uformat(U_UNICODE);
-        }
-  	}
-	#else
-	setlocale(LC_CTYPE,f->language);
-	set_uformat(U_UNICODE);
-	
-	#ifdef ALFONT_LINUX
-	nLen = strlen(s_pointer) * 5 + 1;
-	#else
-	nLen= strlen(s_pointer) + 1;
-	#endif
-
-	lpszW = (char *)malloc(nLen*sizeof(wchar_t));
-	memset(lpszW, 0, nLen);
-	mbstowcs((wchar_t *)lpszW, s_pointer, nLen);
-	#endif
-  }
-  else {
-    #ifdef ALFONT_LINUX
-	set_uformat(U_UTF8);
-	nLen= ustrlen(s_pointer) + 1;
-    #endif
-    lpszW = (char *)s_pointer;
-  }
-
-  memset(*out, 0, _msize(*out));
-  if (_msize(*out) > 0 && _msize(lpszW) >= _msize(*out))
-  {
-	memcpy(*out, lpszW, _msize(*out));
-  }
-  else if (_msize(*out) > 0 && _msize(*out) > _msize(lpszW))
-  {
-	memcpy(*out, lpszW, _msize(lpszW));
-  }
-
-  if ((f->type==1)||(f->type==2)) {
-  	if (lpszW)
-	free(lpszW);
-  }
-
-  if(s_pointer) {
-	free(s_pointer);
-  }
-
-  #ifndef ALFONT_DOS
-  setlocale(LC_CTYPE,"");
-  #endif
-
-  if (f->type==2) {
-	set_uformat(curr_uformat);
-  }
-}
-
 int alfont_need_uconvert(ALFONT_FONT *f, const char *str) {
   char *lpszW;
   char *str_pointer=NULL; //used for original string fixed by autofix