* [Qemu-devel] [PATCH] win32: Fix CRLF problem in make_device_config.sh
@ 2010-12-16 21:52 Stefan Weil
2010-12-16 22:42 ` [Qemu-devel] " Paolo Bonzini
2010-12-18 16:34 ` [Qemu-devel] [PATCH v2] " Stefan Weil
0 siblings, 2 replies; 26+ messages in thread
From: Stefan Weil @ 2010-12-16 21:52 UTC (permalink / raw)
To: QEMU Developers
QEMU source code with CRLF line endings
which is quite common on windows hosts
fails with current make_device_config.sh.
The awk script gets the name of the included
file with \r, so instead of pci.mak it will
search for pci.mak\r which of course does
not work.
Fix this by removing any \r at end of line.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
make_device_config.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/make_device_config.sh b/make_device_config.sh
index 8abadfe..f0ce10a 100644
--- a/make_device_config.sh
+++ b/make_device_config.sh
@@ -18,7 +18,7 @@ process_includes () {
f=$src
while [ -n "$f" ] ; do
- f=`awk '/^include / {ORS=" " ; print "'$src_dir'/" $2}' $f`
+ f=`awk '/^include / {ORS=" "; sub(/\r$/, "", $2); print "'$src_dir'/" $2}' $f`
[ $? = 0 ] || exit 1
all_includes="$all_includes $f"
done
--
1.7.2.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-16 21:52 [Qemu-devel] [PATCH] win32: Fix CRLF problem in make_device_config.sh Stefan Weil
@ 2010-12-16 22:42 ` Paolo Bonzini
2010-12-17 13:34 ` Andreas Färber
2010-12-18 16:34 ` [Qemu-devel] [PATCH v2] " Stefan Weil
1 sibling, 1 reply; 26+ messages in thread
From: Paolo Bonzini @ 2010-12-16 22:42 UTC (permalink / raw)
To: Stefan Weil; +Cc: QEMU Developers
On 12/16/2010 10:52 PM, Stefan Weil wrote:
> QEMU source code with CRLF line endings
> which is quite common on windows hosts
> fails with current make_device_config.sh.
>
> The awk script gets the name of the included
> file with \r, so instead of pci.mak it will
> search for pci.mak\r which of course does
> not work.
>
> Fix this by removing any \r at end of line.
Why isn't cygwin (or whatever you're using) removing it?
Paolo
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-16 22:42 ` [Qemu-devel] " Paolo Bonzini
@ 2010-12-17 13:34 ` Andreas Färber
2010-12-17 13:44 ` Paolo Bonzini
0 siblings, 1 reply; 26+ messages in thread
From: Andreas Färber @ 2010-12-17 13:34 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: QEMU Developers
Am 16.12.2010 um 23:42 schrieb Paolo Bonzini:
> On 12/16/2010 10:52 PM, Stefan Weil wrote:
>> QEMU source code with CRLF line endings
>> which is quite common on windows hosts
>> fails with current make_device_config.sh.
>>
>> The awk script gets the name of the included
>> file with \r, so instead of pci.mak it will
>> search for pci.mak\r which of course does
>> not work.
>>
>> Fix this by removing any \r at end of line.
>
> Why isn't cygwin (or whatever you're using) removing it?
I believe Cygwin had an option to choose the line ending style once
during setup. By default it uses Unix-style line endings.
If someone edits source files in some Windows editor, the above issue
seems likely.
My awk foo is insufficient to ack the patch but if it doesn't break
Unices it looks reasonable to me.
Andreas
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-17 13:34 ` Andreas Färber
@ 2010-12-17 13:44 ` Paolo Bonzini
2010-12-17 19:01 ` Stefan Weil
0 siblings, 1 reply; 26+ messages in thread
From: Paolo Bonzini @ 2010-12-17 13:44 UTC (permalink / raw)
To: Andreas Färber; +Cc: QEMU Developers
On 12/17/2010 02:34 PM, Andreas Färber wrote:
>>>
>>> Fix this by removing any \r at end of line.
>>
>> Why isn't cygwin (or whatever you're using) removing it?
>
> I believe Cygwin had an option to choose the line ending style once
> during setup. By default it uses Unix-style line endings.
> If someone edits source files in some Windows editor, the above issue
> seems likely.
Hmm, MSYS is more problematic: the manual says "In the MSYS environment
under Windows, `gawk' automatically uses binary mode for reading and
writing files. Thus there is no need to use the `BINMODE' variable.
This can cause problems with other Unix-like components that have been
ported to Windows that expect `gawk' to do automatic translationof
`"\r\n"', since it won't.".
> My awk foo is insufficient to ack the patch but if it doesn't break
> Unices it looks reasonable to me.
I'd be worried a bit about Solaris and other proprietary OSes with
prehistoric Unix utilities. Perhaps using \012 instead of \r is better.
Paolo
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-17 13:44 ` Paolo Bonzini
@ 2010-12-17 19:01 ` Stefan Weil
2010-12-17 19:33 ` Andreas Färber
2010-12-17 20:08 ` Paolo Bonzini
0 siblings, 2 replies; 26+ messages in thread
From: Stefan Weil @ 2010-12-17 19:01 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Andreas Färber, QEMU Developers
Am 17.12.2010 14:44, schrieb Paolo Bonzini:
> On 12/17/2010 02:34 PM, Andreas Färber wrote:
>>>>
>>>> Fix this by removing any \r at end of line.
>>>
>>> Why isn't cygwin (or whatever you're using) removing it?
>>
>> I believe Cygwin had an option to choose the line ending style once
>> during setup. By default it uses Unix-style line endings.
>> If someone edits source files in some Windows editor, the above issue
>> seems likely.
>
> Hmm, MSYS is more problematic: the manual says "In the MSYS
> environment under Windows, `gawk' automatically uses binary mode for
> reading and writing files. Thus there is no need to use the `BINMODE'
> variable. This can cause problems with other Unix-like components that
> have been ported to Windows that expect `gawk' to do automatic
> translationof `"\r\n"', since it won't.".
I had the \r problem when using msys. There seem to be several factors:
* git configuration (add CR / don't add CR)
* msys mount options (binmode / textmode)
* (g)awk (read binary)
>
>> My awk foo is insufficient to ack the patch but if it doesn't break
>> Unices it looks reasonable to me.
>
> I'd be worried a bit about Solaris and other proprietary OSes with
> prehistoric Unix utilities. Perhaps using \012 instead of \r is better.
>
> Paolo
I currently have no possibility to run tests with other awk implementations,
so I cannot tell whether \012 is needed at all (\r is not a new invention).
Do all awk versions support regular expressions with characters in
octal encoding?.
Perhaps we can wait several days for feedback from users with an old awk
and apply the patch if there is none.
Regards,
Stefan
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-17 19:01 ` Stefan Weil
@ 2010-12-17 19:33 ` Andreas Färber
2010-12-17 19:54 ` Stefan Weil
2010-12-17 20:08 ` Paolo Bonzini
1 sibling, 1 reply; 26+ messages in thread
From: Andreas Färber @ 2010-12-17 19:33 UTC (permalink / raw)
To: Stefan Weil; +Cc: Paolo Bonzini, QEMU Developers
Am 17.12.2010 um 20:01 schrieb Stefan Weil:
> Am 17.12.2010 14:44, schrieb Paolo Bonzini:
>> On 12/17/2010 02:34 PM, Andreas Färber wrote:
>>>>>
>>>>> Fix this by removing any \r at end of line.
>>>>
>>>> Why isn't cygwin (or whatever you're using) removing it?
>>>
>>> I believe Cygwin had an option to choose the line ending style once
>>> during setup. By default it uses Unix-style line endings.
>>> If someone edits source files in some Windows editor, the above
>>> issue
>>> seems likely.
>>
>> Hmm, MSYS is more problematic: the manual says "In the MSYS
>> environment under Windows, `gawk' automatically uses binary mode
>> for reading and writing files. Thus there is no need to use the
>> `BINMODE' variable. This can cause problems with other Unix-like
>> components that have been ported to Windows that expect `gawk' to
>> do automatic translationof `"\r\n"', since it won't.".
>
> I had the \r problem when using msys. There seem to be several
> factors:
>
> * git configuration (add CR / don't add CR)
> * msys mount options (binmode / textmode)
> * (g)awk (read binary)
>
>>
>>> My awk foo is insufficient to ack the patch but if it doesn't break
>>> Unices it looks reasonable to me.
>>
>> I'd be worried a bit about Solaris and other proprietary OSes with
>> prehistoric Unix utilities. Perhaps using \012 instead of \r is
>> better.
>>
>> Paolo
>
> I currently have no possibility to run tests with other awk
> implementations,
> so I cannot tell whether \012 is needed at all (\r is not a new
> invention).
> Do all awk versions support regular expressions with characters in
> octal encoding?.
>
> Perhaps we can wait several days for feedback from users with an old
> awk
> and apply the patch if there is none.
I have an open bug ticket wrt configure being broken on Solaris 10 due
to tracing shell incompatibilities.
If you provide a small self-contained example I can check though.
Andreas
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-17 19:33 ` Andreas Färber
@ 2010-12-17 19:54 ` Stefan Weil
2010-12-17 21:00 ` Andreas Färber
0 siblings, 1 reply; 26+ messages in thread
From: Stefan Weil @ 2010-12-17 19:54 UTC (permalink / raw)
To: Andreas Färber; +Cc: QEMU Developers
Am 17.12.2010 20:33, schrieb Andreas Färber:
> Am 17.12.2010 um 20:01 schrieb Stefan Weil:
>
>> Am 17.12.2010 14:44, schrieb Paolo Bonzini:
>>> On 12/17/2010 02:34 PM, Andreas Färber wrote:
>>>>>>
>>>>>> Fix this by removing any \r at end of line.
>>>>>
>>>>> Why isn't cygwin (or whatever you're using) removing it?
>>>>
>>>> I believe Cygwin had an option to choose the line ending style once
>>>> during setup. By default it uses Unix-style line endings.
>>>> If someone edits source files in some Windows editor, the above issue
>>>> seems likely.
>>>
>>> Hmm, MSYS is more problematic: the manual says "In the MSYS
>>> environment under Windows, `gawk' automatically uses binary mode for
>>> reading and writing files. Thus there is no need to use the
>>> `BINMODE' variable. This can cause problems with other Unix-like
>>> components that have been ported to Windows that expect `gawk' to do
>>> automatic translationof `"\r\n"', since it won't.".
>>
>> I had the \r problem when using msys. There seem to be several factors:
>>
>> * git configuration (add CR / don't add CR)
>> * msys mount options (binmode / textmode)
>> * (g)awk (read binary)
>>
>>>
>>>> My awk foo is insufficient to ack the patch but if it doesn't break
>>>> Unices it looks reasonable to me.
>>>
>>> I'd be worried a bit about Solaris and other proprietary OSes with
>>> prehistoric Unix utilities. Perhaps using \012 instead of \r is
>>> better.
>>>
>>> Paolo
>>
>> I currently have no possibility to run tests with other awk
>> implementations,
>> so I cannot tell whether \012 is needed at all (\r is not a new
>> invention).
>> Do all awk versions support regular expressions with characters in
>> octal encoding?.
>>
>> Perhaps we can wait several days for feedback from users with an old awk
>> and apply the patch if there is none.
>
> I have an open bug ticket wrt configure being broken on Solaris 10 due
> to tracing shell incompatibilities.
>
> If you provide a small self-contained example I can check though.
>
> Andreas
Example (needs bash's echo -e):
# create line with crlf ending:
echo -e 'include xy\r' >file
# returns xy\r:
awk '/^include / {ORS=" "; print $2}' file | od
# should return xy:
awk '/^include / {ORS=" "; sub(/\r$/, "", $2); print $2}' file | od
Regards,
Stefan
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-17 19:01 ` Stefan Weil
2010-12-17 19:33 ` Andreas Färber
@ 2010-12-17 20:08 ` Paolo Bonzini
1 sibling, 0 replies; 26+ messages in thread
From: Paolo Bonzini @ 2010-12-17 20:08 UTC (permalink / raw)
To: Stefan Weil; +Cc: Andreas Färber, QEMU Developers
On 12/17/2010 08:01 PM, Stefan Weil wrote:
> I currently have no possibility to run tests with other awk
> implementations,
> so I cannot tell whether \012 is needed at all (\r is not a new invention).
> Do all awk versions support regular expressions with characters in
> octal encoding?.
The awk manual reports \b, \f and \r as unportable, and says that \a,
\v, \x have been introduced after those. \x is not in POSIX.
That leaves \a, \n, \t, \v and \NNN as portable.
Paolo
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-17 19:54 ` Stefan Weil
@ 2010-12-17 21:00 ` Andreas Färber
2010-12-17 21:25 ` Paolo Bonzini
0 siblings, 1 reply; 26+ messages in thread
From: Andreas Färber @ 2010-12-17 21:00 UTC (permalink / raw)
To: Stefan Weil; +Cc: QEMU Developers
Am 17.12.2010 um 20:54 schrieb Stefan Weil:
> Am 17.12.2010 20:33, schrieb Andreas Färber:
>> Am 17.12.2010 um 20:01 schrieb Stefan Weil:
>>
>>> Am 17.12.2010 14:44, schrieb Paolo Bonzini:
>>>> On 12/17/2010 02:34 PM, Andreas Färber wrote:
>>>>>>>
>>>>>>> Fix this by removing any \r at end of line.
>>>>>>
>>>>>> Why isn't cygwin (or whatever you're using) removing it?
>>>>>
>>>>> I believe Cygwin had an option to choose the line ending style
>>>>> once
>>>>> during setup. By default it uses Unix-style line endings.
>>>>> If someone edits source files in some Windows editor, the above
>>>>> issue
>>>>> seems likely.
>>>>
>>>> Hmm, MSYS is more problematic: the manual says "In the MSYS
>>>> environment under Windows, `gawk' automatically uses binary mode
>>>> for reading and writing files. Thus there is no need to use the
>>>> `BINMODE' variable. This can cause problems with other Unix-like
>>>> components that have been ported to Windows that expect `gawk' to
>>>> do automatic translationof `"\r\n"', since it won't.".
>>>
>>> I had the \r problem when using msys. There seem to be several
>>> factors:
>>>
>>> * git configuration (add CR / don't add CR)
>>> * msys mount options (binmode / textmode)
>>> * (g)awk (read binary)
>>>
>>>>
>>>>> My awk foo is insufficient to ack the patch but if it doesn't
>>>>> break
>>>>> Unices it looks reasonable to me.
>>>>
>>>> I'd be worried a bit about Solaris and other proprietary OSes
>>>> with prehistoric Unix utilities. Perhaps using \012 instead of
>>>> \r is better.
>>>>
>>>> Paolo
>>>
>>> I currently have no possibility to run tests with other awk
>>> implementations,
>>> so I cannot tell whether \012 is needed at all (\r is not a new
>>> invention).
>>> Do all awk versions support regular expressions with characters in
>>> octal encoding?.
>>>
>>> Perhaps we can wait several days for feedback from users with an
>>> old awk
>>> and apply the patch if there is none.
>>
>> I have an open bug ticket wrt configure being broken on Solaris 10
>> due to tracing shell incompatibilities.
>>
>> If you provide a small self-contained example I can check though.
>>
>> Andreas
>
>
> Example (needs bash's echo -e):
>
> # create line with crlf ending:
> echo -e 'include xy\r' >file
>
> # returns xy\r:
> awk '/^include / {ORS=" "; print $2}' file | od
0000000 074570 020015
0000004
> # should return xy:
> awk '/^include / {ORS=" "; sub(/\r$/, "", $2); print $2}' file | od
awk: syntax error near line 1
awk: illegal statement near line 1
0000000
Andreas
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-17 21:00 ` Andreas Färber
@ 2010-12-17 21:25 ` Paolo Bonzini
2010-12-17 22:17 ` Andreas Färber
0 siblings, 1 reply; 26+ messages in thread
From: Paolo Bonzini @ 2010-12-17 21:25 UTC (permalink / raw)
To: Andreas Färber; +Cc: QEMU Developers
On 12/17/2010 10:00 PM, Andreas Färber wrote:
> Am 17.12.2010 um 20:54 schrieb Stefan Weil:
>
>> Am 17.12.2010 20:33, schrieb Andreas Färber:
>>> Am 17.12.2010 um 20:01 schrieb Stefan Weil:
>>>
>>>> Am 17.12.2010 14:44, schrieb Paolo Bonzini:
>>>>> On 12/17/2010 02:34 PM, Andreas Färber wrote:
>>>>>>>>
>>>>>>>> Fix this by removing any \r at end of line.
>>>>>>>
>>>>>>> Why isn't cygwin (or whatever you're using) removing it?
>>>>>>
>>>>>> I believe Cygwin had an option to choose the line ending style once
>>>>>> during setup. By default it uses Unix-style line endings.
>>>>>> If someone edits source files in some Windows editor, the above issue
>>>>>> seems likely.
>>>>>
>>>>> Hmm, MSYS is more problematic: the manual says "In the MSYS
>>>>> environment under Windows, `gawk' automatically uses binary mode
>>>>> for reading and writing files. Thus there is no need to use the
>>>>> `BINMODE' variable. This can cause problems with other Unix-like
>>>>> components that have been ported to Windows that expect `gawk' to
>>>>> do automatic translationof `"\r\n"', since it won't.".
>>>>
>>>> I had the \r problem when using msys. There seem to be several factors:
>>>>
>>>> * git configuration (add CR / don't add CR)
>>>> * msys mount options (binmode / textmode)
>>>> * (g)awk (read binary)
>>>>
>>>>>
>>>>>> My awk foo is insufficient to ack the patch but if it doesn't break
>>>>>> Unices it looks reasonable to me.
>>>>>
>>>>> I'd be worried a bit about Solaris and other proprietary OSes with
>>>>> prehistoric Unix utilities. Perhaps using \012 instead of \r is
>>>>> better.
>>>>>
>>>>> Paolo
>>>>
>>>> I currently have no possibility to run tests with other awk
>>>> implementations,
>>>> so I cannot tell whether \012 is needed at all (\r is not a new
>>>> invention).
>>>> Do all awk versions support regular expressions with characters in
>>>> octal encoding?.
>>>>
>>>> Perhaps we can wait several days for feedback from users with an old
>>>> awk
>>>> and apply the patch if there is none.
>>>
>>> I have an open bug ticket wrt configure being broken on Solaris 10
>>> due to tracing shell incompatibilities.
>>>
>>> If you provide a small self-contained example I can check though.
>>>
>>> Andreas
>>
>>
>> Example (needs bash's echo -e):
>>
>> # create line with crlf ending:
>> echo -e 'include xy\r' >file
>>
>> # returns xy\r:
>> awk '/^include / {ORS=" "; print $2}' file | od
>
> 0000000 074570 020015
> 0000004
>
>> # should return xy:
>> awk '/^include / {ORS=" "; sub(/\r$/, "", $2); print $2}' file | od
>
> awk: syntax error near line 1
> awk: illegal statement near line 1
> 0000000
Can you try \015 instead of \r?
Paolo
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-17 21:25 ` Paolo Bonzini
@ 2010-12-17 22:17 ` Andreas Färber
2010-12-17 23:24 ` Paolo Bonzini
0 siblings, 1 reply; 26+ messages in thread
From: Andreas Färber @ 2010-12-17 22:17 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: QEMU Developers
Am 17.12.2010 um 22:25 schrieb Paolo Bonzini:
> On 12/17/2010 10:00 PM, Andreas Färber wrote:
>> Am 17.12.2010 um 20:54 schrieb Stefan Weil:
>>
>>> Am 17.12.2010 20:33, schrieb Andreas Färber:
>>>> Am 17.12.2010 um 20:01 schrieb Stefan Weil:
>>>>
>>>>> Am 17.12.2010 14:44, schrieb Paolo Bonzini:
>>>>>> On 12/17/2010 02:34 PM, Andreas Färber wrote:
>>>>>>>>>
>>>>>>>>> Fix this by removing any \r at end of line.
>>>>>>>>
>>>>>>>> Why isn't cygwin (or whatever you're using) removing it?
>>>>>>>
>>>>>>> I believe Cygwin had an option to choose the line ending style
>>>>>>> once
>>>>>>> during setup. By default it uses Unix-style line endings.
>>>>>>> If someone edits source files in some Windows editor, the
>>>>>>> above issue
>>>>>>> seems likely.
>>>>>>
>>>>>> Hmm, MSYS is more problematic: the manual says "In the MSYS
>>>>>> environment under Windows, `gawk' automatically uses binary mode
>>>>>> for reading and writing files. Thus there is no need to use the
>>>>>> `BINMODE' variable. This can cause problems with other Unix-like
>>>>>> components that have been ported to Windows that expect `gawk' to
>>>>>> do automatic translationof `"\r\n"', since it won't.".
>>>>>
>>>>> I had the \r problem when using msys. There seem to be several
>>>>> factors:
>>>>>
>>>>> * git configuration (add CR / don't add CR)
>>>>> * msys mount options (binmode / textmode)
>>>>> * (g)awk (read binary)
>>>>>
>>>>>>
>>>>>>> My awk foo is insufficient to ack the patch but if it doesn't
>>>>>>> break
>>>>>>> Unices it looks reasonable to me.
>>>>>>
>>>>>> I'd be worried a bit about Solaris and other proprietary OSes
>>>>>> with
>>>>>> prehistoric Unix utilities. Perhaps using \012 instead of \r is
>>>>>> better.
>>>>>>
>>>>>> Paolo
>>>>>
>>>>> I currently have no possibility to run tests with other awk
>>>>> implementations,
>>>>> so I cannot tell whether \012 is needed at all (\r is not a new
>>>>> invention).
>>>>> Do all awk versions support regular expressions with characters in
>>>>> octal encoding?.
>>>>>
>>>>> Perhaps we can wait several days for feedback from users with an
>>>>> old
>>>>> awk
>>>>> and apply the patch if there is none.
>>>>
>>>> I have an open bug ticket wrt configure being broken on Solaris 10
>>>> due to tracing shell incompatibilities.
>>>>
>>>> If you provide a small self-contained example I can check though.
>>>>
>>>> Andreas
>>>
>>>
>>> Example (needs bash's echo -e):
>>>
>>> # create line with crlf ending:
>>> echo -e 'include xy\r' >file
>>>
>>> # returns xy\r:
>>> awk '/^include / {ORS=" "; print $2}' file | od
>>
>> 0000000 074570 020015
>> 0000004
>>
>>> # should return xy:
>>> awk '/^include / {ORS=" "; sub(/\r$/, "", $2); print $2}' file | od
>>
>> awk: syntax error near line 1
>> awk: illegal statement near line 1
>> 0000000
>
> Can you try \015 instead of \r?
Same.
Andreas
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-17 22:17 ` Andreas Färber
@ 2010-12-17 23:24 ` Paolo Bonzini
2010-12-18 10:19 ` Stefan Weil
0 siblings, 1 reply; 26+ messages in thread
From: Paolo Bonzini @ 2010-12-17 23:24 UTC (permalink / raw)
To: Andreas Färber; +Cc: QEMU Developers
On 12/17/2010 11:17 PM, Andreas Färber wrote:
>>>> Example (needs bash's echo -e):
>>>>
>>>> # create line with crlf ending:
>>>> echo -e 'include xy\r' >file
>>>>
>>>> # returns xy\r:
>>>> awk '/^include / {ORS=" "; print $2}' file | od
>>>
>>> 0000000 074570 020015
>>> 0000004
>>>
>>>> # should return xy:
>>>> awk '/^include / {ORS=" "; sub(/\r$/, "", $2); print $2}' file | od
>>>
>>> awk: syntax error near line 1
>>> awk: illegal statement near line 1
>>> 0000000
>>
>> Can you try \015 instead of \r?
>
> Same.
Then I guess Stefan should use
tr -d '\015' < file | awk '/^include / {ORS=" "; print $2}'
or something like that.
Paolo
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-17 23:24 ` Paolo Bonzini
@ 2010-12-18 10:19 ` Stefan Weil
2010-12-18 12:02 ` Andreas Färber
0 siblings, 1 reply; 26+ messages in thread
From: Stefan Weil @ 2010-12-18 10:19 UTC (permalink / raw)
To: Andreas Färber; +Cc: Paolo Bonzini, QEMU Developers
Am 18.12.2010 00:24, schrieb Paolo Bonzini:
> On 12/17/2010 11:17 PM, Andreas Färber wrote:
>>>>> Example (needs bash's echo -e):
>>>>>
>>>>> # create line with crlf ending:
>>>>> echo -e 'include xy\r' >file
>>>>>
>>>>> # returns xy\r:
>>>>> awk '/^include / {ORS=" "; print $2}' file | od
>>>>
>>>> 0000000 074570 020015
>>>> 0000004
>>>>
>>>>> # should return xy:
>>>>> awk '/^include / {ORS=" "; sub(/\r$/, "", $2); print $2}' file | od
>>>>
>>>> awk: syntax error near line 1
>>>> awk: illegal statement near line 1
>>>> 0000000
>>>
>>> Can you try \015 instead of \r?
>>
>> Same.
>
> Then I guess Stefan should use
>
> tr -d '\015' < file | awk '/^include / {ORS=" "; print $2}'
>
> or something like that.
>
> Paolo
Andreas, please try this variant of Paolo's suggestion:
tr -d '\r' file | awk '/^include / {ORS=" "; print $2}' | od -c
I found some SunOS man pages online: tr should work with
'\r', and awk does not support the sub function (therefore
you always got a syntax error).
If the new code works, I'll send a modified patch.
Thanks,
Stefan
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-18 10:19 ` Stefan Weil
@ 2010-12-18 12:02 ` Andreas Färber
2010-12-18 14:20 ` Stefan Weil
0 siblings, 1 reply; 26+ messages in thread
From: Andreas Färber @ 2010-12-18 12:02 UTC (permalink / raw)
To: Stefan Weil; +Cc: Paolo Bonzini, QEMU Developers
Am 18.12.2010 um 11:19 schrieb Stefan Weil:
> Am 18.12.2010 00:24, schrieb Paolo Bonzini:
>> On 12/17/2010 11:17 PM, Andreas Färber wrote:
>>>>>> Example (needs bash's echo -e):
>>>>>>
>>>>>> # create line with crlf ending:
>>>>>> echo -e 'include xy\r' >file
>>>>>>
>>>>>> # returns xy\r:
>>>>>> awk '/^include / {ORS=" "; print $2}' file | od
>>>>>
>>>>> 0000000 074570 020015
>>>>> 0000004
>>>>>
>>>>>> # should return xy:
>>>>>> awk '/^include / {ORS=" "; sub(/\r$/, "", $2); print $2}' file
>>>>>> | od
>>>>>
>>>>> awk: syntax error near line 1
>>>>> awk: illegal statement near line 1
>>>>> 0000000
>>>>
>>>> Can you try \015 instead of \r?
>>>
>>> Same.
>>
>> Then I guess Stefan should use
>>
>> tr -d '\015' < file | awk '/^include / {ORS=" "; print $2}'
>>
>> or something like that.
>>
>> Paolo
>
>
> Andreas, please try this variant of Paolo's suggestion:
>
> tr -d '\r' file | awk '/^include / {ORS=" "; print $2}' | od -c
Like that, the tr hangs. The following works better:
bash-3.00$ tr -d '\r' < file | awk '/^include / {ORS=" "; print $2}' |
od -c
0000000 x y
0000003
Andreas
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] win32: Fix CRLF problem in make_device_config.sh
2010-12-18 12:02 ` Andreas Färber
@ 2010-12-18 14:20 ` Stefan Weil
0 siblings, 0 replies; 26+ messages in thread
From: Stefan Weil @ 2010-12-18 14:20 UTC (permalink / raw)
To: Andreas Färber; +Cc: QEMU Developers
Am 18.12.2010 13:02, schrieb Andreas Färber:
> Am 18.12.2010 um 11:19 schrieb Stefan Weil:
>
>> Am 18.12.2010 00:24, schrieb Paolo Bonzini:
>>> On 12/17/2010 11:17 PM, Andreas Färber wrote:
>>>>>>> Example (needs bash's echo -e):
>>>>>>>
>>>>>>> # create line with crlf ending:
>>>>>>> echo -e 'include xy\r' >file
>>>>>>>
>>>>>>> # returns xy\r:
>>>>>>> awk '/^include / {ORS=" "; print $2}' file | od
>>>>>>
>>>>>> 0000000 074570 020015
>>>>>> 0000004
>>>>>>
>>>>>>> # should return xy:
>>>>>>> awk '/^include / {ORS=" "; sub(/\r$/, "", $2); print $2}' file | od
>>>>>>
>>>>>> awk: syntax error near line 1
>>>>>> awk: illegal statement near line 1
>>>>>> 0000000
>>>>>
>>>>> Can you try \015 instead of \r?
>>>>
>>>> Same.
>>>
>>> Then I guess Stefan should use
>>>
>>> tr -d '\015' < file | awk '/^include / {ORS=" "; print $2}'
>>>
>>> or something like that.
>>>
>>> Paolo
>>
>>
>> Andreas, please try this variant of Paolo's suggestion:
>>
>> tr -d '\r' file | awk '/^include / {ORS=" "; print $2}' | od -c
>
> Like that, the tr hangs. The following works better:
>
> bash-3.00$ tr -d '\r' < file | awk '/^include / {ORS=" "; print $2}' |
> od -c
> 0000000 x y
> 0000003
>
> Andreas
Mea culpa. Of course tr expects its data from stdin - the '<' got lost
when I wrote the mail.
Thanks for the testing.
Stefan
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh
2010-12-16 21:52 [Qemu-devel] [PATCH] win32: Fix CRLF problem in make_device_config.sh Stefan Weil
2010-12-16 22:42 ` [Qemu-devel] " Paolo Bonzini
@ 2010-12-18 16:34 ` Stefan Weil
2010-12-18 17:09 ` Andreas Färber
1 sibling, 1 reply; 26+ messages in thread
From: Stefan Weil @ 2010-12-18 16:34 UTC (permalink / raw)
To: QEMU Developers
QEMU source code with CRLF line endings
which is quite common on windows hosts
fails with current make_device_config.sh.
The awk script gets the name of the included
file with \r, so instead of pci.mak it will
search for pci.mak\r which of course does
not work.
Fix this by removing any \r.
v2:
Avoid using sub() and \r with awk because they are unsupported
on some platforms. Use tr to remove \r. This new solution
improves portability and was suggested by Paolo Bonzini.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
make_device_config.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/make_device_config.sh b/make_device_config.sh
index 8abadfe..596fc5b 100644
--- a/make_device_config.sh
+++ b/make_device_config.sh
@@ -18,7 +18,7 @@ process_includes () {
f=$src
while [ -n "$f" ] ; do
- f=`awk '/^include / {ORS=" " ; print "'$src_dir'/" $2}' $f`
+ f=`tr -d '\r' < $f | awk '/^include / {ORS=" "; print "'$src_dir'/" $2}'`
[ $? = 0 ] || exit 1
all_includes="$all_includes $f"
done
--
1.7.2.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh
2010-12-18 16:34 ` [Qemu-devel] [PATCH v2] " Stefan Weil
@ 2010-12-18 17:09 ` Andreas Färber
2010-12-18 18:59 ` Blue Swirl
0 siblings, 1 reply; 26+ messages in thread
From: Andreas Färber @ 2010-12-18 17:09 UTC (permalink / raw)
To: Stefan Weil; +Cc: QEMU Developers
Am 18.12.2010 um 17:34 schrieb Stefan Weil:
> QEMU source code with CRLF line endings
> which is quite common on windows hosts
> fails with current make_device_config.sh.
>
> The awk script gets the name of the included
> file with \r, so instead of pci.mak it will
> search for pci.mak\r which of course does
> not work.
>
> Fix this by removing any \r.
>
> v2:
> Avoid using sub() and \r with awk because they are unsupported
> on some platforms. Use tr to remove \r. This new solution
> improves portability and was suggested by Paolo Bonzini.
>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Acked-by: Andreas Färber <andreas.faerber@web.de>
> ---
> make_device_config.sh | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/make_device_config.sh b/make_device_config.sh
> index 8abadfe..596fc5b 100644
> --- a/make_device_config.sh
> +++ b/make_device_config.sh
> @@ -18,7 +18,7 @@ process_includes () {
>
> f=$src
> while [ -n "$f" ] ; do
> - f=`awk '/^include / {ORS=" " ; print "'$src_dir'/" $2}' $f`
> + f=`tr -d '\r' < $f | awk '/^include / {ORS=" "; print
> "'$src_dir'/" $2}'`
> [ $? = 0 ] || exit 1
> all_includes="$all_includes $f"
> done
> --
> 1.7.2.3
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh
2010-12-18 17:09 ` Andreas Färber
@ 2010-12-18 18:59 ` Blue Swirl
2010-12-19 15:42 ` Stefan Weil
0 siblings, 1 reply; 26+ messages in thread
From: Blue Swirl @ 2010-12-18 18:59 UTC (permalink / raw)
To: Andreas Färber; +Cc: QEMU Developers
Thanks, applied.
On Sat, Dec 18, 2010 at 5:09 PM, Andreas Färber <andreas.faerber@web.de> wrote:
> Am 18.12.2010 um 17:34 schrieb Stefan Weil:
>
>> QEMU source code with CRLF line endings
>> which is quite common on windows hosts
>> fails with current make_device_config.sh.
>>
>> The awk script gets the name of the included
>> file with \r, so instead of pci.mak it will
>> search for pci.mak\r which of course does
>> not work.
>>
>> Fix this by removing any \r.
>>
>> v2:
>> Avoid using sub() and \r with awk because they are unsupported
>> on some platforms. Use tr to remove \r. This new solution
>> improves portability and was suggested by Paolo Bonzini.
>>
>> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
>
> Acked-by: Andreas Färber <andreas.faerber@web.de>
>
>> ---
>> make_device_config.sh | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/make_device_config.sh b/make_device_config.sh
>> index 8abadfe..596fc5b 100644
>> --- a/make_device_config.sh
>> +++ b/make_device_config.sh
>> @@ -18,7 +18,7 @@ process_includes () {
>>
>> f=$src
>> while [ -n "$f" ] ; do
>> - f=`awk '/^include / {ORS=" " ; print "'$src_dir'/" $2}' $f`
>> + f=`tr -d '\r' < $f | awk '/^include / {ORS=" "; print "'$src_dir'/"
>> $2}'`
>> [ $? = 0 ] || exit 1
>> all_includes="$all_includes $f"
>> done
>> --
>> 1.7.2.3
>
>
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh
2010-12-18 18:59 ` Blue Swirl
@ 2010-12-19 15:42 ` Stefan Weil
2010-12-19 16:06 ` Andreas Färber
2010-12-19 16:21 ` [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh Blue Swirl
0 siblings, 2 replies; 26+ messages in thread
From: Stefan Weil @ 2010-12-19 15:42 UTC (permalink / raw)
To: Andreas Färber; +Cc: Blue Swirl, Paolo Bonzini, QEMU Developers
Am 18.12.2010 19:59, schrieb Blue Swirl:
> Thanks, applied.
>
> On Sat, Dec 18, 2010 at 5:09 PM, Andreas Färber
> <andreas.faerber@web.de> wrote:
>> Am 18.12.2010 um 17:34 schrieb Stefan Weil:
>>
>>> QEMU source code with CRLF line endings
>>> which is quite common on windows hosts
>>> fails with current make_device_config.sh.
>>>
>>> The awk script gets the name of the included
>>> file with \r, so instead of pci.mak it will
>>> search for pci.mak\r which of course does
>>> not work.
>>>
>>> Fix this by removing any \r.
>>>
>>> v2:
>>> Avoid using sub() and \r with awk because they are unsupported
>>> on some platforms. Use tr to remove \r. This new solution
>>> improves portability and was suggested by Paolo Bonzini.
>>>
>>> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
>>
>> Acked-by: Andreas Färber <andreas.faerber@web.de>
>>> ---
>>> make_device_config.sh | 2 +-
>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/make_device_config.sh b/make_device_config.sh
>>> index 8abadfe..596fc5b 100644
>>> --- a/make_device_config.sh
>>> +++ b/make_device_config.sh
>>> @@ -18,7 +18,7 @@ process_includes () {
>>>
>>> f=$src
>>> while [ -n "$f" ] ; do
>>> - f=`awk '/^include / {ORS=" " ; print "'$src_dir'/" $2}' $f`
>>> + f=`tr -d '\r' < $f | awk '/^include / {ORS=" "; print "'$src_dir'/"
>>> $2}'`
>>> [ $? = 0 ] || exit 1
>>> all_includes="$all_includes $f"
>>> done
>>> --
>>> 1.7.2.3
The new code raises a new problem (sorry that I did not detect it earlier):
On hosts with /bin/sh != bash, make displays an error from
make_device_config.sh:
$ touch default-configs/i386-softmmu.mak
$ make
GEN i386-softmmu/config-devices.mak
/qemu/make_device_config.sh: 24: cannot open
/qemu/default-configs/pci.mak : No such file
make continues, so the error message is not fatal but a cosmetical issue.
It took me some time to find the reason for this error message although
it is quite simple:
The filename f which is calculated using awk ends with a blank character
caused by ORS=" ".
Obviously this blank does not matter for bash and other shells when
$f is used as a parameter. I/O redirection with bash works, too.
But dash (and perhaps other simple shells) work different. For dash,
< $f works like < "$f", so the blank is part of the filename,
and "pci.mak " of course does not exist. Is this a dash bug or a feature?
Using ORS="" solves the problem for me, but might raise new compatibility
problems (is an empty records separator always supported?).
Andreas, may I ask you for one more test?
$ echo -e 'include xy\r' | tr -d '\r' | awk '/^include / {ORS=""; print
$2}' | od -c
It should return 0000002, not 0000003 like the previous test:
0000000 x y
0000002
Regards,
Stefan
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh
2010-12-19 15:42 ` Stefan Weil
@ 2010-12-19 16:06 ` Andreas Färber
2010-12-20 10:37 ` Paolo Bonzini
2010-12-30 21:53 ` Andreas Färber
2010-12-19 16:21 ` [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh Blue Swirl
1 sibling, 2 replies; 26+ messages in thread
From: Andreas Färber @ 2010-12-19 16:06 UTC (permalink / raw)
To: Stefan Weil; +Cc: Blue Swirl, Paolo Bonzini, QEMU Developers
Am 19.12.2010 um 16:42 schrieb Stefan Weil:
> Am 18.12.2010 19:59, schrieb Blue Swirl:
>> Thanks, applied.
>>
>> On Sat, Dec 18, 2010 at 5:09 PM, Andreas Färber <andreas.faerber@web.de
>> > wrote:
>>> Am 18.12.2010 um 17:34 schrieb Stefan Weil:
>>>
>>>> QEMU source code with CRLF line endings
>>>> which is quite common on windows hosts
>>>> fails with current make_device_config.sh.
>>>>
>>>> The awk script gets the name of the included
>>>> file with \r, so instead of pci.mak it will
>>>> search for pci.mak\r which of course does
>>>> not work.
>>>>
>>>> Fix this by removing any \r.
>>>>
>>>> v2:
>>>> Avoid using sub() and \r with awk because they are unsupported
>>>> on some platforms. Use tr to remove \r. This new solution
>>>> improves portability and was suggested by Paolo Bonzini.
>>>>
>>>> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
>>>
>>> Acked-by: Andreas Färber <andreas.faerber@web.de>
>>>> ---
>>>> make_device_config.sh | 2 +-
>>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/make_device_config.sh b/make_device_config.sh
>>>> index 8abadfe..596fc5b 100644
>>>> --- a/make_device_config.sh
>>>> +++ b/make_device_config.sh
>>>> @@ -18,7 +18,7 @@ process_includes () {
>>>>
>>>> f=$src
>>>> while [ -n "$f" ] ; do
>>>> - f=`awk '/^include / {ORS=" " ; print "'$src_dir'/" $2}' $f`
>>>> + f=`tr -d '\r' < $f | awk '/^include / {ORS=" "; print
>>>> "'$src_dir'/"
>>>> $2}'`
>>>> [ $? = 0 ] || exit 1
>>>> all_includes="$all_includes $f"
>>>> done
>>>> --
>>>> 1.7.2.3
>
> The new code raises a new problem (sorry that I did not detect it
> earlier):
>
> On hosts with /bin/sh != bash, make displays an error from
> make_device_config.sh:
>
> $ touch default-configs/i386-softmmu.mak
> $ make
> GEN i386-softmmu/config-devices.mak
> /qemu/make_device_config.sh: 24: cannot open /qemu/default-configs/
> pci.mak : No such file
>
> make continues, so the error message is not fatal but a cosmetical
> issue.
I'm pretty sure I saw that with some bash, too. Possibly on Haiku.
Anyway...
> It took me some time to find the reason for this error message
> although
> it is quite simple:
>
> The filename f which is calculated using awk ends with a blank
> character
> caused by ORS=" ".
>
> Obviously this blank does not matter for bash and other shells when
> $f is used as a parameter. I/O redirection with bash works, too.
> But dash (and perhaps other simple shells) work different. For dash,
> < $f works like < "$f", so the blank is part of the filename,
> and "pci.mak " of course does not exist. Is this a dash bug or a
> feature?
>
> Using ORS="" solves the problem for me, but might raise new
> compatibility
> problems (is an empty records separator always supported?).
>
> Andreas, may I ask you for one more test?
>
> $ echo -e 'include xy\r' | tr -d '\r' | awk '/^include / {ORS="";
> print $2}' | od -c
>
> It should return 0000002, not 0000003 like the previous test:
>
> 0000000 x y
> 0000002
Tested-by: Andreas Färber <andreas.faerber@web.de>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh
2010-12-19 15:42 ` Stefan Weil
2010-12-19 16:06 ` Andreas Färber
@ 2010-12-19 16:21 ` Blue Swirl
2010-12-19 16:43 ` Andreas Färber
1 sibling, 1 reply; 26+ messages in thread
From: Blue Swirl @ 2010-12-19 16:21 UTC (permalink / raw)
To: Stefan Weil; +Cc: Paolo Bonzini, Andreas Färber, QEMU Developers
On Sun, Dec 19, 2010 at 3:42 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Am 18.12.2010 19:59, schrieb Blue Swirl:
>>
>> Thanks, applied.
>>
>> On Sat, Dec 18, 2010 at 5:09 PM, Andreas Färber <andreas.faerber@web.de>
>> wrote:
>>>
>>> Am 18.12.2010 um 17:34 schrieb Stefan Weil:
>>>
>>>> QEMU source code with CRLF line endings
>>>> which is quite common on windows hosts
>>>> fails with current make_device_config.sh.
>>>>
>>>> The awk script gets the name of the included
>>>> file with \r, so instead of pci.mak it will
>>>> search for pci.mak\r which of course does
>>>> not work.
>>>>
>>>> Fix this by removing any \r.
>>>>
>>>> v2:
>>>> Avoid using sub() and \r with awk because they are unsupported
>>>> on some platforms. Use tr to remove \r. This new solution
>>>> improves portability and was suggested by Paolo Bonzini.
>>>>
>>>> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
>>>
>>> Acked-by: Andreas Färber <andreas.faerber@web.de>
>>>>
>>>> ---
>>>> make_device_config.sh | 2 +-
>>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/make_device_config.sh b/make_device_config.sh
>>>> index 8abadfe..596fc5b 100644
>>>> --- a/make_device_config.sh
>>>> +++ b/make_device_config.sh
>>>> @@ -18,7 +18,7 @@ process_includes () {
>>>>
>>>> f=$src
>>>> while [ -n "$f" ] ; do
>>>> - f=`awk '/^include / {ORS=" " ; print "'$src_dir'/" $2}' $f`
>>>> + f=`tr -d '\r' < $f | awk '/^include / {ORS=" "; print "'$src_dir'/"
>>>> $2}'`
>>>> [ $? = 0 ] || exit 1
>>>> all_includes="$all_includes $f"
>>>> done
>>>> --
>>>> 1.7.2.3
>
> The new code raises a new problem (sorry that I did not detect it earlier):
>
> On hosts with /bin/sh != bash, make displays an error from
> make_device_config.sh:
>
> $ touch default-configs/i386-softmmu.mak
> $ make
> GEN i386-softmmu/config-devices.mak
> /qemu/make_device_config.sh: 24: cannot open /qemu/default-configs/pci.mak :
> No such file
>
> make continues, so the error message is not fatal but a cosmetical issue.
> It took me some time to find the reason for this error message although
> it is quite simple:
>
> The filename f which is calculated using awk ends with a blank character
> caused by ORS=" ".
>
> Obviously this blank does not matter for bash and other shells when
> $f is used as a parameter. I/O redirection with bash works, too.
> But dash (and perhaps other simple shells) work different. For dash,
> < $f works like < "$f", so the blank is part of the filename,
> and "pci.mak " of course does not exist. Is this a dash bug or a feature?
>
> Using ORS="" solves the problem for me, but might raise new compatibility
> problems (is an empty records separator always supported?).
>
> Andreas, may I ask you for one more test?
>
> $ echo -e 'include xy\r' | tr -d '\r' | awk '/^include / {ORS=""; print $2}'
> | od -c
>
> It should return 0000002, not 0000003 like the previous test:
>
> 0000000 x y
> 0000002
How about something like this instead:
(SRC_DIR=/src; echo -e 'include xy' | sed -n 's|^include
*\(.*\)|'$SRC_DIR/'\1|p')
/src/xy
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh
2010-12-19 16:21 ` [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh Blue Swirl
@ 2010-12-19 16:43 ` Andreas Färber
0 siblings, 0 replies; 26+ messages in thread
From: Andreas Färber @ 2010-12-19 16:43 UTC (permalink / raw)
To: Blue Swirl; +Cc: QEMU Developers, Paolo Bonzini
Am 19.12.2010 um 17:21 schrieb Blue Swirl:
> On Sun, Dec 19, 2010 at 3:42 PM, Stefan Weil <weil@mail.berlios.de>
> wrote:
>> Am 18.12.2010 19:59, schrieb Blue Swirl:
>>>
>>> Thanks, applied.
>>>
>>> On Sat, Dec 18, 2010 at 5:09 PM, Andreas Färber <andreas.faerber@web.de
>>> >
>>> wrote:
>>>>
>>>> Am 18.12.2010 um 17:34 schrieb Stefan Weil:
>>>>
>>>>> QEMU source code with CRLF line endings
>>>>> which is quite common on windows hosts
>>>>> fails with current make_device_config.sh.
>>>>>
>>>>> The awk script gets the name of the included
>>>>> file with \r, so instead of pci.mak it will
>>>>> search for pci.mak\r which of course does
>>>>> not work.
>>>>>
>>>>> Fix this by removing any \r.
>>>>>
>>>>> v2:
>>>>> Avoid using sub() and \r with awk because they are unsupported
>>>>> on some platforms. Use tr to remove \r. This new solution
>>>>> improves portability and was suggested by Paolo Bonzini.
>>>>>
>>>>> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
>>>>
>>>> Acked-by: Andreas Färber <andreas.faerber@web.de>
>>>>>
>>>>> ---
>>>>> make_device_config.sh | 2 +-
>>>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>>>
>>>>> diff --git a/make_device_config.sh b/make_device_config.sh
>>>>> index 8abadfe..596fc5b 100644
>>>>> --- a/make_device_config.sh
>>>>> +++ b/make_device_config.sh
>>>>> @@ -18,7 +18,7 @@ process_includes () {
>>>>>
>>>>> f=$src
>>>>> while [ -n "$f" ] ; do
>>>>> - f=`awk '/^include / {ORS=" " ; print "'$src_dir'/" $2}' $f`
>>>>> + f=`tr -d '\r' < $f | awk '/^include / {ORS=" "; print
>>>>> "'$src_dir'/"
>>>>> $2}'`
>>>>> [ $? = 0 ] || exit 1
>>>>> all_includes="$all_includes $f"
>>>>> done
>>>>> --
>>>>> 1.7.2.3
>>
>> The new code raises a new problem (sorry that I did not detect it
>> earlier):
>>
>> On hosts with /bin/sh != bash, make displays an error from
>> make_device_config.sh:
>>
>> $ touch default-configs/i386-softmmu.mak
>> $ make
>> GEN i386-softmmu/config-devices.mak
>> /qemu/make_device_config.sh: 24: cannot open /qemu/default-configs/
>> pci.mak :
>> No such file
>>
>> make continues, so the error message is not fatal but a cosmetical
>> issue.
>> It took me some time to find the reason for this error message
>> although
>> it is quite simple:
>>
>> The filename f which is calculated using awk ends with a blank
>> character
>> caused by ORS=" ".
>>
>> Obviously this blank does not matter for bash and other shells when
>> $f is used as a parameter. I/O redirection with bash works, too.
>> But dash (and perhaps other simple shells) work different. For dash,
>> < $f works like < "$f", so the blank is part of the filename,
>> and "pci.mak " of course does not exist. Is this a dash bug or a
>> feature?
>>
>> Using ORS="" solves the problem for me, but might raise new
>> compatibility
>> problems (is an empty records separator always supported?).
>>
>> Andreas, may I ask you for one more test?
>>
>> $ echo -e 'include xy\r' | tr -d '\r' | awk '/^include / {ORS="";
>> print $2}'
>> | od -c
>>
>> It should return 0000002, not 0000003 like the previous test:
>>
>> 0000000 x y
>> 0000002
>
> How about something like this instead:
> (SRC_DIR=/src; echo -e 'include xy' | sed -n 's|^include
> *\(.*\)|'$SRC_DIR/'\1|p')
> /src/xy
Produces the above result on Sol10. With 'include xy\r' ... | od -c
leads to:
0000000 / s r c / x y \r \n
0000011
In bash.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh
2010-12-19 16:06 ` Andreas Färber
@ 2010-12-20 10:37 ` Paolo Bonzini
2010-12-30 21:53 ` Andreas Färber
1 sibling, 0 replies; 26+ messages in thread
From: Paolo Bonzini @ 2010-12-20 10:37 UTC (permalink / raw)
To: Andreas Färber; +Cc: Blue Swirl, QEMU Developers
On 12/19/2010 05:06 PM, Andreas Färber wrote:
>
> Andreas, may I ask you for one more test?
>
> $ echo -e 'include xy\r' | tr -d '\r' | awk '/^include / {ORS=""; print
> $2}' | od -c
I'd not bother with ORS and use '$1 == "include" { printf "%s", $2 }'
instead.
Paolo
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh
2010-12-19 16:06 ` Andreas Färber
2010-12-20 10:37 ` Paolo Bonzini
@ 2010-12-30 21:53 ` Andreas Färber
2010-12-30 22:04 ` [Qemu-devel] [PATCH] make_device_config: Fix non-fatal error message with dash and other shells Stefan Weil
1 sibling, 1 reply; 26+ messages in thread
From: Andreas Färber @ 2010-12-30 21:53 UTC (permalink / raw)
To: Stefan Weil, Blue Swirl; +Cc: Paolo Bonzini, QEMU Developers
Am 19.12.2010 um 17:06 schrieb Andreas Färber:
> Am 19.12.2010 um 16:42 schrieb Stefan Weil:
>
>> Am 18.12.2010 19:59, schrieb Blue Swirl:
>>> Thanks, applied.
>>>
>>> On Sat, Dec 18, 2010 at 5:09 PM, Andreas Färber <andreas.faerber@web.de
>>> > wrote:
>>>> Am 18.12.2010 um 17:34 schrieb Stefan Weil:
>>>>
>>>>> QEMU source code with CRLF line endings
>>>>> which is quite common on windows hosts
>>>>> fails with current make_device_config.sh.
>>>>>
>>>>> The awk script gets the name of the included
>>>>> file with \r, so instead of pci.mak it will
>>>>> search for pci.mak\r which of course does
>>>>> not work.
>>>>>
>>>>> Fix this by removing any \r.
>>>>>
>>>>> v2:
>>>>> Avoid using sub() and \r with awk because they are unsupported
>>>>> on some platforms. Use tr to remove \r. This new solution
>>>>> improves portability and was suggested by Paolo Bonzini.
>>>>>
>>>>> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
>>>>
>>>> Acked-by: Andreas Färber <andreas.faerber@web.de>
>>>>> ---
>>>>> make_device_config.sh | 2 +-
>>>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>>>
>>>>> diff --git a/make_device_config.sh b/make_device_config.sh
>>>>> index 8abadfe..596fc5b 100644
>>>>> --- a/make_device_config.sh
>>>>> +++ b/make_device_config.sh
>>>>> @@ -18,7 +18,7 @@ process_includes () {
>>>>>
>>>>> f=$src
>>>>> while [ -n "$f" ] ; do
>>>>> - f=`awk '/^include / {ORS=" " ; print "'$src_dir'/" $2}' $f`
>>>>> + f=`tr -d '\r' < $f | awk '/^include / {ORS=" "; print
>>>>> "'$src_dir'/"
>>>>> $2}'`
>>>>> [ $? = 0 ] || exit 1
>>>>> all_includes="$all_includes $f"
>>>>> done
>>>>> --
>>>>> 1.7.2.3
>>
>> The new code raises a new problem (sorry that I did not detect it
>> earlier):
>>
>> On hosts with /bin/sh != bash, make displays an error from
>> make_device_config.sh:
>>
>> $ touch default-configs/i386-softmmu.mak
>> $ make
>> GEN i386-softmmu/config-devices.mak
>> /qemu/make_device_config.sh: 24: cannot open /qemu/default-configs/
>> pci.mak : No such file
>>
>> make continues, so the error message is not fatal but a cosmetical
>> issue.
>
> I'm pretty sure I saw that with some bash, too. Possibly on Haiku.
I'm still seeing this issue, on Mac OS X with bash. And yes, on Haiku
with bash, too.
Any update?
Thanks,
Andreas
> Anyway...
>
>> It took me some time to find the reason for this error message
>> although
>> it is quite simple:
>>
>> The filename f which is calculated using awk ends with a blank
>> character
>> caused by ORS=" ".
>>
>> Obviously this blank does not matter for bash and other shells when
>> $f is used as a parameter. I/O redirection with bash works, too.
>> But dash (and perhaps other simple shells) work different. For dash,
>> < $f works like < "$f", so the blank is part of the filename,
>> and "pci.mak " of course does not exist. Is this a dash bug or a
>> feature?
>>
>> Using ORS="" solves the problem for me, but might raise new
>> compatibility
>> problems (is an empty records separator always supported?).
>>
>> Andreas, may I ask you for one more test?
>>
>> $ echo -e 'include xy\r' | tr -d '\r' | awk '/^include / {ORS="";
>> print $2}' | od -c
>>
>> It should return 0000002, not 0000003 like the previous test:
>>
>> 0000000 x y
>> 0000002
>
> Tested-by: Andreas Färber <andreas.faerber@web.de>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH] make_device_config: Fix non-fatal error message with dash and other shells
2010-12-30 21:53 ` Andreas Färber
@ 2010-12-30 22:04 ` Stefan Weil
2010-12-30 23:08 ` Andreas Färber
0 siblings, 1 reply; 26+ messages in thread
From: Stefan Weil @ 2010-12-30 22:04 UTC (permalink / raw)
To: QEMU Developers; +Cc: Blue Swirl, andreas.faerber
ORS=" " adds a blank to the name of the include file.
Some shells (e.g. dash) don't accept input redirection
(tr -d '\r' < $f) when $f ends with a blank, so they
print an error message instead of reading pci.mak.
This is a non-fatal error because pci.mak does not
contain an include line. It was introduced by commit
5d6b423c5cd6f9dfac30959ff1d5c088996719c3.
Using printf avoids adding a blank and is also supported
by older awk versions (this solution was suggested by
Paolo Bonzini, thank you).
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
make_device_config.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/make_device_config.sh b/make_device_config.sh
index 596fc5b..5d14885 100644
--- a/make_device_config.sh
+++ b/make_device_config.sh
@@ -18,7 +18,7 @@ process_includes () {
f=$src
while [ -n "$f" ] ; do
- f=`tr -d '\r' < $f | awk '/^include / {ORS=" "; print "'$src_dir'/" $2}'`
+ f=`tr -d '\r' < $f | awk '/^include / {printf "'$src_dir'/%s", $2}'`
[ $? = 0 ] || exit 1
all_includes="$all_includes $f"
done
--
1.7.2.3
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH] make_device_config: Fix non-fatal error message with dash and other shells
2010-12-30 22:04 ` [Qemu-devel] [PATCH] make_device_config: Fix non-fatal error message with dash and other shells Stefan Weil
@ 2010-12-30 23:08 ` Andreas Färber
0 siblings, 0 replies; 26+ messages in thread
From: Andreas Färber @ 2010-12-30 23:08 UTC (permalink / raw)
To: Stefan Weil; +Cc: Blue Swirl, QEMU Developers
Am 30.12.2010 um 23:04 schrieb Stefan Weil:
> ORS=" " adds a blank to the name of the include file.
> Some shells (e.g. dash) don't accept input redirection
> (tr -d '\r' < $f) when $f ends with a blank, so they
> print an error message instead of reading pci.mak.
> This is a non-fatal error because pci.mak does not
> contain an include line. It was introduced by commit
> 5d6b423c5cd6f9dfac30959ff1d5c088996719c3.
>
> Using printf avoids adding a blank and is also supported
> by older awk versions (this solution was suggested by
> Paolo Bonzini, thank you).
>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Tested-by: Andreas Färber <andreas.faerber@web.de>
`make defconfig; make` working fine on Mac OS X now!
Thanks,
Andreas
> ---
> make_device_config.sh | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/make_device_config.sh b/make_device_config.sh
> index 596fc5b..5d14885 100644
> --- a/make_device_config.sh
> +++ b/make_device_config.sh
> @@ -18,7 +18,7 @@ process_includes () {
>
> f=$src
> while [ -n "$f" ] ; do
> - f=`tr -d '\r' < $f | awk '/^include / {ORS=" "; print
> "'$src_dir'/" $2}'`
> + f=`tr -d '\r' < $f | awk '/^include / {printf "'$src_dir'/%s",
> $2}'`
> [ $? = 0 ] || exit 1
> all_includes="$all_includes $f"
> done
> --
> 1.7.2.3
>
>
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2010-12-30 23:09 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-16 21:52 [Qemu-devel] [PATCH] win32: Fix CRLF problem in make_device_config.sh Stefan Weil
2010-12-16 22:42 ` [Qemu-devel] " Paolo Bonzini
2010-12-17 13:34 ` Andreas Färber
2010-12-17 13:44 ` Paolo Bonzini
2010-12-17 19:01 ` Stefan Weil
2010-12-17 19:33 ` Andreas Färber
2010-12-17 19:54 ` Stefan Weil
2010-12-17 21:00 ` Andreas Färber
2010-12-17 21:25 ` Paolo Bonzini
2010-12-17 22:17 ` Andreas Färber
2010-12-17 23:24 ` Paolo Bonzini
2010-12-18 10:19 ` Stefan Weil
2010-12-18 12:02 ` Andreas Färber
2010-12-18 14:20 ` Stefan Weil
2010-12-17 20:08 ` Paolo Bonzini
2010-12-18 16:34 ` [Qemu-devel] [PATCH v2] " Stefan Weil
2010-12-18 17:09 ` Andreas Färber
2010-12-18 18:59 ` Blue Swirl
2010-12-19 15:42 ` Stefan Weil
2010-12-19 16:06 ` Andreas Färber
2010-12-20 10:37 ` Paolo Bonzini
2010-12-30 21:53 ` Andreas Färber
2010-12-30 22:04 ` [Qemu-devel] [PATCH] make_device_config: Fix non-fatal error message with dash and other shells Stefan Weil
2010-12-30 23:08 ` Andreas Färber
2010-12-19 16:21 ` [Qemu-devel] [PATCH v2] win32: Fix CRLF problem in make_device_config.sh Blue Swirl
2010-12-19 16:43 ` Andreas Färber
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 NNTP newsgroup(s).