示例#1
0
int main() {

  igraph_t graph;
  FILE *ifile = fopen("cattr_bool_bug.graphml", "r");

  if (!ifile) {
    printf("Cannot open input file");
    return 1;
  }

  igraph_i_set_attribute_table(&igraph_cattribute_table);

  igraph_read_graph_graphml(&graph, ifile, 0);
  fclose(ifile);

  check_attr(&graph, 10);

  igraph_to_directed(&graph, IGRAPH_TO_DIRECTED_ARBITRARY);

  check_attr(&graph, 20);

  if (GAB(&graph, "loops")) { return 2; }

  igraph_destroy(&graph);

  return 0;
}
示例#2
0
int cmd_check_attr(int argc, const char **argv, const char *prefix)
{
	struct git_attr_check *check;
	int cnt, i, doubledash;
	const char *errstr = NULL;

	argc = parse_options(argc, argv, check_attr_options, check_attr_usage,
		PARSE_OPT_KEEP_DASHDASH);
	if (!argc)
		usage_with_options(check_attr_usage, check_attr_options);

	if (read_cache() < 0) {
		die("invalid cache");
	}

	doubledash = -1;
	for (i = 0; doubledash < 0 && i < argc; i++) {
		if (!strcmp(argv[i], "--"))
			doubledash = i;
	}

	/* If there is no double dash, we handle only one attribute */
	if (doubledash < 0) {
		cnt = 1;
		doubledash = 0;
	} else
		cnt = doubledash;
	doubledash++;

	if (cnt <= 0)
		errstr = "No attribute specified";
	else if (stdin_paths && doubledash < argc)
		errstr = "Can't specify files with --stdin";
	if (errstr) {
		error("%s", errstr);
		usage_with_options(check_attr_usage, check_attr_options);
	}

	check = xcalloc(cnt, sizeof(*check));
	for (i = 0; i < cnt; i++) {
		const char *name;
		struct git_attr *a;
		name = argv[i];
		a = git_attr(name, strlen(name));
		if (!a)
			return error("%s: not a valid attribute name", name);
		check[i].attr = a;
	}

	if (stdin_paths)
		check_attr_stdin_paths(cnt, check, argv);
	else {
		for (i = doubledash; i < argc; i++)
			check_attr(cnt, check, argv, argv[i]);
		maybe_flush_or_die(stdout, "attribute to stdout");
	}
	return 0;
}
示例#3
0
void insert_symbol (symbol_table table, const string* key, 
                     symbol* sym, astree* node) {
   table[key] = sym;
   for (size_t size = 1; size < block_count.size(); ++size) {
      fprintf(fsym, "   ");
   }
   fprintf (fsym, "%s (%zu.%zu.%zu) {%zu} %s\n", key->c_str(), 
            sym->filenr, sym->linenr, sym->offset, sym->blocknr, 
            check_attr (node));
}
示例#4
0
static void check_attr_stdin_paths(const char *prefix, int cnt,
                                   struct git_attr_check *check)
{
    struct strbuf buf, nbuf;
    int line_termination = null_term_line ? 0 : '\n';

    strbuf_init(&buf, 0);
    strbuf_init(&nbuf, 0);
    while (strbuf_getline(&buf, stdin, line_termination) != EOF) {
        if (line_termination && buf.buf[0] == '"') {
            strbuf_reset(&nbuf);
            if (unquote_c_style(&nbuf, buf.buf, NULL))
                die("line is badly quoted");
            strbuf_swap(&buf, &nbuf);
        }
        check_attr(prefix, cnt, check, buf.buf);
        maybe_flush_or_die(stdout, "attribute to stdout");
    }
    strbuf_release(&buf);
    strbuf_release(&nbuf);
}
示例#5
0
文件: check-attr.c 项目: 0369/git
static void check_attr_stdin_paths(const char *prefix, int cnt,
	struct git_attr_check *check)
{
	struct strbuf buf = STRBUF_INIT;
	struct strbuf unquoted = STRBUF_INIT;
	strbuf_getline_fn getline_fn;

	getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
	while (getline_fn(&buf, stdin) != EOF) {
		if (!nul_term_line && buf.buf[0] == '"') {
			strbuf_reset(&unquoted);
			if (unquote_c_style(&unquoted, buf.buf, NULL))
				die("line is badly quoted");
			strbuf_swap(&buf, &unquoted);
		}
		check_attr(prefix, cnt, check, buf.buf);
		maybe_flush_or_die(stdout, "attribute to stdout");
	}
	strbuf_release(&buf);
	strbuf_release(&unquoted);
}
static CK_RV
sc_pkcs11_secret_key_get_attribute(struct sc_pkcs11_session *session,
                                   void *object, CK_ATTRIBUTE_PTR attr)
{
    struct pkcs11_secret_key *key;

    key = (struct pkcs11_secret_key *) object;
    switch (attr->type) {
    case CKA_CLASS:
        get_attr(attr, CK_OBJECT_CLASS, CKO_SECRET_KEY);
        break;
    case CKA_KEY_TYPE:
        get_attr(attr, CK_KEY_TYPE, key->type);
    case CKA_VALUE:
        check_attr(attr, key->value_len);
        memcpy(attr->pValue, key->value, key->value_len);
        break;
    case CKA_VALUE_LEN:
        get_attr(attr, CK_ULONG, key->value_len);
        break;
    case CKA_SENSITIVE:
    case CKA_SIGN:
    case CKA_VERIFY:
    case CKA_WRAP:
    case CKA_UNWRAP:
    case CKA_NEVER_EXTRACTABLE:
        get_attr(attr, CK_BBOOL, 0);
        break;
    case CKA_ENCRYPT:
    case CKA_DECRYPT:
    case CKA_EXTRACTABLE:
    case CKA_ALWAYS_SENSITIVE:
        get_attr(attr, CK_BBOOL, 1);
        break;
    default:
        return CKR_ATTRIBUTE_TYPE_INVALID;
    }
    return CKR_OK;
}
示例#7
0
int cmd_check_attr(int argc, const char **argv, const char *prefix)
{
    struct git_attr_check *check;
    int cnt, i, doubledash, filei;

    argc = parse_options(argc, argv, prefix, check_attr_options,
                         check_attr_usage, PARSE_OPT_KEEP_DASHDASH);

    if (read_cache() < 0) {
        die("invalid cache");
    }

    if (cached_attrs)
        git_attr_set_direction(GIT_ATTR_INDEX, NULL);

    doubledash = -1;
    for (i = 0; doubledash < 0 && i < argc; i++) {
        if (!strcmp(argv[i], "--"))
            doubledash = i;
    }

    /* Process --all and/or attribute arguments: */
    if (all_attrs) {
        if (doubledash >= 1)
            error_with_usage("Attributes and --all both specified");

        cnt = 0;
        filei = doubledash + 1;
    } else if (doubledash == 0) {
        error_with_usage("No attribute specified");
    } else if (doubledash < 0) {
        if (!argc)
            error_with_usage("No attribute specified");

        if (stdin_paths) {
            /* Treat all arguments as attribute names. */
            cnt = argc;
            filei = argc;
        } else {
            /* Treat exactly one argument as an attribute name. */
            cnt = 1;
            filei = 1;
        }
    } else {
        cnt = doubledash;
        filei = doubledash + 1;
    }

    /* Check file argument(s): */
    if (stdin_paths) {
        if (filei < argc)
            error_with_usage("Can't specify files with --stdin");
    } else {
        if (filei >= argc)
            error_with_usage("No file specified");
    }

    if (all_attrs) {
        check = NULL;
    } else {
        check = xcalloc(cnt, sizeof(*check));
        for (i = 0; i < cnt; i++) {
            const char *name;
            struct git_attr *a;
            name = argv[i];
            a = git_attr(name);
            if (!a)
                return error("%s: not a valid attribute name",
                             name);
            check[i].attr = a;
        }
    }

    if (stdin_paths)
        check_attr_stdin_paths(prefix, cnt, check);
    else {
        for (i = filei; i < argc; i++)
            check_attr(prefix, cnt, check, argv[i]);
        maybe_flush_or_die(stdout, "attribute to stdout");
    }
    return 0;
}
示例#8
0
int cmd_check_attr(int argc, const char **argv, const char *prefix)
{
	struct attr_check *check;
	int cnt, i, doubledash, filei;

	if (!is_bare_repository())
		setup_work_tree();

	git_config(git_default_config, NULL);

	argc = parse_options(argc, argv, prefix, check_attr_options,
			     check_attr_usage, PARSE_OPT_KEEP_DASHDASH);

	if (read_cache() < 0) {
		die("invalid cache");
	}

	if (cached_attrs)
		git_attr_set_direction(GIT_ATTR_INDEX, NULL);

	doubledash = -1;
	for (i = 0; doubledash < 0 && i < argc; i++) {
		if (!strcmp(argv[i], "--"))
			doubledash = i;
	}

	/* Process --all and/or attribute arguments: */
	if (all_attrs) {
		if (doubledash >= 1)
			error_with_usage("Attributes and --all both specified");

		cnt = 0;
		filei = doubledash + 1;
	} else if (doubledash == 0) {
		error_with_usage("No attribute specified");
	} else if (doubledash < 0) {
		if (!argc)
			error_with_usage("No attribute specified");

		if (stdin_paths) {
			/* Treat all arguments as attribute names. */
			cnt = argc;
			filei = argc;
		} else {
			/* Treat exactly one argument as an attribute name. */
			cnt = 1;
			filei = 1;
		}
	} else {
		cnt = doubledash;
		filei = doubledash + 1;
	}

	/* Check file argument(s): */
	if (stdin_paths) {
		if (filei < argc)
			error_with_usage("Can't specify files with --stdin");
	} else {
		if (filei >= argc)
			error_with_usage("No file specified");
	}

	check = attr_check_alloc();
	if (!all_attrs) {
		for (i = 0; i < cnt; i++) {
			const struct git_attr *a = git_attr(argv[i]);

			if (!a)
				return error("%s: not a valid attribute name",
					     argv[i]);
			attr_check_append(check, a);
		}
	}

	if (stdin_paths)
		check_attr_stdin_paths(prefix, check, all_attrs);
	else {
		for (i = filei; i < argc; i++)
			check_attr(prefix, check, all_attrs, argv[i]);
		maybe_flush_or_die(stdout, "attribute to stdout");
	}

	attr_check_free(check);
	return 0;
}
示例#9
0
QString obout( QObject *w) {
  QString attr; // return value

  QString wname = w->objectName();
  QString wtype = w->metaObject()->className();
  //qDebug() << wname << wtype;

  if (OUTXML) {
    //printf("<%s>\n", wname.replace(' ','_').toAscii().data());
    jxout += "<" + wname.replace(' ','_') + " >\n";
    return wname;
  }

  QString outname;
/* eliminate cruft */
  if (wname.startsWith("qt_")) {
  } else if (wname.isNull()) {
    if (wtype == "QWidget") {
    } else if (wtype == "QSplitterHandle") {
    } else if (wtype == "QTextControl") {
    } else if (wtype == "QVBoxLayout") {
    } else if (wtype == "QAction") {
    }

  } else if (wname == "VSplitter") {
    outname = wname;
    attr = " ";
  } else if (wname == "HSplitter") {
    outname = wname;
    attr = " ";
  } else if (wname == "MenuBar") {
    outname = wname;
    attr = " ";
  } else if (wname == "MenuItem") {
    outname = wname;
    attr = " ";
  } else if (wname == "Navigator") {
    outname = wname;
    attr = " ";
  } else if (wname == "Widget") {
    outname = wname;
    attr = " ";
  } else if (wname == "OpenGLContext") {
    outname = wname;
    attr = " ";
  } else if (wtype == "QMenu") {
    outname = "MenuItem";
    attr = "label: "; attr.append('"'); attr.append(wname); attr.append('"');
  } else if (wtype == "QAction") {
    outname = "MenuItem";
    attr = "label: "; attr.append('"'); attr.append(wname); attr.append('"');
    QString check = check_attr((QAction *)w);
    if (!check.isNull()) attr.append(","+check);
  } else if (wtype == "JXAction") {
    outname = "MenuItem";
    attr = "label: "; attr.append('"'); attr.append(wname); attr.append('"');
    QString cback = callback_attr((JXAction *)w);
    if (!cback.isNull()) attr.append(","+cback);
    QString check = check_attr((QAction *)w);
    if (!check.isNull()) attr.append(","+check);
  } else {
    attr = " ";
  }

  if (!outname.isNull()) {
    //printf("(%s [\n", outname.toAscii().data());
    jxout += "( " + outname + " [\n";
  }
  return attr;

}