Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
mkmf.rb: unspace
* lib/mkmf.rb (String#unspace): unescape with backslashes.  normal
  makes need to escape spaces with backslashes.  nmake is not the
  case.
  • Loading branch information
nobu committed Sep 21, 2012
commit 1357c65f90a03e0af9d9c91d7714d62b641c53fa
15 changes: 10 additions & 5 deletions lib/mkmf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ def quote
/\s/ =~ self ? "\"#{self}\"" : "#{self}"
end

# Escape whitespaces for Makefile.
def unspace
gsub(/\s/, '\\\\\\&')
end

# Generates a string used as cpp macro name.
def tr_cpp
strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P")
Expand Down Expand Up @@ -1723,7 +1728,7 @@ def mkintpath(path)
end
unless defined?(mkintpath)
def mkintpath(path)
path
path.unspace
end
end

Expand Down Expand Up @@ -1751,9 +1756,9 @@ def configuration(srcdir)

#### Start of system configuration section. ####
#{"top_srcdir = " + $top_srcdir.sub(%r"\A#{Regexp.quote($topdir)}/", "$(topdir)/") if $extmk}
srcdir = #{srcdir.gsub(/\$\((srcdir)\)|\$\{(srcdir)\}/) {mkintpath(CONFIG[$1||$2])}.quote}
topdir = #{mkintpath($extmk ? CONFIG["topdir"] : $topdir).quote}
hdrdir = #{mkintpath(CONFIG["hdrdir"]).quote}
srcdir = #{srcdir.gsub(/\$\((srcdir)\)|\$\{(srcdir)\}/) {mkintpath(CONFIG[$1||$2])}}
topdir = #{mkintpath($extmk ? CONFIG["topdir"] : $topdir)}
hdrdir = #{mkintpath(CONFIG["hdrdir"])}
arch_hdrdir = #{$arch_hdrdir.quote}
VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])}
}
Expand All @@ -1765,7 +1770,7 @@ def configuration(srcdir)
end
CONFIG.each do |key, var|
next unless /prefix$/ =~ key
mk << "#{key} = #{with_destdir(var)}\n"
mk << "#{key} = #{with_destdir(var).unspace}\n"
end
CONFIG.each do |key, var|
next if /^abs_/ =~ key
Expand Down