Subversion Repositories wimsdev

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
  2.  *
  3.  *  This program is free software; you can redistribute it and/or modify
  4.  *  it under the terms of the GNU General Public License as published by
  5.  *  the Free Software Foundation; either version 2 of the License, or
  6.  *  (at your option) any later version.
  7.  *
  8.  *  This program is distributed in the hope that it will be useful,
  9.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.  *  GNU General Public License for more details.
  12.  *
  13.  *  You should have received a copy of the GNU General Public License
  14.  *  along with this program; if not, write to the Free Software
  15.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17.  
  18.         /* It is this routine which uses print_precision. */
  19. void float2str(double d, char *p)
  20. {
  21.     char buf[64], *pp;
  22.     int i;
  23.     if(d==0) {
  24.         strcpy(p,"0"); return;
  25.     }
  26.     i=10; /* simple precision cookup */
  27.     snprintf(buf,sizeof(buf),"%%.%dg",i);
  28.     snprintf(p,MAX_LINELEN,buf,(double) d);
  29.     pp=p;while(isspace(*pp)) pp++;
  30.     if(pp>p) strcpy(p,pp);
  31. }
  32.  
  33.         /* substitute variable names by their environment strings
  34.          * The buffer pointed to by p must have enough space
  35.          * (defined by MAX_LINELEN). */
  36. char *substit(char *p)
  37. {
  38.     char *pp, *pe;
  39.     char namebuf[MAX_NAMELEN+1];
  40.     int i, l;
  41.  
  42.     pe=strchr(p,'"'); if(pe!=NULL) l=pe-p; else l=MAX_LINELEN;
  43.     for(pp=find_name_start(p); *pp!=0 && pp-p<l;
  44.         pp=find_name_start(pe)) {
  45.         pe=find_name_end(pp);
  46.         if((pp>p && !isspace(*(pp-1)) && *(pp-1)!=',') ||
  47.            (*pe!=0 && !isspace(*pe) && *pe!=',')) continue;
  48.         memmove(namebuf,pp,pe-pp); namebuf[pe-pp]=0;
  49.         i=search_list(nametab,nametab_no,sizeof(nametab[0]),namebuf);
  50.         if(i<0) continue;
  51.         if(nametab[i].type==t_prep && preptab[nametab[i].serial].typ==p_font)
  52.           break;
  53.         if(nametab[i].type==t_color)
  54.           string_modify(p,pp,pe,colortab[nametab[i].serial].def);
  55.     }
  56.     return p;
  57. }
  58.  
  59. double evalue(char *p)
  60. {
  61.     return strevalue(p);
  62. }
  63.    
  64.