Skip to content

Commit

Permalink
fix config key length
Browse files Browse the repository at this point in the history
Change-Id: Id1ceb8c8b49ab44e1632e2859e2e6d0a672fbe51
  • Loading branch information
yong.teng committed Dec 8, 2013
1 parent 0976497 commit 9f5e4c6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
7 changes: 6 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Changes 1.0.0 Beta
09 Dec 2013
*) Change:讲 Properties Config 保存数据时换行符由固定的"\r\n",更改为宏 PHP_EOL
*) Bugfix: Ini Config 和 Properties Config key 长度问题

Changes 1.0.0 Alpha
25 Nov 2013
08 Dec 2013
*) Change:修改 IP 验证 flags 默认值为:0,即将原来的默认不允许为保留 IP,修改为默认允许为保留 IP
*) Change:删除电话号码验证内部 API 和相关数据结构
*) Change:调整 Validate::isBlank 内部 API
Expand Down
4 changes: 2 additions & 2 deletions config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ typedef struct _config_object {
} \
}

#define config_save_write(_path, _path_length, str){ \
#define config_save_write(path, path_length, str){ \
size_t result_size; \
int result = buession_file_write((_path), (_path_length), (str).c, (str).len, PHP_LOCK_EX, &result_size TSRMLS_CC); \
int result = buession_file_write((path), (path_length), (str).c, (str).len, PHP_LOCK_EX, &result_size TSRMLS_CC); \
smart_str_free(&(str)); \
RETURN_BOOL(result == SUCCESS); \
}
Expand Down
20 changes: 9 additions & 11 deletions config/ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,17 @@ ZEND_END_ARG_INFO()
/* }}} */

static void config_ini_add_value(zval *dest, char *key, uint key_length, zval *value TSRMLS_DC){
if(value){
zval *val;
zval *val;

config_ini_parse_value(value, val);
add_assoc_zval_ex(dest, key, key_length, val);
}
config_ini_parse_value(value, val);
add_assoc_zval_ex(dest, key, key_length, val);
}

static void config_ini_add_next_index_value(zval *dest, zval *value TSRMLS_DC){
if(value){
zval *val;
zval *val;

config_ini_parse_value(value, val);
add_next_index_zval(dest, val);
}
config_ini_parse_value(value, val);
add_next_index_zval(dest, val);
}

static void config_ini_simple_parse(zval *arg1, zval *arg2, zval *arg3, int callback_type, zval *result TSRMLS_DC){
Expand Down Expand Up @@ -209,7 +205,7 @@ static int config_ini_render_apply(zval **value TSRMLS_DC, int num_args, va_list
parent_key_length = spprintf(&parent_key, 0, "%s.%s", parent, hash_key->arKey);
}else{
parent_key_length = hash_key->nKeyLength - 1;
parent_key = estrndup(hash_key->arKey, hash_key->nKeyLength);
parent_key = estrndup(hash_key->arKey, parent_key_length);
}
}else{
if(parent){
Expand Down Expand Up @@ -328,6 +324,8 @@ static BUESSION_METHOD(config_ini, save){
if((data_ht = buession_zval_convert_to_hash(data TSRMLS_CC))){
zend_hash_apply_with_arguments(data_ht TSRMLS_CC, (apply_func_args_t) config_ini_render_apply, 4, &content, NULL, 0, FALSE);
}

content.len = content.len - (sizeof(PHP_EOL) - 1);
smart_str_0(&content);
config_save_write(path, path_length, content);
}
Expand Down
2 changes: 2 additions & 0 deletions config/properties.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ static BUESSION_METHOD(config_properties, save){
if((data_ht = buession_zval_convert_to_hash(data TSRMLS_CC))){
zend_hash_apply_with_arguments(data_ht TSRMLS_CC, (apply_func_args_t) config_properties_render_apply, 3, &content, NULL, 0);
}

content.len = content.len - (sizeof(PHP_EOL) - 1);
smart_str_0(&content);
config_save_write(path, path_length, content);
}
Expand Down
4 changes: 2 additions & 2 deletions config/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static BUESSION_METHOD(config_simple, save){

config_save_init(intern, path, path_length, data);

smart_str_appendl(&content, "<?php\r\n\treturn ", sizeof("<?php\r\n\treturn ") - 1);
smart_str_appendl(&content, "<?php"PHP_EOL"\treturn ", sizeof("<?php"PHP_EOL"\treturn ") - 1);
if(Z_TYPE_P(data) == IS_OBJECT){
HashTable *properties = Z_OBJ_HT_P(data)->get_properties(data TSRMLS_CC);
zval *zproperties;
Expand All @@ -155,7 +155,7 @@ static BUESSION_METHOD(config_simple, save){
}else{
php_var_export_ex(&data, 1, &content TSRMLS_CC);
}
smart_str_appendl(&content, ";\r\n?>", sizeof(";\r\n?>") - 1);
smart_str_appendl(&content, ";"PHP_EOL"?>", sizeof(";"PHP_EOL"?>") - 1);

smart_str_0(&content);
config_save_write(path, path_length, content);
Expand Down

0 comments on commit 9f5e4c6

Please sign in to comment.