/* end of string reached? */ if (*start == '\0')
{ /* technically we don't need to free here, but we're nice */
free(storage);
storage = NULL;
string = NULL; return NULL;
}
/* test if delimiter character */ if (delim && strchr(delim, *start))
{ /* *Ifnotatendofstring,weneedtoinsertanulltoterminatethe *returnedtoken.Wecanjustoverwritethenextcharacterifit *happenstobeinthewhitespaceset...otherwisemoveoverthe *restofthestringtomakeroom.(Thisiswhyweallocatedextra *spaceabove).
*/
p = start + 1; if (*p != '\0')
{ if (!strchr(whitespace, *p))
memmove(p + 1, p, strlen(p) + 1);
*p = '\0';
string = p + 1;
} else
{ /* at end of string, so no extra work */
string = p;
}
return start;
}
/* check for E string */
p = start; if (e_strings &&
(*p == 'E' || *p == 'e') &&
p[1] == '\'')
{
quote = "'";
escape = '\\'; /* if std strings before, not any more */
p++;
}
/* test if quoting character */ if (quote && strchr(quote, *p))
{ /* okay, we have a quoted token, now scan for the closer */ char thisquote = *p++;
for (; *p; p += PQmblenBounded(p, encoding))
{ if (*p == escape && p[1] != '\0')
p++; /* process escaped anything */ elseif (*p == thisquote && p[1] == thisquote)
p++; /* process doubled quote */ elseif (*p == thisquote)
{
p++; /* skip trailing quote */ break;
}
}
/* *Ifnotatendofstring,weneedtoinsertanulltoterminatethe *returnedtoken.Seenotesabove.
*/ if (*p != '\0')
{ if (!strchr(whitespace, *p))
memmove(p + 1, p, strlen(p) + 1);
*p = '\0';
string = p + 1;
} else
{ /* at end of string, so no extra work */
string = p;
}
/* Clean up the token if caller wants that */ if (del_quotes)
strip_quotes(start, thisquote, escape, encoding);
if (delim)
{ unsignedint offset2 = strcspn(start, delim);
if (offset > offset2)
offset = offset2;
}
if (quote)
{ unsignedint offset2 = strcspn(start, quote);
if (offset > offset2)
offset = offset2;
}
p = start + offset;
/* *Ifnotatendofstring,weneedtoinsertanulltoterminatethe *returnedtoken.Seenotesabove.
*/ if (*p != '\0')
{ if (!strchr(whitespace, *p))
memmove(p + 1, p, strlen(p) + 1);
*p = '\0';
string = p + 1;
} else
{ /* at end of string, so no extra work */
string = p;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.