File: skip_keyword.c

package info (click to toggle)
garlic 1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 4,516 kB
  • sloc: ansic: 52,465; makefile: 2,254
file content (69 lines) | stat: -rw-r--r-- 1,763 bytes parent folder | download | duplicates (6)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* Copyright (C) 2000 Damir Zucic */

/*=============================================================================

				skip_keyword.c

Purpose:
	Skip keyword: find the pointer which points to the first character
	which belongs to  the set of separators.  Used to skip keyword and
	reach the content following the keyword. This function is required
	because some keywords may be abbreviated.

Input:
	(1) Pointer to the string which has a keyword at the beginning.
	(2) Pointer to the list (string) of separators.

Output:
	(1) Return value.

Return value:
	(1) Pointer to the remainder of the string, following the keyword.
	(2) NULL on failure.

========includes:============================================================*/

#include <stdio.h>

/*======skip keyword:========================================================*/

char *SkipKeyword_ (char *stringP, char *separatorsP)
{
int		current_char, current_separator;
int		separator_foundF = 0;
char		*P;

/* Check the input string pointer: */
if (stringP == NULL) return NULL;

/* Find the first separator: */
while ((current_char = *stringP++) != '\0')
	{
	/** Search the set of separators: **/
	P = separatorsP;
	separator_foundF = 0;
	while ((current_separator = *P++) != '\0')
		{
		if (current_char == current_separator)
			{
			separator_foundF = 1;
			break;
			}
		}

	/** If the current character belongs to **/
	/** the set of separators, job is done: **/
	if (separator_foundF) break;
	}

/* If end of string is reached  but separator was */
/* not found, there is nothing after the keyword: */
if (!separator_foundF) return NULL;

/* Return the pointer to the remainder of the string: */
return --stringP;
}

/*===========================================================================*/