/* Copyright (c) 2026 The Solidite Developers
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <iostream>
#include <string>
#include <cstdint>
int main(int argc, char* argv[]) {
std::string to_stdout;
for (int i = 1; i < argc; ++i) {
if (i != argc - 1) {
to_stdout += std::string(argv[i]) + ' ';
continue;
}
to_stdout += std::string(argv[i]) + '\n';
}
char escape;
for (size_t i = 0; i < to_stdout.length(); ++i) {
if (to_stdout[i] == '\\') {
escape = to_stdout[i+1];
// get the escape character before erasal
to_stdout.erase(i, 2);
switch (escape) {
case 'a':
to_stdout.insert(i, "\a");
break;
case 'b':
to_stdout.insert(i, "\b");
break;
case 'c':
to_stdout.erase(to_stdout.length() - 1, 1);
break;
case 'n':
to_stdout.insert(i, "\n");
break;
case 'r':
to_stdout.insert(i, "\r");
break;
case 't':
to_stdout.insert(i, "\t");
break;
case 'v':
to_stdout.insert(i, "\v");
break;
case '\\':
to_stdout.insert(i, "\\");
break;
default:
if (i == to_stdout.length())
to_stdout.insert(i, "\\\n");
break;
}
}
}
std::cout << to_stdout;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>