#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 498 of file cmt_awk.cxx. 00500 { 00501 cmt_string line; 00502 00503 m_line_number = 0; 00504 m_condition = ok; 00505 00506 begin (); 00507 if (m_condition != ok) return (m_condition); 00508 00509 FILE* f = popen (command.c_str (), "r"); 00510 00511 if (f == 0) return (failed); 00512 00513 char buffer[256]; 00514 char* ptr; 00515 00516 while ((ptr = fgets (buffer, sizeof (buffer), f)) != NULL) 00517 { 00518 line = ptr; 00519 00520 line.replace ("\n", ""); 00521 00522 m_line_number++; 00523 00524 if (line != "") 00525 { 00526 if (expression.match (line)) 00527 { 00528 filter (line); 00529 if (m_condition != ok) return (m_condition); 00530 } 00531 } 00532 } 00533 00534 pclose (f); 00535 00536 end (); 00537 00538 return (m_condition); 00539 } |
|
Reimplemented from Awk. Definition at line 448 of file cmt_awk.cxx. 00450 { 00451 cmt_string line; 00452 00453 m_line_number = 0; 00454 m_condition = ok; 00455 00456 begin (); 00457 if (m_condition != ok) return (m_condition); 00458 00459 FILE* f = popen (command.c_str (), "r"); 00460 00461 if (f == 0) return (failed); 00462 00463 char buffer[8192]; 00464 char* ptr; 00465 00466 while ((ptr = fgets (buffer, sizeof (buffer), f)) != NULL) 00467 { 00468 line = ptr; 00469 00470 if (line.find ("\n") == cmt_string::npos) 00471 { 00472 cerr << "#CMT> Warning : Line too long and truncated in PAwk::run for command " << command << endl; 00473 } 00474 00475 line.replace ("\n", ""); 00476 00477 m_line_number++; 00478 00479 if (line != "") 00480 { 00481 if ((pattern == "") || 00482 (line.find (pattern) != cmt_string::npos)) 00483 { 00484 filter (line); 00485 if (m_condition != ok) return (m_condition); 00486 } 00487 } 00488 } 00489 00490 pclose (f); 00491 00492 end (); 00493 00494 return (m_condition); 00495 } |