Subversion Repositories wimsdev

Rev

Rev 10 | Rev 7673 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10 Rev 3718
Line 23... Line 23...
23
void float2str(double d, char *p)
23
void float2str(double d, char *p)
24
{
24
{
25
    char buf[16];
25
    char buf[16];
26
    int i;
26
    int i;
27
    if(d==0) {
27
    if(d==0) {
28
        strcpy(p,"0"); return;
28
        ovlstrcpy(p,"0"); return;
29
    }
29
    }
30
    if(!finite(d)) { /* isinf, isnan possibly not available */
30
    if(!finite(d)) { /* isinf, isnan possibly not available */
31
        if (d == d) strcpy(p, (d > 0)? "Inf": "-Inf"); else strcpy(p,"NaN");
31
        if (d == d) ovlstrcpy(p, (d > 0)? "Inf": "-Inf"); else ovlstrcpy(p,"NaN");
32
        return;
32
        return;
33
    }
33
    }
34
    if(d<1000000 && d>-1000000 && d==floor(d)) {
34
    if(d<1000000 && d>-1000000 && d==floor(d)) {
35
        mystrncpy(p,int2str(d),MAX_LINELEN); return;
35
        mystrncpy(p,int2str(d),MAX_LINELEN); return;
36
    }
36
    }
Line 42... Line 42...
42
    }
42
    }
43
    else {
43
    else {
44
        buf[2]='0'+i; buf[3]='g'; buf[4]=0;
44
        buf[2]='0'+i; buf[3]='g'; buf[4]=0;
45
    }
45
    }
46
    snprintf(p,MAX_LINELEN,buf,(double) d);
46
    snprintf(p,MAX_LINELEN,buf,(double) d);
47
    if(isspace(*p)) strcpy(p,find_word_start(p));
47
    if(isspace(*p)) ovlstrcpy(p,find_word_start(p));
48
}
48
}
49
 
49
 
50
        /* substitute variable names by their environment strings
50
        /* substitute variable names by their environment strings
51
         * The buffer pointed to by p must have enough space
51
         * The buffer pointed to by p must have enough space
52
         * (defined by MAX_LINELEN). */
52
         * (defined by MAX_LINELEN). */
Line 88... Line 88...
88
                p2=find_matching(pp+2,']');
88
                p2=find_matching(pp+2,']');
89
                if(p2==NULL) {
89
                if(p2==NULL) {
90
                    module_error("unmatched_parentheses");
90
                    module_error("unmatched_parentheses");
91
                    *p=0; return p;
91
                    *p=0; return p;
92
                }
92
                }
93
                *p2=0; strcpy(buf,pp+2); oldnext=p2+1;
93
                *p2=0; ovlstrcpy(buf,pp+2); oldnext=p2+1;
94
                substnest++; substit(buf); substnest--;
94
                substnest++; substit(buf); substnest--;
95
                d=evalue(buf); float2str(d,buf);
95
                d=evalue(buf); float2str(d,buf);
96
                goto replace;
96
                goto replace;
97
            }
97
            }
98
               
98
               
Line 108... Line 108...
108
            if(pt1==NULL) {buf[0]=0; goto replace;}
108
            if(pt1==NULL) {buf[0]=0; goto replace;}
109
            *pt1=0; pt1=strchr(p2,';');
109
            *pt1=0; pt1=strchr(p2,';');
110
            if(pt1==NULL) {
110
            if(pt1==NULL) {
111
                if(*find_word_start(p2)==0) {*p2=0; goto noarray;}
111
                if(*find_word_start(p2)==0) {*p2=0; goto noarray;}
112
                snprintf(tbuf,sizeof(tbuf),"%s of $%s",p2,buf);
112
                snprintf(tbuf,sizeof(tbuf),"%s of $%s",p2,buf);
113
                calc_itemof(tbuf); strcpy(buf,tbuf); goto replace;
113
                calc_itemof(tbuf); ovlstrcpy(buf,tbuf); goto replace;
114
            }
114
            }
115
            else {
115
            else {
116
                *pt1++=0; p2=find_word_start(p2);
116
                *pt1++=0; p2=find_word_start(p2);
117
                if(*p2) {
117
                if(*p2) {
118
                    snprintf(tbuf,sizeof(tbuf),"%s of $%s",p2,buf);
118
                    snprintf(tbuf,sizeof(tbuf),"%s of $%s",p2,buf);
Line 123... Line 123...
123
                }
123
                }
124
                if(*find_word_start(pt1)) {
124
                if(*find_word_start(pt1)) {
125
                    snprintf(buf,sizeof(buf),"%s of %s",pt1,tbuf);
125
                    snprintf(buf,sizeof(buf),"%s of %s",pt1,tbuf);
126
                    calc_columnof(buf); goto replace;
126
                    calc_columnof(buf); goto replace;
127
                }
127
                }
128
                else strcpy(buf,tbuf);
128
                else ovlstrcpy(buf,tbuf);
129
                goto replace;
129
                goto replace;
130
            }
130
            }
131
        }
131
        }
132
        noarray: ev=getvar(buf); ln=getvar_len;
132
        noarray: ev=getvar(buf); ln=getvar_len;
133
        if(ev==NULL) ev=""; if(strchr(ev,'$')==NULL) goto rep2;
133
        if(ev==NULL) ev=""; if(strchr(ev,'$')==NULL) goto rep2;