All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] adapted to latest opkg upstream for version compare
@ 2012-04-10 13:44 Lianhao Lu
  2012-04-10 13:44 ` [PATCH 1/1] opkg-compare-versions: Adapted to the latest opkg upstream Lianhao Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Lianhao Lu @ 2012-04-10 13:44 UTC (permalink / raw)
  To: yocto

NOTE: this patch is for opkg-utils upstream.

Modified the C version of opkg-compare-version to adapt to the latest opkg upstream.

This is part of the 1.2 bug fixing [YOCTO #2233].

The following changes since commit 002d29bc605d7c2d02e4cf20a43c5277c15f5597:
  Tick Chen (1):
        [opkg-utils] fix install fail problem      Thanks for khorben's patch :-)      https://docs.openmoko.org/trac/attachment/ticket/2072/patch-opkg-utils_Makefile_install_path.diff

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib llu/opkg-utils
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=llu/opkg-utils

Lianhao Lu (1):
  opkg-compare-versions: Adapted to the latest opkg upstream.

 opkg-compare-versions.c |   55 +++++++++++++++++++++-------------------------
 1 files changed, 25 insertions(+), 30 deletions(-)



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] opkg-compare-versions: Adapted to the latest opkg upstream.
  2012-04-10 13:44 [PATCH 0/1] adapted to latest opkg upstream for version compare Lianhao Lu
@ 2012-04-10 13:44 ` Lianhao Lu
  0 siblings, 0 replies; 2+ messages in thread
From: Lianhao Lu @ 2012-04-10 13:44 UTC (permalink / raw)
  To: yocto

Adapted to the latest opkg upstream implemenation for comparing
versions.

This is part of the bug fixing [YOCTO #2233].

Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
---
 opkg-compare-versions.c |   55 +++++++++++++++++++++-------------------------
 1 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/opkg-compare-versions.c b/opkg-compare-versions.c
index d5133fa..62851fa 100644
--- a/opkg-compare-versions.c
+++ b/opkg-compare-versions.c
@@ -31,43 +31,38 @@ struct versionrevision {
   const char *revision;
 };  
 
-static int verrevcmp(const char *val, const char *ref) 
-{
-  int vc, rc;
-  long vl, rl;
-  const char *vp, *rp;
-  const char *vsep, *rsep;
-
+/* assume ascii; warning: evaluates x multiple times! */
+#define order(x) ((x) == '~' ? -1 \
+		: isdigit((x)) ? 0 \
+		: !(x) ? 0 \
+		: isalpha((x)) ? (x) \
+		: (x) + 256)
+
+static int
+verrevcmp(const char *val, const char *ref) {
   if (!val) val= "";
   if (!ref) ref= "";
-  for (;;) {
-    vp= val;  while (*vp && !isdigit(*vp)) vp++;
-    rp= ref;  while (*rp && !isdigit(*rp)) rp++;
-    for (;;) {
-      vc= val == vp ? 0 : *val++;
-      rc= ref == rp ? 0 : *ref++;
-      if (!rc && !vc) break;
-      if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
-      if (rc && !isalpha(rc)) rc += 256;
+
+  while (*val || *ref) {
+    int first_diff= 0;
+
+    while ( (*val && !isdigit(*val)) || (*ref && !isdigit(*ref)) ) {
+      int vc= order(*val), rc= order(*ref);
       if (vc != rc) return vc - rc;
+      val++; ref++;
     }
-    val= vp;
-    ref= rp;
-    vl=0;  if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
-    rl=0;  if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
-    if (vl != rl) return vl - rl;
-
-    vc = *val;
-    rc = *ref;
-    vsep = strchr(".-", vc);
-    rsep = strchr(".-", rc);
-    if (vsep && !rsep) return -1;
-    if (!vsep && rsep) return +1;
-
-    if (!*val && !*ref) return 0;
-    if (!*val) return -1;
-    if (!*ref) return +1;
+
+    while ( *val == '0' ) val++;
+    while ( *ref == '0' ) ref++;
+    while (isdigit(*val) && isdigit(*ref)) {
+      if (!first_diff) first_diff= *val - *ref;
+      val++; ref++;
+    }
+    if (isdigit(*val)) return 1;
+    if (isdigit(*ref)) return -1;
+    if (first_diff) return first_diff;
   }
+  return 0;
 }
 
 int versioncompare(const struct versionrevision *version,
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-10 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-10 13:44 [PATCH 0/1] adapted to latest opkg upstream for version compare Lianhao Lu
2012-04-10 13:44 ` [PATCH 1/1] opkg-compare-versions: Adapted to the latest opkg upstream Lianhao Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.