-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mock - update func signatures for latest glibc #9117
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,78 @@ | ||
// https://gist.github.com/Fonger/98cc95ac39fbe1a7e4d9 | ||
|
||
#ifndef HAVE_STRLCAT | ||
/* | ||
'_cups_strlcat()' - Safely concatenate two strings. | ||
*/ | ||
|
||
size_t /* O - Length of string */ | ||
strlcat(char* dst, /* O - Destination string */ | ||
const char* src, /* I - Source string */ | ||
size_t size) /* I - Size of destination string buffer */ | ||
#include <cstddef> | ||
#include <cstdlib> | ||
#include <cstring> | ||
|
||
extern "C" | ||
{ | ||
size_t srclen; /* Length of source string */ | ||
size_t dstlen; /* Length of destination string */ | ||
#ifdef STRLCAT_MISSING | ||
// '_cups_strlcat()' - Safely concatenate two strings. | ||
|
||
/* | ||
Figure out how much room is left... | ||
*/ | ||
size_t /* O - Length of string */ | ||
strlcat(char* dst, /* O - Destination string */ | ||
const char* src, /* I - Source string */ | ||
size_t size) /* I - Size of destination string buffer */ | ||
{ | ||
size_t srclen; /* Length of source string */ | ||
size_t dstlen; /* Length of destination string */ | ||
|
||
dstlen = strlen(dst); | ||
size -= dstlen + 1; | ||
// Figure out how much room is left... | ||
|
||
if (!size) | ||
{ | ||
return (dstlen); /* No room, return immediately... */ | ||
} | ||
dstlen = strlen(dst); | ||
size -= dstlen + 1; | ||
|
||
/* | ||
Figure out how much room is needed... | ||
*/ | ||
if (!size) | ||
{ | ||
return (dstlen); /* No room, return immediately... */ | ||
} | ||
|
||
srclen = strlen(src); | ||
// Figure out how much room is needed... | ||
|
||
/* | ||
Copy the appropriate amount... | ||
*/ | ||
srclen = strlen(src); | ||
|
||
if (srclen > size) | ||
{ | ||
srclen = size; | ||
// Copy the appropriate amount... | ||
|
||
if (srclen > size) | ||
{ | ||
srclen = size; | ||
} | ||
|
||
memcpy(dst + dstlen, src, srclen); | ||
dst[dstlen + srclen] = '\0'; | ||
|
||
return (dstlen + srclen); | ||
} | ||
#endif /* STRLCAT_MISSING */ | ||
|
||
memcpy(dst + dstlen, src, srclen); | ||
dst[dstlen + srclen] = '\0'; | ||
#ifdef STRLCPY_MISSING | ||
// '_cups_strlcpy()' - Safely copy two strings. | ||
|
||
return (dstlen + srclen); | ||
} | ||
#endif /* !HAVE_STRLCAT */ | ||
size_t /* O - Length of string */ | ||
strlcpy(char* dst, /* O - Destination string */ | ||
const char* src, /* I - Source string */ | ||
size_t size) /* I - Size of destination string buffer */ | ||
{ | ||
size_t srclen; /* Length of source string */ | ||
|
||
#ifndef HAVE_STRLCPY | ||
/* | ||
'_cups_strlcpy()' - Safely copy two strings. | ||
*/ | ||
// Figure out how much room is needed... | ||
|
||
size_t /* O - Length of string */ | ||
strlcpy(char* dst, /* O - Destination string */ | ||
const char* src, /* I - Source string */ | ||
size_t size) /* I - Size of destination string buffer */ | ||
{ | ||
size_t srclen; /* Length of source string */ | ||
size--; | ||
|
||
/* | ||
Figure out how much room is needed... | ||
*/ | ||
srclen = strlen(src); | ||
|
||
size--; | ||
// Copy the appropriate amount... | ||
|
||
srclen = strlen(src); | ||
if (srclen > size) | ||
{ | ||
srclen = size; | ||
} | ||
|
||
/* | ||
Copy the appropriate amount... | ||
*/ | ||
memcpy(dst, src, srclen); | ||
dst[srclen] = '\0'; | ||
|
||
if (srclen > size) | ||
{ | ||
srclen = size; | ||
return (srclen); | ||
} | ||
#endif /* STRLCPY_MISSING */ | ||
|
||
memcpy(dst, src, srclen); | ||
dst[srclen] = '\0'; | ||
|
||
return (srclen); | ||
} | ||
#endif /* !HAVE_STRLCPY */ | ||
} // extern "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
promised by TODO
overall libc stdlib comparison is tricky, don't see any feature flags with glibc 🤷
matching attributes with latest version breaks old one and vice versa, so these have to be hidden unless asked foractually, matching noexcept sort of works. assuming it is true for local implementation