blob: cc7a1e28696d135a392c03c72464df61e3c3378a (
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
|
#include "config.h"
#include "strutil.h"
#include <ctype.h>
#include <string.h>
RCSID("$Id: strutil.c,v 1.1.1.1 1999/02/02 23:29:39 shmit Exp $");
char *
getword(const char *src, char *dst)
{
int inquote = 0;
while (isspace(*src))
src++;
while (*src) {
if (*src == '\\' && *++src)
*dst++ = *src++;
else if (*src == '"') {
if (inquote)
inquote = 0;
else
inquote = 1;
src++;
} else if (*src == '#') {
if (!inquote)
break;
*dst++ = *src++;
} else if (!inquote && isspace(*src))
break;
else
*dst++ = *src++;
}
*dst = '\0';
if (!*src || *src == '#')
return NULL;
return (char *)src;
}
|