--- ray/src/common/image.c 1991/11/12 16:55:38 2.1 +++ ray/src/common/image.c 1992/09/08 09:09:20 2.4 @@ -1,4 +1,4 @@ -/* Copyright (c) 1991 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -16,6 +16,8 @@ static char SCCSid[] = "$SunId$ LBL"; #include "resolu.h" +#include "paths.h" + VIEW stdview = STDVIEW; /* default view parameters */ @@ -276,7 +278,6 @@ register char *av[]; { #define check(c,l) if ((av[0][c]&&av[0][c]!=' ') || \ badarg(ac-1,av+1,l)) return(-1) - extern double atof(); if (ac <= 0 || av[0][0] != '-' || av[0][1] != 'v') return(-1); @@ -338,8 +339,8 @@ register char *s; int na; int nvopts = 0; - while (*s == ' ') - s++; + if (*s != '-') + s = sskip(s); while (*s) { ac = 0; do { @@ -373,8 +374,33 @@ FILE *fp; } -static char *altname[] = {NULL,"rpict","rview","pinterp",VIEWSTR,NULL}; +int +isview(s) /* is this a view string? */ +char *s; +{ + static char *altname[]={NULL,"rpict","rview","pinterp",VIEWSTR,NULL}; + extern char *progname, *rindex(); + register char *cp; + register char **an; + /* add program name to list */ + if (altname[0] == NULL) + if ((cp = rindex(progname, DIRSEP)) != NULL) + altname[0] = cp+1; + else + altname[0] = progname; + /* skip leading path */ + cp = s; + while (*cp && *cp != ' ') + cp++; + while (cp > s && cp[-1] != DIRSEP) + cp--; + for (an = altname; *an != NULL; an++) + if (!strncmp(*an, cp, strlen(*an))) + return(1); + return(0); +} + struct myview { VIEW *hv; int ok; @@ -386,14 +412,8 @@ gethview(s, v) /* get view from header */ char *s; register struct myview *v; { - register char **an; - - for (an = altname; *an != NULL; an++) - if (!strncmp(*an, s, strlen(*an))) { - if (sscanview(v->hv, s+strlen(*an)) > 0) - v->ok++; - return; - } + if (isview(s) && sscanview(v->hv, s) > 0) + v->ok++; } @@ -403,14 +423,12 @@ char *fname; VIEW *vp; RESOLU *rp; { - extern char *progname; struct myview mvs; FILE *fp; if ((fp = fopen(fname, "r")) == NULL) return(-1); - altname[0] = progname; mvs.hv = vp; mvs.ok = 0;