diff options
author | terminaldweller <thabogre@gmail.com> | 2021-10-24 03:05:03 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2021-10-24 03:05:03 +0000 |
commit | e52a9cc1a80c1463acf356c00afd4f43454e65a7 (patch) | |
tree | 5d6993a2955455ae4c2cdb14e90abc87d07b7c7d | |
parent | Merge pull request #21 from pJunger/readme (diff) | |
download | cgrep-e52a9cc1a80c1463acf356c00afd4f43454e65a7.tar.gz cgrep-e52a9cc1a80c1463acf356c00afd4f43454e65a7.zip |
added -C option. llvm 14
-rw-r--r-- | .travis.yml | 15 | ||||
-rw-r--r-- | cgrep.cpp | 15 | ||||
-rw-r--r-- | cgrep.roff | 4 |
3 files changed, 32 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml index 0a8c68c..6edb944 100644 --- a/.travis.yml +++ b/.travis.yml @@ -121,3 +121,18 @@ matrix: - git submodule update
script:
- make CXX=clang-13 LLVM_CONF=llvm-config-13
+ - dist: bionic
+ name: llvm14
+ sudo: required
+ language: cpp
+ before_script:
+ - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
+ - sudo apt-get update -y
+ - wget https://apt.llvm.org/llvm.sh
+ - chmod +x llvm.sh
+ - sudo ./llvm.sh 14
+ - sudo apt-get install -y clang-14 llvm-14-dev libclang-common-14-dev libclang-14-dev
+ - git submodule init
+ - git submodule update
+ script:
+ - make CXX=clang-14 LLVM_CONF=llvm-config-14
@@ -137,6 +137,11 @@ cl::opt<int> CO_B("B", cl::desc("Same as grep, how many lines before the matched " "line to print. Defaults to 0."), cl::init(0), cl::cat(CGrepCat), cl::Optional); // done +cl::opt<int> + CO_C("C", + cl::desc("Same as grep, how many lines before and after the matched " + "line to print. Defaults to 0."), + cl::init(0), cl::cat(CGrepCat), cl::Optional); // done } // namespace /***********************************************************************************************/ #if 1 @@ -253,8 +258,14 @@ void output_handler(const MatchFinder::MatchResult &MR, SourceRange SR, std::cout << CC_RED << MR.SourceManager->getFilename(SR.getBegin()).str() << ":" << linenumber << ":" << columnnumber_start << CC_NORMAL; } else { - unsigned line_range_begin = linenumber - CO_B; - unsigned line_range_end = linenumber + CO_A; + unsigned line_range_begin; + unsigned line_range_end; + if (0 >= CO_C) { + line_range_begin = linenumber - CO_C; + line_range_end = linenumber + CO_C; + } + line_range_begin = linenumber - CO_B; + line_range_end = linenumber + CO_A; std::string line; unsigned line_nu = 0; while (getline(mainfile, line)) { @@ -38,6 +38,10 @@ How many lines after the matched line to print. Defaults to 0. Howm many lines before the matched line to print. Defaults to 0. .TP +\fB-C=<int>\fP +Howm many lines before and after the matched line to print. Defaults to 0. + +.TP \fB--all\fP Turns on all switches other than nameddecl. |