Archive: Problem with search & replace and latest version of NSIS


Problem with search & replace and latest version of NSIS
  Dear folks,

I have a problem with the search & replace function written by KiCHiK
http://nsis.sourceforge.net/archive/...instances=0,44

I took this function into my script and compiled it with the old version of NSIS (sorry old means 2.0b0). Means I had to search in several files and replace several lines. So I copied this function, renamed it and everything went fine.

NOW, I am working with CVS version (2.0b2) and everything went wrong. Calling this function two times: one time to replace four lines in FILE A and replace two lines in FILE B. Depending on which FILE is called first, the other one is getting 0KB size.

So calling the function for FILE A first, makes FILE B output 0KB and vice versa.

Thing this is not normal?
Is anybody out ther to verify this behaviour or telling me what I am doing wrong? Perhaps I can place the code somewhere...

I am using other functions too (e.g. PATH manipulation, service check and so on). Could this be a problem?

Regards
Mo


Here are the code lines....
 


ReplaceAPParams

FileOpen$0 "$INSTDIR\\Path\\to\\file_A.conf.tmp" "r"
>GetTempFileName $R0
FileOpen$1 $R0 "w"
>loop:
FileRead $0 $2
IfErrors done
StrCmp$2 "++ServerRoot++$\\r$\\n" 0 +3
FileWrite$1 "ServerRoot $\\"$INSTDIRApache2$"$\\r$\\n"
Goto loop
StrCmp$2 "++DocumentRoot++$\\r$\\n" 0 +3
FileWrite$1 "DocumentRoot $\\"$INSTDIRApache2htdocs$"$\\r$\\n"
Goto loop
StrCmp$2 "++php_value include_path++$\\r$\\n" 0 +3
FileWrite$1 "php_value include_path = $\\".;$INSTDIRApache2htdocsphp$"$\\r$\\n"
Goto loop
StrCmp$2 "++mod_gzip_temp_dir++$\\r$\\n" 0 +3
FileWrite$1 "mod_gzip_temp_dir = $\\"$INSTDIRApache2tmp$"$\\r$\\n"
Goto loop
FileWrite$1 $2
Goto loop

done:
FileClose $0
FileClose$1
Delete "$INSTDIR\\Path\\to\\file_A.conf.tmp"
Rename $R0 "$INSTDIR\\Path\\to\\file_A.conf"
>FunctionEnd
>


This really works fine on this file_A. I call this function in the corresponding section with:

Call ReplaceAPParams 

>


What it does: Replacing the 4 lines beginning with:
++ServerRoot++
++DocumentRoot++
++php_value include_path++
++mod_gzip_temp_dir++

AND: it really does what it should

BUT: After this function I call another (ReplacePHPParams), and it's really the same except it's another file to be opened and some other values to be replaced.

I call this (other) function in ITS corresponding section also with


Call ReplacePHPParams 

>


The output when the installer is called:
file_A.conf 39KB
file_B.conf 0KB

Turning this around (calling ReplacePHPParams first) makes it looking like that:
file_A.conf 0KB
file_B.conf 39KB

(Both files have 39KB so the size should only be a indicator that it is written or not.)

Thx for help
Mo

Try b1, try the latest CVS version and if nither works attach the full script.


KiCHiK -
(Thx for ya offer:-)

I did it already. I tried all of them. BUT my old 2.0b0 strikes after installation of a later release.... It tells me something like: Error: Can't find "MUI.nsh"

So here is the script! (attached)
Eventually it is rubbish in some parts, that's because I extracted it from the big one....
(some messy parts: SplashScreen, etc)

Thx in advance
Mo


I think the "IfErrors done" line does this. The error flag must have been set somewhere along the way and when it got to the function it just skipped it all because it thought there is an error. I have added ClearErrors at the top of my script in the archive and so should you for your script.


Sorry, could you be a bit more specific?
:-)
-------[edit]
commenting this line makes my system hang @installation time ---------


Add ClearErrors at the top of each function that replaces lines in your script and uses my code.


got it, sorry my fault

COOL
Thx for debugging!


------ [edit]

It's working again, yiiieeeepppiiii
Now let's go on working

Luv ya guys ;-)

----------------