StrCpy $R0 "sometext" ""
;$R0 is still "sometext"
This is expected.
However,
StrCpy $R1 ""
StrCpy $R0 "sometext" $R1
;$R0 is now ""
This is not expected.
Looks like the maxlen parameter is evaluated at compile time instead of runtime, which leads to inconsistent behavior when using variable vs literal string.
The presence of the maxlen parameter is determined at compile time and if present, is evaluated at run-time.
Your problematic StrCpy ends up as 'StrCpy $R0 "sometext" 0' (at run-time) because $R1 needs to be converted to a number and "" is not a number so you get 0.
If you don't know at compile time whether or not you want to truncate the string then you need to set the maxlen parameter variable to ${NSIS_MAX_STRLEN}.
I understand, but think this is rather unintuitive.
From my pov the parameter is present at compile time in the first example - it's "" as opposed to not present.
If a function relies on outside input for maxlen then it would have to test for empty string and replace with ${NSIS_MAX_STRLEN} itself. I just think this should be handled by the engine rather than the script so that literal "" vs variable empty string behave the same way.
At the very least the behavior should be documented.
The only reason it accepts "" in the first place is so you can do StrCpy $0 "foo" "" -1. Meaning, it allows you to specify the start offset without specifying maxlen.