📄 wordm1.c
字号:
exit(1);
}
#endif
for( p = 0; TestEntry < j-1; TestEntry++)
{
*((pTestBuf[i])+p) = *(pTotalBuf + TestEntry);
p++;
}
*((pTestBuf[i])+p) = '\0';
/*find out answer*/
AnswerEntry = j+1;
if(NextWordEntry >= AnswerEntry)
counter4 = NextWordEntry - AnswerEntry;
else
counter4 = 1;
#ifdef SIM_ON_PC
if((pAnswerBuf[i] = (char *)calloc(counter4,sizeof(char))) == NULL)
{
printf("In line 356 Allocation erro");
exit(1);
} /*add allocation check by xx 10/11/2004*/
#else
if((pAnswerBuf[i] = (char *)SysLmalloc(counter4)) == NULL)
{
printf("In line 362 Allocation erro");
exit(1);
}
#endif
for(q = 0;AnswerEntry < NextWordEntry - 1; AnswerEntry++)
{
*((pAnswerBuf[i])+q) = *(pTotalBuf + AnswerEntry);
q++;
}
*( (pAnswerBuf[i])+q ) = '\0';
WordCounter++;
}
}
return WordCounter;
break;
case 6:
NU_Get_First(&statobj, "b:\\6jy.txt");
filelength = statobj.fsize;
for(i = 0 ; i < 40 ; i ++ )
{
WordEntry = *(pWordEntry+40*(list - 1) + i);
NextWordEntry = *(pWordEntry+40*(list - 1) + i + 1);
if(NextWordEntry < filelength)
;
else
NextWordEntry = WordEntry;
WordEntry++; /* ignore the '#' */
if((40*(list-1)+ i) < Lev6.count)
{
for( j = WordEntry; (*(pTotalBuf + j) != 0xa); j++); //find the change line dot
if(j > WordEntry)
counter1 = j - WordEntry;
else
counter1 = 1;
#ifdef SIM_ON_PC
if((pWordBuf[i] = (char *)calloc(counter1,sizeof(char))) == NULL)
{
printf("In line 391 Allocation erro");
exit(1);
} /*add allocation check by xx 10/11/2004*/
#else
if((pWordBuf[i] = (char *)SysLmalloc(counter1)) == NULL)
{
printf("In line 397 Allocation erro");
exit(1);
}
#endif
for(m = 0; WordEntry < j - 1; WordEntry++)
{
*((pWordBuf[i])+m) = *(pTotalBuf + WordEntry);
m++;
}
*( (pWordBuf[i])+m ) = '\0';
ExpEntry = j;
//find exp
for(;(*(pTotalBuf + j) != 36)&&(j < NextWordEntry); j++);
if(j > ExpEntry)
counter2 = j - ExpEntry;
else
counter2 = 1;
#ifdef SIM_ON_PC
if((pExpBuf[i] = (char *)calloc(counter2,sizeof(char))) == NULL)
{
printf("In line 416 Allocation erro");
exit(1);
} /*add allocation check by xx 10/11/2004*/
#else
if((pExpBuf[i] = (char *)SysLmalloc(counter2)) == NULL)
{
printf("In line 422 Allocation erro");
exit(1);
}
#endif
for(n = 0; ExpEntry < j - 1; ExpEntry++)
{
*( (pExpBuf[i])+n ) = *(pTotalBuf + ExpEntry);
n++;
}
*( (pExpBuf[i])+n ) = '\0';
//find out test
TestEntry = j + 1;
for(;(*(pTotalBuf + j)) != 37&&(j < NextWordEntry); j++);
if(j > TestEntry)
counter3 = j - TestEntry;
else
counter3 = 1;
#ifdef SIM_ON_PC
if((pTestBuf[i] = (char *)calloc(counter3,sizeof(char))) == NULL)
{
printf("In line 445 Allocation erro");
exit(1);
} /*add allocation check by xx 10/11/2004*/
#else
if((pTestBuf[i] = (char *)SysLmalloc(counter3)) == NULL)
{
printf("In line 451 Allocation erro");
exit(1);
}
#endif
for( p = 0; TestEntry < j-1; TestEntry++)
{
*((pTestBuf[i])+p) = *(pTotalBuf + TestEntry);
p++;
}
*((pTestBuf[i])+p) = '\0';
/*find out answer*/
AnswerEntry = j+1;
if(NextWordEntry >= AnswerEntry)
counter4 = NextWordEntry - AnswerEntry;
else
counter4 = 1;
#ifdef SIM_ON_PC
if((pAnswerBuf[i] = (char *)calloc(counter4,sizeof(char))) == NULL)
{
printf("In line 471 Allocation erro");
exit(1);
} /*add allocation check by xx 10/11/2004*/
#else
if((pAnswerBuf[i] = (char *)SysLmalloc(counter4)) == NULL)
{
printf("In line 477 Allocation erro");
exit(1);
}
#endif
for(q = 0;AnswerEntry < NextWordEntry - 1; AnswerEntry++)
{
*((pAnswerBuf[i])+q) = *(pTotalBuf + AnswerEntry);
q++;
}
*( (pAnswerBuf[i])+q ) = '\0';
WordCounter++;
}
}
return WordCounter;
break;
case 10:
//fp = FAL_Open("b:\\master.txt", PO_RDWR|PO_CREAT, FAL_IWRITE|FAL_IREAD);
NU_Get_First(&statobj, "b:\\master.txt");
filelength = statobj.fsize;
// FAL_Fclose(fp, 0);
for(i = 0; ((i < 40)&&(40*(list-1)+ i < LevM.count)); i ++ )
{
WordEntry = *(pWordEntry+40*(list - 1) + i);
NextWordEntry = *(pWordEntry+40*(list - 1) + i + 1);
if(NextWordEntry < filelength)
;
else
NextWordEntry = WordEntry;
WordEntry++; /* ignore the '#' */
//if((40*(list-1)+ i) < LevM.count)
//{
for( j = WordEntry; (*(pTotalBuf + j) != 0xa); j++); //find the change line dot
if(j > WordEntry)
counter1 = j - WordEntry;
else
counter1 = 1;
#ifdef SIM_ON_PC
if((pWordBuf[i] = (char *)calloc(counter1,sizeof(char))) == NULL)
{
printf("In line 506 Allocation erro");
exit(1);
} /*add allocation check by xx 10/11/2004*/
#else
if((pWordBuf[i] = (char *)SysLmalloc(counter1)) == NULL)
{
printf("In line 512 Allocation erro");
exit(1);
}
#endif
for(m = 0; WordEntry < j - 1; WordEntry++)
{
*((pWordBuf[i])+m) = *(pTotalBuf + WordEntry);
m++;
}
*( (pWordBuf[i])+m ) = '\0';
ExpEntry = j;
//find exp
for(;(*(pTotalBuf + j) != 36)&&(j < NextWordEntry); j++);
if(j > ExpEntry)
counter2 = j - ExpEntry;
else
counter2 = 1;
#ifdef SIM_ON_PC
if((pExpBuf[i] = (char *)calloc(counter2,sizeof(char))) == NULL)
{
printf("In line 531 Allocation erro");
exit(1);
} /*add allocation check by xx 10/11/2004*/
#else
if((pExpBuf[i] = (char *)SysLmalloc(counter2)) == NULL)
{
printf("In line 537 Allocation erro");
exit(1);
}
#endif
for(n = 0; ExpEntry < j - 1; ExpEntry++)
{
*( (pExpBuf[i])+n ) = *(pTotalBuf + ExpEntry);
n++;
}
*( (pExpBuf[i])+n ) = '\0';
//find out test
TestEntry = j + 1;
for(;(*(pTotalBuf + j)) != 37&&(j < NextWordEntry); j++);
if(j > TestEntry)
counter3 = j - TestEntry;
else
counter3 = 1;
#ifdef SIM_ON_PC
if((pTestBuf[i] = (char *)calloc(counter3,sizeof(char))) == NULL)
{
printf("In line 560 Allocation erro");
exit(1);
} /*add allocation check by xx 10/11/2004*/
#else
if((pTestBuf[i] = (char *)SysLmalloc(counter3)) == NULL)
{
printf("In line 566 Allocation erro");
exit(1);
}
#endif
for( p = 0; TestEntry < j-1; TestEntry++)
{
*((pTestBuf[i])+p) = *(pTotalBuf + TestEntry);
p++;
}
*((pTestBuf[i])+p) = '\0';
/*find out answer*/
AnswerEntry = j + 1;
if(NextWordEntry >= AnswerEntry)
counter4 = NextWordEntry - AnswerEntry;
else
counter4 = 1;
#ifdef SIM_ON_PC
if((pAnswerBuf[i] = (char *)calloc(counter4,sizeof(char))) == NULL)
{
printf("In line 586 Allocation erro");
exit(1);
} /*add allocation check by xx 10/11/2004*/
#else
if((pAnswerBuf[i] = (char *)SysLmalloc(counter4)) == NULL)
{
printf("In line 592 Allocation erro");
exit(1);
}
#endif
for(q = 0;AnswerEntry < NextWordEntry - 1; AnswerEntry++)
{
*((pAnswerBuf[i])+q) = *(pTotalBuf + AnswerEntry);
q++;
}
*( (pAnswerBuf[i])+q ) = '\0';
WordCounter++;
//}
}
return WordCounter;
break;
default:
break;
}
}
void LowLevProc(int lev)
{
WordBuf(lev);
WordIndexInList(lev);
}
int RangeTest( int Wcounter )
{
int i,counter = 0,j;
for(i = 0;i < Wcounter - 1; i++)
{
if ( *(pTestBuf[i]) != '\0' )
{
#ifdef SIM_ON_PC
if((pTestModify[counter] = (char *)calloc((strlen(pTestBuf[i])+1),sizeof(char))) == NULL)
{
printf("line 631 Allocation erro\n");
exit(1);
}
if((pAnswerModify[counter] = (char *)calloc(strlen(pAnswerBuf[i])+1 , sizeof(char)))== NULL)
{
printf("line 636 in WordM1.c Allocation erro\n");
exit(1);
}
#else
if((pTestModify[counter] = (char *)SysLmalloc(strlen(pTestBuf[i])+1)) == NULL)
{
printf("line 642 Allocation erro\n");
exit(1);
}
if((pAnswerModify[counter] = (char *)SysLmalloc(strlen(pAnswerBuf[i])+1))== NULL)
{
printf("line 447 in WordM1.c Allocation erro\n");
exit(1);
}
#endif
/* strlen don't
* count '\0'
*/
*pTestModify[counter] = "";
*pAnswerModify[counter] = "";
strcpy(pTestModify[counter],pTestBuf[i]);
strcpy(pAnswerModify[counter],pAnswerBuf[i]);
counter++;
}
}
for(i = 0;i < Wcounter - 1; i++)
{
free(pTestBuf[i]);
free(pAnswerBuf[i]);
}
return counter;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -