[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Portability problem in rtems custom cfg's



joel at oarcorp.com wrote:

> On Mon, 9 Aug 1999, David Sotkowitz wrote:
>
> > In the cfg sources, SED is used to remove CR-LF,and leave a LF on Unix.
> > The problem is, on NT, where the removal is unnecessary, a nibble is
> > removed from the checksum at the end of the srecord when generating the exe.
>
> My first response is that this is a bug in sed on cygwin. :)

>
> The history behind this is that some of the monitors for the boards listed
> below either (1) did not like the extra LF (i.e. refused to download
> unless it was removed) or (2) did not care and thus you saved a few
> seconds of download time.

>
> > The bug is in RTEMS 4.0.0
>
> > The following diff provides a modification that will work. Alternately,
> > one could conditionalize on ostype.
>
> If objcopy ever changes where it does not generate the extra \r, then this
> will also strip the last nibble.
>
> Ralf .. David .. any ideas what is the best thing to do?

There are too many basic questions involved to allow me to propose a solution:

* What are srec-files? Are they general text files (i.e. allow \r\n and/or \n), are
they DOS-text files (require \r\n) or are they unix text files (require \n). If
they are DOS-text files (I.e. binary files under unix), then using sed on them is
not allowed under unix and filtering \r would be a violation of their specs.

* If sed is internally converting \r\n to \n and vice-versa under Cygwin, it is
useless for many purposes, because the resulting text files would be DOS-text files
and thus useless under Unix. IMHO, sed shouldn't care about DOS-text files and
should not convert \n\r to \n, because sed is a unix tool to handle unix-text
files.

* Using \r in sed substitution patterns is highly non-portable and is a extension
specific to gnu-sed, AFAIK.

* Seding out any non-printable characters is highly sensitive to portablity issues
and should  be avoided (I.e. using sed to filter out \r is questionable in general)

* A portable sed pattern would be something similar to 's/\([0-9A-Za-z]*\)/\1/',
but this would be useless for filtering out \r if sed is expanding \n to \r\n on
output => Given sed's behavior  on Cygwin is correct (which I doubt :-), RTEMS's
attempts to filter out \r are basically broken and can't be worked around by any
sed pattern.

Ralf