コード例 #1
0
ファイル: tagz.cpp プロジェクト: Antokolos/instead-android-ng
static int need_full(T_CHAR* ptr)
{
	if (is_roman(ptr)) return 1;
	if (sepcmp(ptr,_TX("RPG"))) return 1;
	while(!separator(*ptr))
	{
		if (*ptr<'0' || *ptr>'9') return 0;
		ptr++;
	}
	return 1;
}
コード例 #2
0
ファイル: CalcRoman.cpp プロジェクト: kordax/Stroustrup
Rom get_rom()
{
	char ch;
	string value;
	cin >> ch;
	while (is_roman(ch))
	{
		value += ch;
		cin >> ch;
	}
	cin.unget();
	return Rom(number, value);
};
コード例 #3
0
ファイル: match.c プロジェクト: magsilva/bibclean
YESorNO
match_pattern(const char *s, const char *pattern)
{
    const char *org_s;
    const char *org_pattern;

    org_s = s;
    org_pattern = pattern;

    s = next_s(s-1);
    for ( ; (*pattern != '\0'); ++pattern)
    {
        switch(*pattern)
        {
        case 'a':			/* single letter */
            if (!Isalpha((int)*s))
                RETURN_MATCH_FAILURE("single letter");
            s = next_s(s);
            break;

        case 'A':			/* one or more letters */
            if (!Isalpha((int)*s))
                RETURN_MATCH_FAILURE("one or more letters");
            while (Isalpha((int)*s))
                s = next_s(s);
            break;

        case 'd':
            if (!Isdigit((int)*s))	/* single digit */
                RETURN_MATCH_FAILURE("single digit");
            s = next_s(s);
            break;

        case 'D':			/* one or more digits */
            if (!Isdigit((int)*s))
                RETURN_MATCH_FAILURE("one or more digits");
            while (Isdigit((int)*s))
                s = next_s(s);
            break;

        case 'r':			/* single roman numeral */
            if (!is_roman((int)*s))
                RETURN_MATCH_FAILURE("single roman numeral");
            s = next_s(s);
            break;

        case 'R':			/* one or more roman numerals */
            if (!is_roman((int)*s))
                RETURN_MATCH_FAILURE("one or more roman numerals");
            while (is_roman((int)*s))
                s = next_s(s);
            break;

        case 'w':			/* one word (letters and digits) */
            if (!Isalnum((int)*s))
                RETURN_MATCH_FAILURE("one word (letters and digits)");
            while (Isalnum((int)*s))
                s = next_s(s);
            break;

        case 'W':			/* one or more space-separated words */
            if (!Isalnum((int)*s))
                RETURN_MATCH_FAILURE("one or more space-separated words");
            while (Isalnum((int)*s))		/* parse first word */
                s = next_s(s);
            for (;;)
            {
                if (!Isspace((int)*s))
                    break;
                while (Isspace((int)*s))	/* parse separators */
                    s = next_s(s);
                while (Isalnum((int)*s))	/* parse another word */
                    s = next_s(s);
            }
            break;

        case 'X':		/* one or more special-separated words */
            if (!Isalnum((int)*s))
                RETURN_MATCH_FAILURE("one or more special-separated words");
            while (Isalnum((int)*s))		/* parse first word */
                s = next_s(s);
            for (;;)
            {
                if (!is_special(*s))
                    break;
                while (is_special(*s))	/* parse separators */
                    s = next_s(s);
                while (Isalnum((int)*s))	/* parse another word */
                    s = next_s(s);
            }
            break;

        case ' ':			/* one or more whitespace characters */
            if (!Isspace((int)*s))
                RETURN_MATCH_FAILURE("one or more whitespace characters");
            while (Isspace((int)*s))
                s = next_s(s);
            break;

        case '.':			/* exactly one special character */
            if (!is_special(*s))
                RETURN_MATCH_FAILURE("exactly one special character");
            s = next_s(s);		/* [07-Mar-1999] bug fix: missing before bibclean 2.12 */
            break;

        case ':':			/* one or more special characters */
            if (!is_special(*s))
                RETURN_MATCH_FAILURE("one or more special characters");
            while (is_special(*s))
                s = next_s(s);
            break;

        case '\\':			/* literal next character */
            pattern++;
            /* fall through to exact match test */
            /*@fallthrough@*/ /*FALLTHROUGH*/

        default:			/* anything else: exact match */
            if (*pattern != *s)
                RETURN_MATCH_FAILURE("anything else: exact match");
            s = next_s(s);
        }				/* end switch */
    }					/* end for (; ;) */
    if (*s == '\0')
        return (YES);
    else
        RETURN_MATCH_FAILURE("end of string");
}
コード例 #4
0
static int
is_list_entry(fz_text_line *line, fz_text_span *span, int *char_num_ptr)
{
	int char_num;
	fz_text_char *chr;

	/* First, skip over any whitespace */
	for (char_num = 0; char_num < span->len; char_num++)
	{
		chr = &span->text[char_num];
		if (!is_unicode_wspace(chr->c))
			break;
	}
	*char_num_ptr = char_num;

	if (span != line->first_span || char_num >= span->len)
		return 0;

	/* Now we check for various special cases, which we consider to mean
	 * that this is probably a list entry and therefore should always count
	 * as a separate paragraph (and hence not be entered in the line height
	 * table). */
	chr = &span->text[char_num];

	/* Is the first char on the line, a bullet point? */
	if (is_unicode_bullet(chr->c))
		return 1;

#ifdef SPOT_LINE_NUMBERS
	/* Is the entire first span a number? Or does it start with a number
	 * followed by ) or : ? Allow to involve single latin chars too. */
	if (is_number(chr->c) || is_latin_char(chr->c))
	{
		int cn = char_num;
		int met_char = is_latin_char(chr->c);
		for (cn = char_num+1; cn < span->len; cn++)
		{
			fz_text_char *chr2 = &span->text[cn];

			if (is_latin_char(chr2->c) && !met_char)
			{
				met_char = 1;
				continue;
			}
			met_char = 0;
			if (!is_number(chr2->c) && !is_unicode_wspace(chr2->c))
				break;
			else if (chr2->c == ')' || chr2->c == ':')
			{
				cn = span->len;
				break;
			}
		}
		if (cn == span->len)
			return 1;
	}

	/* Is the entire first span a roman numeral? Or does it start with
	 * a roman numeral followed by ) or : ? */
	if (is_roman(chr->c))
	{
		int cn = char_num;
		for (cn = char_num+1; cn < span->len; cn++)
		{
			fz_text_char *chr2 = &span->text[cn];

			if (!is_roman(chr2->c) && !is_unicode_wspace(chr2->c))
				break;
			else if (chr2->c == ')' || chr2->c == ':')
			{
				cn = span->len;
				break;
			}
		}
		if (cn == span->len)
			return 1;
	}
#endif
	return 0;
}