struct StringsBase *StringsBase=0L; /*#define RUN*/ #ifdef RUN int StrnCmp(cs,ct,l) register char *cs,*ct; register long l; { /* */ register char c; do ; while( (c=*cs++) && (c==*ct++) && --l ); if(c) ct--; return(c-*ct); }; /* strncmp $VER: 0.1 */ #endif long test(cs,ct,l) char *cs; char *ct; long l; { long el=StrnCmp(cs,ct,l); char s[64]; sprintf(s,"<%s>",cs); printf(" %8s %2ld ",s,StrLen(cs)); sprintf(s,"<%s>",ct); printf(" %8s %2ld %2ld",s,StrLen(ct),l); if(el) printf(" UNGLEICH %ld\n",el); if(!el) printf(" GLEICH %ld\n",el); return el; /* */ } int main() { /* MAIN */ long el=0; char *s[256]; StringsBase=(struct StringsBase *)OpenLibrary("Strings.library",0); puts(" cs len ct len n return"); el=test("wenn","wenn",7); el=test("wenn","wenn",3); el=test("wenn","weHN",2); el=test("wenn","weHN",3); el=test("wenn","weHN",4); el=test("Wenn","wen",7); el=test("Wenn","wenne",7); el=test("Wenn","wenn",7); el=test("Wenn","wen",7); el=test("Wenn","wenne",7); el=test("W","W",7); el=test("W","W",1); el=test("W","W",0); el=test("W","",7); el=test("","W",1); el=test("","",3); if(StringsBase) CloseLibrary(StringsBase); return 0; } /* END */ #ifdef COMMENT cs len ct len n return 4 4 7 GLEICH 0 4 4 3 GLEICH 0 4 4 2 GLEICH 0 4 4 3 UNGLEICH 38 4 4 4 UNGLEICH 38 4 3 7 UNGLEICH -32 4 5 7 UNGLEICH -32 4 4 7 UNGLEICH -32 4 3 7 UNGLEICH -32 4 5 7 UNGLEICH -32 1 1 7 GLEICH 0 1 1 1 GLEICH 0 1 1 0 GLEICH 0 1 <> 0 7 UNGLEICH 1 <> 0 1 1 UNGLEICH -1 <> 0 <> 0 3 GLEICH 0 #endif