view ueda/libueda/util.c @ 68:b7f49f029bc3

pads2gpcb: use Cartesian Y axis direction internally
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sun, 31 Jan 2016 23:19:37 +0000
parents c91e7a30fab3
children
line wrap: on
line source

/*
 * Miscellaneous utility functions for libueda
 */

#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>

char *
copystr(src)
	register char *src;
{
	register char *buf;

	buf = malloc(strlen(src) + 1);
	if (!buf) {
		perror("malloc");
		exit(1);
	}
	strcpy(buf, src);
	return(buf);
}

string_is_valid_decnum(str)
	char *str;
{
	register char *cp = str;

	if (*cp == '-')
		cp++;
	if (!isdigit(*cp))
		return(0);
	while (isdigit(*cp))
		cp++;
	return(*cp == '\0');
}