Fossil

Changes On Branch th1-recursive-render
Login

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

Changes In Branch th1-recursive-render Excluding Merge-Ins

This is equivalent to a diff from 12b5eed944 to 0dc3a65515

2021-07-05
16:55
Resolved problems with recursive invocation of th1's render command. ... (check-in: a5f00e0a71 user: stephan tags: trunk)
16:52
Resolved a g.th1Flags bitmask collision between TH_STATE_xxx and TH_INIT_NO_ENCODE. ... (Closed-Leaf check-in: 0dc3a65515 user: stephan tags: th1-recursive-render)
2021-07-02
04:16
When calling Th_Render() recursively, pass on g.th1Flags so that recursive calls do not inadvertently toggle flags like TH_INIT_NO_ENCODE. ... (check-in: 0a57df7e07 user: stephan tags: th1-recursive-render)
2021-07-01
13:58
Add the --fossilcmd option to "fossil ui". Carry the --jsmode and --create options through to the remote fossil. ... (check-in: c359589ef6 user: drh tags: trunk)
04:03
Proposed fix for out-of-order output when calling th1 render function from a th-doc page body. DO NOT MERGE: this is being checked in so that it can be deployed on a test server. ... (check-in: a381a8102b user: stephan tags: th1-recursive-render)
03:26
Minor doc typo fix. ... (check-in: 12b5eed944 user: stephan tags: trunk)
2021-06-30
22:58
Replaced part of [3946ff81] which was inadvertently removed via [612f6cee] (parallel edits). Removed an unused var. ... (check-in: 4f095cdba0 user: stephan tags: trunk)

Changes to src/th_main.c.
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#define TH_INIT_FORBID_MASK (TH_INIT_FORCE_TCL) /* Illegal from a script. */
#endif

/*
** Flags set by functions in this file to keep track of integration state
** information.  These flags should not be used outside of this file.
*/
#define TH_STATE_CONFIG     ((u32)0x00000020) /* We opened the config. */
#define TH_STATE_REPOSITORY ((u32)0x00000040) /* We opened the repository. */
#define TH_STATE_MASK       ((u32)0x00000060) /* All possible state flags. */

#ifdef FOSSIL_ENABLE_TH1_HOOKS
/*
** These are the "well-known" TH1 error messages that occur when no hook is
** registered to be called prior to executing a command or processing a web
** page, respectively.  If one of these errors is seen, it will not be sent
** or displayed to the remote user or local interactive user, respectively.







|
|
|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#define TH_INIT_FORBID_MASK (TH_INIT_FORCE_TCL) /* Illegal from a script. */
#endif

/*
** Flags set by functions in this file to keep track of integration state
** information.  These flags should not be used outside of this file.
*/
#define TH_STATE_CONFIG     ((u32)0x00000200) /* We opened the config. */
#define TH_STATE_REPOSITORY ((u32)0x00000400) /* We opened the repository. */
#define TH_STATE_MASK       ((u32)0x00000600) /* All possible state flags. */

#ifdef FOSSIL_ENABLE_TH1_HOOKS
/*
** These are the "well-known" TH1 error messages that occur when no hook is
** registered to be called prior to executing a command or processing a web
** page, respectively.  If one of these errors is seen, it will not be sent
** or displayed to the remote user or local interactive user, respectively.
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373

/* See Th_SetOutputBlob() */
static Blob * pThOut = 0;
/*
** Sets the th1-internal output-redirection blob and returns the
** previous value. That blob is used by certain output-generation
** routines to emit its output. It returns the previous value so that
** a routing can temporarily replace the buffer with its own and
** restore it when it's done.
*/
Blob * Th_SetOutputBlob(Blob * pOut){
  Blob * tmp = pThOut;
  pThOut = pOut;
  return tmp;
}







|







359
360
361
362
363
364
365
366
367
368
369
370
371
372
373

/* See Th_SetOutputBlob() */
static Blob * pThOut = 0;
/*
** Sets the th1-internal output-redirection blob and returns the
** previous value. That blob is used by certain output-generation
** routines to emit its output. It returns the previous value so that
** a routine can temporarily replace the buffer with its own and
** restore it when it's done.
*/
Blob * Th_SetOutputBlob(Blob * pOut){
  Blob * tmp = pThOut;
  pThOut = pOut;
  return tmp;
}
2832
2833
2834
2835
2836
2837
2838
2839

2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
** TH_INIT_MASK.
*/
#define TH_R2B_MASK    ((u32)0x0f000)
#define TH_R2B_NO_VARS ((u32)0x01000) /* Disables eval of $vars and $<vars> */
#endif

/*
** If pOut is NULL, this works identically to Th_Render(), else it

** works just like that function but appends any TH1-generated output
** to the given blob. A bitmask of TH_R2B_xxx and/or TH_INIT_xxx flags
** may be passed as the 3rd argument, or 0 for default options.  Note
** that this function necessarily calls Th_FossilInit(), which may
** unset flags used on previous calls unless mFlags is explicitly
** passed in.
*/
int Th_RenderToBlob(const char *z, Blob * pOut, u32 mFlags){
  int i = 0;
  int n;
  int rc = TH_OK;
  char *zResult;
  Blob * const origOut = Th_SetOutputBlob(pOut);







|
>
|
|
|
|
|
|







2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
** TH_INIT_MASK.
*/
#define TH_R2B_MASK    ((u32)0x0f000)
#define TH_R2B_NO_VARS ((u32)0x01000) /* Disables eval of $vars and $<vars> */
#endif

/*
** If pOut is NULL, this works identically to Th_Render() and sends
** any TH1-generated output to stdin (in CLI mode) or the CGI buffer
** (in CGI mode), else it works just like that function but appends
** any TH1-generated output to the given blob. A bitmask of TH_R2B_xxx
** and/or TH_INIT_xxx flags may be passed as the 3rd argument, or 0
** for default options.  Note that this function necessarily calls
** Th_FossilInit(), which may unset flags used on previous calls
** unless mFlags is explicitly passed in.
*/
int Th_RenderToBlob(const char *z, Blob * pOut, u32 mFlags){
  int i = 0;
  int n;
  int rc = TH_OK;
  char *zResult;
  Blob * const origOut = Th_SetOutputBlob(pOut);
2915
2916
2917
2918
2919
2920
2921
2922












2923
2924
2925
2926
2927
2928
2929
** before being inserted.
**
** This routine processes the template and writes the results to one
** of stdout, CGI, or an internal blob which was set up via a prior
** call to Th_SetOutputBlob().
*/
int Th_Render(const char *z){
  return Th_RenderToBlob(z, 0, 0);












}

/*
** COMMAND: test-th-render
**
** Usage: %fossil test-th-render FILE
**







|
>
>
>
>
>
>
>
>
>
>
>
>







2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
** before being inserted.
**
** This routine processes the template and writes the results to one
** of stdout, CGI, or an internal blob which was set up via a prior
** call to Th_SetOutputBlob().
*/
int Th_Render(const char *z){
  return Th_RenderToBlob(z, pThOut, g.th1Flags)
    /* Maintenance reminder: on most calls to Th_Render(), e.g. for
    ** outputing the site skin, pThOut will be 0, which means that
    ** Th_RenderToBlob() will output directly to the CGI buffer (in
    ** CGI mode) or stdout (in CLI mode). Recursive calls, however,
    ** e.g. via the "render" script function binding, need to use the
    ** pThOut blob in order to avoid out-of-order output if
    ** Th_SetOutputBlob() has been called. If it has not been called,
    ** pThOut will be 0, which will redirect the output to CGI/stdout,
    ** as appropriate. We need to pass on g.th1Flags for the case of
    ** recursive calls, so that, e.g., TH_INIT_NO_ENCODE does not get
    ** inadvertently toggled off by a recursive call.
    */;
}

/*
** COMMAND: test-th-render
**
** Usage: %fossil test-th-render FILE
**