int EE_Evaluate( char* e, double* result, int* a ) { //if( setjmp( jb ) ) // return( ERROR ); expression = e; ERANC = e; STRLWR( expression ); *result = 0; Parse(); if( ! *token ) return ( E_EMPTY ); *a = Level1( result ); return( E_OK ); }
/* * WriteHighlight * Output contains duplicates! */ void WriteHighlight(char *filename) { FILE *f = fopen(filename, "wt"); if (!f) { fprintf(stderr, "Cannot open file!\n"); exit(1); } for (int i=0; i<outputs; i++) { STRLWR(output[i]); char *p = strpbrk(output[i], " \""); if (p) *p = 0; else p = strchr(output[i], 0); fprintf(f, "%s\n", output[i]); if ((*(p-1) == 'b') || (*(p-1) == 'w')) // also make a default name without any B or W suffix { *(p-1) = 0; fprintf(f, "%s\n", output[i]); } } fclose(f); }
static void write_params1(lprec *lp, FILE *fp, char *header, int newline) { int ret = 0, ret2, i, j, k, value, value2, elements, majorversion, minorversion, release, build; unsigned int basemask; REAL a = 0; char buf[4096], par[20]; ini_writeheader(fp, header, newline); lp_solve_version(&majorversion, &minorversion, &release, &build); sprintf(buf, "lp_solve version %d.%d settings\n", majorversion, minorversion); ini_writecomment(fp, buf); for(i = 0; i < sizeof(functions) / sizeof(*functions); i++) { switch(functions[i].type) { case intfunction: if(functions[i].get_function.int_get_function == NULL) continue; ret = functions[i].get_function.int_get_function(lp); break; case longfunction: if(functions[i].get_function.long_get_function == NULL) continue; ret = functions[i].get_function.long_get_function(lp); break; case MYBOOLfunction: if(functions[i].get_function.MYBOOL_get_function == NULL) continue; ret = (int) functions[i].get_function.MYBOOL_get_function(lp); break; case REALfunction: if(functions[i].get_function.REAL_get_function == NULL) continue; a = functions[i].get_function.REAL_get_function(lp); break; } buf[0] = 0; if(functions[i].values == NULL) { switch(functions[i].type) { case intfunction: case longfunction: case MYBOOLfunction: sprintf(buf, "%d", ret); break; case REALfunction: sprintf(buf, "%g", a); break; } } else { elements = functions[i].elements; basemask = functions[i].basemask; for(j = 0; j < elements; j++) { value = functions[i].values[j].value; ret2 = ret; if(((unsigned int) value) < basemask) ret2 &= basemask; if(value == 0) { if(ret2 == 0) { if(*buf) strcat(buf, " + "); strcat(buf, functions[i].values[j].svalue); } } else if((ret2 & value) == value) { for(k = 0; k < elements; k++) { value2 = functions[i].values[k].value; if((k != j) && (value2 > value) && ((value2 & value) == value) && ((ret2 & value2) == value2)) break; } if(k == elements) { if(*buf) strcat(buf, " + "); strcat(buf, functions[i].values[j].svalue); } } } } if(functions[i].mask & WRITE_ACTIVE) par[0] = 0; else strcpy(par, ";"); strcat(par, functions[i].par); ini_writedata(fp, STRLWR(par), buf); } }