1139804Simp/* This file is automatically generated. DO NOT EDIT! */ 2185435Sbz/* Generated from: NetBSD: mknative-gdb,v 1.16 2023/07/31 17:09:59 christos Exp */ 3185435Sbz/* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp */ 4191673Sjamie 5185435Sbz/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 6190466Sjamie/* A GNU-like <string.h>. 7185404Sbz 8185404Sbz Copyright (C) 1995-1996, 2001-2022 Free Software Foundation, Inc. 9185404Sbz 10185404Sbz This file is free software: you can redistribute it and/or modify 11185404Sbz it under the terms of the GNU Lesser General Public License as 12185404Sbz published by the Free Software Foundation; either version 2.1 of the 13185404Sbz License, or (at your option) any later version. 14185404Sbz 15185404Sbz This file is distributed in the hope that it will be useful, 16185404Sbz but WITHOUT ANY WARRANTY; without even the implied warranty of 17185404Sbz MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18185404Sbz GNU Lesser General Public License for more details. 19185404Sbz 20185404Sbz You should have received a copy of the GNU Lesser General Public License 21185404Sbz along with this program. If not, see <https://www.gnu.org/licenses/>. */ 22185404Sbz 23185404Sbz#if __GNUC__ >= 3 24185404Sbz#pragma GCC system_header 25185404Sbz#endif 26185404Sbz 2746197Sphk 2846155Sphk#if defined _GL_ALREADY_INCLUDING_STRING_H 29116182Sobrien/* Special invocation convention: 30116182Sobrien - On OS X/NetBSD we have a sequence of nested includes 31116182Sobrien <string.h> -> <strings.h> -> "string.h" 32193066Sjamie In this situation system _chk variants due to -D_FORTIFY_SOURCE 33185435Sbz might be used after any replacements defined here. */ 34185435Sbz 35185435Sbz#include_next <string.h> 36131177Spjd 3746155Sphk#else 3846155Sphk/* Normal invocation convention. */ 3946155Sphk 4046155Sphk#ifndef _GL_STRING_H 4146155Sphk 4246155Sphk#define _GL_ALREADY_INCLUDING_STRING_H 4346155Sphk 44192895Sjamie/* The include_next requires a split double-inclusion guard. */ 45164032Srwatson#include_next <string.h> 4646155Sphk 47124882Srwatson#undef _GL_ALREADY_INCLUDING_STRING_H 48177785Skib 4946155Sphk#ifndef _GL_STRING_H 5087275Srwatson#define _GL_STRING_H 5187275Srwatson 52220137Strasz/* NetBSD 5.0 mis-defines NULL. */ 53221362Strasz#include <stddef.h> 54168401Spjd 55193066Sjamie/* MirBSD defines mbslen as a macro. */ 56113275Smike#if 0 && defined __MirBSD__ 57147185Spjd# include <wchar.h> 58113275Smike#endif 5946155Sphk 60113275Smike/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ 6157163Srwatson/* But in any case avoid namespace pollution on glibc systems. */ 62113275Smike#if (0 || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ 63196019Srwatson && ! defined __GLIBC__ 6446155Sphk# include <unistd.h> 65196019Srwatson#endif 66196019Srwatson 6746155Sphk/* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>. */ 68196019Srwatson/* But in any case avoid namespace pollution on glibc systems. */ 69185435Sbz#if ((0 || 0 || defined GNULIB_POSIXCHECK) \ 70185435Sbz && defined _AIX) \ 71185435Sbz && ! defined __GLIBC__ 72185435Sbz# include <strings.h> 73185435Sbz#endif 74185435Sbz 7546155Sphk/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers 76163606Srwatson that can be freed by passing them as the Ith argument to the 77163606Srwatson function F. */ 78195944Sjamie#ifndef _GL_ATTRIBUTE_DEALLOC 79195944Sjamie# if __GNUC__ >= 11 8046155Sphk# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) 81227293Sed# else 8246155Sphk# define _GL_ATTRIBUTE_DEALLOC(f, i) 83202468Sbz# endif 84202468Sbz#endif 85202468Sbz 86202468Sbz/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that 87202468Sbz can be freed via 'free'; it can be used only after declaring 'free'. */ 88202468Sbz/* Applies to: functions. Cannot be used on inline functions. */ 89202468Sbz#ifndef _GL_ATTRIBUTE_DEALLOC_FREE 90202468Sbz# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) 91202468Sbz#endif 92202468Sbz 93202468Sbz/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly 94202468Sbz allocated memory. */ 95202468Sbz/* Applies to: functions. */ 96202468Sbz#ifndef _GL_ATTRIBUTE_MALLOC 97202468Sbz# if __GNUC__ >= 3 || defined __clang__ 98192895Sjamie# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) 99192895Sjamie# else 100192895Sjamie# define _GL_ATTRIBUTE_MALLOC 101192895Sjamie# endif 102192895Sjamie#endif 103192895Sjamie 104192895Sjamie/* The __attribute__ feature is available in gcc versions 2.5 and later. 105192895Sjamie The attribute __pure__ was added in gcc 2.96. */ 106231267Smm#ifndef _GL_ATTRIBUTE_PURE 107194762Sjamie# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ 108195944Sjamie# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 109201145Santoine# else 110196176Sbz# define _GL_ATTRIBUTE_PURE /* empty */ 111202468Sbz# endif 112196176Sbz#endif 113202468Sbz 114196176Sbz/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 115192895Sjamie/* C++ compatible function declaration macros. 116192895Sjamie Copyright (C) 2010-2022 Free Software Foundation, Inc. 117192895Sjamie 11857163Srwatson This program is free software: you can redistribute it and/or modify it 119221362Strasz under the terms of the GNU Lesser General Public License as published 120168401Spjd by the Free Software Foundation; either version 2 of the License, or 121191673Sjamie (at your option) any later version. 122191673Sjamie 123221362Strasz This program is distributed in the hope that it will be useful, 124179881Sdelphij but WITHOUT ANY WARRANTY; without even the implied warranty of 125113275Smike MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 126191673Sjamie Lesser General Public License for more details. 127190466Sjamie 128191673Sjamie You should have received a copy of the GNU Lesser General Public License 129192895Sjamie along with this program. If not, see <https://www.gnu.org/licenses/>. */ 130192895Sjamie 131221362Strasz#ifndef _GL_CXXDEFS_H 132221362Strasz#define _GL_CXXDEFS_H 133232598Strasz 134221362Strasz/* Begin/end the GNULIB_NAMESPACE namespace. */ 135221362Strasz#if defined __cplusplus && defined GNULIB_NAMESPACE 136185435Sbz# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { 137190466Sjamie# define _GL_END_NAMESPACE } 138192895Sjamie#else 139185435Sbz# define _GL_BEGIN_NAMESPACE 140185435Sbz# define _GL_END_NAMESPACE 141190466Sjamie#endif 142192895Sjamie 143185435Sbz/* The three most frequent use cases of these macros are: 144113275Smike 145191673Sjamie * For providing a substitute for a function that is missing on some 146191673Sjamie platforms, but is declared and works fine on the platforms on which 147191673Sjamie it exists: 148191673Sjamie 149191673Sjamie #if @GNULIB_FOO@ 150191673Sjamie # if !@HAVE_FOO@ 151113275Smike _GL_FUNCDECL_SYS (foo, ...); 152192895Sjamie # endif 153216861Sbz _GL_CXXALIAS_SYS (foo, ...); 154216861Sbz _GL_CXXALIASWARN (foo); 155216861Sbz #elif defined GNULIB_POSIXCHECK 156192895Sjamie ... 157192895Sjamie #endif 158192895Sjamie 159202468Sbz * For providing a replacement for a function that exists on all platforms, 160202468Sbz but is broken/insufficient and needs to be replaced on some platforms: 161202468Sbz 162202468Sbz #if @GNULIB_FOO@ 163202468Sbz # if @REPLACE_FOO@ 164202468Sbz # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 165192895Sjamie # undef foo 166216861Sbz # define foo rpl_foo 167192895Sjamie # endif 168192895Sjamie _GL_FUNCDECL_RPL (foo, ...); 169192895Sjamie _GL_CXXALIAS_RPL (foo, ...); 170202468Sbz # else 171202468Sbz _GL_CXXALIAS_SYS (foo, ...); 172202468Sbz # endif 173202468Sbz _GL_CXXALIASWARN (foo); 174202468Sbz #elif defined GNULIB_POSIXCHECK 175202468Sbz ... 176195870Sjamie #endif 177216861Sbz 178195870Sjamie * For providing a replacement for a function that exists on some platforms 179195870Sjamie but is broken/insufficient and needs to be replaced on some of them and 180195870Sjamie is additionally either missing or undeclared on some other platforms: 181195870Sjamie 182195870Sjamie #if @GNULIB_FOO@ 183195870Sjamie # if @REPLACE_FOO@ 184195870Sjamie # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 185195870Sjamie # undef foo 186195870Sjamie # define foo rpl_foo 187195870Sjamie # endif 188192895Sjamie _GL_FUNCDECL_RPL (foo, ...); 189195870Sjamie _GL_CXXALIAS_RPL (foo, ...); 190192895Sjamie # else 191192895Sjamie # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 192195870Sjamie _GL_FUNCDECL_SYS (foo, ...); 193192895Sjamie # endif 194192895Sjamie _GL_CXXALIAS_SYS (foo, ...); 195216861Sbz # endif 196192895Sjamie _GL_CXXALIASWARN (foo); 197192895Sjamie #elif defined GNULIB_POSIXCHECK 198192895Sjamie ... 199192895Sjamie #endif 200192895Sjamie*/ 201192895Sjamie 202192895Sjamie/* _GL_EXTERN_C declaration; 203192895Sjamie performs the declaration with C linkage. */ 204192895Sjamie#if defined __cplusplus 205232059Smm# define _GL_EXTERN_C extern "C" 206232059Smm#else 207232186Smm# define _GL_EXTERN_C extern 208232278Smm#endif 209254741Sdelphij 210277985Sjamie/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 211295951Saraujo declares a replacement function, named rpl_func, with the given prototype, 212295951Saraujo consisting of return type, parameters, and attributes. 213192895Sjamie Example: 214216861Sbz _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 215192895Sjamie _GL_ARG_NONNULL ((1))); 216192895Sjamie */ 217192895Sjamie#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 218192895Sjamie _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 219192895Sjamie#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 220192895Sjamie _GL_EXTERN_C rettype rpl_func parameters_and_attributes 221192895Sjamie 222192895Sjamie/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 223192895Sjamie declares the system function, named func, with the given prototype, 224232059Smm consisting of return type, parameters, and attributes. 225232059Smm Example: 226232186Smm _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 227232278Smm _GL_ARG_NONNULL ((1))); 228254741Sdelphij */ 229277985Sjamie#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 230295951Saraujo _GL_EXTERN_C rettype func parameters_and_attributes 231295951Saraujo 232192895Sjamie/* _GL_CXXALIAS_RPL (func, rettype, parameters); 233216861Sbz declares a C++ alias called GNULIB_NAMESPACE::func 234192895Sjamie that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 235196002Sjamie Example: 236196002Sjamie _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 237232059Smm 238192895Sjamie Wrapping rpl_func in an object with an inline conversion operator 239196002Sjamie avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is 240231267Smm actually used in the program. */ 241192895Sjamie#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 242193865Sjamie _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 243192895Sjamie#if defined __cplusplus && defined GNULIB_NAMESPACE 244192895Sjamie# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 245280632Sian namespace GNULIB_NAMESPACE \ 246280632Sian { \ 247280632Sian static const struct _gl_ ## func ## _wrapper \ 248280632Sian { \ 249280632Sian typedef rettype (*type) parameters; \ 250280632Sian \ 251280632Sian inline operator type () const \ 252280632Sian { \ 253280632Sian return ::rpl_func; \ 254280632Sian } \ 255280632Sian } func = {}; \ 256280632Sian } \ 257280632Sian _GL_EXTERN_C int _gl_cxxalias_dummy 258192895Sjamie#else 259185435Sbz# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 260185435Sbz _GL_EXTERN_C int _gl_cxxalias_dummy 261185435Sbz#endif 262185435Sbz 263185435Sbz/* _GL_CXXALIAS_MDA (func, rettype, parameters); 264185435Sbz is to be used when func is a Microsoft deprecated alias, on native Windows. 265185435Sbz It declares a C++ alias called GNULIB_NAMESPACE::func 266185435Sbz that redirects to _func, if GNULIB_NAMESPACE is defined. 267185435Sbz Example: 268185435Sbz _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); 269185435Sbz */ 270185435Sbz#define _GL_CXXALIAS_MDA(func,rettype,parameters) \ 271185435Sbz _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters) 272185435Sbz 273185435Sbz/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 274185435Sbz is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 275185435Sbz except that the C function rpl_func may have a slightly different 276185435Sbz declaration. A cast is used to silence the "invalid conversion" error 277185435Sbz that would otherwise occur. */ 278185435Sbz#if defined __cplusplus && defined GNULIB_NAMESPACE 279185435Sbz# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 280185435Sbz namespace GNULIB_NAMESPACE \ 281185435Sbz { \ 282185435Sbz static const struct _gl_ ## func ## _wrapper \ 283185435Sbz { \ 284185435Sbz typedef rettype (*type) parameters; \ 285185435Sbz \ 286185435Sbz inline operator type () const \ 287185435Sbz { \ 288185435Sbz return reinterpret_cast<type>(::rpl_func); \ 289185435Sbz } \ 290185435Sbz } func = {}; \ 291185435Sbz } \ 292185435Sbz _GL_EXTERN_C int _gl_cxxalias_dummy 293185435Sbz#else 294185435Sbz# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 295185435Sbz _GL_EXTERN_C int _gl_cxxalias_dummy 296190466Sjamie#endif 297185435Sbz 298185435Sbz/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters); 299185435Sbz is like _GL_CXXALIAS_MDA (func, rettype, parameters); 300185435Sbz except that the C function func may have a slightly different declaration. 301185435Sbz A cast is used to silence the "invalid conversion" error that would 302185435Sbz otherwise occur. */ 303185435Sbz#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \ 304185435Sbz _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters) 305185435Sbz 306191673Sjamie/* _GL_CXXALIAS_SYS (func, rettype, parameters); 307191673Sjamie declares a C++ alias called GNULIB_NAMESPACE::func 308191673Sjamie that redirects to the system provided function func, if GNULIB_NAMESPACE 309191673Sjamie is defined. 310191673Sjamie Example: 311191673Sjamie _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 312225617Skmacy 313185435Sbz Wrapping func in an object with an inline conversion operator 314191673Sjamie avoids a reference to func unless GNULIB_NAMESPACE::func is 315191673Sjamie actually used in the program. */ 316192895Sjamie#if defined __cplusplus && defined GNULIB_NAMESPACE 317185435Sbz# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 318191673Sjamie namespace GNULIB_NAMESPACE \ 319191673Sjamie { \ 320191673Sjamie static const struct _gl_ ## func ## _wrapper \ 321185435Sbz { \ 322191673Sjamie typedef rettype (*type) parameters; \ 323191673Sjamie \ 324191673Sjamie inline operator type () const \ 325191673Sjamie { \ 326185435Sbz return ::func; \ 327192895Sjamie } \ 328192895Sjamie } func = {}; \ 329191673Sjamie } \ 330191673Sjamie _GL_EXTERN_C int _gl_cxxalias_dummy 331191673Sjamie#else 332192895Sjamie# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 333192895Sjamie _GL_EXTERN_C int _gl_cxxalias_dummy 334192895Sjamie#endif 335258929Speter 336191673Sjamie/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 337191673Sjamie is like _GL_CXXALIAS_SYS (func, rettype, parameters); 338191673Sjamie except that the C function func may have a slightly different declaration. 339191673Sjamie A cast is used to silence the "invalid conversion" error that would 340185435Sbz otherwise occur. */ 341191673Sjamie#if defined __cplusplus && defined GNULIB_NAMESPACE 342191673Sjamie# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 343185435Sbz namespace GNULIB_NAMESPACE \ 344191673Sjamie { \ 345185435Sbz static const struct _gl_ ## func ## _wrapper \ 346191673Sjamie { \ 347191673Sjamie typedef rettype (*type) parameters; \ 348191673Sjamie \ 349191673Sjamie inline operator type () const \ 350191673Sjamie { \ 351192895Sjamie return reinterpret_cast<type>(::func); \ 352192895Sjamie } \ 353192895Sjamie } func = {}; \ 354192895Sjamie } \ 355192895Sjamie _GL_EXTERN_C int _gl_cxxalias_dummy 356192895Sjamie#else 357192895Sjamie# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 358192895Sjamie _GL_EXTERN_C int _gl_cxxalias_dummy 359192895Sjamie#endif 360192895Sjamie 361192895Sjamie/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 362192895Sjamie is like _GL_CXXALIAS_SYS (func, rettype, parameters); 363193865Sjamie except that the C function is picked among a set of overloaded functions, 364193865Sjamie namely the one with rettype2 and parameters2. Two consecutive casts 365193865Sjamie are used to silence the "cannot find a match" and "invalid conversion" 366193865Sjamie errors that would otherwise occur. */ 367193865Sjamie#if defined __cplusplus && defined GNULIB_NAMESPACE 368193865Sjamie /* The outer cast must be a reinterpret_cast. 369193865Sjamie The inner cast: When the function is defined as a set of overloaded 370193865Sjamie functions, it works as a static_cast<>, choosing the designated variant. 371193865Sjamie When the function is defined as a single variant, it works as a 372192895Sjamie reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 373192895Sjamie# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 374185435Sbz namespace GNULIB_NAMESPACE \ 375193865Sjamie { \ 376192895Sjamie static const struct _gl_ ## func ## _wrapper \ 377192895Sjamie { \ 378192895Sjamie typedef rettype (*type) parameters; \ 379192895Sjamie \ 380192895Sjamie inline operator type () const \ 381192895Sjamie { \ 382192895Sjamie return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ 383192895Sjamie } \ 384192895Sjamie } func = {}; \ 385192895Sjamie } \ 386192895Sjamie _GL_EXTERN_C int _gl_cxxalias_dummy 387192895Sjamie#else 388192895Sjamie# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 389192895Sjamie _GL_EXTERN_C int _gl_cxxalias_dummy 390192895Sjamie#endif 391192895Sjamie 392192895Sjamie/* _GL_CXXALIASWARN (func); 393192895Sjamie causes a warning to be emitted when ::func is used but not when 394192895Sjamie GNULIB_NAMESPACE::func is used. func must be defined without overloaded 395192895Sjamie variants. */ 396192895Sjamie#if defined __cplusplus && defined GNULIB_NAMESPACE 397192895Sjamie# define _GL_CXXALIASWARN(func) \ 398192895Sjamie _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 399192895Sjamie# define _GL_CXXALIASWARN_1(func,namespace) \ 400192895Sjamie _GL_CXXALIASWARN_2 (func, namespace) 401192895Sjamie/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 402192895Sjamie we enable the warning only when not optimizing. */ 403192895Sjamie# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) 404192895Sjamie# define _GL_CXXALIASWARN_2(func,namespace) \ 405192895Sjamie _GL_WARN_ON_USE (func, \ 406192895Sjamie "The symbol ::" #func " refers to the system function. " \ 407192895Sjamie "Use " #namespace "::" #func " instead.") 408192895Sjamie# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 409192895Sjamie# define _GL_CXXALIASWARN_2(func,namespace) \ 410192895Sjamie extern __typeof__ (func) func 411192895Sjamie# else 412192895Sjamie# define _GL_CXXALIASWARN_2(func,namespace) \ 413192895Sjamie _GL_EXTERN_C int _gl_cxxalias_dummy 414192895Sjamie# endif 415192895Sjamie#else 416192895Sjamie# define _GL_CXXALIASWARN(func) \ 417192895Sjamie _GL_EXTERN_C int _gl_cxxalias_dummy 418192895Sjamie#endif 419191673Sjamie 420192895Sjamie/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 421192895Sjamie causes a warning to be emitted when the given overloaded variant of ::func 422191673Sjamie is used but not when GNULIB_NAMESPACE::func is used. */ 423191673Sjamie#if defined __cplusplus && defined GNULIB_NAMESPACE 424192895Sjamie# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 425192895Sjamie _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 426192895Sjamie GNULIB_NAMESPACE) 427191673Sjamie# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 428192895Sjamie _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 429192895Sjamie/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 430191673Sjamie we enable the warning only when not optimizing. */ 431192895Sjamie# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) 432192895Sjamie# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 433192895Sjamie _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \ 434191673Sjamie "The symbol ::" #func " refers to the system function. " \ 435192895Sjamie "Use " #namespace "::" #func " instead.") 436191673Sjamie# else 437191673Sjamie# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 438191673Sjamie _GL_EXTERN_C int _gl_cxxalias_dummy 439192895Sjamie# endif 440191673Sjamie#else 441192895Sjamie# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 442191673Sjamie _GL_EXTERN_C int _gl_cxxalias_dummy 443191673Sjamie#endif 444192895Sjamie 445192895Sjamie#endif /* _GL_CXXDEFS_H */ 446192895Sjamie 447192895Sjamie/* The definition of _GL_ARG_NONNULL is copied here. */ 448192895Sjamie/* A C macro for declaring that specific arguments must not be NULL. 449192895Sjamie Copyright (C) 2009-2022 Free Software Foundation, Inc. 450192895Sjamie 451192895Sjamie This program is free software: you can redistribute it and/or modify it 452192895Sjamie under the terms of the GNU Lesser General Public License as published 453192895Sjamie by the Free Software Foundation; either version 2 of the License, or 454192895Sjamie (at your option) any later version. 455192895Sjamie 456192895Sjamie This program is distributed in the hope that it will be useful, 457192895Sjamie but WITHOUT ANY WARRANTY; without even the implied warranty of 458192895Sjamie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 459192895Sjamie Lesser General Public License for more details. 460192895Sjamie 461192895Sjamie You should have received a copy of the GNU Lesser General Public License 462192895Sjamie along with this program. If not, see <https://www.gnu.org/licenses/>. */ 463192895Sjamie 464192895Sjamie/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 465192895Sjamie that the values passed as arguments n, ..., m must be non-NULL pointers. 466192895Sjamie n = 1 stands for the first argument, n = 2 for the second argument etc. */ 467192895Sjamie#ifndef _GL_ARG_NONNULL 468192895Sjamie# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__ 469192895Sjamie# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 470192895Sjamie# else 471192895Sjamie# define _GL_ARG_NONNULL(params) 472192895Sjamie# endif 473191673Sjamie#endif 474191673Sjamie 475191673Sjamie/* The definition of _GL_WARN_ON_USE is copied here. */ 476191673Sjamie/* A C macro for emitting warnings if a function is used. 477192895Sjamie Copyright (C) 2010-2022 Free Software Foundation, Inc. 478192895Sjamie 479191673Sjamie This program is free software: you can redistribute it and/or modify it 480192895Sjamie under the terms of the GNU Lesser General Public License as published 481192895Sjamie by the Free Software Foundation; either version 2 of the License, or 482192895Sjamie (at your option) any later version. 483192895Sjamie 484192895Sjamie This program is distributed in the hope that it will be useful, 485192895Sjamie but WITHOUT ANY WARRANTY; without even the implied warranty of 486192895Sjamie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 487192895Sjamie Lesser General Public License for more details. 488192895Sjamie 489191673Sjamie You should have received a copy of the GNU Lesser General Public License 490191673Sjamie along with this program. If not, see <https://www.gnu.org/licenses/>. */ 491191673Sjamie 492191673Sjamie/* _GL_WARN_ON_USE (function, "literal string") issues a declaration 493192895Sjamie for FUNCTION which will then trigger a compiler warning containing 494192895Sjamie the text of "literal string" anywhere that function is called, if 495185435Sbz supported by the compiler. If the compiler does not support this 496185435Sbz feature, the macro expands to an unused extern declaration. 497192895Sjamie 498192895Sjamie _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the 499192895Sjamie attribute used in _GL_WARN_ON_USE. If the compiler does not support 500192895Sjamie this feature, it expands to empty. 501192895Sjamie 502192895Sjamie These macros are useful for marking a function as a potential 503192895Sjamie portability trap, with the intent that "literal string" include 504192895Sjamie instructions on the replacement function that should be used 505192895Sjamie instead. 506192895Sjamie _GL_WARN_ON_USE is for functions with 'extern' linkage. 507192895Sjamie _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 508185435Sbz linkage. 509192895Sjamie 510192895Sjamie However, one of the reasons that a function is a portability trap is 511191673Sjamie if it has the wrong signature. Declaring FUNCTION with a different 512191673Sjamie signature in C is a compilation error, so this macro must use the 513191673Sjamie same type as any existing declaration so that programs that avoid 514185435Sbz the problematic FUNCTION do not fail to compile merely because they 515185435Sbz included a header that poisoned the function. But this implies that 516192895Sjamie _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already 517191673Sjamie have a declaration. Use of this macro implies that there must not 518191673Sjamie be any other macro hiding the declaration of FUNCTION; but 519191673Sjamie undefining FUNCTION first is part of the poisoning process anyway 520191673Sjamie (although for symbols that are provided only via a macro, the result 521191673Sjamie is a compilation error rather than a warning containing 522191673Sjamie "literal string"). Also note that in C++, it is only safe to use if 523191673Sjamie FUNCTION has no overloads. 524191673Sjamie 525225617Skmacy For an example, it is possible to poison 'getline' by: 526185435Sbz - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], 527191673Sjamie [getline]) in configure.ac, which potentially defines 528191673Sjamie HAVE_RAW_DECL_GETLINE 529191673Sjamie - adding this code to a header that wraps the system <stdio.h>: 530191673Sjamie #undef getline 531191673Sjamie #if HAVE_RAW_DECL_GETLINE 532191673Sjamie _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" 533191673Sjamie "not universally present; use the gnulib module getline"); 534191673Sjamie #endif 535191673Sjamie 536191673Sjamie It is not possible to directly poison global variables. But it is 537191673Sjamie possible to write a wrapper accessor function, and poison that 538191673Sjamie (less common usage, like &environ, will cause a compilation error 539191673Sjamie rather than issue the nice warning, but the end result of informing 540191673Sjamie the developer about their portability problem is still achieved): 541191673Sjamie #if HAVE_RAW_DECL_ENVIRON 542191673Sjamie static char *** 543191673Sjamie rpl_environ (void) { return &environ; } 544191673Sjamie _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); 545191673Sjamie # undef environ 546185435Sbz # define environ (*rpl_environ ()) 547190466Sjamie #endif 548185435Sbz or better (avoiding contradictory use of 'static' and 'extern'): 549185435Sbz #if HAVE_RAW_DECL_ENVIRON 550185435Sbz static char *** 551185435Sbz _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") 552191673Sjamie rpl_environ (void) { return &environ; } 553191673Sjamie # undef environ 554196135Sbz # define environ (*rpl_environ ()) 555191673Sjamie #endif 556196835Sjamie */ 557280632Sian#ifndef _GL_WARN_ON_USE 558192895Sjamie 559196135Sbz# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 560191673Sjamie/* A compiler attribute is available in gcc versions 4.3.0 and later. */ 561192895Sjamie# define _GL_WARN_ON_USE(function, message) \ 562193066Sjamie_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message))) 563298833Sjamie# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 564298833Sjamie __attribute__ ((__warning__ (message))) 565298833Sjamie# elif __clang_major__ >= 4 566231267Smm/* Another compiler attribute is available in clang. */ 567195870Sjamie# define _GL_WARN_ON_USE(function, message) \ 568280632Sian_GL_WARN_EXTERN_C __typeof__ (function) function \ 569230129Smm __attribute__ ((__diagnose_if__ (1, message, "warning"))) 570191673Sjamie# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 571192895Sjamie __attribute__ ((__diagnose_if__ (1, message, "warning"))) 572191673Sjamie# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 573191673Sjamie/* Verify the existence of the function. */ 574195974Sjamie# define _GL_WARN_ON_USE(function, message) \ 575191673Sjamie_GL_WARN_EXTERN_C __typeof__ (function) function 576191673Sjamie# define _GL_WARN_ON_USE_ATTRIBUTE(message) 577195974Sjamie# else /* Unsupported. */ 578191673Sjamie# define _GL_WARN_ON_USE(function, message) \ 579224290Smckusick_GL_WARN_EXTERN_C int _gl_warn_on_use 580224290Smckusick# define _GL_WARN_ON_USE_ATTRIBUTE(message) 581191673Sjamie# endif 582185435Sbz#endif 583191673Sjamie 584191673Sjamie/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message") 585191673Sjamie is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the 586191673Sjamie function is declared with the given prototype, consisting of return type, 587191673Sjamie parameters, and attributes. 588298833Sjamie This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 589194762Sjamie not work in this case. */ 590192895Sjamie#ifndef _GL_WARN_ON_USE_CXX 591191673Sjamie# if !defined __cplusplus 592191673Sjamie# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 593191673Sjamie _GL_WARN_ON_USE (function, msg) 594185435Sbz# else 595191673Sjamie# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 596191673Sjamie/* A compiler attribute is available in gcc versions 4.3.0 and later. */ 597191673Sjamie# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 598191673Sjamieextern rettype_gcc function parameters_and_attributes \ 599185435Sbz __attribute__ ((__warning__ (msg))) 600191673Sjamie# elif __clang_major__ >= 4 601191673Sjamie/* Another compiler attribute is available in clang. */ 602191673Sjamie# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 603185435Sbzextern rettype_clang function parameters_and_attributes \ 604191673Sjamie __attribute__ ((__diagnose_if__ (1, msg, "warning"))) 605191673Sjamie# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 606191673Sjamie/* Verify the existence of the function. */ 607185435Sbz# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 608185435Sbzextern rettype_gcc function parameters_and_attributes 609185435Sbz# else /* Unsupported. */ 610185435Sbz# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 611185435Sbz_GL_WARN_EXTERN_C int _gl_warn_on_use 612185435Sbz# endif 613230407Smm# endif 614191673Sjamie#endif 615298833Sjamie 616298833Sjamie/* _GL_WARN_EXTERN_C declaration; 617298833Sjamie performs the declaration with C linkage. */ 618298833Sjamie#ifndef _GL_WARN_EXTERN_C 619298833Sjamie# if defined __cplusplus 620298833Sjamie# define _GL_WARN_EXTERN_C extern "C" 621298833Sjamie# else 622191673Sjamie# define _GL_WARN_EXTERN_C extern 623191673Sjamie# endif 624191673Sjamie#endif 625191673Sjamie 626191673Sjamie/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have 627191673Sjamie been included yet. */ 628191673Sjamie#if 1 629191673Sjamie# if (1 && !defined free \ 630191673Sjamie && !(defined __cplusplus && defined GNULIB_NAMESPACE)) 631191673Sjamie/* We can't do '#define free rpl_free' here. */ 632191673Sjamie_GL_EXTERN_C void rpl_free (void *); 633191673Sjamie# undef _GL_ATTRIBUTE_DEALLOC_FREE 634191673Sjamie# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1) 635191673Sjamie# else 636194762Sjamie# if defined _MSC_VER 637194762Sjamie_GL_EXTERN_C void __cdecl free (void *); 638194762Sjamie# else 639194762Sjamie# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 640194762Sjamie_GL_EXTERN_C void free (void *) throw (); 641194762Sjamie# else 642194762Sjamie_GL_EXTERN_C void free (void *); 643194762Sjamie# endif 644194762Sjamie# endif 645192895Sjamie# endif 646212436Sjamie#else 647212436Sjamie# if defined _MSC_VER 648212436Sjamie_GL_EXTERN_C void __cdecl free (void *); 649192895Sjamie# else 650212436Sjamie# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2) 651212436Sjamie_GL_EXTERN_C void free (void *) throw (); 652212436Sjamie# else 653212436Sjamie_GL_EXTERN_C void free (void *); 654212436Sjamie# endif 655192895Sjamie# endif 656231267Smm#endif 657231267Smm 658231267Smm/* Clear a block of memory. The compiler will not delete a call to 659231267Smm this function, even if the block is dead after the call. */ 660231267Smm#if 0 661231267Smm# if ! 1 662231267Smm_GL_FUNCDECL_SYS (explicit_bzero, void, 663231267Smm (void *__dest, size_t __n) _GL_ARG_NONNULL ((1))); 664191673Sjamie# endif 665192895Sjamie_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n)); 666192895Sjamie_GL_CXXALIASWARN (explicit_bzero); 667192895Sjamie#elif defined GNULIB_POSIXCHECK 668192895Sjamie# undef explicit_bzero 669192895Sjamie# if HAVE_RAW_DECL_EXPLICIT_BZERO 670192895Sjamie_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - " 671192895Sjamie "use gnulib module explicit_bzero for portability"); 672191673Sjamie# endif 673195870Sjamie#endif 674195870Sjamie 675195870Sjamie/* Find the index of the least-significant set bit. */ 676195870Sjamie#if 0 677195870Sjamie# if !1 678195870Sjamie_GL_FUNCDECL_SYS (ffsl, int, (long int i)); 679195870Sjamie# endif 680195870Sjamie_GL_CXXALIAS_SYS (ffsl, int, (long int i)); 681195870Sjamie_GL_CXXALIASWARN (ffsl); 682195870Sjamie#elif defined GNULIB_POSIXCHECK 683195870Sjamie# undef ffsl 684195870Sjamie# if HAVE_RAW_DECL_FFSL 685195870Sjamie_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module"); 686195870Sjamie# endif 687195870Sjamie#endif 688195870Sjamie 689195870Sjamie 690195870Sjamie/* Find the index of the least-significant set bit. */ 691195870Sjamie#if 0 692195870Sjamie# if 0 693195870Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 694195870Sjamie# define ffsll rpl_ffsll 695195870Sjamie# endif 696195870Sjamie_GL_FUNCDECL_RPL (ffsll, int, (long long int i)); 697195870Sjamie_GL_CXXALIAS_RPL (ffsll, int, (long long int i)); 698195870Sjamie# else 699195870Sjamie# if !1 700195870Sjamie_GL_FUNCDECL_SYS (ffsll, int, (long long int i)); 701211085Sjamie# endif 702211085Sjamie_GL_CXXALIAS_SYS (ffsll, int, (long long int i)); 703211085Sjamie# endif 704211085Sjamie_GL_CXXALIASWARN (ffsll); 705211085Sjamie#elif defined GNULIB_POSIXCHECK 706211085Sjamie# undef ffsll 707194251Sjamie# if HAVE_RAW_DECL_FFSLL 708194251Sjamie_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module"); 709194251Sjamie# endif 710194251Sjamie#endif 711194251Sjamie 712194251Sjamie 713194251Sjamie#if 1 714195974Sjamie/* On native Windows, map 'memccpy' to '_memccpy', so that -loldnames is not 715195974Sjamie required. In C++ with GNULIB_NAMESPACE, avoid differences between 716195974Sjamie platforms by defining GNULIB_NAMESPACE::memccpy always. */ 717195974Sjamie# if defined _WIN32 && !defined __CYGWIN__ 718195974Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 719195974Sjamie# undef memccpy 720195974Sjamie# define memccpy _memccpy 721195974Sjamie# endif 722195974Sjamie_GL_CXXALIAS_MDA (memccpy, void *, 723195974Sjamie (void *dest, const void *src, int c, size_t n)); 724195974Sjamie# else 725195974Sjamie_GL_CXXALIAS_SYS (memccpy, void *, 726195974Sjamie (void *dest, const void *src, int c, size_t n)); 727195974Sjamie# endif 728191673Sjamie_GL_CXXALIASWARN (memccpy); 729192895Sjamie#endif 730192895Sjamie 731192895Sjamie 732192895Sjamie/* Return the first instance of C within N bytes of S, or NULL. */ 733192895Sjamie#if 1 734192895Sjamie# if 1 735192895Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 736192895Sjamie# undef memchr 737191673Sjamie# define memchr rpl_memchr 738191673Sjamie# endif 739191673Sjamie_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) 740191673Sjamie _GL_ATTRIBUTE_PURE 741191673Sjamie _GL_ARG_NONNULL ((1))); 742191673Sjamie_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); 743191673Sjamie# else 744191673Sjamie /* On some systems, this function is defined as an overloaded function: 745191673Sjamie extern "C" { const void * std::memchr (const void *, int, size_t); } 746191673Sjamie extern "C++" { void * std::memchr (void *, int, size_t); } */ 747191673Sjamie_GL_CXXALIAS_SYS_CAST2 (memchr, 748191673Sjamie void *, (void const *__s, int __c, size_t __n), 749191673Sjamie void const *, (void const *__s, int __c, size_t __n)); 750191673Sjamie# endif 751191673Sjamie# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 752191673Sjamie && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 753191673Sjamie || defined __clang__) 754191673Sjamie_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n) throw ()); 755191673Sjamie_GL_CXXALIASWARN1 (memchr, void const *, 756191673Sjamie (void const *__s, int __c, size_t __n) throw ()); 757191673Sjamie# elif __GLIBC__ >= 2 758191673Sjamie_GL_CXXALIASWARN (memchr); 759193066Sjamie# endif 760193066Sjamie#elif defined GNULIB_POSIXCHECK 761191673Sjamie# undef memchr 762191673Sjamie/* Assume memchr is always declared. */ 763191673Sjamie_GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " 764191673Sjamie "use gnulib module memchr for portability" ); 765191673Sjamie#endif 766191673Sjamie 767191673Sjamie/* Return the first occurrence of NEEDLE in HAYSTACK. */ 768191673Sjamie#if 1 769191673Sjamie# if 1 770191673Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 771193066Sjamie# define memmem rpl_memmem 772193066Sjamie# endif 773193066Sjamie_GL_FUNCDECL_RPL (memmem, void *, 774193066Sjamie (void const *__haystack, size_t __haystack_len, 775193066Sjamie void const *__needle, size_t __needle_len) 776193066Sjamie _GL_ATTRIBUTE_PURE 777193066Sjamie _GL_ARG_NONNULL ((1, 3))); 778193066Sjamie_GL_CXXALIAS_RPL (memmem, void *, 779193066Sjamie (void const *__haystack, size_t __haystack_len, 780193066Sjamie void const *__needle, size_t __needle_len)); 781193066Sjamie# else 782193066Sjamie# if ! 1 783193066Sjamie_GL_FUNCDECL_SYS (memmem, void *, 784193066Sjamie (void const *__haystack, size_t __haystack_len, 785193066Sjamie void const *__needle, size_t __needle_len) 786193066Sjamie _GL_ATTRIBUTE_PURE 787193066Sjamie _GL_ARG_NONNULL ((1, 3))); 788193066Sjamie# endif 789193066Sjamie_GL_CXXALIAS_SYS (memmem, void *, 790193066Sjamie (void const *__haystack, size_t __haystack_len, 791193066Sjamie void const *__needle, size_t __needle_len)); 792193066Sjamie# endif 793193066Sjamie_GL_CXXALIASWARN (memmem); 794193066Sjamie#elif defined GNULIB_POSIXCHECK 795193066Sjamie# undef memmem 796193066Sjamie# if HAVE_RAW_DECL_MEMMEM 797193066Sjamie_GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - " 798193066Sjamie "use gnulib module memmem-simple for portability, " 799193066Sjamie "and module memmem for speed" ); 800193066Sjamie# endif 801193066Sjamie#endif 802193066Sjamie 803193066Sjamie/* Copy N bytes of SRC to DEST, return pointer to bytes after the 804193066Sjamie last written byte. */ 805193066Sjamie#if 1 806193066Sjamie# if ! 1 807205014Snwhitehorn_GL_FUNCDECL_SYS (mempcpy, void *, 808217896Sdchagin (void *restrict __dest, void const *restrict __src, 809193066Sjamie size_t __n) 810193066Sjamie _GL_ARG_NONNULL ((1, 2))); 811193066Sjamie# endif 812193066Sjamie_GL_CXXALIAS_SYS (mempcpy, void *, 813193066Sjamie (void *restrict __dest, void const *restrict __src, 814193066Sjamie size_t __n)); 815193066Sjamie_GL_CXXALIASWARN (mempcpy); 816193066Sjamie#elif defined GNULIB_POSIXCHECK 817193066Sjamie# undef mempcpy 818193066Sjamie# if HAVE_RAW_DECL_MEMPCPY 819193066Sjamie_GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " 820193066Sjamie "use gnulib module mempcpy for portability"); 821193066Sjamie# endif 822193066Sjamie#endif 823193066Sjamie 824193066Sjamie/* Search backwards through a block for a byte (specified as an int). */ 825193066Sjamie#if 1 826185435Sbz# if ! 1 827191673Sjamie_GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) 828191673Sjamie _GL_ATTRIBUTE_PURE 829277279Sjamie _GL_ARG_NONNULL ((1))); 830191673Sjamie# endif 831191673Sjamie /* On some systems, this function is defined as an overloaded function: 832191673Sjamie extern "C++" { const void * std::memrchr (const void *, int, size_t); } 833191673Sjamie extern "C++" { void * std::memrchr (void *, int, size_t); } */ 834191673Sjamie_GL_CXXALIAS_SYS_CAST2 (memrchr, 835192895Sjamie void *, (void const *, int, size_t), 836195870Sjamie void const *, (void const *, int, size_t)); 837195870Sjamie# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 838195870Sjamie && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 839195870Sjamie || defined __clang__) 840195870Sjamie_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t) throw ()); 841192895Sjamie_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t) throw ()); 842192895Sjamie# else 843185435Sbz_GL_CXXALIASWARN (memrchr); 844192895Sjamie# endif 845192895Sjamie#elif defined GNULIB_POSIXCHECK 846185435Sbz# undef memrchr 847195974Sjamie# if HAVE_RAW_DECL_MEMRCHR 848192895Sjamie_GL_WARN_ON_USE (memrchr, "memrchr is unportable - " 849192895Sjamie "use gnulib module memrchr for portability"); 850192895Sjamie# endif 851192895Sjamie#endif 852192895Sjamie 853202116Sbz/* Find the first occurrence of C in S. More efficient than 854202116Sbz memchr(S,C,N), at the expense of undefined behavior if C does not 855202116Sbz occur within N bytes. */ 856192895Sjamie#if 1 857192895Sjamie# if ! 0 858192895Sjamie_GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) 859192895Sjamie _GL_ATTRIBUTE_PURE 860192895Sjamie _GL_ARG_NONNULL ((1))); 861192895Sjamie# endif 862192895Sjamie /* On some systems, this function is defined as an overloaded function: 863192895Sjamie extern "C++" { const void * std::rawmemchr (const void *, int); } 864192895Sjamie extern "C++" { void * std::rawmemchr (void *, int); } */ 865192895Sjamie_GL_CXXALIAS_SYS_CAST2 (rawmemchr, 866192895Sjamie void *, (void const *__s, int __c_in), 867192895Sjamie void const *, (void const *__s, int __c_in)); 868192895Sjamie# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 869192895Sjamie && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 870192895Sjamie || defined __clang__) 871192895Sjamie_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in) throw ()); 872192895Sjamie_GL_CXXALIASWARN1 (rawmemchr, void const *, 873192895Sjamie (void const *__s, int __c_in) throw ()); 874192895Sjamie# else 875192895Sjamie_GL_CXXALIASWARN (rawmemchr); 876192895Sjamie# endif 877192895Sjamie#elif defined GNULIB_POSIXCHECK 878192895Sjamie# undef rawmemchr 879192895Sjamie# if HAVE_RAW_DECL_RAWMEMCHR 880185435Sbz_GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - " 881191673Sjamie "use gnulib module rawmemchr for portability"); 882191673Sjamie# endif 883185435Sbz#endif 884185435Sbz 885191673Sjamie/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ 886191673Sjamie#if 0 887277279Sjamie# if ! 1 888191673Sjamie_GL_FUNCDECL_SYS (stpcpy, char *, 889191673Sjamie (char *restrict __dst, char const *restrict __src) 890191673Sjamie _GL_ARG_NONNULL ((1, 2))); 891191673Sjamie# endif 892191673Sjamie_GL_CXXALIAS_SYS (stpcpy, char *, 893192895Sjamie (char *restrict __dst, char const *restrict __src)); 894195870Sjamie_GL_CXXALIASWARN (stpcpy); 895195870Sjamie#elif defined GNULIB_POSIXCHECK 896195870Sjamie# undef stpcpy 897195870Sjamie# if HAVE_RAW_DECL_STPCPY 898195870Sjamie_GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " 899192895Sjamie "use gnulib module stpcpy for portability"); 900192895Sjamie# endif 901185435Sbz#endif 902192895Sjamie 903192895Sjamie/* Copy no more than N bytes of SRC to DST, returning a pointer past the 904185435Sbz last non-NUL byte written into DST. */ 905195974Sjamie#if 0 906192895Sjamie# if 0 907192895Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 908192895Sjamie# undef stpncpy 909192895Sjamie# define stpncpy rpl_stpncpy 910192895Sjamie# endif 911192895Sjamie_GL_FUNCDECL_RPL (stpncpy, char *, 912192895Sjamie (char *restrict __dst, char const *restrict __src, 913192895Sjamie size_t __n) 914192895Sjamie _GL_ARG_NONNULL ((1, 2))); 915192895Sjamie_GL_CXXALIAS_RPL (stpncpy, char *, 916192895Sjamie (char *restrict __dst, char const *restrict __src, 917192895Sjamie size_t __n)); 918192895Sjamie# else 919192895Sjamie# if ! 1 920192895Sjamie_GL_FUNCDECL_SYS (stpncpy, char *, 921192895Sjamie (char *restrict __dst, char const *restrict __src, 922185435Sbz size_t __n) 923191673Sjamie _GL_ARG_NONNULL ((1, 2))); 924185435Sbz# endif 925185435Sbz_GL_CXXALIAS_SYS (stpncpy, char *, 926195945Sjamie (char *restrict __dst, char const *restrict __src, 927195945Sjamie size_t __n)); 928195945Sjamie# endif 929195945Sjamie_GL_CXXALIASWARN (stpncpy); 930195945Sjamie#elif defined GNULIB_POSIXCHECK 931195945Sjamie# undef stpncpy 932195945Sjamie# if HAVE_RAW_DECL_STPNCPY 933195945Sjamie_GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - " 934195945Sjamie "use gnulib module stpncpy for portability"); 935230143Smm# endif 936191673Sjamie#endif 937191673Sjamie 938191673Sjamie#if defined GNULIB_POSIXCHECK 939191673Sjamie/* strchr() does not work with multibyte strings if the locale encoding is 940191673Sjamie GB18030 and the character to be searched is a digit. */ 941191673Sjamie# undef strchr 942191673Sjamie/* Assume strchr is always declared. */ 943191673Sjamie_GL_WARN_ON_USE_CXX (strchr, 944191673Sjamie const char *, char *, (const char *, int), 945191673Sjamie "strchr cannot work correctly on character strings " 946191673Sjamie "in some multibyte locales - " 947191673Sjamie "use mbschr if you care about internationalization"); 948191673Sjamie#endif 949191673Sjamie 950191673Sjamie/* Find the first occurrence of C in S or the final NUL byte. */ 951191673Sjamie#if 1 952191673Sjamie# if 0 953241896Skib# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 954230129Smm# define strchrnul rpl_strchrnul 955230129Smm# endif 956230129Smm_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in) 957230129Smm _GL_ATTRIBUTE_PURE 958230129Smm _GL_ARG_NONNULL ((1))); 959230129Smm_GL_CXXALIAS_RPL (strchrnul, char *, 960230407Smm (const char *str, int ch)); 961230407Smm# else 962230407Smm# if ! 1 963230407Smm_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) 964230407Smm _GL_ATTRIBUTE_PURE 965230407Smm _GL_ARG_NONNULL ((1))); 966230129Smm# endif 967230129Smm /* On some systems, this function is defined as an overloaded function: 968230129Smm extern "C++" { const char * std::strchrnul (const char *, int); } 969230129Smm extern "C++" { char * std::strchrnul (char *, int); } */ 970230407Smm_GL_CXXALIAS_SYS_CAST2 (strchrnul, 971230129Smm char *, (char const *__s, int __c_in), 972230129Smm char const *, (char const *__s, int __c_in)); 973230129Smm# endif 974230129Smm# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 975230129Smm && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 976230129Smm || defined __clang__) 977230129Smm_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in) throw ()); 978230129Smm_GL_CXXALIASWARN1 (strchrnul, char const *, 979230129Smm (char const *__s, int __c_in) throw ()); 980230129Smm# else 981192895Sjamie_GL_CXXALIASWARN (strchrnul); 982192895Sjamie# endif 983192895Sjamie#elif defined GNULIB_POSIXCHECK 984192895Sjamie# undef strchrnul 985192895Sjamie# if HAVE_RAW_DECL_STRCHRNUL 986192895Sjamie_GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " 987191673Sjamie "use gnulib module strchrnul for portability"); 988191673Sjamie# endif 989185435Sbz#endif 990280632Sian 991280632Sian/* Duplicate S, returning an identical malloc'd string. */ 992280632Sian#if 1 993280632Sian# if 0 994280632Sian# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 995280632Sian# undef strdup 996280632Sian# define strdup rpl_strdup 997280632Sian# endif 998280632Sian_GL_FUNCDECL_RPL (strdup, char *, 999280632Sian (char const *__s) 1000280632Sian _GL_ARG_NONNULL ((1)) 1001280632Sian _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1002280632Sian_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); 1003280632Sian# elif defined _WIN32 && !defined __CYGWIN__ 1004280632Sian# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1005280632Sian# undef strdup 1006280632Sian# define strdup _strdup 1007280632Sian# endif 1008280632Sian_GL_CXXALIAS_MDA (strdup, char *, (char const *__s)); 1009280632Sian# else 1010280632Sian# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup 1011280632Sian /* strdup exists as a function and as a macro. Get rid of the macro. */ 1012280632Sian# undef strdup 1013280632Sian# endif 1014280632Sian# if (!1 || __GNUC__ >= 11) && !defined strdup 1015280632Sian_GL_FUNCDECL_SYS (strdup, char *, 1016280632Sian (char const *__s) 1017280632Sian _GL_ARG_NONNULL ((1)) 1018280632Sian _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1019280632Sian# endif 1020280632Sian_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); 1021280632Sian# endif 1022280632Sian_GL_CXXALIASWARN (strdup); 1023280632Sian#else 1024280632Sian# if __GNUC__ >= 11 && !defined strdup 1025280632Sian/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */ 1026280632Sian_GL_FUNCDECL_SYS (strdup, char *, 1027280632Sian (char const *__s) 1028280632Sian _GL_ARG_NONNULL ((1)) 1029280632Sian _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1030191673Sjamie# endif 1031298833Sjamie# if defined GNULIB_POSIXCHECK 1032191673Sjamie# undef strdup 1033185435Sbz# if HAVE_RAW_DECL_STRDUP 1034191673Sjamie_GL_WARN_ON_USE (strdup, "strdup is unportable - " 1035298833Sjamie "use gnulib module strdup for portability"); 1036196835Sjamie# endif 1037196835Sjamie# elif 1 1038196835Sjamie/* On native Windows, map 'creat' to '_creat', so that -loldnames is not 1039196835Sjamie required. In C++ with GNULIB_NAMESPACE, avoid differences between 1040196835Sjamie platforms by defining GNULIB_NAMESPACE::strdup always. */ 1041196835Sjamie# if defined _WIN32 && !defined __CYGWIN__ 1042298833Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1043191673Sjamie# undef strdup 1044192895Sjamie# define strdup _strdup 1045192895Sjamie# endif 1046192895Sjamie_GL_CXXALIAS_MDA (strdup, char *, (char const *__s)); 1047192895Sjamie# else 1048192895Sjamie# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup 1049192895Sjamie# undef strdup 1050192895Sjamie# endif 1051191673Sjamie_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); 1052191673Sjamie# endif 1053191673Sjamie_GL_CXXALIASWARN (strdup); 1054191673Sjamie# endif 1055191673Sjamie#endif 1056191673Sjamie 1057191673Sjamie/* Append no more than N characters from SRC onto DEST. */ 1058192895Sjamie#if 0 1059191673Sjamie# if 0 1060191673Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1061191673Sjamie# undef strncat 1062191673Sjamie# define strncat rpl_strncat 1063191673Sjamie# endif 1064191673Sjamie_GL_FUNCDECL_RPL (strncat, char *, 1065191673Sjamie (char *restrict dest, const char *restrict src, size_t n) 1066191673Sjamie _GL_ARG_NONNULL ((1, 2))); 1067192895Sjamie_GL_CXXALIAS_RPL (strncat, char *, 1068192895Sjamie (char *restrict dest, const char *restrict src, size_t n)); 1069192895Sjamie# else 1070192895Sjamie_GL_CXXALIAS_SYS (strncat, char *, 1071191673Sjamie (char *restrict dest, const char *restrict src, size_t n)); 1072191673Sjamie# endif 1073191673Sjamie# if __GLIBC__ >= 2 1074191673Sjamie_GL_CXXALIASWARN (strncat); 1075191673Sjamie# endif 1076191673Sjamie#elif defined GNULIB_POSIXCHECK 1077191673Sjamie# undef strncat 1078191673Sjamie# if HAVE_RAW_DECL_STRNCAT 1079191673Sjamie_GL_WARN_ON_USE (strncat, "strncat is unportable - " 1080191673Sjamie "use gnulib module strncat for portability"); 1081191673Sjamie# endif 1082191673Sjamie#endif 1083191673Sjamie 1084191673Sjamie/* Return a newly allocated copy of at most N bytes of STRING. */ 1085191673Sjamie#if 0 1086191673Sjamie# if 0 1087191673Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1088192895Sjamie# undef strndup 1089191673Sjamie# define strndup rpl_strndup 1090191673Sjamie# endif 1091191673Sjamie_GL_FUNCDECL_RPL (strndup, char *, 1092191673Sjamie (char const *__s, size_t __n) 1093191673Sjamie _GL_ARG_NONNULL ((1)) 1094191673Sjamie _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1095191673Sjamie_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n)); 1096191673Sjamie# else 1097191673Sjamie# if !1 || (__GNUC__ >= 11 && !defined strndup) 1098191673Sjamie_GL_FUNCDECL_SYS (strndup, char *, 1099191673Sjamie (char const *__s, size_t __n) 1100191673Sjamie _GL_ARG_NONNULL ((1)) 1101191673Sjamie _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1102191673Sjamie# endif 1103191673Sjamie_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n)); 1104191673Sjamie# endif 1105191673Sjamie_GL_CXXALIASWARN (strndup); 1106191673Sjamie#else 1107191673Sjamie# if __GNUC__ >= 11 && !defined strndup 1108298833Sjamie/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */ 1109191673Sjamie_GL_FUNCDECL_SYS (strndup, char *, 1110196835Sjamie (char const *__s, size_t __n) 1111196835Sjamie _GL_ARG_NONNULL ((1)) 1112196835Sjamie _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE); 1113196835Sjamie# endif 1114192895Sjamie# if defined GNULIB_POSIXCHECK 1115192895Sjamie# undef strndup 1116192895Sjamie# if HAVE_RAW_DECL_STRNDUP 1117192895Sjamie_GL_WARN_ON_USE (strndup, "strndup is unportable - " 1118192895Sjamie "use gnulib module strndup for portability"); 1119192895Sjamie# endif 1120196835Sjamie# endif 1121196835Sjamie#endif 1122192895Sjamie 1123192895Sjamie/* Find the length (number of bytes) of STRING, but scan at most 1124192895Sjamie MAXLEN bytes. If no '\0' terminator is found in that many bytes, 1125192895Sjamie return MAXLEN. */ 1126192895Sjamie#if 1 1127192895Sjamie# if 0 1128192895Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1129298833Sjamie# undef strnlen 1130192895Sjamie# define strnlen rpl_strnlen 1131192895Sjamie# endif 1132192895Sjamie_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen) 1133192895Sjamie _GL_ATTRIBUTE_PURE 1134192895Sjamie _GL_ARG_NONNULL ((1))); 1135192895Sjamie_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)); 1136192895Sjamie# else 1137192895Sjamie# if ! 1 1138298833Sjamie_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen) 1139192895Sjamie _GL_ATTRIBUTE_PURE 1140298833Sjamie _GL_ARG_NONNULL ((1))); 1141192895Sjamie# endif 1142298833Sjamie_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)); 1143298833Sjamie# endif 1144192895Sjamie_GL_CXXALIASWARN (strnlen); 1145192895Sjamie#elif defined GNULIB_POSIXCHECK 1146191673Sjamie# undef strnlen 1147192895Sjamie# if HAVE_RAW_DECL_STRNLEN 1148191673Sjamie_GL_WARN_ON_USE (strnlen, "strnlen is unportable - " 1149298833Sjamie "use gnulib module strnlen for portability"); 1150191673Sjamie# endif 1151191673Sjamie#endif 1152191673Sjamie 1153191673Sjamie#if defined GNULIB_POSIXCHECK 1154191673Sjamie/* strcspn() assumes the second argument is a list of single-byte characters. 1155191673Sjamie Even in this simple case, it does not work with multibyte strings if the 1156191673Sjamie locale encoding is GB18030 and one of the characters to be searched is a 1157191673Sjamie digit. */ 1158191673Sjamie# undef strcspn 1159191673Sjamie/* Assume strcspn is always declared. */ 1160191673Sjamie_GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " 1161191673Sjamie "in multibyte locales - " 1162191673Sjamie "use mbscspn if you care about internationalization"); 1163191673Sjamie#endif 1164191673Sjamie 1165191673Sjamie/* Find the first occurrence in S of any character in ACCEPT. */ 1166191673Sjamie#if 0 1167191673Sjamie# if ! 1 1168191673Sjamie_GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) 1169192895Sjamie _GL_ATTRIBUTE_PURE 1170191673Sjamie _GL_ARG_NONNULL ((1, 2))); 1171191673Sjamie# endif 1172191673Sjamie /* On some systems, this function is defined as an overloaded function: 1173191673Sjamie extern "C" { const char * strpbrk (const char *, const char *); } 1174191673Sjamie extern "C++" { char * strpbrk (char *, const char *); } */ 1175191673Sjamie_GL_CXXALIAS_SYS_CAST2 (strpbrk, 1176191673Sjamie char *, (char const *__s, char const *__accept), 1177191673Sjamie const char *, (char const *__s, char const *__accept)); 1178191673Sjamie# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1179191673Sjamie && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 1180191673Sjamie || defined __clang__) 1181191673Sjamie_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ()); 1182191673Sjamie_GL_CXXALIASWARN1 (strpbrk, char const *, 1183191673Sjamie (char const *__s, char const *__accept) throw ()); 1184191673Sjamie# elif __GLIBC__ >= 2 1185191673Sjamie_GL_CXXALIASWARN (strpbrk); 1186191673Sjamie# endif 1187191673Sjamie# if defined GNULIB_POSIXCHECK 1188191673Sjamie/* strpbrk() assumes the second argument is a list of single-byte characters. 1189191673Sjamie Even in this simple case, it does not work with multibyte strings if the 1190191673Sjamie locale encoding is GB18030 and one of the characters to be searched is a 1191191673Sjamie digit. */ 1192191673Sjamie# undef strpbrk 1193191673Sjamie_GL_WARN_ON_USE_CXX (strpbrk, 1194191673Sjamie const char *, char *, (const char *, const char *), 1195191673Sjamie "strpbrk cannot work correctly on character strings " 1196191673Sjamie "in multibyte locales - " 1197191673Sjamie "use mbspbrk if you care about internationalization"); 1198191673Sjamie# endif 1199191673Sjamie#elif defined GNULIB_POSIXCHECK 1200191673Sjamie# undef strpbrk 1201191673Sjamie# if HAVE_RAW_DECL_STRPBRK 1202191673Sjamie_GL_WARN_ON_USE_CXX (strpbrk, 1203191673Sjamie const char *, char *, (const char *, const char *), 1204191673Sjamie "strpbrk is unportable - " 1205191673Sjamie "use gnulib module strpbrk for portability"); 1206191673Sjamie# endif 1207191673Sjamie#endif 1208191673Sjamie 1209191673Sjamie#if defined GNULIB_POSIXCHECK 1210191673Sjamie/* strspn() assumes the second argument is a list of single-byte characters. 1211191673Sjamie Even in this simple case, it cannot work with multibyte strings. */ 1212185435Sbz# undef strspn 1213191673Sjamie/* Assume strspn is always declared. */ 1214191673Sjamie_GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings " 1215194762Sjamie "in multibyte locales - " 1216194762Sjamie "use mbsspn if you care about internationalization"); 1217194762Sjamie#endif 1218194762Sjamie 1219194762Sjamie#if defined GNULIB_POSIXCHECK 1220194762Sjamie/* strrchr() does not work with multibyte strings if the locale encoding is 1221191673Sjamie GB18030 and the character to be searched is a digit. */ 1222192895Sjamie# undef strrchr 1223298832Sjamie/* Assume strrchr is always declared. */ 1224192895Sjamie_GL_WARN_ON_USE_CXX (strrchr, 1225192895Sjamie const char *, char *, (const char *, int), 1226298833Sjamie "strrchr cannot work correctly on character strings " 1227298833Sjamie "in some multibyte locales - " 1228192895Sjamie "use mbsrchr if you care about internationalization"); 1229192895Sjamie#endif 1230192895Sjamie 1231192895Sjamie/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. 1232192895Sjamie If one is found, overwrite it with a NUL, and advance *STRINGP 1233191673Sjamie to point to the next char after it. Otherwise, set *STRINGP to NULL. 1234191673Sjamie If *STRINGP was already NULL, nothing happens. 1235191673Sjamie Return the old value of *STRINGP. 1236191673Sjamie 1237191673Sjamie This is a variant of strtok() that is multithread-safe and supports 1238191673Sjamie empty fields. 1239191673Sjamie 1240191673Sjamie Caveat: It modifies the original string. 1241191673Sjamie Caveat: These functions cannot be used on constant strings. 1242191673Sjamie Caveat: The identity of the delimiting character is lost. 1243191673Sjamie Caveat: It doesn't work with multibyte strings unless all of the delimiter 1244191673Sjamie characters are ASCII characters < 0x30. 1245191673Sjamie 1246191673Sjamie See also strtok_r(). */ 1247191673Sjamie#if 0 1248191673Sjamie# if ! 1 1249191673Sjamie_GL_FUNCDECL_SYS (strsep, char *, 1250191673Sjamie (char **restrict __stringp, char const *restrict __delim) 1251191673Sjamie _GL_ARG_NONNULL ((1, 2))); 1252192895Sjamie# endif 1253192895Sjamie_GL_CXXALIAS_SYS (strsep, char *, 1254192895Sjamie (char **restrict __stringp, char const *restrict __delim)); 1255191673Sjamie_GL_CXXALIASWARN (strsep); 1256191673Sjamie# if defined GNULIB_POSIXCHECK 1257191673Sjamie# undef strsep 1258191673Sjamie_GL_WARN_ON_USE (strsep, "strsep cannot work correctly on character strings " 1259191673Sjamie "in multibyte locales - " 1260191673Sjamie "use mbssep if you care about internationalization"); 1261191673Sjamie# endif 1262191673Sjamie#elif defined GNULIB_POSIXCHECK 1263191673Sjamie# undef strsep 1264191673Sjamie# if HAVE_RAW_DECL_STRSEP 1265191673Sjamie_GL_WARN_ON_USE (strsep, "strsep is unportable - " 1266191673Sjamie "use gnulib module strsep for portability"); 1267191673Sjamie# endif 1268191673Sjamie#endif 1269191673Sjamie 1270191673Sjamie#if 1 1271191673Sjamie# if 1 1272191673Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1273192895Sjamie# define strstr rpl_strstr 1274192895Sjamie# endif 1275194762Sjamie_GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) 1276185435Sbz _GL_ATTRIBUTE_PURE 1277192895Sjamie _GL_ARG_NONNULL ((1, 2))); 1278191673Sjamie_GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); 1279192895Sjamie# else 1280192895Sjamie /* On some systems, this function is defined as an overloaded function: 1281298833Sjamie extern "C++" { const char * strstr (const char *, const char *); } 1282298833Sjamie extern "C++" { char * strstr (char *, const char *); } */ 1283191673Sjamie_GL_CXXALIAS_SYS_CAST2 (strstr, 1284191673Sjamie char *, (const char *haystack, const char *needle), 1285192895Sjamie const char *, (const char *haystack, const char *needle)); 1286191673Sjamie# endif 1287191673Sjamie# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1288195944Sjamie && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 1289195944Sjamie || defined __clang__) 1290195945Sjamie_GL_CXXALIASWARN1 (strstr, char *, 1291195945Sjamie (char *haystack, const char *needle) throw ()); 1292195945Sjamie_GL_CXXALIASWARN1 (strstr, const char *, 1293195945Sjamie (const char *haystack, const char *needle) throw ()); 1294195945Sjamie# elif __GLIBC__ >= 2 1295192895Sjamie_GL_CXXALIASWARN (strstr); 1296195974Sjamie# endif 1297195974Sjamie#elif defined GNULIB_POSIXCHECK 1298195974Sjamie/* strstr() does not work with multibyte strings if the locale encoding is 1299195974Sjamie different from UTF-8: 1300195974Sjamie POSIX says that it operates on "strings", and "string" in POSIX is defined 1301195974Sjamie as a sequence of bytes, not of characters. */ 1302195974Sjamie# undef strstr 1303195974Sjamie/* Assume strstr is always declared. */ 1304195974Sjamie_GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " 1305195974Sjamie "work correctly on character strings in most " 1306195974Sjamie "multibyte locales - " 1307195974Sjamie "use mbsstr if you care about internationalization, " 1308195974Sjamie "or use strstr if you care about speed"); 1309195974Sjamie#endif 1310192895Sjamie 1311192895Sjamie/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive 1312195974Sjamie comparison. */ 1313195974Sjamie#if 0 1314195974Sjamie# if 0 1315195974Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1316195974Sjamie# define strcasestr rpl_strcasestr 1317195974Sjamie# endif 1318195974Sjamie_GL_FUNCDECL_RPL (strcasestr, char *, 1319195974Sjamie (const char *haystack, const char *needle) 1320195974Sjamie _GL_ATTRIBUTE_PURE 1321195974Sjamie _GL_ARG_NONNULL ((1, 2))); 1322195974Sjamie_GL_CXXALIAS_RPL (strcasestr, char *, 1323195974Sjamie (const char *haystack, const char *needle)); 1324195974Sjamie# else 1325195974Sjamie# if ! 1 1326192895Sjamie_GL_FUNCDECL_SYS (strcasestr, char *, 1327195945Sjamie (const char *haystack, const char *needle) 1328195945Sjamie _GL_ATTRIBUTE_PURE 1329202468Sbz _GL_ARG_NONNULL ((1, 2))); 1330202468Sbz# endif 1331202468Sbz /* On some systems, this function is defined as an overloaded function: 1332192895Sjamie extern "C++" { const char * strcasestr (const char *, const char *); } 1333192895Sjamie extern "C++" { char * strcasestr (char *, const char *); } */ 1334196002Sjamie_GL_CXXALIAS_SYS_CAST2 (strcasestr, 1335232059Smm char *, (const char *haystack, const char *needle), 1336191673Sjamie const char *, (const char *haystack, const char *needle)); 1337280632Sian# endif 1338280632Sian# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1339280632Sian && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \ 1340280632Sian || defined __clang__) 1341280632Sian_GL_CXXALIASWARN1 (strcasestr, char *, 1342280632Sian (char *haystack, const char *needle) throw ()); 1343192895Sjamie_GL_CXXALIASWARN1 (strcasestr, const char *, 1344192895Sjamie (const char *haystack, const char *needle) throw ()); 1345298833Sjamie# else 1346191673Sjamie_GL_CXXALIASWARN (strcasestr); 1347194251Sjamie# endif 1348194251Sjamie#elif defined GNULIB_POSIXCHECK 1349194251Sjamie/* strcasestr() does not work with multibyte strings: 1350194251Sjamie It is a glibc extension, and glibc implements it only for unibyte 1351194251Sjamie locales. */ 1352185435Sbz# undef strcasestr 1353191673Sjamie# if HAVE_RAW_DECL_STRCASESTR 1354191673Sjamie_GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character " 1355185435Sbz "strings in multibyte locales - " 1356192895Sjamie "use mbscasestr if you care about " 1357191673Sjamie "internationalization, or use c-strcasestr if you want " 1358191673Sjamie "a locale independent function"); 1359191673Sjamie# endif 1360191673Sjamie#endif 1361185435Sbz 1362191673Sjamie/* Parse S into tokens separated by characters in DELIM. 1363185435Sbz If S is NULL, the saved pointer in SAVE_PTR is used as 1364191673Sjamie the next starting point. For example: 1365298833Sjamie char s[] = "-abc-=-def"; 1366191673Sjamie char *sp; 1367185435Sbz x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" 1368191673Sjamie x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL 1369191673Sjamie x = strtok_r(NULL, "=", &sp); // x = NULL 1370195974Sjamie // s = "abc\0-def\0" 1371195974Sjamie 1372195974Sjamie This is a variant of strtok() that is multithread-safe. 1373195974Sjamie 1374195974Sjamie For the POSIX documentation for this function, see: 1375195945Sjamie https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html 1376195945Sjamie 1377195945Sjamie Caveat: It modifies the original string. 1378195945Sjamie Caveat: These functions cannot be used on constant strings. 1379195945Sjamie Caveat: The identity of the delimiting character is lost. 1380195945Sjamie Caveat: It doesn't work with multibyte strings unless all of the delimiter 1381195945Sjamie characters are ASCII characters < 0x30. 1382195945Sjamie 1383195945Sjamie See also strsep(). */ 1384195974Sjamie#if 1 1385195974Sjamie# if 0 1386195974Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1387195974Sjamie# undef strtok_r 1388195974Sjamie# define strtok_r rpl_strtok_r 1389195974Sjamie# endif 1390195974Sjamie_GL_FUNCDECL_RPL (strtok_r, char *, 1391195974Sjamie (char *restrict s, char const *restrict delim, 1392195974Sjamie char **restrict save_ptr) 1393195974Sjamie _GL_ARG_NONNULL ((2, 3))); 1394195974Sjamie_GL_CXXALIAS_RPL (strtok_r, char *, 1395195974Sjamie (char *restrict s, char const *restrict delim, 1396195974Sjamie char **restrict save_ptr)); 1397195974Sjamie# else 1398195974Sjamie# if 0 || defined GNULIB_POSIXCHECK 1399195974Sjamie# undef strtok_r 1400191673Sjamie# endif 1401185435Sbz# if ! 1 1402191673Sjamie_GL_FUNCDECL_SYS (strtok_r, char *, 1403192895Sjamie (char *restrict s, char const *restrict delim, 1404192895Sjamie char **restrict save_ptr) 1405192895Sjamie _GL_ARG_NONNULL ((2, 3))); 1406192895Sjamie# endif 1407192895Sjamie_GL_CXXALIAS_SYS (strtok_r, char *, 1408192895Sjamie (char *restrict s, char const *restrict delim, 1409194762Sjamie char **restrict save_ptr)); 1410194762Sjamie# endif 1411194762Sjamie_GL_CXXALIASWARN (strtok_r); 1412194762Sjamie# if defined GNULIB_POSIXCHECK 1413194762Sjamie_GL_WARN_ON_USE (strtok_r, "strtok_r cannot work correctly on character " 1414194762Sjamie "strings in multibyte locales - " 1415192895Sjamie "use mbstok_r if you care about internationalization"); 1416192895Sjamie# endif 1417192895Sjamie#elif defined GNULIB_POSIXCHECK 1418192895Sjamie# undef strtok_r 1419192895Sjamie# if HAVE_RAW_DECL_STRTOK_R 1420192895Sjamie_GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - " 1421231267Smm "use gnulib module strtok_r for portability"); 1422231267Smm# endif 1423231267Smm#endif 1424231267Smm 1425232059Smm 1426231267Smm/* The following functions are not specified by POSIX. They are gnulib 1427231267Smm extensions. */ 1428231267Smm 1429231267Smm#if 0 1430232059Smm/* Return the number of multibyte characters in the character string STRING. 1431231267Smm This considers multibyte characters, unlike strlen, which counts bytes. */ 1432231267Smm# ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */ 1433231267Smm# undef mbslen 1434231267Smm# endif 1435231267Smm# if 0 /* AIX, OSF/1, MirBSD define mbslen already in libc. */ 1436232059Smm# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1437231267Smm# define mbslen rpl_mbslen 1438231267Smm# endif 1439231267Smm_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) 1440185435Sbz _GL_ATTRIBUTE_PURE 1441195974Sjamie _GL_ARG_NONNULL ((1))); 1442192895Sjamie_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); 1443195974Sjamie# else 1444195974Sjamie_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) 1445195974Sjamie _GL_ATTRIBUTE_PURE 1446195974Sjamie _GL_ARG_NONNULL ((1))); 1447195974Sjamie_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); 1448195974Sjamie# endif 1449195974Sjamie_GL_CXXALIASWARN (mbslen); 1450195974Sjamie#endif 1451195974Sjamie 1452195974Sjamie#if 0 1453195974Sjamie/* Return the number of multibyte characters in the character string starting 1454195974Sjamie at STRING and ending at STRING + LEN. */ 1455195974Sjamie_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) 1456195974Sjamie _GL_ATTRIBUTE_PURE 1457195974Sjamie _GL_ARG_NONNULL ((1)); 1458195974Sjamie#endif 1459195974Sjamie 1460195974Sjamie#if 0 1461195974Sjamie/* Locate the first single-byte character C in the character string STRING, 1462195974Sjamie and return a pointer to it. Return NULL if C is not found in STRING. 1463195974Sjamie Unlike strchr(), this function works correctly in multibyte locales with 1464195974Sjamie encodings such as GB18030. */ 1465195974Sjamie# if defined __hpux 1466195974Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1467192895Sjamie# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ 1468192895Sjamie# endif 1469192895Sjamie_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) 1470192895Sjamie _GL_ATTRIBUTE_PURE 1471192895Sjamie _GL_ARG_NONNULL ((1))); 1472192895Sjamie_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); 1473192895Sjamie# else 1474195974Sjamie_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) 1475195974Sjamie _GL_ATTRIBUTE_PURE 1476195974Sjamie _GL_ARG_NONNULL ((1))); 1477195974Sjamie_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); 1478195974Sjamie# endif 1479195974Sjamie_GL_CXXALIASWARN (mbschr); 1480195974Sjamie#endif 1481195945Sjamie 1482195974Sjamie#if 0 1483195974Sjamie/* Locate the last single-byte character C in the character string STRING, 1484195974Sjamie and return a pointer to it. Return NULL if C is not found in STRING. 1485195945Sjamie Unlike strrchr(), this function works correctly in multibyte locales with 1486195974Sjamie encodings such as GB18030. */ 1487195974Sjamie# if defined __hpux || defined __INTERIX 1488195945Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1489195974Sjamie# define mbsrchr rpl_mbsrchr /* avoid collision with system function */ 1490195945Sjamie# endif 1491195974Sjamie_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) 1492192895Sjamie _GL_ATTRIBUTE_PURE 1493195974Sjamie _GL_ARG_NONNULL ((1))); 1494195974Sjamie_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); 1495195974Sjamie# else 1496195974Sjamie_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) 1497195974Sjamie _GL_ATTRIBUTE_PURE 1498195974Sjamie _GL_ARG_NONNULL ((1))); 1499195974Sjamie_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); 1500195974Sjamie# endif 1501195974Sjamie_GL_CXXALIASWARN (mbsrchr); 1502195974Sjamie#endif 1503195974Sjamie 1504195974Sjamie#if 0 1505195974Sjamie/* Find the first occurrence of the character string NEEDLE in the character 1506195974Sjamie string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK. 1507192895Sjamie Unlike strstr(), this function works correctly in multibyte locales with 1508192895Sjamie encodings different from UTF-8. */ 1509192895Sjamie_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) 1510192895Sjamie _GL_ATTRIBUTE_PURE 1511185435Sbz _GL_ARG_NONNULL ((1, 2)); 1512191673Sjamie#endif 1513195974Sjamie 1514192895Sjamie#if 0 1515195974Sjamie/* Compare the character strings S1 and S2, ignoring case, returning less than, 1516195974Sjamie equal to or greater than zero if S1 is lexicographically less than, equal to 1517195974Sjamie or greater than S2. 1518195974Sjamie Note: This function may, in multibyte locales, return 0 for strings of 1519195974Sjamie different lengths! 1520195974Sjamie Unlike strcasecmp(), this function works correctly in multibyte locales. */ 1521195974Sjamie_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) 1522195974Sjamie _GL_ATTRIBUTE_PURE 1523195974Sjamie _GL_ARG_NONNULL ((1, 2)); 1524195974Sjamie#endif 1525195974Sjamie 1526195974Sjamie#if 0 1527195974Sjamie/* Compare the initial segment of the character string S1 consisting of at most 1528195974Sjamie N characters with the initial segment of the character string S2 consisting 1529195974Sjamie of at most N characters, ignoring case, returning less than, equal to or 1530195974Sjamie greater than zero if the initial segment of S1 is lexicographically less 1531195974Sjamie than, equal to or greater than the initial segment of S2. 1532195974Sjamie Note: This function may, in multibyte locales, return 0 for initial segments 1533195974Sjamie of different lengths! 1534195974Sjamie Unlike strncasecmp(), this function works correctly in multibyte locales. 1535195974Sjamie But beware that N is not a byte count but a character count! */ 1536195974Sjamie_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) 1537195974Sjamie _GL_ATTRIBUTE_PURE 1538192895Sjamie _GL_ARG_NONNULL ((1, 2)); 1539192895Sjamie#endif 1540192895Sjamie 1541192895Sjamie#if 0 1542192895Sjamie/* Compare the initial segment of the character string STRING consisting of 1543192895Sjamie at most mbslen (PREFIX) characters with the character string PREFIX, 1544192895Sjamie ignoring case. If the two match, return a pointer to the first byte 1545195974Sjamie after this prefix in STRING. Otherwise, return NULL. 1546195974Sjamie Note: This function may, in multibyte locales, return non-NULL if STRING 1547195945Sjamie is of smaller length than PREFIX! 1548195974Sjamie Unlike strncasecmp(), this function works correctly in multibyte 1549195974Sjamie locales. */ 1550195974Sjamie_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) 1551195945Sjamie _GL_ATTRIBUTE_PURE 1552195974Sjamie _GL_ARG_NONNULL ((1, 2)); 1553195974Sjamie#endif 1554195945Sjamie 1555195974Sjamie#if 0 1556195945Sjamie/* Find the first occurrence of the character string NEEDLE in the character 1557195974Sjamie string HAYSTACK, using case-insensitive comparison. 1558192895Sjamie Note: This function may, in multibyte locales, return success even if 1559195974Sjamie strlen (haystack) < strlen (needle) ! 1560195974Sjamie Unlike strcasestr(), this function works correctly in multibyte locales. */ 1561195974Sjamie_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) 1562195974Sjamie _GL_ATTRIBUTE_PURE 1563195974Sjamie _GL_ARG_NONNULL ((1, 2)); 1564195974Sjamie#endif 1565195974Sjamie 1566195974Sjamie#if 0 1567195974Sjamie/* Find the first occurrence in the character string STRING of any character 1568195974Sjamie in the character string ACCEPT. Return the number of bytes from the 1569195974Sjamie beginning of the string to this occurrence, or to the end of the string 1570195974Sjamie if none exists. 1571195974Sjamie Unlike strcspn(), this function works correctly in multibyte locales. */ 1572195974Sjamie_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) 1573192895Sjamie _GL_ATTRIBUTE_PURE 1574192895Sjamie _GL_ARG_NONNULL ((1, 2)); 1575191673Sjamie#endif 1576192895Sjamie 1577191673Sjamie#if 0 1578192895Sjamie/* Find the first occurrence in the character string STRING of any character 1579298833Sjamie in the character string ACCEPT. Return the pointer to it, or NULL if none 1580292416Sjamie exists. 1581292416Sjamie Unlike strpbrk(), this function works correctly in multibyte locales. */ 1582292416Sjamie# if defined __hpux 1583292416Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1584298833Sjamie# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ 1585298833Sjamie# endif 1586292416Sjamie_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) 1587292416Sjamie _GL_ATTRIBUTE_PURE 1588191673Sjamie _GL_ARG_NONNULL ((1, 2))); 1589196835Sjamie_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); 1590196835Sjamie# else 1591192895Sjamie_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) 1592191673Sjamie _GL_ATTRIBUTE_PURE 1593191673Sjamie _GL_ARG_NONNULL ((1, 2))); 1594192895Sjamie_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); 1595192895Sjamie# endif 1596191673Sjamie_GL_CXXALIASWARN (mbspbrk); 1597298833Sjamie#endif 1598298833Sjamie 1599298833Sjamie#if 0 1600298833Sjamie/* Find the first occurrence in the character string STRING of any character 1601192895Sjamie not in the character string REJECT. Return the number of bytes from the 1602192895Sjamie beginning of the string to this occurrence, or to the end of the string 1603192895Sjamie if none exists. 1604192895Sjamie Unlike strspn(), this function works correctly in multibyte locales. */ 1605192895Sjamie_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) 1606192895Sjamie _GL_ATTRIBUTE_PURE 1607192895Sjamie _GL_ARG_NONNULL ((1, 2)); 1608192895Sjamie#endif 1609192895Sjamie 1610192895Sjamie#if 0 1611191673Sjamie/* Search the next delimiter (multibyte character listed in the character 1612192895Sjamie string DELIM) starting at the character string *STRINGP. 1613192895Sjamie If one is found, overwrite it with a NUL, and advance *STRINGP to point 1614192895Sjamie to the next multibyte character after it. Otherwise, set *STRINGP to NULL. 1615192895Sjamie If *STRINGP was already NULL, nothing happens. 1616185435Sbz Return the old value of *STRINGP. 1617298833Sjamie 1618298833Sjamie This is a variant of mbstok_r() that supports empty fields. 1619298833Sjamie 1620298833Sjamie Caveat: It modifies the original string. 1621298833Sjamie Caveat: These functions cannot be used on constant strings. 1622298833Sjamie Caveat: The identity of the delimiting character is lost. 1623298833Sjamie 1624298833Sjamie See also mbstok_r(). */ 1625298833Sjamie_GL_EXTERN_C char * mbssep (char **stringp, const char *delim) 1626298833Sjamie _GL_ARG_NONNULL ((1, 2)); 1627298833Sjamie#endif 1628298833Sjamie 1629298833Sjamie#if 0 1630298833Sjamie/* Parse the character string STRING into tokens separated by characters in 1631298833Sjamie the character string DELIM. 1632298833Sjamie If STRING is NULL, the saved pointer in SAVE_PTR is used as 1633298833Sjamie the next starting point. For example: 1634298833Sjamie char s[] = "-abc-=-def"; 1635298833Sjamie char *sp; 1636298833Sjamie x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def" 1637298833Sjamie x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL 1638298833Sjamie x = mbstok_r(NULL, "=", &sp); // x = NULL 1639298833Sjamie // s = "abc\0-def\0" 1640298833Sjamie 1641191673Sjamie Caveat: It modifies the original string. 1642191673Sjamie Caveat: These functions cannot be used on constant strings. 1643192895Sjamie Caveat: The identity of the delimiting character is lost. 1644195974Sjamie 1645195974Sjamie See also mbssep(). */ 1646195974Sjamie_GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim, 1647195974Sjamie char **save_ptr) 1648195974Sjamie _GL_ARG_NONNULL ((2, 3)); 1649195974Sjamie#endif 1650192895Sjamie 1651195945Sjamie/* Map any int, typically from errno, into an error message. */ 1652195945Sjamie#if 1 1653195945Sjamie# if 1 1654195945Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1655195945Sjamie# undef strerror 1656195945Sjamie# define strerror rpl_strerror 1657192895Sjamie# endif 1658192895Sjamie_GL_FUNCDECL_RPL (strerror, char *, (int)); 1659192895Sjamie_GL_CXXALIAS_RPL (strerror, char *, (int)); 1660192895Sjamie# else 1661192895Sjamie_GL_CXXALIAS_SYS (strerror, char *, (int)); 1662185435Sbz# endif 1663191673Sjamie# if __GLIBC__ >= 2 1664191673Sjamie_GL_CXXALIASWARN (strerror); 1665192895Sjamie# endif 1666195974Sjamie#elif defined GNULIB_POSIXCHECK 1667195974Sjamie# undef strerror 1668195974Sjamie/* Assume strerror is always declared. */ 1669195974Sjamie_GL_WARN_ON_USE (strerror, "strerror is unportable - " 1670195974Sjamie "use gnulib module strerror to guarantee non-NULL result"); 1671195974Sjamie#endif 1672192895Sjamie 1673195945Sjamie/* Map any int, typically from errno, into an error message. Multithread-safe. 1674195945Sjamie Uses the POSIX declaration, not the glibc declaration. */ 1675195945Sjamie#if 1 1676195945Sjamie# if 1 1677195945Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1678195945Sjamie# undef strerror_r 1679192895Sjamie# define strerror_r rpl_strerror_r 1680192895Sjamie# endif 1681192895Sjamie_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) 1682192895Sjamie _GL_ARG_NONNULL ((2))); 1683192895Sjamie_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); 1684191673Sjamie# else 1685191673Sjamie# if !1 1686192895Sjamie_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) 1687191673Sjamie _GL_ARG_NONNULL ((2))); 1688192895Sjamie# endif 1689192895Sjamie_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); 1690192895Sjamie# endif 1691192895Sjamie# if 1 1692192895Sjamie_GL_CXXALIASWARN (strerror_r); 1693194762Sjamie# endif 1694194762Sjamie#elif defined GNULIB_POSIXCHECK 1695194762Sjamie# undef strerror_r 1696194762Sjamie# if HAVE_RAW_DECL_STRERROR_R 1697194762Sjamie_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " 1698194762Sjamie "use gnulib module strerror_r-posix for portability"); 1699194762Sjamie# endif 1700194762Sjamie#endif 1701192895Sjamie 1702192895Sjamie/* Return the name of the system error code ERRNUM. */ 1703192895Sjamie#if 0 1704192895Sjamie# if 0 1705192895Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1706192895Sjamie# undef strerrorname_np 1707192895Sjamie# define strerrorname_np rpl_strerrorname_np 1708231267Smm# endif 1709231267Smm_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum)); 1710231267Smm_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum)); 1711231267Smm# else 1712232059Smm# if !1 1713231267Smm_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum)); 1714298833Sjamie# endif 1715192895Sjamie_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum)); 1716298833Sjamie# endif 1717192895Sjamie_GL_CXXALIASWARN (strerrorname_np); 1718192895Sjamie#elif defined GNULIB_POSIXCHECK 1719298833Sjamie# undef strerrorname_np 1720192895Sjamie# if HAVE_RAW_DECL_STRERRORNAME_NP 1721192895Sjamie_GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - " 1722192895Sjamie "use gnulib module strerrorname_np for portability"); 1723192895Sjamie# endif 1724192895Sjamie#endif 1725192895Sjamie 1726192895Sjamie/* Return an abbreviation string for the signal number SIG. */ 1727191673Sjamie#if 0 1728192895Sjamie# if ! 1 1729230129Smm_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig)); 1730230129Smm# endif 1731192895Sjamie_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig)); 1732192895Sjamie_GL_CXXALIASWARN (sigabbrev_np); 1733192895Sjamie#elif defined GNULIB_POSIXCHECK 1734192895Sjamie# undef sigabbrev_np 1735191673Sjamie# if HAVE_RAW_DECL_SIGABBREV_NP 1736191673Sjamie_GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - " 1737193066Sjamie "use gnulib module sigabbrev_np for portability"); 1738193066Sjamie# endif 1739193066Sjamie#endif 1740193066Sjamie 1741193066Sjamie/* Return an English description string for the signal number SIG. */ 1742193066Sjamie#if 0 1743193066Sjamie# if ! 1 1744193066Sjamie_GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig)); 1745194118Sjamie# endif 1746194118Sjamie_GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig)); 1747194118Sjamie_GL_CXXALIASWARN (sigdescr_np); 1748194118Sjamie#elif defined GNULIB_POSIXCHECK 1749194118Sjamie# undef sigdescr_np 1750194118Sjamie# if HAVE_RAW_DECL_SIGDESCR_NP 1751193066Sjamie_GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - " 1752193066Sjamie "use gnulib module sigdescr_np for portability"); 1753193066Sjamie# endif 1754193066Sjamie#endif 1755193066Sjamie 1756194118Sjamie#if 0 1757193066Sjamie# if 0 1758194118Sjamie# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1759194118Sjamie# define strsignal rpl_strsignal 1760193066Sjamie# endif 1761194118Sjamie_GL_FUNCDECL_RPL (strsignal, char *, (int __sig)); 1762193066Sjamie_GL_CXXALIAS_RPL (strsignal, char *, (int __sig)); 1763193066Sjamie# else 1764193066Sjamie# if ! 1 1765193066Sjamie_GL_FUNCDECL_SYS (strsignal, char *, (int __sig)); 1766193066Sjamie# endif 1767193066Sjamie/* Need to cast, because on Cygwin 1.5.x systems, the return type is 1768193066Sjamie 'const char *'. */ 1769194118Sjamie_GL_CXXALIAS_SYS_CAST (strsignal, char *, (int __sig)); 1770194118Sjamie# endif 1771194118Sjamie_GL_CXXALIASWARN (strsignal); 1772193066Sjamie#elif defined GNULIB_POSIXCHECK 1773194118Sjamie# undef strsignal 1774194118Sjamie# if HAVE_RAW_DECL_STRSIGNAL 1775194118Sjamie_GL_WARN_ON_USE (strsignal, "strsignal is unportable - " 1776193066Sjamie "use gnulib module strsignal for portability"); 1777194118Sjamie# endif 1778194118Sjamie#endif 1779194118Sjamie 1780193066Sjamie#if 0 1781193066Sjamie# if !1 1782193066Sjamie_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) 1783193066Sjamie _GL_ATTRIBUTE_PURE 1784193066Sjamie _GL_ARG_NONNULL ((1, 2))); 1785192895Sjamie# endif 1786192895Sjamie_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); 1787192895Sjamie_GL_CXXALIASWARN (strverscmp); 1788192895Sjamie#elif defined GNULIB_POSIXCHECK 1789192895Sjamie# undef strverscmp 1790192895Sjamie# if HAVE_RAW_DECL_STRVERSCMP 1791191673Sjamie_GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - " 1792191673Sjamie "use gnulib module strverscmp for portability"); 1793191673Sjamie# endif 1794191673Sjamie#endif 1795191673Sjamie 1796191673Sjamie 1797298833Sjamie#endif /* _GL_STRING_H */ 1798191673Sjamie#endif /* _GL_STRING_H */ 1799191673Sjamie#endif 1800191673Sjamie