struct StringsBase *StringsBase=0L; /*#define RUN*/ #ifdef RUN long StrcSpn(s,ss) register char *s,*ss; { register long l=-1; register char *sp,c,sc; do { l++; c=*s++; sp=ss; do { if(c==(sc=*sp++)) c=sc=0; } while(sc); } while(c); return l; } /* $VER: FEB06 StrcSpn 0.2 */ #endif long test(s,sc) char *s,*sc; { long l=0; char o[64]; l=StrcSpn(s,sc); sprintf(o,"<%s>",s); printf(" %8s ",o); sprintf(o,"<%s>",sc); printf(" %8s %ld\n",o,l); return l; } int main() { /* MAIN */ long el=0,l; char *s[64]; StringsBase=(struct StringsBase *)OpenLibrary("Strings.library",0); strcpy(s,"test StrcSpn"); printf(" Inputstring return\n",s); l=test(s,"egh"); l=test(s,"agh"); l=test(s,"ght"); l=test(s,"w"); l=test(s,"xyS"); l=test(s,"c"); l=test(s,""); l=test(s,"ies"); if(StringsBase) CloseLibrary(StringsBase); return el; } /* END */ #ifdef COMMENT _StrcSpn: movem.l d2/a2,-(sp) move.l 8(a5),a0 move.l 12(a5),a1 moveq.l #-1,d0 StrcSpnLoop: addq.l #1,d0 move.b (a0)+,d1 move.l a1,a2 StrcSpnLittleLoop: move.b (a2)+,d2 cmp.b d2,d1 bne StrcSpnJump clr.b d2 clr.b d1 StrcSpnJump: tst.b d2 bne StrcSpnLittleLoop tst.b d1 bne StrcSpnLoop movem.l (sp)+,d2/a2 rts Inputstring return 1 12 0 12 5 8 <> 12 1 #endif