Переглянути джерело

Shell: Stop lying about string types

Hendiadyoin1 2 роки тому
батько
коміт
3d83d70cac

+ 2 - 2
Userland/Shell/AST.cpp

@@ -3796,7 +3796,7 @@ ErrorOr<Vector<String>> GlobValue::resolve_as_list(RefPtr<Shell> shell)
     Vector<String> strings;
     TRY(strings.try_ensure_capacity(results.size()));
     for (auto& entry : results) {
-        TRY(strings.try_append(TRY(String::from_utf8(entry))));
+        TRY(strings.try_append(TRY(String::from_deprecated_string(entry))));
     }
 
     return resolve_slices(shell, move(strings), m_slices);
@@ -3927,7 +3927,7 @@ ErrorOr<Vector<String>> TildeValue::resolve_as_list(RefPtr<Shell> shell)
     if (!shell)
         return { resolve_slices(shell, Vector { TRY(builder.to_string()) }, m_slices) };
 
-    return { resolve_slices(shell, Vector { TRY(String::from_utf8(shell->expand_tilde(builder.to_deprecated_string()))) }, m_slices) };
+    return { resolve_slices(shell, Vector { TRY(String::from_deprecated_string(shell->expand_tilde(builder.to_deprecated_string()))) }, m_slices) };
 }
 
 ErrorOr<NonnullRefPtr<Rewiring>> CloseRedirection::apply() const

+ 1 - 1
Userland/Shell/Formatter.cpp

@@ -598,7 +598,7 @@ void Formatter::visit(const AST::MatchExpr* node)
                         if (!first)
                             current_builder().append(" | "sv);
                         first = false;
-                        auto node = make_ref_counted<AST::BarewordLiteral>(AST::Position {}, String::from_utf8(option.pattern_value).release_value_but_fixme_should_propagate_errors());
+                        auto node = make_ref_counted<AST::BarewordLiteral>(AST::Position {}, String::from_deprecated_string(option.pattern_value).release_value_but_fixme_should_propagate_errors());
                         node->visit(*this);
                     }
                 });

+ 1 - 1
Userland/Shell/ImmediateFunctions.cpp

@@ -232,7 +232,7 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_regex_replace(AST::ImmediateExpressi
         TRY(replacement->resolve_as_list(this))[0],
         PosixFlags::Global | PosixFlags::Multiline | PosixFlags::Unicode);
 
-    return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), TRY(String::from_utf8(result)), AST::StringLiteral::EnclosureType::None);
+    return AST::make_ref_counted<AST::StringLiteral>(invoking_node.position(), TRY(String::from_deprecated_string(result)), AST::StringLiteral::EnclosureType::None);
 }
 
 ErrorOr<RefPtr<AST::Node>> Shell::immediate_remove_suffix(AST::ImmediateExpression& invoking_node, Vector<NonnullRefPtr<AST::Node>> const& arguments)

+ 2 - 2
Userland/Shell/Parser.cpp

@@ -1023,12 +1023,12 @@ AST::MatchEntry Parser::parse_match_entry()
         for (auto& regex : regexps) {
             if (names.is_empty()) {
                 for (auto& name : regex.parser_result.capture_groups)
-                    names.append(String::from_utf8(name).release_value_but_fixme_should_propagate_errors());
+                    names.append(String::from_deprecated_string(name).release_value_but_fixme_should_propagate_errors());
             } else {
                 size_t index = 0;
                 for (auto& name : regex.parser_result.capture_groups) {
                     if (names.size() <= index) {
-                        names.append(String::from_utf8(name).release_value_but_fixme_should_propagate_errors());
+                        names.append(String::from_deprecated_string(name).release_value_but_fixme_should_propagate_errors());
                         continue;
                     }