summaryrefslogtreecommitdiff
path: root/support/texlab/crates/bibutils_sys/src/is_ws.c
blob: 4f9e22e35b112871eed3d8410e22280853f21c52 (plain)
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
/*
 * is_ws.c
 *
 * Copyright (c) Chris Putnam 2003-2019
 *
 * Source code released under the GPL version 2
 *
 */
#include "is_ws.h"

/* is_ws(), is whitespace */
int 
is_ws( const char ch )
{
	if ( ch==' ' || ch=='\n' || ch=='\t' || ch=='\r' ) return 1;
	else return 0;
}

const char *
skip_ws( const char *p )
{
	if ( p ) {
		while ( is_ws( *p ) ) p++;
	}
	return p;
}

const char *
skip_notws( const char *p )
{
	if ( p ) {
		while ( *p && !is_ws( *p ) ) p++;
	}
	return p;
}

const char *
skip_line( const char *p )
{
	/* ...skip until end-of-line markers */
	while ( *p && *p!='\n' && *p!='\r' ) p++;

	/* ...skip end-of-line marker */
	if ( *p=='\r' ) p++; /* for CR LF or just CR end of lines */
	if ( *p=='\n' ) p++;

	return p;
}