Permalink
Browse files

CPack: Fix for NSIS not checking the length of the correct PATH envir…

…onment var.
  • Loading branch information...
1 parent 1e9bffb commit 70c9da2f25b8d6a9e14cd5208078c8386587e423 @omf omf committed Apr 19, 2011
Showing with 27 additions and 11 deletions.
  1. +27 −11 modules/NSIS.template.in
View
@@ -199,6 +199,21 @@ FunctionEnd
!endif
!endif
+; GetPathEnvVar - Retrieves the correct (User or All) PATH environment variable
+; Input: None
+; Output: User or All path environment variable
+
+Function GetPathEnvVar
+ Push $0
+ StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey
+ ReadRegStr $0 ${NT_current_env} "PATH"
+ Goto Current
+ ReadAllKey:
+ ReadRegStr $0 ${NT_all_env} "PATH"
+ Current:
+ Exch $0
+FunctionEnd
+
; AddToPath - Adds the given dir to the search path.
; Input - head of the stack
; Note - Win9x systems requires reboot
@@ -208,11 +223,17 @@ Function AddToPath
Push $1
Push $2
Push $3
+ Push $4
# don't add if the path doesn't exist
IfFileExists "$0\*.*" "" AddToPath_done
- ReadEnvStr $1 PATH
+ Call GetPathEnvVar
+ Pop $4
+ Push $4
+ Pop $1
+
+ ; ReadEnvStr $1 PATH
; if the path is too long for a NSIS variable NSIS will return a 0
; length string. If we find that, then warn and skip any path
; modification as it will trash the existing path.
@@ -260,17 +281,11 @@ Function AddToPath
Goto AddToPath_done
AddToPath_NT:
- StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey
- ReadRegStr $1 ${NT_current_env} "PATH"
- Goto DoTrim
- ReadAllKey:
- ReadRegStr $1 ${NT_all_env} "PATH"
- DoTrim:
- StrCmp $1 "" AddToPath_NTdoIt
- Push $1
+ StrCmp $4 "" AddToPath_NTdoIt
+ Push $4
Call Trim
- Pop $1
- StrCpy $0 "$1;$0"
+ Pop $4
+ StrCpy $0 "$4;$0"
AddToPath_NTdoIt:
StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey
WriteRegExpandStr ${NT_current_env} "PATH" $0
@@ -281,6 +296,7 @@ Function AddToPath
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
AddToPath_done:
+ Pop $4
Pop $3
Pop $2
Pop $1

0 comments on commit 70c9da2

Please sign in to comment.