#include <cmt_awk.h>
  Inheritance diagram for PAwk:
| Public Methods | |
| condition? | run (const cmt_string &command, const cmt_string &pattern="") | 
| condition? | run (const cmt_string &text, const cmt_regexp &expression) | 
| 
 | ||||||||||||
| ? | Reimplemented from Awk. Definition at line 540 of file cmt_awk.cxx. References Awk::begin(), cmt_string::c_str(), Awk::condition, Awk::end(), Awk::filter(), Awk::m_condition, Awk::m_line_number, cmt_regexp::match(), Awk::ok, and cmt_string::replace(). 00542 {
00543   cmt_string line;
00544 
00545   m_line_number = 0;
00546   m_condition = ok;
00547 
00548   begin ();
00549   if (m_condition != ok) return (m_condition);
00550 
00551   FILE* f = popen (command.c_str (), "r"); 
00552   
00553   if (f == 0) return (failed);
00554 
00555   char buffer[256]; 
00556   char* ptr;
00557 
00558   while ((ptr = fgets (buffer, sizeof (buffer), f)) != NULL) 
00559     {
00560       line = ptr;
00561 
00562       line.replace ("\n", "");
00563 
00564       m_line_number++;
00565 
00566       if (line != "")
00567         {
00568           if (expression.match (line))
00569             {
00570               filter (line);
00571               if (m_condition != ok) return (m_condition);
00572             }
00573         }
00574     }
00575 
00576   pclose (f);
00577 
00578   end ();
00579 
00580   return (m_condition);
00581 }
 | 
| 
 | ||||||||||||
| ? | Reimplemented from Awk. Definition at line 490 of file cmt_awk.cxx. References Awk::begin(), cmt_string::c_str(), Awk::condition, Awk::end(), Awk::filter(), cmt_string::find(), Awk::m_condition, Awk::m_line_number, cmt_string::npos, Awk::ok, and cmt_string::replace(). Referenced by Generator::build_windefs(). 00492 {
00493   cmt_string line;
00494 
00495   m_line_number = 0;
00496   m_condition = ok;
00497 
00498   begin ();
00499   if (m_condition != ok) return (m_condition);
00500 
00501   FILE* f = popen (command.c_str (), "r"); 
00502   
00503   if (f == 0) return (failed);
00504 
00505   char buffer[8192]; 
00506   char* ptr;
00507 
00508   while ((ptr = fgets (buffer, sizeof (buffer), f)) != NULL) 
00509     {
00510       line = ptr;
00511 
00512       if (line.find ("\n") == cmt_string::npos)
00513         {
00514           cerr << "#CMT> Warning: Line too long and truncated in PAwk::run for command " << command << endl;
00515         }
00516 
00517       line.replace ("\n", "");
00518 
00519       m_line_number++;
00520 
00521       if (line != "")
00522         {
00523           if ((pattern == "") ||
00524               (line.find (pattern) != cmt_string::npos))
00525             {
00526               filter (line);
00527               if (m_condition != ok) return (m_condition);
00528             }
00529         }
00530     }
00531 
00532   pclose (f);
00533 
00534   end ();
00535 
00536   return (m_condition);
00537 }
 |