IMO we should not enable a buggy function, the output may be un expected and 
if it results in memory corruption we could end with a fairly annoying and 
hard to trace problem.

Ilia

On April 2, 2003 09:54 pm, John Coggeshall wrote:
> Here's a patch for the GD lib.. I'd like to commit this if there is no
> objection. It does a few things:
>
> 1) Creates a warning for imagepscopyfont()... It's in the docs and right
> now its completely commented out in the source... For BC this really
> should not just completely disappear (even if T1Lib is buggy about it).
> 2) Cleans up the error reporting done when working with T1LIB by using
> T1Lib's T1_StrError() function to produce meaniful error messages when
> something goes wrong.
>
> Diff is attached below..
>
> John
>
> cvs server: Diffing .
> 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 02:46:45 -0000
> @@ -282,9 +282,7 @@
>
>  #ifdef HAVE_LIBT1
>         PHP_FE(imagepsloadfont,
> NULL)
> -       /*
>         PHP_FE(imagepscopyfont,
> NULL)
> -       */
>         PHP_FE(imagepsfreefont,
> NULL)
>         PHP_FE(imagepsencodefont,
> NULL)
>         PHP_FE(imagepsextendfont,
> NULL)
> @@ -3188,21 +3186,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)) {
> @@ -3218,10 +3202,11 @@
>
>  /* {{{ proto int imagepscopyfont(int font_index)
>     Make a copy of a font for purposes like extending or reenconding */
> -/* The function in t1lib which this function uses seem to be buggy...
> +/* The function in t1lib which this function uses seem to be buggy...
> */
>  PHP_FUNCTION(imagepscopyfont)
>  {
> -       zval **fnt;
> +    php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function is no
> longer available");
> +/*     zval **fnt;
>         int l_ind, type;
>         gd_ps_font *nf_ind, *of_ind;
>
> @@ -3267,8 +3252,9 @@
>         nf_ind->extend = 1;
>         l_ind = zend_list_insert(nf_ind, le_ps_font);
>         RETURN_LONG(l_ind);
> -}
>  */
> +}
> +
>  /* }}} */
>
>  /* {{{ proto bool imagepsfreefont(int font_index)
> @@ -3339,6 +3325,11 @@
>         ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font",
> le_ps_font);
>
>         T1_DeleteAllSizes(*f_ind);
> +
> +        if(Z_DVAL_PP(ext) < 0) {
> +            zend_error(E_WARNING, "Invalid value for parameter 2 (must
> be greater than zero)");
> +        }
> +
>         if (T1_ExtendFont(*f_ind, Z_DVAL_PP(ext)) != 0) {
>                 RETURN_FALSE;
>         }
> @@ -3476,7 +3467,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 +3486,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;
>         }
>
> Index: php_gd.h
> ===================================================================
> RCS file: /repository/php4/ext/gd/php_gd.h,v
> retrieving revision 1.54
> diff -u -r1.54 php_gd.h
> --- php_gd.h    31 Mar 2003 08:49:19 -0000      1.54
> +++ php_gd.h    3 Apr 2003 02:46:45 -0000
> @@ -157,9 +157,7 @@
>  PHP_FUNCTION(imagettfbbox);
>  PHP_FUNCTION(imagettftext);
>  PHP_FUNCTION(imagepsloadfont);
> -/*
>  PHP_FUNCTION(imagepscopyfont);
> -*/
>  PHP_FUNCTION(imagepsfreefont);
>  PHP_FUNCTION(imagepsencodefont);
>  PHP_FUNCTION(imagepsextendfont);
>
> -~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-
> John Coggeshall
> john at coggeshall dot org                  http://www.coggeshall.org/
> -~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to