コード例 #1
0
int _tmain(int argc, _TCHAR* argv[])
{
	FILE* f0 = fopen("chan0.txt", "rt");
	FILE* f1 = fopen("chan1.txt", "rt");

	double time0 = -1, time1 = -1;
	int bin0 = -1, bin1 = -1;
	
	if (!fileReadLine(f0, &time0, &bin0) || !fileReadLine(f1, &time1, &bin1))
		return -1;
	while (true) {
		// compare timestamps
		if (fabs(time1 - time0) < 0.5) {
			// event timestamp match
			printf("event match %lf, %lf; enegries %d and %d\n", time0, time1, bin0, bin1);
		}
		// take the next instance from one of the files
		if (time1 > time0) {
			if (feof(f0))
				break;
			if (!fileReadLine(f0, &time0, &bin0))
				return -1;
		} else {
			if (feof(f1))
				break;
			if (!fileReadLine(f1, &time1, &bin1))
				return -1;
		}
	}

	scanf("*");
	return 0;
}
コード例 #2
0
ファイル: scheme.c プロジェクト: ruchee/ctags
static void findSchemeTags (void)
{
	vString *name = vStringNew ();
	const unsigned char *line;

	while ((line = fileReadLine ()) != NULL)
	{
		const unsigned char *cp = line;

		if (cp [0] == '(' &&
			(cp [1] == 'D' || cp [1] == 'd') &&
			(cp [2] == 'E' || cp [2] == 'e') &&
			(cp [3] == 'F' || cp [3] == 'f'))
		{
			while (*cp != '\0'  &&  !isspace (*cp))
				cp++;
			/* Skip over open parens and white space */
			do {
				while (*cp != '\0' && (isspace (*cp) || *cp == '('))
					cp++;
				if (*cp == '\0')
					cp = line = fileReadLine ();
				else
					break;
			} while (line);
			if (line == NULL)
				break;
			readIdentifier (name, cp);
			makeSimpleTag (name, SchemeKinds, K_FUNCTION);
		}
		if (cp [0] == '(' &&
			(cp [1] == 'S' || cp [1] == 's') &&
			(cp [2] == 'E' || cp [2] == 'e') &&
			(cp [3] == 'T' || cp [3] == 't') &&
			(cp [4] == '!' || cp [4] == '!') &&
			(isspace (cp [5]) || cp[5] == '\0'))
		{
			cp += 5;
			/* Skip over white space */
			do {
				while (*cp != '\0' && isspace (*cp))
					cp++;
				if (*cp == '\0')
					cp = line = fileReadLine ();
				else
					break;
			} while (line);
			if (line == NULL)
				break;
			readIdentifier (name, cp);
			makeSimpleTag (name, SchemeKinds, K_SET);
		}
	}
	vStringDelete (name);
}
コード例 #3
0
/**
 * osGetMemInfo
 *
 */
IEC_UINT osGetMemInfo(IEC_UDINT *ulpTotal, IEC_UDINT *ulpUsed, IEC_UDINT *ulpFree)
{
	IEC_UINT uRes = OK;

  #if defined(RTS_CFG_LINUX)
	IEC_UDINT hFile = 0;
	IEC_CHAR  szBuff[2048];

	IEC_UDINT s, b, c;

	uRes = fileOpen(&hFile, FILE_MEMINFO, FIO_MODE_READ, TRUE);
	if (uRes != OK)
	{
		RETURN(uRes);
	}

	/* Skip first line
	 */
	uRes = fileReadLine(hFile, szBuff, sizeof(szBuff));
	if (uRes != OK)
	{
		fileClose(hFile);
		RETURN(uRes);
	}

	uRes = fileReadLine(hFile, szBuff, sizeof(szBuff));
	if (uRes != OK)
	{
		fileClose(hFile);
		RETURN(uRes);
	}

	fileClose(hFile);

	/* total available | used | free | shared | buffers (kernel) | cached
	 * (in bytes)
	 */
	
	uRes = (IEC_UINT)OS_SSCANF(szBuff, "Mem:  %u %u %u %u %u %u", ulpTotal, ulpUsed, ulpFree, &s, &b, &c);
	if (uRes != 6)
	{
		RETURN(ERR_INVALID_DATA);
	}

	uRes = OK;

  #else

	*ulpTotal = *ulpUsed = *ulpFree = 0;

  #endif

	RETURN(uRes);
}
コード例 #4
0
ファイル: basic.c プロジェクト: terfect/Geany-plus
static void findBasicTags (void)
{
	const char *line;
	KeyWord *keywords;

	keywords = freebasic_keywords;

	while ((line = (const char *) fileReadLine ()) != NULL)
	{
		const char *p = line;
		KeyWord const *kw;

		while (isspace (*p))
			p++;

		/* Empty line or comment? */
		if (!*p || *p == '\'')
			continue;

		/* In Basic, keywords always are at the start of the line. */
		for (kw = keywords; kw->token; kw++)
			if (match_keyword (p, kw)) break;

		/* Is it a label? */
		match_colon_label (p);
	}
}
コード例 #5
0
ファイル: txt2tags.c プロジェクト: 15ramky/geany
static void findTxt2tagsTags (void)
{
	NestingLevels *nls = nestingLevelsNew();
	vString *name = vStringNew();
	const unsigned char *line;

	while ((line = fileReadLine()) != NULL)
	{
		int depth;

		if (isTxt2tagsLine(line))
			; /* skip not to improperly match titles */
		else if (parseTxt2tagsTitle(line, name, &depth))
		{
			NestingLevel *nl = nestingLevelsGetCurrent(nls);
			while (nl && nl->indentation >= depth)
			{
				nestingLevelsPop(nls);
				nl = nestingLevelsGetCurrent(nls);
			}

			vStringTerminate(name);
			makeTxt2tagsTag(name, nls, K_SECTION);
			nestingLevelsPush(nls, name, K_SECTION);
			nestingLevelsGetCurrent(nls)->indentation = depth;
		}
	}
	vStringDelete (name);
	nestingLevelsFree(nls);
}
コード例 #6
0
ファイル: ocaml.c プロジェクト: b4n/fishman-ctags
static void findOcamlTags (void)
{
	vString *name = vStringNew ();
	lexingState st;
	ocaToken tok;

	initStack ();
	computeModuleName ();
	tempIdent = vStringNew ();
	lastModule = vStringNew ();
	lastClass = vStringNew ();
	voidName = vStringNew ();
	vStringCopyS (voidName, "_");

	st.name = vStringNew ();
	st.cp = fileReadLine ();
	toDoNext = &globalScope;
	tok = lex (&st);
	while (tok != Tok_EOF)
	{
		(*toDoNext) (st.name, tok);
		tok = lex (&st);
	}

	vStringDelete (st.name);
	vStringDelete (name);
	vStringDelete (voidName);
	vStringDelete (tempIdent);
	vStringDelete (lastModule);
	vStringDelete (lastClass);
	clearStack ();
}
コード例 #7
0
ファイル: lua.c プロジェクト: Monits/ctags
static void findLuaTags (void)
{
	vString *name = vStringNew ();
	const unsigned char *line;

	while ((line = fileReadLine ()) != NULL)
	{
		const char *p, *q;

		if (! is_a_code_line (line))
			continue;

		p = (const char*) strstr ((const char*) line, "function");
		if (p == NULL)
			continue;

		q = strchr ((const char*) line, '=');
		
		if (q == NULL) {
			p = p + 9;  /* skip the `function' word */
			q = strchr ((const char*) p, '(');
			extract_name (p, q, name);
		} else {
			p = (const char*) &line[0];
			extract_name (p, q, name);
		}
	}
	vStringDelete (name);
}
コード例 #8
0
ファイル: clojure.c プロジェクト: NIMBIT/ctags
static void findClojureTags (void)
{
	vString *name = vStringNew ();
	const unsigned char *p;
	CurrentNamespace = vStringNew ();

	while ((p = fileReadLine ()) != NULL)
	{
		vStringClear (name);

		while (isspace (*p))
			p++;

		if (*p == '(')
		{
			if (isNamespace (p))
			{
				skipToSymbol (&p);
				makeNamespaceTag (name, p);
			}
			else if (isFunction (p))
			{
				skipToSymbol (&p);
				makeFunctionTag (name, p);
			}
		}
	}
	vStringDelete (name);
	vStringDelete (CurrentNamespace);
}
コード例 #9
0
ファイル: ocaml.c プロジェクト: b4n/fishman-ctags
static void eatComment (lexingState * st)
{
	boolean unfinished = TRUE;
	boolean lastIsStar = FALSE;
	const unsigned char *c = st->cp + 2;

	while (unfinished)
	{
		/* we've reached the end of the line..
		 * so we have to reload a line... */
		if (c == NULL || *c == '\0')
		{
			st->cp = fileReadLine ();
			/* WOOPS... no more input...
			 * we return, next lexing read
			 * will be null and ok */
			if (st->cp == NULL)
				return;
			c = st->cp;
		}
		/* we've reached the end of the comment */
		else if (*c == ')' && lastIsStar)
			unfinished = FALSE;
		/* here we deal with imbricated comment, which
		 * are allowed in OCaml */
		else if (c[0] == '(' && c[1] == '*')
		{
			st->cp = c;
			eatComment (st);

			c = st->cp;
			if (c == NULL)
			    return;

			lastIsStar = FALSE;
            c++;
		}
		/* OCaml has a rule which says :
		 *
		 *   "Comments do not occur inside string or character literals.
		 *    Nested comments are handled correctly."
		 *
		 * So if we encounter a string beginning, we must parse it to
		 * get a good comment nesting (bug ID: 3117537)
		 */
        else if (*c == '"')
        {
            st->cp = c;
            eatString (st);
            c = st->cp;
        }
		else
        {
			lastIsStar = '*' == *c;
            c++;
        }
	}

	st->cp = c;
}
コード例 #10
0
ファイル: objc.c プロジェクト: simlrh/ctags
static void eatComment (lexingState * st)
{
	boolean unfinished = TRUE;
	boolean lastIsStar = FALSE;
	const unsigned char *c = st->cp + 2;

	while (unfinished)
	{
		/* we've reached the end of the line..
		 * so we have to reload a line... */
		if (c == NULL || *c == '\0')
		{
			st->cp = fileReadLine ();
			/* WOOPS... no more input...
			 * we return, next lexing read
			 * will be null and ok */
			if (st->cp == NULL)
				return;
			c = st->cp;
		}
		/* we've reached the end of the comment */
		else if (*c == '/' && lastIsStar)
			unfinished = FALSE;
		else
		{
			lastIsStar = '*' == *c;
			c++;
		}
	}

	st->cp = c;
}
コード例 #11
0
ファイル: awk.c プロジェクト: b4n/fishman-ctags
static void findAwkTags (void)
{
	vString *name = vStringNew ();
	const unsigned char *line;

	while ((line = fileReadLine ()) != NULL)
	{
		if (strncmp ((const char*) line, "function", (size_t) 8) == 0  &&
			isspace ((int) line [8]))
		{
			const unsigned char *cp = line + 8;

			while (isspace ((int) *cp))
				++cp;
			while (isalnum ((int) *cp)  ||  *cp == '_')
			{
				vStringPut (name, (int) *cp);
				++cp;
			}
			vStringTerminate (name);
			while (isspace ((int) *cp))
				++cp;
			if (*cp == '(')
				makeSimpleTag (name, AwkKinds, K_FUNCTION);
			vStringClear (name);
			if (*cp != '\0')
				++cp;
		}
	}
	vStringDelete (name);
}
コード例 #12
0
ファイル: falcon.c プロジェクト: rumca-js/ctags
/* 
 * Function Definitions
 */
static void findFalconTags (void)
{
    vString *name = vStringNew ();
    const unsigned char *line;

    while ((line = fileReadLine ()) != NULL)
    {
        const unsigned char *cp = line;

        if (*cp == '#')
            continue;

        if (strncmp ((const char*) cp, "function", (size_t) 8) == 0)
        {
            cp += 8;
            while (isspace ((int) *cp))
                ++cp;
            while (isalnum ((int) *cp)  ||  *cp == '_')
            {
                vStringPut (name, (int) *cp);
                ++cp;
            }
            vStringTerminate (name);
            makeSimpleTag (name, FalconKinds, K_FUNCTION);
            vStringClear (name);
        }
        else if (strncmp ((const char*) cp, "class", (size_t) 5) == 0)
        {
            cp += 5;
            while (isspace ((int) *cp))
                ++cp;
            while (isalnum ((int) *cp)  ||  *cp == '_')
            {
                vStringPut (name, (int) *cp);
                ++cp;
            }
            vStringTerminate (name);
            makeSimpleTag (name, FalconKinds, K_CLASS);
            vStringClear (name);
        }
        else if (strncmp ((const char*) cp, "load", (size_t) 4) == 0)
        {
            cp += 4;
            while (isspace ((int) *cp))
                ++cp;
            while (isalnum ((int) *cp)  ||  *cp == '_')
            {
                vStringPut (name, (int) *cp);
                ++cp;
            }
            vStringTerminate (name);
            makeSimpleTag (name, FalconKinds, K_NAMESPACE);
            vStringClear (name);
        }
    }
    vStringDelete (name);
}
コード例 #13
0
ファイル: docbook.c プロジェクト: ApOgEE/geany
static void findDocBookTags(void)
{
    const char *line;

    while ((line = (const char*)fileReadLine()) != NULL)
    {
		const char *cp = line;

		for (; *cp != '\0'; cp++)
		{
			if (*cp == '<')
			{
				cp++;

				/* <section id="..."> */
				if (getWord("section", &cp))
				{
					createTag(K_SECTION, cp);
					continue;
				}
				/* <sect1 id="..."> */
				if (getWord("sect1", &cp))
				{
					createTag(K_SECT1, cp);
					continue;
				}
				/* <sect2 id="..."> */
				if (getWord("sect2", &cp))
				{
					createTag(K_SECT2, cp);
					continue;
				}
				/* <sect3 id="..."> */
				if (getWord("sect3", &cp) ||
					getWord("sect4", &cp) ||
					getWord("sect5", &cp))
				{
					createTag(K_SECT3, cp);
					continue;
				}
				/* <chapter id="..."> */
				if (getWord("chapter", &cp))
				{
					createTag(K_CHAPTER, cp);
					continue;
				}
				/* <appendix id="..."> */
				if (getWord("appendix", &cp))
				{
					createTag(K_APPENDIX, cp);
					continue;
				}
			}
		}
    }
}
コード例 #14
0
ファイル: vim.c プロジェクト: Cognoscan/ctags
static const unsigned char * readVimballLine (void)
{
	const unsigned char *line;

	while ((line = fileReadLine ()) != NULL)
	{
		break;
	}

	return line;
}
コード例 #15
0
/**
 * osGetTaskStatM
 *
 */
IEC_UINT osGetTaskStatM(IEC_UDINT ulID, IEC_UDINT *ulpSize, IEC_UDINT *ulpRes)
{
	IEC_UINT uRes = OK;

  #if defined(RTS_CFG_LINUX)
	IEC_UDINT hFile = 0;

	IEC_CHAR  szBuff[2048];
	
	IEC_UDINT ulShared, ulText, ulLib, ulData, ulDirty;

	OS_SPRINTF(szBuff, FILE_PIDSTATM, ulID);

	uRes = fileOpen(&hFile, szBuff, FIO_MODE_READ, TRUE);
	if (uRes != OK)
	{
		RETURN(uRes);
	}

	uRes = fileReadLine(hFile, szBuff, sizeof(szBuff));
	if (uRes != OK)
	{
		fileClose(hFile);
		RETURN(uRes);
	}

	uRes = fileClose(hFile);

	/* Overall Size | Resident | Shared | Text (TRS) | Library (LRS)
	 * Data (DRS) | Dirty
	 * (in pages à 4096kb)
	 */

	uRes = (IEC_UINT)OS_SSCANF(szBuff, "%u %u %u %u %u %u %u",
				ulpSize, ulpRes, &ulShared, &ulText, &ulLib, &ulData, &ulDirty);

	if (uRes < 7)
	{
		RETURN(ERR_INVALID_DATA);
	}

	uRes = OK;

	*ulpSize *= 4096;
	*ulpRes  *= 4096;

  #else

	*ulpSize = *ulpRes = 0;

  #endif

	RETURN(uRes);
}
コード例 #16
0
ファイル: perl.c プロジェクト: relaxdiego/ctags
/*
 * Perl subroutine declaration may look like one of the following:
 *
 *  sub abc;
 *  sub abc :attr;
 *  sub abc (proto);
 *  sub abc (proto) :attr;
 *
 * Note that there may be more than one attribute.  Attributes may
 * have things in parentheses (they look like arguments).  Anything
 * inside of those parentheses goes.  Prototypes may contain semi-colons.
 * The matching end when we encounter (outside of any parentheses) either
 * a semi-colon (that'd be a declaration) or an left curly brace
 * (definition).
 *
 * This is pretty complicated parsing (plus we all know that only perl can
 * parse Perl), so we are only promising best effort here.
 *
 * If we can't determine what this is (due to a file ending, for example),
 * we will return FALSE.
 */
static boolean isSubroutineDeclaration (const unsigned char *cp)
{
	boolean attr = FALSE;
	int nparens = 0;

	do {
		for ( ; *cp; ++cp) {
SUB_DECL_SWITCH:
			switch (*cp) {
				case ':':
					if (nparens)
						break;
					else if (TRUE == attr)
						return FALSE;    /* Invalid attribute name */
					else
						attr = TRUE;
					break;
				case '(':
					++nparens;
					break;
				case ')':
					--nparens;
					break;
				case ' ':
				case '\t':
					break;
				case ';':
					if (!nparens)
						return TRUE;
				case '{':
					if (!nparens)
						return FALSE;
				default:
					if (attr) {
						if (isIdentifier1(*cp)) {
							cp++;
							while (isIdentifier (*cp))
								cp++;
							attr = FALSE;
							goto SUB_DECL_SWITCH; /* Instead of --cp; */
						} else {
							return FALSE;
						}
					} else if (nparens) {
						break;
					} else {
						return FALSE;
					}
			}
		}
	} while (NULL != (cp = fileReadLine ()));

	return FALSE;
}
コード例 #17
0
ファイル: server_main.c プロジェクト: GastonMontes/Facultad
int main(int argc, char *argv[])
{
    ServerArguments arguments;
    
    // Arguments parser.
    if (serverArgumentsCreate(&arguments, argc, argv) == ERROR) {
        return ERROR;
    }
    
    File file;
    if (fileCreate(&file, serverArgumentsFileRoute(&arguments)) == ERROR) {
        return ERROR;
    }
    
    int sesion_id = ONE;
    while (!feof(fileAsociatedFile(&file))) {
        long line_length = fileLineLengthCount(&file);
        char buffer[line_length + ONE];
        fileReadLine(&file, buffer, (int)line_length + ONE);
        Process process;
        processCreate(&process, buffer, sesion_id);
        sesion_id++;
    }
    
    // Create server.
    Server server;
    
    if (serverCreate(&server) == ERROR) {
        return ERROR;
    }
    
    if (serverOpen(&server, serverArgumentsPort(&arguments)) == ERROR) {
        return ERROR;
    }
    
    Socket new_sock = serverAccept(&server);
    if (new_sock.sockfd == ERROR) {
        return ERROR;
    }
    
    if (socketSend(&new_sock, NULL) == ERROR) {
        return ERROR;
    }
    
    serverArgumentsDestroy(&arguments);
    serverDestroy(&server);
    socketDestroy(&new_sock);
    fileDestroy(&file);
    
    return ZERO;
}
コード例 #18
0
ファイル: sml.c プロジェクト: shigio/ctags
static void findSmlTags (void)
{
    vString *const identifier = vStringNew ();
    const unsigned char *line;
    smlKind lastTag = K_NONE;

    while ((line = fileReadLine ()) != NULL)
    {
        const unsigned char *cp = skipSpace (line);
        do
        {
            smlKind foundTag;
            if (CommentLevel != 0)
            {
                cp = (const unsigned char *) strstr ((const char *) cp, "*)");
                if (cp == NULL)
                    continue;
                else
                {
                    --CommentLevel;
                    cp += 2;
                }
            }
            foundTag = findNextIdentifier (&cp);
            if (foundTag != K_NONE)
            {
                cp = skipSpace (cp);
                cp = parseIdentifier (cp, identifier);
                if (foundTag == K_AND)
                {
                    if (lastTag != K_NONE)
                        makeSmlTag (lastTag, identifier);
                }
                else
                {
                    makeSmlTag (foundTag, identifier);
                    lastTag = foundTag;
                }
            }
            if (strstr ((const char *) cp, "(*") != NULL)
            {
                cp += 2;
                cp = (const unsigned char *) strstr ((const char *) cp, "*)");
                if (cp == NULL)
                    ++CommentLevel;
            }
        } while (cp != NULL  &&  strcmp ((const char *) cp, "") != 0);
    }
    vStringDelete (identifier);
}
コード例 #19
0
ファイル: sh.c プロジェクト: ALPHAMARIOX/pn
static void findShTags (void)
{
	vString *name = vStringNew ();
	const unsigned char *line;

	while ((line = fileReadLine ()) != NULL)
	{
		const unsigned char* cp = line;
		boolean functionFound = FALSE;

		if (line [0] == '#')
			continue;

		while (isspace (*cp))
			cp++;
		if (strncmp ((const char*) cp, "function", (size_t) 8) == 0  &&
			isspace ((int) cp [8]))
		{
			functionFound = TRUE;
			cp += 8;
			if (! isspace ((int) *cp))
				continue;
			while (isspace ((int) *cp))
				++cp;
		}
		if (! (isalnum ((int) *cp) || *cp == '_'))
			continue;
		while (isalnum ((int) *cp)  ||  *cp == '_')
		{
			vStringPut (name, (int) *cp);
			++cp;
		}
		vStringTerminate (name);
		while (isspace ((int) *cp))
			++cp;
		if (*cp++ == '(')
		{
			while (isspace ((int) *cp))
				++cp;
			if (*cp == ')'  && ! hackReject (name))
				functionFound = TRUE;
		}
		if (functionFound)
			makeSimpleTag (name, ShKinds, K_FUNCTION);
		vStringClear (name);
	}
	vStringDelete (name);
}
コード例 #20
0
/**
 * osGetLoadAvg
 *
 */
IEC_UINT osGetLoadAvg(IEC_REAL *fp1, IEC_REAL *fp5, IEC_REAL *fp15, IEC_UDINT *ulpPReady, IEC_UDINT *ulpPSum)
{
	IEC_UINT uRes = OK;

  #if defined(RTS_CFG_LINUX)

	IEC_UDINT hFile = 0;
	IEC_CHAR  szBuff[2048];

	IEC_UDINT ulPLast;

	uRes = fileOpen(&hFile, FILE_LOADAVG, FIO_MODE_READ, TRUE);
	if (uRes != OK)
	{
		RETURN(uRes);
	}

	uRes = fileReadLine(hFile, szBuff, sizeof(szBuff));
	if (uRes != OK)
	{
		fileClose(hFile);
		RETURN(uRes);
	}

	uRes = fileClose(hFile);

	/* 1 min. load average | 5 min. load average | 15 min load average
	 * processes ready to run | overall number of processes | last PID
	 */
	
	uRes = (IEC_UINT)OS_SSCANF(szBuff, "%f %f %f %u/%u %u", fp1, fp5, fp15, ulpPReady, ulpPSum, &ulPLast);
	if (uRes != 6)
	{
		RETURN(ERR_INVALID_DATA);
	}

	uRes = OK;

  #else

	*fp1 = *fp5 = *fp15		= 0.0;
	*ulpPReady = *ulpPSum	= 0;

  #endif

	RETURN(uRes);
}
コード例 #21
0
ファイル: vim.c プロジェクト: Cognoscan/ctags
static const unsigned char * readVimLine (void)
{
	const unsigned char *line;

	while ((line = fileReadLine ()) != NULL)
	{
		while (isspace ((int) *line))
			++line;

		if ((int) *line == '"')
			continue;  /* skip comment */

		break;
	}

	return line;
}
コード例 #22
0
ファイル: parser_perl.cpp プロジェクト: Mezomish/juffed
QString Parser_Perl::parseArgs()
{
    QString res;
    const char *cp;
    while ((cp=(const char*)fileReadLine())!=NULL)
    {
        cp = skipSpace (cp);
        if(*cp=='\0')continue;
        if(*cp=='#') continue;
        if(strstr(cp,"{"))
            if(!(strstr(cp,"shift") || strstr(cp,"@_")))
                continue;
        if(strstr(cp,"shift") || strstr(cp, "@_"))
        {
        	if(strstr(cp,"$"))
  			  cp=strstr(cp,"$");
			else
			{
				if(strstr(cp,"@"))
				{
					if((strstr(cp,"@") != strstr(cp,"@_")))
					    cp=strstr(cp,"@");
					else
						cp=NULL;
				}
				else
					cp=NULL;
			}
            if(cp)
            {
                printf("no $!!\n");
                if(!res.isEmpty())res.append(", ");
                while(*cp !='=' && *cp!='\0' && *cp!=')' && *cp!=';')
                {
                  if(*cp!=' ')
                  	res.append(*cp);
                  cp++;
                }
            }else
                continue;
        }
        if(strstr(cp,"}"))break;
    }
    return res;
}
コード例 #23
0
ファイル: lisp.c プロジェクト: Twinside/CTagSpotlight
/* Algorithm adapted from from GNU etags.
 */
static void findLispTags (void)
{
	vString *name = vStringNew ();
	const unsigned char* p;


	while ((p = fileReadLine ()) != NULL)
	{
		if (*p == '(')
		{
			if (L_isdef (p))
			{
				while (*p != '\0' && !isspace ((int) *p))
					p++;
				while (isspace ((int) *p))
					p++;
				L_getit (name, p);
			}
			else
			{
				/* Check for (foo::defmumble name-defined ... */
				do
					p++;
				while (*p != '\0' && !isspace ((int) *p)
						&& *p != ':' && *p != '(' && *p != ')');
				if (*p == ':')
				{
					do
						p++;
					while (*p == ':');

					if (L_isdef (p - 1))
					{
						while (*p != '\0' && !isspace ((int) *p))
							p++;
						while (isspace (*p))
							p++;
						L_getit (name, p);
					}
				}
			}
		}
	}
	vStringDelete (name);
}
コード例 #24
0
ファイル: perl.c プロジェクト: relaxdiego/ctags
/* Parse constants declared via hash reference, like this:
 * use constant {
 *   A => 1,
 *   B => 2,
 * };
 * The approach we take is simplistic, but it covers the vast majority of
 * cases well.  There can be some false positives.
 * Returns 0 if found the end of the hashref, -1 if we hit EOF
 */
static int parseConstantsFromHashRef (const unsigned char *cp,
	vString *name, vString *package)
{
	while (1) {
		enum const_state state =
			parseConstantsFromLine((const char *) cp, name, package);
		switch (state) {
			case CONST_STATE_NEXT_LINE:
				cp = fileReadLine();
				if (cp)
					break;
				else
					return -1;
			case CONST_STATE_HIT_END:
				return 0;
		}
	}
}
コード例 #25
0
ファイル: rst.c プロジェクト: simlrh/ctags
/* TODO: parse overlining & underlining as distinct sections. */
static void findRstTags (void)
{
	vString *name = vStringNew ();
	fpos_t filepos;
	const unsigned char *line;

	memset(&filepos, 0, sizeof(fpos_t));
	memset(kindchars, 0, sizeof kindchars);
	nestingLevels = nestingLevelsNew();

	while ((line = fileReadLine ()) != NULL)
	{
		int line_len = strlen((const char*) line);
		int name_len_bytes = vStringLength(name);
		int name_len = utf8_strlen(vStringValue(name), name_len_bytes);

		/* if the name doesn't look like UTF-8, assume one-byte charset */
		if (name_len < 0)
			name_len = name_len_bytes;

		/* underlines must be the same length or more */
		if (line_len >= name_len && name_len > 0 &&
			ispunct(line[0]) && issame((const char*) line))
		{
			char c = line[0];
			int kind = get_kind(c);

			if (kind >= 0)
			{
				makeRstTag(name, kind, filepos);
				continue;
			}
		}
		vStringClear (name);
		if (!isspace(*line))
		{
			vStringCatS(name, (const char*)line);
			filepos = getInputFilePosition();
		}
		vStringTerminate(name);
	}
	vStringDelete (name);
	nestingLevelsFree(nestingLevels);
}
コード例 #26
0
/**
 * osGetStat
 *
 */
IEC_UINT osGetStat(SProcTime *pPT)
{
	IEC_UINT uRes = OK;

  #if defined(RTS_CFG_LINUX)
	IEC_UDINT hFile = 0;
	IEC_CHAR  szBuff[2048];

	uRes = fileOpen(&hFile, FILE_STAT, FIO_MODE_READ, TRUE);
	if (uRes != OK)
	{
		RETURN(uRes);
	}

	uRes = fileReadLine(hFile, szBuff, sizeof(szBuff));
	if (uRes != OK)
	{
		fileClose(hFile);
		RETURN(uRes);
	}

	fileClose(hFile);
	
	/* User | Nice | System | Idle
	 * (in jiffies)
	 */

	uRes = (IEC_UINT)OS_SSCANF(szBuff, "cpu  %u %u %u %u", &pPT->ulUser, &pPT->ulNice, &pPT->ulSyst, &pPT->ulIdle);
	if (uRes != 4)
	{
		RETURN(ERR_INVALID_DATA);
	}

	uRes = OK;

  #else

	OS_MEMSET(pPT, 0x00, sizeof(SProcTime));

  #endif

	RETURN(uRes);
}
コード例 #27
0
ファイル: objc.c プロジェクト: simlrh/ctags
static void findObjcTags (void)
{
	vString *name = vStringNew ();
	lexingState st;
	objcToken tok;

	parentName = vStringNew ();
	tempName = vStringNew ();
	fullMethodName = vStringNew ();
	prevIdent = vStringNew ();

	/* (Re-)initialize state variables, this might be a second file */
	comeAfter = NULL;
	fallback = NULL;
	parentType = K_INTERFACE;
	ignoreBalanced_count = 0;
	methodKind = 0;
	parseStruct_gotName = FALSE;
	parseEnumFields_prev = NULL;
	parseEnum_named = FALSE;
	ignorePreprocStuff_escaped = FALSE;

	st.name = vStringNew ();
	st.cp = fileReadLine ();
	toDoNext = &globalScope;
	tok = lex (&st);
	while (tok != Tok_EOF)
	{
		(*toDoNext) (st.name, tok);
		tok = lex (&st);
	}
	vStringDelete(st.name);

	vStringDelete (name);
	vStringDelete (parentName);
	vStringDelete (tempName);
	vStringDelete (fullMethodName);
	vStringDelete (prevIdent);
	parentName = NULL;
	tempName = NULL;
	prevIdent = NULL;
	fullMethodName = NULL;
}
コード例 #28
0
ファイル: tcl.c プロジェクト: 05storm26/codelite
static void findTclTags (void)
{
	vString *name = vStringNew ();
	const unsigned char *line;

	while ((line = fileReadLine ()) != NULL)
	{
		const unsigned char *cp;

		while (isspace (line [0])) 
			++line;
		
		if (line [0] == '\0'  ||  line [0] == '#')
			continue;

		/* read first word */
		for (cp = line ; *cp != '\0'  &&  ! isspace ((int) *cp) ; ++cp)
			;
		if (! isspace ((int) *cp))
			continue;
		while (isspace ((int) *cp))
			++cp;
		/* Now `line' points at first word and `cp' points at next word */

		if (match (line, "proc"))
			cp = makeTclTag (cp, name, K_PROCEDURE);
		else if (match (line, "class") || match (line, "itcl::class"))
			cp = makeTclTag (cp, name, K_CLASS);
		else if (match (line, "public") ||
				match (line, "protected") ||
				match (line, "private"))
		{
			if (match (cp, "method"))
			{
				cp += 6;
				while (isspace ((int) *cp))
					++cp;
				cp = makeTclTag (cp, name, K_METHOD);
			}
		}
	}
	vStringDelete (name);
}
コード例 #29
0
ファイル: elixir.c プロジェクト: jsvisa/ctags
static void findElixirTags (void)
{
    vString *const module = vStringNew ();
    const unsigned char *line;

    while ((line = fileReadLine ()) != NULL)
    {
        const unsigned char *cp = line;

        skipWhitespace(&cp);

        if (*cp == '#')  /* skip initial comment */
            continue;
        if (*cp == '@')  /* strings sometimes start in column one */
            continue;

        if (*cp == 'd')
            parseDirective(cp, module);
    }
    vStringDelete (module);
}
コード例 #30
0
ファイル: perl6.c プロジェクト: oscarfv/ctags
/* Read next contiguous sequence of non-whitespace characters, store
 * the address in `ptok', and return its length.  Return value of zero
 * means EOF.
 *
 * TODO: Currently, POD and multi-line comments are not handled.
 */
static int
getNonSpaceStr (struct p6Ctx *ctx, const char **ptok)
{
    const char *s = ctx->line;
    if (!s) {
next_line:
        s = (const char *) fileReadLine();
        if (!s)
            return 0;                           /* EOF */
    }
    while (*s && isspace(*s))                   /* Skip whitespace */
        ++s;
    if ('#' == *s)
        goto next_line;
    int non_white_len = strcspn(s, ",; \t");
    if (non_white_len) {
        ctx->line = s + non_white_len;          /* Save state */
        *ptok = s;
        return non_white_len;
    } else
        goto next_line;
}