示例#1
0
void ScanForFunctions(CLanguageProxy& proxy)
{
	const char *text = proxy.Text(), *max = text + proxy.Size();
	if (*max != 0)
		return;
	
	while (text < max)
	{
		text = skip(text, '<');
		text = skip_white(text);
		
		switch (toupper(*text))
		{
			case 0:
				return;
			case 'A':
				if (isspace(*++text))
					text = Anchor(text, proxy);
				else
					text = skip_nc(text, '>');
				break;
			case 'H':
				if (*++text >= '1' && *text <= '6')
				{
					text = Heading(text, proxy);
				}
				else
					text = skip_nc(text, '>');
				break;
			case 'S':
				if (strncasecmp(text, "SCRIPT", 6) == 0)
					text = JavaScript(text, proxy);
				break;
			default:
				text = skip_nc(text + 1, '>');
				break;
		}
	}
} /* ScanForFunctions */
void ScanForFunctions(CLanguageProxy& proxy)
{
	bool sorted = proxy.Sorted();
	PopupList lstHeadings, lstAnchors, lstPhpFunctions, lstPhpClasses, lstJsFunctions, lstJsClasses;

	const char *text = proxy.Text(), *max = text + proxy.Size();
	if (*max != 0)
		return;

	if (strncasecmp(text, "<!--:javascript", 15) == 0)
		text = JavaScript(text, lstJsFunctions, lstJsClasses, sorted);
	else if (strncasecmp(text, "<!--:php", 8) == 0)
		text = PhpScript(text + 11, lstPhpFunctions, lstPhpClasses, sorted);

	while (*text && text < max)
	{
		text = skip(text, '<');
		text = skip_whitespace(text);
		
		switch (toupper(*text))
		{
			case '?':
				text = PhpScript(text, lstPhpFunctions, lstPhpClasses, sorted);
				break;

			case 'A':
				if (isspace(*++text))
					text = anchor(text, proxy, lstAnchors, sorted);
				else
					text = skip_nc(text, '>');
				break;

			case 'L':
				if (strncasecmp(text, "LINK", 4) == 0)
					text = anchor(text + 4, proxy, lstAnchors, sorted);
				else
					text = skip_nc(text, '>');
				break;

			case 'H':
				if (*++text >= '1' && *text <= '6')
				{
					text = heading(text, lstHeadings, sorted);
				}
				else
					text = skip_nc(text, '>');
				break;

			case 'S':
				if (strncasecmp(text, "SCRIPT", 6) == 0)
					text = JavaScript(text, lstJsFunctions, lstJsClasses, sorted);
				break;

			default:
				text = skip_nc(text + 1, '>');
				break;
		}
	}

	add_to_popup("PHP-Classes",   lstPhpClasses,   proxy);
	add_to_popup("PHP-Functions", lstPhpFunctions, proxy);
	add_to_popup("JS-Classes",    lstJsClasses,    proxy);
	add_to_popup("JS-Functions",  lstJsFunctions,  proxy);
	add_to_popup("HTML-Anchors",  lstAnchors,      proxy);
	add_to_popup("HTML-Headings", lstHeadings,     proxy);
} /* ScanForFunctions */