comparison ueda/mclutils/seqrefdes.c @ 81:6e43956e740d

beginning of BOM utils refactoring: seqrefdes code factored out
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 23 Feb 2017 19:15:48 +0000
parents
children
comparison
equal deleted inserted replaced
80:df98a82b807e 81:6e43956e740d
1 /*
2 * Detection of sequential reference designators
3 * for the tallying of refdes lists in BOM outputs
4 */
5
6 #include <ctype.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9
10 static
11 is_string_num(str)
12 char *str;
13 {
14 if (*str < '1' || *str > '9')
15 return(0);
16 while (isdigit(*str))
17 str++;
18 if (*str)
19 return(0);
20 else
21 return(1);
22 }
23
24 is_refdes_sequential(str1, str2)
25 char *str1, *str2;
26 {
27 int num1, num2;
28
29 while (isupper(*str1))
30 if (*str1++ != *str2++)
31 return(0);
32 if (!is_string_num(str1) || !is_string_num(str2))
33 return(0);
34 num1 = atoi(str1);
35 num2 = atoi(str2);
36 if (num2 == num1 + 1)
37 return(1);
38 else
39 return(0);
40 }