示例#1
0
int
parse_mapentry(char *line, size_t len, size_t lineno)
{
	DBT	 key;
	DBT	 val;
	char	*keyp;
	char	*valp;

	keyp = line;
	while (isspace((int)*keyp))
		keyp++;
	if (*keyp == '\0' || *keyp == '#')
		return 1;

	valp = keyp;
	strsep(&valp, " \t:");
	if (valp == NULL || valp == keyp)
		goto bad;
	while (*valp == ':' || isspace((int)*valp))
		valp++;
	if (*valp == '\0' || *valp == '#')
		goto bad;

	/* Check for dups. */
	key.data = keyp;
	key.size = strlen(keyp) + 1;

	xlowercase(key.data, key.data, strlen(key.data) + 1);
	if (db->get(db, &key, &val, 0) == 0) {
		warnx("%s:%zd: duplicate entry for %s", source, lineno, keyp);
		return 0;
	}

	if (type == T_PLAIN) {
		if (! make_plain(&val, valp))
			goto bad;
	}
	else if (type == T_ALIASES) {
		if (! make_aliases(&val, valp))
			goto bad;
	}

	if (db->put(db, &key, &val, 0) == -1) {
		warn("dbput");
		return 0;
	}

	dbputs++;

	free(val.data);

	return 1;

bad:
	warnx("%s:%zd: invalid entry", source, lineno);
	return 0;
}
示例#2
0
int main(int argc, char const *argv[])
{
	int t;
	char a[1000009];
	t = get_int();
	while(t--)
	{
		long long int length = get_line(a);
		if (length ==1)
		{
			printf("11\n");
			continue;
		}
		if(make_plain(a,length))
		{
			printf("%s\n", a);
			continue;
		}
		if (length%2)
		{
			bool tmp = incre_mid1(a,length/2,length);
			printf("%s", a);
			if (!tmp)
				printf("1");
			printf("\n");
		}
		else
		{
			bool tmp = incre_mid2(a,length/2 -1,length/2,length);
			printf("%s", a);
			if (!tmp)
				printf("1");
			printf("\n");
		}
	}
	return 0;
}