BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Function StrNPos

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Language BASM
View previous topic :: View next topic  
Author Message
Olivier Pons
Guest





PostPosted: Sat May 19, 2007 1:46 pm    Post subject: Function StrNPos Reply with quote



Hi,

I'm looking for a function with a prototype like this :

function StrNPos(Source:PChar; SearchFor:PChar; const
AMaxLen:Integer):Integer;

Is that already implemented (I've not found a function like this in both
FastCode & FastMM478 projects) sowewhere ?
Back to top
Olivier Pons
Guest





PostPosted: Sat May 19, 2007 2:41 pm    Post subject: Re: Function StrNPos Reply with quote



I'm sorry, maybe I didn't explain myself properly.

Here's what I want to do :
in my program, I have a buffer which is most of the time a Pchar (i.e. a
sequence of chars terminated by a #0). But sometimes, this buffer doesn't
end with a #0.
That's why the StrPos function goes out of the scope and returns a Pchar to
a bad memory location.
And that's why I'm looking for a StrPos() function but with a maxlength
parameter.

Any idea if something like this is already implemented ?

"Olivier Pons" <olivierdot.pons (AT) freedot (DOT) fr.notdot.com> a écrit dans le
message de news:464eb864 (AT) newsgroups (DOT) borland.com...
Quote:
Hi,

I'm looking for a function with a prototype like this :

function StrNPos(Source:PChar; SearchFor:PChar; const
AMaxLen:Integer):Integer;

Is that already implemented (I've not found a function like this in both
FastCode & FastMM478 projects) sowewhere ?

Back to top
danny heijl
Guest





PostPosted: Sat May 19, 2007 6:47 pm    Post subject: Re: Function StrNPos Reply with quote



Olivier Pons schreef:

Quote:
I'm looking for a function with a prototype like this :

function StrNPos(Source:PChar; SearchFor:PChar; const
AMaxLen:Integer):Integer;

From:

de.comp.lang.delphi.misc
"Dietrich 'Milton' Bubenheim" <d...@despammed.com>
Fri, 22 Nov 2002 00:59:51 +0100
Re: StrLPos? asm?


function StrLPos(const Str1, Str2: Pointer; Len1, Len2:longword):
Pointer; assembler;
asm
PUSH EDI
PUSH ESI
PUSH EBX
MOV EBX,EAX
MOV EDI,EDX
PUSH ECX
MOV ECX,[EBP+8]
JE @@2
MOV ESI,ECX
POP ECX
SUB ECX,ESI
JBE @@2
MOV EDI,EBX
LEA EBX,[ESI-1]
@@1: MOV ESI,EDX
LODSB
REPNE SCASB
JNE @@2
MOV EAX,ECX
PUSH EDI
MOV ECX,EBX
REPE CMPSB
POP EDI
MOV ECX,EAX
JNE @@1
LEA EAX,[EDI-1]
JMP @@3
@@2: XOR EAX,EAX
@@3: POP EBX
POP ESI
POP EDI
end;


No idea if it works.

danny
---
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Language BASM All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.