Hi!

- fix: INT21/42: for seeking error was always returned DE_INVLDHNDL; now
  error propagated from lower levels.

--- Begin Message ---
diff -ruNp old/kernel/dosfns.c new/kernel/dosfns.c
--- old/kernel/dosfns.c 2004-07-25 01:25:20.000000000 +0000
+++ new/kernel/dosfns.c 2004-07-25 02:31:20.000000000 +0000
@@ -317,7 +317,11 @@ long DosRWSft(int sft_idx, size_t n, voi
 
 int SftSeek(int sft_idx, LONG new_pos, unsigned mode)
 {
-  sft FAR *s = idx_to_sft(sft_idx);
+  return _SftSeek(idx_to_sft(sft_idx), new_pos, mode);
+}
+
+int _SftSeek(sft FAR *s, LONG new_pos, unsigned mode)
+{
   if (FP_OFF(s) == (size_t) -1)
     return DE_INVLDHNDL;
         
@@ -367,20 +371,6 @@ int SftSeek(int sft_idx, LONG new_pos, u
   return SUCCESS;
 }
 
-ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode)
-{
-  int sft_idx = get_sft_idx(hndl);
-  COUNT result;
-
-  /* Get the SFT block that contains the SFT      */
-  result = SftSeek(sft_idx, new_pos, mode);
-  if (result == SUCCESS)
-  {
-    return idx_to_sft(sft_idx)->sft_posit;
-  }
-  return (ULONG)-1;
-}
-
 STATIC long get_free_hndl(void)
 {
   psp FAR *p = MK_FP(cu_psp, 0);
@@ -844,8 +834,8 @@ UWORD DosGetFree(UBYTE drive, UWORD * na
   }
 #endif
 
-  /* now tell fs to give us free cluster count                 */
   *nc = dpbp->dpb_size - 1;
+  /* now tell fs to give us free cluster count                 */
   if (navc)
     *navc = (UWORD) dos_free(dpbp);
   if (spc > 64)
diff -ruNp old/kernel/inthndlr.c new/kernel/inthndlr.c
--- old/kernel/inthndlr.c       2004-07-25 00:22:58.000000000 +0000
+++ new/kernel/inthndlr.c       2004-07-25 02:53:58.000000000 +0000
@@ -889,19 +889,15 @@ dispatch:
 
       /* Dos Seek                                                     */
     case 0x42:
-      if (lr.AL > 2)
-        goto error_invalid;
-      lrc = DosSeek(lr.BX, (LONG)((((ULONG) (lr.CX)) << 16) | lr.DX), lr.AL);
-      if (lrc == -1)
-      {
-        lrc = DE_INVLDHNDL;
-      }
-      else
+    {
+      sft FAR *s = get_sft(lr.BX);
+      if ((rc = _SftSeek(s, MK_ULONG(lr.CX, lr.DX), lr.AL)) >= SUCCESS)
       {
-        lr.DX = (UWORD)(lrc >> 16);
-        lrc = (UWORD) lrc;
+        lr.DX = hiword (s->sft_posit);
+        lr.AX = loword (s->sft_posit);
       }
-      goto long_check;
+      goto short_check;
+    }
 
       /* Get/Set File Attributes                                      */
     case 0x43:
diff -ruNp old/kernel/proto.h new/kernel/proto.h
--- old/kernel/proto.h  2004-07-25 00:28:04.000000000 +0000
+++ new/kernel/proto.h  2004-07-25 02:48:16.000000000 +0000
@@ -78,12 +78,11 @@ sft FAR *get_sft(UCOUNT);
 
 /* dosfns.c */
 
-#define SEEK_SET 0
-#define SEEK_CUR 1
-#define SEEK_END 2
+#define SEEK_SET 0u
+#define SEEK_CUR 1u
+#define SEEK_END 2u
 
 const char FAR *get_root(const char FAR *);
-BOOL check_break(void);
 UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, void FAR * bp,
                       COUNT * err, BOOL force_binary);
 COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode);
@@ -93,7 +92,7 @@ void BinarySftIO(int sft_idx, void *bp, 
 long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode);
 #define DosRead(hndl, n, bp) DosRWSft(get_sft_idx(hndl), n, bp, XFR_READ)
 #define DosWrite(hndl, n, bp) DosRWSft(get_sft_idx(hndl), n, bp, XFR_WRITE)
-ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode);
+int _SftSeek(sft FAR*, LONG new_pos, unsigned mode);
 long DosOpen(char FAR * fname, unsigned flags, unsigned attrib);
 COUNT CloneHandle(unsigned hndl);
 long DosDup(unsigned Handle);

--- End Message ---

Reply via email to