[PATCH] Added support for comments in input to mkenvimage.

Dominik Muth dominik.muth at bkvibro.com
Thu Aug 28 12:25:27 CEST 2014


This patch adds support for comments in the input to mkenvimage, i.e. in
the environment source: All lines starting with a # in the firs column
will be ignored.

Additionally empty lines will also be ignored.

Signed-off-by: Dominik Muth <dominik.muth at bkvibro.com>
---
 tools/mkenvimage.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c
index bbd3041..4f75338 100644
--- a/tools/mkenvimage.c
+++ b/tools/mkenvimage.c
@@ -37,6 +37,8 @@ static void usage(const char *exec_name)
               "\t\tkey1=3Dvalue1\n"
               "\t\tkey2=3Dvalue2\n"
               "\t\t...\n"
+              "\tEmpty lines are skipped, and lines with a # in the first\=
n"
+              "\tcolumn are treated as comments (also skipped).\n"
               "\t-r : the environment has multiple copies in flash\n"
               "\t-b : the target is big endian (default is little endian)\=
n"
               "\t-p <byte> : fill the image with <byte> bytes instead of 0=
xff bytes\n"
@@ -221,10 +223,9 @@ int main(int argc, char **argv)
        /* Replace newlines separating variables with \0 */
        for (fp =3D 0, ep =3D 0 ; fp < filesize ; fp++) {
                if (filebuf[fp] =3D=3D '\n') {
-                       if (ep =3D=3D 0) {
+                       if (fp =3D=3D 0 || filebuf[fp-1] =3D=3D '\n') {
                                /*
-                                * Newlines at the beginning of the file ?
-                                * Ignore them.
+                                * Skip empty lines.
                                 */
                                continue;
                        } else if (filebuf[fp-1] =3D=3D '\\') {
@@ -240,6 +241,10 @@ int main(int argc, char **argv)
                                /* End of a variable */
                                envptr[ep++] =3D '\0';
                        }
+               } else if ((fp =3D=3D 0 || filebuf[fp-1] =3D=3D '\n') && fi=
lebuf[fp] =3D=3D '#') {
+                       /* Comment, skip the line. */
+                       while (++fp < filesize && filebuf[fp] !=3D '\n')
+                               continue;
                } else {
                        envptr[ep++] =3D filebuf[fp];
                }
--
1.7.9.5

________________________________

Sitz der Gesellschaft / Registered Office: Darmstadt
Handelsregister Darmstadt / Darmstadt Commercial Register No.: HRB 6803
Geschaeftsfuehrung / Managing Director: Torben Ekvall
The Royal Bank of Scotland N.V., Frankfurt a.M., 1654012009 (BLZ 502 304 00=
)
SWIFT-BIC: ABNADEFF FRA
IBAN: DE21 5023 0400 1654 0120 09
UST-ID Nr. / UST-ID No.: DE 812 272 970
WEEE-Reg.-Nr. / WEEE-Reg.-No.: DE 69572330

Registered Office: Naerum
Naerum Commercial Register No.: 15 38 05 94
Managing Director: Torben Ekvall
Danske Bank, Account no.: 3001 3345212949
SWIFT Address: DABADKKK
IBAN No.: DK94 3000 3345 2129 49


Der Inhalt dieser E-Mail ist ausschliesslich fuer den/die bezeichneten Empf=
aenger bestimmt. Wenn Sie nicht der vorgesehene Adressat dieser E-Mail oder=
 dessen Vertreter sein sollen, so beachten Sie bitte, dass jede Form der Ke=
nntnisnahme, Veroeffentlichung, Vervielfaeltigung oder Weitergabe des Inhal=
ts dieser E-Mail unzulaessig ist. Wir bitten Sie, sich in diesem Fall mit d=
em Absender der E-Mail oder telefonisch unter +49 (0) 6151 428-1100 in Verb=
indung zu setzen.


This e-mail is confidential and may be read, copied and used only by the in=
tended recipient. If you have received it in error, please contact the send=
er immediately by return e-mail or by telephoning +49 (0) 6151 428-1100. Pl=
ease then delete the e-mail and do not disclose its contents to any person.


More information about the U-Boot mailing list