mailing list of musl libc
 help / color / mirror / code / Atom feed
8f3f11f01439e233b7ac5dade2875069b8946c04 blob 712 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
#define _GNU_SOURCE
#include <ctype.h>
#include <string.h>

int strverscmp(const char *l, const char *r)
{
	int haszero=1;
	while (*l && *r && l[0]==r[0]){
		if (l[0]=='0'){
			if (haszero==1) {
				haszero=0;
			}
		} else if (isdigit(l[0])) {
			if (haszero==1) {
				haszero=2;
			}
		} else {
			haszero=1;
		}
		l++; r++;
	}
	if (haszero==1 && (l[0]=='0' || r[0]=='0')) {
		haszero=0;
	}
	if ((isdigit(l[0]) && isdigit(r[0]) ) && haszero) {
		int lenl=0, lenr=0, firstl=l[0], firstr=r[0];
		while (isdigit(l++[0]) ) {
			lenl++;
		}
		while (isdigit(r++[0]) ) {
			lenr++;
		}
		if (lenl==lenr) {
			return (firstl -  firstr);
		} else {
			return (lenl - lenr);
		}
	} else {
		return (l[0] -  r[0]);
	}
}
debug log:

solving 8f3f11f ...
found 8f3f11f in https://inbox.vuxu.org/musl/20130201200452.26687bed.idunham@lavabit.com/ ||
	https://inbox.vuxu.org/musl/20121231124952.87eaca31.idunham@lavabit.com/
found 7054967 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 7054967837f895301d5472ec9303ff63905db6ed	src/string/strverscmp.c

applying [1/2] https://inbox.vuxu.org/musl/20130201200452.26687bed.idunham@lavabit.com/
diff --git a/src/string/strverscmp.c b/src/string/strverscmp.c
index 7054967..8f3f11f 100644

Checking patch src/string/strverscmp.c...
Applied patch src/string/strverscmp.c cleanly.

skipping https://inbox.vuxu.org/musl/20121231124952.87eaca31.idunham@lavabit.com/ for 8f3f11f
index at:
100644 8f3f11f01439e233b7ac5dade2875069b8946c04	src/string/strverscmp.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).