]> granicus.if.org Git - php/commitdiff
This commit was manufactured by cvs2svn to create branch 'PHP_4_3'.
authorSVN Migration <svn@php.net>
Tue, 23 Sep 2003 10:06:20 +0000 (10:06 +0000)
committerSVN Migration <svn@php.net>
Tue, 23 Sep 2003 10:06:20 +0000 (10:06 +0000)
13 files changed:
ext/gettext/tests/gettext_basic.phpt [new file with mode: 0644]
ext/gettext/tests/locale/fi/LC_MESSAGES/messages.mo [new file with mode: 0644]
ext/gettext/tests/locale/fi/LC_MESSAGES/messages.po [new file with mode: 0644]
ext/mbstring/libmbfl/filters/html_entities.h [new file with mode: 0644]
ext/mbstring/libmbfl/filters/mbfilter_htmlent.c [new file with mode: 0644]
ext/mbstring/libmbfl/filters/mbfilter_htmlent.h [new file with mode: 0644]
ext/mbstring/libmbfl/mbfl/mbfilter_8bit.h [new file with mode: 0644]
ext/mbstring/libmbfl/mbfl/mbfilter_pass.h [new file with mode: 0644]
ext/mbstring/libmbfl/mbfl/mbfilter_wchar.h [new file with mode: 0644]
ext/mbstring/libmbfl/mbfl/mbfl_allocators.c [new file with mode: 0644]
ext/mbstring/libmbfl/mbfl/mbfl_allocators.h [new file with mode: 0644]
ext/mbstring/libmbfl/mbfl/mbfl_encoding.c [new file with mode: 0644]
ext/mbstring/libmbfl/mbfl/mbfl_language.c [new file with mode: 0644]

diff --git a/ext/gettext/tests/gettext_basic.phpt b/ext/gettext/tests/gettext_basic.phpt
new file mode 100644 (file)
index 0000000..734cc81
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Gettext basic test
+--SKIPIF--
+<?php if (!extension_loaded("gettext")) print "skip"; ?>
+--FILE--
+<?php // $Id$
+
+chdir(dirname(__FILE__));
+setlocale(LC_ALL, 'fi_FI');
+bindtextdomain ("messages", "./locale");
+textdomain ("messages");
+echo gettext("Basic test"), "\n";
+echo _("Basic test"), "\n";
+
+?>
+--EXPECT--
+Perustesti
+Perustesti
diff --git a/ext/gettext/tests/locale/fi/LC_MESSAGES/messages.mo b/ext/gettext/tests/locale/fi/LC_MESSAGES/messages.mo
new file mode 100644 (file)
index 0000000..55f4d1a
Binary files /dev/null and b/ext/gettext/tests/locale/fi/LC_MESSAGES/messages.mo differ
diff --git a/ext/gettext/tests/locale/fi/LC_MESSAGES/messages.po b/ext/gettext/tests/locale/fi/LC_MESSAGES/messages.po
new file mode 100644 (file)
index 0000000..3505156
--- /dev/null
@@ -0,0 +1,15 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: gettext_basic.phpt:11
+msgid "Basic test"
+msgstr "Perustesti"
diff --git a/ext/mbstring/libmbfl/filters/html_entities.h b/ext/mbstring/libmbfl/filters/html_entities.h
new file mode 100644 (file)
index 0000000..99dbfe2
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this part: Marcus Boerger <helly@php.net>
+ *
+ */
+/*
+ * The source code included in this files was separated from mbfilter.h
+ * by moriyoshi koizumi <moriyoshi@php.net> on 4 dec 2002.
+ * 
+ */
+
+#ifndef MBFL_HTML_ENTITIES_H
+#define MBFL_HTML_ENTITIES_H
+
+#include "mbfilter.h"
+
+extern mbfl_html_entity mbfl_html_entity_list[];
+
+#endif /* MBFL_HTML_ENTITIES_H */
+
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_htmlent.c b/ext/mbstring/libmbfl/filters/mbfilter_htmlent.c
new file mode 100644 (file)
index 0000000..c9c5390
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this part: Marcus Boerger <helly@php.net>
+ *
+ */
+/*
+ * The source code included in this files was separated from mbfilter.c
+ * by moriyoshi koizumi <moriyoshi@php.net> on 4 dec 2002.
+ * 
+ */
+
+#include "php.h"
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#include "mbfilter.h"
+#include "mbfilter_htmlent.h"
+#include "html_entities.h"
+
+static const unsigned char mblen_table_html[] = { /* 0x00, 0x80 - 0xFF, only valid for numeric entities */
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
+};
+
+static const char *mbfl_encoding_html_ent_aliases[] = {"HTML", "html", NULL};
+
+const mbfl_encoding mbfl_encoding_html_ent = {
+       mbfl_no_encoding_html_ent,
+       "HTML-ENTITIES",
+       "US-ASCII",
+       (const char *(*)[])&mbfl_encoding_html_ent_aliases,
+       NULL, /* mblen_table_html, Do not use table instead calulate length based on entities actually used */
+       MBFL_ENCTYPE_HTML_ENT
+};
+
+const struct mbfl_convert_vtbl vtbl_wchar_html = {
+       mbfl_no_encoding_wchar,
+       mbfl_no_encoding_html_ent,
+       mbfl_filt_conv_common_ctor,
+       mbfl_filt_conv_common_dtor,
+       mbfl_filt_conv_html_enc,
+       mbfl_filt_conv_html_enc_flush
+};
+
+const struct mbfl_convert_vtbl vtbl_html_wchar = {
+       mbfl_no_encoding_html_ent,
+       mbfl_no_encoding_wchar,
+       mbfl_filt_conv_html_dec_ctor,
+       mbfl_filt_conv_html_dec_dtor,
+       mbfl_filt_conv_html_dec,
+       mbfl_filt_conv_html_dec_flush };
+
+
+#define CK(statement)  do { if ((statement) < 0) return (-1); } while (0)
+
+/*
+ * any => HTML
+ */
+int mbfl_filt_conv_html_enc(int c, mbfl_convert_filter *filter)
+{
+       int tmp[10];
+       int i = 0, p = 0, e;
+       unsigned int uc;
+
+       if (c<256 && mblen_table_html[c]==1) {
+               CK((*filter->output_function)(c, filter->data));
+       } else {
+               /*php_error_docref("ref.mbstring" TSRMLS_CC, E_NOTICE, "mbfl_filt_conv_html_enc(0x%08X = %d)", c, c);*/
+               CK((*filter->output_function)('&', filter->data));
+               while (1) {
+                   e = mbfl_html_entity_list[i].code;
+                       if (c < e || e == -1) {
+                               break;
+                       }
+                       if (c == e) {
+                               while(mbfl_html_entity_list[i].name[p]) {
+                                       CK((*filter->output_function)((int)mbfl_html_entity_list[i].name[p++], filter->data));
+                               }
+                               break;
+                       }
+                       i++;
+               }
+               i=0;
+               if (!p) {
+                       CK((*filter->output_function)('#', filter->data));
+                       uc = (unsigned int)c;
+                       do {
+                               tmp[i++] = '0'+uc%10;
+                               uc /= 10;
+                       } while (uc);
+                       do {
+                               CK((*filter->output_function)(tmp[--i], filter->data));
+                       } while (i);
+               }
+               CK((*filter->output_function)(';', filter->data));
+       }
+       return c;
+}
+
+int mbfl_filt_conv_html_enc_flush(mbfl_convert_filter *filter)
+{
+       filter->status = 0;
+       filter->cache = 0;
+       return 0;
+}
+
+/*
+ * HTML => any
+ */
+#define html_enc_buffer_size   16
+static const char html_entity_chars[] = "#0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+void mbfl_filt_conv_html_dec_ctor(mbfl_convert_filter *filter)
+{
+       filter->status = 0;
+       filter->cache = (int)mbfl_malloc(html_enc_buffer_size+1);
+}
+       
+void mbfl_filt_conv_html_dec_dtor(mbfl_convert_filter *filter)
+{
+       filter->status = 0;
+       if (filter->cache)
+       {
+               mbfl_free((void*)filter->cache);
+       }
+       filter->cache = 0;
+}
+
+int mbfl_filt_conv_html_dec(int c, mbfl_convert_filter *filter)
+{
+       int  pos, ent = 0;
+       mbfl_html_entity *entity;
+       char *buffer = (char*)filter->cache;
+
+       if (!filter->status) {
+               if (c == '&' ) {
+                       filter->status = 1;
+                       buffer[0] = '&';
+               } else {
+                       CK((*filter->output_function)(c, filter->data));
+               }
+       } else {
+               if (c == ';') {
+                       buffer[filter->status] = 0;
+                       if (buffer[1]=='#') {
+                               /* numeric entity */
+                               for (pos=2; pos<filter->status; pos++) {
+                                       ent = ent*10 + (buffer[pos] - '0');
+                               }
+                               CK((*filter->output_function)(ent, filter->data));
+                               filter->status = 0;
+                               /*php_error_docref("ref.mbstring" TSRMLS_CC, E_NOTICE, "mbstring decoded '%s'=%d", buffer, ent);*/
+                       } else {
+                               /* named entity */
+                               entity = (mbfl_html_entity *)mbfl_html_entity_list;
+                               while (entity->name) {
+                                       if (!strcmp(buffer+1, entity->name))    {
+                                               ent = entity->code;
+                                               break;
+                                       }
+                                       entity++;
+                               }
+                               if (ent) {
+                                       /* decoded */
+                                       CK((*filter->output_function)(ent, filter->data));
+                                       filter->status = 0;
+                                       /*php_error_docref("ref.mbstring" TSRMLS_CC, E_NOTICE,"mbstring decoded '%s'=%d", buffer, ent);*/
+                               } else { 
+                                       /* failure */
+                                       buffer[filter->status++] = ';';
+                                       buffer[filter->status] = 0;
+                                       /* php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring cannot decode '%s'", buffer); */
+                                       mbfl_filt_conv_html_dec_flush(filter);
+                               }
+                       }
+               } else {
+                       /* add character */
+                       buffer[filter->status++] = c;
+                       /* add character and check */
+                       if (!strchr(html_entity_chars, c) || filter->status+1==html_enc_buffer_size || (c=='#' && filter->status>2))
+                       {
+                               /* illegal character or end of buffer */
+                               if (c=='&')
+                                       filter->status--;
+                               buffer[filter->status] = 0;
+                               /* php_error_docref("ref.mbstring" TSRMLS_CC, E_WARNING, "mbstring cannot decode '%s'", buffer)l */
+                               mbfl_filt_conv_html_dec_flush(filter);
+                               if (c=='&')
+                               {
+                                       filter->status = 1;
+                                       buffer[0] = '&';
+                               }
+                       }
+               }
+       }
+       return c;
+}
+
+int mbfl_filt_conv_html_dec_flush(mbfl_convert_filter *filter)
+{
+       int status, pos = 0;
+       char *buffer;
+
+       buffer = (char*)filter->cache;
+       status = filter->status;
+       /* flush fragments */
+       while (status--) {
+               CK((*filter->output_function)(buffer[pos++], filter->data));
+       }
+       filter->status = 0;
+       /*filter->buffer = 0; of cause NOT*/
+       return 0;
+}
+
+
diff --git a/ext/mbstring/libmbfl/filters/mbfilter_htmlent.h b/ext/mbstring/libmbfl/filters/mbfilter_htmlent.h
new file mode 100644 (file)
index 0000000..99827c2
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this part: Marcus Boerger <helly@php.net>
+ *
+ */
+/*
+ * The source code included in this files was separated from mbfilter.c
+ * by moriyoshi koizumi <moriyoshi@php.net> on 4 dec 2002.
+ * 
+ */
+
+#ifndef MBFL_MBFILTER_HTMLENT_H
+#define MBFL_MBFILTER_HTMLENT_H
+
+#include "mbfilter.h"
+
+extern const mbfl_encoding mbfl_encoding_html_ent;
+extern const struct mbfl_convert_vtbl vtbl_wchar_html; 
+extern const struct mbfl_convert_vtbl vtbl_html_wchar;
+
+void mbfl_filt_conv_html_dec_ctor(mbfl_convert_filter *filter);
+void mbfl_filt_conv_html_dec_dtor(mbfl_convert_filter *filter);
+int mbfl_filt_conv_html_enc(int c, mbfl_convert_filter *filter);
+int mbfl_filt_conv_html_enc_flush(mbfl_convert_filter *filter);
+int mbfl_filt_conv_html_dec(int c, mbfl_convert_filter *filter);
+int mbfl_filt_conv_html_dec_flush(mbfl_convert_filter *filter);
+void mbfl_filt_conv_html_dec_ctor(mbfl_convert_filter *filter);
+void mbfl_filt_conv_html_dec_dtor(mbfl_convert_filter *filter);
+
+#endif /* MBFL_MBFILTER_HTMLENT_H */
diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter_8bit.h b/ext/mbstring/libmbfl/mbfl/mbfilter_8bit.h
new file mode 100644 (file)
index 0000000..4fc8922
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this file:
+ *
+ */
+/*
+ * The source code included in this files was separated from mbfilter.c
+ * by Moriyoshi Koizumi <moriyoshi@php.net> on 20 Dec 2002. The file
+ * mbfilter.c is included in this package .
+ *
+ */
+
+#ifndef MBFL_MBFILTER_8BIT_H
+#define MBFL_MBFILTER_8BIT_H
+
+#include "mbfl_defs.h"
+#include "mbfilter.h"
+
+extern const mbfl_encoding mbfl_encoding_8bit;
+
+#endif /* MBFL_MBFILTER_8BIT_H */
diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter_pass.h b/ext/mbstring/libmbfl/mbfl/mbfilter_pass.h
new file mode 100644 (file)
index 0000000..087aa2c
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this file:
+ *
+ */
+/*
+ * The source code included in this files was separated from mbfilter.c
+ * by moriyoshi koizumi <moriyoshi@php.net> on 4 dec 2002.
+ * 
+ */
+
+#ifndef MBFL_MBFILTER_PASS_H
+#define MBFL_MBFILTER_PASS_H
+
+#include "mbfl_defs.h"
+#include "mbfilter.h"
+
+extern const mbfl_encoding mbfl_encoding_pass; 
+extern const struct mbfl_convert_vtbl vtbl_pass;
+
+MBFLAPI extern int mbfl_filt_conv_pass(int c, mbfl_convert_filter *filter);
+
+#endif /* MBFL_MBFILTER_PASS_H */
diff --git a/ext/mbstring/libmbfl/mbfl/mbfilter_wchar.h b/ext/mbstring/libmbfl/mbfl/mbfilter_wchar.h
new file mode 100644 (file)
index 0000000..24bf747
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this file:
+ *
+ */
+/*
+ * The source code included in this files was separated from mbfilter.c
+ * by Moriyoshi Koizumi <moriyoshi@php.net> on 20 Dec 2002. The file
+ * mbfilter.c is included in this package .
+ *
+ */
+
+#ifndef MBFL_MBFILTER_WCHAR_H
+#define MBFL_MBFILTER_WCHAR_H
+
+#include "mbfl_defs.h"
+#include "mbfilter.h"
+
+extern const mbfl_encoding mbfl_encoding_wchar;
+
+#endif /* MBFL_MBFILTER_WCHAR_H */
diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_allocators.c b/ext/mbstring/libmbfl/mbfl/mbfl_allocators.c
new file mode 100644 (file)
index 0000000..cc13d15
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this file:
+ *
+ */
+/*
+ * The source code included in this files was separated from mbfilter.c
+ * by Moriyoshi Koizumi <moriyoshi@php.net> on 20 Dec 2002. The file
+ * mbfilter.c is included in this package .
+ *
+ */
+
+#include "php.h"
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#ifdef HAVE_MEMORY_H
+#include <memory.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+
+#include "mbfl_allocators.h"
+
+static void *__mbfl__malloc(unsigned int);
+static void *__mbfl__realloc(void *, unsigned int);
+static void *__mbfl__calloc(unsigned int, unsigned int);
+static void __mbfl__free(void *);
+
+static mbfl_allocators default_allocators = {
+       __mbfl__malloc,
+       __mbfl__realloc,
+       __mbfl__calloc,
+       __mbfl__free,
+       __mbfl__malloc,
+       __mbfl__realloc,
+       __mbfl__free
+};
+
+mbfl_allocators *__mbfl_allocators = &default_allocators;
+
+static void *__mbfl__malloc(unsigned int sz)
+{
+       return malloc(sz);
+}
+
+static void *__mbfl__realloc(void *ptr, unsigned int sz)
+{
+       return realloc(ptr, sz);
+}
+
+static void *__mbfl__calloc(unsigned int nelems, unsigned int szelem)
+{
+       return calloc(nelems, szelem);
+}
+
+static void __mbfl__free(void *ptr)
+{
+       free(ptr);
+} 
+
diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_allocators.h b/ext/mbstring/libmbfl/mbfl/mbfl_allocators.h
new file mode 100644 (file)
index 0000000..a1539f0
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this file:
+ *
+ */
+/*
+ * The source code included in this files was separated from mbfilter.h
+ * by Moriyoshi Koizumi <moriyoshi@php.net> on 20 Dec 2002. The file
+ * mbfilter.h is included in this package .
+ *
+ */
+
+#ifndef MBFL_ALLOCATORS_H
+#define MBFL_ALLOCATORS_H
+
+#include "mbfl_defs.h"
+
+typedef struct _mbfl_allocators {
+       void *(*malloc)(unsigned int);
+       void *(*realloc)(void *, unsigned int);
+       void *(*calloc)(unsigned int, unsigned int);
+       void (*free)(void *);
+       void *(*pmalloc)(unsigned int); 
+       void *(*prealloc)(void *, unsigned int);
+       void (*pfree)(void *);
+} mbfl_allocators;
+
+MBFLAPI extern mbfl_allocators *__mbfl_allocators; 
+
+#define mbfl_malloc (__mbfl_allocators->malloc)
+#define mbfl_realloc (__mbfl_allocators->realloc)
+#define mbfl_calloc (__mbfl_allocators->calloc)
+#define mbfl_free (__mbfl_allocators->free)
+#define mbfl_pmalloc (__mbfl_allocators->pmalloc)
+#define mbfl_prealloc (__mbfl_allocators->preallloc)
+#define mbfl_pfree (__mbfl_allocators->pfree)
+
+#endif /* MBFL_ALLOCATORS_H */
diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_encoding.c b/ext/mbstring/libmbfl/mbfl/mbfl_encoding.c
new file mode 100644 (file)
index 0000000..a63ea37
--- /dev/null
@@ -0,0 +1,297 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this file:
+ *
+ */
+/*
+ * The source code included in this files was separated from mbfilter.c
+ * by Moriyoshi Koizumi <moriyoshi@php.net> on 20 Dec 2002. The file
+ * mbfilter.c is included in this package .
+ *
+ */
+
+#include "php.h"
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#include "mbfl_encoding.h"
+#include "mbfilter_pass.h"
+#include "mbfilter_8bit.h"
+#include "mbfilter_wchar.h"
+
+#include "filters/mbfilter_euc_cn.h"
+#include "filters/mbfilter_hz.h"
+#include "filters/mbfilter_euc_tw.h"
+#include "filters/mbfilter_big5.h"
+#include "filters/mbfilter_uhc.h"
+#include "filters/mbfilter_euc_kr.h"
+#include "filters/mbfilter_iso2022_kr.h"
+#include "filters/mbfilter_sjis.h"
+#include "filters/mbfilter_jis.h"
+#include "filters/mbfilter_euc_jp.h"
+#include "filters/mbfilter_euc_jp_win.h"
+#include "filters/mbfilter_ascii.h"
+#include "filters/mbfilter_koi8r.h"
+#include "filters/mbfilter_cp866.h"
+#include "filters/mbfilter_cp932.h"
+#include "filters/mbfilter_cp936.h"
+#include "filters/mbfilter_cp1251.h"
+#include "filters/mbfilter_cp1252.h"
+#include "filters/mbfilter_iso8859_1.h"
+#include "filters/mbfilter_iso8859_2.h"
+#include "filters/mbfilter_iso8859_3.h"
+#include "filters/mbfilter_iso8859_4.h"
+#include "filters/mbfilter_iso8859_5.h"
+#include "filters/mbfilter_iso8859_6.h"
+#include "filters/mbfilter_iso8859_7.h"
+#include "filters/mbfilter_iso8859_8.h"
+#include "filters/mbfilter_iso8859_9.h"
+#include "filters/mbfilter_iso8859_10.h"
+#include "filters/mbfilter_iso8859_13.h"
+#include "filters/mbfilter_iso8859_14.h"
+#include "filters/mbfilter_iso8859_15.h"
+#include "filters/mbfilter_base64.h"
+#include "filters/mbfilter_qprint.h"
+#include "filters/mbfilter_uuencode.h"
+#include "filters/mbfilter_7bit.h"
+#include "filters/mbfilter_utf7.h"
+#include "filters/mbfilter_utf7imap.h"
+#include "filters/mbfilter_utf8.h"
+#include "filters/mbfilter_utf16.h"
+#include "filters/mbfilter_utf32.h"
+#include "filters/mbfilter_byte2.h"
+#include "filters/mbfilter_byte4.h"
+#include "filters/mbfilter_ucs4.h"
+#include "filters/mbfilter_ucs2.h"
+#include "filters/mbfilter_htmlent.h"
+
+#ifndef HAVE_STRCASECMP
+#ifdef HAVE_STRICMP
+#define strcasecmp stricmp
+#endif
+#endif 
+
+
+static const char *mbfl_encoding_auto_aliases[] = {"unknown", NULL};
+
+static const mbfl_encoding mbfl_encoding_auto = {
+       mbfl_no_encoding_auto,
+       "auto",
+       NULL,
+       (const char *(*)[])&mbfl_encoding_auto_aliases,
+       NULL,
+       0
+};
+
+static const mbfl_encoding *mbfl_encoding_ptr_list[] = {
+       &mbfl_encoding_pass,
+       &mbfl_encoding_auto,
+       &mbfl_encoding_wchar,
+       &mbfl_encoding_byte2be,
+       &mbfl_encoding_byte2le,
+       &mbfl_encoding_byte4be,
+       &mbfl_encoding_byte4le,
+       &mbfl_encoding_base64,
+       &mbfl_encoding_uuencode,
+       &mbfl_encoding_html_ent,
+       &mbfl_encoding_qprint,
+       &mbfl_encoding_7bit,
+       &mbfl_encoding_8bit,
+       &mbfl_encoding_ucs4,
+       &mbfl_encoding_ucs4be,
+       &mbfl_encoding_ucs4le,
+       &mbfl_encoding_ucs2,
+       &mbfl_encoding_ucs2be,
+       &mbfl_encoding_ucs2le,
+       &mbfl_encoding_utf32,
+       &mbfl_encoding_utf32be,
+       &mbfl_encoding_utf32le,
+       &mbfl_encoding_utf16,
+       &mbfl_encoding_utf16be,
+       &mbfl_encoding_utf16le,
+       &mbfl_encoding_utf8,
+       &mbfl_encoding_utf7,
+       &mbfl_encoding_utf7imap,
+       &mbfl_encoding_ascii,
+       &mbfl_encoding_euc_jp,
+       &mbfl_encoding_sjis,
+       &mbfl_encoding_eucjp_win,
+       &mbfl_encoding_sjis_win,
+       &mbfl_encoding_jis,
+       &mbfl_encoding_2022jp,
+       &mbfl_encoding_cp1252,
+       &mbfl_encoding_8859_1,
+       &mbfl_encoding_8859_2,
+       &mbfl_encoding_8859_3,
+       &mbfl_encoding_8859_4,
+       &mbfl_encoding_8859_5,
+       &mbfl_encoding_8859_6,
+       &mbfl_encoding_8859_7,
+       &mbfl_encoding_8859_8,
+       &mbfl_encoding_8859_9,
+       &mbfl_encoding_8859_10,
+       &mbfl_encoding_8859_13,
+       &mbfl_encoding_8859_14,
+       &mbfl_encoding_8859_15,
+       &mbfl_encoding_euc_cn,
+       &mbfl_encoding_cp936,
+       &mbfl_encoding_hz,
+       &mbfl_encoding_euc_tw,
+       &mbfl_encoding_big5,
+       &mbfl_encoding_euc_kr,
+       &mbfl_encoding_uhc,
+       &mbfl_encoding_2022kr,
+       &mbfl_encoding_cp1251,
+       &mbfl_encoding_cp866,
+       &mbfl_encoding_koi8r,
+       NULL
+};
+
+/* encoding resolver */
+const mbfl_encoding *
+mbfl_name2encoding(const char *name)
+{
+       const mbfl_encoding *encoding;
+       int i, j;
+
+       if (name == NULL) {
+               return NULL;
+       }
+
+       i = 0;
+       while ((encoding = mbfl_encoding_ptr_list[i++]) != NULL){
+               if (strcasecmp(encoding->name, name) == 0) {
+                       return encoding;
+               }
+       }
+
+       /* serch MIME charset name */
+       i = 0;
+       while ((encoding = mbfl_encoding_ptr_list[i++]) != NULL) {
+               if (encoding->mime_name != NULL) {
+                       if (strcasecmp(encoding->mime_name, name) == 0) {
+                               return encoding;
+                       }
+               }
+       }
+
+       /* serch aliases */
+       i = 0;
+       while ((encoding = mbfl_encoding_ptr_list[i++]) != NULL) {
+               if (encoding->aliases != NULL) {
+                       j = 0;
+                       while ((*encoding->aliases)[j] != NULL) {
+                               if (strcasecmp((*encoding->aliases)[j], name) == 0) {
+                                       return encoding;
+                               }
+                               j++;
+                       }
+               }
+       }
+
+       return NULL;
+}
+
+const mbfl_encoding *
+mbfl_no2encoding(enum mbfl_no_encoding no_encoding)
+{
+       const mbfl_encoding *encoding;
+       int i;
+
+       i = 0;
+       while ((encoding = mbfl_encoding_ptr_list[i++]) != NULL){
+               if (encoding->no_encoding == no_encoding) {
+                       return encoding;
+               }
+       }
+
+       return NULL;
+}
+
+enum mbfl_no_encoding
+mbfl_name2no_encoding(const char *name)
+{
+       const mbfl_encoding *encoding;
+
+       encoding = mbfl_name2encoding(name);
+       if (encoding == NULL) {
+               return mbfl_no_encoding_invalid;
+       } else {
+               return encoding->no_encoding;
+       }
+}
+
+const char *
+mbfl_no_encoding2name(enum mbfl_no_encoding no_encoding)
+{
+       const mbfl_encoding *encoding;
+
+       encoding = mbfl_no2encoding(no_encoding);
+       if (encoding == NULL) {
+               return "";
+       } else {
+               return encoding->name;
+       }
+}
+
+const char *
+mbfl_no2preferred_mime_name(enum mbfl_no_encoding no_encoding)
+{
+       const mbfl_encoding *encoding;
+
+       encoding = mbfl_no2encoding(no_encoding);
+       if (encoding != NULL && encoding->mime_name != NULL && encoding->mime_name[0] != '\0') {
+               return encoding->mime_name;
+       } else {
+               return NULL;
+       }
+}
+
+int
+mbfl_is_support_encoding(const char *name)
+{
+       const mbfl_encoding *encoding;
+
+       encoding = mbfl_name2encoding(name);
+       if (encoding == NULL) {
+               return 0;
+       } else {
+               return 1;
+       }
+}
+
+
+
+
diff --git a/ext/mbstring/libmbfl/mbfl/mbfl_language.c b/ext/mbstring/libmbfl/mbfl/mbfl_language.c
new file mode 100644 (file)
index 0000000..5f55a45
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+ * "streamable kanji code filter and converter"
+ * Copyright (c) 1998-2002 HappySize, Inc. All rights reserved.
+ *
+ * LICENSE NOTICES
+ *
+ * This file is part of "streamable kanji code filter and converter",
+ * which is distributed under the terms of GNU Lesser General Public 
+ * License (version 2) as published by the Free Software Foundation.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with "streamable kanji code filter and converter";
+ * if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA  02111-1307  USA
+ *
+ * The author of this file:
+ *
+ */
+/*
+ * The source code included in this files was separated from mbfilter.c
+ * by Moriyoshi Koizumi <moriyoshi@php.net> on 20 Dec 2002. The file
+ * mbfilter.c is included in this package .
+ *
+ */
+
+#include "php.h"
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#include "mbfl_encoding.h"
+#include "mbfl_language.h"
+
+#include "nls/nls_ja.h"
+#include "nls/nls_kr.h"
+#include "nls/nls_zh.h"
+#include "nls/nls_uni.h"
+#include "nls/nls_de.h"
+#include "nls/nls_ru.h"
+#include "nls/nls_en.h"
+#include "nls/nls_neutral.h"
+
+#ifndef HAVE_STRCASECMP
+#ifdef HAVE_STRICMP
+#define strcasecmp stricmp
+#endif
+#endif 
+
+static const mbfl_language *mbfl_language_ptr_table[] = {
+       &mbfl_language_uni,
+       &mbfl_language_japanese,
+       &mbfl_language_korean,
+       &mbfl_language_simplified_chinese,
+       &mbfl_language_traditional_chinese,
+       &mbfl_language_english,
+       &mbfl_language_german,
+       &mbfl_language_russian,
+       &mbfl_language_neutral,
+       NULL
+};
+
+/* language resolver */
+const mbfl_language *
+mbfl_name2language(const char *name)
+{
+       const mbfl_language *language;
+       int i, j;
+
+       if (name == NULL) {
+               return NULL;
+       }
+
+       i = 0;
+       while ((language = mbfl_language_ptr_table[i++]) != NULL){
+               if (strcasecmp(language->name, name) == 0) {
+                       return language;
+               }
+       }
+
+       i = 0;
+       while ((language = mbfl_language_ptr_table[i++]) != NULL){
+               if (strcasecmp(language->short_name, name) == 0) {
+                       return language;
+               }
+       }
+
+       /* serch aliases */
+       i = 0;
+       while ((language = mbfl_language_ptr_table[i++]) != NULL) {
+               if (language->aliases != NULL) {
+                       j = 0;
+                       while ((*language->aliases)[j] != NULL) {
+                               if (strcasecmp((*language->aliases)[j], name) == 0) {
+                                       return language;
+                               }
+                               j++;
+                       }
+               }
+       }
+
+       return NULL;
+}
+
+const mbfl_language *
+mbfl_no2language(enum mbfl_no_language no_language)
+{
+       const mbfl_language *language;
+       int i;
+
+       i = 0;
+       while ((language = mbfl_language_ptr_table[i++]) != NULL){
+               if (language->no_language == no_language) {
+                       return language;
+               }
+       }
+
+       return NULL;
+}
+
+enum mbfl_no_language
+mbfl_name2no_language(const char *name)
+{
+       const mbfl_language *language;
+
+       language = mbfl_name2language(name);
+       if (language == NULL) {
+               return mbfl_no_language_invalid;
+       } else {
+               return language->no_language;
+       }
+}
+
+const char *
+mbfl_no_language2name(enum mbfl_no_language no_language)
+{
+       const mbfl_language *language;
+
+       language = mbfl_no2language(no_language);
+       if (language == NULL) {
+               return "";
+       } else {
+               return language->name;
+       }
+}
+