Skip to content

Commit 2141014

Browse files
Automation51DAutomation51D
andauthored
Merged Pull Request '#61 update-packages/main->main: Update packages'
Co-authored-by: Automation51D <[email protected]>
1 parent 4ff4881 commit 2141014

File tree

2 files changed

+43
-20
lines changed

2 files changed

+43
-20
lines changed

dd/device-detection-cxx.c

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,7 +3592,7 @@ EXTERNAL int fiftyoneDegreesFloatIsEqual(fiftyoneDegreesFloatInternal f1, fiftyo
35923592
* the IEEE single precision standard is supported, default the type
35933593
* to the native float type.
35943594
*/
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)
35963596
/**
35973597
* Define 51Degrees float implementation as native float.
35983598
*/
@@ -11692,7 +11692,7 @@ size_t fiftyoneDegreesHeadersSize(int count) {
1169211692

1169311693
typedef void(*parseIterator)(
1169411694
void *state,
11695-
EvidenceIpType type,
11695+
EvidenceIpType segmentType,
1169611696
const char *start,
1169711697
const char *end);
1169811698

@@ -11701,13 +11701,13 @@ typedef void(*parseIterator)(
1170111701
*/
1170211702
static void callbackIpAddressCount(
1170311703
void *state,
11704-
EvidenceIpType type,
11704+
EvidenceIpType segmentType,
1170511705
const char *start,
1170611706
const char *end) {
1170711707
if (start <= end) {
11708-
if (type != FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_INVALID) {
11708+
if (segmentType != FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_INVALID) {
1170911709
(*(int*)state)++;
11710-
if (type == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6) {
11710+
if (segmentType == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6) {
1171111711
(*(int*)state)++;
1171211712
}
1171311713
}
@@ -11765,27 +11765,48 @@ static void parseIpV6Segment(
1176511765

1176611766
static void callbackIpAddressBuild(
1176711767
void *state,
11768-
EvidenceIpType type,
11768+
EvidenceIpType segmentType,
1176911769
const char *start,
1177011770
const char *end) {
1177111771
EvidenceIpAddress *address = (EvidenceIpAddress*)state;
11772-
if (type == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV4) {
11772+
if (segmentType == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV4) {
1177311773
*address->current = getIpByte(atoi(start));
1177411774
address->current++;
1177511775
}
11776-
else if (type == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6) {
11776+
else if (segmentType == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_IPV6) {
1177711777
parseIpV6Segment(address, start, end);
1177811778
}
1177911779
}
1178011780

11781-
static EvidenceIpType getIpTypeFromSeparator(char separator) {
11781+
static EvidenceIpType getIpTypeFromSeparator(const char separator) {
1178211782
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);
1178911810
}
1179011811
}
1179111812

@@ -11801,18 +11822,20 @@ static EvidenceIpType iterateIpAddress(
1180111822
parseIterator foundSegment) {
1180211823
const char *current = start;
1180311824
const char *nextSegment = current;
11825+
EvidenceIpType currentSegmentType = FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_INVALID;
1180411826
while (current <= end && nextSegment < end) {
1180511827
if (*current == ',' ||
1180611828
*current == ':' ||
1180711829
*current == '.' ||
1180811830
*current == ' ' ||
1180911831
*current == '\0') {
11832+
currentSegmentType = getSegmentTypeWithSeparator(*current, type, currentSegmentType);
1181011833
if (type == FIFTYONE_DEGREES_EVIDENCE_IP_TYPE_INVALID) {
11811-
type = getIpTypeFromSeparator(*current);
11834+
type = currentSegmentType;
1181211835
}
1181311836
// Check if it is leading abbreviation
1181411837
if (current - 1 >= start) {
11815-
foundSegment(state, type, nextSegment, current - 1);
11838+
foundSegment(state, currentSegmentType, nextSegment, current - 1);
1181611839
}
1181711840
nextSegment = current + 1;
1181811841
}
@@ -15061,7 +15084,7 @@ void fiftyoneDegreesTextFileIterateWithLimit(
1506115084

1506215085
// Shift the buffer to the left and load the next characters.
1506315086
size_t shift = end - current;
15064-
memcpy(buffer, current, shift);
15087+
memmove(buffer, current, shift);
1506515088
current = buffer + shift;
1506615089
}
1506715090
// Update end to the last line read
@@ -15242,7 +15265,7 @@ void fiftyoneDegreesSignalWait(fiftyoneDegreesSignal *signal) {
1524215265
#endif
1524315266

1524415267
bool fiftyoneDegreesThreadingGetIsThreadSafe() {
15245-
#if FIFTYONE_DEGREES_NO_THREADING
15268+
#if defined(FIFTYONE_DEGREES_NO_THREADING) && FIFTYONE_DEGREES_NO_THREADING
1524615269
return false;
1524715270
#else
1524815271
return true;

dd/device-detection-cxx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3643,7 +3643,7 @@ EXTERNAL int fiftyoneDegreesFloatIsEqual(fiftyoneDegreesFloatInternal f1, fiftyo
36433643
* the IEEE single precision standard is supported, default the type
36443644
* to the native float type.
36453645
*/
3646-
#if _MSC_VER || (FLT_RADIX == 2 && FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128 && FLT_MIN_EXP == -125)
3646+
#if defined(_MSC_VER) || (defined(FLT_RADIX) && FLT_RADIX == 2 && FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128 && FLT_MIN_EXP == -125)
36473647
/**
36483648
* Define 51Degrees float implementation as native float.
36493649
*/

0 commit comments

Comments
 (0)