Ignore all Carriage Returns when importing an environment.
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
This is used for compatibility with text files which are using CRLF instead of LF as the end of a line.
--- lib/hashtable.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-)
lib/hashtable.c +15 -3
@@ -623,9 +623,9 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep,* (entries separated by newline characters). * * To allow for nicely formatted text input, leading white space -* (sequences of SPACE and TAB chars) is ignored, and entries starting -* (after removal of any leading white space) with a '#' character are -* considered comments and ignored. +* (sequences of SPACE and TAB chars) is ignored, all Carriage Returns +* are ignored and entries starting (after removal of any leading white +* space) with a '#' character are considered comments and ignored. * * [NOTE: this means that a variable name cannot start with a '#' * character.]
@@ -642,6 +642,7 @@ int himport_r(struct hsearch_data *htab, const char *env, size_t size, const char sep, int flag) { char *data, *sp, *dp, *name, *value; +unsigned ignored_crs;/* Test for correct arguments. */ if (htab ==NULL ) {
@@ -698,6 +699,17 @@ int himport_r(struct hsearch_data *htab, } } +/* Remove all Carriage Returns */ + ignored_crs =0 ; +for (;dp < data + size && *dp; ++dp) { +if ( *dp =='\r' ) + ++ignored_crs; +else if (ignored_crs) + *(dp-ignored_crs) = *dp; + } + size -= ignored_crs; + dp = data; +/* Parse environment; allow for '\0' and 'sep' as separators */ do { ENTRY e, *rv;
Signature · 1 line
1.7.3.4
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Dear Alexander Holler,
Quoted 2 lines · In message <[email protected]> you wrote:
This is used for compatibility with text files which are using CRLF instead of LF as the end of a line.
I don't think we should do this. If you have text files with CR-LF line endings, then please use external tools (like dos2unix) to filter these and bring them into the appropriate format.
I would like to put as little restrictions on the content of an environment variable as possible. I can see valid use for strings that contain a CR character.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de There is, however, a strange, musty smell in the air that reminds me of something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit. - Larry Wall in Configure from the perl distribution
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Am 11.05.2012 21:09, schrieb Wolfgang Denk:
Quoted 6 lines
Dear Alexander Holler,
Quoted 2 lines · In message<[email protected]> you wrote:
This is used for compatibility with text files which are using CRLF instead of LF as the end of a line.
Quoted 7 lines
I don't think we should do this. If you have text files with CR-LF line endings, then please use external tools (like dos2unix) to filter these and bring them into the appropriate format.
I would like to put as little restrictions on the content of an environment variable as possible. I can see valid use for strings that contain a CR character.
I don't see any reasonable usage for carriage returns in imported environment variables, but I've seen many people from the windows camp struggling in writing small text files to set some environment variables (which mostly end up in the kernel cmdline). Especially because those CR's often will lead to obscure errors because almost nothing (in u-boot or linux) is able to handle them.
Anyway I don't really care, I just found it very user friendly to strip the carriage returns, especially for those embedded newbies which are in need to use some unnamed windows IDE.
So I've decided (after having that patch lying around for about a year) to finally post it.
Regards,
Alexander
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Dear Alexander Holler,
Quoted 7 lines · In message <[email protected]> you wrote:
Quoted 4 lines
I would like to put as little restrictions on the content of an environment variable as possible. I can see valid use for strings that contain a CR character.
I don't see any reasonable usage for carriage returns in imported environment variables, but I've seen many people from the windows camp
A CR causes the output to re-start from start of line. I can construct all kind of fancy disply by using "echo $var" - especially so if "var" can contain control characters including CR. It makes no sense striiping these out.
Quoted 4 lines
struggling in writing small text files to set some environment variables (which mostly end up in the kernel cmdline). Especially because those CR's often will lead to obscure errors because almost nothing (in u-boot or linux) is able to handle them.
This is a problem that is as old as DOS, and solutions for this have been known since. I already mentioned dos2unix.
Quoted 6 lines
Anyway I don't really care, I just found it very user friendly to strip the carriage returns, especially for those embedded newbies which are in need to use some unnamed windows IDE.
So I've decided (after having that patch lying around for about a year) to finally post it.
Thanks - but it adds restrictions to doing perfectly valid things. I see the disadvantages significantly bigger than what we can win - keep in mind, that dealing wqith DOS line endings is a topic that is decades old.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You get a wonderful view from the point of no return.
- Terry Pratchett, _Making_Money_PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Hello,
Am 12.05.2012 23:18, schrieb Wolfgang Denk:
Quoted 4 lines
Thanks - but it adds restrictions to doing perfectly valid things. I see the disadvantages significantly bigger than what we can win - keep in mind, that dealing wqith DOS line endings is a topic that is decades old.
Not dealing with them too. ;)
Two other solutions come to mind: Expanding the if( '\r' ) so that it only removes CRs if they are before LF or make \r possible in import and use \r in export.
Regards,
Alexander
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Dear Alexander Holler,
Quoted 6 lines · In message <[email protected]> you wrote:
Not dealing with them too. ;)
Two other solutions come to mind: Expanding the if( '\r' ) so that it only removes CRs if they are before LF or make \r possible in import and use \r in export.
I think I would accept an option (configurable) to accept \r\n line endings when importing text input. For output, there shall always be \n only.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Too much of anything, even love, isn't necessarily a good thing. -- Kirk, "The Trouble with Tribbles", stardate 4525.6
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
In reply to Alexander HollerDear Alexander Holler,
Quoted 4 lines
This is used for compatibility with text files which are using CRLF instead of LF as the end of a line.
Signed-off-by Alexander Holler <[email protected]>
Why don't you run the file trough dos2unix or tr -d '\r' ?
Quoted 37 lines
--- lib/hashtable.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-)lib/hashtable.c +0
-0@@ -623,9 +623,9 @@ ssize_t hexport_r(struct hsearch_data *htab, const charsep, * (entries separated by newline characters).
*
* To allow for nicely formatted text input, leading white space
- * (sequences of SPACE and TAB chars) is ignored, and entries starting
- * (after removal of any leading white space) with a '#' character are
- * considered comments and ignored.
+ * (sequences of SPACE and TAB chars) is ignored, all Carriage Returns
+ * are ignored and entries starting (after removal of any leading white
+ * space) with a '#' character are considered comments and ignored. *
* [NOTE: this means that a variable name cannot start with a '#'
* character.]lib/hashtable.c +5
-0@@ -642,6 +642,7 @@ int himport_r(struct hsearch_data *htab, const char *env, size_t size, const char sep, int flag) { char *data, *sp, *dp, *name, *value; +unsigned ignored_crs;/* Test for correct arguments. */ if (htab ==NULL ) {@@ -698,6 +699,17 @@ int himport_r(struct hsearch_data *htab, } } +/* Remove all Carriage Returns */ + ignored_crs =0 ; +for (;dp < data + size && *dp; ++dp) { +if ( *dp =='\r' )
lib/hashtable.c int himport_r(struct hsearch_data *htab, · line 715
Quoted 10 lines
lib/hashtable.c +7
-0+ ++ignored_crs; + else if(ignored_crs) + *(dp-ignored_crs) = *dp; + } + size -= ignored_crs; + dp = data; +/* Parse environment; allow for '\0' and 'sep' as separators */ do { ENTRY e, *rv;
Best regards,
Marek Vasut
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Am 12.05.2012 08:17, schrieb Marek Vasut:
Quoted 8 lines
Dear Alexander Holler,
Quoted 4 lines
This is used for compatibility with text files which are using CRLF instead of LF as the end of a line.
Signed-off-by Alexander Holler<[email protected]>Why don't you run the file trough dos2unix or tr -d '\r' ?
Because my files don't contain CRs. ;)
Regards,
Alexander
Quoted 51 lines
Quoted 38 lines
--- lib/hashtable.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-)lib/hashtable.c +0
-0@@ -623,9 +623,9 @@ ssize_t hexport_r(struct hsearch_data *htab, const charsep, * (entries separated by newline characters).
*
* To allow for nicely formatted text input, leading white space
- * (sequences of SPACE and TAB chars) is ignored, and entries starting
- * (after removal of any leading white space) with a '#' character are
- * considered comments and ignored.
+ * (sequences of SPACE and TAB chars) is ignored, all Carriage Returns
+ * are ignored and entries starting (after removal of any leading white
+ * space) with a '#' character are considered comments and ignored. *
* [NOTE: this means that a variable name cannot start with a '#'
* character.]lib/hashtable.c +5
-0@@ -642,6 +642,7 @@ int himport_r(struct hsearch_data *htab, const char *env, size_t size, const char sep, int flag) { char *data, *sp, *dp, *name, *value; +unsigned ignored_crs;/* Test for correct arguments. */ if (htab ==NULL ) {@@ -698,6 +699,17 @@ int himport_r(struct hsearch_data *htab, } } +/* Remove all Carriage Returns */ + ignored_crs =0 ; +for (;dp< data + size&& *dp; ++dp) { +if ( *dp =='\r' )lib/hashtable.c int himport_r(struct hsearch_data *htab, · line 715
Quoted 10 lines
lib/hashtable.c +7
-0+ ++ignored_crs; + else if(ignored_crs) + *(dp-ignored_crs) = *dp; + } + size -= ignored_crs; + dp = data; +/* Parse environment; allow for '\0' and 'sep' as separators */ do { ENTRY e, *rv;Best regards,
Marek Vasut
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Dear Alexander Holler,
Quoted 11 lines
Am 12.05.2012 08:17, schrieb Marek Vasut:
Quoted 8 lines
Dear Alexander Holler,
Quoted 4 lines
This is used for compatibility with text files which are using CRLF instead of LF as the end of a line.
Signed-off-by Alexander Holler<[email protected]>Why don't you run the file trough dos2unix or tr -d '\r' ?
Because my files don't contain CRs. ;)
s/you/someone else/ :)
Quoted 74 lines
Regards,
Alexander
Quoted 57 lines
Quoted 57 lines
---
lib/hashtable.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-)lib/hashtable.c +0
-0@@ -623,9 +623,9 @@ ssize_t hexport_r(struct hsearch_data *htab, constchar sep, * (entries separated by newline characters).
*
* To allow for nicely formatted text input, leading white space- * (sequences of SPACE and TAB chars) is ignored, and entries starting
- * (after removal of any leading white space) with a '#' character are
- * considered comments and ignored.
+ * (sequences of SPACE and TAB chars) is ignored, all Carriage Returns
+ * are ignored and entries starting (after removal of any leading white
+ * space) with a '#' character are considered comments and ignored.*
* [NOTE: this means that a variable name cannot start with a '#'
* character.]lib/hashtable.c +12
-0@@ -642,6 +642,7 @@ int himport_r(struct hsearch_data *htab, const char *env, size_t size, const char sep, int flag) { char *data, *sp, *dp, *name, *value; +unsigned ignored_crs;/* Test for correct arguments. */ if (htab ==NULL ) {@@ -698,6 +699,17 @@ int himport_r(struct hsearch_data *htab, } } +/* Remove all Carriage Returns */ + ignored_crs =0 ; +for (;dp< data + size&& *dp; ++dp) { +if ( *dp =='\r' ) + ++ignored_crs; +else if (ignored_crs) + *(dp-ignored_crs) = *dp; + } + size -= ignored_crs; + dp = data; +Quoted 7 lines
Quoted 4 lines
/* Parse environment; allow for '\0' and 'sep' as separators */ do {
ENTRY e, *rv;
Best regards,
Marek Vasut_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Am 12.05.2012 16:46, schrieb Marek Vasut:
Quoted 8 lines
Dear Alexander Holler,
Quoted 6 lines
Am 12.05.2012 08:17, schrieb Marek Vasut:
Quoted 5 lines
Dear Alexander Holler,
Quoted 3 lines
This is used for compatibility with text files which are using CRLF instead of LF as the end of a line.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Alexander Holler<[email protected]>Why don't you run the file trough dos2unix or tr -d '\r' ?
Because my files don't contain CRs. ;)
s/you/someone else/ :)
Try to explain a windows user that a text file should not contain carriage returns and how he can achieve that.
You'll do it once, maybe twice, than you will surrender. ;)
Regards,
Alexander
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Dear Alexander Holler,
Quoted 13 lines
Am 12.05.2012 16:46, schrieb Marek Vasut:
Quoted 12 lines
Dear Alexander Holler,
Quoted 10 lines
Am 12.05.2012 08:17, schrieb Marek Vasut:
Quoted 8 lines
Dear Alexander Holler,
Quoted 4 lines
This is used for compatibility with text files which are using CRLF instead of LF as the end of a line.
Signed-off-by Alexander Holler<[email protected]>Why don't you run the file trough dos2unix or tr -d '\r' ?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Because my files don't contain CRs. ;)
s/you/someone else/ :)
Try to explain a windows user that a text file should not contain carriage returns and how he can achieve that.
You'll do it once, maybe twice, than you will surrender. ;)
But you're fixing the problem at a wrong place, aren't you? Besides, removing \r might harm some environments, don't you think?
Quoted 3 lines
Regards,
Alexander
Best regards,
Marek Vasut
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Am 12.05.2012 18:08, schrieb Marek Vasut:
Quoted 19 lines
Dear Alexander Holler,
Quoted 17 lines
Am 12.05.2012 16:46, schrieb Marek Vasut:
Quoted 15 lines
Dear Alexander Holler,
Quoted 11 lines
Am 12.05.2012 08:17, schrieb Marek Vasut:
Quoted 8 lines
Dear Alexander Holler,
Quoted 4 lines
This is used for compatibility with text files which are using CRLF instead of LF as the end of a line.
Signed-off-by Alexander Holler<[email protected]>Why don't you run the file trough dos2unix or tr -d '\r' ?
Because my files don't contain CRs. ;)
s/you/someone else/ :)
Quoted 7 lines
Quoted 4 lines
Try to explain a windows user that a text file should not contain carriage returns and how he can achieve that.
You'll do it once, maybe twice, than you will surrender. ;)
But you're fixing the problem at a wrong place, aren't you? Besides, removing \r might harm some environments, don't you think?
No, there is no other layer between the user and that function.
Anyway, as already said, I don't care, just had this patch lying around a year and I finally surrendered to post it here (in favor of those users). But it seems I was right in not posting it. ;)
Regards,
Alexander
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Dear Alexander Holler,
Quoted 25 lines
Am 12.05.2012 18:08, schrieb Marek Vasut:
Quoted 24 lines
Dear Alexander Holler,
Quoted 21 lines
Am 12.05.2012 16:46, schrieb Marek Vasut:
Quoted 8 lines
Dear Alexander Holler,
Quoted 6 lines
Am 12.05.2012 08:17, schrieb Marek Vasut:
Quoted 5 lines
Dear Alexander Holler,
Quoted 3 lines
This is used for compatibility with text files which are using CRLF instead of LF as the end of a line.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Alexander Holler<[email protected]>Why don't you run the file trough dos2unix or tr -d '\r' ?
Because my files don't contain CRs. ;)
s/you/someone else/ :)
Try to explain a windows user that a text file should not contain carriage returns and how he can achieve that.
You'll do it once, maybe twice, than you will surrender. ;)
Quoted 8 lines
Quoted 2 lines
But you're fixing the problem at a wrong place, aren't you? Besides, removing \r might harm some environments, don't you think?
No, there is no other layer between the user and that function.
Anyway, as already said, I don't care, just had this patch lying around a year and I finally surrendered to post it here (in favor of those users). But it seems I was right in not posting it. ;)
Don't get me wrong, I'm not opposed to this patch, nor I want to demotivate you in further submissions. I'm just trying to figure out if actually surrending to crappy software on one side is a good move on our side. I'd prefer to get more oppinions from other people actually, I don't want the guilt to fall on me :-)
Quoted 4 lines
Regards,
Alexander
Best regards,
Marek Vasut
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Am 12.05.2012 20:37, schrieb Marek Vasut:
Quoted 32 lines
Dear Alexander Holler,
Quoted 30 lines
Am 12.05.2012 18:08, schrieb Marek Vasut:
Quoted 19 lines
Dear Alexander Holler,
Quoted 17 lines
Am 12.05.2012 16:46, schrieb Marek Vasut:
Quoted 15 lines
Dear Alexander Holler,
Quoted 11 lines
Am 12.05.2012 08:17, schrieb Marek Vasut:
Quoted 8 lines
Dear Alexander Holler,
Quoted 4 lines
This is used for compatibility with text files which are using CRLF instead of LF as the end of a line.
Signed-off-by Alexander Holler<[email protected]>Why don't you run the file trough dos2unix or tr -d '\r' ?
Because my files don't contain CRs. ;)
s/you/someone else/ :)
Quoted 7 lines
Quoted 4 lines
Try to explain a windows user that a text file should not contain carriage returns and how he can achieve that.
You'll do it once, maybe twice, than you will surrender. ;)
But you're fixing the problem at a wrong place, aren't you? Besides, removing \r might harm some environments, don't you think?
No, there is no other layer between the user and that function.
Quoted 8 lines
Quoted 3 lines
Anyway, as already said, I don't care, just had this patch lying around a year and I finally surrendered to post it here (in favor of those users). But it seems I was right in not posting it. ;)
Don't get me wrong, I'm not opposed to this patch, nor I want to demotivate you in further submissions. I'm just trying to figure out if actually surrending to crappy software on one side is a good move on our side. I'd prefer to get more oppinions from other people actually, I don't want the guilt to fall on me :-)
In the good old days (tm) with line printers and almost endless paper from dead trees, CRLF instead only LF as line endings in text files did made sense.
Regards,
Alexander
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Dear Alexander Holler,
Quoted 4 lines · In message <[email protected]> you wrote:
In the good old days (tm) with line printers and almost endless paper from dead trees, CRLF instead only LF as line endings in text files did made sense.
It still makes a lot of sense in tty output. Guess how all the one-line status status lines are being printed?
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Is the glass half empty, half full, or twice as large as it needs to
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
Am 12.05.2012 23:21, schrieb Wolfgang Denk:
Quoted 10 lines
Dear Alexander Holler,
Quoted 4 lines · In message<[email protected]> you wrote:
In the good old days (tm) with line printers and almost endless paper from dead trees, CRLF instead only LF as line endings in text files did made sense.
It still makes a lot of sense in tty output. Guess how all the one-line status status lines are being printed?
That's why I hinted the line printers in response to "crappy software".
Regards,
Alexander
PATCH 1/1 Ignore all Carriage Returns when importing an environment.
In reply to Alexander HollerDear Alexander Holler,
Quoted 5 lines · In message <[email protected]> you wrote:
Try to explain a windows user that a text file should not contain carriage returns and how he can achieve that.
You'll do it once, maybe twice, than you will surrender. ;)
I disagree here. But of course YMMV.
But we should not remove functionality to make life easier for ignorant people who don't listen to your advice.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Save yourself! Reboot in 5 seconds!