示例#1
0
文件: html.c 项目: eldar/ldc
void Html::scanCDATA()
{
    while(*p && *p != 0x1A)
    {
        int lineSepLength = isLineSeparator(p);
        if (lineSepLength>0)
        {
            /* Always extract new lines, so that D lexer counts the lines
             * right.
             */
            linnum++;
            dbuf->writeUTF8('\n');
            p += lineSepLength;
            continue;
        }
        else if (p[0] == ']' && p[1] == ']' && p[2] == '>')
        {
            /* end of CDATA section */
            p += 3;
            return;
        }
        else if (inCode)
        {
            /* this CDATA section contains D code */
            dbuf->writeByte(*p);
        }

        p++;
    }
}
示例#2
0
  StringPiece operator[](size_t i) const {
    int mini = mvc.psum(i);
    int maxi = mvc.psum(i+1);
    int len = 0;
    if(mini == -1 || maxi == -1) return std::string();

    for(; maxi >= mini; maxi--){
      if(!isLineSeparator(mv[maxi]))
        break;
    }
    len = std::max(0,maxi-mini-1);
    return StringPiece(mv.at_ptr(mini),len);
  }
示例#3
0
 static bool make_index(const char *infile, const char *outfile){
   MMapVector<char> mv(infile);
   size_t siz = mv.size();
   std::vector<int> offset;
   bool flg = false;
   for(size_t i = 0; i < siz; i++){
     if(isLineSeparator(mv[i])){
       flg = true;
     }else if(flg){
       offset.push_back(i-1);
       flg =false;
     }
   }
   offset.push_back(siz-1);
   mv.release();
   VerticalCode vc(offset);
   std::ofstream ofs(outfile);
   if(!ofs) return false;
   bool res = vc.save(ofs);
   ofs.close();
   if(!ofs) return false;
   return res;
 }