Re: [PATCH v3] libcpp: add function to check XID properties

2024-01-04 Thread Arthur Cohen

Hi Joseph,

Thanks for the review!

On 12/18/23 20:00, Joseph Myers wrote:

On Fri, 8 Sep 2023, Arthur Cohen wrote:


+  if (c < 0x80)
+  {
+if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z'))
+  return CPP_XID_START | CPP_XID_CONTINUE;
+if (('0' <= c && c <= '9') || c == '_')
+  return CPP_XID_CONTINUE;


This may be an artifact of how the patch was mailed, but indentation seems
off here (should be six spaces for both return statements) >

+  md = (mn + mx) / 2;
+  if (c <= ucnranges[md].end)
+  mx = md;
+  else
+  mn = md + 1;


And likewise here (should be a tab for both assignments).

OK with those indentation fixes.




Thanks for noticing - this was indeed misindented.

I'll make the suggested fixes and will push the patch.

Best,

Arthur



[COMMITTED] libcpp: add function to check XID properties

2024-01-04 Thread Arthur Cohen
From: Raiki Tamura 

This commit adds a new function intended for checking the XID properties
of a possibly unicode character, as well as the accompanying enum
describing the possible properties.

libcpp/ChangeLog:

* charset.cc (cpp_check_xid_property): New.
* include/cpplib.h
(cpp_check_xid_property): New.
(enum cpp_xid_property): New.

Signed-off-by: Raiki Tamura 
---
 libcpp/charset.cc   | 36 
 libcpp/include/cpplib.h |  7 +++
 2 files changed, 43 insertions(+)

diff --git a/libcpp/charset.cc b/libcpp/charset.cc
index 95ca381eb7b..54d7b9e0932 100644
--- a/libcpp/charset.cc
+++ b/libcpp/charset.cc
@@ -1332,6 +1332,42 @@ _cpp_uname2c_uax44_lm2 (const char *name, size_t len, 
char *canon_name)
   return result;
 }
 
+/* Returns flags representing the XID properties of the given codepoint.  */
+unsigned int
+cpp_check_xid_property (cppchar_t c)
+{
+  // fast path for ASCII
+  if (c < 0x80)
+{
+  if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z'))
+   return CPP_XID_START | CPP_XID_CONTINUE;
+  if (('0' <= c && c <= '9') || c == '_')
+   return CPP_XID_CONTINUE;
+}
+
+  if (c > UCS_LIMIT)
+return 0;
+
+  int mn, mx, md;
+  mn = 0;
+  mx = ARRAY_SIZE (ucnranges) - 1;
+  while (mx != mn)
+{
+  md = (mn + mx) / 2;
+  if (c <= ucnranges[md].end)
+   mx = md;
+  else
+   mn = md + 1;
+}
+
+  unsigned short flags = ucnranges[mn].flags;
+
+  if (flags & CXX23)
+return CPP_XID_START | CPP_XID_CONTINUE;
+  if (flags & NXX23)
+return CPP_XID_CONTINUE;
+  return 0;
+}
 
 /* Returns 1 if C is valid in an identifier, 2 if C is valid except at
the start of an identifier, and 0 if C is not valid in an
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index f699daaeb64..5746aac9ea4 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -1631,4 +1631,11 @@ bool cpp_valid_utf8_p (const char *data, size_t 
num_bytes);
 bool cpp_is_combining_char (cppchar_t c);
 bool cpp_is_printable_char (cppchar_t c);
 
+enum cpp_xid_property {
+  CPP_XID_START = 1,
+  CPP_XID_CONTINUE = 2
+};
+
+unsigned int cpp_check_xid_property (cppchar_t c);
+
 #endif /* ! LIBCPP_CPPLIB_H */
-- 
2.42.1

P.S.: Note that the requested formatting changes have been adressed -
I'm not sure why the patch is formatted this way.

Best,

Arthur


Re: libgrust: 'AM_ENABLE_MULTILIB' only for target builds [PR113056]

2024-01-04 Thread Pierre-Emmanuel Patry

Hello Thomas,

On 12/18/23 17:58, Thomas Schwinge wrote:


--- a/libgrust/configure.ac
+++ b/libgrust/configure.ac



-# AM_ENABLE_MULTILIB(, ..)
+AM_ENABLE_MULTILIB(, ..)


Such a change was applied eventually, and is necessary for target builds
-- but potentially harmful for host builds.  OK to push the attached
"libgrust: 'AM_ENABLE_MULTILIB' only for target builds [PR113056]"?


These changes make sense, I'm fine with those being pushed.

Regards,


--
Patry Pierre-Emmanuel
Compiler Engineer - Embecosm


OpenPGP_0xD006124B2A7AEA23.asc
Description: OpenPGP public key


OpenPGP_signature.asc
Description: OpenPGP digital signature