unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] wcsmbs: Avoid escaped character literals in <wchar.h>
@ 2020-02-17 10:57 Florian Weimer
  2020-02-17 11:57 ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2020-02-17 10:57 UTC (permalink / raw)
  To: libc-alpha

They confuse scripts/conformtest.py because it treats the L and the
x7f as namespace-violating identifiers.

These failures are only visibile if the conform tests are run in such
a way that __USE_EXTERN_INLINES is defined.

-----
 wcsmbs/wchar.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index 5e0d65b14e..3e88be1f16 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -316,13 +316,13 @@ extern size_t mbrlen (const char *__restrict __s, size_t __n,
 extern wint_t __btowc_alias (int __c) __asm ("btowc");
 __extern_inline wint_t
 __NTH (btowc (int __c))
-{ return (__builtin_constant_p (__c) && __c >= '\0' && __c <= '\x7f'
+{ return (__builtin_constant_p (__c) && __c >= 0 && __c <= 0x7f
 	  ? (wint_t) __c : __btowc_alias (__c)); }
 
 extern int __wctob_alias (wint_t __c) __asm ("wctob");
 __extern_inline int
 __NTH (wctob (wint_t __wc))
-{ return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f'
+{ return (__builtin_constant_p (__wc) && __wc >= 0 && __wc <= 0x7f
 	  ? (int) __wc : __wctob_alias (__wc)); }
 
 __extern_inline size_t


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] wcsmbs: Avoid escaped character literals in <wchar.h>
  2020-02-17 10:57 [PATCH] wcsmbs: Avoid escaped character literals in <wchar.h> Florian Weimer
@ 2020-02-17 11:57 ` Andreas Schwab
  2020-02-17 12:47   ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2020-02-17 11:57 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Feb 17 2020, Florian Weimer wrote:

> They confuse scripts/conformtest.py because it treats the L and the

s/scripts/conform/

> x7f as namespace-violating identifiers.

Can the script be fixed not to do that?

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] wcsmbs: Avoid escaped character literals in <wchar.h>
  2020-02-17 11:57 ` Andreas Schwab
@ 2020-02-17 12:47   ` Florian Weimer
  2020-02-17 16:06     ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2020-02-17 12:47 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

* Andreas Schwab:

> On Feb 17 2020, Florian Weimer wrote:
>
>> They confuse scripts/conformtest.py because it treats the L and the
>
> s/scripts/conform/
>
>> x7f as namespace-violating identifiers.
>
> Can the script be fixed not to do that?

Like this?

A more elaborate alternative would be to use Zack's C tokenizer in the
conform tests, but I don't know if its feature set is aligned with
what we need in the conform tests.

Subject: Add wide and character literal support to conform/conformtest.py

Without this change, tokens such as L'x7f' are reconginzed as a
identifiers L, x7f, which are not in the implementation namespace and
therefore trigger failures.

diff --git a/conform/conformtest.py b/conform/conformtest.py
index 951e3b2420..3bdc2a8e57 100644
--- a/conform/conformtest.py
+++ b/conform/conformtest.py
@@ -638,7 +638,7 @@ class HeaderTests(object):
                 # constants, and hex floats may be wrongly split into
                 # tokens including identifiers, but this is sufficient
                 # in practice and matches the old perl script.
-                line = re.sub(r'"[^"]*"', '', line)
+                line = re.sub(r'(?:\bL)?(?:"[^"]*"|\'[^\']*\')', '', line)
                 line = line.strip()
                 for token in re.split(r'[^A-Za-z0-9_]+', line):
                     if re.match(r'[A-Za-z_]', token):

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] wcsmbs: Avoid escaped character literals in <wchar.h>
  2020-02-17 12:47   ` Florian Weimer
@ 2020-02-17 16:06     ` Andreas Schwab
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2020-02-17 16:06 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Feb 17 2020, Florian Weimer wrote:

> Subject: Add wide and character literal support to conform/conformtest.py
>
> Without this change, tokens such as L'x7f' are reconginzed as a
> identifiers L, x7f, which are not in the implementation namespace and
> therefore trigger failures.
>
> diff --git a/conform/conformtest.py b/conform/conformtest.py
> index 951e3b2420..3bdc2a8e57 100644
> --- a/conform/conformtest.py
> +++ b/conform/conformtest.py
> @@ -638,7 +638,7 @@ class HeaderTests(object):
>                  # constants, and hex floats may be wrongly split into
>                  # tokens including identifiers, but this is sufficient
>                  # in practice and matches the old perl script.
> -                line = re.sub(r'"[^"]*"', '', line)
> +                line = re.sub(r'(?:\bL)?(?:"[^"]*"|\'[^\']*\')', '', line)
>                  line = line.strip()
>                  for token in re.split(r'[^A-Za-z0-9_]+', line):
>                      if re.match(r'[A-Za-z_]', token):

Ok if you update the comment.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-17 16:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17 10:57 [PATCH] wcsmbs: Avoid escaped character literals in <wchar.h> Florian Weimer
2020-02-17 11:57 ` Andreas Schwab
2020-02-17 12:47   ` Florian Weimer
2020-02-17 16:06     ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).