static int maybe_adjust_cairo (char *line) { char *s = line + 12; int ret = 0; if (!strncmp(s, "cairo", 5)) { if (gnuplot_png_terminal() != GP_PNG_CAIRO) { /* drop back to non-cairo PNG term */ shift_string_left(s + 5, 5); ret = 1; } } else if (gnuplot_png_terminal() == GP_PNG_CAIRO && strlen(line) < 512 - 5) { /* substitute the preferred cairo PNG term */ char *p, tmp[512]; strcpy(tmp, "set term pngcairo"); s += strspn(s, " "); if (!strncmp(s, "truecolor ", 10)) { /* invalid */ s += 10; } if (!strncmp(s, "font", 4)) { /* attempt to fix up old gnuplot font spec */ char fname[32], fsize[6]; s += 4; s += strspn(s, " "); if (*s != '"') { if (sscanf(s, "%31s %5s", fname, fsize) == 2) { strcat(tmp, " font \""); strcat(tmp, fname); strcat(tmp, ","); strcat(tmp, fsize); strcat(tmp, "\" "); } } p = strstr(s, " size "); if (p != NULL) { strcat(tmp, p + 1); } else { strncat(tmp, "\n", 1); } } else { /* hope for the best */ strcat(tmp, s); } strcpy(line, tmp); ret = 1; } return ret; }
void set_warnings(int w) { FILE *fp1, *fp2; char buf[512]; makefile_setup(&fp1, &fp2); while (fgets(buf, 512, fp1)) { if (strncmp(buf, "#WARNING_ERROR=", strlen("#WARNING_ERROR=")) == 0) { switch (w) { case 'W': shift_string_left(buf, 1); break; case 'w': case 'n': break; } } if (strncmp(buf, "WARNING_ERROR=", strlen("WARNING_ERROR=")) == 0) { switch (w) { case 'n': case 'w': shift_string_right(buf, 1); buf[0] = '#'; break; case 'W': break; } } if (strncmp(buf, "#WARNING_OPTIONS=", strlen("#WARNING_OPTIONS=")) == 0) { switch (w) { case 'W': case 'w': shift_string_left(buf, 1); break; case 'n': break; } } if (strncmp(buf, "WARNING_OPTIONS=", strlen("WARNING_OPTIONS=")) == 0) { switch (w) { case 'w': case 'W': break; case 'n': shift_string_right(buf, 1); buf[0] = '#'; break; } } fprintf(fp2, "%s", buf); } makefile_create(&fp1, &fp2); }