home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / gcc / bug / 3045 < prev    next >
Encoding:
Text File  |  1992-12-23  |  2.5 KB  |  87 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!mrc-crc.ac.UK!dcurtis
  3. From: dcurtis@mrc-crc.ac.UK (Dr. David Curtis)
  4. Subject: fseek() bug in djgpp?
  5. Message-ID: <1992Dec23.090918.4842@crc.ac.uk>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: MRC Human Genome Resource Centre
  8. Distribution: gnu
  9. Date: Wed, 23 Dec 1992 09:09:18 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 74
  12.  
  13. Am I being completely stupid, or does the djgpp version of fseek() just
  14. not work _at_all_? Seeks to offsets relative to SEEK_CUR just go
  15. completely wrong. I have a file called funcs.doc which suggests that it
  16. should be possible to do seeks backwards or forwards from SEEK_END, but
  17. only forwards from SEEK_CUR. If this is correct it sounds pretty
  18. non-standard to me. Anyway, when I tried this out I found that no seeks
  19. relative to SEEK_CUR worked correctly. See code to prove it below. I am
  20. using DOS 5 and SMARTDRV.SYS, though I doubt this is anything to do with
  21. it, and djgpp version 2.22. I am surprised that bugs as obvious as this
  22. are present in library. What other bugs are known? - I still can't get
  23. my f2c-translated code to run correctly....
  24.  
  25.  
  26. Dave Curtis
  27.  
  28. Academic Department of Psychiatry,    Janet:       d.curtis@UK.AC.IC.SM
  29. St. Mary's Hospital,                  Elsewhere:   d.curtis@SM.IC.AC.UK
  30. Praed Street, London W2.              EARN/Bitnet: dcurtis%CRC@UKACRL
  31. Tel 071-725 1993                      Usenet:...!mcsun!ukc!mrccrc!D.Curtis
  32.  
  33. Test code:
  34. (TEST.PED is any old text file, though opened in binary mode)
  35.  
  36. seeking backwards or forwards 5 from SEEK_CUR seems to move forwards by 17!!!
  37.  
  38. #include <stdio.h>
  39.  
  40. #define test(c) (printf("Trying %s ...\n",#c),printf("Result was %d\n",c))
  41. #define tell() (printf("Now at %ld, ",ftell(fp)),\
  42.     printf("next character is 0x%x\n",fgetc(fp)))
  43.  
  44. main()
  45. {
  46. FILE *fp;
  47. fp=fopen("TEST.PED","r+");
  48. test(fseek(fp,0,0));
  49. tell();
  50. test(fseek(fp,0,0));
  51. tell();
  52. test(fseek(fp,0,2));  /* end */
  53. tell();
  54. test(fseek(fp,-10,2));
  55. tell();
  56. test(fseek(fp,10,0));
  57. tell();
  58. test(fseek(fp,5,1));  /* relative */
  59. tell();
  60. test(fseek(fp,-5,1));
  61. tell();
  62. }
  63.  
  64. Trying fseek(fp,0,0) ...
  65. Result was 0
  66. Now at 0, next character is 0x28
  67. Trying fseek(fp,0,0) ...
  68. Result was 0
  69. Now at 0, next character is 0x28
  70. Trying fseek(fp,0,2) ...
  71. Result was 0
  72. Now at 2212, next character is 0xffffffff
  73. Trying fseek(fp,-10,2) ...
  74. Result was 0
  75. Now at 2202, next character is 0x2e
  76. Trying fseek(fp,10,0) ...
  77. Result was 0
  78. Now at 10, next character is 0xa
  79. Trying fseek(fp,5,1) ...
  80. Result was 0
  81. Now at 37, next character is 0x33
  82. Trying fseek(fp,-5,1) ...
  83. Result was 0
  84. Now at 54, next character is 0x20
  85.  
  86.  
  87.