cvs: php4 /ext/standard pack.c

From: Date: Sun, 10 Sep 2000 13:47:51 +0000
Subject: cvs: php4 /ext/standard pack.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-1684@lists.php.net to get a copy of this message
stas Sun Sep 10 06:47:51 2000 EDT Modified files: /php4/ext/standard pack.c Log: Make unpack("H") work like in Perl Index: php4/ext/standard/pack.c diff -u php4/ext/standard/pack.c:1.25 php4/ext/standard/pack.c:1.26 --- php4/ext/standard/pack.c:1.25 Sun Sep 10 06:34:03 2000 +++ php4/ext/standard/pack.c Sun Sep 10 06:47:51 2000 @@ -15,7 +15,7 @@ | Authors: Chris Schneider <cschneid@relog.ch> | +----------------------------------------------------------------------+ */ -/* $Id: pack.c,v 1.25 2000/09/10 13:34:03 stas Exp $ */ +/* $Id: pack.c,v 1.26 2000/09/10 13:47:51 stas Exp $ */ #include "php.h" @@ -551,12 +551,18 @@ break; } - case 'a': case 'A': case 'h': case 'H': { + case 'a': case 'A': { size = arg; arg = 1; break; } + case 'h': case 'H': { + size = arg/2; + arg = 1; + break; + } + /* Use 1 byte of input */ case 'c': case 'C': case 'x': { size = 1; @@ -638,11 +644,10 @@ int ipos, opos; /* If size was given take minimum of len and size */ - if ((size >= 0) && (len > size)) { - len = size; - } - - size = (len + 1) / 2; + if ((size >= 0) && (len > size*2)) { + len = size*2; + } + buf = emalloc(len + 1); for (ipos = opos = 0; opos < len; opos++) {

« previous php.cvs (#1684) next »