Example #1
0
File: diff.c Project: pjkack/ctags
static int parseHunk (const unsigned char* cp, vString *hunk, int scope_index)
{
	/*
	   example input: @@ -0,0 +1,134 @@
	   expected output: -0,0 +1,134
	*/

	const char *next_delim;
	const char *start, *end;
	const char *c;
	int i = CORK_NIL;

	cp += 3;
	start = (const char*)cp;

	if (*start != '-')
		return i;

	next_delim = strstr ((const char*)cp, HunkDelim[1]);
	if ((next_delim == NULL)
	    || (! (start < next_delim )))
		return i;
	end = next_delim;
	if (! ( '0' <= *( end - 1 ) && *( end - 1 ) <= '9'))
		return i;
	for (c = start; c < end; c++)
		if (*c == '\t')
			return i;
	vStringNCopyS (hunk, start, end - start);
	i = makeSimpleTag (hunk, DiffKinds, K_HUNK);
	if (i > CORK_NIL && scope_index > CORK_NIL)
	{
		tagEntryInfo *e =  getEntryInCorkQueue (i);
		e->extensionFields.scopeIndex = scope_index;
	}
	return i;
}
Example #2
0
static void markTheLastTagAsDeletedFile (int scope_index)
{
    tagEntryInfo *e =  getEntryInCorkQueue (scope_index);
    e->kind = &(DiffKinds [K_DELETED_FILE]);
}
Example #3
0
static void makeAsmTag (
		const vString *const name,
		const vString *const operator,
		const bool labelCandidate,
		const bool nameFollows,
		const bool directive,
		unsigned int *lastMacroCorkIndex)
{
	if (vStringLength (name) > 0)
	{
		bool found;
		const AsmKind kind = operatorKind (operator, &found);
		if (found)
		{
			if (kind > K_NONE)
				makeSimpleTag (name, kind);
		}
		else if (isDefineOperator (operator))
		{
			if (! nameFollows)
				makeSimpleTag (name, K_DEFINE);
		}
		else if (labelCandidate)
		{
			operatorKind (name, &found);
			if (! found)
				makeSimpleTag (name, K_LABEL);
		}
		else if (directive)
		{
			bool found_dummy;
			const AsmKind kind_for_directive = operatorKind (name, &found_dummy);
			tagEntryInfo *macro_tag;

			switch (kind_for_directive)
			{
			case K_NONE:
				break;
			case K_MACRO:
				*lastMacroCorkIndex = makeSimpleTag (operator,
													 kind_for_directive);
				break;
			case K_PSUEDO_MACRO_END:
				if (*lastMacroCorkIndex != CORK_NIL)
				{
					macro_tag = getEntryInCorkQueue (*lastMacroCorkIndex);
					macro_tag->extensionFields.endLine = getInputLineNumber ();
					*lastMacroCorkIndex = CORK_NIL;
				}
				break;
			case K_SECTION:
				makeSimpleRefTag (operator,
								  kind_for_directive,
								  ASM_SECTION_PLACEMENT);
				break;
			default:
				makeSimpleTag (operator, kind_for_directive);
			}
		}
	}
}