On Thu, Jul 13, 2017 at 12:17:40PM -0300, Eduardo Habkost wrote: > > > Oh right. So you need to find dots and split at these points. > > > Something like the below? Completely untested. > > > > > > int mstcmp(const char *s1, const char *s2) > > > { > > > const char *e1, *e2; > > > int l1, l2, c; > > > > > > do { > > > e1 = strchr(s1, '.'); > > > e2 = strchr(s2, '.'); > > > > > > l1 = e1 ? e1 - s1 + 1 : strlen(s1); > > > l2 = e2 ? e2 - s2 + 1 : strlen(s2); > > > > > > /* compare numerically: shorter strings give smaller numbers */ > > > if (l1 != l2) { > > > break; > > > } > > > c = strncmp(s1, s2, l1); > > > if (c) { > > > return c; > > > } > > > s1 += l1; > > > s2 += l1; > > > } while (l1); > > > > > > return l1 - l2; > > > } > > I believe copying strverscmp() from gnulib as-is is better than > reimplementing a subset of it.
I would then probably copy it unconditionally. > > -- > Eduardo