moriyoshi Thu Jan 16 15:59:08 2003 EDT Modified files: /php4/ext/standard filters.c Log: Finally fixed a qp encoder bug that line break characters that appear exactly at the end of the chunk lost in the output. # I bet no more problems will occur in quoted-printable encoder. # But I recognised the counterpart is still buggy due to RFC2045-incompliance. Index: php4/ext/standard/filters.c diff -u php4/ext/standard/filters.c:1.19 php4/ext/standard/filters.c:1.20 --- php4/ext/standard/filters.c:1.19 Wed Jan 15 10:05:17 2003 +++ php4/ext/standard/filters.c Thu Jan 16 15:59:07 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filters.c,v 1.19 2003/01/15 15:05:17 moriyoshi Exp $ */ +/* $Id: filters.c,v 1.20 2003/01/16 20:59:07 moriyoshi Exp $ */ #include "php.h" #include "php_globals.h" @@ -680,11 +680,11 @@ } #define NEXT_CHAR(ps, icnt, lb_ptr, lb_cnt, lbchars) \ - ((lb_cnt) < (lb_ptr) ? (lbchars)[(lb_cnt)] : *(ps)) + ((lb_ptr) < (lb_cnt) ? (lbchars)[(lb_ptr)] : *(ps)) #define CONSUME_CHAR(ps, icnt, lb_ptr, lb_cnt) \ - if ((lb_cnt) < (lb_ptr)) { \ - (lb_cnt)++; \ + if ((lb_ptr) < (lb_cnt)) { \ + (lb_ptr)++; \ } else { \ (lb_cnt) = (lb_ptr) = 0; \ --(icnt); \ @@ -703,7 +703,12 @@ int opts; static char qp_digits[] = "0123456789ABCDEF"; - if (in_pp == NULL || in_left_p == NULL) { + line_ccnt = inst->line_ccnt; + opts = inst->opts; + lb_ptr = inst->lb_ptr; + lb_cnt = inst->lb_cnt; + + if ((in_pp == NULL || in_left_p == NULL) && (lb_ptr >=lb_cnt)) { return PHP_CONV_ERR_SUCCESS; } @@ -711,19 +716,13 @@ icnt = *in_left_p; pd = (unsigned char *)(*out_pp); ocnt = *out_left_p; - line_ccnt = inst->line_ccnt; - opts = inst->opts; - lb_ptr = inst->lb_ptr; - lb_cnt = inst->lb_cnt; - while (icnt > 0) { + for (;;) { if (!(opts & PHP_CONV_QPRINT_OPT_BINARY) && inst->lbchars != NULL && inst->lbchars_len > 0) { /* look ahead for the line break chars to make a right decision * how to consume incoming characters */ - if (*ps == inst->lbchars[lb_cnt]) { - ps++; - icnt--; + if (icnt > 0 && *ps == inst->lbchars[lb_cnt]) { lb_cnt++; if (lb_cnt >= inst->lbchars_len) { @@ -742,9 +741,14 @@ line_ccnt = inst->line_len; lb_ptr = lb_cnt = 0; } + ps++, icnt--; continue; } } + + if (lb_ptr >= lb_cnt && icnt <= 0) { + break; + } c = NEXT_CHAR(ps, icnt, lb_ptr, lb_cnt, inst->lbchars);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php