mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:26:24 +02:00
* GetEnv fix merged from os2 target
This commit is contained in:
parent
c7ca2ff901
commit
f95d795858
@ -942,54 +942,50 @@ begin
|
|||||||
{$ASMMODE INTEL}
|
{$ASMMODE INTEL}
|
||||||
asm
|
asm
|
||||||
cld
|
cld
|
||||||
mov ecx, EnvC
|
mov edi, Environment
|
||||||
mov edi, EnvP
|
|
||||||
mov edi, [edi]
|
|
||||||
lea esi, _EnvVar
|
lea esi, _EnvVar
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
lodsb
|
lodsb
|
||||||
@NewVar:
|
@NewVar:
|
||||||
push ecx
|
cmp byte ptr [edi], 0
|
||||||
push eax
|
jz @Stop
|
||||||
push esi
|
push eax { eax contains length of searched variable name }
|
||||||
mov ecx, -1
|
push esi { esi points to the beginning of the variable name }
|
||||||
mov edx, edi
|
mov ecx, -1 { our character ('=' - see below) _must_ be found }
|
||||||
mov al, '='
|
mov edx, edi { pointer to beginning of variable name saved in edx }
|
||||||
|
mov al, '=' { searching until '=' (end of variable name) }
|
||||||
repne
|
repne
|
||||||
scasb
|
scasb { scan until '=' not found }
|
||||||
neg ecx
|
neg ecx { what was the name length? }
|
||||||
dec ecx
|
dec ecx { corrected }
|
||||||
dec ecx
|
dec ecx { exclude the '=' character }
|
||||||
pop esi
|
pop esi { restore pointer to beginning of variable name }
|
||||||
pop eax
|
pop eax { restore length of searched variable name }
|
||||||
push eax
|
push eax { and save both of them again for later use }
|
||||||
push esi
|
push esi
|
||||||
cmp ecx, eax
|
cmp ecx, eax { compare length of searched variable name with name }
|
||||||
jnz @NotEqual
|
jnz @NotEqual { ... of currently found variable, jump if different }
|
||||||
xchg edx, edi
|
xchg edx, edi { pointer to current variable name restored in edi }
|
||||||
repe
|
repe
|
||||||
cmpsb
|
cmpsb { compare till the end of variable name }
|
||||||
xchg edx, edi
|
xchg edx, edi { pointer to beginning of variable contents in edi }
|
||||||
jz @Equal
|
jz @Equal { finish if they're equal }
|
||||||
@NotEqual:
|
@NotEqual:
|
||||||
xor eax, eax
|
xor eax, eax { look for 00h }
|
||||||
mov ecx, -1
|
mov ecx, -1 { it _must_ be found }
|
||||||
repne
|
repne
|
||||||
scasb
|
scasb { scan until found }
|
||||||
pop esi
|
pop esi { restore pointer to beginning of variable name }
|
||||||
pop eax
|
pop eax { restore length of searched variable name }
|
||||||
pop ecx
|
jmp @NewVar { ... or continue with new variable otherwise }
|
||||||
dec ecx
|
|
||||||
jecxz @Stop
|
|
||||||
jmp @NewVar
|
|
||||||
@Stop:
|
@Stop:
|
||||||
mov P, ecx
|
xor eax, eax
|
||||||
|
mov P, eax { Not found - return nil }
|
||||||
jmp @End
|
jmp @End
|
||||||
@Equal:
|
@Equal:
|
||||||
pop esi
|
pop esi { restore the stack position }
|
||||||
pop eax
|
pop eax
|
||||||
pop ecx
|
mov P, edi { place pointer to variable contents in P }
|
||||||
mov P, edi
|
|
||||||
@End:
|
@End:
|
||||||
end;
|
end;
|
||||||
GetEnv := StrPas (P);
|
GetEnv := StrPas (P);
|
||||||
@ -1217,7 +1213,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 2002-11-17 16:22:53 hajny
|
Revision 1.2 2002-12-15 22:50:29 hajny
|
||||||
|
* GetEnv fix merged from os2 target
|
||||||
|
|
||||||
|
Revision 1.1 2002/11/17 16:22:53 hajny
|
||||||
+ RTL for emx target
|
+ RTL for emx target
|
||||||
|
|
||||||
Revision 1.19 2002/09/07 16:01:24 peter
|
Revision 1.19 2002/09/07 16:01:24 peter
|
||||||
|
Loading…
Reference in New Issue
Block a user