forked from boostorg/regex
Updated most of the docs.
Updated the makefiles. Last few fixes to the core code. [SVN r23284]
This commit is contained in:
+41
-39
@@ -15,25 +15,27 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <boost/regex.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
#ifdef __BORLANDC__
|
||||
# pragma hrdstop
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_REGEX_V3
|
||||
#include <boost/regex/v3/fileiter.hpp>
|
||||
#else
|
||||
#include <boost/regex/v4/fileiter.hpp>
|
||||
#endif
|
||||
#include "jgrep.h"
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/regex/v4/fileiter.hpp>
|
||||
#include "jgrep.h"
|
||||
#ifndef BOOST_REGEX_NO_FILEITER
|
||||
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std{
|
||||
using ::strcpy;
|
||||
using ::strcat;
|
||||
using ::sprintf;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
re_type e;
|
||||
//rei_type ei(a);
|
||||
|
||||
// flags for output:
|
||||
|
||||
@@ -49,7 +51,7 @@ bool verbose = false;
|
||||
|
||||
void usage()
|
||||
{
|
||||
cout <<
|
||||
std::cout <<
|
||||
"jgrep version 0.95\n"
|
||||
"usage: jgrep [-options] expression file [files...]\n"
|
||||
"\n"
|
||||
@@ -68,7 +70,7 @@ void usage()
|
||||
"expression: a regular expression, or a literal string if -r- is specified\n"
|
||||
"\n"
|
||||
"files: one or more files to search, the names can contain the wildcard\n"
|
||||
" characters ? and *\n" << endl;
|
||||
" characters ? and *\n" << std::endl;
|
||||
|
||||
}
|
||||
|
||||
@@ -107,9 +109,9 @@ void parse_switch(const char* flag)
|
||||
verbose = false;
|
||||
break;
|
||||
default:
|
||||
cout << "Undefined option -";
|
||||
cout.put(*flag);
|
||||
cout << endl;
|
||||
std::cout << "Undefined option -";
|
||||
std::cout.put(*flag);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
// turn off prev character:
|
||||
break;
|
||||
@@ -143,9 +145,9 @@ void parse_switch(const char* flag)
|
||||
case '+':
|
||||
break;
|
||||
default:
|
||||
cout << "Undefined option -";
|
||||
cout.put(*flag);
|
||||
cout << endl;
|
||||
std::cout << "Undefined option -";
|
||||
std::cout.put(*flag);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
++flag;
|
||||
}
|
||||
@@ -163,18 +165,18 @@ void HandleFile(const char* wild)
|
||||
{
|
||||
// go through sub directories:
|
||||
char buf[MAX_PATH];
|
||||
strcpy(buf, start.root());
|
||||
std::strcpy(buf, start.root());
|
||||
int rootlen = strlen(buf);
|
||||
if(*buf == 0)
|
||||
{
|
||||
strcpy(buf, ".");
|
||||
strcat(buf, directory_iterator::separator());
|
||||
strcat(buf, "*");
|
||||
std::strcpy(buf, ".");
|
||||
std::strcat(buf, directory_iterator::separator());
|
||||
std::strcat(buf, "*");
|
||||
}
|
||||
else
|
||||
{
|
||||
strcat(buf, directory_iterator::separator());
|
||||
strcat(buf, "*");
|
||||
std::strcat(buf, directory_iterator::separator());
|
||||
std::strcat(buf, "*");
|
||||
}
|
||||
directory_iterator dstart(buf);
|
||||
directory_iterator dend;
|
||||
@@ -185,12 +187,12 @@ void HandleFile(const char* wild)
|
||||
|
||||
while(dstart != dend)
|
||||
{
|
||||
sprintf(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
std::sprintf(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr);
|
||||
HandleFile(buf);
|
||||
++dstart;
|
||||
}
|
||||
}
|
||||
for_each(start, end, process_grep);
|
||||
std::for_each(start, end, process_grep);
|
||||
}
|
||||
|
||||
int done = 0;
|
||||
@@ -215,8 +217,8 @@ void HandleArg(const char* arg)
|
||||
}
|
||||
else
|
||||
{
|
||||
char* buf = new char[strlen(arg) + 8];
|
||||
sprintf(buf, "\\<%s\\>", arg);
|
||||
char* buf = new char[std::strlen(arg) + 8];
|
||||
std::sprintf(buf, "\\<%s\\>", arg);
|
||||
e.set_expression(buf, use_case ? regex::normal : regbase::normal | regbase::icase);
|
||||
//ei.set_expression(buf);
|
||||
delete[] buf;
|
||||
@@ -225,20 +227,20 @@ void HandleArg(const char* arg)
|
||||
else
|
||||
{
|
||||
// we need to convert text to literal:
|
||||
int len2 = strlen(arg);
|
||||
int len2 = std::strlen(arg);
|
||||
int len = len2 * 5 + 6;
|
||||
char buf[8];
|
||||
char* buf2 = new char[len];
|
||||
*buf2 = 0;
|
||||
if(words_only)
|
||||
strcpy(buf2, "\\<");
|
||||
std::strcpy(buf2, "\\<");
|
||||
for(int j = 0; j < len2; ++j)
|
||||
{
|
||||
sprintf(buf, "\\0%o", int(arg[j]));
|
||||
strcat(buf2, buf);
|
||||
std::sprintf(buf, "\\0%o", int(arg[j]));
|
||||
std::strcat(buf2, buf);
|
||||
}
|
||||
if(words_only)
|
||||
strcat(buf2, "\\>");
|
||||
std::strcat(buf2, "\\>");
|
||||
e.set_expression(buf2, use_case ? regex::normal : regbase::normal | regbase::icase);
|
||||
//ei.set_expression(buf2);
|
||||
delete[] buf2;
|
||||
@@ -266,7 +268,7 @@ int main(int argc, char * argv[])
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
cout <<
|
||||
std::std::cout <<
|
||||
"\n<note>\n"
|
||||
"This functionality is not available on with this compiler on this platform.\n"
|
||||
"</note>\n";
|
||||
|
||||
Reference in New Issue
Block a user