@@ -3592,7 +3592,7 @@ EXTERNAL int fiftyoneDegreesFloatIsEqual(fiftyoneDegreesFloatInternal f1, fiftyo
3592
3592
* the IEEE single precision standard is supported, default the type
3593
3593
* to the native float type.
3594
3594
*/
3595
- #if _MSC_VER || (FLT_RADIX == 2 && FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128 && FLT_MIN_EXP == -125)
3595
+ #if defined( _MSC_VER) || (defined(FLT_RADIX) && FLT_RADIX == 2 && FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128 && FLT_MIN_EXP == -125)
3596
3596
/**
3597
3597
* Define 51Degrees float implementation as native float.
3598
3598
*/
@@ -11692,7 +11692,7 @@ size_t fiftyoneDegreesHeadersSize(int count) {
11692
11692
11693
11693
typedef void(*parseIterator)(
11694
11694
void *state,
11695
- EvidenceIpType type ,
11695
+ EvidenceIpType segmentType ,
11696
11696
const char *start,
11697
11697
const char *end);
11698
11698
@@ -11701,13 +11701,13 @@ typedef void(*parseIterator)(
11701
11701
*/
11702
11702
static void callbackIpAddressCount(
11703
11703
void *state,
11704
- EvidenceIpType type ,
11704
+ EvidenceIpType segmentType ,
11705
11705
const char *start,
11706
11706
const char *end) {
11707
11707
if (start <= end) {
11708
- if (type != FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_INVALID) {
11708
+ if (segmentType != FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_INVALID) {
11709
11709
(*(int*)state)++;
11710
- if (type == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6) {
11710
+ if (segmentType == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6) {
11711
11711
(*(int*)state)++;
11712
11712
}
11713
11713
}
@@ -11765,27 +11765,48 @@ static void parseIpV6Segment(
11765
11765
11766
11766
static void callbackIpAddressBuild(
11767
11767
void *state,
11768
- EvidenceIpType type ,
11768
+ EvidenceIpType segmentType ,
11769
11769
const char *start,
11770
11770
const char *end) {
11771
11771
EvidenceIpAddress *address = (EvidenceIpAddress*)state;
11772
- if (type == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV4) {
11772
+ if (segmentType == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV4) {
11773
11773
*address->current = getIpByte(atoi(start));
11774
11774
address->current++;
11775
11775
}
11776
- else if (type == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6) {
11776
+ else if (segmentType == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6) {
11777
11777
parseIpV6Segment(address, start, end);
11778
11778
}
11779
11779
}
11780
11780
11781
- static EvidenceIpType getIpTypeFromSeparator(char separator) {
11781
+ static EvidenceIpType getIpTypeFromSeparator(const char separator) {
11782
11782
switch (separator) {
11783
- case '.':
11784
- return FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV4;
11785
- case ':':
11786
- return FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6;
11787
- default:
11788
- return FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_INVALID;
11783
+ case '.':
11784
+ return FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV4;
11785
+ case ':':
11786
+ return FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6;
11787
+ default:
11788
+ return FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_INVALID;
11789
+ }
11790
+ }
11791
+
11792
+ static EvidenceIpType getSegmentTypeWithSeparator(
11793
+ const char separator,
11794
+ const EvidenceIpType ipType,
11795
+ const EvidenceIpType lastSeparatorType) {
11796
+ switch (ipType) {
11797
+ case FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV4:
11798
+ return FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV4;
11799
+ case FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6:
11800
+ switch (separator) {
11801
+ case ':':
11802
+ return FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6;
11803
+ case '.':
11804
+ return FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV4;
11805
+ default:
11806
+ return lastSeparatorType;
11807
+ }
11808
+ default:
11809
+ return getIpTypeFromSeparator(separator);
11789
11810
}
11790
11811
}
11791
11812
@@ -11801,18 +11822,20 @@ static EvidenceIpType iterateIpAddress(
11801
11822
parseIterator foundSegment) {
11802
11823
const char *current = start;
11803
11824
const char *nextSegment = current;
11825
+ EvidenceIpType currentSegmentType = FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_INVALID;
11804
11826
while (current <= end && nextSegment < end) {
11805
11827
if (*current == ',' ||
11806
11828
*current == ':' ||
11807
11829
*current == '.' ||
11808
11830
*current == ' ' ||
11809
11831
*current == '\0') {
11832
+ currentSegmentType = getSegmentTypeWithSeparator(*current, type, currentSegmentType);
11810
11833
if (type == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_INVALID) {
11811
- type = getIpTypeFromSeparator(*current) ;
11834
+ type = currentSegmentType ;
11812
11835
}
11813
11836
// Check if it is leading abbreviation
11814
11837
if (current - 1 >= start) {
11815
- foundSegment(state, type , nextSegment, current - 1);
11838
+ foundSegment(state, currentSegmentType , nextSegment, current - 1);
11816
11839
}
11817
11840
nextSegment = current + 1;
11818
11841
}
@@ -15061,7 +15084,7 @@ void fiftyoneDegreesTextFileIterateWithLimit(
15061
15084
15062
15085
// Shift the buffer to the left and load the next characters.
15063
15086
size_t shift = end - current;
15064
- memcpy (buffer, current, shift);
15087
+ memmove (buffer, current, shift);
15065
15088
current = buffer + shift;
15066
15089
}
15067
15090
// Update end to the last line read
@@ -15242,7 +15265,7 @@ void fiftyoneDegreesSignalWait(fiftyoneDegreesSignal *signal) {
15242
15265
#endif
15243
15266
15244
15267
bool fiftyoneDegreesThreadingGetIsThreadSafe() {
15245
- #if FIFTYONE_DEGREES_NO_THREADING
15268
+ #if defined(FIFTYONE_DEGREES_NO_THREADING) && FIFTYONE_DEGREES_NO_THREADING
15246
15269
return false;
15247
15270
#else
15248
15271
return true;
0 commit comments