1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
/*
** The implementation of the TH core. This file contains the parser, and
** the implementation of the interface in th.h.
*/
#include "th.h"
#include <string.h>
#include <assert.h>
#include <stdio.h> /* FILE class */
#ifdef TH_USE_OUTBUF
#endif
extern void *fossil_realloc(void *p, size_t n);
static void * th_fossil_realloc(void *p, unsigned int n){
return fossil_realloc( p, n );
}
static int Th_output_f_ob( char const * zData, int len, void * pState );
|
>
|
>
>
>
>
>
>
>
>
>
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/*
** The implementation of the TH core. This file contains the parser, and
** the implementation of the interface in th.h.
*/
#include "th.h"
#include <string.h>
#include <assert.h>
#include <stdio.h> /* FILE class */
#ifdef TH_ENABLE_OUTBUF
struct Th_Ob_Man {
Blob ** aBuf; /* Stack of Blobs */
int nBuf; /* Number of blobs */
int cursor; /* Current level (-1=not active) */
Th_Interp * interp; /* The associated interpreter */
Th_Vtab_Output * aOutput
/* Stack of output routines corresponding
to the current buffering level.
Has nBuf entries.
*/;
};
#endif
extern void *fossil_realloc(void *p, size_t n);
static void * th_fossil_realloc(void *p, unsigned int n){
return fossil_realloc( p, n );
}
static int Th_output_f_ob( char const * zData, int len, void * pState );
|
| ︙ | | | ︙ | |
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
|
? Th_HashFind(interp, interp->paGc, key, th_strlen(key), 0)
: NULL;
return e ? ((Th_GcEntry*)e->pData)->pData : NULL;
}
#ifdef TH_USE_OUTBUF
/* Reminder: the ob code "really" belongs in th_lang.c,
but we need access to Th_Interp internals in order to
swap out Th_Vtab parts for purposes of stacking layers
of buffers.
*/
#define Th_Ob_Man_empty_m { \
NULL/*aBuf*/, \
|
|
|
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
|
? Th_HashFind(interp, interp->paGc, key, th_strlen(key), 0)
: NULL;
return e ? ((Th_GcEntry*)e->pData)->pData : NULL;
}
#ifdef TH_ENABLE_OUTBUF
/* Reminder: the ob code "really" belongs in th_lang.c,
but we need access to Th_Interp internals in order to
swap out Th_Vtab parts for purposes of stacking layers
of buffers.
*/
#define Th_Ob_Man_empty_m { \
NULL/*aBuf*/, \
|
| ︙ | | | ︙ | |
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
|
assert(-1 == pMan->cursor);
}
/*printf( "post-pop: pMan->nBuf=%d, pMan->cursor=%d\n", pMan->nBuf, pMan->cursor);*/
return rc;
}
}
void Th_ob_cleanup( Th_Ob_Man * man ){
Blob * b;
while( (b = Th_ob_pop(man)) ){
blob_reset(b);
Th_Free( man->interp, b );
}
}
/*
** TH Syntax:
**
** ob clean
**
** Erases any currently buffered contents but does not modify
|
|
|
|
>
|
>
>
>
>
>
|
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
|
assert(-1 == pMan->cursor);
}
/*printf( "post-pop: pMan->nBuf=%d, pMan->cursor=%d\n", pMan->nBuf, pMan->cursor);*/
return rc;
}
}
int Th_ob_pop_free( Th_Ob_Man * pMan ){
Blob * b = Th_ob_pop( pMan );
if(!b) return 1;
else {
blob_reset(b);
Th_Free( pMan->interp, b );
}
}
void Th_ob_cleanup( Th_Ob_Man * man ){
while( 0 == Th_ob_pop_free(man) ){}
}
/*
** TH Syntax:
**
** ob clean
**
** Erases any currently buffered contents but does not modify
|
| ︙ | | | ︙ | |
3141
3142
3143
3144
3145
3146
3147
3148
3149
|
}
return rc;
}
#undef Th_Ob_Man_empty_m
#undef Th_Ob_Man_KEY
#endif
/* end TH_USE_OUTBUF */
|
|
|
3159
3160
3161
3162
3163
3164
3165
3166
3167
|
}
return rc;
}
#undef Th_Ob_Man_empty_m
#undef Th_Ob_Man_KEY
#endif
/* end TH_ENABLE_OUTBUF */
|