Esempio n. 1
0
File: asm2.c Progetto: norayr/kronos
void  Pass2 ()

{
char * strcat (), * malloc();

 if (verbose > 1)
  fprintf (stderr, "Pass 2  ---  Optimization\n");

 maxfun = SETOFF (maxfun, 4); 

 bufsize = max (poolsize, maxfun);
 if ((buf1 = malloc (bufsize)) == (char *)0 ||
     (buf2 = malloc (bufsize)) == (char *)0) {
  unlink(ofname);
  error ("Not enough memory\n\n");
  }

 fflush (fpcode);
 fflush (fpinit);
 fflush (fpallo);
 fflush (fpobj);
 fdobj = fileno(fpobj);

 fsize = HDSIZE * 4 + poolsize;
 lseek(fdobj, (long)fsize, 0);
 /* reuse the space of jump labels table */
 lab = (int *) jlabels;
 * lab = 0;

 inittable();
 export ();
Esempio n. 2
0
/**
 * Create a fingerprint: 
 * - record the frequency of each unique n-gram in a hash table
 * - take the most frequent n-grams
 * - sort them alphabetically, recording their relative rank
 */
extern int fp_Create( void *handle, const char *buffer, uint4 bufsize, uint4 maxngrams )
{
	sint4 i = 0;
	fp_t *h = NULL;
	table_t *t  = NULL;
	char *tmp   = NULL;

	if ( bufsize < MINDOCSIZE ) {
		return 0;
	}

	/*** Throw out all invalid chars ***/
	tmp = prepbuffer( buffer, bufsize ); 	
	if ( tmp == NULL ) {
		return 0;
	}

	h = (fp_t*)handle;
	t = inittable(maxngrams);

	/*** Create a hash table containing n-gram counts ***/
	createngramtable(t, tmp);

	/*** Take the top N n-grams and add them to the profile ***/
	table2heap(t);	
	maxngrams = WGMIN( maxngrams, t->size );       

	h->fprint = (ngram_t *)wg_malloc( sizeof(ngram_t) * maxngrams );
	h->size = maxngrams;

	/*** Pull n-grams out of heap (backwards) ***/
	for (i=maxngrams-1; i>=0; i--) {

		entry_t tmp2;

		heapextract(t, &tmp2);
		
		/*** the string and its rank is all we need ***/
		strcpy( h->fprint[i].str, tmp2.str );
		h->fprint[i].rank = i;
	}

	tabledone(t);
	wg_free(tmp);

	/*** Sort n-grams alphabetically, for easy comparison ***/
	qsort( h->fprint, h->size, sizeof(ngram_t), ngramcmp_str ); 
	return 1;
}
Esempio n. 3
0
int main()
{
       int start;
       printf("\nDIJKSTRA ALGORITHM");
       readgraph();
       displaymat();
       inittable();
       printf("\nEnter the starting Vertex:");
       scanf("%d",&start);
       dj(start);
       printf("\nfinal:");
       displaytable();
       getch();
       return 0;
}
Esempio n. 4
0
void tableinit(GameTable* const gameStat) {
    for (int i = 0; i < Players; ++i) { // 代走させる処理
        if (gameStat->Player[i].ConnectionLost) {
            EnvTable::Instantiate()->PlayerDat[i].RemotePlayerFlag = 0;
            gameStat->Player[i].ConnectionLost = false;
        }
    }
    init_ai(gameStat);
    inittable(gameStat);
    // 局の開始で同期する。1.7系列まではこのとき落ち戻りが可能(落ち戻り機能は1.8で廃止されました)
    statsync(gameStat, mihajong_socket::protocol::Server_StartRound_Signature,
    [](GameTable* const gameStat, int ReceivedMsg) -> bool {
        if (ReceivedMsg == mihajong_socket::protocol::Server_StartRound_Signature) {
            return true;
        } else if (ReceivedMsg == 1023) { // 回線が切れてたら
            EnvTable::Instantiate()->GameMode = EnvTable::Standalone;
            for (int i = 0; i < Players; ++i)
                EnvTable::Instantiate()->PlayerDat[i].RemotePlayerFlag = 0;
            return true;
        } else {
            return false;
        }
    });
    // 牌譜バッファの初期化
    haifu::haifuinit();
    /* 卓の情報を同期 */
    syncTableStat(gameStat);
    // BGMを鳴らす
    choosebgm(gameStat);
    // 画面の準備
    screen(gameStat);
    // 洗牌
    tileshuffle(gameStat);
    // 賽を振る
    bool doraFlag = rolldice(gameStat, false, 0);
#ifndef GUOBIAO
    if (RuleData::chkRule("dice_roll", "roll_twice"))
#endif /* GUOBIAO */
        (void)rolldice(gameStat, doraFlag, 2); // 二度振りの2回目
    // 配牌
    haipai(gameStat);
    return;
}
Esempio n. 5
0
static unsigned char *_convert_lzw_dynamic(unsigned char *data_in,
                                   int max_bits,int use_rle,
                                   unsigned long in_len,
                                   unsigned long orig_len, int q,
				   struct local_data *data)
{
unsigned char *data_out;
int csize,orgcsize;
int newcode,oldcode,k=0;
int first=1,noadd;

//printf("in_len = %d, orig_len = %d\n", in_len, orig_len);
data->quirk = q;
data->global_use_rle=use_rle;
data->maxstr=(1<<max_bits);

if((data_out=malloc(orig_len))==NULL) {
  //fprintf(stderr,"nomarch: out of memory!\n");
  return NULL;
}

data->io.data_in_point=data_in; data->io.data_in_max=data_in+in_len;
data->io.data_out_point=data_out; data->io.data_out_max=data_out+orig_len;
data->dc_bitbox=data->dc_bitsleft=0;
data->codeofs=0;
outputrle(-1,NULL, &data->rd, &data->io);	/* init RLE */

data->oldver=0;
csize=9;		/* initial code size */
if(max_bits==0)		/* special case for static 12-bit */
  data->oldver=1,csize=12,data->maxstr=4096;
orgcsize=csize;
inittable(orgcsize, data);

oldcode=newcode=0;
if(data->quirk & NOMARCH_QUIRK_SKIPMAX)
  data->io.data_in_point++;	/* skip type 8 max. code size, always 12 */

if(max_bits==16)
  data->maxstr=(1<<*data->io.data_in_point++);	 /* but compress-type *may* change it (!) */

/* XXX */
if (data->maxstr > (1 << max_bits))
  return NULL;

data->nomarch_input_size = 0;

while(1)
  {
//printf("input_size = %d        csize = %d\n", data->nomarch_input_size, csize);
  if(!readcode(&newcode,csize,data)) {
//printf("readcode failed!\n");
    break;
}
//printf("newcode = %x\n", newcode);

  if (data->quirk & NOMARCH_QUIRK_END101) {
    if (newcode == 0x101 /* data_out_point>=data_out_max */) {
//printf("end\n");
      break;
    }
  }

  noadd=0;
  if(first)
    {
    k=newcode,first=0;
    if(data->oldver) noadd=1;
    }

  if(newcode==256 && !data->oldver)
    {
    /* this *doesn't* reset the table (!), merely reduces code size again.
     * (It makes new strings by treading on the old entries.)
     * This took fscking forever to work out... :-(
     */
    data->st_last=255;

    if (data->quirk & NOMARCH_QUIRK_START101)	/* CM: Digital symphony data->quirk */
      data->st_last++;
    
    /* XXX do we need a resync if there's a reset when *already* csize==9?
     * (er, assuming that can ever happen?)
     */
    code_resync(csize, data);
    csize=orgcsize;
    if(!readcode(&newcode,csize,data))
      break;
    }

  if((!data->oldver && newcode<=data->st_last) ||
     (data->oldver && data->st_chr[newcode]!=UNUSED))
    {
    outputstring(newcode, data);
    k=findfirstchr(newcode, data);
    }
  else
    {
    /* this is a bit of an assumption, but these ones don't seem to happen in
     * non-broken files, so...
     */
#if 0
    /* actually, don't bother, just let the CRC tell the story. */
    if(newcode>data->st_last+1)
      fprintf(stderr,"warning: bad LZW code\n");
#endif
/*    k=findfirstchr(oldcode);*/	/* don't think I actually need this */
    outputstring(oldcode, data);
    outputchr(k, data);
    }

  if(data->st_last!=data->maxstr-1)
    {
    if(!noadd)
      {
      if(!addstring(oldcode,k,data))
        {
        /* XXX I think this is meant to be non-fatal?
         * well, nothing for now, anyway...
         */
        }
      if(data->st_last!=data->maxstr-1 && data->st_last==((1<<csize)-1))
        {
        csize++;
        code_resync(csize-1, data);
        }
      }
    }
    
  oldcode=newcode;
  }

if (~data->quirk & NOMARCH_QUIRK_NOCHK) {
  /* junk it on error */
  if(data->io.data_in_point!=data->io.data_in_max) {
    free(data_out);
    return(NULL);
  }
}

return(data_out);
}
Esempio n. 6
0
void makedists()
{
  /* compute distance matrix */
  long i, j;
  double v;

  inittable();
  for (i = 0; i < endsite; i++)
    weightrat[i] = weight[i] * rate[category[alias[i] - 1] - 1];
  if (progress) {
    printf("Distances calculated for species\n");
#ifdef WIN32
    phyFillScreenColor();
#endif
  }
  for (i = 0; i < spp; i++)
    if (similarity)
      d[i][i] = 1.0;
    else
      d[i][i] = 0.0;
  baddists = false;
  
  float cur_prog = 0;
  int total = (spp*spp / 2) + 1;
  float step = (1.0f / total) * 100.0f;

  for (i = 1; i < spp; i++) {
    if (progress) {
      printf("    ");
      for (j = 0; j < nmlngth; j++)
        putchar(nayme[i - 1][j]);
      printf("   ");
    }
    for (j = i + 1; j <= spp; j++) {
      makev(i, j, &v);
      v = fabs(v);     
      if ( baddists == true ) {
        v = -1;
        baddists = false;
      }
      d[i - 1][j - 1] = v;
      d[j - 1][i - 1] = v;
      
      U2::TaskStateInfo* ts = U2::getTaskInfo();
      if (ts->cancelFlag != 0) {
          ugene_exit("Task canceled!");
      } else if(!U2::isBootstr()){
          cur_prog += step;
          ts->progress = int (cur_prog);   
      }
      
      if (progress) {
        putchar('.');
        fflush(stdout);
      }
    }
    if (progress) {
      putchar('\n');
#ifdef WIN32
      phyFillScreenColor();
#endif
    }
  }
  if (progress) {
    printf("    ");
    for (j = 0; j < nmlngth; j++)
      putchar(nayme[spp - 1][j]);
    putchar('\n');
  }
}  /* makedists */
Esempio n. 7
0
Table::Table(QWidget *parent)
    : QTableWidget(parent)
{
    inittable();
}