[Ecls-list] READ, newline character and differnt platforms

Juan Jose Garcia Ripoll worm at arrakis.es
Sat Nov 23 11:54:03 UTC 2002


Hi,

the latest bug I fixed involves READ and READ-PRESERVING-WHITESPACE. Somehow, 
READ would not eat the whitespace behind an object, and therefore typing 
(READ-LINE) at the prompt would simply produce an empty string.

This brings me to a question. Does anybody know the convention for text files 
in Mac OSX? I mean, whether a newline character is translated to a carriage 
return plus a linefeed. I built an automatic test for ECL which checks this 
(see below), but I cannot detect this happening.

Juanjo

#include <stdio.h>
int main() {
  FILE *f = fopen("conftestval","w");
  int c1, c2;
  if (f == NULL) exit(1);
  fprintf(f, "\n");
  fclose(f);
  f = fopen("conftestval","rb");
  if (f == NULL) exit(1);
  c1 = fgetc(f);
  c2 = fgetc(f);
  fclose(f);
  f = fopen("conftestval","w");
  if (f == NULL) exit(1);
  if (c1 == '\r')
    fprintf(f,"crlf");
  else if (c2 == '\r')
    fprintf(f,"lfcr");
  else
    fprintf(f,"unix");
  fclose(f);
}





More information about the ecl-devel mailing list