473,379 Members | 1,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

HI I get the following error while run the command makefile in Ubuntu 9.10?

Hi,

while running the command "make all" for English morphological analyser, i get the following error.I am using ubuntu 9.10.

cc -O -DUNIX -DBSD -g -I/home/English/src/java/morph-1.5/hash -I/usr/include/X11/Xaw -c -w -o lib/dynahash.o /home/English/src/java/morph-1.5/hash/dynahash.c
/home/English/src/java/morph-1.5/hash/dynahash.c: In function ‘flush_meta’:
/home/English/src/java/morph-1.5/hash/dynahash.c:521: error: expected identifier before ‘(’ token
/home/English/src/java/morph-1.5/hash/dynahash.c: In function ‘hash_get’:
/home/English/src/java/morph-1.5/hash/dynahash.c:557: error: expected identifier before ‘(’ token
/home/English/src/java/morph-1.5/hash/dynahash.c: In function ‘hash_put’:
/home/English/src/java/morph-1.5/hash/dynahash.c:575: error: expected identifier before ‘(’ token
/home/English/src/java/morph-1.5/hash/dynahash.c: In function ‘hash_delete’:
/home/English/src/java/morph-1.5/hash/dynahash.c:600: error: expected identifier before ‘(’ token
/home/English/src/java/morph-1.5/hash/dynahash.c: In function ‘hash_seq’:
/home/English/src/java/morph-1.5/hash/dynahash.c:753: error: expected identifier before ‘(’ token
make: *** [lib/dynahash.o] Error 1

and the program is given below:


Expand|Select|Wrap|Line Numbers
  1. #include <sys/param.h>
  2. #include <sys/stat.h>
  3. #include <sys/fcntl.h>
  4. #include <sys/sysmacros.h>
  5. #include <errno.h>
  6. #include <assert.h>
  7. #include <db.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <unistd.h>
  11. #include <string.h>
  12. #include "hash.h"
  13. #include "endian.h"
  14. /* Fast arithmetic, relying on powers of 2, */
  15.  
  16. #define MOD(x,y)        ((x) & ((y)-1))
  17. #define RETURN_ERROR(ERR,LOC)    { save_errno = ERR; goto LOC; }
  18.  
  19. /* Return values */
  20.  
  21. #define    SUCCESS    0
  22. #define    ERROR    -1
  23. #define    ABNORMAL 1
  24.  
  25. /* page.c */
  26. extern int __get_page();
  27. extern int __split_page();
  28. extern int __addel();
  29. extern int __delpair();
  30. extern u_long *__init_bitmap();
  31.  
  32. /* big.c */
  33. extern int __big_return();
  34. extern int __big_keydata();
  35. extern u_short __find_last_page();
  36.  
  37. /* buf.c */
  38. extern BUFHEAD    *__get_buf();
  39. extern void __buf_init();
  40. extern int __buf_free();
  41.  
  42. /* hash function */
  43. extern int (*default_hash)();
  44.  
  45. /* My externals */
  46. extern int __expand_table();
  47. extern u_int __call_hash();
  48.  
  49. /* Internal routines */
  50. static HTAB *init_hash();
  51. static int hash_access();
  52. static int flush_meta();
  53. static int alloc_segs();
  54. static int init_htab();
  55. static char *hash_realloc();
  56. static int hdestroy();
  57. static int hash_put();
  58. static int hash_delete();
  59. static int hash_get();
  60. static int hash_sync();
  61. static int hash_close();
  62. static int hash_seq();
  63. static void swap_header_copy();
  64. static void swap_header();
  65.  
  66. /* Local data */
  67.  
  68. HTAB *hashp = NULL;
  69.  
  70. #ifdef HASH_STATISTICS
  71. long hash_accesses, hash_collisions, hash_expansions, hash_overflows;
  72. #endif
  73.  
  74. /************************** INTERFACE ROUTINES **********************/
  75. /* OPEN/CLOSE */
  76.  
  77. extern    DB *
  78. hash_open ( file, flags, mode, info )
  79. const char    *file;
  80. int    flags;
  81. int    mode;
  82. const HASHINFO    *info;        /* Special directives for create */
  83. {
  84.     int        buckets;
  85.     int        bpages;
  86.     int        hdrsize;
  87.     int        i;
  88.     int        new_table = 0;
  89.     int        nkey;
  90.     int        nsegs;
  91.     int        save_errno;
  92.     struct    stat statbuf;
  93.     DB        *dbp;
  94.  
  95.  
  96.     if ( !(hashp = (HTAB *) calloc( 1, sizeof(HTAB) ))) {
  97.     /* calloc should set errno */
  98.     return(0);
  99.     }
  100.     hashp->fp = -1;
  101.     /* 
  102.     Select flags relevant to us.
  103.     Even if user wants write only, we need to be able to read 
  104.     the actual file, so we need to open it read/write.  But, the
  105.     field in the hashp structure needs to be accurate so that
  106.     we can check accesses.
  107.     */
  108.     flags = flags & (O_CREAT | O_EXCL | O_RDONLY | O_RDWR | O_TRUNC | O_WRONLY);
  109.     hashp->flags = flags;
  110.     if ( flags & O_WRONLY )  flags = (flags & ~O_WRONLY) | O_RDWR;
  111.  
  112.     if ( !file || 
  113.      (flags & O_TRUNC) || 
  114.      (stat ( file, &statbuf ) && (errno == ENOENT)) ) {
  115.      if ( errno == ENOENT ) {
  116.         errno = 0;        /* Just in case someone looks at errno */
  117.      }
  118.      new_table = 1;
  119.     }
  120.  
  121.     if ( file ) {
  122.     if ((hashp->fp = open ( file, flags, mode )) == -1) {
  123.         RETURN_ERROR (errno, error0);
  124.     }
  125.     (void)fcntl(hashp->fp, F_SETFD, 1);
  126.     }
  127.  
  128.     if ( new_table ) {
  129.     if ( !(hashp = init_hash( info )) ) {
  130.         RETURN_ERROR(errno,error1);
  131.     }
  132.     } else {
  133.     /* Table already exists */
  134.     if ( info && info->hash ) hashp->hash = info->hash;
  135.     else hashp->hash = default_hash;
  136.  
  137.     hdrsize = read ( hashp->fp, &hashp->hdr, sizeof(HASHHDR) );
  138. #if BYTE_ORDER == LITTLE_ENDIAN
  139.     swap_header ( );
  140. #endif
  141.     if ( hdrsize == -1 ) {
  142.         RETURN_ERROR(errno, error1);
  143.     }
  144.     if ( hdrsize != sizeof(HASHHDR) ) {
  145.         RETURN_ERROR(EFTYPE, error1);
  146.     }
  147.  
  148.     /* Verify file type, versions and hash function */
  149.     if ( hashp->MAGIC != HASHMAGIC ) 
  150.         RETURN_ERROR ( EFTYPE, error1 );
  151.     if ( hashp->VERSION != VERSION_NO ) 
  152.         RETURN_ERROR ( EFTYPE, error1 );
  153.     if (hashp->hash ( CHARKEY, sizeof(CHARKEY) ) != hashp->H_CHARKEY ) {
  154.         RETURN_ERROR ( EFTYPE, error1 );
  155.     }
  156.  
  157.     /* 
  158.         Figure out how many segments we need.
  159.     */
  160.     nsegs = (hashp->MAX_BUCKET + hashp->SGSIZE -1)/ hashp->SGSIZE;
  161.     hashp->nsegs = 0;
  162.     if (alloc_segs( nsegs )) {    
  163.         /* 
  164.         If alloc_segs fails, table will have been destroyed 
  165.         and errno will have been set.
  166.         */
  167.         return( (DB *) NULL );
  168.     }
  169.  
  170.     /* Read in bitmaps */
  171.     bpages = (hashp->SPARES[__log2(hashp->MAX_BUCKET)] + 
  172.           (hashp->BSIZE << BYTE_SHIFT) - 1) >> 
  173.           (hashp->BSHIFT + BYTE_SHIFT);
  174.  
  175.     hashp->nmaps = bpages;
  176.     memset ( &hashp->mapp[0], 0, bpages * sizeof ( u_long *) );
  177.     }
  178.  
  179.     /* Initialize Buffer Manager */
  180.     if ( info && info->cachesize ) {
  181.     __buf_init (info->cachesize);
  182.     } else {
  183.     __buf_init (DEF_BUFSIZE);
  184.     }
  185.  
  186.     hashp->new_file = new_table;
  187.     hashp->save_file = file && (hashp->flags & (O_WRONLY|O_RDWR));
  188.     hashp->cbucket = -1;
  189.     if ( !(dbp = (DB *)malloc ( sizeof (DB) )) ) {
  190.     save_errno = errno;
  191.     hdestroy();
  192.     errno = save_errno;
  193.     return ( NULL );
  194.     }
  195.     dbp->internal = (char *)hashp;
  196.     dbp->close = hash_close;
  197.     dbp->del = hash_delete;
  198.     dbp->get = hash_get;
  199.     dbp->put = hash_put;
  200.     dbp->seq = hash_seq;
  201.     dbp->sync = hash_sync;
  202.     dbp->type = DB_HASH;
  203.  
  204. #ifdef DEBUG
  205.     (void)fprintf(stderr, "%s\n%s%x\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%x\n%s%x\n%s%d\n%s%d\n",
  206.         "init_htab:",
  207.         "TABLE POINTER   ", hashp,
  208.         "BUCKET SIZE     ", hashp->BSIZE,
  209.         "BUCKET SHIFT    ", hashp->BSHIFT,
  210.         "DIRECTORY SIZE  ", hashp->DSIZE,
  211.         "SEGMENT SIZE    ", hashp->SGSIZE,
  212.         "SEGMENT SHIFT   ", hashp->SSHIFT,
  213.         "FILL FACTOR     ", hashp->FFACTOR,
  214.         "MAX BUCKET      ", hashp->MAX_BUCKET,
  215.         "HIGH MASK       ", hashp->HIGH_MASK,
  216.         "LOW  MASK       ", hashp->LOW_MASK,
  217.         "NSEGS           ", hashp->nsegs,
  218.         "NKEYS           ", hashp->NKEYS );
  219. #endif
  220. #ifdef HASH_STATISTICS
  221.     hash_overflows = hash_accesses = hash_collisions = hash_expansions = 0;
  222. #endif
  223.     return (dbp);
  224.  
  225. error2:
  226.     (void)hdestroy();
  227.     errno = save_errno;
  228.     return ( (DB *)NULL );
  229.  
  230. error1:
  231.     (void) close ( hashp->fp );
  232.  
  233. error0:
  234.     free ( hashp );
  235.     errno = save_errno;
  236.     return ( (DB *) NULL );
  237. }
  238.  
  239. static int
  240. hash_close (dbp)
  241. DB    *dbp;
  242. {
  243.     int    retval;
  244.  
  245.     if ( !dbp ) {
  246.         return(ERROR);
  247.     }
  248.     hashp = (HTAB *)dbp->internal;
  249.     retval = hdestroy();
  250.     (void)free ( dbp );
  251.     return ( retval );
  252. }
  253.  
  254.  
  255. /************************** LOCAL CREATION ROUTINES **********************/
  256. static HTAB * 
  257. init_hash( info )
  258. HASHINFO *info;
  259. {
  260.     int    nelem;
  261.  
  262.     nelem = 1;
  263.  
  264.     hashp->LORDER    = BYTE_ORDER;
  265.     hashp->BSIZE    = DEF_BUCKET_SIZE;
  266.     hashp->BSHIFT   = DEF_BUCKET_SHIFT;
  267.     hashp->SGSIZE   = DEF_SEGSIZE;
  268.     hashp->SSHIFT   = DEF_SEGSIZE_SHIFT;
  269.     hashp->DSIZE    = DEF_DIRSIZE;
  270.     hashp->FFACTOR  = DEF_FFACTOR;
  271.     hashp->hash     = default_hash;
  272.     bzero (hashp->SPARES, sizeof (hashp->SPARES));
  273.  
  274.     if ( info ) {
  275.         if ( info->bsize )   {
  276.         /* Round pagesize up to power of 2 */
  277.         hashp->BSHIFT  = __log2(info->bsize);
  278.         hashp->BSIZE   = 1 << hashp->BSHIFT;
  279.         if ( hashp->BSIZE > MAX_BSIZE ) {
  280.             errno = EINVAL;
  281.             return(0);
  282.         }
  283.         }
  284.         if ( info->ffactor )  hashp->FFACTOR = info->ffactor;
  285.         if ( info->hash ) hashp->hash    = info->hash;
  286.         if ( info->nelem ) nelem = info->nelem;
  287.         if ( info->lorder ) {
  288.         if ( info->lorder != BIG_ENDIAN && 
  289.              info->lorder != LITTLE_ENDIAN) {
  290.             errno = EINVAL;
  291.             return(0);
  292.         }
  293.         hashp->LORDER = info->lorder;
  294.         }
  295.     }
  296.  
  297.     /* init_htab should destroy the table and set errno if it fails */
  298.     if ( init_htab ( nelem ) ) {
  299.         return(0);
  300.     } else {
  301.         return(hashp);
  302.     }
  303. }
  304.  
  305. /*
  306.     This calls alloc_segs which may run out of memory.
  307.     Alloc_segs will destroy the table and set errno,
  308.     so we just pass the error information along.
  309.  
  310.     Returns 0 on No Error
  311.  
  312. */
  313. static int
  314. init_htab ( nelem )
  315. int    nelem;
  316. {
  317.     register SEGMENT    *segp;
  318.     register int nbuckets;
  319.     register int nsegs;
  320.     int    l2;
  321.  
  322.  /*
  323.   * Divide number of elements by the fill factor and determine a desired
  324.   * number of buckets.  Allocate space for the next greater power of
  325.   * two number of buckets
  326.   */
  327.     nelem = (nelem - 1) / hashp->FFACTOR + 1;
  328.  
  329.     l2 = __log2(nelem);
  330.     nbuckets = 1 << l2;
  331.     nbuckets = MAX ( nbuckets, 2 );
  332.  
  333.     hashp->SPARES[l2] = l2 + 1;
  334.     hashp->SPARES[l2+1] = l2 + 1;
  335.     /* 
  336.         First bitmap page is at:
  337.         splitpoint l2
  338.         page offset 1
  339.     */
  340.     __init_bitmap ( OADDR_OF(l2,1), l2+1, 0 );
  341.  
  342.     hashp->MAX_BUCKET = hashp->LOW_MASK = nbuckets - 1;
  343.     hashp->HIGH_MASK = (nbuckets << 1) - 1;
  344.     hashp->HDRPAGES = ((MAX(sizeof(HASHHDR),MINHDRSIZE) - 1) >> 
  345.               hashp->BSHIFT) + 1;
  346.  
  347.     nsegs = (nbuckets - 1) / hashp->SGSIZE + 1;
  348.     nsegs = 1 << __log2(nsegs);
  349.  
  350.     if ( nsegs > hashp->DSIZE ) {
  351.         hashp->DSIZE  = nsegs;
  352.     }
  353.  
  354.     return (alloc_segs ( nsegs ) );
  355. }
  356.  
  357. /********************** DESTROY/CLOSE ROUTINES ************************/
  358.  
  359. /*
  360.     Flushes any changes to the file if necessary and
  361.     destroys the hashp structure, freeing all allocated
  362.     space.
  363. */
  364. static int
  365. hdestroy()
  366. {
  367.     int    save_errno;
  368.     int    i;
  369.  
  370.     save_errno = 0;
  371.  
  372.     if (hashp != NULL) {
  373. #ifdef HASH_STATISTICS
  374.      (void)    fprintf(stderr,    "hdestroy: accesses %ld collisions %ld\n",
  375.             hash_accesses, hash_collisions);
  376.      (void)    fprintf(stderr, "hdestroy: expansions %ld\n",
  377.             hash_expansions);
  378.      (void)    fprintf(stderr, "hdestroy: overflows %ld\n",
  379.             hash_overflows);
  380.      (void)    fprintf(stderr,    "keys %ld maxp %d segmentcount %d\n",
  381.             hashp->NKEYS, hashp->MAX_BUCKET, hashp->nsegs);
  382.  
  383.     for ( i = 0; i < NCACHED; i++ ) {
  384.         (void) fprintf ( stderr, "spares[%d] = %d\n", i, hashp->SPARES[i] );
  385.     }
  386. #endif
  387.  
  388.         /* 
  389.             Call on buffer manager to free buffers, and if
  390.             required, write them to disk
  391.         */
  392.         if (__buf_free(1, hashp->save_file)) {
  393.             save_errno = errno;
  394.         }
  395.         if ( hashp->dir ) {
  396.             (void)free(*hashp->dir);    /* Free initial segments */
  397.             /* Free extra segments */
  398.             while ( hashp->exsegs-- ) {
  399.             (void)free ( hashp->dir[--hashp->nsegs] );
  400.             }
  401.             (void)free(hashp->dir);
  402.         }
  403.         if (flush_meta() && !save_errno) {
  404.             save_errno = errno;
  405.         }
  406.  
  407.         /* Free Bigmaps */
  408.         for ( i = 0; i < hashp->nmaps; i++ ) {
  409.             if ( hashp->mapp[i] ) {
  410.             (void) free ( hashp->mapp[i] );
  411.             }
  412.         }
  413.  
  414.         if ( hashp->fp != -1 ) {
  415.             (void)close (hashp->fp);
  416.         }
  417.         (void)free(hashp);
  418.         hashp = NULL;
  419.     }
  420.     if ( save_errno ) {
  421.         errno = save_errno;
  422.         return(ERROR);
  423.     } else {
  424.         return(SUCCESS);
  425.     }
  426. }
  427.  
  428. /* 
  429.     Write modified pages to disk 
  430.     0 == OK
  431.     -1 ERROR
  432. */
  433. static int
  434. hash_sync(dbp)
  435. DB    *dbp;
  436. {
  437.     if ( !dbp ) {
  438.         return (ERROR);
  439.     }
  440.  
  441.     hashp = (HTAB *)dbp->internal;
  442.  
  443.     if (!hashp->save_file) return(0);
  444.     if ( __buf_free ( 0, 1 )  || flush_meta()) {
  445.         return(ERROR);
  446.     }
  447.     hashp->new_file = 0;
  448.     return(0);
  449. }
  450.  
  451. /*
  452. 0 == OK
  453. -1 indicates that errno should be set
  454. */
  455. static int
  456. flush_meta()
  457. {
  458.         int    fp;
  459.     int    hdrsize;
  460.     int    i;
  461.     int    wsize;
  462.     HASHHDR    *whdrp;
  463.     HASHHDR    whdr;
  464.  
  465.     if (!hashp->save_file) return(0);
  466.     hashp->MAGIC = HASHMAGIC;
  467.     hashp->VERSION = VERSION_NO;
  468.     hashp->H_CHARKEY = hashp->hash ( CHARKEY, sizeof(CHARKEY));
  469.  
  470.     fp = hashp->fp;
  471.     whdrp = &hashp->hdr;
  472. #if BYTE_ORDER == LITTLE_ENDIAN
  473.     whdrp = &whdr;
  474.     swap_header_copy( &hashp->hdr, whdrp );
  475. #endif
  476.     if ( (lseek (fp, 0, SEEK_SET) == -1 ) ||
  477.          ((wsize = write ( fp, whdrp, sizeof(HASHHDR))) == -1)) {
  478.         return(-1);
  479.     } else if ( wsize != sizeof(HASHHDR) ) {
  480.         errno = EFTYPE;
  481.         hashp->errno = errno;
  482.         return(-1);
  483.     }
  484.     for ( i = 0; i < NCACHED; i++ ) {
  485.         if ( hashp->mapp[i] ) {
  486.         if (!__put_page((char *)hashp->mapp[i],
  487.             hashp->BITMAPS[i], 0, 1)){
  488.             return(-1);
  489.         }
  490.         }
  491.     }
  492.     return(0);
  493. }
  494. /*******************************SEARCH ROUTINES *****************************/
  495. /*
  496.     All the access routines return 
  497.     0 on SUCCESS
  498.     1 to indicate an external ERROR (i.e. key not found, etc)
  499.     -1 to indicate an internal ERROR (i.e. out of memory, etc)
  500. */
  501. static int
  502. hash_get ( dbp, key, data, flag )
  503. DB    *dbp;
  504. DBT    *key, *data;
  505. u_int    flag;
  506. {
  507. #ifdef lint
  508.     flag = flag;
  509. #endif
  510.  
  511.     if ( !dbp ) {
  512.     return (ERROR);
  513.     }
  514.     hashp = (HTAB *)dbp->internal;
  515.     if ( hashp->flags & O_WRONLY ) {
  516.     errno = EBADF;
  517.     hashp->errno = errno;
  518.     return ( ERROR );
  519.     }
  520.     return ( hash_access ((ACTION) HASH_GET, key, data ) );
  521. }
  522.  
  523. static int
  524. hash_put ( dbp, key, data, flag )
  525. DB    *dbp;
  526. DBT     *key, *data;
  527. u_int    flag;
  528. {
  529.     if ( !dbp ) {
  530.     return (ERROR);
  531.     }
  532.     hashp = (HTAB *)dbp->internal;
  533.     if ( (hashp->flags & O_ACCMODE) == O_RDONLY ) {
  534.     errno = EBADF;
  535.     hashp->errno = errno;
  536.     return ( ERROR );
  537.     }
  538.     if ( flag == R_NOOVERWRITE ) {
  539.     return ( hash_access ( HASH_PUTNEW, key, data ) );
  540.     } else {
  541.     return ( hash_access ( HASH_PUT, key, data ) );
  542.     }
  543. }
  544.  
  545. static int
  546. hash_delete ( dbp, key, flag )
  547. DB    *dbp;
  548. DBT     *key;
  549. u_int    flag;        /* Ignored */
  550. {
  551. #ifdef lint
  552.     flag = flag;
  553. #endif
  554.     if ( !dbp ) {
  555.     return (ERROR);
  556.     }
  557.     hashp = (HTAB *)dbp->internal;
  558.     if ( (hashp->flags & O_ACCMODE) == O_RDONLY ) {
  559.     errno = EBADF;
  560.     hashp->errno = errno;
  561.     return ( ERROR );
  562.     }
  563.     return ( hash_access ( HASH_DELETE, key, NULL ) );
  564. }
  565.  
  566. /*
  567.     Assume that hashp has been set in wrapper routine
  568. */
  569. static int
  570. hash_access(action, key, val)
  571. ACTION action;
  572. DBT *key, *val;
  573. {
  574.     register    BUFHEAD    *rbufp;
  575.     register    u_short    *bp;
  576.     register    int    ndx;
  577.     register     int n;
  578.     register     int off = hashp->BSIZE;
  579.     register    int        size;
  580.     register    char    *kp;
  581.     BUFHEAD    *bufp;
  582.     BUFHEAD    *save_bufp;
  583.     u_short    pageno;
  584.  
  585. #ifdef HASH_STATISTICS
  586.     hash_accesses++;
  587. #endif
  588.  
  589.     size = key->size;
  590.     kp = (char *)key->data;
  591.     rbufp = __get_buf ( __call_hash(kp, size), NULL, 0 );
  592.     if ( !rbufp ) return(ERROR);
  593.     save_bufp = rbufp;
  594.  
  595.     /* Pin the bucket chain */
  596.     rbufp->flags |= BUF_PIN;
  597.     for ( bp = (u_short *)rbufp->page, n = *bp++, ndx = 1; ndx < n;  ) {
  598.         if ( bp[1] >= REAL_KEY ) {
  599.         /* Real key/data pair */
  600.         if (size == off - *bp && 
  601.             bcmp(kp, rbufp->page + *bp, size) == 0) {
  602.             goto found;
  603.         }
  604.         off = bp[1];
  605. #ifdef HASH_STATISTICS
  606.         hash_collisions++;
  607. #endif
  608.             bp += 2; 
  609.             ndx += 2;
  610.         } else if ( bp[1] == OVFLPAGE ) {
  611.         rbufp = __get_buf ( *bp, rbufp, 0 );
  612.         if ( !rbufp ) {
  613.             save_bufp->flags &= ~BUF_PIN;
  614.             return (ERROR);
  615.         }
  616.         /* FOR LOOP INIT */
  617.         bp = (u_short *)rbufp->page;
  618.         n = *bp++;
  619.         ndx = 1;
  620.         off = hashp->BSIZE;
  621.         } else if ( bp[1] < REAL_KEY ) {
  622.         if ( (ndx = __find_bigpair(rbufp, ndx, kp, size )) > 0 ) {
  623.             goto found;
  624.         } else if ( ndx == -2 ) {
  625.             bufp = rbufp;
  626.             if ( !(pageno = __find_last_page ( &bufp )) ) {
  627.             ndx = 0;
  628.             rbufp = bufp;
  629.             break;    /* FOR */
  630.             }
  631.             rbufp = __get_buf ( pageno, bufp, 0 );
  632.             if ( !rbufp ) {
  633.             save_bufp->flags &= ~BUF_PIN;
  634.             return (ERROR);
  635.             }
  636.             /* FOR LOOP INIT */
  637.             bp = (u_short *)rbufp->page;
  638.             n = *bp++;
  639.             ndx = 1;
  640.             off = hashp->BSIZE;
  641.         } else  {
  642.             save_bufp->flags &= ~BUF_PIN;
  643.             return(ERROR);
  644.         }
  645.         } 
  646.     }
  647.  
  648.     /* Not found */
  649.     switch ( action ) {
  650.         case HASH_PUT:
  651.         case HASH_PUTNEW:
  652.         if (__addel(rbufp, key, val)) {
  653.             save_bufp->flags &= ~BUF_PIN;
  654.             return(ERROR);
  655.         } else {
  656.             save_bufp->flags &= ~BUF_PIN;
  657.             return(SUCCESS);
  658.         }
  659.         case HASH_GET:
  660.         case HASH_DELETE:
  661.         default:
  662.         save_bufp->flags &= ~BUF_PIN;
  663.         return(ABNORMAL);
  664.     }
  665.  
  666. found:
  667.     switch (action) {
  668.         case HASH_PUTNEW:
  669.         save_bufp->flags &= ~BUF_PIN;
  670.         return(ABNORMAL);
  671.         case HASH_GET:
  672.         bp = (u_short *)rbufp->page;
  673.         if (bp[ndx+1] < REAL_KEY) __big_return(rbufp, ndx, val, 0);
  674.         else {
  675.             val->data = (u_char *)rbufp->page + (int) bp[ndx + 1];
  676.             val->size = bp[ndx] - bp[ndx + 1];
  677.         }
  678.         break;
  679.         case HASH_PUT:
  680.         if ((__delpair (rbufp, ndx)) || (__addel (rbufp, key, val)) ) {
  681.             save_bufp->flags &= ~BUF_PIN;
  682.             return(ERROR);
  683.         }
  684.         break;
  685.         case HASH_DELETE:
  686.         if (__delpair (rbufp, ndx))return(ERROR);
  687.         break;
  688.     }
  689.     save_bufp->flags &= ~BUF_PIN;
  690.     return (SUCCESS);
  691. }
  692.  
  693. static int
  694. hash_seq(dbp, key, data, flag)
  695. DB    *dbp;
  696. DBT     *key, *data;
  697. u_int    flag;
  698. {
  699.     register    u_int bucket;
  700.     register    BUFHEAD    *bufp;
  701.     BUFHEAD    *save_bufp;
  702.     u_short    *bp;
  703.     u_short    ndx;
  704.     u_short    pageno;
  705.  
  706.     if ( !dbp ) {
  707.         return (ERROR);
  708.     }
  709.  
  710.     hashp = (HTAB *)dbp->internal;
  711.     if ( hashp->flags & O_WRONLY ) {
  712.         errno = EBADF;
  713.         hashp->errno = errno;
  714.         return ( ERROR );
  715.     }
  716. #ifdef HASH_STATISTICS
  717.     hash_accesses++;
  718. #endif
  719.  
  720.     if ( (hashp->cbucket < 0) || (flag == R_FIRST) ) {
  721.         hashp->cbucket = 0;
  722.         hashp->cndx = 1;
  723.         hashp->cpage = NULL;
  724.     }
  725.  
  726.     if ( !(bufp = hashp->cpage) ) {
  727.         for (bucket = hashp->cbucket; 
  728.          bucket <= hashp->MAX_BUCKET; 
  729.          bucket++, hashp->cndx = 1 ) {
  730.  
  731.         bufp = __get_buf ( bucket, NULL, 0 );
  732.         if (!bufp) return(ERROR);
  733.         hashp->cpage = bufp;
  734.         bp = (u_short *)bufp->page;
  735.         if (bp[0]) break;
  736.         }
  737.         hashp->cbucket = bucket;
  738.         if ( hashp->cbucket > hashp->MAX_BUCKET ) {
  739.         hashp->cbucket = -1;
  740.         return ( ABNORMAL );
  741.         } 
  742.     } else {
  743.         bp  = (u_short *)hashp->cpage->page;
  744.     }
  745.  
  746. #ifdef DEBUG
  747.     assert (bp);
  748.     assert (bufp);
  749. #endif
  750.     while ( bp[hashp->cndx+1] == OVFLPAGE ) {
  751.         bufp = hashp->cpage = __get_buf ( bp[hashp->cndx], bufp, 0 );
  752.         if (!bufp) return(ERROR);
  753.         bp = (u_short *)(bufp->page);
  754.         hashp->cndx = 1;
  755.     }
  756.     ndx = hashp->cndx;
  757.     if (bp[ndx+1] < REAL_KEY) {
  758.         if (__big_keydata(bufp, ndx, key, data, 1)) {
  759.         return(ERROR);
  760.         }
  761.     } else {
  762.         key->data = (u_char *)hashp->cpage->page + bp[ndx];
  763.         key->size = (ndx > 1 ? bp[ndx-1] : hashp->BSIZE) - bp[ndx];
  764.         data->data = (u_char *)hashp->cpage->page + bp[ndx + 1];
  765.         data->size = bp[ndx] - bp[ndx + 1];
  766.         ndx += 2;
  767.         if ( ndx > bp[0] ) {
  768.         hashp->cpage = NULL;
  769.         hashp->cbucket++;
  770.         hashp->cndx=1;
  771.         } else hashp->cndx = ndx;
  772.     }
  773.     return (SUCCESS);
  774. }
  775.  
  776. /********************************* UTILITIES ************************/
  777. /*
  778.     0 ==> OK
  779.     -1 ==> Error
  780. */
  781. extern int
  782. __expand_table()
  783. {
  784.     u_int    old_bucket, new_bucket;
  785.     int    new_segnum;
  786.     int    dirsize;
  787.     int    spare_ndx;
  788.     register    char **old, **new;
  789. #ifdef HASH_STATISTICS
  790.     hash_expansions++;
  791. #endif
  792.  
  793.     new_bucket = ++hashp->MAX_BUCKET;
  794.     old_bucket = (hashp->MAX_BUCKET & hashp->LOW_MASK);
  795.  
  796.     new_segnum = new_bucket >> hashp->SSHIFT;
  797.  
  798.     /* Check if we need a new segment */
  799.     if ( new_segnum >= hashp->nsegs ) {
  800.  
  801.         /* Check if we need to expand directory */
  802.         if ( new_segnum >= hashp->DSIZE ) {
  803.  
  804.         /* Reallocate directory */
  805.         dirsize = hashp->DSIZE * sizeof ( SEGMENT * );
  806.         if (!hash_realloc ( &hashp->dir, dirsize, (dirsize << 1 ) )) {
  807.             return(-1);
  808.         }
  809.         hashp->DSIZE = dirsize << 1;
  810.         }
  811.         if (!(hashp->dir[new_segnum] = 
  812.             (SEGMENT)calloc ( hashp->SGSIZE, sizeof(SEGMENT)))) {
  813.             return(-1);
  814.         }
  815.         hashp->exsegs++;
  816.         hashp->nsegs++;
  817.     }
  818.  
  819.     /*
  820.         If the split point is increasing (MAX_BUCKET's log
  821.         base 2 increases), we need to copy the current contents
  822.         of the spare split bucket to the next bucket
  823.     */
  824.     spare_ndx = __log2(hashp->MAX_BUCKET);
  825.     if ( spare_ndx != (__log2(hashp->MAX_BUCKET - 1))) {
  826.         hashp->SPARES[spare_ndx] = hashp->SPARES[spare_ndx-1];
  827.     }
  828.  
  829.     if ( new_bucket > hashp->HIGH_MASK ) {
  830.         /* Starting a new doubling */
  831.         hashp->LOW_MASK = hashp->HIGH_MASK;
  832.         hashp->HIGH_MASK = new_bucket | hashp->LOW_MASK;
  833.     }
  834.  
  835.     /*
  836.      * Relocate records to the new bucket
  837.      */
  838.     return(__split_page ( old_bucket, new_bucket ));
  839. }
  840. /*
  841.     If realloc guarantees that the pointer is not destroyed
  842.     if the realloc fails, then this routine can go away
  843. */
  844. static char * 
  845. hash_realloc ( p_ptr, oldsize, newsize )
  846. char    **p_ptr;
  847. int    oldsize;
  848. int    newsize;
  849. {
  850.     register char    *p;
  851.  
  852.     if (p = (char *)malloc ( newsize ) ) {
  853.         bcopy ( *p_ptr, p, oldsize );
  854.         bzero ( *p_ptr + oldsize, newsize-oldsize );
  855.         free(*p_ptr);
  856.         *p_ptr = p;
  857.     }
  858.     return (p);
  859. }
  860.  
  861. extern u_int
  862. __call_hash ( k, len )
  863. char    *k;
  864. int    len;
  865. {
  866.     int    n, bucket;
  867.     n = hashp->hash(k, len);
  868.  
  869.     bucket = n & hashp->HIGH_MASK;
  870.     if ( bucket > hashp->MAX_BUCKET ) {
  871.         bucket = bucket & hashp->LOW_MASK;
  872.     }
  873.  
  874.     return(bucket);
  875. }
  876.  
  877. /*
  878.     Allocate segment table.  On error, destroy the table
  879.     and set errno.
  880.  
  881.     Returns 0 on success
  882. */
  883. static int
  884. alloc_segs ( nsegs )
  885. int    nsegs;
  886. {
  887.     register int    i;
  888.     register SEGMENT    store;
  889.  
  890.     int    save_errno;
  891.  
  892.     if (!(hashp->dir = (SEGMENT *)calloc(hashp->DSIZE, sizeof(SEGMENT *)))) {
  893.     save_errno = errno;
  894.     (void)hdestroy();
  895.     errno = save_errno;
  896.     return(-1);
  897.     }
  898.  
  899.     /* Allocate segments */
  900.     store = (SEGMENT)calloc ( nsegs << hashp->SSHIFT, sizeof (SEGMENT) );
  901.     if ( !store ) {
  902.     save_errno = errno;
  903.     (void)hdestroy();
  904.     errno = save_errno;
  905.     return(-1);
  906.     }
  907.  
  908.     for ( i=0; i < nsegs; i++, hashp->nsegs++ ) {
  909.     hashp->dir[i] = &store[i<<hashp->SSHIFT];
  910.     }
  911.     return(0);
  912. }
  913.  
  914. /*
  915.     Hashp->hdr needs to be byteswapped.
  916. */
  917. static void
  918. swap_header_copy ( srcp, destp )
  919. HASHHDR    *srcp;
  920. HASHHDR    *destp;
  921. {
  922.     int i;
  923.  
  924.     BLSWAP_COPY(srcp->magic, destp->magic);
  925.     BLSWAP_COPY(srcp->version, destp->version);
  926.     BLSWAP_COPY(srcp->lorder, destp->lorder);
  927.     BLSWAP_COPY(srcp->bsize, destp->bsize);
  928.     BLSWAP_COPY(srcp->bshift, destp->bshift);
  929.     BLSWAP_COPY(srcp->dsize, destp->dsize);
  930.     BLSWAP_COPY(srcp->ssize, destp->ssize);
  931.     BLSWAP_COPY(srcp->sshift, destp->sshift);
  932.     BLSWAP_COPY(srcp->max_bucket, destp->max_bucket);
  933.     BLSWAP_COPY(srcp->high_mask, destp->high_mask);
  934.     BLSWAP_COPY(srcp->low_mask, destp->low_mask);
  935.     BLSWAP_COPY(srcp->ffactor, destp->ffactor);
  936.     BLSWAP_COPY(srcp->nkeys, destp->nkeys);
  937.     BLSWAP_COPY(srcp->hdrpages, destp->hdrpages);
  938.     BLSWAP_COPY(srcp->h_charkey, destp->h_charkey);
  939.     for ( i=0; i < NCACHED; i++ ) {
  940.     BLSWAP_COPY ( srcp->spares[i] , destp->spares[i]);
  941.     BSSWAP_COPY ( srcp->bitmaps[i] , destp->bitmaps[i]);
  942.     }
  943.     return;
  944. }
  945.  
  946. static void
  947. swap_header ( )
  948. {
  949.     HASHHDR    *hdrp;
  950.     int    i;
  951.  
  952.     hdrp = &hashp->hdr;
  953.  
  954.     BLSWAP(hdrp->magic);
  955.     BLSWAP(hdrp->version);
  956.     BLSWAP(hdrp->lorder);
  957.     BLSWAP(hdrp->bsize);
  958.     BLSWAP(hdrp->bshift);
  959.     BLSWAP(hdrp->dsize);
  960.     BLSWAP(hdrp->ssize);
  961.     BLSWAP(hdrp->sshift);
  962.     BLSWAP(hdrp->max_bucket);
  963.     BLSWAP(hdrp->high_mask);
  964.     BLSWAP(hdrp->low_mask);
  965.     BLSWAP(hdrp->ffactor);
  966.     BLSWAP(hdrp->nkeys);
  967.     BLSWAP(hdrp->hdrpages);
  968.     BLSWAP(hdrp->h_charkey);
  969.     for ( i=0; i < NCACHED; i++ ) {
  970.     BLSWAP ( hdrp->spares[i] );
  971.     BSSWAP ( hdrp->bitmaps[i] );
  972.     }
  973.     return;
  974. }
Jul 19 '10 #1
3 1686
newb16
687 512MB
Where is line 521? What does it have similar to other four error location with the same message?
Jul 19 '10 #2
ya, all the the four error locations contain the following line:

hashp->errno = errno;
Jul 20 '10 #3
Banfa
9,065 Expert Mod 8TB
The problem is probably the errno member of the HTAB structure.

Originally errno, as defined in errno.h was just an integer declared

extern int errno;

However in modern implementations, for various reasons mainly to do with thread safety, errno is sometimes declared as a macro calling another function(s).

In this case the expression hashp->errno will have errno substituted by whatever the macro defines which is what is causing an error that apparently makes no sense for the obvious line of code.

Your only real solution is to rename the errno member of HTAB to something else.
Jul 20 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Raghul | last post by:
I am getting this error while copying n number of messages to the folder using imaplib.What to do to copy n number of folders in mail The error i got is imaplib.error: command COPY illegal in...
1
by: timVerizon | last post by:
Hoping someone can help here.. Our application (C#.Net) was receiving IBM.Data.DB2.DB2Exceptions ERROR SQL0904N Unsuccessful execution caused by an unavailable resource. Reason code: '', type...
1
by: chanmm | last post by:
I hit the problem in my WinXP can someone help me: The Web server reported the following error when attempting to create or open the Web project located at the following URL:...
1
by: Greg Burns | last post by:
--------------------------- Microsoft Development Environment --------------------------- The Web server reported the following error when attempting to create or open the Web project located at...
2
by: Error when creating new asp.net applicat | last post by:
Hi, I'm getting this error when I create a asp.net application. The Web server reported the following error when attempting to create or open the Web projects located at the following URL:...
10
by: Shawn | last post by:
JIT Debugging failed with the following error: Access is denied. JIT Debugging was initiated by the following account 'PLISKEN\ASPNET' I get this messag in a dialog window when I try to open an...
2
by: mike_li | last post by:
On Window 2000 Professional Server DB2 UDB Level: DB2 code release "SQL07029" with level identifie "030A0105" and informational tokens "DB2 v7.1.0.98", "n040510" and "WR21337". In the...
0
by: howardr101 | last post by:
Hi, Have hunted around on the groups and can't find anything, hence. I've tried this against 2 mail servers (mailtraq and hmailserver) and it occus with both. The problems seems to be that...
6
by: friend.05 | last post by:
I am able to compile the program, but while building it I am getting following error,can any explain when does this error mean. Command Lines Creating temporary file...
3
by: deneushasler | last post by:
Hello my name is Juan Jose. My problem is as follows. When I try to insert a record into a table (access) to control DetailsView Visual Web Developer 2005, when I run the page and insert a record...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.