The implementation for the refix filter.
More...
#include <fstream>
#include <iostream>
#include <regex>
|
| int | main (int argc, const char *argv[]) |
| | Resequences the reference/footnote numbers. More...
|
| |
The implementation for the refix filter.
◆ main()
| int main |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
Resequences the reference/footnote numbers.
- Parameters
-
| [in] | argc | = 1 for normal operation, or = 2 for test mode. |
| [in] | argv | Currently ignored. |
- Returns
- = 0 means no errors, = 1 means no test file.
198 using namespace std::string_literals;
199 const auto testing{argc > 1};
214 constexpr auto kNoTestFile{1};
217 if (ifile.open(
"test.txt"), ifile) ;
218 else return std::cerr <<
"refix: no file.\n", kNoTestFile;
220 auto &in{testing ? ifile : std::cin};
224 while (getline(in, l)) {
226 std::regex pat{R
"((\[)(\d+)(\]))"};
227 if (regex_search(l, mch, pat)) {
229 auto refOrd{stoi(mch.str(2))};
236 if(refOrd == 1) sv = SV::inFt, xptOrd = 1;
242 l = mch.prefix().str() +
"["s +
243 std::to_string(xptOrd) +
"]"s +
246 std::cout << l <<
'\n';