コード例 #1
0
String
VS_SubString (const char * str, int begin, int len)
{
    int    n;
    String nstr;

    n = strlen (str);

    if (begin >= n)
	return VS_New (NULL);

    if (len == -1)
	n -= begin;
    else
    {
	if (begin+len > n)
	    n -= begin;
	else
	    n = len;
    }

    nstr = new (struct _String);

    nstr->maxlen = ALIGN(n+1,8);
    nstr->buffer = xmalloc (nstr->maxlen);
    nstr->len	 = n;

    strncpy (nstr->buffer, str + begin, n);
    nstr->buffer[n] = 0;

    return nstr;
}
コード例 #2
0
static int
StringPutsCB (StringStream * ss, const char * str, CBD data)
{
    if (!ss->out)
	ss->out = VS_New (NULL);

    VS_AppendString (ss->out, str);

    return 1;
}
コード例 #3
0
static int
StringPutCB (StringStream * ss, int c, CBD data)
{
    if (!ss->out)
	ss->out = VS_New (NULL);

    VS_AppendChar (ss->out, c);

    return c;
}