diff options
| -rw-r--r-- | .clang-format | 45 | ||||
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | compile_flags.txt | 6 | ||||
| -rw-r--r-- | makefile | 18 | ||||
| -rw-r--r-- | src/srcut.cpp | 34 |
5 files changed, 105 insertions, 0 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..ff96bb5 --- /dev/null +++ b/.clang-format | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | --- | ||
| 2 | AccessModifierOffset: -4 | ||
| 3 | AlignConsecutiveAssignments: 'true' | ||
| 4 | AlignConsecutiveDeclarations: 'true' | ||
| 5 | AlignEscapedNewlines: Left | ||
| 6 | AlignTrailingComments: 'true' | ||
| 7 | AlwaysBreakAfterReturnType: TopLevelDefinitions | ||
| 8 | BreakBeforeBraces: Stroustrup | ||
| 9 | BreakConstructorInitializers: BeforeComma | ||
| 10 | BreakInheritanceList: BeforeComma | ||
| 11 | ColumnLimit: '0' | ||
| 12 | CompactNamespaces: 'false' | ||
| 13 | Cpp11BracedListStyle: 'false' | ||
| 14 | FixNamespaceComments: 'true' | ||
| 15 | IncludeBlocks: Regroup | ||
| 16 | IncludeCategories: | ||
| 17 | - Regex: '^.*(precomp|pch|stdafx)' | ||
| 18 | Priority: -1 | ||
| 19 | - Regex: '^<.*>' | ||
| 20 | Priority: 1 | ||
| 21 | - Regex: '^".*"' | ||
| 22 | Priority: 2 | ||
| 23 | - Regex: '.*' | ||
| 24 | Priority: 3 | ||
| 25 | IndentCaseLabels: 'false' | ||
| 26 | IndentPPDirectives: AfterHash | ||
| 27 | IndentWidth: '4' | ||
| 28 | IndentWrappedFunctionNames: 'false' | ||
| 29 | KeepEmptyLinesAtTheStartOfBlocks: 'false' | ||
| 30 | PointerAlignment: Left | ||
| 31 | SortIncludes: 'true' | ||
| 32 | SpaceAfterCStyleCast: 'true' | ||
| 33 | SpaceAfterTemplateKeyword: 'false' | ||
| 34 | SpaceBeforeAssignmentOperators: 'true' | ||
| 35 | SpaceBeforeParens: ControlStatements | ||
| 36 | SpaceBeforeRangeBasedForLoopColon: 'false' | ||
| 37 | SpaceInEmptyParentheses: 'false' | ||
| 38 | SpacesInAngles: 'false' | ||
| 39 | SpacesInCStyleCastParentheses: 'false' | ||
| 40 | SpacesInConditionalStatement: 'true' | ||
| 41 | SpacesInParentheses: 'false' | ||
| 42 | Standard: Auto | ||
| 43 | TabWidth: '4' | ||
| 44 | UseTab: ForIndentation | ||
| 45 | ... | ||
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f886c89 --- /dev/null +++ b/.gitignore | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | bin/* | ||
| 2 | obj/*.o | ||
diff --git a/compile_flags.txt b/compile_flags.txt new file mode 100644 index 0000000..8efbfab --- /dev/null +++ b/compile_flags.txt | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | -Wall | ||
| 2 | -Werror | ||
| 3 | -std=c++20 | ||
| 4 | -pedantic | ||
| 5 | -I/usr/local/include | ||
| 6 | -Iinclude | ||
diff --git a/makefile b/makefile new file mode 100644 index 0000000..7723923 --- /dev/null +++ b/makefile | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | .PHONY: all clean | ||
| 2 | |||
| 3 | BIN=bin/srcut | ||
| 4 | OBJS+=obj/srcut.o | ||
| 5 | HEADER=${wildcard include/*.hpp} | ||
| 6 | |||
| 7 | CPPFLAGS=-Wall -Werror -std=c++20 -pedantic -Iinclude -O2 | ||
| 8 | |||
| 9 | all: $(BIN) | ||
| 10 | |||
| 11 | $(BIN): $(OBJS) | ||
| 12 | c++ -o $@ $(OBJS) | ||
| 13 | |||
| 14 | obj/%.o: src/%.cpp $(HEADER) | ||
| 15 | c++ -o $@ $(CPPFLAGS) -c $< | ||
| 16 | |||
| 17 | clean: | ||
| 18 | rm -f obj/* bin/* | ||
diff --git a/src/srcut.cpp b/src/srcut.cpp new file mode 100644 index 0000000..194cc65 --- /dev/null +++ b/src/srcut.cpp | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | #include <fstream> | ||
| 2 | #include <iostream> | ||
| 3 | #include <string> | ||
| 4 | |||
| 5 | using namespace std; | ||
| 6 | |||
| 7 | static void | ||
| 8 | process(istream& in, ostream& os) | ||
| 9 | { | ||
| 10 | auto match_begin = [](string_view s) -> bool { | ||
| 11 | return s.empty(); | ||
| 12 | }; | ||
| 13 | |||
| 14 | auto match_end = [](string_view s) -> bool { | ||
| 15 | return s.empty(); | ||
| 16 | }; | ||
| 17 | |||
| 18 | for ( string line; getline(in, line); ) { | ||
| 19 | if ( match_begin(line) ) { | ||
| 20 | } | ||
| 21 | else if ( match_end(line) ) { | ||
| 22 | } | ||
| 23 | else { | ||
| 24 | os << line << '\n'; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | os << flush; | ||
| 28 | } | ||
| 29 | |||
| 30 | int | ||
| 31 | main(void) | ||
| 32 | { | ||
| 33 | process(cin); | ||
| 34 | } | ||
