Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Add circumflex handling #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion rpm_vercmp/vercmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


class Vercmp(object):
R_NONALNUMTILDE = re.compile(br"^([^a-zA-Z0-9~]*)(.*)$")
R_NONALNUMTILDE = re.compile(br"^([^a-zA-Z0-9~^]*)(.*)$")
R_NUM = re.compile(br"^([\d]+)(.*)$")
R_ALPHA = re.compile(br"^([a-zA-Z]+)(.*)$")

Expand All @@ -46,6 +46,17 @@ def compare(cls, first, second):
if second.startswith(b'~'):
return 1

# handle the circumflex separator
if first.startswith(b'^'):
if second.startswith(b'^'):
first, second = first[1:], second[1:]
continue
first = first[1:]
return -1 if second else 1
if second.startswith(b'^'):
second = second[1:]
return 1 if first else -1

# If we ran to the end of either, we are finished with the loop
if not first or not second:
break
Expand Down