| 346 | } |
| 347 | |
| 348 | staticfn char * |
| 349 | lib_dlb_fgets(char *buf, int len, dlb *dp) |
| 350 | { |
| 351 | int i; |
| 352 | char *bp, c = 0; |
| 353 | |
| 354 | if (len <= 0) |
| 355 | return buf; /* sanity check */ |
| 356 | |
| 357 | /* return NULL on EOF */ |
| 358 | if (dp->mark >= dp->size) |
| 359 | return (char *) 0; |
| 360 | |
| 361 | len--; /* save room for null */ |
| 362 | for (i = 0, bp = buf; i < len && dp->mark < dp->size && c != '\n'; |
| 363 | i++, bp++) { |
| 364 | if (dlb_fread(bp, 1, 1, dp) <= 0) |
| 365 | break; /* EOF or error */ |
| 366 | c = *bp; |
| 367 | } |
| 368 | *bp = '\0'; |
| 369 | |
| 370 | #if defined(MSDOS) || defined(WIN32) |
| 371 | if ((bp = strchr(buf, '\r')) != 0) { |
| 372 | *bp++ = '\n'; |
| 373 | *bp = '\0'; |
| 374 | } |
| 375 | #endif |
| 376 | |
| 377 | return buf; |
| 378 | } |
| 379 | |
| 380 | staticfn int |
| 381 | lib_dlb_fgetc(dlb *dp) |
nothing calls this directly
no test coverage detected