void semicolonarrsetfn(Param pm, char *x) { char ***dptr = (char ***)pm->data; freearray(*dptr); *dptr = x ? semicolonsplit(x, pm->flags & PM_UNIQUE) : mkarray(NULL); if (pm->ename) semicolon_arrfixenv(pm->nam, *dptr); }
LOCAL LVAL newmatrix P2C(int, m, int, n) { LVAL dim, result; xlsave1(dim); checknonneg(m); checknonneg(n); dim = integer_list_2(m, n); result = mkarray(dim, NIL, NIL, s_true); xlpop(); return result; }
static LVAL newmatrix P2C(unsigned, r, unsigned, c) { LVAL rows, cols, dim, result; xlstkcheck(3); xlsave(rows); xlsave(cols); xlsave(dim); rows = cvfixnum((FIXTYPE) r); cols = cvfixnum((FIXTYPE) c); dim = list2(rows, cols); result = mkarray(dim, NIL, NIL, s_true); xlpopn(3); return(result); }
local void mk_ccd(dyn* b, vec dc_pos, int project, wavelength band, real distance, real reddening, real upper_Llimit, real xoffset, real yoffset, real electrons_to_ADU, real beta_PSF, real arcsec_per_pixel, real fwhm, char* filename, bool add_background_stars, bool add_standard_star, int input_seed, bool add_cosmics, int nbad_column, bool verbose) { PRL(band); real maximum_electrons = electrons_to_ADU*SATURATION_LIMIT-1; real half_xccd = 0.5*XCCD_MAX*arcsec_per_pixel; real half_yccd = 0.5*YCCD_MAX*arcsec_per_pixel; real **ccd = mkarray(XCCD_MAX, YCCD_MAX); cerr << "CCD allocated"<<endl; for(int ix = 0; ix<XCCD_MAX; ix++) for(int iy = 0; iy<YCCD_MAX; iy++) ccd[ix][iy] = 0; PRL(distance); real distance_modulus = 5 * log10(distance/10.); PRC(distance_modulus); PRL(distance); // magnitude_limit -= distance_modulus; // real magnitude_limit = t_obs/10. - distance_modulus; // real luminosity_limit = pow(10, (4.76-magnitude_limit)/5.5); // in V // PRC(magnitude_limit); // PRL(luminosity_limit); real pos_to_parsec = b->get_starbase()->conv_r_dyn_to_star(1) * cnsts.parameters(Rsun)/cnsts.parameters(parsec); real pos_to_arcsec = b->get_starbase()->conv_r_dyn_to_star(1) * 3600 * cnsts.parameters(Rsun) / (distance*cnsts.parameters(parsec)); PRC(pos_to_parsec);PRL(pos_to_arcsec); real xpos, ypos, zpos; real M_max = VERY_LARGE_NUMBER; real local_Mmm=0, magn; real luminosity, L_max = 0; real xmax=0, ymax=0; vec r; if (b->get_oldest_daughter()) { vec r_com = b->get_pos() - dc_pos; for_all_leaves(dyn, b, bb) { // cerr << " new star: "; // cerr << bb->get_index()<<endl; r = bb->get_pos()-bb->get_parent()->get_pos(); // PRL(r); switch(project) { case -3: xpos = r[0]; ypos = r[1]; zpos = -r[2]; break; case -2: xpos = -r[0]; ypos = r[2]; zpos = -r[1]; break; case -1: xpos = -r[1]; ypos = r[2]; zpos = -r[0]; break; case 1: xpos = r[1]; ypos = r[2]; zpos = r[0]; break; case 2: xpos = r[0]; ypos = r[2]; zpos = r[1]; break; case 3: xpos = r[0]; ypos = r[1]; zpos = r[2]; break; } xpos = xpos * pos_to_arcsec + half_xccd - xoffset; ypos = ypos * pos_to_arcsec + half_yccd - yoffset; zpos *= pos_to_parsec; // PRC(zpos); if(distance+zpos>0) { real local_distance_modulus = 5 * log10((distance+zpos)/10.); // PRL(local_distance_modulus); luminosity = get_luminosity(bb, band, local_distance_modulus, maximum_electrons/upper_Llimit); // PRL(luminosity); if(L_max<luminosity) { L_max = luminosity; M_max = 4.76 - 2.5*log10(luminosity) - local_distance_modulus; local_Mmm = local_distance_modulus; xmax = xpos; //ascsec ymax = ypos; } if (luminosity<=0) { luminosity = 0; // cerr << "Stellar luminosity = " << luminosity << endl; // cerr << " star Not added to ccd"<<endl; } else { if (verbose) { real nx = xpos/arcsec_per_pixel; real ny = ypos/arcsec_per_pixel; if (nx>=-10 && nx<=XCCD_MAX && ny>=-10 && ny<=YCCD_MAX+10) { cerr << "Cluster star #" << bb->get_index() << " pos (x, y): " << nx << " " << ny << " pixels" << endl; cerr << " magnitudes (M, m): " << 4.76 - 2.5*log10(luminosity) - local_distance_modulus << " " << 4.76 - 2.5*log10(luminosity) <<endl; } } add_star_to_ccd(ccd, luminosity, xpos, ypos, beta_PSF, arcsec_per_pixel, fwhm); } } }
int main(int argc, char *argv[]) { if (argc < 3) usage(); exit(mkarray(argv[1], argv[2])); }
int init_term(void) { #ifndef TGETENT_ACCEPTS_NULL static char termbuf[2048]; /* the termcap buffer */ #endif if (!*term) return termok = TERM_BAD; /* unset zle if using zsh under emacs */ if (!strcmp(term, "emacs")) opts[USEZLE] = 0; #ifdef TGETENT_ACCEPTS_NULL /* If possible, we let tgetent allocate its own termcap buffer */ if (tgetent(NULL, term) != 1) { #else if (tgetent(termbuf, term) != 1) { #endif if (isset(INTERACTIVE)) zerr("can't find termcap info for %s", term, 0); errflag = 0; return termok = TERM_BAD; } else { char tbuf[1024], *pp; int t0; termok = TERM_OK; for (t0 = 0; t0 != TC_COUNT; t0++) { pp = tbuf; zsfree(tcstr[t0]); /* AIX tgetstr() ignores second argument */ if (!(pp = tgetstr(tccapnams[t0], &pp))) tcstr[t0] = NULL, tclen[t0] = 0; else { tclen[t0] = strlen(pp); tcstr[t0] = (char *) zalloc(tclen[t0] + 1); memcpy(tcstr[t0], pp, tclen[t0] + 1); } } /* check whether terminal has automargin (wraparound) capability */ hasam = tgetflag("am"); /* if there's no termcap entry for cursor up, use single line mode: * * this is flagged by termok which is examined in zle_refresh.c * */ if (!tccan(TCUP)) { tcstr[TCUP] = NULL; termok = TERM_NOUP; } /* if there's no termcap entry for cursor left, use \b. */ if (!tccan(TCLEFT)) { tcstr[TCLEFT] = ztrdup("\b"); tclen[TCLEFT] = 1; } /* if the termcap entry for down is \n, don't use it. */ if (tccan(TCDOWN) && tcstr[TCDOWN][0] == '\n') { tclen[TCDOWN] = 0; zsfree(tcstr[TCDOWN]); tcstr[TCDOWN] = NULL; } /* if there's no termcap entry for clear, use ^L. */ if (!tccan(TCCLEARSCREEN)) { tcstr[TCCLEARSCREEN] = ztrdup("\14"); tclen[TCCLEARSCREEN] = 1; } } return termok; } /* Initialize lots of global variables and hash tables */ /**/ void setupvals(void) { struct passwd *pswd; struct timezone dummy_tz; char *ptr; #ifdef HAVE_GETRLIMIT int i; #endif noeval = 0; curhist = 0; histsiz = DEFAULT_HISTSIZE; inithist(); clwords = (char **) zcalloc((clwsize = 16) * sizeof(char *)); cmdstack = (unsigned char *) zalloc(256); cmdsp = 0; bangchar = '!'; hashchar = '#'; hatchar = '^'; termok = TERM_BAD; curjob = prevjob = coprocin = coprocout = -1; gettimeofday(&shtimer, &dummy_tz); /* init $SECONDS */ srand((unsigned int)(shtimer.tv_sec + shtimer.tv_usec)); /* seed $RANDOM */ hostnam = (char *) zalloc(256); gethostname(hostnam, 256); /* Set default path */ path = (char **) zalloc(sizeof(*path) * 5); path[0] = ztrdup("/bin"); path[1] = ztrdup("/usr/bin"); path[2] = ztrdup("/usr/ucb"); path[3] = ztrdup("/usr/local/bin"); path[4] = NULL; cdpath = mkarray(NULL); manpath = mkarray(NULL); fignore = mkarray(NULL); fpath = mkarray(NULL); mailpath = mkarray(NULL); watch = mkarray(NULL); psvar = mkarray(NULL); #ifdef DYNAMIC module_path = mkarray(ztrdup(MODULE_DIR)); modules = newlinklist(); #endif /* Set default prompts */ if (opts[INTERACTIVE]) { prompt = ztrdup("%m%# "); prompt2 = ztrdup("%_> "); } else { prompt = ztrdup(""); prompt2 = ztrdup(""); } prompt3 = ztrdup("?# "); prompt4 = ztrdup("+ "); sprompt = ztrdup("zsh: correct '%R' to '%r' [nyae]? "); ifs = ztrdup(DEFAULT_IFS); wordchars = ztrdup(DEFAULT_WORDCHARS); postedit = ztrdup(""); underscore = ztrdup(""); zoptarg = ztrdup(""); zoptind = 1; schedcmds = NULL; ppid = (long) getppid(); mypid = (long) getpid(); term = ztrdup(""); #ifdef TIOCGWINSZ if (!(columns = shttyinfo.winsize.ws_col)) columns = 80; if (columns < 2) opts[USEZLE] = 0; if (!(lines = shttyinfo.winsize.ws_row)) lines = 24; if (lines < 2) opts[SINGLELINEZLE] = 1; #else columns = 80; lines = 24; #endif /* The following variable assignments cause zsh to behave more * * like Bourne and Korn shells when invoked as "sh" or "ksh". * * NULLCMD=":" and READNULLCMD=":" */ if (emulation == EMULATE_KSH || emulation == EMULATE_SH) { nullcmd = ztrdup(":"); readnullcmd = ztrdup(":"); } else { nullcmd = ztrdup("cat"); readnullcmd = ztrdup("more"); } /* We cache the uid so we know when to * * recheck the info for `USERNAME' */ cached_uid = getuid(); /* Get password entry and set info for `HOME' and `USERNAME' */ if ((pswd = getpwuid(cached_uid))) { home = metafy(pswd->pw_dir, -1, META_DUP); cached_username = ztrdup(pswd->pw_name); } else { home = ztrdup("/"); cached_username = ztrdup(""); } /* Try a cheap test to see if we can * * initialize `PWD' from `HOME' */ if (ispwd(home)) pwd = ztrdup(home); else if ((ptr = zgetenv("PWD")) && ispwd(ptr)) pwd = ztrdup(ptr); else pwd = metafy(zgetcwd(), -1, META_REALLOC); oldpwd = ztrdup(pwd); /* initialize `OLDPWD' = `PWD' */ #ifdef __EMX__ *cdrive = _getdrive(); strcat(cdrive+1,":"); #endif inittyptab(); /* initialize the ztypes table */ initlextabs(); /* initialize lexing tables */ createreswdtable(); /* create hash table for reserved words */ createaliastable(); /* create hash table for aliases */ createcmdnamtable(); /* create hash table for external commands */ createshfunctable(); /* create hash table for shell functions */ createbuiltintable(); /* create hash table for builtin commands */ createnameddirtable(); /* create hash table for named directories */ createparamtable(); /* create paramater hash table */ #ifdef ZLE_MODULE add_dep("compctl", "zle"); addbuiltin("bindkey", 0, NULL, 0, -1, "zle"); addbuiltin("vared", 0, NULL, 1, 7, "zle"); addbuiltin("compctl", 0, NULL, 0, -1, "compctl"); #endif #ifdef HAVE_GETRLIMIT for (i = 0; i != RLIM_NLIMITS; i++) { getrlimit(i, current_limits + i); limits[i] = current_limits[i]; } #endif breaks = loops = 0; lastmailcheck = time(NULL); locallist = NULL; locallevel = sourcelevel = 0; trapreturn = 0; noerrexit = 0; nohistsave = 1; dirstack = newlinklist(); bufstack = newlinklist(); hsubl = hsubr = NULL; lastpid = 0; bshin = SHIN ? fdopen(SHIN, "r") : stdin; if (isset(SHINSTDIN) && !SHIN && unset(INTERACTIVE)) { #ifdef _IONBF setvbuf(stdin, NULL, _IONBF, 0); #else setlinebuf(stdin); #endif } times(&shtms); } /* Initialize signal handling */ /**/ void init_signals(void) { intr(); #ifndef QDEBUG signal_ignore(SIGQUIT); #endif install_handler(SIGHUP); install_handler(SIGCHLD); if (interact) { install_handler(SIGALRM); #ifdef SIGWINCH install_handler(SIGWINCH); #endif signal_ignore(SIGTERM); } if (jobbing) { long ttypgrp; #ifndef __EMX__ while ((ttypgrp = gettygrp()) != -1 && ttypgrp != mypgrp) kill(0, SIGTTIN); #endif if (ttypgrp == -1) { opts[MONITOR] = 0; } else { #ifndef __EMX__ signal_ignore(SIGTTOU); signal_ignore(SIGTSTP); signal_ignore(SIGTTIN); #endif signal_ignore(SIGPIPE); attachtty(mypgrp); } } if (islogin) { signal_setmask(signal_mask(0)); } else if (interact) { sigset_t set; sigemptyset(&set); sigaddset(&set, SIGINT); sigaddset(&set, SIGQUIT); signal_unblock(set); } }