Add build-many-glibcs.py arm-linux-gnueabihf-v7{-disable-multiarch}
[glibc.git] / string / tst-svc.c
blobd5cf2c19c9ba048f81a147fe3ab2d87201f93aac
1 /* Test for strverscmp() */
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <string.h>
7 #define MAX_STRINGS 256
8 #define MAX_LINE_SIZE 32
10 static int
11 compare (const void *p1, const void *p2)
13 return strverscmp (*((char **) p1), *((char **) p2));
16 int
17 do_test (void)
19 char line[MAX_LINE_SIZE + 1];
20 char *str[MAX_STRINGS];
21 int count = 0;
22 int i, n;
24 while (count < MAX_STRINGS && fgets (line, MAX_LINE_SIZE, stdin) != NULL)
26 n = strlen (line) - 1;
28 if (line[n] == '\n')
29 line[n] = '\0';
31 str[count] = strdup (line);
33 if (str[count] == NULL)
34 exit (EXIT_FAILURE);
36 ++count;
39 qsort (str, count, sizeof (char *), compare);
41 for (i = 0; i < count; ++i)
42 puts (str[i]);
44 return EXIT_SUCCESS;
47 #include <support/test-driver.c>