bug-strcoll1.c 535 B

123456789101112131415161718192021222324
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <locale.h>
  4. int
  5. main (void)
  6. {
  7. const char t1[] = "0-0-0-0-0-0-0-0-0-0.COM";
  8. const char t2[] = "00000-00000.COM";
  9. int res1;
  10. int res2;
  11. setlocale (LC_ALL, "en_US.ISO-8859-1");
  12. res1 = strcoll (t1, t2);
  13. printf ("strcoll (\"%s\", \"%s\") = %d\n", t1, t2, res1);
  14. res2 = strcoll (t2, t1);
  15. printf ("strcoll (\"%s\", \"%s\") = %d\n", t2, t1, res2);
  16. return ((res1 == 0 && res2 != 0)
  17. || (res1 != 0 && res2 == 0)
  18. || (res1 < 0 && res2 < 0)
  19. || (res1 > 0 && res2 > 0));
  20. }