Skip to content

Commit 950b285

Browse files
authored
posix.cfg: Added support for strxfrm_l (#5839)
Reference: - https://pubs.opengroup.org/onlinepubs/9699919799/functions/strxfrm_l.html
1 parent 42c3aeb commit 950b285

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

cfg/posix.cfg

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4179,6 +4179,30 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
41794179
<valid>0:</valid>
41804180
</arg>
41814181
</function>
4182+
<!-- https://pubs.opengroup.org/onlinepubs/9699919799/functions/strxfrm_l.html -->
4183+
<!-- size_t strxfrm_l(char *restrict s1, const char *restrict s2, size_t n, locale_t locale) -->
4184+
<function name="strxfrm_l">
4185+
<returnValue type="size_t"/>
4186+
<noreturn>false</noreturn>
4187+
<leak-ignore/>
4188+
<!-- In case the 3rd argument is 0, the 1st argument is permitted to be a null pointer. (#6306) -->
4189+
<arg nr="1" direction="out">
4190+
<minsize type="argvalue" arg="3"/>
4191+
</arg>
4192+
<arg nr="2" direction="in">
4193+
<not-null/>
4194+
<not-uninit/>
4195+
<strz/>
4196+
<minsize type="argvalue" arg="3"/>
4197+
</arg>
4198+
<arg nr="3" direction="in">
4199+
<not-uninit/>
4200+
<valid>0:</valid>
4201+
</arg>
4202+
<arg nr="4" direction="in">
4203+
<not-uninit/>
4204+
</arg>
4205+
</function>
41824206
<!-- https://pubs.opengroup.org/onlinepubs/9699919799/functions/asctime.html -->
41834207
<!-- char *asctime_r(const struct tm *tm, char *buf); -->
41844208
<function name="asctime_r">

test/cfg/posix.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,18 @@
3131
#include <ctype.h>
3232
#include <stdbool.h>
3333
#include <time.h>
34+
#include <string.h>
35+
#include <strings.h>
36+
#if defined(__APPLE__)
37+
#include <xlocale.h>
38+
#endif
3439
#if !(defined(__APPLE__) && defined(__MACH__))
3540
#include <mqueue.h>
3641
#endif
3742
#include <stdlib.h>
3843
#include <unistd.h>
3944
#include <wchar.h>
40-
#include <string.h>
41-
#include <strings.h>
45+
4246

4347
#if !(defined(__APPLE__) && defined(__MACH__))
4448
void nullPointer_mq_timedsend(mqd_t mqdes, const char* msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec* abs_timeout) {
@@ -102,6 +106,17 @@ int nullPointer_posix_trace_getnext_event(trace_id_t trid, struct posix_trace_ev
102106
}
103107
#endif // __TRACE_H__
104108

109+
size_t nullPointer_strxfrm_l(char *restrict dest, const char *restrict src, size_t count, locale_t locale)
110+
{
111+
(void)strxfrm_l(dest, src, count, locale);
112+
// In case the 3rd argument is 0, the 1st argument is permitted to be a null pointer. (#6306)
113+
(void)strxfrm_l(NULL, src, 0, locale);
114+
(void)strxfrm_l(NULL, src, 1, locale);
115+
(void)strxfrm_l(NULL, src, count, locale);
116+
// cppcheck-suppress nullPointer
117+
return strxfrm_l(dest, NULL, count, locale);
118+
}
119+
105120
void nullPointer_pthread_attr_getstack(const pthread_attr_t *attr, void *stackaddr, size_t stacksize) {
106121
// cppcheck-suppress nullPointer
107122
(void) pthread_attr_getstack(NULL, &stackaddr, &stacksize);

0 commit comments

Comments
 (0)