5 #include "string/string.h"
7 // Comparaison function for version numbers
8 // Implementation is based on dpkg's version comparison code (verrevcmp() and order())
9 // http://anonscm.debian.org/gitweb/?p=dpkg/dpkg.git;a=blob;f=lib/dpkg/version.c;hb=74946af470550a3295e00cf57eca1747215b9311
10 inline int char_weight(char c){
13 else if (std::isalpha(c))
23 inline int DpkPakVersionCmp(const char* a, const char* b){
27 while ((*a && !std::isdigit(*a)) || (*b && !std::isdigit(*b))) {
28 int ac = char_weight(*a);
29 int bc = char_weight(*b);
43 while (std::isdigit(*a) && std::isdigit(*b)) {
61 // release strings after using
62 inline bool DpkReadDepsLine( const char *line, char **pakname, char **pakversion ){
65 const char* p_name_end;
66 const char* p_version;
67 const char* p_version_end;
72 while ( std::isspace( *c ) && *c != '\0' ) ++c;
74 while ( !std::isspace( *c ) && *c != '\0' ) ++c;
76 while ( std::isspace( *c ) && *c != '\0' ) ++c;
78 while ( !std::isspace( *c ) && *c != '\0' ) ++c;
81 if ( p_name_end - p_name > 0 ){
82 *pakname = string_clone_range( StringRange( p_name, p_name_end ) );
85 if ( p_version_end - p_version > 0 ) {
86 *pakversion = string_clone_range( StringRange( p_version, p_version_end ) );