# Patch GD (updated)

- Thread: https://externals.io/message/626
- Original archive: https://news-web.php.net/php.internals/626
- Started by John Coggeshall on 2003-04-03T05:51:57+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #626 — John Coggeshall — 2003-04-03T05:51:57+00:00

URL: https://externals.io/message/626#626

Okay... Here's the patch again. This is only one patch to correct the
error handling of the GD extension when using T1Lib... If someone really
wants me to post a second patch for the imagepscopyfont() function I
will, but it's a really trivial... I just suggested we throw a warning
instead of completely removing the function from the extension for BC
reasons...

Here's the error handling patch:

Index: gd.c
===================================================================
RCS file: /repository/php4/ext/gd/gd.c,v
retrieving revision 1.261
diff -u -r1.261 gd.c
--- gd.c	31 Mar 2003 08:49:19 -0000	1.261
+++ gd.c	3 Apr 2003 05:45:59 -0000
@@ -3188,21 +3188,7 @@
 	f_ind = T1_AddFont(Z_STRVAL_PP(file));
 
 	if (f_ind < 0) {
-		switch (f_ind) {
-			case -1:
-				php_error_docref(NULL TSRMLS_CC,
E_WARNING, "Couldn't find the font file");
-				RETURN_FALSE;
-				break;
-			case -2:
-			case -3:
-				php_error_docref(NULL TSRMLS_CC,
E_WARNING, "Memory allocation fault in t1lib");
-				RETURN_FALSE;
-				break;
-			default:
-				php_error_docref(NULL TSRMLS_CC,
E_WARNING, "An unknown error occurred in t1lib");
-				RETURN_FALSE;
-				break;
-		}
+	    php_error_docref(NULL TSRMLS_CC, E_WARNING, "T1Lib Error:
%s", T1_StrError(f_ind));
 	}
 
 	if (T1_LoadFont(f_ind)) {
@@ -3476,7 +3462,7 @@
 
 	if (!str_path) {
 		if (T1_errno) {
-			php_error_docref(NULL TSRMLS_CC, E_WARNING,
"libt1 returned error %d", T1_errno);
+			php_error_docref(NULL TSRMLS_CC, E_WARNING,
"T1Lib Error: %s", T1_StrError(T1_errno));
 		}
 		RETURN_FALSE;
 	}
@@ -3495,7 +3481,7 @@
 	str_img = T1_AAFillOutline(str_path, 0);
 
 	if (T1_errno) {
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "libt1
returned error %d", T1_errno);
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "T1Lib
Error: %s", T1_StrError(T1_errno));
 		RETURN_FALSE;
 	}
 

John

-~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-
John Coggeshall
john at coggeshall dot org                  http://www.coggeshall.org/
-~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~
