Re: [Tex-music] RE: staff jumping beams--my own problem solved

2003-12-01 Thread Bernhard Lang
On Mon, 1 Dec 2003, Roland Stigge wrote:

> It's possible to call fromdos from your build scripts, Makefile, etc.

Yes, but that means not only that you have to tell your Makefile rules how
to read things coming from another system but also you have to tell it how
to make formats for other systems (without being able to test the result
on your system), as gmake and friends are not commonly to be found on
windows systems. Well, maybe on systems running musixtex and friends, they
are.

> Besides, I don't think hacking either glibc or source packages (or what
> did you mean with your code excerpts?) is an easy standard approach. :-)

No, not hacking glibc, this wouldn't be a good idea. But using your own
routines on top of glibc (or whatever basic io library you are actually
using) which handle, what the routines therein do not handle. The excerpts
actually rely on fgets and fread, to be found in stdio.h

regards
Bernhard

___
Tex-music mailing list
[EMAIL PROTECTED]
http://icking-music-archive.org/mailman/listinfo/tex-music


Re: [Tex-music] RE: staff jumping beams--my own problem solved

2003-12-01 Thread Roland Stigge
On Mon, 2003-12-01 at 12:55, Bernhard Lang wrote:
> > Feel free to use already existing tools like dos2unix / fromdos (vs.
> > unix2dos / todos) usually shipped with Unix-like OS distributions. The
> > relevant Debian package is e.g. called sysutils.
> 
> Of course, but this means one file version for one system, one for the
> next and so on. This yields exactly to the sort of problems into which Don
> got. As *clean* I would consider one input file for all OSs, i.e. in this
> case a program which is happy with all different forms of line end
> definitions.

It's possible to call fromdos from your build scripts, Makefile, etc.
Personally, I took the approach you described above to package musixtex
for Debian. The solution is easy to automate.

Besides, I don't think hacking either glibc or source packages (or what
did you mean with your code excerpts?) is an easy standard approach. :-)

bye,
  Roland


signature.asc
Description: This is a digitally signed message part
___
Tex-music mailing list
[EMAIL PROTECTED]
http://icking-music-archive.org/mailman/listinfo/tex-music


Re: [Tex-music] RE: staff jumping beams--my own problem solved

2003-12-01 Thread Bernhard Lang
On Mon, 1 Dec 2003, Roland Stigge wrote:

> On Mon, 2003-12-01 at 11:34, Bernhard Lang wrote:
> > The only clean solution: write your own input routine which is capable of
> > handling the different line end codings.
>
> Feel free to use already existing tools like dos2unix / fromdos (vs.
> unix2dos / todos) usually shipped with Unix-like OS distributions. The
> relevant Debian package is e.g. called sysutils.

Of course, but this means one file version for one system, one for the
next and so on. This yields exactly to the sort of problems into which Don
got. As *clean* I would consider one input file for all OSs, i.e. in this
case a program which is happy with all different forms of line end
definitions.

___
Tex-music mailing list
[EMAIL PROTECTED]
http://icking-music-archive.org/mailman/listinfo/tex-music


Re: [Tex-music] RE: staff jumping beams--my own problem solved

2003-12-01 Thread Roland Stigge
On Mon, 2003-12-01 at 11:34, Bernhard Lang wrote:
> The only clean solution: write your own input routine which is capable of
> handling the different line end codings.

Feel free to use already existing tools like dos2unix / fromdos (vs.
unix2dos / todos) usually shipped with Unix-like OS distributions. The
relevant Debian package is e.g. called sysutils.

bye,
  Roland


signature.asc
Description: This is a digitally signed message part
___
Tex-music mailing list
[EMAIL PROTECTED]
http://icking-music-archive.org/mailman/listinfo/tex-music


Re: [Tex-music] RE: staff jumping beams--my own problem solved

2003-12-01 Thread Peter Vanroose
> (you might also ask the question why DOS did not use what was already
> established)

Well... it was not yet "established" at that time (around 1980):
Unix indeed used "LF" for line endings, but e.g. the popular VMS used
"CR+LF".

There was a rationale for using CR+LF at that time:
"CR+LF" files are simpler to send to a printer:
"CR" means "carriage return", i.e., go to the start of this line,
while "LF" means "line feed", i.e., go down one line vertically.
Hence, sending an ASCII text file with LFs but no CRs to a printer
will give you output of the following form:

This is the first line.
   This is the second line.
   End so on, up to page b

(and the rest of the output will be missing).


--  Peter Vanroose.
___
Tex-music mailing list
[EMAIL PROTECTED]
http://icking-music-archive.org/mailman/listinfo/tex-music


Re: [Tex-music] RE: staff jumping beams--my own problem solved

2003-12-01 Thread Bernhard Lang
On Mon, 1 Dec 2003, Dirk Laurie wrote:

> Don Simons skryf:
> >
> > It was the d*#@ line-ending characters! Why doesn't everyone just use
> > Windows? :-)
> >
> One might also ask the question: why can't all compilers produce code
> that will accept any of CR, LF, CR+LF or LF+CR as end-of-line?

This was part of ANSI C standard (where you had the choice between text
and binary files). The gcc compiler (i.e. its standard io library), as
being POSIX conform, accepts still the mode option b/t in fopen for
compatibility reasons, but alas, it has no effect any more and this
helpful feature is broken now. The situation might be similar for other
compilers.

The only clean solution: write your own input routine which is capable of
handling the different line end codings.

--snip-- without guarantee

char *my_fgets(char *s, int size, FILE *stream) {
  int c, no_line_end = 1, pos = 0;

  if (--size < 0) return NULL;

  while (no_line_end && (pos < size)) {
no_line_end = 0;
switch (c = fgetc(stream)) {
  case EOF:
if (!pos) return NULL; // error
break;

  case LF:
if ((c = fgetc(stream)) != CR) ungetc(c, stream);
s[pos++] = LOCAL_LINE_END;
break;

  case CR:
if ((c = fgetc(stream)) != LF) ungetc(c, stream);
s[pos++] = LOCAL_LINE_END;
break;

  default:
no_line_end = 1;
s[pos++] = c;
}
  }

  s[pos] = 0;
  return s;
}


static char last_character = 0;
size_t freadtext(void *ptr, size_t count, FILE *stream) {
// ignores all subsequent LF after a CR and vice versa
  size_t bytes_read = 0;
  int c;

  while (bytes_read < count)
switch (c = fgetc(stream)) {
  case EOF:
goto LoopEnd;

  case LF:
if (last_character == CR) break;
((char*)ptr)[bytes_read++] = LOCAL_LINE_END;
last_character = LF;
break;

  case CR:
if (last_character == LF) break;
((char*)ptr)[bytes_read++] = LOCAL_LINE_END;
last_character = CR;
break;

  default:
last_character = ((char*)ptr)[bytes_read++] = c;
}
LoopEnd:
  return bytes_read;
}

--snap--

(you might also ask the question why DOS did not use what was already
established)

regards
Bernhard

___
Tex-music mailing list
[EMAIL PROTECTED]
http://icking-music-archive.org/mailman/listinfo/tex-music


Re: [Tex-music] RE: staff jumping beams--my own problem solved

2003-12-01 Thread Dirk Laurie
Don Simons skryf:
> 
> It was the d*#@ line-ending characters! Why doesn't everyone just use
> Windows? :-)
> 
Some of us are too poor to buy it, others are too honest to pirate it,
still others are too idealistic to use non-free software (among TeX
users this is maybe the largest group) -- and all of us enjoy not
having to worry about viruses.

One might also ask the question: why can't all compilers produce code
that will accept any of CR, LF, CR+LF or LF+CR as end-of-line?

Dirk
___
Tex-music mailing list
[EMAIL PROTECTED]
http://icking-music-archive.org/mailman/listinfo/tex-music


RE: [Tex-music] RE: staff jumping beams--my own problem solved

2003-11-28 Thread Don Simons
I wrote

> I downloaded ritornel4.mtx from the archive but I can't get it to
> compile. I
> get the message
>
> c:\my documents\pmx>prepmx ritornel4
> ==> This is M-Tx pre0.54c (Music from TeXt) <15 August 2003>
> Writing to ritornel4.pmx
> No music paragraphs!: ERROR on line 1
>
> Any idea what's wrong?
>

It was the d*#@ line-ending characters! Why doesn't everyone just use
Windows? :-)

--Don

___
Tex-music mailing list
[EMAIL PROTECTED]
http://icking-music-archive.org/mailman/listinfo/tex-music