提交 4f694da1 编写于 作者: 饶先宏's avatar 饶先宏

202105271557

上级 77987d73
......@@ -180,12 +180,14 @@ static int bigint_bn_SetWidth(HOBJECT object, int width, int signexpand)
pobj->buf = buf;
}
blen = pobj->width / CELL_WIDTH;
bc = pobj->width & (CELL_WIDTH-1);
if (sign)
pobj->buf[blen] |= CELL_MASK << bc;
else
pobj->buf[blen] &= CELL_MASK >> (CELL_WIDTH - bc);
blen = width / CELL_WIDTH;
if (blen < pobj->buflen) {
bc = width & (CELL_WIDTH - 1);
if (sign)
pobj->buf[blen] |= CELL_MASK << bc;
else
pobj->buf[blen] &= CELL_MASK >> (CELL_WIDTH - bc);
}
for (i = blen+1; i < pobj->buflen; i++) {
pobj->buf[i] = sign ? CELL_MASK : 0;
}
......@@ -393,7 +395,8 @@ static int bigint_bn_AssignStr(HOBJECT object, const char* str, const char **nst
objwidth = pobj->width;
if (autowidth == 0 && objwidth <= 0)
return -1;
bigint_bn_SetWidth(object, 64, 0);
if (autowidth)
bigint_bn_SetWidth(object, 64, 0);
state = TOKEN_INITIAL;
sign = 0;
while (*strt != 0) {
......@@ -494,8 +497,8 @@ static int bigint_bn_AssignStr(HOBJECT object, const char* str, const char **nst
return -1;
}
}
bigint_bn_MulUint32(object, object, 2);
bigint_bn_AddUint32(object, object, ch - '0');
bigint_bn_MulInt32(object, object, 2);
bigint_bn_AddInt32(object, object, ch - '0');
numvalid = 1;
}
else if (ch == '_') {
......@@ -517,8 +520,8 @@ static int bigint_bn_AssignStr(HOBJECT object, const char* str, const char **nst
return -1;
}
}
bigint_bn_MulUint32(object, object, 8);
bigint_bn_AddUint32(object, object, ch - '0');
bigint_bn_MulInt32(object, object, 8);
bigint_bn_AddInt32(object, object, ch - '0');
numvalid = 1;
}
else if (ch == '_') {
......@@ -540,8 +543,8 @@ static int bigint_bn_AssignStr(HOBJECT object, const char* str, const char **nst
return -1;
}
}
bigint_bn_MulUint32(object, object, 10);
bigint_bn_AddUint32(object, object, ch - '0');
bigint_bn_MulInt32(object, object, 10);
bigint_bn_AddInt32(object, object, ch - '0');
numvalid = 1;
}
else {
......@@ -562,13 +565,13 @@ static int bigint_bn_AssignStr(HOBJECT object, const char* str, const char **nst
return -1;
}
}
bigint_bn_MulUint32(object, object, 16);
bigint_bn_MulInt32(object, object, 16);
if (ch > '0' && ch <= '9')
bigint_bn_AddUint32(object, object, ch - '0');
bigint_bn_AddInt32(object, object, ch - '0');
else if (ch >= 'a' && ch <= 'f')
bigint_bn_AddUint32(object, object, ch - 'a' + 10);
bigint_bn_AddInt32(object, object, ch - 'a' + 10);
else if (ch >= 'A' && ch <= 'F')
bigint_bn_AddUint32(object, object, ch - 'A' + 10);
bigint_bn_AddInt32(object, object, ch - 'A' + 10);
}
else if (ch == '_') {
}
......@@ -601,7 +604,7 @@ lastnum:
width++;
}
else {
width = pobj->width;
width = objwidth;
}
bigint_bn_SetWidth(object, width, sign);
return 0;
......@@ -796,7 +799,7 @@ static int bigint_bn_SubUint32(HOBJECT object, HOBJECT src, unsigned int value)
{
bigint_bn_AssignUint32(object, value);
bigint_bn_Neg(object, object);
bigint_bn_AddUint32(object, object, src);
bigint_bn_AddU(object, object, src);
return 0;
}
......
......@@ -114,11 +114,12 @@ static int hdl4se_constCreate(const PARAMITEM* pParams, int paramcount, HOBJECT*
if (0 == objectCall3(temp, AssignStr, (const char*)pParams[i].pvalue, &nstr, 0)) {
objectCall1(temp, GetInt32, &pobj->width);
}
if (pobj->width <= 0 || pobj->width > (1 << 24))
objectRelease(temp);
if (pobj->width <= 0 || pobj->width > (1 << 24)) {
return -1;
}
pobj->out_data = bigintegerCreate(pobj->width);
objectCall3(pobj->out_data, AssignStr, nstr, NULL, 0);
objectRelease(temp);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册