Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add docs and tests for the TH1 'string index' command added by check-in [0c57ba3eb4]. Also, fix issue with handling of the special 'end' index. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
e9845e590456d23b168ec24ecdacf4e0 |
| User & Date: | mistachkin 2017-10-02 15:23:48.474 |
Context
|
2017-10-02
| ||
| 16:25 | Avoid large SQL inserts when computing the path between two check-ins for use by reverse annotation. ... (check-in: 5eba557c22 user: drh tags: trunk) | |
| 15:23 | Add docs and tests for the TH1 'string index' command added by check-in [0c57ba3eb4]. Also, fix issue with handling of the special 'end' index. ... (check-in: e9845e5904 user: mistachkin tags: trunk) | |
| 12:22 | More fixes to reverse annotation via the /fdiff page. It is closer, but it is still not right. ... (check-in: 08cacbf6e5 user: drh tags: trunk) | |
Changes
Changes to src/th_lang.c.
| ︙ | ︙ | |||
729 730 731 732 733 734 735 |
int iIndex;
if( argc!=4 ){
return Th_WrongNumArgs(interp, "string index string index");
}
if( argl[3]==3 && 0==memcmp("end", argv[3], 3) ){
| | | 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 |
int iIndex;
if( argc!=4 ){
return Th_WrongNumArgs(interp, "string index string index");
}
if( argl[3]==3 && 0==memcmp("end", argv[3], 3) ){
iIndex = argl[2]-1;
}else if( Th_ToInt(interp, argv[3], argl[3], &iIndex) ){
Th_ErrorMessage(
interp, "Expected \"end\" or integer, got:", argv[3], argl[3]);
return TH_ERROR;
}
if( iIndex>=0 && iIndex<argl[2] ){
|
| ︙ | ︙ |
Changes to test/th1.test.
| ︙ | ︙ | |||
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 |
fossil test-th-eval {string is integer 0xC0DEF00D}
test th1-string-is-30 {$RESULT eq "1"}
###############################################################################
fossil test-th-eval {string is integer 0xC0DEF00Z}
test th1-string-is-31 {$RESULT eq "0"}
###############################################################################
fossil test-th-eval {markdown}
test th1-markdown-1 {$RESULT eq \
{TH_ERROR: wrong # args: should be "markdown STRING"}}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 |
fossil test-th-eval {string is integer 0xC0DEF00D}
test th1-string-is-30 {$RESULT eq "1"}
###############################################################################
fossil test-th-eval {string is integer 0xC0DEF00Z}
test th1-string-is-31 {$RESULT eq "0"}
###############################################################################
fossil test-th-eval {string index "" -1}
test th1-string-index-1 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index "" 0}
test th1-string-index-2 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index "" 1}
test th1-string-index-3 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index "" 2}
test th1-string-index-4 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index "" end}
test th1-string-index-5 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index A -1}
test th1-string-index-6 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index A 0}
test th1-string-index-7 {$RESULT eq "A"}
###############################################################################
fossil test-th-eval {string index A 1}
test th1-string-index-8 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index A 2}
test th1-string-index-9 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index A end}
test th1-string-index-10 {$RESULT eq "A"}
###############################################################################
fossil test-th-eval {string index ABC -1}
test th1-string-index-11 {$RESULT eq ""}
###############################################################################
fossil test-th-eval {string index ABC 0}
test th1-string-index-12 {$RESULT eq "A"}
###############################################################################
fossil test-th-eval {string index ABC 1}
test th1-string-index-13 {$RESULT eq "B"}
###############################################################################
fossil test-th-eval {string index ABC 2}
test th1-string-index-14 {$RESULT eq "C"}
###############################################################################
fossil test-th-eval {string index ABC end}
test th1-string-index-15 {$RESULT eq "C"}
###############################################################################
fossil test-th-eval {markdown}
test th1-markdown-1 {$RESULT eq \
{TH_ERROR: wrong # args: should be "markdown STRING"}}
|
| ︙ | ︙ |
Changes to www/th1.md.
| ︙ | ︙ | |||
103 104 105 106 107 108 109 110 111 112 113 114 115 116 | * lsearch LIST STRING * proc NAME ARG-LIST BODY-SCRIPT * rename OLD NEW * return ?-code CODE? ?VALUE? * set VARNAME VALUE * string compare STR1 STR2 * string first NEEDLE HAYSTACK ?START-INDEX? * string is CLASS STRING * string last NEEDLE HAYSTACK ?START-INDEX? * string length STRING * string range STRING FIRST LAST * string repeat STRING COUNT * unset VARNAME * uplevel ?LEVEL? SCRIPT | > | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | * lsearch LIST STRING * proc NAME ARG-LIST BODY-SCRIPT * rename OLD NEW * return ?-code CODE? ?VALUE? * set VARNAME VALUE * string compare STR1 STR2 * string first NEEDLE HAYSTACK ?START-INDEX? * string index STRING INDEX * string is CLASS STRING * string last NEEDLE HAYSTACK ?START-INDEX? * string length STRING * string range STRING FIRST LAST * string repeat STRING COUNT * unset VARNAME * uplevel ?LEVEL? SCRIPT |
| ︙ | ︙ |