diff --git a/.gitmodules b/.gitmodules index 3c559e3..da46d9c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "sundown"] path = sundown - url = https://github.com/tanoku/sundown.git + url = https://github.com/vmg/sundown.git ignore = dirty diff --git a/README.md b/README.md index f0a9383..bc46fbe 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ PHP + Sundown =========================== -php-sundown is just simple wrapper of . +php-sundown is just simple wrapper of . [![Build Status](https://secure.travis-ci.org/chobie/php-sundown.png)](http://travis-ci.org/chobie/php-sundown) @@ -32,9 +32,8 @@ PHP5.3 higher Install for developpers ----------------------- - git clone https://github.com/chobie/php-sundown.git php-sundown -b development + git clone https://github.com/chobie/php-sundown.git php-sundown --recursive cd php-sundown - git submodule init && git submodule update phpze ./configure make @@ -265,6 +264,8 @@ documented at [ExtensionsAndRenderFlags.md](https://github.com/chobie/php-sundow Contributors ------------ + * Dominic Scheirlinck -* stealth35 +* Reeze Xia * Shuhei Tanuma +* stealth35 \ No newline at end of file diff --git a/Rakefile b/Rakefile index dde5010..b534c50 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,3 @@ - desc "compile php-sundown" task :compile => ['sundown/src/markdown.h'] do sh "phpize" @@ -19,6 +18,7 @@ desc "run php test cases" task :test do ENV["TESTS"] = "--show-diff -q" sh "make test" + sh "cat tests/*.diff; if [ $? -eq 0 ];then exit 1; fi" end desc "Run conformance tests" diff --git a/config.m4 b/config.m4 index 2f1a4b1..7ea5ce1 100644 --- a/config.m4 +++ b/config.m4 @@ -20,7 +20,7 @@ sundown/html/houdini_html_e.c " PHP_NEW_EXTENSION(sundown,$SUNDOWN_SOURCES, $ext_shared) - CFLAGS=" -Wunused-variable -Wpointer-sign -Wimplicit-function-declaration" + CFLAGS="-Wunused-variable -Wpointer-sign -Wimplicit-function-declaration -Winline -Wunused-macros -Wredundant-decls -Wstrict-aliasing=2 -Wswitch-enum -Wdeclaration-after-statement" PHP_SUBST([CFLAGS]) PHP_ADD_BUILD_DIR([$ext_builddir/sundown/src]) diff --git a/package.xml b/package.xml index c8640b6..8f38a82 100644 --- a/package.xml +++ b/package.xml @@ -15,10 +15,10 @@ PECL Sundown provides straight forward object oriented Markdown API and customiz chobieeee@php.net yes - 2012-06-02 + 2012-08-11 - 0.3.6 - 0.3.6 + 0.3.7 + 0.3.7 beta @@ -26,24 +26,21 @@ PECL Sundown provides straight forward object oriented Markdown API and customiz PHP - * bumped up 0.3.6 - -now, php-sundown is able to use under windows box. -Thank you stealth35! + * bumped up 0.3.7 -* prettify phpinfo, add ext and sundown version -* windows support -* fix several compile warnings - -[removed constants]: -Sundown\Render\LIST_ORDERED -Sundown\Render\MKDA_NORMAL -Sundown\Render\MKDA_EMAIL +fixed SEGV when processing tableCell and prettify source codes. -[added constants]: -Sundown\Render\Base::LIST_ORDERED -Sundown\Render\Base::MKDA_NORMAL -Sundown\Render\Base::MKDA_EMAIL +9582b04 update contributors +1f11ace update README +497d0a4 add a space after comma. +7bc4703 fix several compile warnings +a11eb98 update CFLAGS for fix compile warnings +9a86d00 fixes #26:prevent SEGV when calling Sundwon\Base\tableCell +26b77d6 change submodule to vmg/sundown from tanoku/sundown +ee8a132 Merge pull request #24 from reeze/patch-2 +0a08969 Fix build in php-src +b0adcc7 Merge pull request #23 from reeze/patch-1 +ebae34b Make travis report test failure since make test didn't report exit code @@ -91,6 +88,7 @@ Sundown\Render\Base::MKDA_EMAIL + @@ -135,6 +133,37 @@ Sundown\Render\Base::MKDA_EMAIL sundown + + + beta + beta + + + 0.3.6 + 0.3.6 + + 2012-06-02 + + * bumped up 0.3.6 + +now, php-sundown is able to use under windows box. +Thank you stealth35! + +* prettify phpinfo, add ext and sundown version +* windows support +* fix several compile warnings + +[removed constants]: +Sundown\Render\LIST_ORDERED +Sundown\Render\MKDA_NORMAL +Sundown\Render\MKDA_EMAIL + +[added constants]: +Sundown\Render\Base::LIST_ORDERED +Sundown\Render\Base::MKDA_NORMAL +Sundown\Render\Base::MKDA_EMAIL + + beta diff --git a/php_sundown.c b/php_sundown.c index 6c9ce3a..e240cfd 100644 --- a/php_sundown.c +++ b/php_sundown.c @@ -56,18 +56,18 @@ static void sundown__render(SundownRendererType render_type, INTERNAL_FUNCTION_P HashTable *table; object = getThis(); - buffer = Z_STRVAL_P(zend_read_property(sundown_class_entry, getThis(),"data",sizeof("data")-1, 0 TSRMLS_CC)); + buffer = Z_STRVAL_P(zend_read_property(sundown_class_entry, getThis(), "data", sizeof("data")-1, 0 TSRMLS_CC)); buffer_len = strlen(buffer); memset(&input_buf, 0x0, sizeof(struct buf)); - input_buf.data = buffer; + input_buf.data = (uint8_t *)buffer; input_buf.size = strlen(buffer); output_buf = bufnew(128); bufgrow(output_buf, strlen(buffer) * 1.2f); - if (Z_TYPE_P(zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC)) != IS_NULL) { - table = Z_ARRVAL_P(zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC)); + if (Z_TYPE_P(zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC)) != IS_NULL) { + table = Z_ARRVAL_P(zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC)); } php_sundown__get_flags(table, &enabled_extensions, &render_flags); @@ -77,7 +77,7 @@ static void sundown__render(SundownRendererType render_type, INTERNAL_FUNCTION_P sdhtml_renderer(&sundown_render, &opt.html, render_flags); break; case SUNDOWN_RENDER_TOC: - sdhtml_toc_renderer(&sundown_render,&opt.html); + sdhtml_toc_renderer(&sundown_render, &opt.html); break; default: RETURN_FALSE; @@ -88,13 +88,13 @@ static void sundown__render(SundownRendererType render_type, INTERNAL_FUNCTION_P sd_markdown_render(output_buf, input_buf.data, input_buf.size, markdown); sd_markdown_free(markdown); - if (Z_BVAL_P(zend_read_property(sundown_class_entry, getThis(),"enable_pants",sizeof("enable_pants")-1, 0 TSRMLS_CC))) { + if (Z_BVAL_P(zend_read_property(sundown_class_entry, getThis(), "enable_pants", sizeof("enable_pants")-1, 0 TSRMLS_CC))) { struct buf *smart_buf = bufnew(128); - sdhtml_smartypants(smart_buf, output_buf->data,output_buf->size); - RETVAL_STRINGL(smart_buf->data, smart_buf->size,1); + sdhtml_smartypants(smart_buf, output_buf->data, output_buf->size); + RETVAL_STRINGL((char*)smart_buf->data, smart_buf->size, 1); bufrelease(smart_buf); } else { - RETVAL_STRINGL(output_buf->data, output_buf->size,1); + RETVAL_STRINGL((char*)output_buf->data, output_buf->size, 1); } } @@ -102,24 +102,24 @@ static void sundown__render(SundownRendererType render_type, INTERNAL_FUNCTION_P setup Sundown extension */ PHP_METHOD(sundown, __construct) { - zval *extensions = NULL,*c_extensions = NULL; + zval *extensions = NULL, *c_extensions = NULL; char *buffer; int buffer_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,"s|a",&buffer, &buffer_len, &extensions) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|a", &buffer, &buffer_len, &extensions) == FAILURE) { return; } - add_property_string_ex(getThis(),"data",sizeof("data"),buffer,1 TSRMLS_CC); + add_property_string_ex(getThis(), "data", sizeof("data"), buffer, 1 TSRMLS_CC); if (extensions == NULL) { MAKE_STD_ZVAL(c_extensions); array_init(c_extensions); } else { ALLOC_INIT_ZVAL(c_extensions); - ZVAL_ZVAL(c_extensions,extensions,1,0); + ZVAL_ZVAL(c_extensions, extensions, 1, 0); } - add_property_zval_ex(getThis(),"extensions",sizeof("extensions"),c_extensions TSRMLS_CC); + add_property_zval_ex(getThis(), "extensions", sizeof("extensions"), c_extensions TSRMLS_CC); } /* }}} */ @@ -129,7 +129,7 @@ PHP_METHOD(sundown, __destruct) { zval *extensions; - extensions = zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC); + extensions = zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC); zval_ptr_dtor(&extensions); } /* }}} */ @@ -138,7 +138,7 @@ PHP_METHOD(sundown, __destruct) Returns converted HTML string */ PHP_METHOD(sundown, toHtml) { - sundown__render(SUNDOWN_RENDER_HTML,INTERNAL_FUNCTION_PARAM_PASSTHRU); + sundown__render(SUNDOWN_RENDER_HTML, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ @@ -146,7 +146,7 @@ PHP_METHOD(sundown, toHtml) Returns converted HTML string */ PHP_METHOD(sundown, __toString) { - sundown__render(SUNDOWN_RENDER_HTML,INTERNAL_FUNCTION_PARAM_PASSTHRU); + sundown__render(SUNDOWN_RENDER_HTML, INTERNAL_FUNCTION_PARAM_PASSTHRU); } /* }}} */ @@ -154,7 +154,7 @@ PHP_METHOD(sundown, __toString) Returns table of contents*/ PHP_METHOD(sundown, toToc) { - sundown__render(SUNDOWN_RENDER_TOC,INTERNAL_FUNCTION_PARAM_PASSTHRU); + sundown__render(SUNDOWN_RENDER_TOC, INTERNAL_FUNCTION_PARAM_PASSTHRU); } @@ -172,8 +172,8 @@ PHP_METHOD(sundown, hasExtension) return; } - if (Z_TYPE_P(zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC)) != IS_NULL) { - table = Z_ARRVAL_P(zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC)); + if (Z_TYPE_P(zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC)) != IS_NULL) { + table = Z_ARRVAL_P(zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC)); RETVAL_BOOL(php_sundown_has_ext(table, name)); } } @@ -191,8 +191,8 @@ PHP_METHOD(sundown, hasRenderFlag) return; } - if (Z_TYPE_P(zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC)) != IS_NULL) { - table = Z_ARRVAL_P(zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC)); + if (Z_TYPE_P(zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC)) != IS_NULL) { + table = Z_ARRVAL_P(zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC)); RETVAL_BOOL(php_sundown_has_ext(table, name)); } } @@ -221,7 +221,7 @@ PHP_MINIT_FUNCTION(sundown) { php_sundown_render_html_toc_init(TSRMLS_C); php_sundown_markdown_init(TSRMLS_C); - REGISTER_NS_STRING_CONSTANT(ZEND_NS_NAME("Sundown","Render"), "HTML", "Sundown\\Render\\HTML", CONST_CS | CONST_PERSISTENT); + REGISTER_NS_STRING_CONSTANT(ZEND_NS_NAME("Sundown", "Render"), "HTML", "Sundown\\Render\\HTML", CONST_CS | CONST_PERSISTENT); return SUCCESS; } @@ -229,9 +229,9 @@ PHP_MINIT_FUNCTION(sundown) { PHP_MINFO_FUNCTION(sundown) { php_info_print_table_start(); - php_info_print_table_header(2,"Sundown Support", "enabled"); - php_info_print_table_row(2,"Version", PHP_SUNDOWN_EXTVER); - php_info_print_table_row(2,"Sundown Version", SUNDOWN_VERSION); + php_info_print_table_header(2, "Sundown Support", "enabled"); + php_info_print_table_row(2, "Version", PHP_SUNDOWN_EXTVER); + php_info_print_table_row(2, "Sundown Version", SUNDOWN_VERSION); php_info_print_table_end(); } diff --git a/php_sundown.h b/php_sundown.h index 6682f5a..d7e6d62 100644 --- a/php_sundown.h +++ b/php_sundown.h @@ -3,7 +3,7 @@ #define PHP_SUNDOWN_H #define PHP_SUNDOWN_EXTNAME "sundown" -#define PHP_SUNDOWN_EXTVER "0.3.6" +#define PHP_SUNDOWN_EXTVER "0.4.0-beta" #ifdef HAVE_CONFIG_H #include "config.h" @@ -24,7 +24,7 @@ * Zend will use when loading this module */ extern zend_module_entry sundown_module_entry; -#define phpext_sundown_ptr &sundown_module_entry; +#define phpext_sundown_ptr &sundown_module_entry extern zend_class_entry *sundown_class_entry, *php_sundown_buffer_class_entry; @@ -73,15 +73,15 @@ typedef struct{ struct html_renderopt html; } php_sundown_render_base_t; -#define SPAN_CALLBACK_EX(buffer,method_name, ...) {\ +#define SPAN_CALLBACK_EX(buffer, method_name, ...) {\ struct php_sundown_renderopt_ex *opt = (struct php_sundown_renderopt_ex*)opaque;\ zval func, *ret;\ \ MAKE_STD_ZVAL(ret);\ - ZVAL_STRING(&func,method_name,1);\ + ZVAL_STRING(&func, method_name, 1);\ \ - if(call_user_function_v(NULL,&opt->self,&func,ret,__VA_ARGS__) == FAILURE){\ - fprintf(stderr,"Can't call method %s\n", method_name);\ + if(call_user_function_v(NULL, &opt->self, &func, ret, __VA_ARGS__) == FAILURE){\ + fprintf(stderr, "Can't call method %s\n", method_name);\ return 0;\ }\ if (ret != NULL) {\ @@ -93,15 +93,15 @@ typedef struct{ } -#define BLOCK_CALLBACK_EX(buffer,method_name, ...) {\ +#define BLOCK_CALLBACK_EX(buffer, method_name, ...) {\ struct php_sundown_renderopt_ex *opt = (struct php_sundown_renderopt_ex*)opaque;\ zval func, *ret;\ \ MAKE_STD_ZVAL(ret);\ - ZVAL_STRING(&func,method_name,1);\ + ZVAL_STRING(&func, method_name, 1);\ \ - if(call_user_function_v(NULL,&opt->self,&func,ret,__VA_ARGS__) == FAILURE){\ - fprintf(stderr,"Can't call method %s\n", method_name);\ + if(call_user_function_v(NULL, &opt->self, &func, ret, __VA_ARGS__) == FAILURE){\ + fprintf(stderr, "Can't call method %s\n", method_name);\ }\ if (ret != NULL) {\ bufput(buffer, Z_STRVAL_P(ret), Z_STRLEN_P(ret));\ @@ -149,7 +149,7 @@ static int call_user_function_v(HashTable *function_table, zval **object_pp, zva params = NULL; } - ret = call_user_function(function_table, object_pp, function_name, retval_ptr, param_count,params TSRMLS_CC); + ret = call_user_function(function_table, object_pp, function_name, retval_ptr, param_count, params TSRMLS_CC); if (param_count > 0) { for (i=0; isize == 0) { ZVAL_NULL(str); } else { - ZVAL_STRINGL(str, text->data, text->size,1); + ZVAL_STRINGL(str, (char *)text->data, text->size, 1); } return str; } @@ -180,7 +180,7 @@ static inline zval* char2str(char *text) zval *str; MAKE_STD_ZVAL(str); - ZVAL_STRING(str, text ,1); + ZVAL_STRING(str, text, 1); return str; } @@ -189,7 +189,7 @@ static inline zval* buf2long(long value) zval *data; MAKE_STD_ZVAL(data); - ZVAL_LONG(data,value); + ZVAL_LONG(data, value); return data; } diff --git a/render_base.c b/render_base.c index 41b8b7a..80a7c2f 100644 --- a/render_base.c +++ b/render_base.c @@ -48,11 +48,11 @@ zend_object_value php_sundown_render_base_new(zend_class_entry *ce TSRMLS_DC) return retval; } -ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render___construct,0,0,1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render___construct, 0, 0, 1) ZEND_ARG_INFO(0, render_flags) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_base_set_render_flags,0,0,1) +ZEND_BEGIN_ARG_INFO_EX(arginfo_sundown_render_base_set_render_flags, 0, 0, 1) ZEND_ARG_INFO(0, render_flags) ZEND_END_ARG_INFO() @@ -186,7 +186,7 @@ PHP_METHOD(sundown_render_base, blockCode) "ss", &code, &code_len, &block_code, &block_code_len) == FAILURE) { return; } - RETVAL_STRINGL(code,code_len,1); + RETVAL_STRINGL(code, code_len, 1); } /* }}} */ @@ -201,7 +201,7 @@ PHP_METHOD(sundown_render_base, blockQuote) "s", "e, "e_len) == FAILURE) { return; } - RETVAL_STRINGL(quote,quote_len,1); + RETVAL_STRINGL(quote, quote_len,1); } /* }}} */ @@ -216,11 +216,11 @@ PHP_METHOD(sundown_render_base, blockHtml) "s", &raw, &raw_len) == FAILURE) { return; } - RETVAL_STRINGL(raw,raw_len,1); + RETVAL_STRINGL(raw, raw_len, 1); } /* }}} */ -/* {{{ proto string Sundown\Render\Base::header($htext,$header_level) +/* {{{ proto string Sundown\Render\Base::header($htext, $header_level) */ PHP_METHOD(sundown_render_base, header) { @@ -228,10 +228,10 @@ PHP_METHOD(sundown_render_base, header) int htext_len, header_level; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "sl",&htext, &htext_len, &header_level) == FAILURE) { + "sl", &htext, &htext_len, &header_level) == FAILURE) { return; } - RETVAL_STRINGL(htext,htext_len,1); + RETVAL_STRINGL(htext, htext_len, 1); } /* }}} */ @@ -257,7 +257,7 @@ PHP_METHOD(sundown_render_base, listBox) "sl", &contents, &contents_len, &list_type) == FAILURE) { return; } - RETVAL_STRINGL(contents,contents_len,1); + RETVAL_STRINGL(contents, contents_len, 1); } /* }}} */ @@ -270,10 +270,10 @@ PHP_METHOD(sundown_render_base, listItem) long list_type; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "sl",&text, &text_len, &list_type) == FAILURE) { + "sl", &text, &text_len, &list_type) == FAILURE) { return; } - RETVAL_STRINGL(text,text_len,1); + RETVAL_STRINGL(text, text_len, 1); } /* }}} */ @@ -288,7 +288,7 @@ PHP_METHOD(sundown_render_base, paragraph) "s", &text, &text_len) == FAILURE) { return; } - RETVAL_STRINGL(text,text_len,1); + RETVAL_STRINGL(text, text_len, 1); } /* }}} */ @@ -303,7 +303,7 @@ PHP_METHOD(sundown_render_base, table) "ss", &header, &header_len, &body, &body_len) == FAILURE) { return; } - RETVAL_STRINGL(body,body_len,1); + RETVAL_STRINGL(body, body_len, 1); } /* }}} */ @@ -318,7 +318,7 @@ PHP_METHOD(sundown_render_base, tableRow) "s", &contents, &contents_len) == FAILURE) { return; } - RETVAL_STRINGL(contents,contents_len,1); + RETVAL_STRINGL(contents, contents_len, 1); } /* }}} */ @@ -333,7 +333,7 @@ PHP_METHOD(sundown_render_base, tableCell) "ss", &content, &content_len, &alignment, &alignment_len) == FAILURE) { return; } - RETVAL_STRINGL(content,content_len,1); + RETVAL_STRINGL(content, content_len, 1); } /* }}} */ @@ -346,10 +346,10 @@ PHP_METHOD(sundown_render_base, autolink) long link_type; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "sl",&link, &link_len, &link_type) == FAILURE) { + "sl", &link, &link_len, &link_type) == FAILURE) { return; } - RETVAL_STRINGL(link,link_len,1); + RETVAL_STRINGL(link, link_len, 1); } /* }}} */ @@ -364,7 +364,7 @@ PHP_METHOD(sundown_render_base, codespan) "s", &code, &code_len) == FAILURE) { return; } - RETVAL_STRINGL(code,code_len,1); + RETVAL_STRINGL(code, code_len, 1); } /* }}} */ @@ -379,7 +379,7 @@ PHP_METHOD(sundown_render_base, doubleEmphasis) "s", &text, &text_len) == FAILURE) { return; } - RETVAL_STRINGL(text,text_len,1); + RETVAL_STRINGL(text, text_len, 1); } /* }}} */ @@ -394,7 +394,7 @@ PHP_METHOD(sundown_render_base, emphasis) "s", &text, &text_len) == FAILURE) { return; } - RETVAL_STRINGL(text,text_len,1); + RETVAL_STRINGL(text, text_len, 1); } /* }}} */ @@ -406,10 +406,10 @@ PHP_METHOD(sundown_render_base, image) int link_len, title_len, alt_text_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "sss",&link, &link_len, &title, &title_len, &alt_text, &alt_text_len) == FAILURE) { + "sss", &link, &link_len, &title, &title_len, &alt_text, &alt_text_len) == FAILURE) { return; } - RETVAL_STRINGL(link,link_len,1); + RETVAL_STRINGL(link, link_len, 1); } /* }}} */ @@ -423,7 +423,7 @@ PHP_METHOD(sundown_render_base, linebreak) } /* }}} */ -/* {{{ proto string Sundown\Render\Base::link($link,$title,$content) +/* {{{ proto string Sundown\Render\Base::link($link, $title, $content) */ PHP_METHOD(sundown_render_base, link) { @@ -431,10 +431,10 @@ PHP_METHOD(sundown_render_base, link) int link_len, title_len, content_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "sss",&link, &link_len, &title, &title_len, &content, &content_len) == FAILURE) { + "sss", &link, &link_len, &title, &title_len, &content, &content_len) == FAILURE) { return; } - RETVAL_STRINGL(link,link_len,1); + RETVAL_STRINGL(link, link_len, 1); } /* }}} */ @@ -449,7 +449,7 @@ PHP_METHOD(sundown_render_base, rawHtml) "s", &raw, &raw_len) == FAILURE) { return; } - RETVAL_STRINGL(raw,raw_len,1); + RETVAL_STRINGL(raw, raw_len, 1); } /* }}} */ @@ -464,7 +464,7 @@ PHP_METHOD(sundown_render_base, tripleEmphasis) "s", &text, &text_len) == FAILURE) { return; } - RETVAL_STRINGL(text,text_len,1); + RETVAL_STRINGL(text, text_len, 1); } /* }}} */ @@ -479,7 +479,7 @@ PHP_METHOD(sundown_render_base, strikethrough) "s", &text, &text_len) == FAILURE) { return; } - RETVAL_STRINGL(text,text_len,1); + RETVAL_STRINGL(text, text_len, 1); } /* }}} */ @@ -494,7 +494,7 @@ PHP_METHOD(sundown_render_base, superscript) "s", &text, &text_len) == FAILURE) { return; } - RETVAL_STRINGL(text,text_len,1); + RETVAL_STRINGL(text, text_len, 1); } /* }}} */ @@ -509,7 +509,7 @@ PHP_METHOD(sundown_render_base, entity) "s", &text, &text_len) == FAILURE) { return; } - RETVAL_STRINGL(text,text_len,1); + RETVAL_STRINGL(text, text_len, 1); } /* }}} */ @@ -521,10 +521,10 @@ PHP_METHOD(sundown_render_base, normalText) int text_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "s",&text, &text_len) == FAILURE) { + "s", &text, &text_len) == FAILURE) { return; } - RETVAL_STRINGL(text,text_len,1); + RETVAL_STRINGL(text, text_len, 1); } /* }}} */ @@ -556,7 +556,7 @@ PHP_METHOD(sundown_render_base, preprocess) return; } - RETVAL_STRINGL(text,text_len, 1); + RETVAL_STRINGL(text, text_len, 1); } /* }}} */ @@ -572,13 +572,13 @@ PHP_METHOD(sundown_render_base, postprocess) return; } - if (Z_BVAL_P(zend_read_property(Z_OBJCE_P(getThis()), getThis(),"enable_pants",sizeof("enable_pants")-1, 1 TSRMLS_CC))) { + if (Z_BVAL_P(zend_read_property(Z_OBJCE_P(getThis()), getThis(), "enable_pants", sizeof("enable_pants")-1, 1 TSRMLS_CC))) { struct buf *smart_buf = bufnew(128); - sdhtml_smartypants(smart_buf, text,text_len); - RETVAL_STRINGL(smart_buf->data, smart_buf->size,1); + sdhtml_smartypants(smart_buf, (uint8_t *)text, text_len); + RETVAL_STRINGL((char*)smart_buf->data, smart_buf->size, 1); bufrelease(smart_buf); } else { - RETVAL_STRINGL(text,text_len, 1); + RETVAL_STRINGL(text, text_len, 1); } } /* }}} */ @@ -601,7 +601,7 @@ PHP_METHOD(sundown_render_base, __construct) MAKE_STD_ZVAL(c_flags); array_init(c_flags); } - add_property_zval_ex(getThis(),"render_flags",sizeof("render_flags"),c_flags TSRMLS_CC); + add_property_zval_ex(getThis(), "render_flags", sizeof("render_flags"), c_flags TSRMLS_CC); } /* }}} */ @@ -612,10 +612,10 @@ PHP_METHOD(sundown_render_base, __construct) */ PHP_METHOD(sundown_render_base, getRenderFlags) { - if (Z_TYPE_P(zend_read_property(sundown_render_base_class_entry, getThis(),"render_flags",sizeof("render_flags")-1, 0 TSRMLS_CC)) != IS_NULL) { + if (Z_TYPE_P(zend_read_property(sundown_render_base_class_entry, getThis(), "render_flags", sizeof("render_flags")-1, 0 TSRMLS_CC)) != IS_NULL) { zval *tmp = NULL; - tmp = zend_read_property(sundown_render_base_class_entry, getThis(),"render_flags",sizeof("render_flags")-1, 0 TSRMLS_CC); + tmp = zend_read_property(sundown_render_base_class_entry, getThis(), "render_flags", sizeof("render_flags")-1, 0 TSRMLS_CC); RETVAL_ZVAL(tmp, 1, 0); } } @@ -632,11 +632,11 @@ PHP_METHOD(sundown_render_base, setRenderFlags) return; } MAKE_STD_ZVAL(c_render_flags); - ZVAL_ZVAL(c_render_flags,render_flags,1,0); + ZVAL_ZVAL(c_render_flags, render_flags, 1, 0); tmp = zend_read_property(sundown_render_base_class_entry, getThis(), "render_flags", sizeof("render_flags")-1, 0 TSRMLS_CC); zval_ptr_dtor(&tmp); - add_property_zval_ex(getThis(),"render_flags",sizeof("render_flags"),c_render_flags TSRMLS_CC); + add_property_zval_ex(getThis(), "render_flags", sizeof("render_flags"), c_render_flags TSRMLS_CC); } /* }}} */ @@ -646,7 +646,7 @@ PHP_METHOD(sundown_render_base, setRenderFlags) PHP_METHOD(sundown_render_base, __destruct) { zval *render_flags; - render_flags = zend_read_property(sundown_render_base_class_entry, getThis(),"render_flags",sizeof("render_flags")-1, 0 TSRMLS_CC); + render_flags = zend_read_property(sundown_render_base_class_entry, getThis(), "render_flags", sizeof("render_flags")-1, 0 TSRMLS_CC); if (Z_TYPE_P(render_flags) == IS_ARRAY) { zval_ptr_dtor(&render_flags); } @@ -691,7 +691,7 @@ static zend_function_entry php_sundown_render_base_methods[] = { void php_sundown_render_base_init(TSRMLS_D) { zend_class_entry ce; - INIT_NS_CLASS_ENTRY(ce, ZEND_NS_NAME("Sundown","Render"),"Base", php_sundown_render_base_methods); + INIT_NS_CLASS_ENTRY(ce, ZEND_NS_NAME("Sundown", "Render"), "Base", php_sundown_render_base_methods); sundown_render_base_class_entry = zend_register_internal_class(&ce TSRMLS_CC); sundown_render_base_class_entry->create_object = php_sundown_render_base_new; zend_declare_property_null(sundown_render_base_class_entry, "render_flags", sizeof("render_flags")-1, ZEND_ACC_PUBLIC TSRMLS_CC); diff --git a/render_html.c b/render_html.c index b86f997..89b6b9e 100644 --- a/render_html.c +++ b/render_html.c @@ -177,7 +177,7 @@ PHP_METHOD(sundown_render_html, blockCode) php_sundown_render_base_t *base; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "ss",&code, &code_len, &block_code, &block_code_len) == FAILURE) { + "ss", &code, &code_len, &block_code, &block_code_len) == FAILURE) { return; } @@ -186,10 +186,10 @@ PHP_METHOD(sundown_render_html, blockCode) input = str2buf(block_code, block_code_len); lang = str2buf(code, code_len); output = bufnew(128); - html->cb.blockcode(output,lang,input, &base->html); + html->cb.blockcode(output, lang, input, &base->html); bufrelease(input); bufrelease(lang); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -213,9 +213,9 @@ PHP_METHOD(sundown_render_html, blockQuote) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(quote, quote_len); output = bufnew(128); - html->cb.blockquote(output,input, &base->html); + html->cb.blockquote(output, input, &base->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -239,14 +239,14 @@ PHP_METHOD(sundown_render_html, blockHtml) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC);\ input = str2buf(raw, raw_len); output = bufnew(128); - html->cb.blockhtml(output,input, &base->html); + html->cb.blockhtml(output, input, &base->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ -/* {{{ proto string Sundown\Render\HTML::header($htext,$header_level) +/* {{{ proto string Sundown\Render\HTML::header($htext, $header_level) */ PHP_METHOD(sundown_render_html, header) { @@ -258,7 +258,7 @@ PHP_METHOD(sundown_render_html, header) php_sundown_render_base_t *base; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "sl",&htext, &htext_len, &header_level) == FAILURE) { + "sl", &htext, &htext_len, &header_level) == FAILURE) { return; } @@ -266,9 +266,9 @@ PHP_METHOD(sundown_render_html, header) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(htext, htext_len); output = bufnew(128); - html->cb.header(output,input,header_level, &base->html); + html->cb.header(output, input, header_level, &base->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -282,8 +282,8 @@ PHP_METHOD(sundown_render_html, hrule) output = bufnew(128); html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC); - html->cb.hrule(output,&html->html); - RETVAL_STRINGL(output->data, output->size,1); + html->cb.hrule(output, &html->html); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } @@ -309,11 +309,11 @@ PHP_METHOD(sundown_render_html, listBox) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC);\ input = str2buf(contents, contents_len); output = bufnew(128); - html->cb.list(output,input,list_type, &base->html); + html->cb.list(output, input, list_type, &base->html); if (input != NULL) { bufrelease(input); } - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -325,7 +325,7 @@ PHP_METHOD(sundown_render_html, listItem) char *text; int text_len; long list_type; - struct buf *input,*output; + struct buf *input, *output; php_sundown_render_html_t *html; php_sundown_render_base_t *base; @@ -338,12 +338,12 @@ PHP_METHOD(sundown_render_html, listItem) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(text, text_len); output = bufnew(128); - html->cb.listitem(output,input,list_type, &base->html); + html->cb.listitem(output, input, list_type, &base->html); if (input != NULL) { bufrelease(input); } - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -367,9 +367,9 @@ PHP_METHOD(sundown_render_html, paragraph) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(text, text_len); output = bufnew(128); - html->cb.paragraph(output,input, &base->html); + html->cb.paragraph(output, input, &base->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -380,7 +380,7 @@ PHP_METHOD(sundown_render_html, table) { char *header, *body; int header_len, body_len; - struct buf *b_header,*b_body,*output; + struct buf *b_header, *b_body, *output; php_sundown_render_html_t *html; php_sundown_render_base_t *base; @@ -392,10 +392,10 @@ PHP_METHOD(sundown_render_html, table) html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC); base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC); b_header = str2buf(header, header_len); - b_body = str2buf(body,body_len); + b_body = str2buf(body, body_len); output = bufnew(128); - html->cb.table(output,b_header,b_body,&base->html); - RETVAL_STRINGL(output->data, output->size,1); + html->cb.table(output, b_header, b_body, &base->html); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(b_header); bufrelease(b_body); bufrelease(output); @@ -408,7 +408,7 @@ PHP_METHOD(sundown_render_html, tableRow) { char *contents; int contents_len; - struct buf *output,*input; + struct buf *output, *input; php_sundown_render_html_t *html; php_sundown_render_base_t *base; @@ -420,8 +420,8 @@ PHP_METHOD(sundown_render_html, tableRow) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(contents, contents_len); output = bufnew(128); - html->cb.table_row(output,input,&base->html); - RETVAL_STRINGL(output->data, output->size,1); + html->cb.table_row(output, input, &base->html); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(input); bufrelease(output); } @@ -447,8 +447,8 @@ PHP_METHOD(sundown_render_html, tableCell) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(content, content_len); output = bufnew(128); - html->cb.table_cell(output,input,alignment,&base->html); - RETVAL_STRINGL(output->data, output->size,1); + html->cb.table_cell(output, input, alignment, &base->html); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(input); bufrelease(output); } @@ -472,9 +472,9 @@ PHP_METHOD(sundown_render_html, autolink) m_link = str2buf(link, link_len); output = bufnew(128); html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC); - html->cb.autolink(output,m_link,link_type, &html->html); + html->cb.autolink(output, m_link, link_type, &html->html); bufrelease(m_link); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } @@ -497,9 +497,9 @@ PHP_METHOD(sundown_render_html, codespan) input = str2buf(code, code_len); output = bufnew(128); html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC); - html->cb.codespan(output,input, &html->html); + html->cb.codespan(output, input, &html->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -515,7 +515,7 @@ PHP_METHOD(sundown_render_html, doubleEmphasis) php_sundown_render_base_t *base; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "s",&text, &text_len) == FAILURE) { + "s", &text, &text_len) == FAILURE) { return; } @@ -523,9 +523,9 @@ PHP_METHOD(sundown_render_html, doubleEmphasis) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC);\ input = str2buf(text, text_len); output = bufnew(128); - html->cb.double_emphasis(output,input, &base->html); + html->cb.double_emphasis(output, input, &base->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -549,9 +549,9 @@ PHP_METHOD(sundown_render_html, emphasis) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(text, text_len); output = bufnew(128); - html->cb.emphasis(output,input, &base->html); + html->cb.emphasis(output, input, &base->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -562,7 +562,7 @@ PHP_METHOD(sundown_render_html, image) { char *link, *title, *alt_text; int link_len, title_len, alt_text_len; - struct buf *b_link,*b_title, *b_alt_text, *output; + struct buf *b_link, *b_title, *b_alt_text, *output; php_sundown_render_html_t *html; php_sundown_render_base_t *base; @@ -577,11 +577,11 @@ PHP_METHOD(sundown_render_html, image) b_title = str2buf(title, title_len); b_alt_text = str2buf(alt_text, alt_text_len); output = bufnew(128); - html->cb.image(output,b_link,b_title,b_alt_text, &base->html); + html->cb.image(output, b_link, b_title, b_alt_text, &base->html); bufrelease(b_link); bufrelease(b_title); bufrelease(b_alt_text); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -595,13 +595,13 @@ PHP_METHOD(sundown_render_html, linebreak) output = bufnew(128); html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC); - html->cb.linebreak(output,&html->html); - RETVAL_STRINGL(output->data, output->size,1); + html->cb.linebreak(output, &html->html); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ -/* {{{ proto string Sundown\Render\HTML::link($link,$title,$content) +/* {{{ proto string Sundown\Render\HTML::link($link, $title, $content) */ PHP_METHOD(sundown_render_html, link) { @@ -611,7 +611,7 @@ PHP_METHOD(sundown_render_html, link) php_sundown_render_html_t *html; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "sss",&link, &link_len, &title, &title_len, &content, &content_len) == FAILURE) { + "sss", &link, &link_len, &title, &title_len, &content, &content_len) == FAILURE) { return; } @@ -620,11 +620,11 @@ PHP_METHOD(sundown_render_html, link) m_title = str2buf(title, title_len); m_content = str2buf(content, content_len); output = bufnew(128); - html->cb.link(output,m_link, m_title, m_content, &html->html); + html->cb.link(output, m_link, m_title, m_content, &html->html); bufrelease(m_link); bufrelease(m_title); bufrelease(m_content); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -646,9 +646,9 @@ PHP_METHOD(sundown_render_html, rawHtml) input = str2buf(raw, raw_len); output = bufnew(128); html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC); - html->cb.raw_html_tag(output,input, &html->html); + html->cb.raw_html_tag(output, input, &html->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -670,9 +670,9 @@ PHP_METHOD(sundown_render_html, tripleEmphasis) html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(text, text_len); output = bufnew(128); - html->cb.triple_emphasis(output,input, &html->html); + html->cb.triple_emphasis(output, input, &html->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -694,9 +694,9 @@ PHP_METHOD(sundown_render_html, strikethrough) html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(text, text_len); output = bufnew(128); - html->cb.strikethrough(output,input, &html->html); + html->cb.strikethrough(output, input, &html->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -711,16 +711,16 @@ PHP_METHOD(sundown_render_html, superscript) php_sundown_render_html_t *html; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "s",&text, &text_len) == FAILURE) { + "s", &text, &text_len) == FAILURE) { return; } html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(text, text_len); output = bufnew(128); - html->cb.superscript(output,input, &html->html); + html->cb.superscript(output, input, &html->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -743,12 +743,12 @@ PHP_METHOD(sundown_render_html, entity) if (html->cb.entity) { input = str2buf(text, text_len); output = bufnew(128); - html->cb.entity(output,input, &html->html); + html->cb.entity(output, input, &html->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } else { - RETVAL_STRINGL(text,text_len, 1); + RETVAL_STRINGL((char *)text, text_len, 1); } } /* }}} */ @@ -770,9 +770,9 @@ PHP_METHOD(sundown_render_html, normalText) html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(text, text_len); output = bufnew(128); - html->cb.normal_text(output,input, &html->html); + html->cb.normal_text(output, input, &html->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -813,7 +813,7 @@ PHP_METHOD(sundown_render_html, __construct) MAKE_STD_ZVAL(c_flags); array_init(c_flags); } - add_property_zval_ex(getThis(),"render_flags",sizeof("render_flags"),c_flags TSRMLS_CC); + add_property_zval_ex(getThis(), "render_flags", sizeof("render_flags"), c_flags TSRMLS_CC); object = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC); sdhtml_renderer(&object->cb, &opt.html, 0); @@ -849,14 +849,14 @@ static zend_function_entry php_sundown_render_html_methods[] = { PHP_ME(sundown_render_html, normalText, arginfo_sundown_render_html_normal_text, ZEND_ACC_PUBLIC) PHP_ME(sundown_render_html, docHeader, arginfo_sundown_render_html_doc_header, ZEND_ACC_PUBLIC) PHP_ME(sundown_render_html, docFooter, arginfo_sundown_render_html_doc_footer, ZEND_ACC_PUBLIC) - {NULL,NULL,NULL} + {NULL, NULL, NULL} }; void php_sundown_render_html_init(TSRMLS_D) { zend_class_entry ce; - INIT_NS_CLASS_ENTRY(ce, ZEND_NS_NAME("Sundown","Render"),"HTML", php_sundown_render_html_methods); + INIT_NS_CLASS_ENTRY(ce, ZEND_NS_NAME("Sundown", "Render"), "HTML", php_sundown_render_html_methods); sundown_render_html_class_entry = zend_register_internal_class_ex(&ce, sundown_render_base_class_entry, NULL TSRMLS_CC); sundown_render_html_class_entry->create_object = php_sundown_render_html_new; zend_declare_property_null(sundown_render_html_class_entry, "render_flags", sizeof("render_flags")-1, ZEND_ACC_PUBLIC TSRMLS_CC); diff --git a/render_html_toc.c b/render_html_toc.c index 77a08b4..8a74f64 100644 --- a/render_html_toc.c +++ b/render_html_toc.c @@ -194,7 +194,7 @@ PHP_METHOD(sundown_render_html_toc, blockHtml) } /* }}} */ -/* {{{ proto string Sundown\Render\HTML_TOC::header($htext,$header_level) +/* {{{ proto string Sundown\Render\HTML_TOC::header($htext, $header_level) */ PHP_METHOD(sundown_render_html_toc, header) { @@ -206,17 +206,17 @@ PHP_METHOD(sundown_render_html_toc, header) php_sundown_render_base_t *base; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "sl",&htext, &htext_len, &header_level) == FAILURE) { + "sl", &htext, &htext_len, &header_level) == FAILURE) { return; } html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC); base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(htext, htext_len); - output = bufnew(128); - html->cb.header(output,input,header_level, &base->html); + output = bufnew(128); + html->cb.header(output, input, header_level, &base->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -302,9 +302,9 @@ PHP_METHOD(sundown_render_html_toc, codespan) input = str2buf(code, code_len); output = bufnew(128); html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC); - html->cb.codespan(output,input, &html->html); + html->cb.codespan(output, input, &html->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -319,7 +319,7 @@ PHP_METHOD(sundown_render_html_toc, doubleEmphasis) php_sundown_render_html_toc_t *html; php_sundown_render_base_t *base; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "s",&text, &text_len) == FAILURE) { + "s", &text, &text_len) == FAILURE) { return; } @@ -327,9 +327,9 @@ PHP_METHOD(sundown_render_html_toc, doubleEmphasis) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC);\ input = str2buf(text, text_len); output = bufnew(128); - html->cb.double_emphasis(output,input, &base->html); + html->cb.double_emphasis(output, input, &base->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -353,9 +353,9 @@ PHP_METHOD(sundown_render_html_toc, emphasis) base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(text, text_len); output = bufnew(128); - html->cb.emphasis(output,input, &base->html); + html->cb.emphasis(output, input, &base->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -376,7 +376,7 @@ PHP_METHOD(sundown_render_html_toc, linebreak) } /* }}} */ -/* {{{ proto string Sundown\Render\HTML_TOC::link($link,$title,$content) +/* {{{ proto string Sundown\Render\HTML_TOC::link($link, $title, $content) */ PHP_METHOD(sundown_render_html_toc, link) { @@ -386,7 +386,7 @@ PHP_METHOD(sundown_render_html_toc, link) php_sundown_render_html_toc_t *html; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "sss",&link, &link_len, &title, &title_len, &content, &content_len) == FAILURE) { + "sss", &link, &link_len, &title, &title_len, &content, &content_len) == FAILURE) { return; } @@ -395,11 +395,11 @@ PHP_METHOD(sundown_render_html_toc, link) m_title = str2buf(title, title_len); m_content = str2buf(content, content_len); output = bufnew(128); - html->cb.link(output,m_link, m_title, m_content, &html->html); + html->cb.link(output, m_link, m_title, m_content, &html->html); bufrelease(m_link); bufrelease(m_title); bufrelease(m_content); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -429,9 +429,9 @@ PHP_METHOD(sundown_render_html_toc, tripleEmphasis) html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(text, text_len); output = bufnew(128); - html->cb.triple_emphasis(output,input, &html->html); + html->cb.triple_emphasis(output, input, &html->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -453,9 +453,9 @@ PHP_METHOD(sundown_render_html_toc, strikethrough) html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(text, text_len); output = bufnew(128); - html->cb.strikethrough(output,input, &html->html); + html->cb.strikethrough(output, input, &html->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -470,16 +470,16 @@ PHP_METHOD(sundown_render_html_toc, superscript) php_sundown_render_html_toc_t *html; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "s",&text, &text_len) == FAILURE) { + "s", &text, &text_len) == FAILURE) { return; } html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC); input = str2buf(text, text_len); output = bufnew(128); - html->cb.superscript(output,input, &html->html); + html->cb.superscript(output, input, &html->html); bufrelease(input); - RETVAL_STRINGL(output->data, output->size,1); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -500,11 +500,11 @@ PHP_METHOD(sundown_render_html_toc, normalText) int text_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, - "s",&text, &text_len) == FAILURE) { + "s", &text, &text_len) == FAILURE) { return; } - RETVAL_STRINGL(text,text_len,1); + RETVAL_STRINGL(text, text_len, 1); } /* }}} */ @@ -525,8 +525,8 @@ PHP_METHOD(sundown_render_html_toc, docFooter) html = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC); output = bufnew(128); - html->cb.doc_footer(output,&html->html); - RETVAL_STRINGL(output->data, output->size,1); + html->cb.doc_footer(output, &html->html); + RETVAL_STRINGL((char *)output->data, output->size, 1); bufrelease(output); } /* }}} */ @@ -551,7 +551,7 @@ PHP_METHOD(sundown_render_html_toc, __construct) MAKE_STD_ZVAL(c_flags); array_init(c_flags); } - add_property_zval_ex(getThis(),"render_flags",sizeof("render_flags"),c_flags TSRMLS_CC); + add_property_zval_ex(getThis(), "render_flags", sizeof("render_flags"), c_flags TSRMLS_CC); object = (php_sundown_render_html_toc_t *) zend_object_store_get_object(getThis() TSRMLS_CC); sdhtml_toc_renderer(&object->cb, &opt.html); @@ -587,14 +587,14 @@ static zend_function_entry php_sundown_render_html_toc_methods[] = { PHP_ME(sundown_render_html_toc, normalText, arginfo_sundown_render_html_toc_normal_text, ZEND_ACC_PUBLIC) PHP_ME(sundown_render_html_toc, docHeader, arginfo_sundown_render_html_toc_doc_header, ZEND_ACC_PUBLIC) PHP_ME(sundown_render_html_toc, docFooter, arginfo_sundown_render_html_toc_doc_footer, ZEND_ACC_PUBLIC) - {NULL,NULL,NULL} + {NULL, NULL, NULL} }; void php_sundown_render_html_toc_init(TSRMLS_D) { zend_class_entry ce; - INIT_NS_CLASS_ENTRY(ce, ZEND_NS_NAME("Sundown","Render"),"HTML_TOC", php_sundown_render_html_toc_methods); + INIT_NS_CLASS_ENTRY(ce, ZEND_NS_NAME("Sundown", "Render"), "HTML_TOC", php_sundown_render_html_toc_methods); sundown_render_html_toc_class_entry = zend_register_internal_class_ex(&ce, sundown_render_base_class_entry, NULL TSRMLS_CC); sundown_render_html_toc_class_entry->create_object = php_sundown_render_html_toc_new; zend_declare_property_null(sundown_render_html_toc_class_entry, "render_flags", sizeof("render_flags")-1, ZEND_ACC_PUBLIC TSRMLS_CC); diff --git a/sundown_markdown.c b/sundown_markdown.c index 768a8f4..3986497 100644 --- a/sundown_markdown.c +++ b/sundown_markdown.c @@ -25,27 +25,27 @@ zend_class_entry *sundown_markdown_class_entry; static void rndr_blockcode(struct buf *ob, const struct buf *text, const struct buf *lang, void *opaque) { - BLOCK_CALLBACK_EX(ob,"blockCode", 2, buf2str(text), buf2str(lang)); + BLOCK_CALLBACK_EX(ob, "blockCode", 2, buf2str(text), buf2str(lang)); } static void rndr_blockquote(struct buf *ob, const struct buf *text, void *opaque) { - BLOCK_CALLBACK_EX(ob,"blockQuote", 1, buf2str(text)); + BLOCK_CALLBACK_EX(ob, "blockQuote", 1, buf2str(text)); } static void rndr_raw_block(struct buf *ob, const struct buf *text, void *opaque) { - BLOCK_CALLBACK_EX(ob,"blockHtml", 1, buf2str(text)); + BLOCK_CALLBACK_EX(ob, "blockHtml", 1, buf2str(text)); } static void rndr_header(struct buf *ob, const struct buf *text, int level, void *opaque) { - BLOCK_CALLBACK_EX(ob,"header", 2, buf2str(text), buf2long(level)); + BLOCK_CALLBACK_EX(ob, "header", 2, buf2str(text), buf2long(level)); } static void rndr_hrule(struct buf *ob, void *opaque) { - BLOCK_CALLBACK_EX(ob,"hrule", 0); + BLOCK_CALLBACK_EX(ob, "hrule", 0); } static void rndr_list(struct buf *ob, const struct buf *text, int flags, void *opaque) @@ -53,7 +53,7 @@ static void rndr_list(struct buf *ob, const struct buf *text, int flags, void *o zval *flag; MAKE_STD_ZVAL(flag); ZVAL_LONG(flag, flags); - BLOCK_CALLBACK_EX(ob,"listBox", 2,buf2str(text),flag); + BLOCK_CALLBACK_EX(ob, "listBox", 2, buf2str(text), flag); } @@ -62,47 +62,48 @@ static void rndr_listitem(struct buf *ob, const struct buf *text, int flags, voi zval *flag; MAKE_STD_ZVAL(flag); ZVAL_LONG(flag, flags); - BLOCK_CALLBACK_EX(ob,"listItem", 2, buf2str(text),flag); + BLOCK_CALLBACK_EX(ob, "listItem", 2, buf2str(text), flag); } static void rndr_paragraph(struct buf *ob, const struct buf *text, void *opaque) { - BLOCK_CALLBACK_EX(ob,"paragraph", 1,buf2str(text)); + BLOCK_CALLBACK_EX(ob, "paragraph", 1, buf2str(text)); } static void rndr_table(struct buf *ob, const struct buf *header, const struct buf *body, void *opaque) { - BLOCK_CALLBACK_EX(ob,"table", 2, buf2str(header), buf2str(body)); + BLOCK_CALLBACK_EX(ob, "table", 2, buf2str(header), buf2str(body)); } static void rndr_tablerow(struct buf *ob, const struct buf *text, void *opaque) { - BLOCK_CALLBACK_EX(ob,"tableRow", 1, buf2str(text)); + BLOCK_CALLBACK_EX(ob, "tableRow", 1, buf2str(text)); } static void rndr_tablecell(struct buf *ob, const struct buf *text, int align, void *opaque) { - zval php_align; + zval *php_align; + MAKE_STD_ZVAL(php_align); switch (align) { case MKD_TABLE_ALIGN_L: - ZVAL_STRING(&php_align, "left", 1); + ZVAL_STRING(php_align, "left", 1); break; case MKD_TABLE_ALIGN_R: - ZVAL_STRING(&php_align, "right", 1); + ZVAL_STRING(php_align, "right", 1); break; case MKD_TABLE_ALIGN_CENTER: - ZVAL_STRING(&php_align, "center", 1); + ZVAL_STRING(php_align, "center", 1); break; default: - ZVAL_NULL(&php_align); + ZVAL_NULL(php_align); break; } - BLOCK_CALLBACK_EX(ob,"tableCell", 2,buf2str(text), &php_align); + BLOCK_CALLBACK_EX(ob, "tableCell", 2, buf2str(text), php_align); } /*** @@ -110,37 +111,37 @@ static void rndr_tablecell(struct buf *ob, const struct buf *text, int align, vo */ static int rndr_autolink(struct buf *ob, const struct buf *link, enum mkd_autolink type, void *opaque) { - SPAN_CALLBACK_EX(ob,"autolink", 2,buf2str(link),buf2long(type)); + SPAN_CALLBACK_EX(ob, "autolink", 2, buf2str(link), buf2long(type)); } static int rndr_codespan(struct buf *ob, const struct buf *text, void *opaque) { - SPAN_CALLBACK_EX(ob,"codespan", 1, buf2str(text)); + SPAN_CALLBACK_EX(ob, "codespan", 1, buf2str(text)); } static int rndr_double_emphasis(struct buf *ob, const struct buf *text, void *opaque) { - SPAN_CALLBACK_EX(ob,"doubleEmphasis", 1, buf2str(text)); + SPAN_CALLBACK_EX(ob, "doubleEmphasis", 1, buf2str(text)); } static int rndr_emphasis(struct buf *ob, const struct buf *text, void *opaque) { - SPAN_CALLBACK_EX(ob,"emphasis", 1, buf2str(text)); + SPAN_CALLBACK_EX(ob, "emphasis", 1, buf2str(text)); } static int rndr_image(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *alt, void *opaque) { - SPAN_CALLBACK_EX(ob,"image", 3, buf2str(link), buf2str(title), buf2str(alt)); + SPAN_CALLBACK_EX(ob, "image", 3, buf2str(link), buf2str(title), buf2str(alt)); } static int rndr_linebreak(struct buf *ob, void *opaque) { - SPAN_CALLBACK_EX(ob,"linebreak", 0); + SPAN_CALLBACK_EX(ob, "linebreak", 0); } static int rndr_link(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *content, void *opaque) { - SPAN_CALLBACK_EX(ob,"link", 3, buf2str(link), buf2str(title), buf2str(content)); + SPAN_CALLBACK_EX(ob, "link", 3, buf2str(link), buf2str(title), buf2str(content)); } static int rndr_raw_html(struct buf *ob, const struct buf *text, void *opaque) @@ -321,23 +322,23 @@ PHP_METHOD(sundown_markdown, __construct) if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z|a", &render, &extensions) == FAILURE) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC," Sundown\\Markdown::__construct() expects parameter 2 to be array"); + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, " Sundown\\Markdown::__construct() expects parameter 2 to be array"); return; } if (Z_TYPE_P(render) == IS_STRING) { if (zend_lookup_class(Z_STRVAL_P(render), strlen(Z_STRVAL_P(render)), &ce TSRMLS_CC) == FAILURE) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,"class %s does not find.", Z_STRVAL_P(render)); + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "class %s does not find.", Z_STRVAL_P(render)); return; } else { - zval *func,*ret, *obj; + zval *func, *ret, *obj; MAKE_STD_ZVAL(func); MAKE_STD_ZVAL(ret); MAKE_STD_ZVAL(obj); - ZVAL_STRING(func,"__construct",1); + ZVAL_STRING(func, "__construct", 1); object_init_ex(obj, *ce); - call_user_function(NULL, &obj,func,ret,0,NULL TSRMLS_CC); + call_user_function(NULL, &obj, func, ret, 0, NULL TSRMLS_CC); zval_ptr_dtor(&func); zval_ptr_dtor(&ret); render = obj; @@ -346,13 +347,13 @@ PHP_METHOD(sundown_markdown, __construct) // nothing todo. Z_ADDREF_P(render); } else { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,"Render class must extend Sundown\\Render\\Base"); + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Render class must extend Sundown\\Render\\Base"); return; } if (!instanceof_function_ex(Z_OBJCE_P(render), sundown_render_base_class_entry, 0 TSRMLS_CC)) { Z_DELREF_P(render); - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,"Render class must extend Sundown\\Render\\Base"); + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Render class must extend Sundown\\Render\\Base"); return; } object->render = render; @@ -362,9 +363,9 @@ PHP_METHOD(sundown_markdown, __construct) array_init(c_extensions); } else { ALLOC_INIT_ZVAL(c_extensions); - ZVAL_ZVAL(c_extensions,extensions,1,0); + ZVAL_ZVAL(c_extensions, extensions, 1, 0); } - add_property_zval_ex(getThis(),"extensions",sizeof("extensions"),c_extensions TSRMLS_CC); + add_property_zval_ex(getThis(), "extensions", sizeof("extensions"), c_extensions TSRMLS_CC); } /* }}} */ @@ -375,7 +376,7 @@ PHP_METHOD(sundown_markdown, __destruct) { zval *extensions; - extensions = zend_read_property(sundown_markdown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC); + extensions = zend_read_property(sundown_markdown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC); zval_ptr_dtor(&extensions); } /* }}} */ @@ -386,7 +387,6 @@ PHP_METHOD(sundown_markdown, __destruct) */ PHP_METHOD(sundown_markdown, render) { - php_sundown_markdown_t *object = (php_sundown_markdown_t *) zend_object_store_get_object(getThis() TSRMLS_CC); php_sundown_render_base_t *render_base; zval preprocess, postprocess, *params[1], *ret, *render, *m_retval; struct buf input_buf, *output_buf; @@ -410,23 +410,19 @@ PHP_METHOD(sundown_markdown, render) output_buf = bufnew(128); bufgrow(output_buf, buffer_len * 1.2f); - if (zend_call_method_with_0_params(&this_ptr, Z_OBJCE_P(getThis()), NULL, "getrender", &render) == FAILURE) { - return; - } - - if (zend_call_method_with_0_params(&render, Z_OBJCE_P(render), NULL, "getrenderflags", &m_retval)) { - table = Z_ARRVAL_P(m_retval); - php_sundown__get_render_flags(table, &render_flags); - table = NULL; - zval_ptr_dtor(&m_retval); - } - - if (zend_call_method_with_0_params(&this_ptr, Z_OBJCE_P(getThis()), NULL, "getextensions", &m_retval)) { - table = Z_ARRVAL_P(m_retval); - php_sundown__get_extensions(table, &enabled_extensions); - table = NULL; - zval_ptr_dtor(&m_retval); - } + zend_call_method_with_0_params(&this_ptr, Z_OBJCE_P(getThis()), NULL, "getrender", &render); + + zend_call_method_with_0_params(&render, Z_OBJCE_P(render), NULL, "getrenderflags", &m_retval); + table = Z_ARRVAL_P(m_retval); + php_sundown__get_render_flags(table, &render_flags); + table = NULL; + zval_ptr_dtor(&m_retval); + + zend_call_method_with_0_params(&this_ptr, Z_OBJCE_P(getThis()), NULL, "getextensions", &m_retval); + table = Z_ARRVAL_P(m_retval); + php_sundown__get_extensions(table, &enabled_extensions); + table = NULL; + zval_ptr_dtor(&m_retval); /* @todo: setup render */ switch (SUNDOWN_RENDER_HTML) { @@ -434,7 +430,7 @@ PHP_METHOD(sundown_markdown, render) sdhtml_renderer(&sundown_render, &opt.html, render_flags); break; case SUNDOWN_RENDER_TOC: - sdhtml_toc_renderer(&sundown_render,&opt.html); + sdhtml_toc_renderer(&sundown_render, &opt.html); break; default: RETURN_FALSE; @@ -457,17 +453,17 @@ PHP_METHOD(sundown_markdown, render) /* preprocess */ MAKE_STD_ZVAL(ret); MAKE_STD_ZVAL(params[0]); - ZVAL_STRINGL(params[0], buffer,strlen(buffer), 1); - ZVAL_STRING(&preprocess,"preprocess",1); + ZVAL_STRINGL(params[0], buffer, strlen(buffer), 1); + ZVAL_STRING(&preprocess, "preprocess", 1); if (call_user_function(NULL, &render, &preprocess, ret, 1, params TSRMLS_CC) == FAILURE) { } memset(&input_buf, 0x0, sizeof(struct buf)); if (ret != NULL && Z_TYPE_P(ret) == IS_STRING) { - input_buf.data = Z_STRVAL_P(ret); + input_buf.data = (uint8_t *)Z_STRVAL_P(ret); input_buf.size = Z_STRLEN_P(ret); } else { - input_buf.data = buffer; + input_buf.data = (uint8_t *)buffer; input_buf.size = strlen(buffer); } zval_ptr_dtor(¶ms[0]); @@ -481,15 +477,15 @@ PHP_METHOD(sundown_markdown, render) /* postprocess */ MAKE_STD_ZVAL(ret); MAKE_STD_ZVAL(params[0]); - ZVAL_STRINGL(params[0], output_buf->data,output_buf->size, 1); - ZVAL_STRING(&postprocess,"postprocess",1); + ZVAL_STRINGL(params[0], (char *)output_buf->data, output_buf->size, 1); + ZVAL_STRING(&postprocess, "postprocess", 1); if (call_user_function(NULL, &render, &postprocess, ret, 1, params TSRMLS_CC) == FAILURE) { } if (ret != NULL && Z_TYPE_P(ret) == IS_STRING) { - RETVAL_STRINGL(Z_STRVAL_P(ret), Z_STRLEN_P(ret),1); + RETVAL_STRINGL(Z_STRVAL_P(ret), Z_STRLEN_P(ret), 1); } else { - RETVAL_STRINGL(output_buf->data,output_buf->size,1); + RETVAL_STRINGL((char *)output_buf->data, output_buf->size, 1); } zval_ptr_dtor(&ret); zval_ptr_dtor(¶ms[0]); @@ -514,8 +510,8 @@ PHP_METHOD(sundown_markdown, hasExtension) return; } - if (Z_TYPE_P(zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC)) != IS_NULL) { - table = Z_ARRVAL_P(zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC)); + if (Z_TYPE_P(zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC)) != IS_NULL) { + table = Z_ARRVAL_P(zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC)); RETVAL_BOOL(php_sundown_has_ext(table, name)); } } @@ -528,20 +524,15 @@ PHP_METHOD(sundown_markdown, hasRenderFlag) char *name; int name_len = 0; HashTable *table; - zval *render_flags,*render = NULL; + zval *render_flags, *render = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) { return; } - if (zend_call_method_with_0_params(&this_ptr, Z_OBJCE_P(getThis()), NULL, "getrender", &render) == FAILURE) { - return; - } - - if (zend_call_method_with_0_params(&render, Z_OBJCE_P(render), NULL, "getrenderflags", &render_flags) == FAILURE) { - return; - } + zend_call_method_with_0_params(&this_ptr, Z_OBJCE_P(getThis()), NULL, "getrender", &render); + zend_call_method_with_0_params(&render, Z_OBJCE_P(render), NULL, "getrenderflags", &render_flags); table = Z_ARRVAL_P(render_flags); RETVAL_BOOL(php_sundown_has_ext(table, name)); @@ -562,10 +553,10 @@ PHP_METHOD(sundown_markdown, setExtensions) return; } - tmp = zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC); + tmp = zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC); zval_ptr_dtor(&tmp); - add_property_zval_ex(getThis(),"extensions",sizeof("extensions"),extensions TSRMLS_CC); + add_property_zval_ex(getThis(), "extensions", sizeof("extensions"), extensions TSRMLS_CC); } /* }}} */ @@ -573,10 +564,10 @@ PHP_METHOD(sundown_markdown, setExtensions) */ PHP_METHOD(sundown_markdown, getExtensions) { - if (Z_TYPE_P(zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC)) != IS_NULL) { + if (Z_TYPE_P(zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC)) != IS_NULL) { zval *result; - result = zend_read_property(sundown_class_entry, getThis(),"extensions",sizeof("extensions")-1, 0 TSRMLS_CC); + result = zend_read_property(sundown_class_entry, getThis(), "extensions", sizeof("extensions")-1, 0 TSRMLS_CC); RETVAL_ZVAL(result, 1, 0); } } @@ -604,7 +595,7 @@ PHP_METHOD(sundown_markdown, setRender) } if (!instanceof_function_ex(Z_OBJCE_P(render), sundown_render_base_class_entry, 0 TSRMLS_CC)) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC,"Render class must extend Sundown\\Render\\Base"); + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Render class must extend Sundown\\Render\\Base"); return; } zval_ptr_dtor(&object->render); @@ -624,14 +615,14 @@ static zend_function_entry php_sundown_markdown_methods[] = { PHP_ME(sundown_markdown, setExtensions, arginfo_sundown_markdown_set_extensions, ZEND_ACC_PUBLIC) PHP_ME(sundown_markdown, hasExtension, arginfo_sundown_markdown_has_extension, ZEND_ACC_PUBLIC) PHP_ME(sundown_markdown, hasRenderFlag, arginfo_sundown_markdown_has_render_flag, ZEND_ACC_PUBLIC) - {NULL,NULL,NULL} + {NULL, NULL, NULL} }; void php_sundown_markdown_init(TSRMLS_D) { zend_class_entry ce; - INIT_NS_CLASS_ENTRY(ce, "Sundown","Markdown", php_sundown_markdown_methods); + INIT_NS_CLASS_ENTRY(ce, "Sundown", "Markdown", php_sundown_markdown_methods); sundown_markdown_class_entry = zend_register_internal_class(&ce TSRMLS_CC); sundown_markdown_class_entry->create_object = php_sundown_markdown_new; zend_declare_property_null(sundown_markdown_class_entry, "extensions", sizeof("extensions")-1, ZEND_ACC_PUBLIC TSRMLS_CC); diff --git a/tests/999-regression-no26.phpt b/tests/999-regression-no26.phpt new file mode 100644 index 0000000..68b4095 --- /dev/null +++ b/tests/999-regression-no26.phpt @@ -0,0 +1,51 @@ +--TEST-- +Check for https://github.com/chobie/php-sundown/issues/19 +--SKIPIF-- + +--FILE-- +true)); +echo $sd->toHTML(); + +//sementation fault: +$md = new \Sundown\Markdown(\Sundown\Render\HTML, array('tables'=>true)); +echo $md->render($table); +--EXPECT-- + + + + + + + + + + + + + + +
First HeaderSecond Header
Content CellContent Cell
Content CellContent Cell
+ + + + + + + + + + + + + + +
First HeaderSecond Header
Content CellContent Cell
Content CellContent Cell
\ No newline at end of file