コード例 #1
0
ファイル: rnode.c プロジェクト: flux-framework/flux-core
static void rnode_alloc_and_check (struct rnode *n, int count, char *expected)
{
    struct idset *ids = NULL;
    char *result = NULL;
    int avail = rnode_avail (n);
    ok (rnode_alloc (n, count, &ids) == 0,
        "rnode_alloc: count=%d", count);
    ok (ids != NULL,
        "rnode_alloc: returns non-null idset");
    ok (idset_count (ids) == count,
        "rnode_alloc: returned idset with expected count (%d)",
        idset_count (ids));
    if (!(result = idset_encode (ids, IDSET_FLAG_RANGE)))
        BAIL_OUT ("failed to encode idset result");
    is (result, expected,
        "rnode_alloc: count=%d: returned expected result %s", count, result);
    ok (rnode_avail (n) == avail - count,
        "rnode_alloc: rnode_avail now %d, expected %d",
        rnode_avail (n), avail - count);
    idset_destroy (ids);
    free (result);
}
コード例 #2
0
ファイル: gtags.c プロジェクト: baohaojun/ajoke-global
/*
 * updatetags: update tag file.
 *
 *	i)	dbpath		directory in which tag file exist
 *	i)	root		root directory of source tree
 *	i)	deleteset	bit array of fid of deleted or modified files 
 *	i)	addlist		\0 separated list of added or modified files
 */
void
updatetags(const char *dbpath, const char *root, IDSET *deleteset, STRBUF *addlist)
{
	struct put_func_data data;
	int seqno, flags;
	const char *path, *start, *end;

	if (vflag)
		fprintf(stderr, "[%s] Updating '%s' and '%s'.\n", now(), dbname(GTAGS), dbname(GRTAGS));
	/*
	 * Open tag files.
	 */
	data.gtop[GTAGS] = gtags_open(dbpath, root, GTAGS, GTAGS_MODIFY, 0);
	if (test("f", makepath(dbpath, dbname(GRTAGS), NULL))) {
		data.gtop[GRTAGS] = gtags_open(dbpath, root, GRTAGS, GTAGS_MODIFY, 0);
	} else {
		/*
		 * If you set NULL to data.gtop[GRTAGS], parse_file() doesn't write to
		 * GRTAGS. See put_syms().
		 */
		data.gtop[GRTAGS] = NULL;
	}
	/*
	 * Delete tags from GTAGS.
	 */
	if (!idset_empty(deleteset)) {
		if (vflag) {
			char fid[MAXFIDLEN];
			int total = idset_count(deleteset);
			unsigned int id;

			seqno = 1;
			for (id = idset_first(deleteset); id != END_OF_ID; id = idset_next(deleteset)) {
				snprintf(fid, sizeof(fid), "%d", id);
				path = gpath_fid2path(fid, NULL);
				if (path == NULL)
					die("GPATH is corrupted.");
				fprintf(stderr, " [%d/%d] deleting tags of %s\n", seqno++, total, path + 2);
			}
		}
		gtags_delete(data.gtop[GTAGS], deleteset);
		if (data.gtop[GRTAGS] != NULL)
			gtags_delete(data.gtop[GRTAGS], deleteset);
	}
	/*
	 * Set flags.
	 */
	data.gtop[GTAGS]->flags = 0;
	if (extractmethod)
		data.gtop[GTAGS]->flags |= GTAGS_EXTRACTMETHOD;
	data.gtop[GRTAGS]->flags = data.gtop[GTAGS]->flags;
	flags = 0;
	if (debug)
		flags |= PARSER_DEBUG;
	if (wflag)
		flags |= PARSER_WARNING;
	/*
	 * Add tags to GTAGS and GRTAGS.
	 */
	start = strbuf_value(addlist);
	end = start + strbuf_getlen(addlist);
	seqno = 0;
	for (path = start; path < end; path += strlen(path) + 1) {
		gpath_put(path, GPATH_SOURCE);
		data.fid = gpath_path2fid(path, NULL);
		if (data.fid == NULL)
			die("GPATH is corrupted.('%s' not found)", path);
		if (vflag)
			fprintf(stderr, " [%d/%d] extracting tags of %s\n", ++seqno, total, path + 2);
		if (debug)
			fprintf(stderr, "[%s]\n", path + 2);
		parse_file(path, flags, put_syms, &data);
		gtags_flush(data.gtop[GTAGS], data.fid);
		if (data.gtop[GRTAGS] != NULL)
			gtags_flush(data.gtop[GRTAGS], data.fid);
	}
	parser_exit();
	gtags_close(data.gtop[GTAGS]);
	if (data.gtop[GRTAGS] != NULL)
		gtags_close(data.gtop[GRTAGS]);
}