# snprintf defined as ap_php_snprintf

- Thread: https://externals.io/message/14592
- Original archive: https://news-web.php.net/php.internals/14592
- Started by Jeff Olhoeft on 2005-02-03T19:59:55+00:00
- Messages: 2
- 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

---

## #14592 — Jeff Olhoeft — 2005-02-03T19:59:55+00:00

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

Hello,

We recently upgraded a system from PHP 4.3.4 to 4.3.10, and tripped
over a problem with snprintf.  One of our PHP extension modules
started failing, causing Apache to exit with code 0177.  Investigation
showed the culprit to be snprintf. It turns out that in 4.3.10,
snprintf is #defined to be ap_php_snprintf. If we #undef snprintf
(thus using glibc's snprintf), the problem is cleared up.

In this segment of the diff between versions 1.178.2.9 and 1.178.2.8
of php.h, you'll see that tests for the existence of a system snprintf
were removed.

 -#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) ||
PHP_BROKEN_SPRINTF || PHP_BROKEN_SNPRINTF || PHP_BROKEN_VSNPRINTF
 #include "snprintf.h"
-#endif

Is this a deliberate change? Is there some way to tell configure to
use the system snprintf instead of the PHP version?

Thanks,

Jeff

---

## #14593 — Derick Rethans — 2005-02-03T20:14:13+00:00

URL: https://externals.io/message/14592#14593 · In reply to: #14592

> Hello,
>
> We recently upgraded a system from PHP 4.3.4 to 4.3.10, and tripped
> over a problem with snprintf.  One of our PHP extension modules
> started failing, causing Apache to exit with code 0177.  Investigation
> showed the culprit to be snprintf. It turns out that in 4.3.10,
> snprintf is #defined to be ap_php_snprintf. If we #undef snprintf
> (thus using glibc's snprintf), the problem is cleared up.
>
> In this segment of the diff between versions 1.178.2.9 and 1.178.2.8
> of php.h, you'll see that tests for the existence of a system snprintf
> were removed.
>
>  -#if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) ||
> PHP_BROKEN_SPRINTF || PHP_BROKEN_SNPRINTF || PHP_BROKEN_VSNPRINTF
>  #include "snprintf.h"
> -#endif
>
> Is this a deliberate change? Is there some way to tell configure to
> use the system snprintf instead of the PHP version?

You should always been using the ap_php_snprintf() one as that has an
extra modified %F for non-locale aware number formatting. To make your
extension work, make sure to include main/snprintf.h.

regards,
Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org
