Fixed register spec so that colon isn't treated as size separator
[idzebra-moved-to-github.git] / bfile / mfile.c
index 41fc3ca..342512f 100644 (file)
@@ -1,10 +1,20 @@
 /*
- * Copyright (C) 1994-1997, Index Data I/S 
+ * Copyright (C) 1994-1998, Index Data I/S 
  * All rights reserved.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: mfile.c,v $
- * Revision 1.25  1997-09-18 08:59:16  adam
+ * Revision 1.28  1998-05-20 10:00:35  adam
+ * Fixed register spec so that colon isn't treated as size separator
+ * unless followed by [0-9+-] in order to allow DOS drive specifications.
+ *
+ * Revision 1.27  1998/02/10 11:55:07  adam
+ * Minor changes.
+ *
+ * Revision 1.26  1997/10/27 14:25:38  adam
+ * Fixed memory leaks.
+ *
+ * Revision 1.25  1997/09/18 08:59:16  adam
  * Extra generic handle for the character mapping routines.
  *
  * Revision 1.24  1997/09/17 12:19:06  adam
@@ -124,8 +134,10 @@ static int scan_areadef(MFile_area ma, const char *name, const char *ad)
             ad++;
         if (!*ad)
             break;
-        while (*ad && *ad != ':')
+        while (*ad)
         {
+           if (*ad == ':' && strchr ("+-0123456789", ad[1]))
+               break;
             if (i < FILENAME_MAX)
                 dirname[i++] = *ad;
             ad++;
@@ -336,7 +348,13 @@ void mf_destroy(MFile_area ma)
     meta_f = ma->mfiles;
     while (meta_f)
     {
+       int i;
        meta_file *m = meta_f;
+       
+       for (i = 0; i<m->no_files; i++)
+       {
+           xfree (m->files[i].path);
+       }
        meta_f = meta_f->next;
        xfree (m);
     }
@@ -385,6 +403,8 @@ MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag)
        sprintf(tmp, "%s/%s.mf.%d", dp->name, mnew->name, 0);
        mnew->files[0].path = xstrdup(tmp);
        mnew->ma = ma;
+       mnew->next = ma->mfiles;
+       ma->mfiles = mnew;
     }
     else
     {
@@ -541,7 +561,8 @@ int mf_write(MFile mf, int no, int offset, int num, const void *buf)
     towrite = num ? num : mf->blocksize;
     if (write(mf->files[mf->cur_file].fd, buf, towrite) < towrite)
     {
-       logf (LOG_FATAL|LOG_ERRNO, "Write failed");
+       logf (LOG_FATAL|LOG_ERRNO, "Write failed for file %s part %d",
+               mf->name, mf->cur_file);
        exit(1);
     }
     return 0;