diff options
author | dvshkurko <dvshkurko@yandex-team.ru> | 2022-02-10 16:45:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:52 +0300 |
commit | c768a99151e47c3a4bb7b92c514d256abd301c4d (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /tools/rescompressor | |
parent | 321ee9bce31ec6e238be26dbcbe539cffa2c3309 (diff) | |
download | ydb-c768a99151e47c3a4bb7b92c514d256abd301c4d.tar.gz |
Restoring authorship annotation for <dvshkurko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'tools/rescompressor')
-rw-r--r-- | tools/rescompressor/main.cpp | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/tools/rescompressor/main.cpp b/tools/rescompressor/main.cpp index c09d65c4c1..9aba1002c5 100644 --- a/tools/rescompressor/main.cpp +++ b/tools/rescompressor/main.cpp @@ -76,75 +76,75 @@ private: } }; -static TString CompressPath(const TVector<TStringBuf>& replacements, TStringBuf in) { - for (auto r : replacements) { - TStringBuf from, to; - r.Split('=', from, to); - if (in.StartsWith(from)) { - return Compress(TString(to) + in.SubStr(from.Size())); - } - } - - return Compress(in); -} - +static TString CompressPath(const TVector<TStringBuf>& replacements, TStringBuf in) { + for (auto r : replacements) { + TStringBuf from, to; + r.Split('=', from, to); + if (in.StartsWith(from)) { + return Compress(TString(to) + in.SubStr(from.Size())); + } + } + + return Compress(in); +} + int main(int argc, char** argv) { - int ind = 0; + int ind = 0; if (argc < 4) { - Cerr << "usage: " << argv[ind] << "asm_output --prefix? [-? origin_resource ro_resource]+" << Endl; + Cerr << "usage: " << argv[ind] << "asm_output --prefix? [-? origin_resource ro_resource]+" << Endl; return 1; } - TVector<TStringBuf> replacements; - - ind++; - TFixedBufferFileOutput asmout(argv[ind]); - ind++; + TVector<TStringBuf> replacements; + + ind++; + TFixedBufferFileOutput asmout(argv[ind]); + ind++; TString prefix; - if (TStringBuf(argv[ind]) == "--prefix") { + if (TStringBuf(argv[ind]) == "--prefix") { prefix = "_"; - ind++; + ind++; } else { prefix = ""; } - while (TStringBuf(argv[ind]).StartsWith("--replace=")) { + while (TStringBuf(argv[ind]).StartsWith("--replace=")) { replacements.push_back(TStringBuf(argv[ind]).SubStr(TStringBuf("--replace=").Size())); - ind++; - } - + ind++; + } + TAsmWriter aw(asmout, prefix); bool raw; - bool error = false; - while (ind < argc) { + bool error = false; + while (ind < argc) { TString compressed; if ("-"sv == argv[ind]) { - ind++; - if (ind >= argc) { - error = true; - break; - } - compressed = CompressPath(replacements, TStringBuf(argv[ind])); + ind++; + if (ind >= argc) { + error = true; + break; + } + compressed = CompressPath(replacements, TStringBuf(argv[ind])); raw = true; } else { - TUnbufferedFileInput inp(argv[ind]); + TUnbufferedFileInput inp(argv[ind]); TString data = inp.ReadAll(); compressed = Compress(TStringBuf(data.data(), data.size())); raw = false; } - ind++; - if (ind >= argc) { - error = true; - break; - } - aw.Write(argv[ind], compressed, raw); - ind++; + ind++; + if (ind >= argc) { + error = true; + break; + } + aw.Write(argv[ind], compressed, raw); + ind++; + } + if (error) { + Cerr << "Incorrect number of parameters at argument " << ind - 1 << argv[ind-1] << Endl; + return 1; } - if (error) { - Cerr << "Incorrect number of parameters at argument " << ind - 1 << argv[ind-1] << Endl; - return 1; - } return 0; } |