forked from adesutherland/CMS-370-BREXX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
countstr.c
36 lines (32 loc) · 861 Bytes
/
countstr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* $Id: countstr.c,v 1.4 2008/07/15 07:40:54 bnv Exp $
* $Log: countstr.c,v $
* Revision 1.4 2008/07/15 07:40:54 bnv
* #include changed from <> to ""
*
* Revision 1.3 2002/06/11 12:37:15 bnv
* Added: CDECL
*
* Revision 1.2 2001/06/25 18:49:48 bnv
* Header changed to Id
*
* Revision 1.1 1998/07/02 17:17:00 bnv
* Initial revision
*
*/
#include "lstring.h"
/* ----------------- Lcountstr ------------------- *
* Counts the appearances of the first string 'target'
* in the second argument 'source'
*/
long __CDECL
Lcountstr(const PLstr target, const PLstr source) {
long output = 0, position;
if (LLEN(*target) == 0) return 0;
position = Lpos(target, source, 0);
while (position > 0) {
output++;
position = Lpos(target, source, position + LLEN(*target));
}
return output;
} /* Lcountstr */