GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
STRVERSCMP(3) FreeBSD Library Functions Manual STRVERSCMP(3)

strverscmpcompare strings according to natural order

Standard C Library (libc, -lc)

#include <string.h>

int
strverscmp(const char *s1, const char *s2);

The () function compares the null-terminated strings s1 and s2 according to their natural order and returns an integer greater than, equal to, or less than 0, depending on whether s1 is greater than, equal to, or less than s2.

More specifically, this natural order is found by iterating over both strings until a difference is found. If the difference is between non-decimal characters, () acts like strcmp(3) (thus, the ordering would be "a", "b", "train"). If a decimal digit is found, the whole number is read and compared (thus, the ordering would be "9", "10", "420" which is different to lexicographic order, what strcmp(3) would have done). Numbers with leading zeroes are interpreted as fractional parts (even without a decimal point), and numbers with more leading zeroes are placed before numbers with fewer leading zeroes (thus, the ordering would be "000", "00", "01", "010", "09", "0", "1", "9", "10").

strcmp(3), versionsort(3)

The strverscmp() function is a GNU extension and conforms to no standard.

The strverscmp() function was added in FreeBSD 13.2.

August 31, 2023 FreeBSD 14.3-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.