Skip to content

Commit 44a4c63

Browse files
VexatosRX14
authored andcommittedJan 3, 2018
Change symbol mangling on Windows to avoid conflicts (#5518)
1 parent 288af4b commit 44a4c63

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed
 

‎src/compiler/crystal/codegen/codegen.cr

+9-8
Original file line numberDiff line numberDiff line change
@@ -2049,14 +2049,15 @@ module Crystal
20492049

20502050
def self.safe_mangling(program, name)
20512051
if program.has_flag?("windows")
2052-
name.gsub do |char|
2053-
case char
2054-
when '<', '>', '(', ')', '*', ':', ',', '#', '@', ' '
2055-
"."
2056-
when '+'
2057-
".."
2058-
else
2059-
char
2052+
String.build do |str|
2053+
name.each_char do |char|
2054+
if char.ascii_alphanumeric? || char == '_'
2055+
str << char
2056+
else
2057+
str << '.'
2058+
char.ord.to_s(16, str, upcase: true)
2059+
str << '.'
2060+
end
20602061
end
20612062
end
20622063
else

0 commit comments

Comments
 (0)
Please sign in to comment.