コード例 #1
0
ファイル: String.cpp プロジェクト: GustavoMOG/edelib
void String::trim_left(void) {
	if(length()) {
		str_trimleft(sdata->chars);
		/* update length */
		sdata->length = strlen(sdata->chars);
	}
}
コード例 #2
0
ファイル: Config.cpp プロジェクト: edeproject/svn
/*
 * scan section in [section]
 * returned value is terminated with '\0'
 */
static bool scan_section(char* line, char* buf, int bufsz) {
	char* bufp = buf;
	bool status = false;

	str_trimleft(line);

	for(; *line && bufsz > 0; line++) {
		if(*line == SECT_CLOSE) {
			status = true;
			break;
		}

		*bufp++ = *line;
		bufsz--;
	}

	*bufp = '\0';
	str_trimright(buf);
	return status;
}
コード例 #3
0
ファイル: strutil.cpp プロジェクト: edeproject/svn
UT_FUNC(strtest, "Test strutil")
{
	unsigned char s1[] = "StRiNG1";
	UT_VERIFY( STR_EQUAL("string1", str_tolower(s1)) );

	unsigned char s2[] = "some Sample Of sTrinG";
	UT_VERIFY( STR_EQUAL("some sample of string", str_tolower(s2)) );

	unsigned char s3[] = "sTRinG2";
	UT_VERIFY( STR_EQUAL("STRING2", str_toupper(s3)) );

	unsigned char s4[] = "xxx AbA BbCCbBc xxx !@# . Abb";
	UT_VERIFY( STR_EQUAL("XXX ABA BBCCBBC XXX !@# . ABB", str_toupper(s4)) );

	char s5[] = "  some with spaces";
	UT_VERIFY( STR_EQUAL("some with spaces", str_trimleft(s5)) );

	char s6[] = "				  some with spaces";
	UT_VERIFY( STR_EQUAL("some with spaces", str_trimleft(s6)) );

	char s6a[] = "|				some with spaces";
	UT_VERIFY( STR_EQUAL("|				some with spaces", str_trimleft(s6a)) );

	char s7[] = ".  some with spaces";
	UT_VERIFY( STR_EQUAL(".  some with spaces", str_trimleft(s7)) );

	char s8[] = "some with spaces  ";
	UT_VERIFY( STR_EQUAL("some with spaces", str_trimright(s8)) );

	char s9[] = "some with spaces                |";
	UT_VERIFY( STR_EQUAL("some with spaces                |", str_trimright(s9)) );