Ignore:
Timestamp:
Apr 3, 2012, 3:54:50 PM (12 years ago)
Author:
rybkin
Message:

See C.L. 482

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/source/cmt_awk.cxx

    r569 r607  
    4040
    4141    cmt_string line;
     42    /*
    4243    int pos;
    4344    int max_pos;
     
    4546    pos = 0;
    4647    max_pos = text.size ();
    47 
     48    */
    4849    m_accumulator.erase (0);
    4950
     51    int nl;
     52    int begin = 0;
     53    int end = text.size ();
     54   
     55    while ((nl = text.find (begin, '\n')) != cmt_string::npos)
     56      {
     57        if (begin < nl && text[nl - 1] == '\r')
     58          {
     59            text.substr (begin, nl - 1 - begin, line);
     60          }
     61        else
     62          {
     63            text.substr (begin, nl - begin, line);
     64          }
     65        //      cerr << "|Awk::condition parse> [" << line << "]" << endl;
     66        begin = nl + 1;
     67        if (m_awk != 0) m_awk->inc_line_number ();
     68
     69        result = parse_line (line);
     70        if (result != Awk::ok) return result;
     71      } // while ((nl = text.find (begin, '\n')) != cmt_string::npos)
     72   
     73    if (begin < end)
     74      {
     75        text.substr (begin, end - begin, line);
     76        if (m_awk != 0) m_awk->inc_line_number ();
     77       
     78        result = parse_line (line);
     79      }
     80   
     81    /*
    5082    for (pos = 0; pos < max_pos;)
    5183      {
     
    90122        if (result != Awk::ok) break;
    91123      }
    92 
     124    */
    93125    return (result);
    94126  }
     
    232264  if (m_condition != ok) return (m_condition);
    233265
    234   if (CmtSystem::testenv ("CMTTESTAWK"))
     266  if (Cmt::get_debug () &&
     267      CmtSystem::testenv ("CMTTESTAWK"))
    235268    {
    236269      Parser p (this, pattern, 0);
     
    242275    {
    243276      cmt_string line;
     277      int nl;
     278      int begin = 0;
     279      int end = text.size ();
     280     
     281      while ((nl = text.find (begin, '\n')) != cmt_string::npos)
     282        {
     283          if (begin < nl && text[nl - 1] == '\r')
     284            {
     285              text.substr (begin, nl - 1 - begin, line);
     286            }
     287          else
     288            {
     289              text.substr (begin, nl - begin, line);
     290            }
     291          //      cerr << "|Awk::condition run> [" << line << "]" << endl;
     292          begin = nl + 1;
     293          m_line_number++;
     294         
     295          if (line != "")
     296            {
     297              if ((pattern == "") ||
     298                  (line.find (pattern) != cmt_string::npos))
     299                {
     300                  filter (line);
     301                  if (m_condition != ok) return (m_condition);
     302                }
     303            }
     304        } // while ((nl = text.find (begin, '\n')) != cmt_string::npos)
     305     
     306      if (begin < end)
     307        {
     308          text.substr (begin, end - begin, line);
     309          m_line_number++;
     310         
     311          if (line != "")
     312            {
     313              if ((pattern == "") ||
     314                  (line.find (pattern) != cmt_string::npos))
     315                {
     316                  filter (line);
     317                  if (m_condition != ok) return (m_condition);
     318                }
     319            }
     320        }
     321      /*
    244322      int pos = 0;
    245323      int max_pos;
     
    315393            }
    316394        }
     395      */
    317396    }
    318397
Note: See TracChangeset for help on using the changeset viewer.