#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 535 of file cmt_awk.cxx. 00537 { 00538 cmt_string line; 00539 00540 m_line_number = 0; 00541 m_condition = ok; 00542 00543 begin (); 00544 if (m_condition != ok) return (m_condition); 00545 00546 FILE* f = popen (command.c_str (), "r"); 00547 00548 if (f == 0) return (failed); 00549 00550 char buffer[256]; 00551 char* ptr; 00552 00553 while ((ptr = fgets (buffer, sizeof (buffer), f)) != NULL) 00554 { 00555 line = ptr; 00556 00557 line.replace ("\n", ""); 00558 00559 m_line_number++; 00560 00561 if (line != "") 00562 { 00563 if (expression.match (line)) 00564 { 00565 filter (line); 00566 if (m_condition != ok) return (m_condition); 00567 } 00568 } 00569 } 00570 00571 pclose (f); 00572 00573 end (); 00574 00575 return (m_condition); 00576 } |
|
Reimplemented from Awk. Definition at line 485 of file cmt_awk.cxx. 00487 { 00488 cmt_string line; 00489 00490 m_line_number = 0; 00491 m_condition = ok; 00492 00493 begin (); 00494 if (m_condition != ok) return (m_condition); 00495 00496 FILE* f = popen (command.c_str (), "r"); 00497 00498 if (f == 0) return (failed); 00499 00500 char buffer[8192]; 00501 char* ptr; 00502 00503 while ((ptr = fgets (buffer, sizeof (buffer), f)) != NULL) 00504 { 00505 line = ptr; 00506 00507 if (line.find ("\n") == cmt_string::npos) 00508 { 00509 cerr << "#CMT> Warning : Line too long and truncated in PAwk::run for command " << command << endl; 00510 } 00511 00512 line.replace ("\n", ""); 00513 00514 m_line_number++; 00515 00516 if (line != "") 00517 { 00518 if ((pattern == "") || 00519 (line.find (pattern) != cmt_string::npos)) 00520 { 00521 filter (line); 00522 if (m_condition != ok) return (m_condition); 00523 } 00524 } 00525 } 00526 00527 pclose (f); 00528 00529 end (); 00530 00531 return (m_condition); 00532 } |