diff mbox series

cpp/remap: Only override if string matched

Message ID 20221020204825.3248771-1-torbjorn.svensson@foss.st.com
State New
Headers show
Series cpp/remap: Only override if string matched | expand

Commit Message

Torbjorn SVENSSON Oct. 20, 2022, 8:48 p.m. UTC
For systems with HAVE_DOS_BASED_FILE_SYSTEM set, only override the
pointer if the backslash pattern matches.

Output without this patch:
.../gcc/testsuite/gcc.dg/cpp/pr71681-2.c:5:10: fatal error: a/t2.h: No such file or directory

With patch applied, no output and the test case succeeds.

libcpp/ChangeLog

	* files.cc: Ensure pattern matches before use.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
 libcpp/files.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Torbjorn SVENSSON Nov. 2, 2022, 6:21 p.m. UTC | #1
Hi,

Ping, https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604062.html

Ok for trunk?

Kind regards,
Torbjörn

On 2022-10-20 22:48, Torbjörn SVENSSON wrote:
> For systems with HAVE_DOS_BASED_FILE_SYSTEM set, only override the
> pointer if the backslash pattern matches.
> 
> Output without this patch:
> .../gcc/testsuite/gcc.dg/cpp/pr71681-2.c:5:10: fatal error: a/t2.h: No such file or directory
> 
> With patch applied, no output and the test case succeeds.
> 
> libcpp/ChangeLog
> 
> 	* files.cc: Ensure pattern matches before use.
> 
> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
> ---
>   libcpp/files.cc | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libcpp/files.cc b/libcpp/files.cc
> index 24208f7b0f8..a18b1caf48d 100644
> --- a/libcpp/files.cc
> +++ b/libcpp/files.cc
> @@ -1833,7 +1833,7 @@ remap_filename (cpp_reader *pfile, _cpp_file *file)
>   #ifdef HAVE_DOS_BASED_FILE_SYSTEM
>         {
>   	const char *p2 = strchr (fname, '\\');
> -	if (!p || (p > p2))
> +	if (!p || (p2 && p > p2))
>   	  p = p2;
>         }
>   #endif
Torbjorn SVENSSON Nov. 17, 2022, 4:44 p.m. UTC | #2
Hi,

Ping, https://gcc.gnu.org/pipermail/gcc-patches/2022-November/604898.html

Ok for trunk?

Kind regards,
Torbjörn

On 2022-11-02 19:21, Torbjorn SVENSSON wrote:
> Hi,
> 
> Ping, https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604062.html
> 
> Ok for trunk?
> 
> Kind regards,
> Torbjörn
> 
> On 2022-10-20 22:48, Torbjörn SVENSSON wrote:
>> For systems with HAVE_DOS_BASED_FILE_SYSTEM set, only override the
>> pointer if the backslash pattern matches.
>>
>> Output without this patch:
>> .../gcc/testsuite/gcc.dg/cpp/pr71681-2.c:5:10: fatal error: a/t2.h: No 
>> such file or directory
>>
>> With patch applied, no output and the test case succeeds.
>>
>> libcpp/ChangeLog
>>
>>     * files.cc: Ensure pattern matches before use.
>>
>> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
>> ---
>>   libcpp/files.cc | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libcpp/files.cc b/libcpp/files.cc
>> index 24208f7b0f8..a18b1caf48d 100644
>> --- a/libcpp/files.cc
>> +++ b/libcpp/files.cc
>> @@ -1833,7 +1833,7 @@ remap_filename (cpp_reader *pfile, _cpp_file *file)
>>   #ifdef HAVE_DOS_BASED_FILE_SYSTEM
>>         {
>>       const char *p2 = strchr (fname, '\\');
>> -    if (!p || (p > p2))
>> +    if (!p || (p2 && p > p2))
>>         p = p2;
>>         }
>>   #endif
Jeff Law Nov. 20, 2022, 8:31 p.m. UTC | #3
On 11/2/22 12:21, Torbjorn SVENSSON via Gcc-patches wrote:
> Hi,
>
> Ping, https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604062.html
>
> Ok for trunk?

OK.  Sorry for the delay.

jeff
Torbjorn SVENSSON Nov. 21, 2022, 12:38 p.m. UTC | #4
Hi,

On 2022-11-20 21:31, Jeff Law wrote:
> 
> On 11/2/22 12:21, Torbjorn SVENSSON via Gcc-patches wrote:
>> Hi,
>>
>> Ping, https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604062.html
>>
>> Ok for trunk?
> 
> OK.  Sorry for the delay.

Thanks for the review.
Pushed.

Kind regards,
Torbjörn

> 
> jeff
> 
>
diff mbox series

Patch

diff --git a/libcpp/files.cc b/libcpp/files.cc
index 24208f7b0f8..a18b1caf48d 100644
--- a/libcpp/files.cc
+++ b/libcpp/files.cc
@@ -1833,7 +1833,7 @@  remap_filename (cpp_reader *pfile, _cpp_file *file)
 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
       {
 	const char *p2 = strchr (fname, '\\');
-	if (!p || (p > p2))
+	if (!p || (p2 && p > p2))
 	  p = p2;
       }
 #endif