Fossil SCM

minor doc touch-ups and one s/cson_value_new_string/json_new_string/.

stephan 2012-02-16 20:57 trunk
Commit 9cfe61e0bfa939e95a9323180e1f1680c2ac5ea2
1 file changed +11 -7
+11 -7
--- src/json.c
+++ src/json.c
@@ -1304,11 +1304,12 @@
13041304
}
13051305
13061306
/*
13071307
** Convenience routine which converts a Julian time value into a Unix
13081308
** 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.
13101311
*/
13111312
cson_value * json_julian_to_timestamp(double j){
13121313
return cson_value_new_integer((cson_int_t)
13131314
db_int64(0,"SELECT cast(strftime('%%s',%lf) as int)",j)
13141315
);
@@ -1318,14 +1319,16 @@
13181319
** Returns a timestamp value.
13191320
*/
13201321
cson_int_t json_timestamp(){
13211322
return (cson_int_t)time(0);
13221323
}
1324
+
13231325
/*
13241326
** Returns a new JSON value (owned by the caller) representing
13251327
** 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.
13271330
*/
13281331
cson_value * json_new_timestamp(cson_int_t timeVal){
13291332
return cson_value_new_integer((timeVal<0) ? (cson_int_t)time(0) : timeVal);
13301333
}
13311334
@@ -1504,11 +1507,12 @@
15041507
cson_value_free(tmp); \
15051508
tmp = NULL; \
15061509
goto cleanup; \
15071510
}while(0)
15081511
1509
- tmp = cson_value_new_string(MANIFEST_UUID,strlen(MANIFEST_UUID));
1512
+
1513
+ tmp = json_new_string(MANIFEST_UUID);
15101514
SET("fossil");
15111515
15121516
tmp = json_new_timestamp(-1);
15131517
SET(FossilJsonKeys.timestamp);
15141518
@@ -1611,11 +1615,11 @@
16111615
**
16121616
** If alsoOutput is true AND g.isHTTP then cgi_reply() is called to
16131617
** flush the output (and headers). Generally only do this if you are
16141618
** about to call exit().
16151619
**
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
16171621
** stdout immediately.
16181622
**
16191623
** For generating the resultText property: if msg is not NULL then it
16201624
** is used as-is. If it is NULL then g.zErrMsg is checked, and if that
16211625
** is NULL then json_err_cstr(code) is used.
@@ -1705,11 +1709,11 @@
17051709
assert(NULL!=a);
17061710
}
17071711
if(!colNames){
17081712
colNamesV = cson_sqlite3_column_names(pStmt->pStmt);
17091713
assert(NULL != colNamesV);
1710
- cson_value_add_reference(colNamesV);
1714
+ cson_value_add_reference(colNamesV)/*avoids an ownership problem*/;
17111715
colNames = cson_value_get_array(colNamesV);
17121716
assert(NULL != colNames);
17131717
}
17141718
row = cson_sqlite3_row_to_object2(pStmt->pStmt, colNames);
17151719
if(!row && !warnMsg){
@@ -1778,12 +1782,12 @@
17781782
17791783
}
17801784
17811785
/*
17821786
** 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.
17851789
**
17861790
** See info_tags_of_checkin() for more details (this is simply a JSON
17871791
** wrapper for that function).
17881792
*/
17891793
cson_value * json_tags_for_checkin_rid(int rid, char propagatingOnly){
17901794
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button