view ueda/mclutils/seqrefdes.c @ 87:60f864a068d5

ifctf-part-lib/m4-fp/hirose.inc: FH12 series footprints created
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 26 Apr 2018 00:42:23 +0000
parents 6e43956e740d
children
line wrap: on
line source

/*
 * Detection of sequential reference designators
 * for the tallying of refdes lists in BOM outputs
 */

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>

static
is_string_num(str)
	char *str;
{
	if (*str < '1' || *str > '9')
		return(0);
	while (isdigit(*str))
		str++;
	if (*str)
		return(0);
	else
		return(1);
}

is_refdes_sequential(str1, str2)
	char *str1, *str2;
{
	int num1, num2;

	while (isupper(*str1))
		if (*str1++ != *str2++)
			return(0);
	if (!is_string_num(str1) || !is_string_num(str2))
		return(0);
	num1 = atoi(str1);
	num2 = atoi(str2);
	if (num2 == num1 + 1)
		return(1);
	else
		return(0);
}