Small cleanup of QCBOR_DISABLE_EXP_AND_MANTISSA
diff --git a/README.md b/README.md
index 805279d..1bce59f 100644
--- a/README.md
+++ b/README.md
@@ -445,8 +445,18 @@
### Disabling Features
-Here's the list of all features that can be disabled to save object
-code. The amount saved is an approximation.
+The following table is all the features that can be disabled and an
+approximate amount by which they reduce the total size of the library.
+Note that in many cases enabling dead stripping and not calling
+functions will reduce what is linked from the library by a lot.
+
+For example, not calling any function that operates on big floats or
+decimal fractions will save the 5000 bytes listed even without
+QCBOR_DISABLE_EXP_AND_MANTISSA. But also note that the configuration
+option still exists because some may wish to use the number conversion
+functions with their support for decimal fractions and big numbers
+disabled.
+
| #define | Saves |
| ----------------------------------------| ------|
@@ -454,7 +464,7 @@
| QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS | 400 |
| QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS | 200 |
| QCBOR_DISABLE_UNCOMMON_TAGS | 100 |
- | QCBOR_DISABLE_EXP_AND_MANTISSA | 400 |
+ | QCBOR_DISABLE_EXP_AND_MANTISSA | 5000 |
| QCBOR_DISABLE_PREFERRED_FLOAT | 900 |
| QCBOR_DISABLE_FLOAT_HW_USE | 50 |
| QCBOR_DISABLE_TAGS | 400 |
diff --git a/inc/qcbor/qcbor_common.h b/inc/qcbor/qcbor_common.h
index 89bfd00..92ec85d 100644
--- a/inc/qcbor/qcbor_common.h
+++ b/inc/qcbor/qcbor_common.h
@@ -33,7 +33,8 @@
#ifndef qcbor_common_h
#define qcbor_common_h
-//TODO: get rid of QCBOR_DISABLE_EXP_AND_MANTISSA and uncommon tags
+//TODO: get rid of uncommon tags define
+//#define QCBOR_DISABLE_EXP_AND_MANTISSA
#ifdef __cplusplus
extern "C" {
diff --git a/inc/qcbor/qcbor_encode.h b/inc/qcbor/qcbor_encode.h
index 2270544..2ceb999 100644
--- a/inc/qcbor/qcbor_encode.h
+++ b/inc/qcbor/qcbor_encode.h
@@ -2670,7 +2670,7 @@
UsefulBufC BigNumber);
-#ifndef QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA
+#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
/* Deprecated. Use QCBOREncode_AddTDecimalFraction() instead */
static void
QCBOREncode_AddDecimalFraction(QCBOREncodeContext *pCtx,
@@ -2798,7 +2798,7 @@
UsefulBufC Mantissa,
bool bIsNegative,
int64_t nBase2Exponent);
-#endif /* ! QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
/* ========================================================================= *
@@ -2899,7 +2899,7 @@
QCBOREncode_AddNegativeBignumToMapN(QCBOREncodeContext *pCtx, int64_t nLabel, UsefulBufC BigNumber);
-#ifndef QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA
+#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
/* Use QCBOREncode_AddTDecimalFraction() instead */
static void
@@ -2986,7 +2986,7 @@
UsefulBufC Mantissa,
bool bIsNegative,
int64_t nBase2Exponent);
-#endif /* ! QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
/* Use QCBOREncode_AddTURI() instead */
static void
diff --git a/inc/qcbor/qcbor_spiffy_decode.h b/inc/qcbor/qcbor_spiffy_decode.h
index e690f31..16542d5 100644
--- a/inc/qcbor/qcbor_spiffy_decode.h
+++ b/inc/qcbor/qcbor_spiffy_decode.h
@@ -2368,7 +2368,7 @@
UsefulBufC *pValue,
bool *pbIsNegative);
-#ifndef QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA
+#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
/* Use QCBORDecode_GetTDecimalFraction() instead */
static void
QCBORDecode_GetDecimalFraction(QCBORDecodeContext *pCtx,
@@ -2483,7 +2483,7 @@
UsefulBufC *pMantissa,
bool *pbMantissaIsNegative,
int64_t *pnExponent);
-#endif /* ! QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
@@ -3443,7 +3443,7 @@
QCBORDecode_GetTBigNumberRawInMapSZ(pMe, szLabel, uTagRequirement, pBigNumber, pbIsNegative);
}
-#ifndef QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA
+#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
static inline void
QCBORDecode_GetDecimalFraction(QCBORDecodeContext *pMe,
uint8_t uTagRequirement,
@@ -3591,7 +3591,7 @@
pbMantissaIsNegative,
pnExponent);
}
-#endif /* ! QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
#ifdef __cplusplus
}
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 2992ce1..73ae425 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -5637,7 +5637,7 @@
return (*pfExp)(uMantissa, nExponent, puResult);
}
-#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
@@ -6060,7 +6060,7 @@
return QCBOR_ERR_UNEXPECTED_TYPE;
}
break;
-#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
default:
@@ -6459,7 +6459,7 @@
return QCBOR_ERR_UNEXPECTED_TYPE;
}
break;
-#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
default:
return QCBOR_ERR_UNEXPECTED_TYPE;
}
diff --git a/src/qcbor_tag_decode.c b/src/qcbor_tag_decode.c
index 36e8dae..325a7a4 100644
--- a/src/qcbor_tag_decode.c
+++ b/src/qcbor_tag_decode.c
@@ -415,7 +415,7 @@
{CBOR_TAG_BIGFLOAT, QCBORDecode_ExpMantissaTagCB},
{CBOR_TAG_DECIMAL_FRACTION, QCBORDecode_ExpMantissaTagCB},
-#endif
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
{CBOR_TAG_DAYS_EPOCH, QCBORDecode_DaysEpochTagCB},
{CBOR_TAG_INVALID64, NULL},
};
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index e4f0f9e..1abb5a8 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -4202,7 +4202,7 @@
uError = QCBORDecode_GetNext(&DCtx, &Item);
uError = QCBORDecode_GetNext(&DCtx, &Item);
-#else /* QCBOR_DISABLE_EXP_AND_MANTISSA */
+#else /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
if(uError != QCBOR_SUCCESS ||
Item.uDataType != QCBOR_TYPE_DECIMAL_FRACTION ||
QCBORDecode_GetNthTag(&DCtx, &Item, 0) != CBOR_TAG_INVALID64 ||
@@ -4212,7 +4212,7 @@
QCBORDecode_GetNthTag(&DCtx, &Item, 4) != CBOR_TAG_INVALID64 ) {
return -5;
}
-#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
/*
More than 4 tags on an item 225(226(227(228(229([])))))
@@ -6789,7 +6789,7 @@
struct DecodeFailTestInput));
}
-#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
@@ -7779,9 +7779,9 @@
#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
#define EXP_AND_MANTISSA_ERROR(x) x
-#else
+#else /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
#define EXP_AND_MANTISSA_ERROR(x) QCBOR_ERR_UNEXPECTED_TYPE
-#endif
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
static const struct NumberConversion NumberConversions[] = {
diff --git a/test/qcbor_decode_tests.h b/test/qcbor_decode_tests.h
index 37d061e..50fc845 100644
--- a/test/qcbor_decode_tests.h
+++ b/test/qcbor_decode_tests.h
@@ -259,7 +259,7 @@
Hostile input tests for decimal fractions and big floats.
*/
int32_t ExponentAndMantissaDecodeFailTests(void);
-#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
int32_t EnterMapTest(void);
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index b9187fc..3c758f2 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -3332,7 +3332,7 @@
}
-#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
int32_t QCBORHeadTest(void)
diff --git a/test/qcbor_encode_tests.h b/test/qcbor_encode_tests.h
index cb9f00f..676b375 100644
--- a/test/qcbor_encode_tests.h
+++ b/test/qcbor_encode_tests.h
@@ -167,7 +167,7 @@
made up of an exponent and mantissa
*/
int32_t ExponentAndMantissaEncodeTests(void);
-#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
/*
diff --git a/test/run_tests.c b/test/run_tests.c
index 578c34c..bcb4540 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -173,7 +173,7 @@
TEST_ENTRY(ExponentAndMantissaDecodeFailTests),
#endif /* QCBOR_DISABLE_TAGS */
TEST_ENTRY(ExponentAndMantissaEncodeTests),
-#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
+#endif /* ! QCBOR_DISABLE_EXP_AND_MANTISSA */
TEST_ENTRY(SortMapTest),
#if !defined(USEFULBUF_DISABLE_ALL_FLOAT) && !defined(QCBOR_DISABLE_PREFERRED_FLOAT)
TEST_ENTRY(CDETest),