home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume8 / sp / part01 / dbm.diffs < prev    next >
Encoding:
Text File  |  1987-02-19  |  2.7 KB  |  144 lines

  1. Index: dbm.c
  2. *** dbm.orig.c    Thu Nov 27 17:45:38 1986
  3. --- dbm.c    Thu Nov 27 18:13:11 1986
  4. ***************
  5. *** 6,16 ****
  6. --- 6,21 ----
  7.   #include    <sys/types.h>
  8.   #include    <sys/stat.h>
  9.   
  10. + static long dbm_access_oldb;
  11. + static getbit_oldb;
  12.   dbminit(file)
  13.   char *file;
  14.   {
  15.       struct stat statb;
  16.   
  17. +     dbm_access_oldb = -1;
  18. +     getbit_oldb = -1;
  19.       dbrdonly = 0;
  20.       strcpy(pagbuf, file);
  21.       strcat(pagbuf, ".pag");
  22. ***************
  23. *** 27,36 ****
  24.           dirf = open(pagbuf, 0);
  25.           dbrdonly = 1;
  26.       }
  27. !     if(pagf < 0 || dirf < 0) {
  28. !         printf("cannot open database %s\n", file);
  29.           return(-1);
  30. -     }
  31.       fstat(dirf, &statb);
  32.       maxbno = statb.st_size*BYTESIZ-1;
  33.       return(0);
  34. --- 32,39 ----
  35.           dirf = open(pagbuf, 0);
  36.           dbrdonly = 1;
  37.       }
  38. !     if(pagf < 0 || dirf < 0)
  39.           return(-1);
  40.       fstat(dirf, &statb);
  41.       maxbno = statb.st_size*BYTESIZ-1;
  42.       return(0);
  43. ***************
  44. *** 130,136 ****
  45. --- 133,143 ----
  46.       return (0);
  47.   
  48.   split:
  49. + #ifdef BUGFIX
  50. +     if(key.dsize+dat.dsize+3*sizeof(short) >= PBLKSIZ) {
  51. + #else
  52.       if(key.dsize+dat.dsize+2*sizeof(short) >= PBLKSIZ) {
  53. + #endif
  54.           printf("entry too big\n");
  55.           return (-1);
  56.       }
  57. ***************
  58. *** 226,232 ****
  59.   dbm_access(hash)
  60.   long hash;
  61.   {
  62. !     static long oldb = -1;
  63.   
  64.       for(hmask=0;; hmask=(hmask<<1)+1) {
  65.           blkno = hash & hmask;
  66. --- 233,239 ----
  67.   dbm_access(hash)
  68.   long hash;
  69.   {
  70. ! /***    static long oldb = -1;    ***/
  71.   
  72.       for(hmask=0;; hmask=(hmask<<1)+1) {
  73.           blkno = hash & hmask;
  74. ***************
  75. *** 234,245 ****
  76.           if(getbit() == 0)
  77.               break;
  78.       }
  79. !     if(blkno != oldb) {
  80.           clrbuf(pagbuf, PBLKSIZ);
  81.           lseek(pagf, blkno*PBLKSIZ, 0);
  82.           read(pagf, pagbuf, PBLKSIZ);
  83.           chkblk(pagbuf);
  84. !         oldb = blkno;
  85.       }
  86.   }
  87.   
  88. --- 241,252 ----
  89.           if(getbit() == 0)
  90.               break;
  91.       }
  92. !     if(blkno != dbm_access_oldb) {
  93.           clrbuf(pagbuf, PBLKSIZ);
  94.           lseek(pagf, blkno*PBLKSIZ, 0);
  95.           read(pagf, pagbuf, PBLKSIZ);
  96.           chkblk(pagbuf);
  97. !         dbm_access_oldb = blkno;
  98.       }
  99.   }
  100.   
  101. ***************
  102. *** 247,253 ****
  103.   {
  104.       long bn;
  105.       register b, i, n;
  106. !     static oldb = -1;
  107.   
  108.       if(bitno > maxbno)
  109.           return(0);
  110. --- 254,260 ----
  111.   {
  112.       long bn;
  113.       register b, i, n;
  114. ! /***    static oldb = -1;  ***/
  115.   
  116.       if(bitno > maxbno)
  117.           return(0);
  118. ***************
  119. *** 255,265 ****
  120.       bn = bitno / BYTESIZ;
  121.       i = bn % DBLKSIZ;
  122.       b = bn / DBLKSIZ;
  123. !     if(b != oldb) {
  124.           clrbuf(dirbuf, DBLKSIZ);
  125.           lseek(dirf, (long)b*DBLKSIZ, 0);
  126.           read(dirf, dirbuf, DBLKSIZ);
  127. !         oldb = b;
  128.       }
  129.       if(dirbuf[i] & (1<<n))
  130.           return(1);
  131. --- 262,272 ----
  132.       bn = bitno / BYTESIZ;
  133.       i = bn % DBLKSIZ;
  134.       b = bn / DBLKSIZ;
  135. !     if(b != getbit_oldb) {
  136.           clrbuf(dirbuf, DBLKSIZ);
  137.           lseek(dirf, (long)b*DBLKSIZ, 0);
  138.           read(dirf, dirbuf, DBLKSIZ);
  139. !         getbit_oldb = b;
  140.       }
  141.       if(dirbuf[i] & (1<<n))
  142.           return(1);
  143.