Fossil SCM
minor doc touch-ups and one s/cson_value_new_string/json_new_string/.
Commit
9cfe61e0bfa939e95a9323180e1f1680c2ac5ea2
Parent
ac8c1ad4bbbf31d…
1 file changed
+11
-7
+11
-7
| --- src/json.c | ||
| +++ src/json.c | ||
| @@ -1304,11 +1304,12 @@ | ||
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | /* |
| 1307 | 1307 | ** Convenience routine which converts a Julian time value into a Unix |
| 1308 | 1308 | ** Epoch timestamp. Requires the db, so this cannot be used before the |
| 1309 | -** repo is opened (will trigger a fatal error in db_xxx()). | |
| 1309 | +** repo is opened (will trigger a fatal error in db_xxx()). The returned | |
| 1310 | +** value is owned by the caller. | |
| 1310 | 1311 | */ |
| 1311 | 1312 | cson_value * json_julian_to_timestamp(double j){ |
| 1312 | 1313 | return cson_value_new_integer((cson_int_t) |
| 1313 | 1314 | db_int64(0,"SELECT cast(strftime('%%s',%lf) as int)",j) |
| 1314 | 1315 | ); |
| @@ -1318,14 +1319,16 @@ | ||
| 1318 | 1319 | ** Returns a timestamp value. |
| 1319 | 1320 | */ |
| 1320 | 1321 | cson_int_t json_timestamp(){ |
| 1321 | 1322 | return (cson_int_t)time(0); |
| 1322 | 1323 | } |
| 1324 | + | |
| 1323 | 1325 | /* |
| 1324 | 1326 | ** Returns a new JSON value (owned by the caller) representing |
| 1325 | 1327 | ** a timestamp. If timeVal is < 0 then time(0) is used to fetch |
| 1326 | -** the time, else timeVal is used as-is | |
| 1328 | +** the time, else timeVal is used as-is. The returned value is | |
| 1329 | +** owned by the caller. | |
| 1327 | 1330 | */ |
| 1328 | 1331 | cson_value * json_new_timestamp(cson_int_t timeVal){ |
| 1329 | 1332 | return cson_value_new_integer((timeVal<0) ? (cson_int_t)time(0) : timeVal); |
| 1330 | 1333 | } |
| 1331 | 1334 | |
| @@ -1504,11 +1507,12 @@ | ||
| 1504 | 1507 | cson_value_free(tmp); \ |
| 1505 | 1508 | tmp = NULL; \ |
| 1506 | 1509 | goto cleanup; \ |
| 1507 | 1510 | }while(0) |
| 1508 | 1511 | |
| 1509 | - tmp = cson_value_new_string(MANIFEST_UUID,strlen(MANIFEST_UUID)); | |
| 1512 | + | |
| 1513 | + tmp = json_new_string(MANIFEST_UUID); | |
| 1510 | 1514 | SET("fossil"); |
| 1511 | 1515 | |
| 1512 | 1516 | tmp = json_new_timestamp(-1); |
| 1513 | 1517 | SET(FossilJsonKeys.timestamp); |
| 1514 | 1518 | |
| @@ -1611,11 +1615,11 @@ | ||
| 1611 | 1615 | ** |
| 1612 | 1616 | ** If alsoOutput is true AND g.isHTTP then cgi_reply() is called to |
| 1613 | 1617 | ** flush the output (and headers). Generally only do this if you are |
| 1614 | 1618 | ** about to call exit(). |
| 1615 | 1619 | ** |
| 1616 | -** !g.isHTTP then alsoOutput is ignored and all output is sent to | |
| 1620 | +** If !g.isHTTP then alsoOutput is ignored and all output is sent to | |
| 1617 | 1621 | ** stdout immediately. |
| 1618 | 1622 | ** |
| 1619 | 1623 | ** For generating the resultText property: if msg is not NULL then it |
| 1620 | 1624 | ** is used as-is. If it is NULL then g.zErrMsg is checked, and if that |
| 1621 | 1625 | ** is NULL then json_err_cstr(code) is used. |
| @@ -1705,11 +1709,11 @@ | ||
| 1705 | 1709 | assert(NULL!=a); |
| 1706 | 1710 | } |
| 1707 | 1711 | if(!colNames){ |
| 1708 | 1712 | colNamesV = cson_sqlite3_column_names(pStmt->pStmt); |
| 1709 | 1713 | assert(NULL != colNamesV); |
| 1710 | - cson_value_add_reference(colNamesV); | |
| 1714 | + cson_value_add_reference(colNamesV)/*avoids an ownership problem*/; | |
| 1711 | 1715 | colNames = cson_value_get_array(colNamesV); |
| 1712 | 1716 | assert(NULL != colNames); |
| 1713 | 1717 | } |
| 1714 | 1718 | row = cson_sqlite3_row_to_object2(pStmt->pStmt, colNames); |
| 1715 | 1719 | if(!row && !warnMsg){ |
| @@ -1778,12 +1782,12 @@ | ||
| 1778 | 1782 | |
| 1779 | 1783 | } |
| 1780 | 1784 | |
| 1781 | 1785 | /* |
| 1782 | 1786 | ** If the given COMMIT rid has any tags associated with it, this |
| 1783 | -** function returns a JSON Array containing the tag names, else it | |
| 1784 | -** returns NULL. | |
| 1787 | +** function returns a JSON Array containing the tag names (owned by | |
| 1788 | +** the caller), else it returns NULL. | |
| 1785 | 1789 | ** |
| 1786 | 1790 | ** See info_tags_of_checkin() for more details (this is simply a JSON |
| 1787 | 1791 | ** wrapper for that function). |
| 1788 | 1792 | */ |
| 1789 | 1793 | cson_value * json_tags_for_checkin_rid(int rid, char propagatingOnly){ |
| 1790 | 1794 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1304,11 +1304,12 @@ | |
| 1304 | } |
| 1305 | |
| 1306 | /* |
| 1307 | ** Convenience routine which converts a Julian time value into a Unix |
| 1308 | ** Epoch timestamp. Requires the db, so this cannot be used before the |
| 1309 | ** repo is opened (will trigger a fatal error in db_xxx()). |
| 1310 | */ |
| 1311 | cson_value * json_julian_to_timestamp(double j){ |
| 1312 | return cson_value_new_integer((cson_int_t) |
| 1313 | db_int64(0,"SELECT cast(strftime('%%s',%lf) as int)",j) |
| 1314 | ); |
| @@ -1318,14 +1319,16 @@ | |
| 1318 | ** Returns a timestamp value. |
| 1319 | */ |
| 1320 | cson_int_t json_timestamp(){ |
| 1321 | return (cson_int_t)time(0); |
| 1322 | } |
| 1323 | /* |
| 1324 | ** Returns a new JSON value (owned by the caller) representing |
| 1325 | ** a timestamp. If timeVal is < 0 then time(0) is used to fetch |
| 1326 | ** the time, else timeVal is used as-is |
| 1327 | */ |
| 1328 | cson_value * json_new_timestamp(cson_int_t timeVal){ |
| 1329 | return cson_value_new_integer((timeVal<0) ? (cson_int_t)time(0) : timeVal); |
| 1330 | } |
| 1331 | |
| @@ -1504,11 +1507,12 @@ | |
| 1504 | cson_value_free(tmp); \ |
| 1505 | tmp = NULL; \ |
| 1506 | goto cleanup; \ |
| 1507 | }while(0) |
| 1508 | |
| 1509 | tmp = cson_value_new_string(MANIFEST_UUID,strlen(MANIFEST_UUID)); |
| 1510 | SET("fossil"); |
| 1511 | |
| 1512 | tmp = json_new_timestamp(-1); |
| 1513 | SET(FossilJsonKeys.timestamp); |
| 1514 | |
| @@ -1611,11 +1615,11 @@ | |
| 1611 | ** |
| 1612 | ** If alsoOutput is true AND g.isHTTP then cgi_reply() is called to |
| 1613 | ** flush the output (and headers). Generally only do this if you are |
| 1614 | ** about to call exit(). |
| 1615 | ** |
| 1616 | ** !g.isHTTP then alsoOutput is ignored and all output is sent to |
| 1617 | ** stdout immediately. |
| 1618 | ** |
| 1619 | ** For generating the resultText property: if msg is not NULL then it |
| 1620 | ** is used as-is. If it is NULL then g.zErrMsg is checked, and if that |
| 1621 | ** is NULL then json_err_cstr(code) is used. |
| @@ -1705,11 +1709,11 @@ | |
| 1705 | assert(NULL!=a); |
| 1706 | } |
| 1707 | if(!colNames){ |
| 1708 | colNamesV = cson_sqlite3_column_names(pStmt->pStmt); |
| 1709 | assert(NULL != colNamesV); |
| 1710 | cson_value_add_reference(colNamesV); |
| 1711 | colNames = cson_value_get_array(colNamesV); |
| 1712 | assert(NULL != colNames); |
| 1713 | } |
| 1714 | row = cson_sqlite3_row_to_object2(pStmt->pStmt, colNames); |
| 1715 | if(!row && !warnMsg){ |
| @@ -1778,12 +1782,12 @@ | |
| 1778 | |
| 1779 | } |
| 1780 | |
| 1781 | /* |
| 1782 | ** If the given COMMIT rid has any tags associated with it, this |
| 1783 | ** function returns a JSON Array containing the tag names, else it |
| 1784 | ** returns NULL. |
| 1785 | ** |
| 1786 | ** See info_tags_of_checkin() for more details (this is simply a JSON |
| 1787 | ** wrapper for that function). |
| 1788 | */ |
| 1789 | cson_value * json_tags_for_checkin_rid(int rid, char propagatingOnly){ |
| 1790 |
| --- src/json.c | |
| +++ src/json.c | |
| @@ -1304,11 +1304,12 @@ | |
| 1304 | } |
| 1305 | |
| 1306 | /* |
| 1307 | ** Convenience routine which converts a Julian time value into a Unix |
| 1308 | ** Epoch timestamp. Requires the db, so this cannot be used before the |
| 1309 | ** repo is opened (will trigger a fatal error in db_xxx()). The returned |
| 1310 | ** value is owned by the caller. |
| 1311 | */ |
| 1312 | cson_value * json_julian_to_timestamp(double j){ |
| 1313 | return cson_value_new_integer((cson_int_t) |
| 1314 | db_int64(0,"SELECT cast(strftime('%%s',%lf) as int)",j) |
| 1315 | ); |
| @@ -1318,14 +1319,16 @@ | |
| 1319 | ** Returns a timestamp value. |
| 1320 | */ |
| 1321 | cson_int_t json_timestamp(){ |
| 1322 | return (cson_int_t)time(0); |
| 1323 | } |
| 1324 | |
| 1325 | /* |
| 1326 | ** Returns a new JSON value (owned by the caller) representing |
| 1327 | ** a timestamp. If timeVal is < 0 then time(0) is used to fetch |
| 1328 | ** the time, else timeVal is used as-is. The returned value is |
| 1329 | ** owned by the caller. |
| 1330 | */ |
| 1331 | cson_value * json_new_timestamp(cson_int_t timeVal){ |
| 1332 | return cson_value_new_integer((timeVal<0) ? (cson_int_t)time(0) : timeVal); |
| 1333 | } |
| 1334 | |
| @@ -1504,11 +1507,12 @@ | |
| 1507 | cson_value_free(tmp); \ |
| 1508 | tmp = NULL; \ |
| 1509 | goto cleanup; \ |
| 1510 | }while(0) |
| 1511 | |
| 1512 | |
| 1513 | tmp = json_new_string(MANIFEST_UUID); |
| 1514 | SET("fossil"); |
| 1515 | |
| 1516 | tmp = json_new_timestamp(-1); |
| 1517 | SET(FossilJsonKeys.timestamp); |
| 1518 | |
| @@ -1611,11 +1615,11 @@ | |
| 1615 | ** |
| 1616 | ** If alsoOutput is true AND g.isHTTP then cgi_reply() is called to |
| 1617 | ** flush the output (and headers). Generally only do this if you are |
| 1618 | ** about to call exit(). |
| 1619 | ** |
| 1620 | ** If !g.isHTTP then alsoOutput is ignored and all output is sent to |
| 1621 | ** stdout immediately. |
| 1622 | ** |
| 1623 | ** For generating the resultText property: if msg is not NULL then it |
| 1624 | ** is used as-is. If it is NULL then g.zErrMsg is checked, and if that |
| 1625 | ** is NULL then json_err_cstr(code) is used. |
| @@ -1705,11 +1709,11 @@ | |
| 1709 | assert(NULL!=a); |
| 1710 | } |
| 1711 | if(!colNames){ |
| 1712 | colNamesV = cson_sqlite3_column_names(pStmt->pStmt); |
| 1713 | assert(NULL != colNamesV); |
| 1714 | cson_value_add_reference(colNamesV)/*avoids an ownership problem*/; |
| 1715 | colNames = cson_value_get_array(colNamesV); |
| 1716 | assert(NULL != colNames); |
| 1717 | } |
| 1718 | row = cson_sqlite3_row_to_object2(pStmt->pStmt, colNames); |
| 1719 | if(!row && !warnMsg){ |
| @@ -1778,12 +1782,12 @@ | |
| 1782 | |
| 1783 | } |
| 1784 | |
| 1785 | /* |
| 1786 | ** If the given COMMIT rid has any tags associated with it, this |
| 1787 | ** function returns a JSON Array containing the tag names (owned by |
| 1788 | ** the caller), else it returns NULL. |
| 1789 | ** |
| 1790 | ** See info_tags_of_checkin() for more details (this is simply a JSON |
| 1791 | ** wrapper for that function). |
| 1792 | */ |
| 1793 | cson_value * json_tags_for_checkin_rid(int rid, char propagatingOnly){ |
| 1794 |