NSIS 去除回车换行脚本

[code] ; TrimNewlines
; 输入,堆栈顶 (例如 whatever$\r$\n)
; 输出,堆栈顶 (替换,例如 whatever)
; 不改变其它变量值。

Function TrimNewlines
Exch $R0
Push $R1
Push $R2
StrCpy $R1 0

loop:
IntOp $R1 $R1 - 1
StrCpy $R2 $R0 1 $R1
StrCmp $R2 “$\r” loop
StrCmp $R2 “$\n” loop
IntOp $R1 $R1 + 1
IntCmp $R1 0 no_trim_needed
StrCpy $R0 $R0 $R1

no_trim_needed:
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
[/code]