incpt.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. *
  5. * This product is part of the Amsterdam Compiler Kit.
  6. *
  7. * Permission to use, sell, duplicate or disclose this software must be
  8. * obtained in writing. Requests for such permissions may be sent to
  9. *
  10. * Dr. Andrew S. Tanenbaum
  11. * Wiskundig Seminarium
  12. * Vrije Universiteit
  13. * Postbox 7161
  14. * 1007 MC Amsterdam
  15. * The Netherlands
  16. *
  17. */
  18. /* Author: J.W. Stevenson */
  19. #include <stdlib.h>
  20. #include <errno.h>
  21. #include <unistd.h>
  22. #include <pc_file.h>
  23. #include <pc_err.h>
  24. extern _trp();
  25. _incpt(f) struct file *f; {
  26. if (f->flags & EOFBIT)
  27. _trp(EEOF);
  28. f->flags |= WINDOW;
  29. f->flags &= ~ELNBIT;
  30. #ifdef CPM
  31. do {
  32. #endif
  33. f->ptr += f->size;
  34. if (f->count == 0) {
  35. f->ptr = f->bufadr;
  36. for(;;) {
  37. f->count=read(f->ufd,f->bufadr,f->buflen);
  38. if ( f->count<0 ) {
  39. if (errno != EINTR) _trp(EREAD) ;
  40. continue ;
  41. }
  42. break ;
  43. }
  44. if (f->count == 0) {
  45. f->flags |= EOFBIT;
  46. *f->ptr = '\0';
  47. return;
  48. }
  49. }
  50. if ((f->count -= f->size) < 0)
  51. _trp(EFTRUNC);
  52. #ifdef CPM
  53. } while ((f->flags&TXTBIT) && *f->ptr == '\r');
  54. #endif
  55. if (f->flags & TXTBIT) {
  56. if (*f->ptr & 0200)
  57. _trp(EASCII);
  58. if (*f->ptr == '\n') {
  59. f->flags |= ELNBIT;
  60. *f->ptr = ' ';
  61. }
  62. #ifdef CPM
  63. if (*f->ptr == 26) {
  64. f->flags |= EOFBIT;
  65. *f->ptr = 0;
  66. }
  67. #endif
  68. }
  69. }