#define USE_THE_REPOSITORY_VARIABLE #include "git-compat-util.h" #include "config.h" #include "strbuf.h" #include "string-list.h" #include "versioncmp.h" /* * versioncmp(): copied from string/strverscmp.c in glibc commit * ee9247c38a8def24a59eb5cfb7196a98bef8cfdc, reformatted to Git coding * style. The implementation is under LGPL-2.1 and Git relicenses it * to GPLv2. */ /* * states: S_N: normal, S_I: comparing integral part, S_F: comparing * fractionnal parts, S_Z: idem but with leading Zeroes only */ #define S_N … #define S_I … #define S_F … #define S_Z … /* result_type: CMP: return diff; LEN: compare using len_diff/diff */ #define CMP … #define LEN … static const struct string_list *prereleases; static int initialized; struct suffix_match { … }; static void find_better_matching_suffix(const char *tagname, const char *suffix, int suffix_len, int start, int conf_pos, struct suffix_match *match) { … } /* * off is the offset of the first different character in the two strings * s1 and s2. If either s1 or s2 contains a prerelease suffix containing * that offset or a suffix ends right before that offset, then that * string will be forced to be on top. * * If both s1 and s2 contain a (different) suffix around that position, * their order is determined by the order of those two suffixes in the * configuration. * If any of the strings contains more than one different suffixes around * that position, then that string is sorted according to the contained * suffix which starts at the earliest offset in that string. * If more than one different contained suffixes start at that earliest * offset, then that string is sorted according to the longest of those * suffixes. * * Return non-zero if *diff contains the return value for versioncmp() */ static int swap_prereleases(const char *s1, const char *s2, int off, int *diff) { … } /* * Compare S1 and S2 as strings holding indices/version numbers, * returning less than, equal to or greater than zero if S1 is less * than, equal to or greater than S2 (for more info, see the texinfo * doc). */ int versioncmp(const char *s1, const char *s2) { … }