annotate ueda/mclutils/seqrefdes.c @ 128:e90e948e9368

m4-fp: SRAM_TSOPII_44 footprint added
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 16 Jul 2020 18:23:22 +0000
parents 6e43956e740d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
81
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Detection of sequential reference designators
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * for the tallying of refdes lists in BOM outputs
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <ctype.h>
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 static
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 is_string_num(str)
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 char *str;
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 if (*str < '1' || *str > '9')
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 return(0);
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 while (isdigit(*str))
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 str++;
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (*str)
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 return(0);
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 else
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 return(1);
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 }
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 is_refdes_sequential(str1, str2)
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 char *str1, *str2;
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 {
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 int num1, num2;
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 while (isupper(*str1))
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 if (*str1++ != *str2++)
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 return(0);
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 if (!is_string_num(str1) || !is_string_num(str2))
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 return(0);
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 num1 = atoi(str1);
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 num2 = atoi(str2);
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (num2 == num1 + 1)
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 return(1);
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 else
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 return(0);
6e43956e740d beginning of BOM utils refactoring: seqrefdes code factored out
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }