mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] scripts: socfpga_import_preloader: Translate DOS line endings
@ 2023-06-15 13:55 Ian Abbott
  2023-06-15 15:49 ` Ian Abbott
  2023-06-15 15:57 ` [PATCH v2] " Ian Abbott
  0 siblings, 2 replies; 13+ messages in thread
From: Ian Abbott @ 2023-06-15 13:55 UTC (permalink / raw)
  To: barebox; +Cc: Ian Abbott

If the handoff files were generated on a Windows system, they will have
DOS line endings.  The `indent` program (with the options used by the
script) does a lousy job tidying up those files, leaving ASCII CR
characters embedded in the lines.  This is particularly bad for array
initializers that have one value per line, because they all end up on a
single line with embedded ASCII CR characters between each value.

Add an initial `sed` command to `copy_source()` to match and remove an
ASCII CR character from the end of each input line.

Also output a message before running `unifdef` and fix the spelling of
"paths" in one of the other messages.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
 scripts/socfpga_import_preloader | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
index bd54e1b913..156382009e 100755
--- a/scripts/socfpga_import_preloader
+++ b/scripts/socfpga_import_preloader
@@ -79,6 +79,10 @@ copy_source() {
 
 	cp $src $tgt
 
+	echo "  Translating DOS line endings..."
+	sed -i "s/`echo -e '\r'`$//" $tgt
+
+	echo "  Fixing conditional compilation..."
 	unifdef -D HCX_COMPAT_MODE=1 -D ENABLE_INST_ROM_WRITE=1 $tgt -o $tgt
 
 	echo "	Fixing extern/static keywords..."
@@ -99,7 +103,7 @@ copy_source() {
 	sed -i 's/alt_8/int8_t/g' $tgt
 	sed -i 's/#include "alt_types.h"//g' $tgt
 
-	echo "	Fixing include pathes..."
+	echo "	Fixing include paths..."
 	# Fix include pathes
 	sed -i 's/#include <iocsr_config_cyclone5.h>/#include <mach\/cyclone5-scan-manager.h>/g' $tgt
 	sed -i 's/#include <pinmux_config.h>/#include <common.h>/g' $tgt
-- 
2.39.2




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

* Re: [PATCH] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-15 13:55 [PATCH] scripts: socfpga_import_preloader: Translate DOS line endings Ian Abbott
@ 2023-06-15 15:49 ` Ian Abbott
  2023-06-15 15:57 ` [PATCH v2] " Ian Abbott
  1 sibling, 0 replies; 13+ messages in thread
From: Ian Abbott @ 2023-06-15 15:49 UTC (permalink / raw)
  To: barebox

On 15/06/2023 14:55, Ian Abbott wrote:
> If the handoff files were generated on a Windows system, they will have
> DOS line endings.  The `indent` program (with the options used by the
> script) does a lousy job tidying up those files, leaving ASCII CR
> characters embedded in the lines.  This is particularly bad for array
> initializers that have one value per line, because they all end up on a
> single line with embedded ASCII CR characters between each value.
> 
> Add an initial `sed` command to `copy_source()` to match and remove an
> ASCII CR character from the end of each input line.
> 
> Also output a message before running `unifdef` and fix the spelling of
> "paths" in one of the other messages.
> 
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> ---
>   scripts/socfpga_import_preloader | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
> index bd54e1b913..156382009e 100755
> --- a/scripts/socfpga_import_preloader
> +++ b/scripts/socfpga_import_preloader
> @@ -79,6 +79,10 @@ copy_source() {
>   
>   	cp $src $tgt
>   
> +	echo "  Translating DOS line endings..."
> +	sed -i "s/`echo -e '\r'`$//" $tgt
> +
> +	echo "  Fixing conditional compilation..."
>   	unifdef -D HCX_COMPAT_MODE=1 -D ENABLE_INST_ROM_WRITE=1 $tgt -o $tgt

I got the whitespace wrong in those "echo" commands. They should start 
with a TAB, not two spaces!

I'll send a 'v2' patch shortly.

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-




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

* [PATCH v2] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-15 13:55 [PATCH] scripts: socfpga_import_preloader: Translate DOS line endings Ian Abbott
  2023-06-15 15:49 ` Ian Abbott
@ 2023-06-15 15:57 ` Ian Abbott
  2023-06-16  6:41   ` Sascha Hauer
  2023-06-16 12:31   ` [PATCH v3] " Ian Abbott
  1 sibling, 2 replies; 13+ messages in thread
From: Ian Abbott @ 2023-06-15 15:57 UTC (permalink / raw)
  To: barebox; +Cc: Ian Abbott

If the handoff files were generated on a Windows system, they will have
DOS line endings.  The `indent` program (with the options used by the
script) does a lousy job tidying up those files, leaving ASCII CR
characters embedded in the lines.  This is particularly bad for array
initializers that have one value per line, because they all end up on a
single line with embedded ASCII CR characters between each value.

Add an initial `sed` command to `copy_source()` to match and remove an
ASCII CR character from the end of each input line.

Also output a message before running `unifdef` and fix the spelling of
"paths" in one of the other messages.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
v2: Corrected tabs in echoed output.
---
 scripts/socfpga_import_preloader | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
index bd54e1b913..26a8556b1a 100755
--- a/scripts/socfpga_import_preloader
+++ b/scripts/socfpga_import_preloader
@@ -79,6 +79,10 @@ copy_source() {
 
 	cp $src $tgt
 
+	echo "	Translating DOS line endings..."
+	sed -i "s/`echo -e '\r'`$//" $tgt
+
+	echo "	Fixing conditional compilation..."
 	unifdef -D HCX_COMPAT_MODE=1 -D ENABLE_INST_ROM_WRITE=1 $tgt -o $tgt
 
 	echo "	Fixing extern/static keywords..."
@@ -99,7 +103,7 @@ copy_source() {
 	sed -i 's/alt_8/int8_t/g' $tgt
 	sed -i 's/#include "alt_types.h"//g' $tgt
 
-	echo "	Fixing include pathes..."
+	echo "	Fixing include paths..."
 	# Fix include pathes
 	sed -i 's/#include <iocsr_config_cyclone5.h>/#include <mach\/cyclone5-scan-manager.h>/g' $tgt
 	sed -i 's/#include <pinmux_config.h>/#include <common.h>/g' $tgt
-- 
2.39.2




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

* Re: [PATCH v2] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-15 15:57 ` [PATCH v2] " Ian Abbott
@ 2023-06-16  6:41   ` Sascha Hauer
  2023-06-16  9:19     ` Ian Abbott
  2023-06-16 12:31   ` [PATCH v3] " Ian Abbott
  1 sibling, 1 reply; 13+ messages in thread
From: Sascha Hauer @ 2023-06-16  6:41 UTC (permalink / raw)
  To: Ian Abbott; +Cc: barebox

Hi Ian,

On Thu, Jun 15, 2023 at 04:57:38PM +0100, Ian Abbott wrote:
> If the handoff files were generated on a Windows system, they will have
> DOS line endings.  The `indent` program (with the options used by the
> script) does a lousy job tidying up those files, leaving ASCII CR
> characters embedded in the lines.  This is particularly bad for array
> initializers that have one value per line, because they all end up on a
> single line with embedded ASCII CR characters between each value.
> 
> Add an initial `sed` command to `copy_source()` to match and remove an
> ASCII CR character from the end of each input line.
> 
> Also output a message before running `unifdef` and fix the spelling of
> "paths" in one of the other messages.
> 
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> ---
> v2: Corrected tabs in echoed output.
> ---
>  scripts/socfpga_import_preloader | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
> index bd54e1b913..26a8556b1a 100755
> --- a/scripts/socfpga_import_preloader
> +++ b/scripts/socfpga_import_preloader
> @@ -79,6 +79,10 @@ copy_source() {
>  
>  	cp $src $tgt
>  
> +	echo "	Translating DOS line endings..."
> +	sed -i "s/`echo -e '\r'`$//" $tgt

Why `echo -e '\r'` here? A plain \r should work as well.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH v2] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-16  6:41   ` Sascha Hauer
@ 2023-06-16  9:19     ` Ian Abbott
  2023-06-16 10:30       ` Sascha Hauer
  0 siblings, 1 reply; 13+ messages in thread
From: Ian Abbott @ 2023-06-16  9:19 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 16/06/2023 07:41, Sascha Hauer wrote:
> Hi Ian,
> 
> On Thu, Jun 15, 2023 at 04:57:38PM +0100, Ian Abbott wrote:
>> If the handoff files were generated on a Windows system, they will have
>> DOS line endings.  The `indent` program (with the options used by the
>> script) does a lousy job tidying up those files, leaving ASCII CR
>> characters embedded in the lines.  This is particularly bad for array
>> initializers that have one value per line, because they all end up on a
>> single line with embedded ASCII CR characters between each value.
>>
>> Add an initial `sed` command to `copy_source()` to match and remove an
>> ASCII CR character from the end of each input line.
>>
>> Also output a message before running `unifdef` and fix the spelling of
>> "paths" in one of the other messages.
>>
>> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
>> ---
>> v2: Corrected tabs in echoed output.
>> ---
>>   scripts/socfpga_import_preloader | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
>> index bd54e1b913..26a8556b1a 100755
>> --- a/scripts/socfpga_import_preloader
>> +++ b/scripts/socfpga_import_preloader
>> @@ -79,6 +79,10 @@ copy_source() {
>>   
>>   	cp $src $tgt
>>   
>> +	echo "	Translating DOS line endings..."
>> +	sed -i "s/`echo -e '\r'`$//" $tgt
> 
> Why `echo -e '\r'` here? A plain \r should work as well.

A plain \r doesn't work, but \\\r works. I prefer '\r'.

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-




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

* Re: [PATCH v2] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-16  9:19     ` Ian Abbott
@ 2023-06-16 10:30       ` Sascha Hauer
  2023-06-16 10:36         ` Ahmad Fatoum
  2023-06-16 12:02         ` Ian Abbott
  0 siblings, 2 replies; 13+ messages in thread
From: Sascha Hauer @ 2023-06-16 10:30 UTC (permalink / raw)
  To: Ian Abbott; +Cc: barebox

On Fri, Jun 16, 2023 at 10:19:38AM +0100, Ian Abbott wrote:
> On 16/06/2023 07:41, Sascha Hauer wrote:
> > Hi Ian,
> > 
> > On Thu, Jun 15, 2023 at 04:57:38PM +0100, Ian Abbott wrote:
> > > If the handoff files were generated on a Windows system, they will have
> > > DOS line endings.  The `indent` program (with the options used by the
> > > script) does a lousy job tidying up those files, leaving ASCII CR
> > > characters embedded in the lines.  This is particularly bad for array
> > > initializers that have one value per line, because they all end up on a
> > > single line with embedded ASCII CR characters between each value.
> > > 
> > > Add an initial `sed` command to `copy_source()` to match and remove an
> > > ASCII CR character from the end of each input line.
> > > 
> > > Also output a message before running `unifdef` and fix the spelling of
> > > "paths" in one of the other messages.
> > > 
> > > Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> > > ---
> > > v2: Corrected tabs in echoed output.
> > > ---
> > >   scripts/socfpga_import_preloader | 6 +++++-
> > >   1 file changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
> > > index bd54e1b913..26a8556b1a 100755
> > > --- a/scripts/socfpga_import_preloader
> > > +++ b/scripts/socfpga_import_preloader
> > > @@ -79,6 +79,10 @@ copy_source() {
> > >   	cp $src $tgt
> > > +	echo "	Translating DOS line endings..."
> > > +	sed -i "s/`echo -e '\r'`$//" $tgt
> > 
> > Why `echo -e '\r'` here? A plain \r should work as well.
> 
> A plain \r doesn't work, but \\\r works. I prefer '\r'.

Strange, would be interesting to know where the difference is.
Here both of these commands have behave the same:

echo hallo | unix2dos | sed "s/`echo -e '\r'`$//" | hexdump -C
echo hallo | unix2dos | sed "s/\r$//" | hexdump -C

They both result in:

00000000  68 61 6c 6c 6f 0a                                 |hallo.|
00000006

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH v2] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-16 10:30       ` Sascha Hauer
@ 2023-06-16 10:36         ` Ahmad Fatoum
  2023-06-16 11:31           ` Sascha Hauer
  2023-06-16 12:02         ` Ian Abbott
  1 sibling, 1 reply; 13+ messages in thread
From: Ahmad Fatoum @ 2023-06-16 10:36 UTC (permalink / raw)
  To: Sascha Hauer, Ian Abbott; +Cc: barebox

Hi,

On 16.06.23 12:30, Sascha Hauer wrote:
> On Fri, Jun 16, 2023 at 10:19:38AM +0100, Ian Abbott wrote:
>> On 16/06/2023 07:41, Sascha Hauer wrote:
>>> Hi Ian,
>>>
>>> On Thu, Jun 15, 2023 at 04:57:38PM +0100, Ian Abbott wrote:
>>>> If the handoff files were generated on a Windows system, they will have
>>>> DOS line endings.  The `indent` program (with the options used by the
>>>> script) does a lousy job tidying up those files, leaving ASCII CR
>>>> characters embedded in the lines.  This is particularly bad for array
>>>> initializers that have one value per line, because they all end up on a
>>>> single line with embedded ASCII CR characters between each value.
>>>>
>>>> Add an initial `sed` command to `copy_source()` to match and remove an
>>>> ASCII CR character from the end of each input line.
>>>>
>>>> Also output a message before running `unifdef` and fix the spelling of
>>>> "paths" in one of the other messages.
>>>>
>>>> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
>>>> ---
>>>> v2: Corrected tabs in echoed output.
>>>> ---
>>>>   scripts/socfpga_import_preloader | 6 +++++-
>>>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
>>>> index bd54e1b913..26a8556b1a 100755
>>>> --- a/scripts/socfpga_import_preloader
>>>> +++ b/scripts/socfpga_import_preloader
>>>> @@ -79,6 +79,10 @@ copy_source() {
>>>>   	cp $src $tgt
>>>> +	echo "	Translating DOS line endings..."
>>>> +	sed -i "s/`echo -e '\r'`$//" $tgt
>>>
>>> Why `echo -e '\r'` here? A plain \r should work as well.
>>
>> A plain \r doesn't work, but \\\r works. I prefer '\r'.
> 
> Strange, would be interesting to know where the difference is.
> Here both of these commands have behave the same:
> 
> echo hallo | unix2dos | sed "s/`echo -e '\r'`$//" | hexdump -C
> echo hallo | unix2dos | sed "s/\r$//" | hexdump -C

Speaking of unix2dos, socfpga_get_sequencer and socfpga_xml_to_config.sh
already use dos2unix. Why can't we do likewise here and avoid any
dash/bash/sed/gsed incompatibilities that might be there?

> 
> They both result in:
> 
> 00000000  68 61 6c 6c 6f 0a                                 |hallo.|
> 00000006
> 
> Sascha
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH v2] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-16 10:36         ` Ahmad Fatoum
@ 2023-06-16 11:31           ` Sascha Hauer
  2023-06-16 11:33             ` Sascha Hauer
  0 siblings, 1 reply; 13+ messages in thread
From: Sascha Hauer @ 2023-06-16 11:31 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Ian Abbott, barebox

On Fri, Jun 16, 2023 at 12:36:11PM +0200, Ahmad Fatoum wrote:
> Hi,
> 
> On 16.06.23 12:30, Sascha Hauer wrote:
> > On Fri, Jun 16, 2023 at 10:19:38AM +0100, Ian Abbott wrote:
> >> On 16/06/2023 07:41, Sascha Hauer wrote:
> >>> Hi Ian,
> >>>
> >>> On Thu, Jun 15, 2023 at 04:57:38PM +0100, Ian Abbott wrote:
> >>>> If the handoff files were generated on a Windows system, they will have
> >>>> DOS line endings.  The `indent` program (with the options used by the
> >>>> script) does a lousy job tidying up those files, leaving ASCII CR
> >>>> characters embedded in the lines.  This is particularly bad for array
> >>>> initializers that have one value per line, because they all end up on a
> >>>> single line with embedded ASCII CR characters between each value.
> >>>>
> >>>> Add an initial `sed` command to `copy_source()` to match and remove an
> >>>> ASCII CR character from the end of each input line.
> >>>>
> >>>> Also output a message before running `unifdef` and fix the spelling of
> >>>> "paths" in one of the other messages.
> >>>>
> >>>> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> >>>> ---
> >>>> v2: Corrected tabs in echoed output.
> >>>> ---
> >>>>   scripts/socfpga_import_preloader | 6 +++++-
> >>>>   1 file changed, 5 insertions(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
> >>>> index bd54e1b913..26a8556b1a 100755
> >>>> --- a/scripts/socfpga_import_preloader
> >>>> +++ b/scripts/socfpga_import_preloader
> >>>> @@ -79,6 +79,10 @@ copy_source() {
> >>>>   	cp $src $tgt
> >>>> +	echo "	Translating DOS line endings..."
> >>>> +	sed -i "s/`echo -e '\r'`$//" $tgt
> >>>
> >>> Why `echo -e '\r'` here? A plain \r should work as well.
> >>
> >> A plain \r doesn't work, but \\\r works. I prefer '\r'.
> > 
> > Strange, would be interesting to know where the difference is.
> > Here both of these commands have behave the same:
> > 
> > echo hallo | unix2dos | sed "s/`echo -e '\r'`$//" | hexdump -C
> > echo hallo | unix2dos | sed "s/\r$//" | hexdump -C
> 
> Speaking of unix2dos, socfpga_get_sequencer and socfpga_xml_to_config.sh
> already use dos2unix. Why can't we do likewise here and avoid any
> dash/bash/sed/gsed incompatibilities that might be there?

We could, but you sent a patch that uses sed instead ;)

I'm fine with using dos2unix. I thought you were doing so to avoid
adding another dependency to the barebox build system. In the end
this script is not even part of the build system, but only a helper
script which is called manually, so this shouldn't be a problem.
Also unix2dos/dos2unix is likely found in all Linux distributions. Just
go for it.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH v2] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-16 11:31           ` Sascha Hauer
@ 2023-06-16 11:33             ` Sascha Hauer
  0 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2023-06-16 11:33 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Ian Abbott, barebox

On Fri, Jun 16, 2023 at 01:31:49PM +0200, Sascha Hauer wrote:
> On Fri, Jun 16, 2023 at 12:36:11PM +0200, Ahmad Fatoum wrote:
> > Hi,
> > 
> > On 16.06.23 12:30, Sascha Hauer wrote:
> > > On Fri, Jun 16, 2023 at 10:19:38AM +0100, Ian Abbott wrote:
> > >> On 16/06/2023 07:41, Sascha Hauer wrote:
> > >>> Hi Ian,
> > >>>
> > >>> On Thu, Jun 15, 2023 at 04:57:38PM +0100, Ian Abbott wrote:
> > >>>> If the handoff files were generated on a Windows system, they will have
> > >>>> DOS line endings.  The `indent` program (with the options used by the
> > >>>> script) does a lousy job tidying up those files, leaving ASCII CR
> > >>>> characters embedded in the lines.  This is particularly bad for array
> > >>>> initializers that have one value per line, because they all end up on a
> > >>>> single line with embedded ASCII CR characters between each value.
> > >>>>
> > >>>> Add an initial `sed` command to `copy_source()` to match and remove an
> > >>>> ASCII CR character from the end of each input line.
> > >>>>
> > >>>> Also output a message before running `unifdef` and fix the spelling of
> > >>>> "paths" in one of the other messages.
> > >>>>
> > >>>> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> > >>>> ---
> > >>>> v2: Corrected tabs in echoed output.
> > >>>> ---
> > >>>>   scripts/socfpga_import_preloader | 6 +++++-
> > >>>>   1 file changed, 5 insertions(+), 1 deletion(-)
> > >>>>
> > >>>> diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
> > >>>> index bd54e1b913..26a8556b1a 100755
> > >>>> --- a/scripts/socfpga_import_preloader
> > >>>> +++ b/scripts/socfpga_import_preloader
> > >>>> @@ -79,6 +79,10 @@ copy_source() {
> > >>>>   	cp $src $tgt
> > >>>> +	echo "	Translating DOS line endings..."
> > >>>> +	sed -i "s/`echo -e '\r'`$//" $tgt
> > >>>
> > >>> Why `echo -e '\r'` here? A plain \r should work as well.
> > >>
> > >> A plain \r doesn't work, but \\\r works. I prefer '\r'.
> > > 
> > > Strange, would be interesting to know where the difference is.
> > > Here both of these commands have behave the same:
> > > 
> > > echo hallo | unix2dos | sed "s/`echo -e '\r'`$//" | hexdump -C
> > > echo hallo | unix2dos | sed "s/\r$//" | hexdump -C
> > 
> > Speaking of unix2dos, socfpga_get_sequencer and socfpga_xml_to_config.sh
> > already use dos2unix. Why can't we do likewise here and avoid any
> > dash/bash/sed/gsed incompatibilities that might be there?
> 
> We could, but you sent a patch that uses sed instead ;)
> 
> I'm fine with using dos2unix. I thought you were doing so to avoid
> adding another dependency to the barebox build system. In the end
> this script is not even part of the build system, but only a helper
> script which is called manually, so this shouldn't be a problem.
> Also unix2dos/dos2unix is likely found in all Linux distributions. Just
> go for it.

Erm, sorry, I thought I am answering Ian. I didn't realize Ahmad wrote
this mail.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH v2] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-16 10:30       ` Sascha Hauer
  2023-06-16 10:36         ` Ahmad Fatoum
@ 2023-06-16 12:02         ` Ian Abbott
  1 sibling, 0 replies; 13+ messages in thread
From: Ian Abbott @ 2023-06-16 12:02 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi Sascha,

On 16/06/2023 11:30, Sascha Hauer wrote:
> On Fri, Jun 16, 2023 at 10:19:38AM +0100, Ian Abbott wrote:
>> On 16/06/2023 07:41, Sascha Hauer wrote:
>>> Hi Ian,
>>>
>>> On Thu, Jun 15, 2023 at 04:57:38PM +0100, Ian Abbott wrote:
>>>> If the handoff files were generated on a Windows system, they will have
>>>> DOS line endings.  The `indent` program (with the options used by the
>>>> script) does a lousy job tidying up those files, leaving ASCII CR
>>>> characters embedded in the lines.  This is particularly bad for array
>>>> initializers that have one value per line, because they all end up on a
>>>> single line with embedded ASCII CR characters between each value.
>>>>
>>>> Add an initial `sed` command to `copy_source()` to match and remove an
>>>> ASCII CR character from the end of each input line.
>>>>
>>>> Also output a message before running `unifdef` and fix the spelling of
>>>> "paths" in one of the other messages.
>>>>
>>>> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
>>>> ---
>>>> v2: Corrected tabs in echoed output.
>>>> ---
>>>>    scripts/socfpga_import_preloader | 6 +++++-
>>>>    1 file changed, 5 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
>>>> index bd54e1b913..26a8556b1a 100755
>>>> --- a/scripts/socfpga_import_preloader
>>>> +++ b/scripts/socfpga_import_preloader
>>>> @@ -79,6 +79,10 @@ copy_source() {
>>>>    	cp $src $tgt
>>>> +	echo "	Translating DOS line endings..."
>>>> +	sed -i "s/`echo -e '\r'`$//" $tgt
>>>
>>> Why `echo -e '\r'` here? A plain \r should work as well.
>>
>> A plain \r doesn't work, but \\\r works. I prefer '\r'.
> 
> Strange, would be interesting to know where the difference is.
> Here both of these commands have behave the same:
> 
> echo hallo | unix2dos | sed "s/`echo -e '\r'`$//" | hexdump -C
> echo hallo | unix2dos | sed "s/\r$//" | hexdump -C
> 
> They both result in:
> 
> 00000000  68 61 6c 6c 6f 0a                                 |hallo.|
> 00000006

Sorry, I misinterpreted what you wrote. I thought you meant replace 
'\r'` with \r, rather than replace `echo -e '\r'` with \r.

I've never seen \r in a sed regular expression before. It seems to be a 
GNU sed extension. POSIX only supports \\ and \n.

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-




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

* [PATCH v3] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-15 15:57 ` [PATCH v2] " Ian Abbott
  2023-06-16  6:41   ` Sascha Hauer
@ 2023-06-16 12:31   ` Ian Abbott
  2023-06-16 12:35     ` Ahmad Fatoum
  2023-06-21  9:34     ` Sascha Hauer
  1 sibling, 2 replies; 13+ messages in thread
From: Ian Abbott @ 2023-06-16 12:31 UTC (permalink / raw)
  To: barebox; +Cc: Ian Abbott

If the handoff files were generated on a Windows system, they will have
DOS line endings (CRLF).  The `indent` program (with the options used by
the script) does a lousy job tidying up those files, leaving ASCII CR
characters embedded in the lines.  This is particularly bad for array
initializers that have one value per line, because they all end up on a
single line with embedded ASCII CR characters between each value.

Add an initial `dos2unix` command to `copy_source()` to change the DOS
line endings (CRLF) to Unix line endings (LF).

Also output a message before running `unifdef` and fix the spelling of
"paths" in one of the other messages.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
v2: Corrected tabs in echoed output.
v3: Use dos2unix instead of sed, as suggested by Ahmed Fatoum.  Remove
    the corresponding echo command because dos2unix is verbose enough
    already!
---
 scripts/socfpga_import_preloader | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
index bd54e1b913..fb8270f5d3 100755
--- a/scripts/socfpga_import_preloader
+++ b/scripts/socfpga_import_preloader
@@ -79,6 +79,9 @@ copy_source() {
 
 	cp $src $tgt
 
+	dos2unix $tgt
+
+	echo "	Fixing conditional compilation..."
 	unifdef -D HCX_COMPAT_MODE=1 -D ENABLE_INST_ROM_WRITE=1 $tgt -o $tgt
 
 	echo "	Fixing extern/static keywords..."
@@ -99,7 +102,7 @@ copy_source() {
 	sed -i 's/alt_8/int8_t/g' $tgt
 	sed -i 's/#include "alt_types.h"//g' $tgt
 
-	echo "	Fixing include pathes..."
+	echo "	Fixing include paths..."
 	# Fix include pathes
 	sed -i 's/#include <iocsr_config_cyclone5.h>/#include <mach\/cyclone5-scan-manager.h>/g' $tgt
 	sed -i 's/#include <pinmux_config.h>/#include <common.h>/g' $tgt
-- 
2.39.2




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

* Re: [PATCH v3] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-16 12:31   ` [PATCH v3] " Ian Abbott
@ 2023-06-16 12:35     ` Ahmad Fatoum
  2023-06-21  9:34     ` Sascha Hauer
  1 sibling, 0 replies; 13+ messages in thread
From: Ahmad Fatoum @ 2023-06-16 12:35 UTC (permalink / raw)
  To: Ian Abbott, barebox

On 16.06.23 14:31, Ian Abbott wrote:
> If the handoff files were generated on a Windows system, they will have
> DOS line endings (CRLF).  The `indent` program (with the options used by
> the script) does a lousy job tidying up those files, leaving ASCII CR
> characters embedded in the lines.  This is particularly bad for array
> initializers that have one value per line, because they all end up on a
> single line with embedded ASCII CR characters between each value.
> 
> Add an initial `dos2unix` command to `copy_source()` to change the DOS
> line endings (CRLF) to Unix line endings (LF).
> 
> Also output a message before running `unifdef` and fix the spelling of
> "paths" in one of the other messages.
> 
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Cheers,
Ahmad

> ---
> v2: Corrected tabs in echoed output.
> v3: Use dos2unix instead of sed, as suggested by Ahmed Fatoum.  Remove
>     the corresponding echo command because dos2unix is verbose enough
>     already!
> ---
>  scripts/socfpga_import_preloader | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
> index bd54e1b913..fb8270f5d3 100755
> --- a/scripts/socfpga_import_preloader
> +++ b/scripts/socfpga_import_preloader
> @@ -79,6 +79,9 @@ copy_source() {
>  
>  	cp $src $tgt
>  
> +	dos2unix $tgt
> +
> +	echo "	Fixing conditional compilation..."
>  	unifdef -D HCX_COMPAT_MODE=1 -D ENABLE_INST_ROM_WRITE=1 $tgt -o $tgt
>  
>  	echo "	Fixing extern/static keywords..."
> @@ -99,7 +102,7 @@ copy_source() {
>  	sed -i 's/alt_8/int8_t/g' $tgt
>  	sed -i 's/#include "alt_types.h"//g' $tgt
>  
> -	echo "	Fixing include pathes..."
> +	echo "	Fixing include paths..."
>  	# Fix include pathes
>  	sed -i 's/#include <iocsr_config_cyclone5.h>/#include <mach\/cyclone5-scan-manager.h>/g' $tgt
>  	sed -i 's/#include <pinmux_config.h>/#include <common.h>/g' $tgt

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH v3] scripts: socfpga_import_preloader: Translate DOS line endings
  2023-06-16 12:31   ` [PATCH v3] " Ian Abbott
  2023-06-16 12:35     ` Ahmad Fatoum
@ 2023-06-21  9:34     ` Sascha Hauer
  1 sibling, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2023-06-21  9:34 UTC (permalink / raw)
  To: Ian Abbott; +Cc: barebox

On Fri, Jun 16, 2023 at 01:31:36PM +0100, Ian Abbott wrote:
> If the handoff files were generated on a Windows system, they will have
> DOS line endings (CRLF).  The `indent` program (with the options used by
> the script) does a lousy job tidying up those files, leaving ASCII CR
> characters embedded in the lines.  This is particularly bad for array
> initializers that have one value per line, because they all end up on a
> single line with embedded ASCII CR characters between each value.
> 
> Add an initial `dos2unix` command to `copy_source()` to change the DOS
> line endings (CRLF) to Unix line endings (LF).
> 
> Also output a message before running `unifdef` and fix the spelling of
> "paths" in one of the other messages.
> 
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> ---
> v2: Corrected tabs in echoed output.
> v3: Use dos2unix instead of sed, as suggested by Ahmed Fatoum.  Remove
>     the corresponding echo command because dos2unix is verbose enough
>     already!
> ---
>  scripts/socfpga_import_preloader | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
> index bd54e1b913..fb8270f5d3 100755
> --- a/scripts/socfpga_import_preloader
> +++ b/scripts/socfpga_import_preloader
> @@ -79,6 +79,9 @@ copy_source() {
>  
>  	cp $src $tgt
>  
> +	dos2unix $tgt
> +
> +	echo "	Fixing conditional compilation..."
>  	unifdef -D HCX_COMPAT_MODE=1 -D ENABLE_INST_ROM_WRITE=1 $tgt -o $tgt
>  
>  	echo "	Fixing extern/static keywords..."
> @@ -99,7 +102,7 @@ copy_source() {
>  	sed -i 's/alt_8/int8_t/g' $tgt
>  	sed -i 's/#include "alt_types.h"//g' $tgt
>  
> -	echo "	Fixing include pathes..."
> +	echo "	Fixing include paths..."
>  	# Fix include pathes
>  	sed -i 's/#include <iocsr_config_cyclone5.h>/#include <mach\/cyclone5-scan-manager.h>/g' $tgt
>  	sed -i 's/#include <pinmux_config.h>/#include <common.h>/g' $tgt
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2023-06-21  9:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-15 13:55 [PATCH] scripts: socfpga_import_preloader: Translate DOS line endings Ian Abbott
2023-06-15 15:49 ` Ian Abbott
2023-06-15 15:57 ` [PATCH v2] " Ian Abbott
2023-06-16  6:41   ` Sascha Hauer
2023-06-16  9:19     ` Ian Abbott
2023-06-16 10:30       ` Sascha Hauer
2023-06-16 10:36         ` Ahmad Fatoum
2023-06-16 11:31           ` Sascha Hauer
2023-06-16 11:33             ` Sascha Hauer
2023-06-16 12:02         ` Ian Abbott
2023-06-16 12:31   ` [PATCH v3] " Ian Abbott
2023-06-16 12:35     ` Ahmad Fatoum
2023-06-21  9:34     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox