Make escape_yaml_fish_2_0 and unescape_yaml_fish_2_0 static

They no longer need to be exposed.
This commit is contained in:
ridiculousfish 2019-08-12 09:22:21 -07:00
parent 3ae5b23971
commit ce178fd6fd
2 changed files with 3 additions and 6 deletions

View file

@ -68,13 +68,14 @@ static void replace_all(std::string *str, const char *needle, const char *replac
} }
} }
void escape_yaml_fish_2_0(std::string *str) { // Support for escaping and unescaping the nonstandard "yaml" format introduced in fish 2.0.
static void escape_yaml_fish_2_0(std::string *str) {
replace_all(str, "\\", "\\\\"); // replace one backslash with two replace_all(str, "\\", "\\\\"); // replace one backslash with two
replace_all(str, "\n", "\\n"); // replace newline with backslash + literal n replace_all(str, "\n", "\\n"); // replace newline with backslash + literal n
} }
/// This function is called frequently, so it ought to be fast. /// This function is called frequently, so it ought to be fast.
void unescape_yaml_fish_2_0(std::string *str) { static void unescape_yaml_fish_2_0(std::string *str) {
size_t cursor = 0, size = str->size(); size_t cursor = 0, size = str->size();
while (cursor < size) { while (cursor < size) {
// Operate on a const version of str, to avoid needless COWs that at() does. // Operate on a const version of str, to avoid needless COWs that at() does.

View file

@ -70,8 +70,4 @@ class history_file_contents_t {
/// Append a history item to a buffer, in preparation for outputting it to the history file. /// Append a history item to a buffer, in preparation for outputting it to the history file.
void append_history_item_to_buffer(const history_item_t &item, std::string *buffer); void append_history_item_to_buffer(const history_item_t &item, std::string *buffer);
// Support for escaping and unescaping the nonstandard "yaml" format introduced in fish 2.0.
void escape_yaml_fish_2_0(std::string *str);
void unescape_yaml_fish_2_0(std::string *str);
#endif #endif