3 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
5 long readline(FILE * stream, char **buf, size_t * n)
13 *buf = calloc(512, sizeof(char));
20 for (i = 0; (ch = fgetc(stream)) != EOF; i++) {
22 *buf = xbt_realloc(*buf, *n += 512);
27 if (cr && (*buf)[i] != '\n') {
28 /* old Mac os uses CR */
32 /* move to the previous pos (pos of the CR) */
33 fsetpos(stream, &pos);
35 /* process as linux now */
39 if ((*buf)[i] == '\n') {
41 /* Windows uses CRLF */
51 } else if (ch == '\r') {
54 /* register the CR position for mac */
55 fgetpos(stream, &pos);
61 *buf = xbt_realloc(*buf, *n += 1);
63 /* Mac os file ended with a blank line */
64 if (ch == EOF && (*buf)[i - 1] == '\r')