Fossil SCM
Fix two more harmless gcc warning message (one of them as suggested by Stephan Beal)
Commit
6ef54dfaf7fd90a49ccd10c81a81cbc117a027ba
Parent
3aa86af6aaad5d1…
2 files changed
+42
-42
+13
-14
+42
-42
| --- src/cson_amalgamation.c | ||
| +++ src/cson_amalgamation.c | ||
| @@ -19,14 +19,14 @@ | ||
| 19 | 19 | # define JSON_PARSER_DLL_API __declspec(dllexport) |
| 20 | 20 | # else |
| 21 | 21 | # define JSON_PARSER_DLL_API __declspec(dllimport) |
| 22 | 22 | # endif |
| 23 | 23 | # else |
| 24 | -# define JSON_PARSER_DLL_API | |
| 24 | +# define JSON_PARSER_DLL_API | |
| 25 | 25 | # endif |
| 26 | 26 | #else |
| 27 | -# define JSON_PARSER_DLL_API | |
| 27 | +# define JSON_PARSER_DLL_API | |
| 28 | 28 | #endif |
| 29 | 29 | |
| 30 | 30 | /* Determine the integer type use to parse non-floating point numbers */ |
| 31 | 31 | #ifdef _WIN32 |
| 32 | 32 | typedef __int64 JSON_int_t; |
| @@ -34,22 +34,22 @@ | ||
| 34 | 34 | #define JSON_PARSER_INTEGER_SPRINTF_TOKEN "%I64d" |
| 35 | 35 | #elif (__STDC_VERSION__ >= 199901L) || (HAVE_LONG_LONG == 1) |
| 36 | 36 | typedef long long JSON_int_t; |
| 37 | 37 | #define JSON_PARSER_INTEGER_SSCANF_TOKEN "%lld" |
| 38 | 38 | #define JSON_PARSER_INTEGER_SPRINTF_TOKEN "%lld" |
| 39 | -#else | |
| 39 | +#else | |
| 40 | 40 | typedef long JSON_int_t; |
| 41 | 41 | #define JSON_PARSER_INTEGER_SSCANF_TOKEN "%ld" |
| 42 | 42 | #define JSON_PARSER_INTEGER_SPRINTF_TOKEN "%ld" |
| 43 | 43 | #endif |
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | #ifdef __cplusplus |
| 47 | 47 | extern "C" { |
| 48 | -#endif | |
| 48 | +#endif | |
| 49 | 49 | |
| 50 | -typedef enum | |
| 50 | +typedef enum | |
| 51 | 51 | { |
| 52 | 52 | JSON_E_NONE = 0, |
| 53 | 53 | JSON_E_INVALID_CHAR, |
| 54 | 54 | JSON_E_INVALID_KEYWORD, |
| 55 | 55 | JSON_E_INVALID_ESCAPE_SEQUENCE, |
| @@ -60,11 +60,11 @@ | ||
| 60 | 60 | JSON_E_EXPECTED_KEY, |
| 61 | 61 | JSON_E_EXPECTED_COLON, |
| 62 | 62 | JSON_E_OUT_OF_MEMORY |
| 63 | 63 | } JSON_error; |
| 64 | 64 | |
| 65 | -typedef enum | |
| 65 | +typedef enum | |
| 66 | 66 | { |
| 67 | 67 | JSON_T_NONE = 0, |
| 68 | 68 | JSON_T_ARRAY_BEGIN, |
| 69 | 69 | JSON_T_ARRAY_END, |
| 70 | 70 | JSON_T_OBJECT_BEGIN, |
| @@ -80,33 +80,33 @@ | ||
| 80 | 80 | } JSON_type; |
| 81 | 81 | |
| 82 | 82 | typedef struct JSON_value_struct { |
| 83 | 83 | union { |
| 84 | 84 | JSON_int_t integer_value; |
| 85 | - | |
| 85 | + | |
| 86 | 86 | double float_value; |
| 87 | - | |
| 87 | + | |
| 88 | 88 | struct { |
| 89 | 89 | const char* value; |
| 90 | 90 | size_t length; |
| 91 | 91 | } str; |
| 92 | 92 | } vu; |
| 93 | 93 | } JSON_value; |
| 94 | 94 | |
| 95 | 95 | typedef struct JSON_parser_struct* JSON_parser; |
| 96 | 96 | |
| 97 | -/*! \brief JSON parser callback | |
| 97 | +/*! \brief JSON parser callback | |
| 98 | 98 | |
| 99 | 99 | \param ctx The pointer passed to new_JSON_parser. |
| 100 | - \param type An element of JSON_type but not JSON_T_NONE. | |
| 100 | + \param type An element of JSON_type but not JSON_T_NONE. | |
| 101 | 101 | \param value A representation of the parsed value. This parameter is NULL for |
| 102 | 102 | JSON_T_ARRAY_BEGIN, JSON_T_ARRAY_END, JSON_T_OBJECT_BEGIN, JSON_T_OBJECT_END, |
| 103 | 103 | JSON_T_NULL, JSON_T_TRUE, and JSON_T_FALSE. String values are always returned |
| 104 | 104 | as zero-terminated C strings. |
| 105 | 105 | |
| 106 | 106 | \return Non-zero if parsing should continue, else zero. |
| 107 | -*/ | |
| 107 | +*/ | |
| 108 | 108 | typedef int (*JSON_parser_callback)(void* ctx, int type, const JSON_value* value); |
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | A typedef for allocator functions semantically compatible with malloc(). |
| @@ -115,11 +115,11 @@ | ||
| 115 | 115 | /** |
| 116 | 116 | A typedef for deallocator functions semantically compatible with free(). |
| 117 | 117 | */ |
| 118 | 118 | typedef void (*JSON_free_t)(void* mem); |
| 119 | 119 | |
| 120 | -/*! \brief The structure used to configure a JSON parser object | |
| 120 | +/*! \brief The structure used to configure a JSON parser object | |
| 121 | 121 | */ |
| 122 | 122 | typedef struct { |
| 123 | 123 | /** Pointer to a callback, called when the parser has something to tell |
| 124 | 124 | the user. This parameter may be NULL. In this case the input is |
| 125 | 125 | merely checked for validity. |
| @@ -176,17 +176,17 @@ | ||
| 176 | 176 | |
| 177 | 177 | \param config. Used to configure the parser. |
| 178 | 178 | */ |
| 179 | 179 | JSON_PARSER_DLL_API void init_JSON_config(JSON_config * config); |
| 180 | 180 | |
| 181 | -/*! \brief Create a JSON parser object | |
| 181 | +/*! \brief Create a JSON parser object | |
| 182 | 182 | |
| 183 | 183 | \param config. Used to configure the parser. Set to NULL to use |
| 184 | 184 | the default configuration. See init_JSON_config. Its contents are |
| 185 | 185 | copied by this function, so it need not outlive the returned |
| 186 | 186 | object. |
| 187 | - | |
| 187 | + | |
| 188 | 188 | \return The parser object, which is owned by the caller and must eventually |
| 189 | 189 | be freed by calling delete_JSON_parser(). |
| 190 | 190 | */ |
| 191 | 191 | JSON_PARSER_DLL_API JSON_parser new_JSON_parser(JSON_config const* config); |
| 192 | 192 | |
| @@ -200,16 +200,16 @@ | ||
| 200 | 200 | JSON_PARSER_DLL_API int JSON_parser_char(JSON_parser jc, int next_char); |
| 201 | 201 | |
| 202 | 202 | /*! \brief Finalize parsing. |
| 203 | 203 | |
| 204 | 204 | Call this method once after all input characters have been consumed. |
| 205 | - | |
| 205 | + | |
| 206 | 206 | \return Non-zero, if all parsed characters are valid JSON, zero otherwise. |
| 207 | 207 | */ |
| 208 | 208 | JSON_PARSER_DLL_API int JSON_parser_done(JSON_parser jc); |
| 209 | 209 | |
| 210 | -/*! \brief Determine if a given string is valid JSON white space | |
| 210 | +/*! \brief Determine if a given string is valid JSON white space | |
| 211 | 211 | |
| 212 | 212 | \return Non-zero if the string is valid, zero otherwise. |
| 213 | 213 | */ |
| 214 | 214 | JSON_PARSER_DLL_API int JSON_parser_is_legal_white_space_string(const char* s); |
| 215 | 215 | |
| @@ -226,12 +226,12 @@ | ||
| 226 | 226 | JSON_PARSER_DLL_API int JSON_parser_reset(JSON_parser jc); |
| 227 | 227 | |
| 228 | 228 | |
| 229 | 229 | #ifdef __cplusplus |
| 230 | 230 | } |
| 231 | -#endif | |
| 232 | - | |
| 231 | +#endif | |
| 232 | + | |
| 233 | 233 | |
| 234 | 234 | #endif /* JSON_PARSER_H */ |
| 235 | 235 | /* end file parser/JSON_parser.h */ |
| 236 | 236 | /* begin file parser/JSON_parser.c */ |
| 237 | 237 | /* |
| @@ -1431,11 +1431,11 @@ | ||
| 1431 | 1431 | #if defined(__cplusplus) |
| 1432 | 1432 | extern "C" { |
| 1433 | 1433 | #endif |
| 1434 | 1434 | |
| 1435 | 1435 | |
| 1436 | - | |
| 1436 | + | |
| 1437 | 1437 | /** |
| 1438 | 1438 | This type holds the "vtbl" for type-specific operations when |
| 1439 | 1439 | working with cson_value objects. |
| 1440 | 1440 | |
| 1441 | 1441 | All cson_values of a given logical type share a pointer to a single |
| @@ -1607,11 +1607,11 @@ | ||
| 1607 | 1607 | #define CSON_OBJ(V) CSON_CAST(cson_object,(V)) |
| 1608 | 1608 | #define CSON_ARRAY(V) CSON_CAST(cson_array,(V)) |
| 1609 | 1609 | |
| 1610 | 1610 | /** |
| 1611 | 1611 | Holds special shared "constant" (though they are non-const) |
| 1612 | - values. | |
| 1612 | + values. | |
| 1613 | 1613 | */ |
| 1614 | 1614 | static struct CSON_EMPTY_HOLDER_ |
| 1615 | 1615 | { |
| 1616 | 1616 | char trueValue; |
| 1617 | 1617 | cson_string stringValue; |
| @@ -1620,17 +1620,17 @@ | ||
| 1620 | 1620 | cson_string_empty_m |
| 1621 | 1621 | }; |
| 1622 | 1622 | |
| 1623 | 1623 | /** |
| 1624 | 1624 | Indexes into the CSON_SPECIAL_VALUES array. |
| 1625 | - | |
| 1625 | + | |
| 1626 | 1626 | If this enum changes in any way, |
| 1627 | 1627 | makes damned sure that CSON_SPECIAL_VALUES is updated |
| 1628 | 1628 | to match!!! |
| 1629 | 1629 | */ |
| 1630 | 1630 | enum CSON_INTERNAL_VALUES { |
| 1631 | - | |
| 1631 | + | |
| 1632 | 1632 | CSON_VAL_UNDEF = 0, |
| 1633 | 1633 | CSON_VAL_NULL = 1, |
| 1634 | 1634 | CSON_VAL_TRUE = 2, |
| 1635 | 1635 | CSON_VAL_FALSE = 3, |
| 1636 | 1636 | CSON_VAL_INT_0 = 4, |
| @@ -1642,11 +1642,11 @@ | ||
| 1642 | 1642 | /** |
| 1643 | 1643 | Some "special" shared cson_value instances. |
| 1644 | 1644 | |
| 1645 | 1645 | These values MUST be initialized in the order specified |
| 1646 | 1646 | by the CSON_INTERNAL_VALUES enum. |
| 1647 | - | |
| 1647 | + | |
| 1648 | 1648 | Note that they are not const because they are used as |
| 1649 | 1649 | shared-allocation objects in non-const contexts. However, the |
| 1650 | 1650 | public API provides no way to modifying them, and clients who |
| 1651 | 1651 | modify values directly are subject to The Wrath of Undefined |
| 1652 | 1652 | Behaviour. |
| @@ -1665,11 +1665,11 @@ | ||
| 1665 | 1665 | |
| 1666 | 1666 | /** |
| 1667 | 1667 | Returns non-0 (true) if m is one of our special |
| 1668 | 1668 | "built-in" values, e.g. from CSON_SPECIAL_VALUES and some |
| 1669 | 1669 | "empty" values. |
| 1670 | - | |
| 1670 | + | |
| 1671 | 1671 | If this returns true, m MUST NOT be free()d! |
| 1672 | 1672 | */ |
| 1673 | 1673 | static char cson_value_is_builtin( void const * m ) |
| 1674 | 1674 | { |
| 1675 | 1675 | if((m >= (void const *)&CSON_EMPTY_HOLDER) |
| @@ -2183,11 +2183,11 @@ | ||
| 2183 | 2183 | static int cson_value_list_visit( cson_value_list * self, |
| 2184 | 2184 | int (*visitor)(cson_value * obj, void * visitorState ), |
| 2185 | 2185 | void * visitorState ); |
| 2186 | 2186 | #endif |
| 2187 | 2187 | #endif |
| 2188 | - | |
| 2188 | + | |
| 2189 | 2189 | #if 0 |
| 2190 | 2190 | # define LIST_T cson_value_list |
| 2191 | 2191 | # define VALUE_T cson_value * |
| 2192 | 2192 | # define VALUE_T_IS_PTR 1 |
| 2193 | 2193 | # define LIST_T cson_kvp_list |
| @@ -2362,11 +2362,11 @@ | ||
| 2362 | 2362 | return cson_value_object_alloc(); |
| 2363 | 2363 | } |
| 2364 | 2364 | |
| 2365 | 2365 | cson_object * cson_new_object() |
| 2366 | 2366 | { |
| 2367 | - | |
| 2367 | + | |
| 2368 | 2368 | return cson_value_get_object( cson_value_new_object() ); |
| 2369 | 2369 | } |
| 2370 | 2370 | |
| 2371 | 2371 | cson_value * cson_value_new_array() |
| 2372 | 2372 | { |
| @@ -2608,11 +2608,11 @@ | ||
| 2608 | 2608 | { |
| 2609 | 2609 | cson_int_t i = 0; |
| 2610 | 2610 | int rc = 0; |
| 2611 | 2611 | switch(val->api->typeID) |
| 2612 | 2612 | { |
| 2613 | - case CSON_TYPE_UNDEF: | |
| 2613 | + case CSON_TYPE_UNDEF: | |
| 2614 | 2614 | case CSON_TYPE_NULL: |
| 2615 | 2615 | i = 0; |
| 2616 | 2616 | break; |
| 2617 | 2617 | case CSON_TYPE_BOOL: { |
| 2618 | 2618 | char b = 0; |
| @@ -2661,11 +2661,11 @@ | ||
| 2661 | 2661 | { |
| 2662 | 2662 | cson_double_t d = 0.0; |
| 2663 | 2663 | int rc = 0; |
| 2664 | 2664 | switch(val->api->typeID) |
| 2665 | 2665 | { |
| 2666 | - case CSON_TYPE_UNDEF: | |
| 2666 | + case CSON_TYPE_UNDEF: | |
| 2667 | 2667 | case CSON_TYPE_NULL: |
| 2668 | 2668 | d = 0; |
| 2669 | 2669 | break; |
| 2670 | 2670 | case CSON_TYPE_BOOL: { |
| 2671 | 2671 | char b = 0; |
| @@ -2791,11 +2791,11 @@ | ||
| 2791 | 2791 | #if 0 |
| 2792 | 2792 | /** |
| 2793 | 2793 | Removes and returns the last value from the given array, |
| 2794 | 2794 | shrinking its size by 1. Returns NULL if ar is NULL, |
| 2795 | 2795 | ar->list.count is 0, or the element at that index is NULL. |
| 2796 | - | |
| 2796 | + | |
| 2797 | 2797 | |
| 2798 | 2798 | If removeRef is true then cson_value_free() is called to remove |
| 2799 | 2799 | ar's reference count for the value. In that case NULL is returned, |
| 2800 | 2800 | even if the object still has live references. If removeRef is false |
| 2801 | 2801 | then the caller takes over ownership of that reference count point. |
| @@ -2858,11 +2858,11 @@ | ||
| 2858 | 2858 | #if !defined(NDEBUG) && CSON_VOID_PTR_IS_BIG |
| 2859 | 2859 | assert( sizeof(cson_int_t) <= sizeof(void *) ); |
| 2860 | 2860 | #endif |
| 2861 | 2861 | if( c ) |
| 2862 | 2862 | { |
| 2863 | - *CSON_INT(c) = v; | |
| 2863 | + memcpy(CSON_INT(c), &v, sizeof(v)); | |
| 2864 | 2864 | } |
| 2865 | 2865 | return c; |
| 2866 | 2866 | } |
| 2867 | 2867 | } |
| 2868 | 2868 | |
| @@ -3068,11 +3068,11 @@ | ||
| 3068 | 3068 | qsort( obj->kvp.list, obj->kvp.count, sizeof(cson_kvp*), |
| 3069 | 3069 | cson_kvp_cmp ); |
| 3070 | 3070 | } |
| 3071 | 3071 | |
| 3072 | 3072 | } |
| 3073 | -#endif | |
| 3073 | +#endif | |
| 3074 | 3074 | |
| 3075 | 3075 | int cson_object_unset( cson_object * obj, char const * key ) |
| 3076 | 3076 | { |
| 3077 | 3077 | if( ! obj || !key || !*key ) return cson_rc.ArgError; |
| 3078 | 3078 | else |
| @@ -3238,11 +3238,11 @@ | ||
| 3238 | 3238 | using p->key. In any other case cson_rc.InternalError is returned. |
| 3239 | 3239 | |
| 3240 | 3240 | Returns cson_rc.AllocError if an allocation fails. |
| 3241 | 3241 | |
| 3242 | 3242 | Returns 0 on success. On error, parsing must be ceased immediately. |
| 3243 | - | |
| 3243 | + | |
| 3244 | 3244 | Ownership of val is ALWAYS TRANSFERED to this function. If this |
| 3245 | 3245 | function fails, val will be cleaned up and destroyed. (This |
| 3246 | 3246 | simplifies error handling in the core parser.) |
| 3247 | 3247 | */ |
| 3248 | 3248 | static int cson_parser_set_key( cson_parser * p, cson_value * val ) |
| @@ -3485,11 +3485,11 @@ | ||
| 3485 | 3485 | ++p->totalKeyCount; |
| 3486 | 3486 | break; |
| 3487 | 3487 | } |
| 3488 | 3488 | case JSON_T_STRING: { |
| 3489 | 3489 | cson_value * v = cson_value_new_string( value->vu.str.value, value->vu.str.length ); |
| 3490 | - rc = ( NULL == v ) | |
| 3490 | + rc = ( NULL == v ) | |
| 3491 | 3491 | ? cson_rc.AllocError |
| 3492 | 3492 | : cson_parser_push_value( p, v ); |
| 3493 | 3493 | break; |
| 3494 | 3494 | } |
| 3495 | 3495 | default: |
| @@ -3532,11 +3532,11 @@ | ||
| 3532 | 3532 | To properly take over ownership of the parser's root node on a |
| 3533 | 3533 | successful parse: |
| 3534 | 3534 | |
| 3535 | 3535 | - Copy p->root's pointer and set p->root to NULL. |
| 3536 | 3536 | - Eventually free up p->root with cson_value_free(). |
| 3537 | - | |
| 3537 | + | |
| 3538 | 3538 | If you do not set p->root to NULL, p->root will be freed along with |
| 3539 | 3539 | any other items inserted into it (or under it) during the parsing |
| 3540 | 3540 | process. |
| 3541 | 3541 | */ |
| 3542 | 3542 | static int cson_parser_clean( cson_parser * p ) |
| @@ -3571,11 +3571,11 @@ | ||
| 3571 | 3571 | int rc = 0; |
| 3572 | 3572 | unsigned int len = 1; |
| 3573 | 3573 | cson_parse_info info = info_ ? *info_ : cson_parse_info_empty; |
| 3574 | 3574 | cson_parser p = cson_parser_empty; |
| 3575 | 3575 | if( ! tgt || ! src ) return cson_rc.ArgError; |
| 3576 | - | |
| 3576 | + | |
| 3577 | 3577 | { |
| 3578 | 3578 | JSON_config jopt = {0}; |
| 3579 | 3579 | init_JSON_config( &jopt ); |
| 3580 | 3580 | jopt.allow_comments = opt.allowComments; |
| 3581 | 3581 | jopt.depth = opt.maxDepth; |
| @@ -4640,11 +4640,11 @@ | ||
| 4640 | 4640 | #endif |
| 4641 | 4641 | #undef TRY_SHARING |
| 4642 | 4642 | cson_value_add_reference(rc); |
| 4643 | 4643 | return rc; |
| 4644 | 4644 | } |
| 4645 | - | |
| 4645 | + | |
| 4646 | 4646 | static cson_value * cson_value_clone_array( cson_value const * orig ) |
| 4647 | 4647 | { |
| 4648 | 4648 | unsigned int i = 0; |
| 4649 | 4649 | cson_array const * asrc = cson_value_get_array( orig ); |
| 4650 | 4650 | unsigned int alen = cson_array_length_get( asrc ); |
| @@ -4680,11 +4680,11 @@ | ||
| 4680 | 4680 | cson_value_free(cl)/*remove our artificial reference */; |
| 4681 | 4681 | } |
| 4682 | 4682 | } |
| 4683 | 4683 | return destV; |
| 4684 | 4684 | } |
| 4685 | - | |
| 4685 | + | |
| 4686 | 4686 | static cson_value * cson_value_clone_object( cson_value const * orig ) |
| 4687 | 4687 | { |
| 4688 | 4688 | cson_object const * src = cson_value_get_object( orig ); |
| 4689 | 4689 | cson_value * destV = NULL; |
| 4690 | 4690 | cson_object * dest = NULL; |
| @@ -4834,11 +4834,11 @@ | ||
| 4834 | 4834 | } |
| 4835 | 4835 | case CSON_TYPE_STRING: { |
| 4836 | 4836 | cson_string const * jstr = cson_value_get_string(orig); |
| 4837 | 4837 | unsigned const int slen = cson_string_length_bytes( jstr ); |
| 4838 | 4838 | assert( NULL != jstr ); |
| 4839 | - v = cson_strdup( cson_string_cstr( jstr ), slen ); | |
| 4839 | + v = cson_strdup( cson_string_cstr( jstr ), slen ); | |
| 4840 | 4840 | break; |
| 4841 | 4841 | } |
| 4842 | 4842 | case CSON_TYPE_INTEGER: { |
| 4843 | 4843 | char buf[BufSize] = {0}; |
| 4844 | 4844 | if( 0 < sprintf( v, "%"CSON_INT_T_PFMT, cson_value_get_integer(orig)) ) |
| @@ -4887,11 +4887,11 @@ | ||
| 4887 | 4887 | } |
| 4888 | 4888 | case CSON_TYPE_STRING: { |
| 4889 | 4889 | cson_string const * jstr = cson_value_get_string(orig); |
| 4890 | 4890 | unsigned const int slen = cson_string_length_bytes( jstr ); |
| 4891 | 4891 | assert( NULL != jstr ); |
| 4892 | - v = cson_strdup( cson_string_cstr( jstr ), slen ); | |
| 4892 | + v = cson_strdup( cson_string_cstr( jstr ), slen ); | |
| 4893 | 4893 | break; |
| 4894 | 4894 | } |
| 4895 | 4895 | case CSON_TYPE_INTEGER: { |
| 4896 | 4896 | char buf[BufSize] = {0}; |
| 4897 | 4897 | if( 0 < sprintf( v, "%"CSON_INT_T_PFMT, cson_value_get_integer(orig)) ) |
| @@ -5351,11 +5351,11 @@ | ||
| 5351 | 5351 | int rc = 0; |
| 5352 | 5352 | int colCount = 0; |
| 5353 | 5353 | assert(st); |
| 5354 | 5354 | colCount = sqlite3_column_count(st); |
| 5355 | 5355 | if( colCount <= 0 ) return NULL; |
| 5356 | - | |
| 5356 | + | |
| 5357 | 5357 | aryV = cson_value_new_array(); |
| 5358 | 5358 | if( ! aryV ) return NULL; |
| 5359 | 5359 | ary = cson_value_get_array(aryV); |
| 5360 | 5360 | assert(ary); |
| 5361 | 5361 | for( i = 0; (0 ==rc) && (i < colCount); ++i ) |
| @@ -5491,11 +5491,11 @@ | ||
| 5491 | 5491 | aryV = NULL; |
| 5492 | 5492 | end: |
| 5493 | 5493 | return aryV; |
| 5494 | 5494 | } |
| 5495 | 5495 | |
| 5496 | - | |
| 5496 | + | |
| 5497 | 5497 | /** |
| 5498 | 5498 | Internal impl of cson_sqlite3_stmt_to_json() when the 'fat' |
| 5499 | 5499 | parameter is non-0. |
| 5500 | 5500 | */ |
| 5501 | 5501 | static int cson_sqlite3_stmt_to_json_fat( sqlite3_stmt * st, cson_value ** tgt ) |
| @@ -5636,11 +5636,11 @@ | ||
| 5636 | 5636 | int rc = sqlite3_prepare_v2( db, sql, -1, &st, NULL ); |
| 5637 | 5637 | if( 0 != rc ) return cson_rc.IOError /* FIXME: Better error code? */; |
| 5638 | 5638 | rc = cson_sqlite3_stmt_to_json( st, tgt, fat ); |
| 5639 | 5639 | sqlite3_finalize( st ); |
| 5640 | 5640 | return rc; |
| 5641 | - } | |
| 5641 | + } | |
| 5642 | 5642 | } |
| 5643 | 5643 | |
| 5644 | 5644 | int cson_sqlite3_bind_value( sqlite3_stmt * st, int ndx, cson_value const * v ) |
| 5645 | 5645 | { |
| 5646 | 5646 | int rc = 0; |
| 5647 | 5647 |
| --- src/cson_amalgamation.c | |
| +++ src/cson_amalgamation.c | |
| @@ -19,14 +19,14 @@ | |
| 19 | # define JSON_PARSER_DLL_API __declspec(dllexport) |
| 20 | # else |
| 21 | # define JSON_PARSER_DLL_API __declspec(dllimport) |
| 22 | # endif |
| 23 | # else |
| 24 | # define JSON_PARSER_DLL_API |
| 25 | # endif |
| 26 | #else |
| 27 | # define JSON_PARSER_DLL_API |
| 28 | #endif |
| 29 | |
| 30 | /* Determine the integer type use to parse non-floating point numbers */ |
| 31 | #ifdef _WIN32 |
| 32 | typedef __int64 JSON_int_t; |
| @@ -34,22 +34,22 @@ | |
| 34 | #define JSON_PARSER_INTEGER_SPRINTF_TOKEN "%I64d" |
| 35 | #elif (__STDC_VERSION__ >= 199901L) || (HAVE_LONG_LONG == 1) |
| 36 | typedef long long JSON_int_t; |
| 37 | #define JSON_PARSER_INTEGER_SSCANF_TOKEN "%lld" |
| 38 | #define JSON_PARSER_INTEGER_SPRINTF_TOKEN "%lld" |
| 39 | #else |
| 40 | typedef long JSON_int_t; |
| 41 | #define JSON_PARSER_INTEGER_SSCANF_TOKEN "%ld" |
| 42 | #define JSON_PARSER_INTEGER_SPRINTF_TOKEN "%ld" |
| 43 | #endif |
| 44 | |
| 45 | |
| 46 | #ifdef __cplusplus |
| 47 | extern "C" { |
| 48 | #endif |
| 49 | |
| 50 | typedef enum |
| 51 | { |
| 52 | JSON_E_NONE = 0, |
| 53 | JSON_E_INVALID_CHAR, |
| 54 | JSON_E_INVALID_KEYWORD, |
| 55 | JSON_E_INVALID_ESCAPE_SEQUENCE, |
| @@ -60,11 +60,11 @@ | |
| 60 | JSON_E_EXPECTED_KEY, |
| 61 | JSON_E_EXPECTED_COLON, |
| 62 | JSON_E_OUT_OF_MEMORY |
| 63 | } JSON_error; |
| 64 | |
| 65 | typedef enum |
| 66 | { |
| 67 | JSON_T_NONE = 0, |
| 68 | JSON_T_ARRAY_BEGIN, |
| 69 | JSON_T_ARRAY_END, |
| 70 | JSON_T_OBJECT_BEGIN, |
| @@ -80,33 +80,33 @@ | |
| 80 | } JSON_type; |
| 81 | |
| 82 | typedef struct JSON_value_struct { |
| 83 | union { |
| 84 | JSON_int_t integer_value; |
| 85 | |
| 86 | double float_value; |
| 87 | |
| 88 | struct { |
| 89 | const char* value; |
| 90 | size_t length; |
| 91 | } str; |
| 92 | } vu; |
| 93 | } JSON_value; |
| 94 | |
| 95 | typedef struct JSON_parser_struct* JSON_parser; |
| 96 | |
| 97 | /*! \brief JSON parser callback |
| 98 | |
| 99 | \param ctx The pointer passed to new_JSON_parser. |
| 100 | \param type An element of JSON_type but not JSON_T_NONE. |
| 101 | \param value A representation of the parsed value. This parameter is NULL for |
| 102 | JSON_T_ARRAY_BEGIN, JSON_T_ARRAY_END, JSON_T_OBJECT_BEGIN, JSON_T_OBJECT_END, |
| 103 | JSON_T_NULL, JSON_T_TRUE, and JSON_T_FALSE. String values are always returned |
| 104 | as zero-terminated C strings. |
| 105 | |
| 106 | \return Non-zero if parsing should continue, else zero. |
| 107 | */ |
| 108 | typedef int (*JSON_parser_callback)(void* ctx, int type, const JSON_value* value); |
| 109 | |
| 110 | |
| 111 | /** |
| 112 | A typedef for allocator functions semantically compatible with malloc(). |
| @@ -115,11 +115,11 @@ | |
| 115 | /** |
| 116 | A typedef for deallocator functions semantically compatible with free(). |
| 117 | */ |
| 118 | typedef void (*JSON_free_t)(void* mem); |
| 119 | |
| 120 | /*! \brief The structure used to configure a JSON parser object |
| 121 | */ |
| 122 | typedef struct { |
| 123 | /** Pointer to a callback, called when the parser has something to tell |
| 124 | the user. This parameter may be NULL. In this case the input is |
| 125 | merely checked for validity. |
| @@ -176,17 +176,17 @@ | |
| 176 | |
| 177 | \param config. Used to configure the parser. |
| 178 | */ |
| 179 | JSON_PARSER_DLL_API void init_JSON_config(JSON_config * config); |
| 180 | |
| 181 | /*! \brief Create a JSON parser object |
| 182 | |
| 183 | \param config. Used to configure the parser. Set to NULL to use |
| 184 | the default configuration. See init_JSON_config. Its contents are |
| 185 | copied by this function, so it need not outlive the returned |
| 186 | object. |
| 187 | |
| 188 | \return The parser object, which is owned by the caller and must eventually |
| 189 | be freed by calling delete_JSON_parser(). |
| 190 | */ |
| 191 | JSON_PARSER_DLL_API JSON_parser new_JSON_parser(JSON_config const* config); |
| 192 | |
| @@ -200,16 +200,16 @@ | |
| 200 | JSON_PARSER_DLL_API int JSON_parser_char(JSON_parser jc, int next_char); |
| 201 | |
| 202 | /*! \brief Finalize parsing. |
| 203 | |
| 204 | Call this method once after all input characters have been consumed. |
| 205 | |
| 206 | \return Non-zero, if all parsed characters are valid JSON, zero otherwise. |
| 207 | */ |
| 208 | JSON_PARSER_DLL_API int JSON_parser_done(JSON_parser jc); |
| 209 | |
| 210 | /*! \brief Determine if a given string is valid JSON white space |
| 211 | |
| 212 | \return Non-zero if the string is valid, zero otherwise. |
| 213 | */ |
| 214 | JSON_PARSER_DLL_API int JSON_parser_is_legal_white_space_string(const char* s); |
| 215 | |
| @@ -226,12 +226,12 @@ | |
| 226 | JSON_PARSER_DLL_API int JSON_parser_reset(JSON_parser jc); |
| 227 | |
| 228 | |
| 229 | #ifdef __cplusplus |
| 230 | } |
| 231 | #endif |
| 232 | |
| 233 | |
| 234 | #endif /* JSON_PARSER_H */ |
| 235 | /* end file parser/JSON_parser.h */ |
| 236 | /* begin file parser/JSON_parser.c */ |
| 237 | /* |
| @@ -1431,11 +1431,11 @@ | |
| 1431 | #if defined(__cplusplus) |
| 1432 | extern "C" { |
| 1433 | #endif |
| 1434 | |
| 1435 | |
| 1436 | |
| 1437 | /** |
| 1438 | This type holds the "vtbl" for type-specific operations when |
| 1439 | working with cson_value objects. |
| 1440 | |
| 1441 | All cson_values of a given logical type share a pointer to a single |
| @@ -1607,11 +1607,11 @@ | |
| 1607 | #define CSON_OBJ(V) CSON_CAST(cson_object,(V)) |
| 1608 | #define CSON_ARRAY(V) CSON_CAST(cson_array,(V)) |
| 1609 | |
| 1610 | /** |
| 1611 | Holds special shared "constant" (though they are non-const) |
| 1612 | values. |
| 1613 | */ |
| 1614 | static struct CSON_EMPTY_HOLDER_ |
| 1615 | { |
| 1616 | char trueValue; |
| 1617 | cson_string stringValue; |
| @@ -1620,17 +1620,17 @@ | |
| 1620 | cson_string_empty_m |
| 1621 | }; |
| 1622 | |
| 1623 | /** |
| 1624 | Indexes into the CSON_SPECIAL_VALUES array. |
| 1625 | |
| 1626 | If this enum changes in any way, |
| 1627 | makes damned sure that CSON_SPECIAL_VALUES is updated |
| 1628 | to match!!! |
| 1629 | */ |
| 1630 | enum CSON_INTERNAL_VALUES { |
| 1631 | |
| 1632 | CSON_VAL_UNDEF = 0, |
| 1633 | CSON_VAL_NULL = 1, |
| 1634 | CSON_VAL_TRUE = 2, |
| 1635 | CSON_VAL_FALSE = 3, |
| 1636 | CSON_VAL_INT_0 = 4, |
| @@ -1642,11 +1642,11 @@ | |
| 1642 | /** |
| 1643 | Some "special" shared cson_value instances. |
| 1644 | |
| 1645 | These values MUST be initialized in the order specified |
| 1646 | by the CSON_INTERNAL_VALUES enum. |
| 1647 | |
| 1648 | Note that they are not const because they are used as |
| 1649 | shared-allocation objects in non-const contexts. However, the |
| 1650 | public API provides no way to modifying them, and clients who |
| 1651 | modify values directly are subject to The Wrath of Undefined |
| 1652 | Behaviour. |
| @@ -1665,11 +1665,11 @@ | |
| 1665 | |
| 1666 | /** |
| 1667 | Returns non-0 (true) if m is one of our special |
| 1668 | "built-in" values, e.g. from CSON_SPECIAL_VALUES and some |
| 1669 | "empty" values. |
| 1670 | |
| 1671 | If this returns true, m MUST NOT be free()d! |
| 1672 | */ |
| 1673 | static char cson_value_is_builtin( void const * m ) |
| 1674 | { |
| 1675 | if((m >= (void const *)&CSON_EMPTY_HOLDER) |
| @@ -2183,11 +2183,11 @@ | |
| 2183 | static int cson_value_list_visit( cson_value_list * self, |
| 2184 | int (*visitor)(cson_value * obj, void * visitorState ), |
| 2185 | void * visitorState ); |
| 2186 | #endif |
| 2187 | #endif |
| 2188 | |
| 2189 | #if 0 |
| 2190 | # define LIST_T cson_value_list |
| 2191 | # define VALUE_T cson_value * |
| 2192 | # define VALUE_T_IS_PTR 1 |
| 2193 | # define LIST_T cson_kvp_list |
| @@ -2362,11 +2362,11 @@ | |
| 2362 | return cson_value_object_alloc(); |
| 2363 | } |
| 2364 | |
| 2365 | cson_object * cson_new_object() |
| 2366 | { |
| 2367 | |
| 2368 | return cson_value_get_object( cson_value_new_object() ); |
| 2369 | } |
| 2370 | |
| 2371 | cson_value * cson_value_new_array() |
| 2372 | { |
| @@ -2608,11 +2608,11 @@ | |
| 2608 | { |
| 2609 | cson_int_t i = 0; |
| 2610 | int rc = 0; |
| 2611 | switch(val->api->typeID) |
| 2612 | { |
| 2613 | case CSON_TYPE_UNDEF: |
| 2614 | case CSON_TYPE_NULL: |
| 2615 | i = 0; |
| 2616 | break; |
| 2617 | case CSON_TYPE_BOOL: { |
| 2618 | char b = 0; |
| @@ -2661,11 +2661,11 @@ | |
| 2661 | { |
| 2662 | cson_double_t d = 0.0; |
| 2663 | int rc = 0; |
| 2664 | switch(val->api->typeID) |
| 2665 | { |
| 2666 | case CSON_TYPE_UNDEF: |
| 2667 | case CSON_TYPE_NULL: |
| 2668 | d = 0; |
| 2669 | break; |
| 2670 | case CSON_TYPE_BOOL: { |
| 2671 | char b = 0; |
| @@ -2791,11 +2791,11 @@ | |
| 2791 | #if 0 |
| 2792 | /** |
| 2793 | Removes and returns the last value from the given array, |
| 2794 | shrinking its size by 1. Returns NULL if ar is NULL, |
| 2795 | ar->list.count is 0, or the element at that index is NULL. |
| 2796 | |
| 2797 | |
| 2798 | If removeRef is true then cson_value_free() is called to remove |
| 2799 | ar's reference count for the value. In that case NULL is returned, |
| 2800 | even if the object still has live references. If removeRef is false |
| 2801 | then the caller takes over ownership of that reference count point. |
| @@ -2858,11 +2858,11 @@ | |
| 2858 | #if !defined(NDEBUG) && CSON_VOID_PTR_IS_BIG |
| 2859 | assert( sizeof(cson_int_t) <= sizeof(void *) ); |
| 2860 | #endif |
| 2861 | if( c ) |
| 2862 | { |
| 2863 | *CSON_INT(c) = v; |
| 2864 | } |
| 2865 | return c; |
| 2866 | } |
| 2867 | } |
| 2868 | |
| @@ -3068,11 +3068,11 @@ | |
| 3068 | qsort( obj->kvp.list, obj->kvp.count, sizeof(cson_kvp*), |
| 3069 | cson_kvp_cmp ); |
| 3070 | } |
| 3071 | |
| 3072 | } |
| 3073 | #endif |
| 3074 | |
| 3075 | int cson_object_unset( cson_object * obj, char const * key ) |
| 3076 | { |
| 3077 | if( ! obj || !key || !*key ) return cson_rc.ArgError; |
| 3078 | else |
| @@ -3238,11 +3238,11 @@ | |
| 3238 | using p->key. In any other case cson_rc.InternalError is returned. |
| 3239 | |
| 3240 | Returns cson_rc.AllocError if an allocation fails. |
| 3241 | |
| 3242 | Returns 0 on success. On error, parsing must be ceased immediately. |
| 3243 | |
| 3244 | Ownership of val is ALWAYS TRANSFERED to this function. If this |
| 3245 | function fails, val will be cleaned up and destroyed. (This |
| 3246 | simplifies error handling in the core parser.) |
| 3247 | */ |
| 3248 | static int cson_parser_set_key( cson_parser * p, cson_value * val ) |
| @@ -3485,11 +3485,11 @@ | |
| 3485 | ++p->totalKeyCount; |
| 3486 | break; |
| 3487 | } |
| 3488 | case JSON_T_STRING: { |
| 3489 | cson_value * v = cson_value_new_string( value->vu.str.value, value->vu.str.length ); |
| 3490 | rc = ( NULL == v ) |
| 3491 | ? cson_rc.AllocError |
| 3492 | : cson_parser_push_value( p, v ); |
| 3493 | break; |
| 3494 | } |
| 3495 | default: |
| @@ -3532,11 +3532,11 @@ | |
| 3532 | To properly take over ownership of the parser's root node on a |
| 3533 | successful parse: |
| 3534 | |
| 3535 | - Copy p->root's pointer and set p->root to NULL. |
| 3536 | - Eventually free up p->root with cson_value_free(). |
| 3537 | |
| 3538 | If you do not set p->root to NULL, p->root will be freed along with |
| 3539 | any other items inserted into it (or under it) during the parsing |
| 3540 | process. |
| 3541 | */ |
| 3542 | static int cson_parser_clean( cson_parser * p ) |
| @@ -3571,11 +3571,11 @@ | |
| 3571 | int rc = 0; |
| 3572 | unsigned int len = 1; |
| 3573 | cson_parse_info info = info_ ? *info_ : cson_parse_info_empty; |
| 3574 | cson_parser p = cson_parser_empty; |
| 3575 | if( ! tgt || ! src ) return cson_rc.ArgError; |
| 3576 | |
| 3577 | { |
| 3578 | JSON_config jopt = {0}; |
| 3579 | init_JSON_config( &jopt ); |
| 3580 | jopt.allow_comments = opt.allowComments; |
| 3581 | jopt.depth = opt.maxDepth; |
| @@ -4640,11 +4640,11 @@ | |
| 4640 | #endif |
| 4641 | #undef TRY_SHARING |
| 4642 | cson_value_add_reference(rc); |
| 4643 | return rc; |
| 4644 | } |
| 4645 | |
| 4646 | static cson_value * cson_value_clone_array( cson_value const * orig ) |
| 4647 | { |
| 4648 | unsigned int i = 0; |
| 4649 | cson_array const * asrc = cson_value_get_array( orig ); |
| 4650 | unsigned int alen = cson_array_length_get( asrc ); |
| @@ -4680,11 +4680,11 @@ | |
| 4680 | cson_value_free(cl)/*remove our artificial reference */; |
| 4681 | } |
| 4682 | } |
| 4683 | return destV; |
| 4684 | } |
| 4685 | |
| 4686 | static cson_value * cson_value_clone_object( cson_value const * orig ) |
| 4687 | { |
| 4688 | cson_object const * src = cson_value_get_object( orig ); |
| 4689 | cson_value * destV = NULL; |
| 4690 | cson_object * dest = NULL; |
| @@ -4834,11 +4834,11 @@ | |
| 4834 | } |
| 4835 | case CSON_TYPE_STRING: { |
| 4836 | cson_string const * jstr = cson_value_get_string(orig); |
| 4837 | unsigned const int slen = cson_string_length_bytes( jstr ); |
| 4838 | assert( NULL != jstr ); |
| 4839 | v = cson_strdup( cson_string_cstr( jstr ), slen ); |
| 4840 | break; |
| 4841 | } |
| 4842 | case CSON_TYPE_INTEGER: { |
| 4843 | char buf[BufSize] = {0}; |
| 4844 | if( 0 < sprintf( v, "%"CSON_INT_T_PFMT, cson_value_get_integer(orig)) ) |
| @@ -4887,11 +4887,11 @@ | |
| 4887 | } |
| 4888 | case CSON_TYPE_STRING: { |
| 4889 | cson_string const * jstr = cson_value_get_string(orig); |
| 4890 | unsigned const int slen = cson_string_length_bytes( jstr ); |
| 4891 | assert( NULL != jstr ); |
| 4892 | v = cson_strdup( cson_string_cstr( jstr ), slen ); |
| 4893 | break; |
| 4894 | } |
| 4895 | case CSON_TYPE_INTEGER: { |
| 4896 | char buf[BufSize] = {0}; |
| 4897 | if( 0 < sprintf( v, "%"CSON_INT_T_PFMT, cson_value_get_integer(orig)) ) |
| @@ -5351,11 +5351,11 @@ | |
| 5351 | int rc = 0; |
| 5352 | int colCount = 0; |
| 5353 | assert(st); |
| 5354 | colCount = sqlite3_column_count(st); |
| 5355 | if( colCount <= 0 ) return NULL; |
| 5356 | |
| 5357 | aryV = cson_value_new_array(); |
| 5358 | if( ! aryV ) return NULL; |
| 5359 | ary = cson_value_get_array(aryV); |
| 5360 | assert(ary); |
| 5361 | for( i = 0; (0 ==rc) && (i < colCount); ++i ) |
| @@ -5491,11 +5491,11 @@ | |
| 5491 | aryV = NULL; |
| 5492 | end: |
| 5493 | return aryV; |
| 5494 | } |
| 5495 | |
| 5496 | |
| 5497 | /** |
| 5498 | Internal impl of cson_sqlite3_stmt_to_json() when the 'fat' |
| 5499 | parameter is non-0. |
| 5500 | */ |
| 5501 | static int cson_sqlite3_stmt_to_json_fat( sqlite3_stmt * st, cson_value ** tgt ) |
| @@ -5636,11 +5636,11 @@ | |
| 5636 | int rc = sqlite3_prepare_v2( db, sql, -1, &st, NULL ); |
| 5637 | if( 0 != rc ) return cson_rc.IOError /* FIXME: Better error code? */; |
| 5638 | rc = cson_sqlite3_stmt_to_json( st, tgt, fat ); |
| 5639 | sqlite3_finalize( st ); |
| 5640 | return rc; |
| 5641 | } |
| 5642 | } |
| 5643 | |
| 5644 | int cson_sqlite3_bind_value( sqlite3_stmt * st, int ndx, cson_value const * v ) |
| 5645 | { |
| 5646 | int rc = 0; |
| 5647 |
| --- src/cson_amalgamation.c | |
| +++ src/cson_amalgamation.c | |
| @@ -19,14 +19,14 @@ | |
| 19 | # define JSON_PARSER_DLL_API __declspec(dllexport) |
| 20 | # else |
| 21 | # define JSON_PARSER_DLL_API __declspec(dllimport) |
| 22 | # endif |
| 23 | # else |
| 24 | # define JSON_PARSER_DLL_API |
| 25 | # endif |
| 26 | #else |
| 27 | # define JSON_PARSER_DLL_API |
| 28 | #endif |
| 29 | |
| 30 | /* Determine the integer type use to parse non-floating point numbers */ |
| 31 | #ifdef _WIN32 |
| 32 | typedef __int64 JSON_int_t; |
| @@ -34,22 +34,22 @@ | |
| 34 | #define JSON_PARSER_INTEGER_SPRINTF_TOKEN "%I64d" |
| 35 | #elif (__STDC_VERSION__ >= 199901L) || (HAVE_LONG_LONG == 1) |
| 36 | typedef long long JSON_int_t; |
| 37 | #define JSON_PARSER_INTEGER_SSCANF_TOKEN "%lld" |
| 38 | #define JSON_PARSER_INTEGER_SPRINTF_TOKEN "%lld" |
| 39 | #else |
| 40 | typedef long JSON_int_t; |
| 41 | #define JSON_PARSER_INTEGER_SSCANF_TOKEN "%ld" |
| 42 | #define JSON_PARSER_INTEGER_SPRINTF_TOKEN "%ld" |
| 43 | #endif |
| 44 | |
| 45 | |
| 46 | #ifdef __cplusplus |
| 47 | extern "C" { |
| 48 | #endif |
| 49 | |
| 50 | typedef enum |
| 51 | { |
| 52 | JSON_E_NONE = 0, |
| 53 | JSON_E_INVALID_CHAR, |
| 54 | JSON_E_INVALID_KEYWORD, |
| 55 | JSON_E_INVALID_ESCAPE_SEQUENCE, |
| @@ -60,11 +60,11 @@ | |
| 60 | JSON_E_EXPECTED_KEY, |
| 61 | JSON_E_EXPECTED_COLON, |
| 62 | JSON_E_OUT_OF_MEMORY |
| 63 | } JSON_error; |
| 64 | |
| 65 | typedef enum |
| 66 | { |
| 67 | JSON_T_NONE = 0, |
| 68 | JSON_T_ARRAY_BEGIN, |
| 69 | JSON_T_ARRAY_END, |
| 70 | JSON_T_OBJECT_BEGIN, |
| @@ -80,33 +80,33 @@ | |
| 80 | } JSON_type; |
| 81 | |
| 82 | typedef struct JSON_value_struct { |
| 83 | union { |
| 84 | JSON_int_t integer_value; |
| 85 | |
| 86 | double float_value; |
| 87 | |
| 88 | struct { |
| 89 | const char* value; |
| 90 | size_t length; |
| 91 | } str; |
| 92 | } vu; |
| 93 | } JSON_value; |
| 94 | |
| 95 | typedef struct JSON_parser_struct* JSON_parser; |
| 96 | |
| 97 | /*! \brief JSON parser callback |
| 98 | |
| 99 | \param ctx The pointer passed to new_JSON_parser. |
| 100 | \param type An element of JSON_type but not JSON_T_NONE. |
| 101 | \param value A representation of the parsed value. This parameter is NULL for |
| 102 | JSON_T_ARRAY_BEGIN, JSON_T_ARRAY_END, JSON_T_OBJECT_BEGIN, JSON_T_OBJECT_END, |
| 103 | JSON_T_NULL, JSON_T_TRUE, and JSON_T_FALSE. String values are always returned |
| 104 | as zero-terminated C strings. |
| 105 | |
| 106 | \return Non-zero if parsing should continue, else zero. |
| 107 | */ |
| 108 | typedef int (*JSON_parser_callback)(void* ctx, int type, const JSON_value* value); |
| 109 | |
| 110 | |
| 111 | /** |
| 112 | A typedef for allocator functions semantically compatible with malloc(). |
| @@ -115,11 +115,11 @@ | |
| 115 | /** |
| 116 | A typedef for deallocator functions semantically compatible with free(). |
| 117 | */ |
| 118 | typedef void (*JSON_free_t)(void* mem); |
| 119 | |
| 120 | /*! \brief The structure used to configure a JSON parser object |
| 121 | */ |
| 122 | typedef struct { |
| 123 | /** Pointer to a callback, called when the parser has something to tell |
| 124 | the user. This parameter may be NULL. In this case the input is |
| 125 | merely checked for validity. |
| @@ -176,17 +176,17 @@ | |
| 176 | |
| 177 | \param config. Used to configure the parser. |
| 178 | */ |
| 179 | JSON_PARSER_DLL_API void init_JSON_config(JSON_config * config); |
| 180 | |
| 181 | /*! \brief Create a JSON parser object |
| 182 | |
| 183 | \param config. Used to configure the parser. Set to NULL to use |
| 184 | the default configuration. See init_JSON_config. Its contents are |
| 185 | copied by this function, so it need not outlive the returned |
| 186 | object. |
| 187 | |
| 188 | \return The parser object, which is owned by the caller and must eventually |
| 189 | be freed by calling delete_JSON_parser(). |
| 190 | */ |
| 191 | JSON_PARSER_DLL_API JSON_parser new_JSON_parser(JSON_config const* config); |
| 192 | |
| @@ -200,16 +200,16 @@ | |
| 200 | JSON_PARSER_DLL_API int JSON_parser_char(JSON_parser jc, int next_char); |
| 201 | |
| 202 | /*! \brief Finalize parsing. |
| 203 | |
| 204 | Call this method once after all input characters have been consumed. |
| 205 | |
| 206 | \return Non-zero, if all parsed characters are valid JSON, zero otherwise. |
| 207 | */ |
| 208 | JSON_PARSER_DLL_API int JSON_parser_done(JSON_parser jc); |
| 209 | |
| 210 | /*! \brief Determine if a given string is valid JSON white space |
| 211 | |
| 212 | \return Non-zero if the string is valid, zero otherwise. |
| 213 | */ |
| 214 | JSON_PARSER_DLL_API int JSON_parser_is_legal_white_space_string(const char* s); |
| 215 | |
| @@ -226,12 +226,12 @@ | |
| 226 | JSON_PARSER_DLL_API int JSON_parser_reset(JSON_parser jc); |
| 227 | |
| 228 | |
| 229 | #ifdef __cplusplus |
| 230 | } |
| 231 | #endif |
| 232 | |
| 233 | |
| 234 | #endif /* JSON_PARSER_H */ |
| 235 | /* end file parser/JSON_parser.h */ |
| 236 | /* begin file parser/JSON_parser.c */ |
| 237 | /* |
| @@ -1431,11 +1431,11 @@ | |
| 1431 | #if defined(__cplusplus) |
| 1432 | extern "C" { |
| 1433 | #endif |
| 1434 | |
| 1435 | |
| 1436 | |
| 1437 | /** |
| 1438 | This type holds the "vtbl" for type-specific operations when |
| 1439 | working with cson_value objects. |
| 1440 | |
| 1441 | All cson_values of a given logical type share a pointer to a single |
| @@ -1607,11 +1607,11 @@ | |
| 1607 | #define CSON_OBJ(V) CSON_CAST(cson_object,(V)) |
| 1608 | #define CSON_ARRAY(V) CSON_CAST(cson_array,(V)) |
| 1609 | |
| 1610 | /** |
| 1611 | Holds special shared "constant" (though they are non-const) |
| 1612 | values. |
| 1613 | */ |
| 1614 | static struct CSON_EMPTY_HOLDER_ |
| 1615 | { |
| 1616 | char trueValue; |
| 1617 | cson_string stringValue; |
| @@ -1620,17 +1620,17 @@ | |
| 1620 | cson_string_empty_m |
| 1621 | }; |
| 1622 | |
| 1623 | /** |
| 1624 | Indexes into the CSON_SPECIAL_VALUES array. |
| 1625 | |
| 1626 | If this enum changes in any way, |
| 1627 | makes damned sure that CSON_SPECIAL_VALUES is updated |
| 1628 | to match!!! |
| 1629 | */ |
| 1630 | enum CSON_INTERNAL_VALUES { |
| 1631 | |
| 1632 | CSON_VAL_UNDEF = 0, |
| 1633 | CSON_VAL_NULL = 1, |
| 1634 | CSON_VAL_TRUE = 2, |
| 1635 | CSON_VAL_FALSE = 3, |
| 1636 | CSON_VAL_INT_0 = 4, |
| @@ -1642,11 +1642,11 @@ | |
| 1642 | /** |
| 1643 | Some "special" shared cson_value instances. |
| 1644 | |
| 1645 | These values MUST be initialized in the order specified |
| 1646 | by the CSON_INTERNAL_VALUES enum. |
| 1647 | |
| 1648 | Note that they are not const because they are used as |
| 1649 | shared-allocation objects in non-const contexts. However, the |
| 1650 | public API provides no way to modifying them, and clients who |
| 1651 | modify values directly are subject to The Wrath of Undefined |
| 1652 | Behaviour. |
| @@ -1665,11 +1665,11 @@ | |
| 1665 | |
| 1666 | /** |
| 1667 | Returns non-0 (true) if m is one of our special |
| 1668 | "built-in" values, e.g. from CSON_SPECIAL_VALUES and some |
| 1669 | "empty" values. |
| 1670 | |
| 1671 | If this returns true, m MUST NOT be free()d! |
| 1672 | */ |
| 1673 | static char cson_value_is_builtin( void const * m ) |
| 1674 | { |
| 1675 | if((m >= (void const *)&CSON_EMPTY_HOLDER) |
| @@ -2183,11 +2183,11 @@ | |
| 2183 | static int cson_value_list_visit( cson_value_list * self, |
| 2184 | int (*visitor)(cson_value * obj, void * visitorState ), |
| 2185 | void * visitorState ); |
| 2186 | #endif |
| 2187 | #endif |
| 2188 | |
| 2189 | #if 0 |
| 2190 | # define LIST_T cson_value_list |
| 2191 | # define VALUE_T cson_value * |
| 2192 | # define VALUE_T_IS_PTR 1 |
| 2193 | # define LIST_T cson_kvp_list |
| @@ -2362,11 +2362,11 @@ | |
| 2362 | return cson_value_object_alloc(); |
| 2363 | } |
| 2364 | |
| 2365 | cson_object * cson_new_object() |
| 2366 | { |
| 2367 | |
| 2368 | return cson_value_get_object( cson_value_new_object() ); |
| 2369 | } |
| 2370 | |
| 2371 | cson_value * cson_value_new_array() |
| 2372 | { |
| @@ -2608,11 +2608,11 @@ | |
| 2608 | { |
| 2609 | cson_int_t i = 0; |
| 2610 | int rc = 0; |
| 2611 | switch(val->api->typeID) |
| 2612 | { |
| 2613 | case CSON_TYPE_UNDEF: |
| 2614 | case CSON_TYPE_NULL: |
| 2615 | i = 0; |
| 2616 | break; |
| 2617 | case CSON_TYPE_BOOL: { |
| 2618 | char b = 0; |
| @@ -2661,11 +2661,11 @@ | |
| 2661 | { |
| 2662 | cson_double_t d = 0.0; |
| 2663 | int rc = 0; |
| 2664 | switch(val->api->typeID) |
| 2665 | { |
| 2666 | case CSON_TYPE_UNDEF: |
| 2667 | case CSON_TYPE_NULL: |
| 2668 | d = 0; |
| 2669 | break; |
| 2670 | case CSON_TYPE_BOOL: { |
| 2671 | char b = 0; |
| @@ -2791,11 +2791,11 @@ | |
| 2791 | #if 0 |
| 2792 | /** |
| 2793 | Removes and returns the last value from the given array, |
| 2794 | shrinking its size by 1. Returns NULL if ar is NULL, |
| 2795 | ar->list.count is 0, or the element at that index is NULL. |
| 2796 | |
| 2797 | |
| 2798 | If removeRef is true then cson_value_free() is called to remove |
| 2799 | ar's reference count for the value. In that case NULL is returned, |
| 2800 | even if the object still has live references. If removeRef is false |
| 2801 | then the caller takes over ownership of that reference count point. |
| @@ -2858,11 +2858,11 @@ | |
| 2858 | #if !defined(NDEBUG) && CSON_VOID_PTR_IS_BIG |
| 2859 | assert( sizeof(cson_int_t) <= sizeof(void *) ); |
| 2860 | #endif |
| 2861 | if( c ) |
| 2862 | { |
| 2863 | memcpy(CSON_INT(c), &v, sizeof(v)); |
| 2864 | } |
| 2865 | return c; |
| 2866 | } |
| 2867 | } |
| 2868 | |
| @@ -3068,11 +3068,11 @@ | |
| 3068 | qsort( obj->kvp.list, obj->kvp.count, sizeof(cson_kvp*), |
| 3069 | cson_kvp_cmp ); |
| 3070 | } |
| 3071 | |
| 3072 | } |
| 3073 | #endif |
| 3074 | |
| 3075 | int cson_object_unset( cson_object * obj, char const * key ) |
| 3076 | { |
| 3077 | if( ! obj || !key || !*key ) return cson_rc.ArgError; |
| 3078 | else |
| @@ -3238,11 +3238,11 @@ | |
| 3238 | using p->key. In any other case cson_rc.InternalError is returned. |
| 3239 | |
| 3240 | Returns cson_rc.AllocError if an allocation fails. |
| 3241 | |
| 3242 | Returns 0 on success. On error, parsing must be ceased immediately. |
| 3243 | |
| 3244 | Ownership of val is ALWAYS TRANSFERED to this function. If this |
| 3245 | function fails, val will be cleaned up and destroyed. (This |
| 3246 | simplifies error handling in the core parser.) |
| 3247 | */ |
| 3248 | static int cson_parser_set_key( cson_parser * p, cson_value * val ) |
| @@ -3485,11 +3485,11 @@ | |
| 3485 | ++p->totalKeyCount; |
| 3486 | break; |
| 3487 | } |
| 3488 | case JSON_T_STRING: { |
| 3489 | cson_value * v = cson_value_new_string( value->vu.str.value, value->vu.str.length ); |
| 3490 | rc = ( NULL == v ) |
| 3491 | ? cson_rc.AllocError |
| 3492 | : cson_parser_push_value( p, v ); |
| 3493 | break; |
| 3494 | } |
| 3495 | default: |
| @@ -3532,11 +3532,11 @@ | |
| 3532 | To properly take over ownership of the parser's root node on a |
| 3533 | successful parse: |
| 3534 | |
| 3535 | - Copy p->root's pointer and set p->root to NULL. |
| 3536 | - Eventually free up p->root with cson_value_free(). |
| 3537 | |
| 3538 | If you do not set p->root to NULL, p->root will be freed along with |
| 3539 | any other items inserted into it (or under it) during the parsing |
| 3540 | process. |
| 3541 | */ |
| 3542 | static int cson_parser_clean( cson_parser * p ) |
| @@ -3571,11 +3571,11 @@ | |
| 3571 | int rc = 0; |
| 3572 | unsigned int len = 1; |
| 3573 | cson_parse_info info = info_ ? *info_ : cson_parse_info_empty; |
| 3574 | cson_parser p = cson_parser_empty; |
| 3575 | if( ! tgt || ! src ) return cson_rc.ArgError; |
| 3576 | |
| 3577 | { |
| 3578 | JSON_config jopt = {0}; |
| 3579 | init_JSON_config( &jopt ); |
| 3580 | jopt.allow_comments = opt.allowComments; |
| 3581 | jopt.depth = opt.maxDepth; |
| @@ -4640,11 +4640,11 @@ | |
| 4640 | #endif |
| 4641 | #undef TRY_SHARING |
| 4642 | cson_value_add_reference(rc); |
| 4643 | return rc; |
| 4644 | } |
| 4645 | |
| 4646 | static cson_value * cson_value_clone_array( cson_value const * orig ) |
| 4647 | { |
| 4648 | unsigned int i = 0; |
| 4649 | cson_array const * asrc = cson_value_get_array( orig ); |
| 4650 | unsigned int alen = cson_array_length_get( asrc ); |
| @@ -4680,11 +4680,11 @@ | |
| 4680 | cson_value_free(cl)/*remove our artificial reference */; |
| 4681 | } |
| 4682 | } |
| 4683 | return destV; |
| 4684 | } |
| 4685 | |
| 4686 | static cson_value * cson_value_clone_object( cson_value const * orig ) |
| 4687 | { |
| 4688 | cson_object const * src = cson_value_get_object( orig ); |
| 4689 | cson_value * destV = NULL; |
| 4690 | cson_object * dest = NULL; |
| @@ -4834,11 +4834,11 @@ | |
| 4834 | } |
| 4835 | case CSON_TYPE_STRING: { |
| 4836 | cson_string const * jstr = cson_value_get_string(orig); |
| 4837 | unsigned const int slen = cson_string_length_bytes( jstr ); |
| 4838 | assert( NULL != jstr ); |
| 4839 | v = cson_strdup( cson_string_cstr( jstr ), slen ); |
| 4840 | break; |
| 4841 | } |
| 4842 | case CSON_TYPE_INTEGER: { |
| 4843 | char buf[BufSize] = {0}; |
| 4844 | if( 0 < sprintf( v, "%"CSON_INT_T_PFMT, cson_value_get_integer(orig)) ) |
| @@ -4887,11 +4887,11 @@ | |
| 4887 | } |
| 4888 | case CSON_TYPE_STRING: { |
| 4889 | cson_string const * jstr = cson_value_get_string(orig); |
| 4890 | unsigned const int slen = cson_string_length_bytes( jstr ); |
| 4891 | assert( NULL != jstr ); |
| 4892 | v = cson_strdup( cson_string_cstr( jstr ), slen ); |
| 4893 | break; |
| 4894 | } |
| 4895 | case CSON_TYPE_INTEGER: { |
| 4896 | char buf[BufSize] = {0}; |
| 4897 | if( 0 < sprintf( v, "%"CSON_INT_T_PFMT, cson_value_get_integer(orig)) ) |
| @@ -5351,11 +5351,11 @@ | |
| 5351 | int rc = 0; |
| 5352 | int colCount = 0; |
| 5353 | assert(st); |
| 5354 | colCount = sqlite3_column_count(st); |
| 5355 | if( colCount <= 0 ) return NULL; |
| 5356 | |
| 5357 | aryV = cson_value_new_array(); |
| 5358 | if( ! aryV ) return NULL; |
| 5359 | ary = cson_value_get_array(aryV); |
| 5360 | assert(ary); |
| 5361 | for( i = 0; (0 ==rc) && (i < colCount); ++i ) |
| @@ -5491,11 +5491,11 @@ | |
| 5491 | aryV = NULL; |
| 5492 | end: |
| 5493 | return aryV; |
| 5494 | } |
| 5495 | |
| 5496 | |
| 5497 | /** |
| 5498 | Internal impl of cson_sqlite3_stmt_to_json() when the 'fat' |
| 5499 | parameter is non-0. |
| 5500 | */ |
| 5501 | static int cson_sqlite3_stmt_to_json_fat( sqlite3_stmt * st, cson_value ** tgt ) |
| @@ -5636,11 +5636,11 @@ | |
| 5636 | int rc = sqlite3_prepare_v2( db, sql, -1, &st, NULL ); |
| 5637 | if( 0 != rc ) return cson_rc.IOError /* FIXME: Better error code? */; |
| 5638 | rc = cson_sqlite3_stmt_to_json( st, tgt, fat ); |
| 5639 | sqlite3_finalize( st ); |
| 5640 | return rc; |
| 5641 | } |
| 5642 | } |
| 5643 | |
| 5644 | int cson_sqlite3_bind_value( sqlite3_stmt * st, int ndx, cson_value const * v ) |
| 5645 | { |
| 5646 | int rc = 0; |
| 5647 |
+13
-14
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -1420,11 +1420,11 @@ | ||
| 1420 | 1420 | if( fetch_baseline(pParent, 0) || fetch_baseline(pChild, 0) ){ |
| 1421 | 1421 | manifest_destroy(*ppOther); |
| 1422 | 1422 | return; |
| 1423 | 1423 | } |
| 1424 | 1424 | isPublic = !content_is_private(mid); |
| 1425 | - | |
| 1425 | + | |
| 1426 | 1426 | /* If pParent is not the primary parent of pChild, and the primary |
| 1427 | 1427 | ** parent of pChild is a phantom, then abort this routine without |
| 1428 | 1428 | ** doing any work. The mlink entries will be computed when the |
| 1429 | 1429 | ** primary parent dephantomizes. |
| 1430 | 1430 | */ |
| @@ -1530,11 +1530,11 @@ | ||
| 1530 | 1530 | isPublic, isPrim, 0); |
| 1531 | 1531 | } |
| 1532 | 1532 | } |
| 1533 | 1533 | } |
| 1534 | 1534 | manifest_cache_insert(*ppOther); |
| 1535 | - | |
| 1535 | + | |
| 1536 | 1536 | /* If pParent is the primary parent of pChild, also run this analysis |
| 1537 | 1537 | ** for all merge parents of pChild |
| 1538 | 1538 | */ |
| 1539 | 1539 | if( isPrim ){ |
| 1540 | 1540 | for(i=1; i<pChild->nParent; i++){ |
| @@ -1564,11 +1564,11 @@ | ||
| 1564 | 1564 | int parentid = 0; |
| 1565 | 1565 | char zBaseId[30]; /* Baseline manifest RID for deltas. "NULL" otherwise */ |
| 1566 | 1566 | Stmt q; |
| 1567 | 1567 | |
| 1568 | 1568 | if( p->zBaseline ){ |
| 1569 | - sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", | |
| 1569 | + sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", | |
| 1570 | 1570 | uuid_to_rid(p->zBaseline,1)); |
| 1571 | 1571 | }else{ |
| 1572 | 1572 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL"); |
| 1573 | 1573 | } |
| 1574 | 1574 | for(i=0; i<nParent; i++){ |
| @@ -1611,11 +1611,11 @@ | ||
| 1611 | 1611 | return parentid; |
| 1612 | 1612 | } |
| 1613 | 1613 | |
| 1614 | 1614 | /* |
| 1615 | 1615 | ** There exists a "parent" tag against checkin rid that has value zValue. |
| 1616 | -** If value is well-formed (meaning that it is a list of UUIDs), then use | |
| 1616 | +** If value is well-formed (meaning that it is a list of UUIDs), then use | |
| 1617 | 1617 | ** zValue to reparent check-in rid. |
| 1618 | 1618 | */ |
| 1619 | 1619 | void manifest_reparent_checkin(int rid, const char *zValue){ |
| 1620 | 1620 | int nParent; |
| 1621 | 1621 | char *zCopy = 0; |
| @@ -1632,11 +1632,11 @@ | ||
| 1632 | 1632 | azParent[i] = &zCopy[i*(UUID_SIZE+1)]; |
| 1633 | 1633 | if( i<nParent-1 && azParent[i][UUID_SIZE]!=' ' ) break; |
| 1634 | 1634 | azParent[i][UUID_SIZE] = 0; |
| 1635 | 1635 | if( !validate16(azParent[i],UUID_SIZE) ) break; |
| 1636 | 1636 | } |
| 1637 | - if( i==nParent | |
| 1637 | + if( i==nParent | |
| 1638 | 1638 | && !db_exists("SELECT 1 FROM plink WHERE cid=%d AND pid=%d", |
| 1639 | 1639 | rid, uuid_to_rid(azParent[0],0)) |
| 1640 | 1640 | ){ |
| 1641 | 1641 | p = manifest_get(rid, CFTYPE_MANIFEST, 0); |
| 1642 | 1642 | } |
| @@ -1704,11 +1704,11 @@ | ||
| 1704 | 1704 | rc = xfer_run_common_script(); |
| 1705 | 1705 | if( rc==TH_OK ){ |
| 1706 | 1706 | zScript = xfer_ticket_code(); |
| 1707 | 1707 | } |
| 1708 | 1708 | } |
| 1709 | - db_prepare(&q, | |
| 1709 | + db_prepare(&q, | |
| 1710 | 1710 | "SELECT rid, value FROM tagxref" |
| 1711 | 1711 | " WHERE tagid=%d AND tagtype=1", |
| 1712 | 1712 | TAG_PARENT |
| 1713 | 1713 | ); |
| 1714 | 1714 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -1921,11 +1921,10 @@ | ||
| 1921 | 1921 | ** file, is a legacy of its original use. |
| 1922 | 1922 | */ |
| 1923 | 1923 | int manifest_crosslink(int rid, Blob *pContent, int flags){ |
| 1924 | 1924 | int i, rc = TH_OK; |
| 1925 | 1925 | Manifest *p; |
| 1926 | - Stmt q; | |
| 1927 | 1926 | int parentid = 0; |
| 1928 | 1927 | int permitHooks = (flags & MC_PERMIT_HOOKS); |
| 1929 | 1928 | const char *zScript = 0; |
| 1930 | 1929 | const char *zUuid = 0; |
| 1931 | 1930 | |
| @@ -2147,21 +2146,21 @@ | ||
| 2147 | 2146 | char *zComment; |
| 2148 | 2147 | if( isAdd ){ |
| 2149 | 2148 | zComment = mprintf( |
| 2150 | 2149 | "Add attachment [/artifact/%!S|%h] to" |
| 2151 | 2150 | " tech note [/technote/%!S|%S]", |
| 2152 | - zSrc, zName, zTarget, zTarget); | |
| 2151 | + zSrc, zName, zTarget, zTarget); | |
| 2153 | 2152 | }else{ |
| 2154 | 2153 | zComment = mprintf( |
| 2155 | 2154 | "Delete attachment \"%h\" from" |
| 2156 | 2155 | " tech note [/technote/%!S|%S]", |
| 2157 | 2156 | zName, zTarget, zTarget); |
| 2158 | 2157 | } |
| 2159 | 2158 | db_multi_exec("UPDATE event SET comment=%Q, type='e'" |
| 2160 | 2159 | " WHERE objid=%Q", |
| 2161 | 2160 | zComment, zAttachId); |
| 2162 | - fossil_free(zComment); | |
| 2161 | + fossil_free(zComment); | |
| 2163 | 2162 | } |
| 2164 | 2163 | db_finalize(&qatt); |
| 2165 | 2164 | } |
| 2166 | 2165 | if( p->type==CFTYPE_TICKET ){ |
| 2167 | 2166 | char *zTag; |
| @@ -2194,11 +2193,11 @@ | ||
| 2194 | 2193 | zName, zTarget, zTarget); |
| 2195 | 2194 | } |
| 2196 | 2195 | db_multi_exec("UPDATE event SET comment=%Q, type='t'" |
| 2197 | 2196 | " WHERE objid=%Q", |
| 2198 | 2197 | zComment, zAttachId); |
| 2199 | - fossil_free(zComment); | |
| 2198 | + fossil_free(zComment); | |
| 2200 | 2199 | } |
| 2201 | 2200 | db_finalize(&qatt); |
| 2202 | 2201 | } |
| 2203 | 2202 | if( p->type==CFTYPE_ATTACHMENT ){ |
| 2204 | 2203 | char *zComment = 0; |
| @@ -2205,18 +2204,18 @@ | ||
| 2205 | 2204 | const char isAdd = (p->zAttachSrc && p->zAttachSrc[0]) ? 1 : 0; |
| 2206 | 2205 | /* We assume that we're attaching to a wiki page until we |
| 2207 | 2206 | ** prove otherwise (which could on a later artifact if we |
| 2208 | 2207 | ** process the attachment artifact before the artifact to |
| 2209 | 2208 | ** which it is attached!) */ |
| 2210 | - char attachToType = 'w'; | |
| 2209 | + char attachToType = 'w'; | |
| 2211 | 2210 | if( fossil_is_uuid(p->zAttachTarget) ){ |
| 2212 | 2211 | if( db_exists("SELECT 1 FROM tag WHERE tagname='tkt-%q'", |
| 2213 | 2212 | p->zAttachTarget) |
| 2214 | 2213 | ){ |
| 2215 | 2214 | attachToType = 't'; /* Attaching to known ticket */ |
| 2216 | 2215 | }else if( db_exists("SELECT 1 FROM tag WHERE tagname='event-%q'", |
| 2217 | - p->zAttachTarget) | |
| 2216 | + p->zAttachTarget) | |
| 2218 | 2217 | ){ |
| 2219 | 2218 | attachToType = 'e'; /* Attaching to known tech note */ |
| 2220 | 2219 | } |
| 2221 | 2220 | } |
| 2222 | 2221 | db_multi_exec( |
| @@ -2245,18 +2244,18 @@ | ||
| 2245 | 2244 | } |
| 2246 | 2245 | }else if( 'e' == attachToType ){ |
| 2247 | 2246 | if( isAdd ){ |
| 2248 | 2247 | zComment = mprintf( |
| 2249 | 2248 | "Add attachment [/artifact/%!S|%h] to tech note [/technote/%!S|%S]", |
| 2250 | - p->zAttachSrc, p->zAttachName, p->zAttachTarget, p->zAttachTarget); | |
| 2249 | + p->zAttachSrc, p->zAttachName, p->zAttachTarget, p->zAttachTarget); | |
| 2251 | 2250 | }else{ |
| 2252 | 2251 | zComment = mprintf( |
| 2253 | 2252 | "Delete attachment \"/artifact/%!S|%h\" from" |
| 2254 | 2253 | " tech note [/technote/%!S|%S]", |
| 2255 | 2254 | p->zAttachName, p->zAttachName, |
| 2256 | 2255 | p->zAttachTarget,p->zAttachTarget); |
| 2257 | - } | |
| 2256 | + } | |
| 2258 | 2257 | }else{ |
| 2259 | 2258 | if( isAdd ){ |
| 2260 | 2259 | zComment = mprintf( |
| 2261 | 2260 | "Add attachment [/artifact/%!S|%h] to ticket [%!S|%S]", |
| 2262 | 2261 | p->zAttachSrc, p->zAttachName, p->zAttachTarget, p->zAttachTarget); |
| 2263 | 2262 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1420,11 +1420,11 @@ | |
| 1420 | if( fetch_baseline(pParent, 0) || fetch_baseline(pChild, 0) ){ |
| 1421 | manifest_destroy(*ppOther); |
| 1422 | return; |
| 1423 | } |
| 1424 | isPublic = !content_is_private(mid); |
| 1425 | |
| 1426 | /* If pParent is not the primary parent of pChild, and the primary |
| 1427 | ** parent of pChild is a phantom, then abort this routine without |
| 1428 | ** doing any work. The mlink entries will be computed when the |
| 1429 | ** primary parent dephantomizes. |
| 1430 | */ |
| @@ -1530,11 +1530,11 @@ | |
| 1530 | isPublic, isPrim, 0); |
| 1531 | } |
| 1532 | } |
| 1533 | } |
| 1534 | manifest_cache_insert(*ppOther); |
| 1535 | |
| 1536 | /* If pParent is the primary parent of pChild, also run this analysis |
| 1537 | ** for all merge parents of pChild |
| 1538 | */ |
| 1539 | if( isPrim ){ |
| 1540 | for(i=1; i<pChild->nParent; i++){ |
| @@ -1564,11 +1564,11 @@ | |
| 1564 | int parentid = 0; |
| 1565 | char zBaseId[30]; /* Baseline manifest RID for deltas. "NULL" otherwise */ |
| 1566 | Stmt q; |
| 1567 | |
| 1568 | if( p->zBaseline ){ |
| 1569 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", |
| 1570 | uuid_to_rid(p->zBaseline,1)); |
| 1571 | }else{ |
| 1572 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL"); |
| 1573 | } |
| 1574 | for(i=0; i<nParent; i++){ |
| @@ -1611,11 +1611,11 @@ | |
| 1611 | return parentid; |
| 1612 | } |
| 1613 | |
| 1614 | /* |
| 1615 | ** There exists a "parent" tag against checkin rid that has value zValue. |
| 1616 | ** If value is well-formed (meaning that it is a list of UUIDs), then use |
| 1617 | ** zValue to reparent check-in rid. |
| 1618 | */ |
| 1619 | void manifest_reparent_checkin(int rid, const char *zValue){ |
| 1620 | int nParent; |
| 1621 | char *zCopy = 0; |
| @@ -1632,11 +1632,11 @@ | |
| 1632 | azParent[i] = &zCopy[i*(UUID_SIZE+1)]; |
| 1633 | if( i<nParent-1 && azParent[i][UUID_SIZE]!=' ' ) break; |
| 1634 | azParent[i][UUID_SIZE] = 0; |
| 1635 | if( !validate16(azParent[i],UUID_SIZE) ) break; |
| 1636 | } |
| 1637 | if( i==nParent |
| 1638 | && !db_exists("SELECT 1 FROM plink WHERE cid=%d AND pid=%d", |
| 1639 | rid, uuid_to_rid(azParent[0],0)) |
| 1640 | ){ |
| 1641 | p = manifest_get(rid, CFTYPE_MANIFEST, 0); |
| 1642 | } |
| @@ -1704,11 +1704,11 @@ | |
| 1704 | rc = xfer_run_common_script(); |
| 1705 | if( rc==TH_OK ){ |
| 1706 | zScript = xfer_ticket_code(); |
| 1707 | } |
| 1708 | } |
| 1709 | db_prepare(&q, |
| 1710 | "SELECT rid, value FROM tagxref" |
| 1711 | " WHERE tagid=%d AND tagtype=1", |
| 1712 | TAG_PARENT |
| 1713 | ); |
| 1714 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -1921,11 +1921,10 @@ | |
| 1921 | ** file, is a legacy of its original use. |
| 1922 | */ |
| 1923 | int manifest_crosslink(int rid, Blob *pContent, int flags){ |
| 1924 | int i, rc = TH_OK; |
| 1925 | Manifest *p; |
| 1926 | Stmt q; |
| 1927 | int parentid = 0; |
| 1928 | int permitHooks = (flags & MC_PERMIT_HOOKS); |
| 1929 | const char *zScript = 0; |
| 1930 | const char *zUuid = 0; |
| 1931 | |
| @@ -2147,21 +2146,21 @@ | |
| 2147 | char *zComment; |
| 2148 | if( isAdd ){ |
| 2149 | zComment = mprintf( |
| 2150 | "Add attachment [/artifact/%!S|%h] to" |
| 2151 | " tech note [/technote/%!S|%S]", |
| 2152 | zSrc, zName, zTarget, zTarget); |
| 2153 | }else{ |
| 2154 | zComment = mprintf( |
| 2155 | "Delete attachment \"%h\" from" |
| 2156 | " tech note [/technote/%!S|%S]", |
| 2157 | zName, zTarget, zTarget); |
| 2158 | } |
| 2159 | db_multi_exec("UPDATE event SET comment=%Q, type='e'" |
| 2160 | " WHERE objid=%Q", |
| 2161 | zComment, zAttachId); |
| 2162 | fossil_free(zComment); |
| 2163 | } |
| 2164 | db_finalize(&qatt); |
| 2165 | } |
| 2166 | if( p->type==CFTYPE_TICKET ){ |
| 2167 | char *zTag; |
| @@ -2194,11 +2193,11 @@ | |
| 2194 | zName, zTarget, zTarget); |
| 2195 | } |
| 2196 | db_multi_exec("UPDATE event SET comment=%Q, type='t'" |
| 2197 | " WHERE objid=%Q", |
| 2198 | zComment, zAttachId); |
| 2199 | fossil_free(zComment); |
| 2200 | } |
| 2201 | db_finalize(&qatt); |
| 2202 | } |
| 2203 | if( p->type==CFTYPE_ATTACHMENT ){ |
| 2204 | char *zComment = 0; |
| @@ -2205,18 +2204,18 @@ | |
| 2205 | const char isAdd = (p->zAttachSrc && p->zAttachSrc[0]) ? 1 : 0; |
| 2206 | /* We assume that we're attaching to a wiki page until we |
| 2207 | ** prove otherwise (which could on a later artifact if we |
| 2208 | ** process the attachment artifact before the artifact to |
| 2209 | ** which it is attached!) */ |
| 2210 | char attachToType = 'w'; |
| 2211 | if( fossil_is_uuid(p->zAttachTarget) ){ |
| 2212 | if( db_exists("SELECT 1 FROM tag WHERE tagname='tkt-%q'", |
| 2213 | p->zAttachTarget) |
| 2214 | ){ |
| 2215 | attachToType = 't'; /* Attaching to known ticket */ |
| 2216 | }else if( db_exists("SELECT 1 FROM tag WHERE tagname='event-%q'", |
| 2217 | p->zAttachTarget) |
| 2218 | ){ |
| 2219 | attachToType = 'e'; /* Attaching to known tech note */ |
| 2220 | } |
| 2221 | } |
| 2222 | db_multi_exec( |
| @@ -2245,18 +2244,18 @@ | |
| 2245 | } |
| 2246 | }else if( 'e' == attachToType ){ |
| 2247 | if( isAdd ){ |
| 2248 | zComment = mprintf( |
| 2249 | "Add attachment [/artifact/%!S|%h] to tech note [/technote/%!S|%S]", |
| 2250 | p->zAttachSrc, p->zAttachName, p->zAttachTarget, p->zAttachTarget); |
| 2251 | }else{ |
| 2252 | zComment = mprintf( |
| 2253 | "Delete attachment \"/artifact/%!S|%h\" from" |
| 2254 | " tech note [/technote/%!S|%S]", |
| 2255 | p->zAttachName, p->zAttachName, |
| 2256 | p->zAttachTarget,p->zAttachTarget); |
| 2257 | } |
| 2258 | }else{ |
| 2259 | if( isAdd ){ |
| 2260 | zComment = mprintf( |
| 2261 | "Add attachment [/artifact/%!S|%h] to ticket [%!S|%S]", |
| 2262 | p->zAttachSrc, p->zAttachName, p->zAttachTarget, p->zAttachTarget); |
| 2263 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -1420,11 +1420,11 @@ | |
| 1420 | if( fetch_baseline(pParent, 0) || fetch_baseline(pChild, 0) ){ |
| 1421 | manifest_destroy(*ppOther); |
| 1422 | return; |
| 1423 | } |
| 1424 | isPublic = !content_is_private(mid); |
| 1425 | |
| 1426 | /* If pParent is not the primary parent of pChild, and the primary |
| 1427 | ** parent of pChild is a phantom, then abort this routine without |
| 1428 | ** doing any work. The mlink entries will be computed when the |
| 1429 | ** primary parent dephantomizes. |
| 1430 | */ |
| @@ -1530,11 +1530,11 @@ | |
| 1530 | isPublic, isPrim, 0); |
| 1531 | } |
| 1532 | } |
| 1533 | } |
| 1534 | manifest_cache_insert(*ppOther); |
| 1535 | |
| 1536 | /* If pParent is the primary parent of pChild, also run this analysis |
| 1537 | ** for all merge parents of pChild |
| 1538 | */ |
| 1539 | if( isPrim ){ |
| 1540 | for(i=1; i<pChild->nParent; i++){ |
| @@ -1564,11 +1564,11 @@ | |
| 1564 | int parentid = 0; |
| 1565 | char zBaseId[30]; /* Baseline manifest RID for deltas. "NULL" otherwise */ |
| 1566 | Stmt q; |
| 1567 | |
| 1568 | if( p->zBaseline ){ |
| 1569 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", |
| 1570 | uuid_to_rid(p->zBaseline,1)); |
| 1571 | }else{ |
| 1572 | sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL"); |
| 1573 | } |
| 1574 | for(i=0; i<nParent; i++){ |
| @@ -1611,11 +1611,11 @@ | |
| 1611 | return parentid; |
| 1612 | } |
| 1613 | |
| 1614 | /* |
| 1615 | ** There exists a "parent" tag against checkin rid that has value zValue. |
| 1616 | ** If value is well-formed (meaning that it is a list of UUIDs), then use |
| 1617 | ** zValue to reparent check-in rid. |
| 1618 | */ |
| 1619 | void manifest_reparent_checkin(int rid, const char *zValue){ |
| 1620 | int nParent; |
| 1621 | char *zCopy = 0; |
| @@ -1632,11 +1632,11 @@ | |
| 1632 | azParent[i] = &zCopy[i*(UUID_SIZE+1)]; |
| 1633 | if( i<nParent-1 && azParent[i][UUID_SIZE]!=' ' ) break; |
| 1634 | azParent[i][UUID_SIZE] = 0; |
| 1635 | if( !validate16(azParent[i],UUID_SIZE) ) break; |
| 1636 | } |
| 1637 | if( i==nParent |
| 1638 | && !db_exists("SELECT 1 FROM plink WHERE cid=%d AND pid=%d", |
| 1639 | rid, uuid_to_rid(azParent[0],0)) |
| 1640 | ){ |
| 1641 | p = manifest_get(rid, CFTYPE_MANIFEST, 0); |
| 1642 | } |
| @@ -1704,11 +1704,11 @@ | |
| 1704 | rc = xfer_run_common_script(); |
| 1705 | if( rc==TH_OK ){ |
| 1706 | zScript = xfer_ticket_code(); |
| 1707 | } |
| 1708 | } |
| 1709 | db_prepare(&q, |
| 1710 | "SELECT rid, value FROM tagxref" |
| 1711 | " WHERE tagid=%d AND tagtype=1", |
| 1712 | TAG_PARENT |
| 1713 | ); |
| 1714 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -1921,11 +1921,10 @@ | |
| 1921 | ** file, is a legacy of its original use. |
| 1922 | */ |
| 1923 | int manifest_crosslink(int rid, Blob *pContent, int flags){ |
| 1924 | int i, rc = TH_OK; |
| 1925 | Manifest *p; |
| 1926 | int parentid = 0; |
| 1927 | int permitHooks = (flags & MC_PERMIT_HOOKS); |
| 1928 | const char *zScript = 0; |
| 1929 | const char *zUuid = 0; |
| 1930 | |
| @@ -2147,21 +2146,21 @@ | |
| 2146 | char *zComment; |
| 2147 | if( isAdd ){ |
| 2148 | zComment = mprintf( |
| 2149 | "Add attachment [/artifact/%!S|%h] to" |
| 2150 | " tech note [/technote/%!S|%S]", |
| 2151 | zSrc, zName, zTarget, zTarget); |
| 2152 | }else{ |
| 2153 | zComment = mprintf( |
| 2154 | "Delete attachment \"%h\" from" |
| 2155 | " tech note [/technote/%!S|%S]", |
| 2156 | zName, zTarget, zTarget); |
| 2157 | } |
| 2158 | db_multi_exec("UPDATE event SET comment=%Q, type='e'" |
| 2159 | " WHERE objid=%Q", |
| 2160 | zComment, zAttachId); |
| 2161 | fossil_free(zComment); |
| 2162 | } |
| 2163 | db_finalize(&qatt); |
| 2164 | } |
| 2165 | if( p->type==CFTYPE_TICKET ){ |
| 2166 | char *zTag; |
| @@ -2194,11 +2193,11 @@ | |
| 2193 | zName, zTarget, zTarget); |
| 2194 | } |
| 2195 | db_multi_exec("UPDATE event SET comment=%Q, type='t'" |
| 2196 | " WHERE objid=%Q", |
| 2197 | zComment, zAttachId); |
| 2198 | fossil_free(zComment); |
| 2199 | } |
| 2200 | db_finalize(&qatt); |
| 2201 | } |
| 2202 | if( p->type==CFTYPE_ATTACHMENT ){ |
| 2203 | char *zComment = 0; |
| @@ -2205,18 +2204,18 @@ | |
| 2204 | const char isAdd = (p->zAttachSrc && p->zAttachSrc[0]) ? 1 : 0; |
| 2205 | /* We assume that we're attaching to a wiki page until we |
| 2206 | ** prove otherwise (which could on a later artifact if we |
| 2207 | ** process the attachment artifact before the artifact to |
| 2208 | ** which it is attached!) */ |
| 2209 | char attachToType = 'w'; |
| 2210 | if( fossil_is_uuid(p->zAttachTarget) ){ |
| 2211 | if( db_exists("SELECT 1 FROM tag WHERE tagname='tkt-%q'", |
| 2212 | p->zAttachTarget) |
| 2213 | ){ |
| 2214 | attachToType = 't'; /* Attaching to known ticket */ |
| 2215 | }else if( db_exists("SELECT 1 FROM tag WHERE tagname='event-%q'", |
| 2216 | p->zAttachTarget) |
| 2217 | ){ |
| 2218 | attachToType = 'e'; /* Attaching to known tech note */ |
| 2219 | } |
| 2220 | } |
| 2221 | db_multi_exec( |
| @@ -2245,18 +2244,18 @@ | |
| 2244 | } |
| 2245 | }else if( 'e' == attachToType ){ |
| 2246 | if( isAdd ){ |
| 2247 | zComment = mprintf( |
| 2248 | "Add attachment [/artifact/%!S|%h] to tech note [/technote/%!S|%S]", |
| 2249 | p->zAttachSrc, p->zAttachName, p->zAttachTarget, p->zAttachTarget); |
| 2250 | }else{ |
| 2251 | zComment = mprintf( |
| 2252 | "Delete attachment \"/artifact/%!S|%h\" from" |
| 2253 | " tech note [/technote/%!S|%S]", |
| 2254 | p->zAttachName, p->zAttachName, |
| 2255 | p->zAttachTarget,p->zAttachTarget); |
| 2256 | } |
| 2257 | }else{ |
| 2258 | if( isAdd ){ |
| 2259 | zComment = mprintf( |
| 2260 | "Add attachment [/artifact/%!S|%h] to ticket [%!S|%S]", |
| 2261 | p->zAttachSrc, p->zAttachName, p->zAttachTarget, p->zAttachTarget); |
| 2262 |