1 /*
2 * is_ws.c
3 *
4 * Copyright (c) Chris Putnam 2003-2020
5 *
6 * Source code released under the GPL version 2
7 *
8 */
9 #include "is_ws.h"
10
11 /* is_ws(), is whitespace */
12 int
is_ws(const char ch)13 is_ws( const char ch )
14 {
15 if ( ch==' ' || ch=='\n' || ch=='\t' || ch=='\r' ) return 1;
16 else return 0;
17 }
18
19 const char *
skip_ws(const char * p)20 skip_ws( const char *p )
21 {
22 if ( p ) {
23 while ( is_ws( *p ) ) p++;
24 }
25 return p;
26 }
27
28 const char *
skip_notws(const char * p)29 skip_notws( const char *p )
30 {
31 if ( p ) {
32 while ( *p && !is_ws( *p ) ) p++;
33 }
34 return p;
35 }
36
37 const char *
skip_line(const char * p)38 skip_line( const char *p )
39 {
40 /* ...skip until end-of-line markers */
41 while ( *p && *p!='\n' && *p!='\r' ) p++;
42
43 /* ...skip end-of-line marker */
44 if ( *p=='\r' ) p++; /* for CR LF or just CR end of lines */
45 if ( *p=='\n' ) p++;
46
47 return p;
48 }
49