Tsukada
ttsuk****@users*****
2002年 5月 26日 (日) 01:10:51 JST
ttsukada 02/05/26 01:10:50 Modified: ext/mbstring buffer.c Log: improve error hanling Revision Changes Path 1.4 +26 -26 php4/ext/mbstring/buffer.c Index: buffer.c =================================================================== RCS file: /cvsroot/php-i18n/php4/ext/mbstring/buffer.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- buffer.c 22 May 2002 20:12:35 -0000 1.3 +++ buffer.c 25 May 2002 16:10:50 -0000 1.4 @@ -35,7 +35,7 @@ buffer->memory_type_self = PHP_MB_MEMORY_TYPE_DALLOC; } } else { - MBSTRG(last_errno) = PHP_MB_ERR_NO_MEMORY; + PHP_MB_ERRSET(PHP_MB_ERR_NO_MEMORY); } return buffer; @@ -100,7 +100,7 @@ int *tmp; if (buffer->memory_type_value == PHP_MB_MEMORY_TYPE_CONST) { - MBSTRG(last_errno) = PHP_MB_ERR_BUFFER_OVER_FLOW; + PHP_MB_ERRSET(PHP_MB_ERR_BUFFER_OVER_FLOW); return FAILURE; } newsize = buffer->size + buffer->realloc; @@ -111,7 +111,7 @@ tmp = erealloc(buffer->value, newsize*sizeof(int)); } if (tmp == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NO_MEMORY; + PHP_MB_ERRSET(PHP_MB_ERR_NO_MEMORY); return FAILURE; } buffer->size = newsize; @@ -128,18 +128,18 @@ int n, *w; if (dst == NULL || src == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NULL_POINTER; + PHP_MB_ERRSET(PHP_MB_ERR_NULL_POINTER); return FAILURE; } if (length < 0) { - MBSTRG(last_errno) = PHP_MB_ERR_ILLEGAL_ARGUMENT; + PHP_MB_ERRSET(PHP_MB_ERR_ILLEGAL_ARGUMENT); return FAILURE; } if ((dst->length + length) >= dst->size) { /* reallocate buffer */ if (dst->memory_type_value == PHP_MB_MEMORY_TYPE_CONST) { - MBSTRG(last_errno) = PHP_MB_ERR_BUFFER_OVER_FLOW; + PHP_MB_ERRSET(PHP_MB_ERR_BUFFER_OVER_FLOW); return FAILURE; } n = dst->length + length + PHP_MB_BUF_ALLOC_SIZE; @@ -150,7 +150,7 @@ w = erealloc(dst->value, n*sizeof(int)); } if (w == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NO_MEMORY; + PHP_MB_ERRSET(PHP_MB_ERR_NO_MEMORY); return FAILURE; } dst->size = n; @@ -172,7 +172,7 @@ _php_mb_buf_concat(php_mb_buf *dst, php_mb_buf *src TSRMLS_DC) { if (dst == NULL || src == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NULL_POINTER; + PHP_MB_ERRSET(PHP_MB_ERR_NULL_POINTER); return FAILURE; } return php_mb_buf_append_wstr(dst, src->value, src->length); @@ -184,18 +184,18 @@ int len, *p, *w; if (dst == NULL || src == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NULL_POINTER; + PHP_MB_ERRSET(PHP_MB_ERR_NULL_POINTER); return FAILURE; } if (offset < 0 || offset > dst->length) { - MBSTRG(last_errno) = PHP_MB_ERR_INDEX_OUT_OF_BOUNDS; + PHP_MB_ERRSET(PHP_MB_ERR_INDEX_OUT_OF_BOUNDS); return FAILURE; } if ((dst->length + src->length) >= dst->size) { /* reallocate buffer */ if (dst->memory_type_value == PHP_MB_MEMORY_TYPE_CONST) { - MBSTRG(last_errno) = PHP_MB_ERR_BUFFER_OVER_FLOW; + PHP_MB_ERRSET(PHP_MB_ERR_BUFFER_OVER_FLOW); return FAILURE; } len = dst->length + src->length + PHP_MB_BUF_ALLOC_SIZE; @@ -206,7 +206,7 @@ p = erealloc(dst->value, len*sizeof(int)); } if (p == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NO_MEMORY; + PHP_MB_ERRSET(PHP_MB_ERR_NO_MEMORY); return FAILURE; } dst->size = len; @@ -242,11 +242,11 @@ int len, *p, *w; if (buffer == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NULL_POINTER; + PHP_MB_ERRSET(PHP_MB_ERR_NULL_POINTER); return FAILURE; } if (start < 0 || start > buffer->length || start > end) { - MBSTRG(last_errno) = PHP_MB_ERR_INDEX_OUT_OF_BOUNDS; + PHP_MB_ERRSET(PHP_MB_ERR_INDEX_OUT_OF_BOUNDS); return FAILURE; } if (start == end) { @@ -278,11 +278,11 @@ int len, *p, *w; if (dst == NULL || src == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NULL_POINTER; + PHP_MB_ERRSET(PHP_MB_ERR_NULL_POINTER); return FAILURE; } if (start < 0 || start > dst->length || start > end) { - MBSTRG(last_errno) = PHP_MB_ERR_INDEX_OUT_OF_BOUNDS; + PHP_MB_ERRSET(PHP_MB_ERR_INDEX_OUT_OF_BOUNDS); return FAILURE; } if (end > dst->length) { @@ -293,7 +293,7 @@ if ((dst->length - len + src->length) >= dst->size) { /* reallocate buffer */ if (dst->memory_type_value == PHP_MB_MEMORY_TYPE_CONST) { - MBSTRG(last_errno) = PHP_MB_ERR_BUFFER_OVER_FLOW; + PHP_MB_ERRSET(PHP_MB_ERR_BUFFER_OVER_FLOW); return FAILURE; } len = dst->length - len + src->length + PHP_MB_BUF_ALLOC_SIZE; @@ -304,7 +304,7 @@ p = erealloc(dst->value, len*sizeof(int)); } if (p == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NO_MEMORY; + PHP_MB_ERRSET(PHP_MB_ERR_NO_MEMORY); return FAILURE; } dst->size = len; @@ -352,11 +352,11 @@ int n, tmp, *p1, *p2; if (buffer == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NULL_POINTER; + PHP_MB_ERRSET(PHP_MB_ERR_NULL_POINTER); return FAILURE; } if (start < 0 || start > buffer->length || start > end) { - MBSTRG(last_errno) = PHP_MB_ERR_INDEX_OUT_OF_BOUNDS; + PHP_MB_ERRSET(PHP_MB_ERR_INDEX_OUT_OF_BOUNDS); return FAILURE; } if (end > buffer->length) { @@ -382,11 +382,11 @@ _php_mb_buf_setchar_at(php_mb_buf *buffer, int index, int c TSRMLS_DC) { if (buffer == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NULL_POINTER; + PHP_MB_ERRSET(PHP_MB_ERR_NULL_POINTER); return FAILURE; } if (index < 0 || index >= buffer->length) { - MBSTRG(last_errno) = PHP_MB_ERR_INDEX_OUT_OF_BOUNDS; + PHP_MB_ERRSET(PHP_MB_ERR_INDEX_OUT_OF_BOUNDS); return FAILURE; } buffer->value[index] = c; @@ -402,7 +402,7 @@ int *tmp; if (buffer->memory_type_value == PHP_MB_MEMORY_TYPE_CONST) { - MBSTRG(last_errno) = PHP_MB_ERR_BUFFER_OVER_FLOW; + PHP_MB_ERRSET(PHP_MB_ERR_BUFFER_OVER_FLOW); if (buffer->value != NULL) { buffer->value[buffer->size - 1] = 0; } @@ -416,7 +416,7 @@ tmp = erealloc(buffer->value, newsize*sizeof(int)); } if (tmp == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NO_MEMORY; + PHP_MB_ERRSET(PHP_MB_ERR_NO_MEMORY); if (buffer->value != NULL) { buffer->value[buffer->size - 1] = 0; } @@ -443,7 +443,7 @@ PHP_MB_BUF_TSRMLS_FETCH(buffer); if (buffer->memory_type_value == PHP_MB_MEMORY_TYPE_CONST) { - MBSTRG(last_errno) = PHP_MB_ERR_BUFFER_OVER_FLOW; + PHP_MB_ERRSET(PHP_MB_ERR_BUFFER_OVER_FLOW); return -1; } newsize = buffer->size + buffer->realloc; @@ -454,7 +454,7 @@ tmp = erealloc(buffer->value, newsize*sizeof(int)); } if (tmp == NULL) { - MBSTRG(last_errno) = PHP_MB_ERR_NO_MEMORY; + PHP_MB_ERRSET(PHP_MB_ERR_NO_MEMORY); return -1; } buffer->size = newsize;