Skip to content

Commit

Permalink
backported fix for ext/imap compilation failure with recent c-client …
Browse files Browse the repository at this point in the history
…versions

(fixes #39401)
  • Loading branch information
tony2001 committed Jan 29, 2007
1 parent f5466ed commit f3c6f9f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -7,6 +7,8 @@ PHP 4 NEWS
class). (Ilia)
- Backported a fix in the configure tests to detect the "rounding fuzz".
(Derick, Joe Orton)
- Backported fix for ext/imap compilation failure with recent c-client
versions. (Tony)

- Moved extensions to PECL:
. ext/ovrimos (Derick)
Expand Down
43 changes: 43 additions & 0 deletions ext/imap/config.m4
Expand Up @@ -127,6 +127,49 @@ if test "$PHP_IMAP" != "no"; then
AC_DEFINE(HAVE_IMAP2004,1,[ ])
])

dnl Check for new version of the utf8_mime2text() function
old_CFLAGS=$CFLAGS
CFLAGS="-I$IMAP_INC_DIR"
AC_CACHE_CHECK(for utf8_mime2text signature, ac_cv_utf8_mime2text,
AC_TRY_COMPILE([
#include <stdio.h>
#include <c-client.h>
],[
SIZEDTEXT *src, *dst;
utf8_mime2text(src, dst);
],[
ac_cv_utf8_mime2text=old
],[
ac_cv_utf8_mime2text=new
])
)
if test "$ac_cv_utf8_mime2text" = "new"; then
AC_DEFINE(HAVE_NEW_MIME2TEXT, 1, [Whether utf8_mime2text() has new signature])
fi
CFLAGS=$old_CPPFLAGS

old_CFLAGS=$CFLAGS
CFLAGS="-I$IMAP_INC_DIR"
AC_CACHE_CHECK(for U8T_CANONICAL, ac_cv_u8t_canonical,
AC_TRY_COMPILE([
#include <c-client.h>
],[
int i = U8T_CANONICAL;
],[
ac_cv_u8t_canonical=yes
],[
ac_cv_u8t_canonical=no
])
)
CFLAGS=$old_CPPFLAGS

if test "$ac_cv_u8t_canonical" = "no" && test "$ac_cv_utf8_mime2text" = "new"; then
AC_MSG_ERROR([utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.])
fi
if test "$ac_cv_u8t_canonical" = "yes" && test "$ac_cv_utf8_mime2text" = "old"; then
AC_MSG_ERROR([utf8_mime2text() has old signature, but U8T_CANONICAL is present. This should not happen. Check config.log for additional information.])
fi

dnl Check for c-client version 2001
old_CPPFLAGS=$CPPFLAGS
CPPFLAGS=-I$IMAP_INC_DIR
Expand Down
8 changes: 8 additions & 0 deletions ext/imap/php_imap.c
Expand Up @@ -74,7 +74,11 @@ static int _php_imap_address_size(ADDRESS *addresslist);
void rfc822_date(char *date);
char *cpystr(const char *str);
char *cpytxt(SIZEDTEXT *dst, char *text, unsigned long size);
#ifndef HAVE_NEW_MIME2TEXT
long utf8_mime2text(SIZEDTEXT *src, SIZEDTEXT *dst);
#else
long utf8_mime2text (SIZEDTEXT *src, SIZEDTEXT *dst, long flags);
#endif
unsigned long find_rightmost_bit(unsigned long *valptr);
void fs_give(void **block);
void *fs_get(size_t size);
Expand Down Expand Up @@ -2064,7 +2068,11 @@ PHP_FUNCTION(imap_utf8)
dest.size = 0;

cpytxt(&src, Z_STRVAL_PP(str), Z_STRLEN_PP(str));
#ifndef HAVE_NEW_MIME2TEXT
utf8_mime2text(&src, &dest);
#else
utf8_mime2text(&src, &dest, U8T_CANONICAL);
#endif
RETURN_STRINGL(dest.data, strlen(dest.data), 1);
}
/* }}} */
Expand Down

0 comments on commit f3c6f9f

Please sign in to comment.