Beispiel #1
0
static void 
readLoop(int addfirst, int (*endTest)(char *,int *), struct ReadSeqVars *V)
{
  int addend = 0;
  int done   = 0;

  V->seqlen = 0;
  if (addfirst) addseq(V->sbuffer, V);
  do {
    getline2(V);
	/* feof() alone is a bug; files not necessarily \n terminated */
    if (*(V->sbuffer) == '\0' && feof(V->f))
      done = TRUE;
    done |= (*endTest)(V->sbuffer, &addend);
    if (addend || !done)
      addseq(V->sbuffer, V);
  } while (!done);
}
Beispiel #2
0
static void 
readUWGCG(struct ReadSeqVars *V)
{
  char  *si;
  char  *sptr;
  int    done;

  V->seqlen = 0;

  /*writeseq: "    %s  Length: %d  (today)  Check: %d  ..\n" */
  /*drop above or ".." from id*/
  if ((si = strstr(V->sbuffer,"  Length: ")) != NULL) *si = 0;
  else if ((si = strstr(V->sbuffer,"..")) != NULL)    *si = 0;

  if ((sptr = strtok(V->sbuffer, "\n\t ")) != NULL)
    SetSeqinfoString(V->sqinfo, sptr, SQINFO_NAME);

  do {
    done = feof(V->f);
    getline2(V);
    if (! done) addseq(V->sbuffer, V);
  } while (!done);
}
Beispiel #3
0
static void
parse_itab_line(char *buf, int fontlen)
{
	char *p, *p1;
	long i;
	long fp0, fp1, un0, un1;

	if ((p = strchr(buf, '\n')) != NULL)
		*p = 0;
	else {
		char *u = _("%s: Warning: line too long\n");
		fprintf(stderr, u, get_progname());
		exit(EX_DATAERR);
	}

	p = buf;

	while (*p == ' ' || *p == '\t')
		p++;
	if (!*p || *p == '#')
		return;

	fp0 = strtol(p, &p1, 0);
	if (p1 == p) {
		char *u = _("%s: Bad input line: %s\n");
		fprintf(stderr, u, get_progname(), buf);
		exit(EX_DATAERR);
	}
	p = p1;

	if (*p == '-') {
		p++;
		fp1 = strtol(p, &p1, 0);
		if (p1 == p) {
			char *u = _("%s: Bad input line: %s\n");
			fprintf(stderr, u, get_progname(), buf);
			exit(EX_DATAERR);
		}
		p = p1;
	} else
		fp1 = 0;

	if (fp0 < 0 || fp0 >= fontlen) {
		char *u = _("%s: Glyph number (0x%lx) past end of font\n");
		fprintf(stderr, u, get_progname(), fp0);
		exit(EX_DATAERR);
	}
	if (fp1 && (fp1 < fp0 || fp1 >= fontlen)) {
		char *u = _("%s: Bad end of range (0x%lx)\n");
		fprintf(stderr, u, get_progname(), fp1);
		exit(EX_DATAERR);
	}

	if (fp1) {
		/* we have a range; expect the word "idem"
		   or a Unicode range of the same length */
		while (*p == ' ' || *p == '\t')
			p++;
		if (!strncmp(p, "idem", 4)) {
			for (i = fp0; i <= fp1; i++)
				addpair(i, i);
			p += 4;
		} else {
			un0 = getunicode(&p);
			while (*p == ' ' || *p == '\t')
				p++;
			if (*p != '-') {
				char *u = _("%s: Corresponding to a range of "
				            "font positions, there should be "
				            "a Unicode range\n");
				fprintf(stderr, u, get_progname());
				exit(EX_DATAERR);
			}
			p++;
			un1 = getunicode(&p);
			if (un0 < 0 || un1 < 0) {
				char *u = _("%s: Bad Unicode range "
				            "corresponding to font position "
				            "range 0x%x-0x%x\n");
				fprintf(stderr, u, get_progname(), fp0, fp1);
				exit(EX_DATAERR);
			}
			if (un1 - un0 != fp1 - fp0) {
				char *u = _("%s: Unicode range U+%x-U+%x not "
				            "of the same length as font "
				            "position range 0x%x-0x%x\n");
				fprintf(stderr, u, get_progname(),
				        un0, un1, fp0, fp1);
				exit(EX_DATAERR);
			}
			for (i = fp0; i <= fp1; i++)
				addpair(i, un0 - fp0 + i);
		} /* not idem */
	} else {  /* no range */
		while ((un0 = getunicode(&p)) >= 0) {
			addpair(fp0, un0);
			while (*p++ == ',' && (un1 = getunicode(&p)) >= 0) {
				addseq(fp0, un1);
			}
			p--;
		}
		while (*p == ' ' || *p == '\t')
			p++;
		if (*p && *p != '#') {
			char *u = _("%s: trailing junk (%s) ignored\n");
			fprintf(stderr, u, get_progname(), p);
		}
	}
}
Beispiel #4
0
static void
readSquid(struct ReadSeqVars *V)
{
  char *sptr;
  int   dostruc = FALSE;

  while (strncmp(V->sbuffer, "NAM ", 4) != 0) getline2(V);

  if ((sptr = strtok(V->sbuffer+4, "\n\t ")) != NULL)
    SetSeqinfoString(V->sqinfo, sptr, SQINFO_NAME);

  /*CONSTCOND*/
  while (1)
    {
      getline2(V);
      if (feof(V->f)) {squid_errno = SQERR_FORMAT; return; }

      if (strncmp(V->sbuffer, "SRC ", 4) == 0)
	{
	  if ((sptr = strtok(V->sbuffer+4, " \t\n")) != NULL)
	    SetSeqinfoString(V->sqinfo, sptr, SQINFO_ID);
	  if ((sptr = strtok(NULL, " \t\n")) != NULL)
	    SetSeqinfoString(V->sqinfo, sptr, SQINFO_ACC);
	  if ((sptr = strtok(NULL, ".")) != NULL)
	    SetSeqinfoString(V->sqinfo, sptr, SQINFO_START);
	  if ((sptr = strtok(NULL, ".:")) != NULL)
	    SetSeqinfoString(V->sqinfo, sptr, SQINFO_STOP);
	  if ((sptr = strtok(NULL, ": \t\n")) != NULL)
	    SetSeqinfoString(V->sqinfo, sptr, SQINFO_OLEN);
	}
      else if (strncmp(V->sbuffer, "DES ", 4) == 0)
	{
	  if ((sptr = strtok(V->sbuffer+4, "\n")) != NULL)
	    SetSeqinfoString(V->sqinfo, sptr, SQINFO_DESC);
	}
      else if (strncmp(V->sbuffer,"SEQ", 3) == 0)
	break;
  }
  
  if (strstr(V->sbuffer, "+SS") != NULL) dostruc = TRUE;

  V->seqlen = 0;
  /*CONSTCOND*/
  while (1)
    {
				/* sequence line */
      getline2(V);
      if (feof(V->f) || strncmp(V->sbuffer, "++", 2) == 0) 
	break;
      addseq(V->sbuffer, V);
				/* structure line */
      if (dostruc)
	{
	  getline2(V);
	  if (feof(V->f)) { squid_errno = SQERR_FORMAT; return; }
	  addstruc(V->sbuffer, V);
	}
    }


  while (!feof(V->f) && strncmp(V->sbuffer, "NAM ", 4) != 0)
    getline2(V);
}