This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug string/20524] New: strverscmp is inconsistent

            Bug ID: 20524
           Summary: strverscmp is inconsistent
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: string
          Assignee: unassigned at sourceware dot org
          Reporter: peda at lysator dot
  Target Milestone: ---

Consider this program:

#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>

int main(void)
        char *strs[] = {
        int i, j;

        for (i = 0; i < 6; ++i) {
                for (j = i + 1; j < 6; ++j) {
                        if (strverscmp(strs[i], strs[j]) < 0)
                        char *tmp = strs[i];
                        strs[i] = strs[j];
                        strs[j] = tmp;
                printf("%s\n", strs[i]);
        return 0;

I expected the strings to be pre-sorted, but the output is:


which is pretty useless. I don't really have an opinion which of 01
and 010 should be considered less, but the above is complete crap.

Since 000 is less than 00, maybe 010 should also be less than 01? But
that contradicts the ordering given in [1] which was what I started with.


You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]