summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2015-02-04 07:20:04 -0800
committerJan Kotas <jkotas@microsoft.com>2015-02-04 07:20:04 -0800
commitfdd9e11d90aae37fd5d7e7492756c23145b13b24 (patch)
tree15e5f5b6f3bc7c457e6018d6d6b9fd074a31a5f2 /src
parent984213fc34360ef0a521ee6cc4eec6f979a8734a (diff)
parent7b87914866b2761f6aaba1dc09551cbe17877791 (diff)
downloadcoreclr-fdd9e11d90aae37fd5d7e7492756c23145b13b24.tar.gz
coreclr-fdd9e11d90aae37fd5d7e7492756c23145b13b24.tar.bz2
coreclr-fdd9e11d90aae37fd5d7e7492756c23145b13b24.zip
Merge pull request #58 from ellismg/fix-h2inc-line-wrapping
Fix h2inc.ps1 generating invalid files on Windows 7
Diffstat (limited to 'src')
-rw-r--r--src/vm/h2inc.ps118
1 files changed, 13 insertions, 5 deletions
diff --git a/src/vm/h2inc.ps1 b/src/vm/h2inc.ps1
index 40dbe1d72c..f9729bcffb 100644
--- a/src/vm/h2inc.ps1
+++ b/src/vm/h2inc.ps1
@@ -8,9 +8,17 @@
# C to MASM include file translator
# This is replacement for the deprecated h2inc tool that used to be part of VS.
+#
+# The use of [console]::WriteLine (instead of Write-Output) is intentional.
+# PowerShell 2.0 (installed by default on Windows 7) wraps lines written with
+# Write-Output at whatever column width is being used by the current terminal,
+# even when output is being redirected to a file. We can't have this behavior
+# because it will cause the generated file to be malformed.
+#
+
Function ProcessFile($filePath) {
- Write-Output "// File start: $filePath"
+ [console]::WriteLine("// File start: $filePath")
Get-Content $filePath | ForEach-Object {
@@ -49,17 +57,17 @@ Function ProcessFile($filePath) {
if ($value -match $HEX_NUMBER_PATTERN -or $value -match $DECIMAL_NUMBER_PATTERN) {
$value = $value -replace $HEX_NUMBER_PATTERN, "0`$1h" # Convert hex constants
$value = $value -replace $DECIMAL_NUMBER_PATTERN, "`$1t" # Convert dec constants
- Write-Output "$name EQU $value"
+ [console]::WriteLine("$name EQU $value")
} else {
- Write-Output "$name TEXTEQU <$value>"
+ [console]::WriteLine("$name TEXTEQU <$value>")
}
}
}
- Write-Output $_
+ [console]::WriteLine("$_")
}
- Write-Output "// File end: $filePath"
+ [console]::WriteLine("// File end: $filePath")
}
ProcessFile $args[0]