[m-rev.] diff: fix a problem with reading .module_dep files
Julien Fischer
jfischer at opturion.com
Mon Jan 5 17:44:00 AEDT 2026
Fix a problem with reading .module_dep files.
The source file name that is used as the second argument of a .module_dep file
may be directory qualified (e.g. if we are using source file mapping to
include source files from multiple directories). On Windows, such directory
qualified source file names may use '\' as a path separator. We use the term
parser to read the contents of .module dep files and that requires '\' to be
escaped. However, the code that writes module_dep files does not currently
do the required escaping. Fix that.
compiler/make.module_dep_file.m:
Escape the source file name before writing it to a .module_dep file.
Julien.
diff --git a/compiler/make.module_dep_file.m b/compiler/make.module_dep_file.m
index 7b429a681..1bcdbd325 100644
--- a/compiler/make.module_dep_file.m
+++ b/compiler/make.module_dep_file.m
@@ -2,7 +2,7 @@
% vim: ft=mercury ts=4 sw=4 expandtab
%---------------------------------------------------------------------------%
% Copyright (C) 2002-2009, 2011 The University of Melbourne.
-% Copyright (C) 2014-2017, 2019-2020, 2024-2025 The Mercury team.
+% Copyright (C) 2014-2017, 2019-2020, 2024-2026 The Mercury team.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%---------------------------------------------------------------------------%
@@ -160,7 +160,7 @@ do_write_module_dep_file_to_stream(Stream, Globals,
Baggage, ParseTreeModuleSrc, !IO) :-
Version = module_dep_file_v2,
version_number(Version, VersionNumber),
- SourceFileName = Baggage ^ mb_source_file_name,
+ SourceFileName = term_io.escaped_string(Baggage ^ mb_source_file_name),
SourceFileTopModuleName = Baggage ^ mb_source_file_top_module_name,
SourceFileTopModuleNameStr =
mercury_bracketed_sym_name_to_string(SourceFileTopModuleName),
More information about the reviews
mailing list