Skip to content
Permalink
Browse files

revert SyNode unicode Env variable changes - moved to synodeCleanup b…

…ranch
  • Loading branch information...
pavel.mash
pavel.mash committed Apr 21, 2019
1 parent 949bcf6 commit 080185d3ef381c6507f6161079b4b81d5fdc0111
Showing with 13 additions and 11 deletions.
  1. +13 −11 SyNode/SyNode.pas
@@ -81,10 +81,8 @@
interface

uses
{$ifdef MSWindows}
Windows,
{$endif}
{$ifndef FPC}
Windows,
ShLwApi, // for older Delphi versions download this file from JEDI library
{$else}
LazFileUtils, dynlibs,
@@ -810,13 +808,13 @@ procedure TSMEngine.DefineNodeProcess;
var process: PJSRootedObject;
env: PJSRootedObject;
FStartupPath: TFileName;
{$IFDEF Unix}
{$IFDEF FPC}
I, Cnt: Integer;
EnvStr: String;
Parts: TStringArray;
EnvStr: AnsiString;
Parts: array of AnsiString;
{$ELSE}
L: PtrInt;
EnvBlock, P, pEq: PWideChar;
EnvBlock, P, pEq: PChar;
strName, strVal: SynUnicode;
{$ENDIF}
begin
@@ -835,7 +833,7 @@ procedure TSMEngine.DefineNodeProcess;

process.ptr.defineProperty(cx, 'startupPath', cx.NewJSString(StringToSynUnicode(FStartupPath)).ToJSVal,
JSPROP_ENUMERATE or JSPROP_PERMANENT or JSPROP_READONLY);
{$IFDEF Unix} // FPC return OEM env var under Windows, so better to use GetEnvironmentStringsW
{$IFDEF FPC}
Cnt := GetEnvironmentVariableCount;
for I := 1 to Cnt do begin
EnvStr := GetEnvironmentString(I);
@@ -846,24 +844,28 @@ procedure TSMEngine.DefineNodeProcess;
end
end;
{$ELSE}
EnvBlock := GetEnvironmentStringsW;
EnvBlock := GetEnvironmentStrings;
try
P := EnvBlock;
while P^<>#0 do begin
{$ifdef UNICODE}
L := StrLenW(P);
{$else}
L := StrLen(P);
{$endif}
if (L>0) and (P^<>'=') then begin
pEq := StrScan(P, '=');
if pEq <> nil then begin
SetString(strName, p, pEq-P);
SetString(strVal, pEq+1, L-(pEq+1-p));
SetString(strVal, pEq+1, {$ifdef UNICODE}StrLenW{$else}StrLen{$endif}(pEq+1));
env.ptr.DefineUCProperty(cx, Pointer(strName), Length(strName), cx.NewJSString(strVal).ToJSVal,
JSPROP_ENUMERATE or JSPROP_PERMANENT or JSPROP_READONLY, nil, nil);
end;
end;
inc(P,L+1);
end;
finally
FreeEnvironmentStringsW(EnvBlock);
FreeEnvironmentStrings(EnvBlock);
end;
{$ENDIF}
process.ptr.defineProperty(cx, 'env', env.ptr.ToJSValue,

0 comments on commit 080185d

Please sign in to comment.
You can’t perform that action at this time.