pos软件中的一个bug,求指正
if (__isConnected()){
snprintf(buffer,sizeof(buffer), "%s\t%s\t%s%c", GET_ItemInfo_PD, itemcheck.pd_batchNo, pd_itemNo, SOCK_END_CHAR);
if (socket_comm(buffer, sizeof(buffer), 2) > 0)
{
if (strlen(buffer)>CMD_LENGTH && !strncmp(buffer,GET_ItemInfo_PD,CMD_LENGTH - 1)
&& buffer[CMD_LENGTH-1] == '\t') //商品存在
{
chrpos = buffer + CMD_LENGTH;
if (*chrpos)
{
//1.
p = chrpos; chrpos = strchr(p, '\t');
if (chrpos == 0) goto label_for_get_pditem_info;
*chrpos++ = '\0';
snprintf(newRow->ItemNo, LEN_ITEMNO, "%s", p); //货号
//2.
p = chrpos; chrpos = strchr(p, '\t');
if (chrpos == 0) goto label_for_get_pditem_info;
*chrpos++ = '\0';
snprintf(newRow->ItemName, LEN_ITEMNAME, "%s", p); //品名
//3
p = chrpos; chrpos = strchr(p, '\t');
if (chrpos == 0) goto label_for_get_pditem_info;
*chrpos++ = '\0';
snprintf(newRow->ItemUnit, LEN_ITEMUNIT, "%s", p); //单位
//4.
newRow->SalePrice = atof(chrpos); //售价
}
return newRow;
}
else //商品不存在时处理,提示商品不存在并返回
{
free(newRow);
if (1)
{
int i = 0;
char tmpText[80 + LEN_ITEMNO], *c;
#ifdef __Language_Debug
readLanguage("PD_item_not_found", tmpText, 80);
#else
if (!readLanguage("PD_item_not_found", tmpText, 80)
sprintf(tmpText, "货号为 \\d 的商品不存在或者不在当前盘点范围内!");
#endif
c = strstr(tmpText, "\\d");
if (c != 0){
*c = ' '; *(c+1) = ' ';
stringAlign(c, strlen(c) + strlen(pd_itemNo) - 2, 2);
while (pd_itemNo[i] != '\0') *c++ = pd_itemNo[i++];
}
__beep();
while(2 != dlg_YesCancel((fb_screen->width-40*FONT_WIDTH)/2, (fb_screen->height-(FONT_HEIGHT+4)*7)/2,
40*FONT_WIDTH, (FONT_HEIGHT+4)*7, tmpText))
{
__beep();
}
}
#ifndef __ScreenAutoBak
redrawPdItemData(); //刷新显示
#endif
return (struct RowItemPD *)NULL;
}
}
如果输入正确ItemNo(商品号),则正常返回货号+品名+单位+售价。如果输入为1-19字符长的错误ItemNo(商品号),则会正常报错,第二次输入仍正常。但如果我输入过字符长为20的ItemNo(商品号),以后再输任何字符长的ItemNo,即便是正确的,程序都会自动从else后开始运行并报错。
求高手解答,在线等!