Skip to content

Commit

Permalink
Convert garglk.ini to DOS-style line endings when installing in Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiegel committed Nov 7, 2017
1 parent 65c9516 commit 1f2e9be
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
58 changes: 58 additions & 0 deletions Unix2DOS.nsh
@@ -0,0 +1,58 @@
; Taken from http://nsis.sourceforge.net/UNIX_to_DOS_text_file_format_conversion_script

Function unix2dos
; strips all CRs
; and then converts all LFs into CRLFs
; (this is roughly equivalent to "cat file | dos2unix | unix2dos")
;
; usage:
; Push "infile"
; Push "outfile"
; Call unix2dos
;
; beware that this function destroys $0 $1 $2

ClearErrors

Pop $2
FileOpen $1 $2 w

Pop $2
FileOpen $0 $2 r

Push $2 ; save name for deleting

IfErrors unix2dos_done

; $0 = file input (opened for reading)
; $1 = file output (opened for writing)

unix2dos_loop:
; read a byte (stored in $2)
FileReadByte $0 $2
IfErrors unix2dos_done ; EOL
; skip CR
StrCmp $2 13 unix2dos_loop
; if LF write an extra CR
StrCmp $2 10 unix2dos_cr unix2dos_write

unix2dos_cr:
FileWriteByte $1 13

unix2dos_write:
; write byte
FileWriteByte $1 $2
; read next byte
Goto unix2dos_loop

unix2dos_done:

; close files
FileClose $0
FileClose $1

; delete original
Pop $0
Delete $0

FunctionEnd
7 changes: 6 additions & 1 deletion installer.nsi
Expand Up @@ -15,6 +15,7 @@ SetCompressor lzma
!define MULTIUSER_EXECUTIONLEVEL Admin
!include MultiUser.nsh
!include MUI.nsh
!include Unix2DOS.nsh
!include FontReg.nsh
!include FontName.nsh

Expand Down Expand Up @@ -65,7 +66,11 @@ Section "DoInstall"
File "build\dist\*.exe"
File "build\dist\*.dll"
File "licenses\*.txt"
File "garglk\garglk.ini"
File "/oname=garglk.ini.tmp" "garglk\garglk.ini"
Push "garglk.ini.tmp"
Push "garglk.ini"
Call unix2dos


WriteUninstaller "uninstall.exe"

Expand Down

0 comments on commit 1f2e9be

Please sign in to comment.