Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/misc/uint.c # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / misc / uint.c` 92 lines ยท 2550 bytes Raw Blame History 1 /* 2 ** 2020-04-14 3 ** 4 ** The author disclaims copyright to this source code. In place of 5 ** a legal notice, here is a blessing: 6 ** 7 ** May you do good and not evil. 8 ** May you find forgiveness for yourself and forgive others. 9 ** May you share freely, never taking more than you give. 10 ** 11 ****************************************************************************** 12 ** 13 ** This SQLite extension implements the UINT collating sequence. 14 ** 15 ** UINT works like BINARY for text, except that embedded strings 16 ** of digits compare in numeric order. 17 ** 18 ** * Leading zeros are handled properly, in the sense that 19 ** they do not mess of the magnitude comparison of embedded 20 ** strings of digits. "x00123y" is equal to "x123y". 21 ** 22 ** * Only unsigned integers are recognized. Plus and minus 23 ** signs are ignored. Decimal points and exponential notation 24 ** are ignored. 25 ** 26 ** * Embedded integers can be of arbitrary length. Comparison 27 ** is *not* limited integers that can be expressed as a 28 ** 64-bit machine integer. 29 */ 30 #include "sqlite3ext.h" 31 SQLITE_EXTENSION_INIT1 32 #include 33 #include 34 #include 35 36 /* 37 ** Compare text in lexicographic order, except strings of digits 38 ** compare in numeric order. 39 */ 40 static int uintCollFunc( 41 void *notUsed, 42 int nKey1, const void *pKey1, 43 int nKey2, const void *pKey2 44 ){ 45 const unsigned char *zA = (const unsigned char*)pKey1; 46 const unsigned char *zB = (const unsigned char*)pKey2; 47 int i=0, j=0, x; 48 (void)notUsed; 49 while( i