本文整理汇总了C++中c_isspace函数的典型用法代码示例。如果您正苦于以下问题:C++ c_isspace函数的具体用法?C++ c_isspace怎么用?C++ c_isspace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了c_isspace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: while
static char *find_space(char *str)
{
while(*str != 0 && c_isspace(*str) == 0) {
str++;
}
if (c_isspace(*str))
return str;
return NULL;
}
开发者ID:fqtools,项目名称:ocserv,代码行数:9,代码来源:config-kkdcp.c
示例2: test_ctype
static void
test_ctype(void)
{
int c;
for (c = -1; c < 256; c++) {
/* Test blank. */
if (c == '\t' || c == ' ')
test_pass(c_isblank(c));
else
test_fail(c_isblank(c));
/* Test white. */
if (c == '\t' || c == ' ' || c == '\n')
test_pass(c_iswhite(c));
else
test_fail(c_iswhite(c));
/* Test space. */
if (c == '\t' || c == '\v' || c == '\f' ||
c == '\r' || c == '\n' || c == ' ')
test_pass(c_isspace(c));
else
test_fail(c_isspace(c));
/* Test digit. */
if (c >= '0' && c <= '9')
test_pass(c_isdigit(c));
else
test_fail(c_isdigit(c));
/* Test lower case. */
if (c >= 'a' && c <= 'z')
test_pass(c_islower(c));
else
test_fail(c_islower(c));
/* Test upper case. */
if (c >= 'A' && c <= 'Z')
test_pass(c_isupper(c));
else
test_fail(c_isupper(c));
/* Test alpha. */
if (c_islower(c) || c_isupper(c))
test_pass(c_isalpha(c));
else
test_fail(c_isalpha(c));
/* Test alphanumeric. */
if (c_isdigit(c) || c_isalpha(c))
test_pass(c_isalnum(c));
else
test_fail(c_isalnum(c));
}
}
开发者ID:CharizTeam,项目名称:dpkg,代码行数:56,代码来源:t-c-ctype.c
示例3: find_key_value
/*
Find value of given key. This is intended for Link header, but will
work with any header that uses ';' as field separator and '=' as key-value
separator.
Link = "Link" ":" #link-value
link-value = "<" URI-Reference ">" *( ";" link-param )
link-param = ( ( "rel" "=" relation-types )
| ( "anchor" "=" <"> URI-Reference <"> )
| ( "rev" "=" relation-types )
| ( "hreflang" "=" Language-Tag )
| ( "media" "=" ( MediaDesc | ( <"> MediaDesc <"> ) ) )
| ( "title" "=" quoted-string )
| ( "title*" "=" ext-value )
| ( "type" "=" ( media-type | quoted-mt ) )
| ( link-extension ) )
link-extension = ( parmname [ "=" ( ptoken | quoted-string ) ] )
| ( ext-name-star "=" ext-value )
ext-name-star = parmname "*" ; reserved for RFC2231-profiled
; extensions. Whitespace NOT
; allowed in between.
ptoken = 1*ptokenchar
ptokenchar = "!" | "#" | "$" | "%" | "&" | "'" | "("
| ")" | "*" | "+" | "-" | "." | "/" | DIGIT
| ":" | "<" | "=" | ">" | "?" | "@" | ALPHA
| "[" | "]" | "^" | "_" | "`" | "{" | "|"
| "}" | "~"
media-type = type-name "/" subtype-name
quoted-mt = <"> media-type <">
relation-types = relation-type
| <"> relation-type *( 1*SP relation-type ) <">
relation-type = reg-rel-type | ext-rel-type
reg-rel-type = LOALPHA *( LOALPHA | DIGIT | "." | "-" )
ext-rel-type = URI
See more: rfc5988
*/
bool
find_key_value (const char *start, const char *end, const char *key, char **value)
{
const char *eq;
size_t key_len = strlen (key);
const char *val_beg, *val_end;
const char *key_beg;
key_beg = start;
while (key_beg + key_len + 1 < end)
{
/* Skip whitespaces. */
while (key_beg + key_len + 1 < end && c_isspace (*key_beg))
key_beg++;
if (strncmp (key_beg, key, key_len))
{
/* Find next token. */
while (key_beg + key_len + 1 < end && *key_beg != ';')
key_beg++;
key_beg++;
continue;
}
else
{
/* Find equals sign. */
eq = key_beg + key_len;
while (eq < end && c_isspace (*eq))
eq++;
if (eq == end)
return false;
if (*eq != '=')
{
key_beg++;
continue;
}
val_beg = eq + 1;
while (val_beg < end && c_isspace (*val_beg))
val_beg++;
if (val_beg == end)
return false;
val_end = val_beg + 1;
while (val_end < end && *val_end != ';' && !c_isspace (*val_end))
val_end++;
*value = xstrndup (val_beg, val_end - val_beg);
return true;
}
}
*value = NULL;
return false;
}
开发者ID:EDEYUAN,项目名称:wget,代码行数:89,代码来源:metalink.c
示例4: _atom_get_url
static void _atom_get_url(void *context, int flags, const char *dir, const char *attr, const char *val, size_t len, size_t pos G_GNUC_WGET_UNUSED)
{
struct atom_context *ctx = context;
wget_string_t url;
if (!val || !len)
return;
url.p = NULL;
if ((flags & XML_FLG_ATTRIBUTE)) {
if (!wget_strcasecmp_ascii(attr, "href") || !wget_strcasecmp_ascii(attr, "uri")
|| !wget_strcasecmp_ascii(attr, "src") || !wget_strcasecmp_ascii(attr, "scheme")
|| !wget_strcasecmp_ascii(attr, "xmlns") || !wget_strncasecmp_ascii(attr, "xmlns:", 6))
{
for (;len && c_isspace(*val); val++, len--); // skip leading spaces
for (;len && c_isspace(val[len - 1]); len--); // skip trailing spaces
url.p = val;
url.len = len;
if (!ctx->urls)
ctx->urls = wget_vector_create(32, -2, NULL);
wget_vector_add(ctx->urls, &url, sizeof(url));
}
}
else if ((flags & XML_FLG_CONTENT)) {
const char *elem = strrchr(dir, '/');
if (elem) {
elem++;
if (!wget_strcasecmp_ascii(elem, "icon") || !wget_strcasecmp_ascii(elem, "id")
|| !wget_strcasecmp_ascii(elem, "logo"))
{
for (;len && c_isspace(*val); val++, len--); // skip leading spaces
for (;len && c_isspace(val[len - 1]); len--); // skip trailing spaces
// debug_printf("#2 %02X %s %s '%.*s' %zd\n", flags, dir, attr, (int) len, val, len);
url.p = val;
url.len = len;
if (!ctx->urls)
ctx->urls = wget_vector_create(32, -2, NULL);
wget_vector_add(ctx->urls, &url, sizeof(url));
}
}
}
}
开发者ID:rockdaboot,项目名称:wget2,代码行数:52,代码来源:atom_url.c
示例5: print_context_function
/* Print FUNCTION in a context header. */
static void
print_context_function (FILE *out, char const *function)
{
int i, j;
putc (' ', out);
for (i = 0; c_isspace ((unsigned char) function[i]) && function[i] != '\n'; i++)
continue;
for (j = i; j < i + 40 && function[j] != '\n'; j++)
continue;
while (i < j && c_isspace ((unsigned char) function[j - 1]))
j--;
fwrite (function + i, sizeof (char), j - i, out);
}
开发者ID:NaiyanXu,项目名称:gitroot,代码行数:14,代码来源:context.c
示例6: break_group_list
/* Breaks a list of "xxx", "yyy", to a character array, of
* MAX_COMMA_SEP_ELEMENTS size; Note that the given string is modified.
*/
static void
break_group_list(void *pool, char *text,
char *broken_text[MAX_GROUPS], unsigned *elements)
{
char *p = talloc_strdup(pool, text);
char *p2;
unsigned len;
*elements = 0;
if (p == NULL)
return;
do {
broken_text[*elements] = p;
(*elements)++;
p = strchr(p, ',');
if (p) {
*p = 0;
len = p - broken_text[*elements-1];
/* remove any trailing space */
p2 = p-1;
while (c_isspace(*p2)) {
*p2 = 0;
p2--;
}
p++; /* move to next entry and skip white
* space.
*/
while (c_isspace(*p))
p++;
if (len == 1) {
/* skip the group */
(*elements)--;
}
} else {
p2 = strrchr(broken_text[(*elements)-1], ' ');
if (p2 != NULL) {
while (c_isspace(*p2)) {
*p2 = 0;
p2--;
}
}
}
}
while (p != NULL && *elements < MAX_GROUPS);
}
开发者ID:xyz12810,项目名称:ocserv,代码行数:54,代码来源:plain.c
示例7: virUUIDParse
/**
* virUUIDParse:
* @uuidstr: zero terminated string representation of the UUID
* @uuid: array of VIR_UUID_BUFLEN bytes to store the raw UUID
*
* Parses the external string representation, allowing spaces and '-'
* character in the sequence, and storing the result as a raw UUID
*
* Returns 0 in case of success and -1 in case of error.
*/
int
virUUIDParse(const char *uuidstr, unsigned char *uuid)
{
const char *cur;
size_t i;
/*
* do a liberal scan allowing '-' and ' ' anywhere between character
* pairs, and surrounding whitespace, as long as there are exactly
* 32 hexadecimal digits the end.
*/
cur = uuidstr;
while (c_isspace(*cur))
cur++;
for (i = 0; i < VIR_UUID_BUFLEN;) {
uuid[i] = 0;
if (*cur == 0)
goto error;
if ((*cur == '-') || (*cur == ' ')) {
cur++;
continue;
}
if (!c_isxdigit(*cur))
goto error;
uuid[i] = virHexToBin(*cur);
uuid[i] *= 16;
cur++;
if (*cur == 0)
goto error;
if (!c_isxdigit(*cur))
goto error;
uuid[i] += virHexToBin(*cur);
i++;
cur++;
}
while (*cur) {
if (!c_isspace(*cur))
goto error;
cur++;
}
return 0;
error:
return -1;
}
开发者ID:Archer-sys,项目名称:libvirt,代码行数:58,代码来源:viruuid.c
示例8: virNetDevVPortProfileGetLldpadPid
static uint32_t
virNetDevVPortProfileGetLldpadPid(void)
{
int fd;
uint32_t pid = 0;
fd = open(LLDPAD_PID_FILE, O_RDONLY);
if (fd >= 0) {
char buffer[10];
if (saferead(fd, buffer, sizeof(buffer)) <= sizeof(buffer)) {
unsigned int res;
char *endptr;
if (virStrToLong_ui(buffer, &endptr, 10, &res) == 0
&& (*endptr == '\0' || c_isspace(*endptr))
&& res != 0) {
pid = res;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("error parsing pid of lldpad"));
}
}
} else {
virReportSystemError(errno,
_("Error opening file %s"), LLDPAD_PID_FILE);
}
VIR_FORCE_CLOSE(fd);
return pid;
}
开发者ID:merijnkr,项目名称:libvirt,代码行数:32,代码来源:virnetdevvportprofile.c
示例9: parse_charset
/* Given a string containing "charset=XXX", return the encoding if found,
or NULL otherwise */
char *
parse_charset (const char *str)
{
const char *end;
char *charset;
if (!str || !*str)
return NULL;
str = c_strcasestr (str, "charset=");
if (!str)
return NULL;
str += 8;
end = str;
/* sXXXav: which chars should be banned ??? */
while (*end && !c_isspace (*end))
end++;
/* sXXXav: could strdupdelim return NULL ? */
charset = strdupdelim (str, end);
/* Do a minimum check on the charset value */
if (!check_encoding_name (charset))
{
xfree (charset);
return NULL;
}
/*logprintf (LOG_VERBOSE, "parse_charset: %s\n", quote (charset));*/
return charset;
}
开发者ID:clerkma,项目名称:texlive-mobile,代码行数:36,代码来源:iri.c
示例10: find_key_values
/* Find all key=value pairs delimited with ';' or ','. This is intended for
Digest header parsing.
The usage is:
const char *pos;
for (pos = header_beg; pos = find_key_values (pos, header_end, &key, &val); pos++)
{
...
}
*/
const char *
find_key_values (const char *start, const char *end, char **key, char **value)
{
const char *key_start, *key_end;
const char *eq;
const char *val_start, *val_end;
eq = start;
while (eq < end && *eq != '=')
{
/* Skip tokens without =value part. */
if (*eq == ';' || *eq == ',')
start = eq + 1;
eq++;
}
if (eq >= end)
return NULL;
key_start = start;
while (key_start < eq && c_isspace (*key_start))
key_start++;
key_end = eq - 1;
while (key_end > key_start && c_isspace (*key_end))
key_end--;
key_end++;
val_start = eq + 1;
while (val_start < end && c_isspace (*val_start))
val_start++;
val_end = val_start;
while (val_end < end && *val_end != ';' &&
*val_end != ',' && !c_isspace (*val_end))
val_end++;
*key = xstrndup (key_start, key_end - key_start);
*value = xstrndup (val_start, val_end - val_start);
/* Skip trailing whitespaces. */
while (val_end < end && c_isspace (*val_end))
val_end++;
return val_end;
}
开发者ID:EDEYUAN,项目名称:wget,代码行数:58,代码来源:metalink.c
示例11: virSkipSpaces
/**
* virSkipSpaces:
* @str: pointer to the char pointer used
*
* Skip potential blanks, this includes space tabs, line feed,
* carriage returns.
*/
void
virSkipSpaces(const char **str)
{
const char *cur = *str;
while (c_isspace(*cur))
cur++;
*str = cur;
}
开发者ID:MountainWei,项目名称:libvirt,代码行数:16,代码来源:virstring.c
示例12: virSkipSpacesAndBackslash
/**
* virSkipSpacesAndBackslash:
* @str: pointer to the char pointer used
*
* Like virSkipSpaces, but also skip backslashes erroneously emitted
* by xend
*/
void
virSkipSpacesAndBackslash(const char **str)
{
const char *cur = *str;
while (c_isspace(*cur) || *cur == '\\')
cur++;
*str = cur;
}
开发者ID:MountainWei,项目名称:libvirt,代码行数:16,代码来源:virstring.c
示例13: trim
/* Skip leading and trailing whitespace, updating the original string
* in-place.
*/
void
trim (char *str)
{
size_t len = strlen (str);
while (len > 0 && c_isspace (str[len-1])) {
str[len-1] = '\0';
len--;
}
const char *p = str;
while (*p && c_isspace (*p)) {
p++;
len--;
}
memmove (str, p, len+1);
}
开发者ID:gaowanlong,项目名称:libguestfs,代码行数:21,代码来源:guestfsd.c
示例14: while
static char *check_str(char *line, size_t line_size, const char *needle, size_t needle_size)
{
char *p;
unsigned n;
while (c_isspace(*line)) {
line++;
line_size--;
}
if (line[0] == '#' || needle_size >= line_size)
return NULL;
if (memcmp(line, needle, needle_size) == 0) {
p = &line[needle_size];
while (c_isspace(*p)) {
p++;
}
if (*p != '=') {
return NULL;
} else
p++;
while (c_isspace(*p)) {
p++;
}
n = strlen(p);
if (n > 1 && p[n-1] == '\n') {
n--;
p[n] = 0;
}
if (n > 1 && p[n-1] == '\r') {
n--;
p[n] = 0;
}
return p;
}
return NULL;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:43,代码来源:gnutls_priority.c
示例15: ascii_grapheme_breaks
/* Assume that every ASCII character starts a new grapheme, which is often
true, except that CR-LF is a single grapheme. */
static void
ascii_grapheme_breaks (const char *s, size_t n, char *p)
{
size_t i;
p[0] = 1;
for (i = 1; i < n; i++)
{
bool is_ascii = c_isprint (s[i]) || c_isspace (s[i]);
p[i] = is_ascii && (s[i] != '\n' || s[i - 1] != '\r');
}
}
开发者ID:Chainfire,项目名称:android-ndk-compression-tools,代码行数:14,代码来源:ulc-grapheme-breaks.c
示例16: is_all_ascii
/* Tests whether a string is entirely ASCII. Returns 1 if yes.
Returns 0 if the string is in an 8-bit encoding or an ISO-2022 encoding. */
int
is_all_ascii (const char *s, size_t n)
{
for (; n > 0; s++, n--)
{
unsigned char c = (unsigned char) *s;
if (!(c_isprint (c) || c_isspace (c)))
return 0;
}
return 1;
}
开发者ID:DesmondWu,项目名称:gnulib,代码行数:14,代码来源:ulc-common.c
示例17: is_filter_line
/* Does the current line match the regexp /^\s*filter\s*=/ */
static int
is_filter_line (const char *line)
{
while (*line && c_isspace (*line))
line++;
if (!*line)
return 0;
if (! STRPREFIX (line, "filter"))
return 0;
line += 6;
while (*line && c_isspace (*line))
line++;
if (!*line)
return 0;
if (*line != '=')
return 0;
return 1;
}
开发者ID:dineshbhoopathy,项目名称:libguestfs,代码行数:23,代码来源:lvm-filter.c
示例18: has_key
/* This is to check if given token exists in HTTP header. Tokens are
separated by ';'. */
bool
has_key (const char *start, const char *end, const char *key)
{
const char *pos; /* Here would the token start. */
size_t key_len = strlen (key);
pos = start;
while (pos + key_len <= end)
{
/* Skip whitespaces at beginning. */
while (pos + key_len <= end && c_isspace (*pos))
pos++;
/* Does the prefix of pos match our key? */
if (strncmp (key, pos, key_len))
{
/* This was not a match.
Skip all characters until beginning of next token. */
while (pos + key_len <= end && *pos != ';')
pos++;
pos++;
continue;
}
/* key is prefix of pos. Is it the exact token or just a prefix? */
pos += key_len;
while (pos < end && c_isspace (*pos))
pos++;
if (pos == end || *pos == ';')
return true;
/* This was not a match (just a prefix).
Skip all characters until beginning of next token. */
while (pos + key_len <= end && *pos != ';')
pos++;
pos++;
}
return false;
}
开发者ID:EDEYUAN,项目名称:wget,代码行数:41,代码来源:metalink.c
示例19: munge_param
static char *
munge_param(const char *datain,
size_t *params,
size_t paramnum,
int *type)
{
char *dataout;
const char *sol;
const char *eol;
const char *eq;
const char *tmp;
size_t dataoutlen;
const char *replace = NULL;
sol = datain + params[paramnum];
eq = strchr(sol, '=');
eol = strchr(sol, '\n');
for (tmp = eq + 1; tmp < eol && !replace; tmp++) {
if (c_isspace(*tmp))
continue;
if (c_isdigit(*tmp)) {
*type = VIR_CONF_LONG;
replace = "\"foo\"";
} else if (*tmp == '[') {
*type = VIR_CONF_LIST;
replace = "666";
} else {
*type = VIR_CONF_STRING;
replace = "666";
}
}
dataoutlen = (eq - datain) + 1 +
strlen(replace) +
strlen(eol) + 1;
if (VIR_ALLOC_N(dataout, dataoutlen) < 0) {
virReportOOMError();
return NULL;
}
memcpy(dataout, datain, (eq - datain) + 1);
memcpy(dataout + (eq - datain) + 1,
replace, strlen(replace));
memcpy(dataout + (eq - datain) + 1 + strlen(replace),
eol, strlen(eol) + 1);
return dataout;
}
开发者ID:emaste,项目名称:libvirt,代码行数:49,代码来源:libvirtdconftest.c
示例20: find_value
/* Take string which must look like "key = value" and find the value.
* There may or may not be spaces before and after the equals sign.
* This function is used by both check_fedora_installer_root and
* check_w2k3_installer_root.
*/
static const char *
find_value (const char *kv)
{
const char *p;
p = strchr (kv, '=');
if (!p)
abort ();
do {
++p;
} while (c_isspace (*p));
return p;
}
开发者ID:rbuj,项目名称:libguestfs,代码行数:20,代码来源:inspect-fs-cd.c
注:本文中的c_isspace函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论