comparison libinterp/corefcn/input.cc @ 31149:f125ddb46055

dir_encoding: Use encoding from .oct-config file in current directory (bug #62761). * libinterp/corefcn/load-path.cc (load_path::read_dir_config), libinterp/corefcn/input.cc (input_system::dir_encoding): Use canonicalized path as key for the dir_encoding map. * test/file-encoding: Add tests for this feature. * test/Makefile.am: Add new folder to test suite.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 13 Jul 2022 13:20:48 +0200
parents 670a0d878af1
children
comparison
equal deleted inserted replaced
31148:52b8b0c1baf9 31149:f125ddb46055
42 42
43 #include "cmd-edit.h" 43 #include "cmd-edit.h"
44 #include "file-ops.h" 44 #include "file-ops.h"
45 #include "iconv-wrappers.h" 45 #include "iconv-wrappers.h"
46 #include "localcharset-wrapper.h" 46 #include "localcharset-wrapper.h"
47 #include "oct-env.h"
47 #include "oct-string.h" 48 #include "oct-string.h"
48 #include "quit.h" 49 #include "quit.h"
49 #include "str-vec.h" 50 #include "str-vec.h"
50 #include "uniconv-wrappers.h" 51 #include "uniconv-wrappers.h"
51 52
571 } 572 }
572 573
573 std::string input_system::dir_encoding (const std::string& dir) 574 std::string input_system::dir_encoding (const std::string& dir)
574 { 575 {
575 std::string enc = m_mfile_encoding; 576 std::string enc = m_mfile_encoding;
576 577 // use canonicalized path as key
577 auto enc_it = m_dir_encoding.find (load_path_dir (dir)); 578 const std::string key = sys::canonicalize_file_name (dir);
579
580 auto enc_it = m_dir_encoding.find (key);
578 if (enc_it != m_dir_encoding.end ()) 581 if (enc_it != m_dir_encoding.end ())
579 enc = enc_it->second; 582 enc = enc_it->second;
580 583
581 return enc; 584 return enc;
582 } 585 }