diff --git a/README.md b/README.md index 3a5423d3..16410a99 100644 --- a/README.md +++ b/README.md @@ -1491,7 +1491,7 @@ Man page - ugrep 1.3.2 July 25, 2019 UGREP(1) + ugrep 1.3.3 July 26, 2019 UGREP(1) diff --git a/bin/linux/ugrep b/bin/linux/ugrep index 0f688f3d..83157574 100755 Binary files a/bin/linux/ugrep and b/bin/linux/ugrep differ diff --git a/bin/macosx/ugrep b/bin/macosx/ugrep index edfb8d33..7c8b63b0 100755 Binary files a/bin/macosx/ugrep and b/bin/macosx/ugrep differ diff --git a/bin/windows/ugrep.exe b/bin/windows/ugrep.exe index 3fc3831e..96c63a25 100755 Binary files a/bin/windows/ugrep.exe and b/bin/windows/ugrep.exe differ diff --git a/man/ugrep.1 b/man/ugrep.1 index f2762a98..88162cc8 100644 --- a/man/ugrep.1 +++ b/man/ugrep.1 @@ -1,4 +1,4 @@ -.TH UGREP "1" "July 25, 2019" "ugrep 1.3.2" "User Commands" +.TH UGREP "1" "July 26, 2019" "ugrep 1.3.3" "User Commands" .SH NAME \fBugrep\fR -- universal file pattern searcher .SH SYNOPSIS diff --git a/patterns/README.md b/patterns/README.md index b9b9d6aa..26c1fd95 100644 --- a/patterns/README.md +++ b/patterns/README.md @@ -1,24 +1,29 @@ +ugrep predefined patterns +========================= + This directory contains a collection of patterns that are helpful to search source code files. Use ugrep option `-f` to specify one or more pattern files to use for searching these patterns in files. The list of patterns defined in this directory will expand over time. -For example, to display all class defitions in C++ files in myproject directory: +For example, to display class definitions in C++ files in the working directory - ugrep -R -o -tc++ -f c++/classes myproject + ugrep -r -o -tc++ -f c++/classes To display Java identifiers (Unicode) with the line numbers of the matches, but skipping all matches of identifiers in comments and strings: - ugrep -R -n -o -f java/names -f java/zap_comments -f java/zap_strings myproject + ugrep -r -n -o -f java/names -f java/zap_comments -f java/zap_strings Some patterns automatically enable ugrep option `-o` to match multiple lines. These pattern files start with `###-o` to enbale option `-o` that is required to match the pattern across multiple lines. For example, strings and comments may span multiple lines, such as Python docstrings, requiring option `-o`. -Patterns requiring Unicode matching are placed in Unicode mode with (?u:X), +Empty lines and lines starting with a `#` are ignored. + +Patterns requiring Unicode matching are placed in Unicode mode with `(?u:X)`, just in case to prevent ugrep option -U from disabling them. We love your contributions to this effort! ❤️ diff --git a/patterns/php/README.md b/patterns/php/README.md index 6daafcca..11b92b27 100644 --- a/patterns/php/README.md +++ b/patterns/php/README.md @@ -6,5 +6,5 @@ PHP patterns - `names` matches identifiers (and keywords) - `strings` matches strings, auto-enables ugrep option -o to match multi-line strings - `zap_comments` removes comments from matches, recommend ugrep option -o -- `zap_html` removes HTML content outside of , auto-enables ugrep option -o +- `zap_html` removes HTML content outside of `` blocks, auto-enables ugrep option -o - `zap_strings` removes strings from matches, recommend ugrep option -o diff --git a/src/ugrep.cpp b/src/ugrep.cpp index 27a0ddd8..47b09047 100644 --- a/src/ugrep.cpp +++ b/src/ugrep.cpp @@ -103,7 +103,7 @@ Optional libraries: #endif // ugrep version info -#define UGREP_VERSION "1.3.2" +#define UGREP_VERSION "1.3.3" // ugrep platform -- see configure.ac #if !defined(PLATFORM) @@ -476,7 +476,7 @@ int main(int argc, char **argv) else if (strncmp(arg, "exclude-from=", 13) == 0) flag_exclude_from.emplace_back(arg + 13); else if (strcmp(arg, "extended-regexp") == 0) - ; + flag_basic_regexp = false; else if (strncmp(arg, "file=", 5) == 0) flag_file.emplace_back(arg + 5); else if (strncmp(arg, "file-extensions=", 16) == 0) @@ -554,7 +554,7 @@ int main(int argc, char **argv) else if (strncmp(arg, "pager=", 6) == 0) flag_pager = arg + 6; else if (strcmp(arg, "perl-regexp") == 0) - flag_perl_regexp = true; + flag_basic_regexp = !(flag_perl_regexp = true); else if (strcmp(arg, "quiet") == 0 || strcmp(arg, "silent") == 0) flag_quiet = flag_no_messages = true; else if (strcmp(arg, "recursive") == 0) @@ -650,6 +650,7 @@ int main(int argc, char **argv) break; case 'E': + flag_basic_regexp = false; break; case 'e': @@ -774,6 +775,7 @@ int main(int argc, char **argv) case 'P': flag_perl_regexp = true; + flag_basic_regexp = false; break; case 'p': @@ -894,7 +896,7 @@ int main(int argc, char **argv) #ifndef HAVE_LIBZ // -z: but we don't have libz if (flag_decompress) - help("option -z is disabled"); + help("option -z is not available in this version of ugrep"); #endif // -t list: list table of types @@ -1394,6 +1396,9 @@ int main(int argc, char **argv) // enable --break flag_break = true; + + // enable --line-buffered to flush output to the pager immediately + flag_line_buffered = true; } #endif @@ -1468,16 +1473,18 @@ int main(int argc, char **argv) help("invalid --tabs=NUM value"); } -#ifdef HAVE_BOOST_REGEX if (flag_perl_regexp) { +#ifdef HAVE_BOOST_REGEX // construct the NFA pattern matcher std::string pattern(reflex::BoostPerlMatcher::convert(regex, convert_flags)); reflex::BoostPerlMatcher matcher(pattern, matcher_options.c_str()); found = findinfiles(magic, matcher, infiles, encoding); +#else + help("Option -P is not available in this version of ugrep"); +#endif } else -#endif { // construct the DFA pattern matcher reflex::Pattern pattern(reflex::Matcher::convert(regex, convert_flags), "r"); @@ -1499,7 +1506,7 @@ int main(int argc, char **argv) { if (!flag_no_messages) { - std::cerr << "Boost regex error at position " << error.position() << " in " << regex << std::endl; + std::cerr << "Boost regex error in " << regex << std::endl; switch (error.code()) { case boost::regex_constants::error_collate: @@ -2774,9 +2781,12 @@ bool ugrep(reflex::AbstractMatcher& matcher, reflex::Input& input, const char *p ; } - // --break: add a line break + // --break: add a line break and flush if ((matches > 0 || flag_any_line) && flag_break) + { fputc('\n', out); + fflush(out); + } return matches > 0; }