[vala/staging] vala: Avoid problems with '\' in #line directives on Windows
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] vala: Avoid problems with '\' in #line directives on Windows
- Date: Sun, 28 Aug 2022 15:22:07 +0000 (UTC)
commit 541e9f2c9dfde40b38fce32b8deb695f3eaf080b
Author: 星外之神 <wszqkzqk qq com>
Date: Sat Aug 27 23:26:41 2022 +0800
vala: Avoid problems with '\' in #line directives on Windows
Replace '\' with '/' in SourceFile.relative_path like in CodeContext.realpath().
F:/msys64/home/x/test/test.vala.c: In function '_vala_main':
F:/msys64/home/x/test/test.vala.c:12:9: warning: unknown escape sequence: '\M'
12 | #line 3 "C:\MyFiles\test.vala"
| ^~~~~~~~~~~~~~~~~~~~~~
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1353
vala/valasourcefile.vala | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/vala/valasourcefile.vala b/vala/valasourcefile.vala
index 8f4175cde..c4ac064a7 100644
--- a/vala/valasourcefile.vala
+++ b/vala/valasourcefile.vala
@@ -33,7 +33,14 @@ public class Vala.SourceFile {
public string? relative_filename {
set {
- this._relative_filename = value;
+ if (Path.DIR_SEPARATOR != '/') {
+ // don't use backslashes internally,
+ // to avoid problems in #line / #include directives
+ string[] components = value.split ("\\");
+ _relative_filename = string.joinv ("/", components);
+ } else {
+ _relative_filename = value;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]