Ejemplo n.º 1
0
void CBlokRtf::GetLStr(int iBlk, CString strFnd, CFile &inF, int &curPos, CString &strOut)
{
//Считывает строку по подстроке
//указатель устанавливается перед подстрокой
// копит строку strOut
//ничего НЕ пишет

	CString strBuf,strTg,s;
	strTg = _T("");
	int tPos;//=0;				// Позиция в strBuf
	int iCnt = 0;
	bool bEnd=true;
	strBuf = GetStrBuf(iBlk,inF,curPos,bEnd);
//		AfxMessageBox("strBuf = \n"+strBuf);
	if(!bEnd){
//		AfxMessageBox("False");
		return;
	}
//AfxMessageBox("Исх строка\n"+strBuf+'\n'+"Подстрока\n"+strFnd);
//-------------------------------Ищу вхождение  подстроки
	if((tPos = strBuf.Find(strFnd))!=-1){
		strTg = strBuf.Left(tPos);
		iCnt = strTg.GetLength(); //tPos;
		int iDlt=0;
		iDlt = GetLnFd(strTg,iCnt);	//подсчёт симв.переноса строк
		strOut+=strTg;
//		strTg.Replace('\n','~');
//		s.Format(" Нашёл GetLStr пред curPos = %i iCnt = %i, iDlt = %i",curPos,iCnt,iDlt);
//AfxMessageBox("Нашёл в GetLStr \n"+s+'\n'+"strTg = "+strTg+'\n'+"strFnd = "+strFnd);
		curPos+= (iCnt+iDlt);				// Получаю новую curPos	
		inF.Seek(curPos,CFile::begin); // поставил указатель ЗА
//		s.Format("Новая поз после поиска curPos = %i",curPos);
//AfxMessageBox(s);
//		curPos = inF.GetPosition();
		return;
	}
	else{						// Не нашёл, можно читать дальше
//		AfxMessageBox("накопление\n"+strOut);
		strOut+=strBuf;
		curPos+=iBlk;
		inF.Seek(curPos,CFile::begin);	// Переместил
//		s.Format("После буфера curPos = %i",curPos);
//		AfxMessageBox("Не нашёл GetLStr\n"+strBuf+'\n'+s);
//		curPos = inF.GetPosition();
		GetLStr(iBlk,strFnd,inF,curPos,strOut);
		return;
	}

}
Ejemplo n.º 2
0
Archivo: rcl.c Proyecto: mingpen/OpenNT
int     GetToken(int fReportError)
{
    for (; ; )  {
        /* skip whitespace */
        while (iswhite( curChar))
            OurGetChar();

        /* take care of 'random' symbols use */
        if (curChar == SYMUSESTART)
            GetSymbol(fReportError, curChar);
        token.sym.name[0] = L'\0';

        /* remember location of token */
        token.row = curLin;
        token.col = curCol;

        /* determine if token is EOF, number, string, or keyword */
        token.type = EOFMARK;
        switch (curChar) {
        case EOFMARK:
            break;

        case SGNCHAR:
        case L'~':
            if (fReportError & TOKEN_NOEXPRESSION)
                GetNumNoExpression();
            else
                GetNum();
            break;

        case STRCHAR:
            GetStr();
            break;

        default:
            if (curChar == L'(' && !(fReportError & TOKEN_NOEXPRESSION))
                GetNum();
            else if (iswdigit( curChar)) {
                if (fReportError & TOKEN_NOEXPRESSION)
                    GetNumNoExpression();
                else
                    GetNum();

                if (curChar == SYMUSESTART)
                    GetSymbol(fReportError, curChar);
            }
            else {
                if (!GetKwd( fReportError))
                    continue;
                if (token.type == TKLSTR) {
                    GetLStr();
                    break;
                }
            }
        }

        break;
    }

    return token.type;
}