Assume filename passed to write_buffer_to_file is already parsed

This commit is contained in:
Maxime Coste 2017-04-20 09:37:04 +01:00
parent 5103b15b84
commit 30e6387071
3 changed files with 4 additions and 5 deletions

View File

@ -323,7 +323,7 @@ void write_buffer(const ParametersParser& parser, Context& context, const ShellC
throw runtime_error("cannot overwrite the buffer when in readonly mode");
auto filename = parser.positional_count() == 0 ?
buffer.name() : parse_filename(parser[0]);
buffer.name() : parse_filename(parser[0]);
context.hooks().run_hook("BufWritePre", filename, context);
write_buffer_to_file(buffer, filename);

View File

@ -280,8 +280,7 @@ void write_buffer_to_fd(Buffer& buffer, int fd)
void write_buffer_to_file(Buffer& buffer, StringView filename)
{
int fd = open(parse_filename(filename).c_str(),
O_CREAT | O_WRONLY | O_TRUNC, 0644);
int fd = open(filename.zstr(), O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd == -1)
throw file_access_error(filename, strerror(errno));

View File

@ -692,9 +692,9 @@ int run_filter(StringView keystr, StringView commands, ConstArrayView<StringView
{
Buffer* buffer = open_file_buffer(file);
if (not suffix_backup.empty())
write_buffer_to_file(*buffer, file + suffix_backup);
write_buffer_to_file(*buffer, buffer->name() + suffix_backup);
apply_to_buffer(*buffer);
write_buffer_to_file(*buffer, file);
write_buffer_to_file(*buffer, buffer->name());
buffer_manager.delete_buffer(*buffer);
}
if (not isatty(0))