mirror of
https://github.com/sqlite/sqlite.git
synced 2025-10-24 09:53:10 +03:00
Fix the SUBSTR() function so that when the 3rd argument is negative,
it counts backwards from the selected start point. Ticket #3625. (CVS 6227) FossilOrigin-Name: 2217339badf1e84edbed1309c39b9f8dfd7646ff
This commit is contained in:
10
src/func.c
10
src/func.c
@@ -16,7 +16,7 @@
|
||||
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
||||
** All other code has file scope.
|
||||
**
|
||||
** $Id: func.c,v 1.212 2009/02/01 18:08:41 drh Exp $
|
||||
** $Id: func.c,v 1.213 2009/02/01 19:23:32 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <stdlib.h>
|
||||
@@ -200,6 +200,14 @@ static void substrFunc(
|
||||
}else if( p1>0 ){
|
||||
p1--;
|
||||
}
|
||||
if( p2<0 ){
|
||||
p1 += p2;
|
||||
p2 = -p2;
|
||||
if( p1<0 ){
|
||||
p2 += p1;
|
||||
p1 = 0;
|
||||
}
|
||||
}
|
||||
if( p1+p2>len ){
|
||||
p2 = len-p1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user