Пример #1
0
Файл: scan.c Проект: Ntools/n
searchnum(int num,char *name)
{
	SCRN *lp;
	char *p;

	p = name;
	while((p = strchr(p,'/')) != NULL) *p= '\\';
	if(lng != ASM && strcmp(name,editfile[edfile].filename)) fileset(name,OFF);

	for(lp = editfile[edfile].topline;lp->num != num;lp= lp->fwd) {
		if(lp == NULL) {
			msg("Illegal error file <illegal line number>\a");
			return(NG);
		}
	}
	line= lp;
	curposy= disset((lastdisplay-widbase)/2);
	curposx= 0;
	return(OK);
}
Пример #2
0
Файл: mem.c Проект: Ntools/n
int markgo(void)
{
	if(filenum != edfile) {
		msg("No mark !");
		return(NG);
	}
	if(smark.line != NULL && line == mark.line) {
		line= smark.line;
		curposx= smark.posx;
		msg("Curent line");
	}
	else {
		msg("Mark line");
		smark.line= line;
		smark.posx= curposx;
		line= mark.line;
		curposx= mark.posx;
	}
	curposy= disset(5);
	return(OK);
}
Пример #3
0
Файл: mem.c Проект: Ntools/n
int markcut(void)
{
	unsigned char *p, buf[BUFSIZ];
	SCRN *op,*lp;
	int ox, i;
	extern refr_flg;

	markcpy();
	ox = curposx;
	lp = markcp;
	if(lp == line) {
		for(i = 0;i < mark.posx;++i) buf[i] = lp->buffer[i];
		while(lp->buffer[ox]) buf[i++] = lp->buffer[ox++];
		buf[i] = '\0';
		curposx = mark.posx;
		update(buf, 0);
	}
	else if(lp->num < line->num) {
		lp->buffer[mark.posx] = '\0';
		p = &line->buffer[curposx];
		sprintf(buf, "%s%s", lp->buffer, p);
		line->rev = lp->rev;
		lp->rev->fwd = line;
		while(lp != line) {
			free(lp->buffer);
			op = lp;
			lp = lp->fwd;
			free(op);
		}
		free(line->buffer);
		line->buffer = memgets(buf);
		curposx = mark.posx;
		curposy = disset(5);
		refr_flg = last = OFF;
	}
	return(NG);
}
Пример #4
0
int linset(struct linprm *lin)

{
  static const char *function = "linset";

  int i, j, naxis, status;
  double *pc, *piximg;
  struct wcserr **err;

  if (lin == 0x0) return LINERR_NULL_POINTER;
  err = &(lin->err);

  naxis = lin->naxis;

  /* Check for a unit matrix. */
  lin->unity = 1;
  pc = lin->pc;
  for (i = 0; i < naxis; i++) {
    for (j = 0; j < naxis; j++) {
      if (j == i) {
        if (*(pc++) != 1.0) {
          lin->unity = 0;
          break;
        }
      } else {
        if (*(pc++) != 0.0) {
          lin->unity = 0;
          break;
        }
      }
    }
  }


  if (lin->unity) {
    if (lin->flag == LINSET) {
      /* Free memory that may have been allocated previously. */
      if (lin->piximg) free(lin->piximg);
      if (lin->imgpix) free(lin->imgpix);
    }

    lin->piximg  = 0x0;
    lin->imgpix  = 0x0;
    lin->i_naxis = 0;

    /* Check cdelt. */
    for (i = 0; i < naxis; i++) {
      if (lin->cdelt[i] == 0.0) {
        return wcserr_set(LIN_ERRMSG(LINERR_SINGULAR_MTX));
      }
    }

  } else {
    if (lin->flag != LINSET || lin->i_naxis < naxis) {
      if (lin->flag == LINSET) {
        /* Free memory that may have been allocated previously. */
        if (lin->piximg) free(lin->piximg);
        if (lin->imgpix) free(lin->imgpix);
      }

      /* Allocate memory for internal arrays. */
      if ((lin->piximg = calloc(naxis*naxis, sizeof(double))) == 0x0) {
        return wcserr_set(LIN_ERRMSG(LINERR_MEMORY));
      }

      if ((lin->imgpix = calloc(naxis*naxis, sizeof(double))) == 0x0) {
        free(lin->piximg);
        return wcserr_set(LIN_ERRMSG(LINERR_MEMORY));
      }

      lin->i_naxis = naxis;
    }

    /* Compute the pixel-to-image transformation matrix. */
    pc     = lin->pc;
    piximg = lin->piximg;
    for (i = 0; i < naxis; i++) {
      for (j = 0; j < naxis; j++) {
        if (lin->disseq == 0x0) {
          /* No sequent distortions, incorporate cdelt into piximg. */
          *(piximg++) = lin->cdelt[i] * (*(pc++));
        } else {
          *(piximg++) = *(pc++);
        }
      }
    }

    /* Compute the image-to-pixel transformation matrix. */
    if ((status = matinv(naxis, lin->piximg, lin->imgpix))) {
      return wcserr_set(LIN_ERRMSG(status));
    }
  }


  /* Set up the distortion functions. */
  lin->affine = 1;
  if (lin->dispre) {
    if ((status = disset(lin->dispre))) {
      return wcserr_set(LIN_ERRMSG(lin_diserr[status]));
    }

    lin->affine = 0;
  }

  if (lin->disseq) {
    if ((status = disset(lin->disseq))) {
      return wcserr_set(LIN_ERRMSG(lin_diserr[status]));
    }

    lin->affine = 0;
  }

  lin->simple = lin->unity && lin->affine;


  /* Create work arrays. */
  if (lin->tmpcrd) free(lin->tmpcrd);
  if ((lin->tmpcrd = calloc(naxis, sizeof(double))) == 0x0) {
    linfree(lin);
    return wcserr_set(LIN_ERRMSG(LINERR_MEMORY));
  }


  lin->flag = LINSET;

  return 0;
}