diff options
Diffstat (limited to 'gcc/config/avr/gen-avr-mmcu-texi.c')
-rw-r--r-- | gcc/config/avr/gen-avr-mmcu-texi.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/gcc/config/avr/gen-avr-mmcu-texi.c b/gcc/config/avr/gen-avr-mmcu-texi.c index f4cb24e28..d5567e709 100644 --- a/gcc/config/avr/gen-avr-mmcu-texi.c +++ b/gcc/config/avr/gen-avr-mmcu-texi.c @@ -18,18 +18,52 @@ along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ +#include <stdlib.h> +#include <stdio.h> + +#define IN_GEN_AVR_MMCU_TEXI + +#include "avr-arch.h" #include "avr-devices.c" static const char* mcu_name[sizeof avr_mcu_types / sizeof avr_mcu_types[0]]; +static int letter (char c) +{ + return c >= 'a' && c <= 'z'; +} + +static int digit (char c) +{ + return c >= '0' && c <= '9'; +} + static int comparator (const void *va, const void *vb) { - const char* const *a = (const char* const*) va; - const char* const *b = (const char* const*) vb; + const char *a = *(const char* const*) va; + const char *b = *(const char* const*) vb; + + while (*a && *b) + { + /* Make letters smaller than digits so that `atmega16a' follows + `atmega16' without `atmega161' etc. between them. */ + + if (letter (*a) && digit (*b)) + return -1; + + if (digit (*a) && letter (*b)) + return 1; + + if (*a != *b) + return *a - *b; + + a++; + b++; + } - return strcmp (*a, *b); + return *a - *b; } static void @@ -61,6 +95,7 @@ int main (void) printf ("@c This file is generated automatically using\n"); printf ("@c gcc/config/avr/gen-avr-mmcu-texi.c from:\n"); + printf ("@c gcc/config/avr/avr-arch.h\n"); printf ("@c gcc/config/avr/avr-devices.c\n"); printf ("@c gcc/config/avr/avr-mcus.def\n\n"); |