Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Sync libucl, and allow PKG_NAME to be an integer that fixes: (games/54321)
Baptiste Daroussin committed 12 years ago
commit 89bd3f32df04f06e2b6c60f2d388327b04643ef0
parent 852a548
3 files changed +12 -5
modified external/libucl/src/ucl_parser.c
@@ -274,7 +274,7 @@ ucl_maybe_parse_number (ucl_object_t *obj,
{
	const char *p = start, *c = start;
	char *endptr;
-
	bool got_dot = false, got_exp = false, need_double = false, is_date = false;
+
	bool got_dot = false, got_exp = false, need_double = false, is_date = false, valid_start = false;
	double dv;
	int64_t lv;

@@ -283,6 +283,7 @@ ucl_maybe_parse_number (ucl_object_t *obj,
	}
	while (p < end) {
		if (isdigit (*p)) {
+
			valid_start = true;
			p ++;
		}
		else if (allow_double) {
@@ -337,6 +338,11 @@ ucl_maybe_parse_number (ucl_object_t *obj,
		}
	}

+
	if (!valid_start) {
+
		*pos = start;
+
		return EINVAL;
+
	}
+

	errno = 0;
	if (need_double) {
		dv = strtod (c, &endptr);
@@ -355,7 +361,7 @@ ucl_maybe_parse_number (ucl_object_t *obj,
		goto set_obj;
	}

-
	if (endptr < end) {
+
	if (endptr < end && endptr != start) {
		p = endptr;
		switch (*p) {
		case 'm':
modified libpkg/pkg_manifest.c
@@ -95,6 +95,7 @@ static struct manifest_key {
	{ "maintainer",          PKG_MAINTAINER,          UCL_STRING, pkg_string},
	{ "message",             PKG_MESSAGE,             UCL_STRING, pkg_string},
	{ "name",                PKG_NAME,                UCL_STRING, pkg_string},
+
	{ "name",                PKG_NAME,                UCL_INT, pkg_int},
	{ "options",             PKG_OPTIONS,             UCL_STRING, pkg_object},
	{ "option_defaults",     PKG_OPTION_DEFAULTS,     UCL_STRING, pkg_object},
	{ "option_descriptions", PKG_OPTION_DESCRIPTIONS, UCL_STRING, pkg_object},
@@ -297,7 +298,7 @@ static int
pkg_int(struct pkg *pkg, ucl_object_t *obj, int attr)
{
	char vint[BUFSIZ];
-
	if (attr == PKG_VERSION) {
+
	if (attr == PKG_VERSION || attr == PKG_NAME) {
		snprintf(vint, sizeof(vint), "%"PRId64, ucl_object_toint(obj));
		return (pkg_set(pkg, attr, vint));
	}
modified libpkg/utils.c
@@ -497,7 +497,7 @@ yaml_sequence_to_object(ucl_object_t *obj, yaml_document_t *doc, yaml_node_t *no
			break;
		case YAML_SCALAR_NODE:
			sub = ucl_object_fromstring_common (val->data.scalar.value,
-
			    val->data.scalar.length, UCL_STRING_TRIM|UCL_STRING_PARSE_BOOLEAN);
+
			    val->data.scalar.length, UCL_STRING_TRIM|UCL_STRING_PARSE_BOOLEAN|UCL_STRING_PARSE_INT);
			break;
		case YAML_NO_NODE:
			/* Should not happen */
@@ -533,7 +533,7 @@ yaml_mapping_to_object(ucl_object_t *obj, yaml_document_t *doc, yaml_node_t *nod
		case YAML_SCALAR_NODE:
			sub = ucl_object_fromstring_common (val->data.scalar.value,
			    val->data.scalar.length,
-
			    UCL_STRING_TRIM|UCL_STRING_PARSE_BOOLEAN);
+
			    UCL_STRING_TRIM|UCL_STRING_PARSE_BOOLEAN|UCL_STRING_PARSE_INT);
			break;
		case YAML_NO_NODE:
			/* Should not happen */