xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/c-support.h (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
17f2ac410Schristos /* Helper routines for C support in GDB.
2*6881a400Schristos    Copyright (C) 2017-2023 Free Software Foundation, Inc.
37f2ac410Schristos 
47f2ac410Schristos    This file is part of GDB.
57f2ac410Schristos 
67f2ac410Schristos    This program is free software; you can redistribute it and/or modify
77f2ac410Schristos    it under the terms of the GNU General Public License as published by
87f2ac410Schristos    the Free Software Foundation; either version 3 of the License, or
97f2ac410Schristos    (at your option) any later version.
107f2ac410Schristos 
117f2ac410Schristos    This program is distributed in the hope that it will be useful,
127f2ac410Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
137f2ac410Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
147f2ac410Schristos    GNU General Public License for more details.
157f2ac410Schristos 
167f2ac410Schristos    You should have received a copy of the GNU General Public License
177f2ac410Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
187f2ac410Schristos 
197f2ac410Schristos #ifndef C_SUPPORT_H
207f2ac410Schristos #define C_SUPPORT_H
217f2ac410Schristos 
227f2ac410Schristos #include "safe-ctype.h"
237f2ac410Schristos 
247f2ac410Schristos /* Like ISALPHA, but also returns true for the union of all UTF-8
257f2ac410Schristos    multi-byte sequence bytes and non-ASCII characters in
267f2ac410Schristos    extended-ASCII charsets (e.g., Latin1).  I.e., returns true if the
277f2ac410Schristos    high bit is set.  Note that not all UTF-8 ranges are allowed in C++
287f2ac410Schristos    identifiers, but we don't need to be pedantic so for simplicity we
297f2ac410Schristos    ignore that here.  Plus this avoids the complication of actually
307f2ac410Schristos    knowing what was the right encoding.  */
317f2ac410Schristos 
327f2ac410Schristos static inline bool
337f2ac410Schristos c_ident_is_alpha (unsigned char ch)
347f2ac410Schristos {
357f2ac410Schristos   return ISALPHA (ch) || ch >= 0x80;
367f2ac410Schristos }
377f2ac410Schristos 
387f2ac410Schristos /* Similarly, but Like ISALNUM.  */
397f2ac410Schristos 
407f2ac410Schristos static inline bool
417f2ac410Schristos c_ident_is_alnum (unsigned char ch)
427f2ac410Schristos {
437f2ac410Schristos   return ISALNUM (ch) || ch >= 0x80;
447f2ac410Schristos }
457f2ac410Schristos 
467f2ac410Schristos #endif /* C_SUPPORT_H */
47