Fossil

Check-in [a37df1d9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:doc additions for /json/diff.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | json-multitag-test | json
Files: files | file ages | folders
SHA1: a37df1d939fc1555b170bdc1afec31cf80b986c2
User & Date: stephan 2011-10-08 05:16:12
Context
2011-10-08
05:16
minor hack to allow libcson to use fossil_malloc/free/realloc() so that we will hook into its die-on-OOM behaviour (=reduced error checking). check-in: 56ecc0c6 user: stephan tags: json-multitag-test, json
05:16
doc additions for /json/diff. check-in: a37df1d9 user: stephan tags: json-multitag-test, json
2011-10-07
14:19
fixed a missing db_finalize() in an error-handling case. check-in: 7906bab8 user: stephan tags: json-multitag-test, json
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/json_diff.c.

21
22
23
24
25
26
27
28


29
30
31
32
33
34
35
..
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
..
60
61
62
63
64
65
66








67
68
69
70
71
72
73
#if INTERFACE
#include "json_detail.h"
#endif



/*
** Append the difference between two RIDs to the output


*/
cson_value * json_generate_diff(const char *zFrom, const char *zTo,
                                int nContext){
  int fromid;
  int toid;
  int outLen;
  Blob from = empty_blob, to = empty_blob, out = empty_blob;
................................................................................
      json_set_err(FSL_JSON_E_UNRESOLVED_UUID,
                   "Could not resolve 'from' ID.");
      return NULL;
  }
  toid = name_to_typed_rid(zTo, "*");
  if(toid<=0){
      json_set_err(FSL_JSON_E_UNRESOLVED_UUID,
                   "Could not resolve 'from' ID.");
      return NULL;
  }
  content_get(fromid, &from);
  content_get(toid, &to);
  blob_zero(&out);
  text_diff(&from, &to, &out, nContext, 1);
  blob_reset(&from);
................................................................................
  blob_reset(&out);
  return rc;
}

/*
** Implementation of the /json/diff page.
**








*/
cson_value * json_page_diff(){
  cson_object * pay = NULL;
  cson_value * v = NULL;
  char const * zFrom;
  char const * zTo;
  int nContext = 0;







|
>
>







 







|







 







>
>
>
>
>
>
>
>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
..
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#if INTERFACE
#include "json_detail.h"
#endif



/*
** Generates a diff between two versions (zFrom and zTo), using nContext
** content lines in the output. On success, returns a new JSON String
** object. On error it sets g.json's error state and returns NULL.
*/
cson_value * json_generate_diff(const char *zFrom, const char *zTo,
                                int nContext){
  int fromid;
  int toid;
  int outLen;
  Blob from = empty_blob, to = empty_blob, out = empty_blob;
................................................................................
      json_set_err(FSL_JSON_E_UNRESOLVED_UUID,
                   "Could not resolve 'from' ID.");
      return NULL;
  }
  toid = name_to_typed_rid(zTo, "*");
  if(toid<=0){
      json_set_err(FSL_JSON_E_UNRESOLVED_UUID,
                   "Could not resolve 'to' ID.");
      return NULL;
  }
  content_get(fromid, &from);
  content_get(toid, &to);
  blob_zero(&out);
  text_diff(&from, &to, &out, nContext, 1);
  blob_reset(&from);
................................................................................
  blob_reset(&out);
  return rc;
}

/*
** Implementation of the /json/diff page.
**
** Arguments:
**
** v1=1st version to diff
** v2=2nd version to diff
**
** Can come from GET, POST.payload, CLI -v1/-v2 or as positional
** parameters following the command name (in HTTP and CLI modes).
**
*/
cson_value * json_page_diff(){
  cson_object * pay = NULL;
  cson_value * v = NULL;
  char const * zFrom;
  char const * zTo;
  int nContext = 0;