mandriva

Ticket #66 (assigned task)

Opened 2 years ago

Last modified 3 months ago

Introduce a python func to compute a version "weigth" in order to sort software on their versions

Reported by: nrueff Owned by: nrueff
Priority: Low Milestone: 1.4.0
Component: python-mmc-glpi Version:
Severity: Major Keywords:
Cc:

Description

Taken from dpkg --compare-versions:

static int verrevcmp(const char *val, const char *ref) {
  if (!val) val= "";
  if (!ref) ref= "";

  while (*val || *ref) {
    int first_diff= 0;

    while ( (*val && !cisdigit(*val)) || (*ref && !cisdigit(*ref)) ) {
      int vc= order(*val), rc= order(*ref);
      if (vc != rc) return vc - rc;
      val++; ref++;
    }

    while ( *val == '0' ) val++;
    while ( *ref == '0' ) ref++;
    while (cisdigit(*val) && cisdigit(*ref)) {
      if (!first_diff) first_diff= *val - *ref;
      val++; ref++;
    }
    if (cisdigit(*val)) return 1;
    if (cisdigit(*ref)) return -1;
    if (first_diff) return first_diff;
  }
  return 0;
}

--compare-versions ver1 op ver2

Compare version numbers, where op is a binary operator. dpkg returns success (zero result) if the specified condition is satisfied, and failure (nonzero result) otherwise. There are two groups of operators, which differ in how they treat an empty ver1 or ver2. These treat an empty version as earlier than any version: lt le eq ne ge gt. These treat an empty version as later than any ver-sion: lt-nl le-nl ge-nl gt-nl. These are provided only for compatibility with control file syntax: < << <= = >= >> >.

Attachments

Change History

Changed 2 years ago by nrueff

  • owner changed from oroussy to nrueff
  • priority changed from major to minor
  • status changed from new to assigned

Changed 2 years ago by dchrisment

  • version 1.0.0rc2 deleted
  • milestone set to 1.2.0

Changed 2 years ago by dchrisment

  • milestone changed from 1.2.0 to 1.3.0

Changed 3 months ago by nrueff

  • milestone changed from 1.3.0 to 1.4.0

Add/Change #66 (Introduce a python func to compute a version "weigth" in order to sort software on their versions)

Author



Action
as assigned
 
Note: See TracTickets for help on using tickets.