home *** CD-ROM | disk | FTP | other *** search
-
- /* LIKE.C
-
- dBASE-IV Funktion LIKE für Clipper nachgebildet.
- (C) (P) Walter Hummerich, 14.09.89
- Put in Public Domain by Walter Hummerich, Köln 91, 10. Dez. 1989
-
-
- Syntax: LIKE(<expC1>, <expC2>)
-
- Zweck: Vergleicht zwei Zeichenketten über Suchschablone
-
- Argumente: <expC1> ist die Suchschablone. Es können die Platzhalter
- '?' (für ein Zeichen) und '*' (für eine beliebige Anzahl
- von Zeichen) verwendet werden.
-
- <expC2> ist die Zeichenkette, die durchsucht wird.
-
- Rückgabe: Ein logischer Wert.
-
- Stimmt die Zeichenkette <expC2> mit der Suchschablone
- <expC1> überein, gibt LIKE ein logisches .T. zurück,
- sonst ein .F.
-
- Beispiele: ? LIKE('??cde?', 'abcdef') && Resultat: .T.
- ? LIKE('*de*', 'abcdef') && Resultat: .T.
- ? LIKE('ab*ef', 'abcdef') && Resultat: .T.
- ? LIKE('?cde?', 'abcdef') && Resultat: .F.
- ? LIKE('*bcde', 'abcdef') && Resultat: .F.
-
- Anmerkung: Vergebt mir, C-Freaks, ich bin nur C-Amateur!!! */
-
-
- #include "nandef.h"
- #include "extend.h"
-
- CLIPPER LIKE()
-
- {
- char *maske;
- char *text;
- char* maskpointer;
- int returncode;
-
- if (PCOUNT != 2)
- { returncode = FALSE; goto exit; }
-
- else
-
- if (ISCHAR(1) & ISCHAR(2))
- {
- maske = _parc(1);
- text = _parc(2);
- maskpointer = maske + _parclen(1);
-
- schleife:
- if ((*maske || *text) == '\0')
- goto ttrue;
-
- if (*maske == '?')
- goto nextcompare;
-
- sonder:
-
- if (*maske == '*')
- { maske++;
- if (*maske == '*')
- goto sonder;
-
- if (*maske == '\0')
- goto ttrue;
-
- maskpointer = maske;
-
- sloop:
- if (*text == '\0')
- goto ffalse;
-
- if (*text != *maske)
- { text++;
- goto sloop;
- }
- }
-
- if (*text != *maske)
- { maske = maskpointer;
- goto sloop;
- }
-
- nextcompare:
- maske++;
- text++;
- goto schleife;
-
- ttrue:
- { returncode = TRUE; goto exit; }
-
- ffalse:
- { returncode = FALSE; goto exit; }
- }
- else
- returncode = FALSE;
-
- exit:
- _retl (returncode);
- }
-