31
31
#ifndef __STDC_LIMIT_MACROS
32
32
# define __STDC_LIMIT_MACROS 1
33
33
#endif
34
+ #define __STDC_WANT_IEC_60559_TYPES_EXT__
34
35
35
36
#include "cbor.h"
36
37
#include "cborinternal_p.h"
93
94
*
94
95
* The code above does not execute a range-check either: it is possible that
95
96
* the value decoded from the CBOR stream encodes a number larger than what can
96
- * be represented in a variable of type \c{ int} . If detecting that case is
97
+ * be represented in a variable of type \c int. If detecting that case is
97
98
* important, the code should call cbor_value_get_int_checked() instead.
98
99
*
99
100
* <h3 class="groupheader">Memory and parsing constraints</h3>
133
134
*
134
135
* \if privatedocs
135
136
* Implementation details: the CborValue contains these fields:
136
- * \list
137
- * \li ptr: pointer to the actual data
138
- * \li flags: flags from the decoder
139
- * \li extra: partially decoded integer value (0, 1 or 2 bytes)
140
- * \li remaining: remaining items in this collection after this item or UINT32_MAX if length is unknown
141
- * \endlist
137
+ * - ptr: pointer to the actual data
138
+ * - flags: flags from the decoder
139
+ * - extra: partially decoded integer value (0, 1 or 2 bytes)
140
+ * - remaining: remaining items in this collection after this item or UINT32_MAX if length is unknown
142
141
* \endif
143
142
*/
144
143
@@ -232,7 +231,7 @@ static CborError preparse_value(CborValue *it)
232
231
case SinglePrecisionFloat :
233
232
case DoublePrecisionFloat :
234
233
it -> flags |= CborIteratorFlag_IntegerValueTooLarge ;
235
- Q_FALLTHROUGH () ;
234
+ CBOR_FALLTHROUGH ;
236
235
case TrueValue :
237
236
case NullValue :
238
237
case UndefinedValue :
@@ -428,12 +427,10 @@ CborError cbor_value_reparse(CborValue *it)
428
427
* will appear during parsing.
429
428
*
430
429
* A basic validation checks for:
431
- * \list
432
- * \li absence of undefined additional information bytes;
433
- * \li well-formedness of all numbers, lengths, and simple values;
434
- * \li string contents match reported sizes;
435
- * \li arrays and maps contain the number of elements they are reported to have;
436
- * \endlist
430
+ * - absence of undefined additional information bytes;
431
+ * - well-formedness of all numbers, lengths, and simple values;
432
+ * - string contents match reported sizes;
433
+ * - arrays and maps contain the number of elements they are reported to have;
437
434
*
438
435
* For further checks, see cbor_value_validate().
439
436
*
@@ -744,7 +741,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
744
741
* \ref cbor_value_is_integer is recommended.
745
742
*
746
743
* Note that this function does not do range-checking: integral values that do
747
- * not fit in a variable of type \c{ int} are silently truncated to fit. Use
744
+ * not fit in a variable of type \c int are silently truncated to fit. Use
748
745
* cbor_value_get_int_checked() if that is not acceptable.
749
746
*
750
747
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_integer()
@@ -759,7 +756,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
759
756
* \ref cbor_value_is_integer is recommended.
760
757
*
761
758
* Note that this function does not do range-checking: integral values that do
762
- * not fit in a variable of type \c{ int64_t} are silently truncated to fit. Use
759
+ * not fit in a variable of type \c int64_t are silently truncated to fit. Use
763
760
* cbor_value_get_int64_checked() that is not acceptable.
764
761
*
765
762
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_integer()
@@ -790,7 +787,7 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
790
787
* If the integer is unsigned (that is, if cbor_value_is_unsigned_integer()
791
788
* returns true), then \a result will contain the actual value. If the integer
792
789
* is negative, then \a result will contain the absolute value of that integer,
793
- * minus one. That is, \c { actual = -result - 1} . On architectures using two's
790
+ * minus one. That is, <tt> actual = -result - 1</tt> . On architectures using two's
794
791
* complement for representation of negative integers, it is equivalent to say
795
792
* that \a result will contain the bitwise negation of the actual value.
796
793
*
@@ -1211,7 +1208,7 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
1211
1208
return CborErrorDataTooLarge ;
1212
1209
1213
1210
if (* result && * buflen >= newTotal )
1214
- * result = !!func (buffer + total , (const uint8_t * )ptr , chunkLen );
1211
+ * result = !!func (buffer == NULL ? buffer : buffer + total , (const uint8_t * )ptr , chunkLen );
1215
1212
else
1216
1213
* result = false;
1217
1214
@@ -1221,7 +1218,7 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
1221
1218
/* is there enough room for the ending NUL byte? */
1222
1219
if (* result && * buflen > total ) {
1223
1220
uint8_t nul [] = { 0 };
1224
- * result = !!func (buffer + total , nul , 1 );
1221
+ * result = !!func (buffer == NULL ? buffer : buffer + total , nul , 1 );
1225
1222
}
1226
1223
* buflen = total ;
1227
1224
return _cbor_value_finish_string_iteration (next );
@@ -1243,10 +1240,10 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
1243
1240
* of the string in order to preallocate a buffer, use
1244
1241
* cbor_value_calculate_string_length().
1245
1242
*
1246
- * On success, this function sets the number of bytes copied to \c{ *buflen} . If
1243
+ * On success, this function sets the number of bytes copied to \c *buflen. If
1247
1244
* the buffer is large enough, this function will insert a null byte after the
1248
1245
* last copied byte, to facilitate manipulation of text strings. That byte is
1249
- * not included in the returned value of \c{ *buflen} . If there was no space for
1246
+ * not included in the returned value of \c *buflen. If there was no space for
1250
1247
* the terminating null, no error is returned, so callers must check the value
1251
1248
* of *buflen after the call, before relying on the '\0'; if it has not been
1252
1249
* changed by the call, there is no '\0'-termination on the buffer's contents.
@@ -1280,10 +1277,10 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
1280
1277
* of the string in order to preallocate a buffer, use
1281
1278
* cbor_value_calculate_string_length().
1282
1279
*
1283
- * On success, this function sets the number of bytes copied to \c{ *buflen} . If
1280
+ * On success, this function sets the number of bytes copied to \c *buflen. If
1284
1281
* the buffer is large enough, this function will insert a null byte after the
1285
1282
* last copied byte, to facilitate manipulation of null-terminated strings.
1286
- * That byte is not included in the returned value of \c{ *buflen} .
1283
+ * That byte is not included in the returned value of \c *buflen.
1287
1284
*
1288
1285
* The \a next pointer, if not null, will be updated to point to the next item
1289
1286
* after this string. If \a value points to the last item, then \a next will be
@@ -1520,7 +1517,7 @@ CborError cbor_value_map_find_value(const CborValue *map, const char *string, Cb
1520
1517
* cbor_value_is_half_float is recommended.
1521
1518
*
1522
1519
* Note: since the C language does not have a standard type for half-precision
1523
- * floating point, this function takes a \c{ void *} as a parameter for the
1520
+ * floating point, this function takes a <tt> void *</tt> as a parameter for the
1524
1521
* storage area, which must be at least 16 bits wide.
1525
1522
*
1526
1523
* \sa cbor_value_get_type(), cbor_value_is_valid(), cbor_value_is_half_float(), cbor_value_get_half_float_as_float(), cbor_value_get_float()
0 commit comments