Example #1
0
static size_t
appendAndFreeString(char* destination, string* str) {
    if (str != NULL) {
        size_t length = str_Length(str);
        memcpy(destination, str_String(str), length);
        str_Free(str);
        return length;
    }
    return 0;
}
Example #2
0
static bool_t ParseSymbol(char* src, uint32_t size)
{
	stringbuffer* pBuffer = strbuf_Create();
	string* pString;
	uint32_t i;
	bool_t r;

	for(i = 0; i < size; ++i)
	{
		char ch = *src++;
		
		if(ch == '\\')
		{
			if(i + 1 < size)
			{
				char* marg = NULL;

				ch = *src++;
				++i;
				
				if(ch == '@')
					marg = fstk_GetMacroRunID();
				else if(ch >= '0' && ch <= '9')
					marg = fstk_GetMacroArgValue(ch);
					
				if(marg)
				{
					strbuf_AppendStringZero(pBuffer, marg);
					continue;
				}
			}

			prj_Fail(ERROR_ID_MALFORMED);
			strbuf_Free(pBuffer);
			return false;
		}

		strbuf_AppendChar(pBuffer, ch);
	}

	pString = strbuf_String(pBuffer);
	strbuf_Free(pBuffer);
	
	if(g_bDontExpandStrings == 0 && sym_IsString(pString))
	{
		string* pValue = sym_GetStringValueByName(pString);
		int len = str_Length(pValue);
		int i;

		lex_SkipBytes(size);
		lex_UnputString(str_String(pValue));

		for(i = 0; i < len; ++i)
		{
			if(str_CharAt(pValue, i) == '\n')
				g_pFileContext->LineNumber -= 1;
		}
		
		r = false;
		str_Free(pValue);
	}
	else
	{
		strcpy(g_CurrentToken.Value.aString, str_String(pString));
		r = true;
	}
	
	str_Free(pString);
	return r;
}