From a2bf45329a172d2c53594c64d27f1c15ac26796a Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 28 Feb 2011 16:28:21 -0500 Subject: New dmnsn_warning() API, remove different severities. --- dimension/main.c | 27 +++++++-------------------- dimension/realize.c | 10 ++++------ 2 files changed, 11 insertions(+), 26 deletions(-) (limited to 'dimension') diff --git a/dimension/main.c b/dimension/main.c index f8b86b4..feeb6db 100644 --- a/dimension/main.c +++ b/dimension/main.c @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2010 Tavian Barnes * + * Copyright (C) 2009-2011 Tavian Barnes * * * * This file is part of Dimension. * * * @@ -50,7 +50,7 @@ main(int argc, char **argv) DMNSN_OPT_VERSION = 256, DMNSN_OPT_THREADS, DMNSN_OPT_QUALITY, - DMNSN_OPT_RESILIENCE + DMNSN_OPT_STRICT }; static struct option long_options[] = { @@ -61,7 +61,7 @@ main(int argc, char **argv) { "height", required_argument, NULL, 'h' }, { "threads", required_argument, NULL, DMNSN_OPT_THREADS }, { "quality", required_argument, NULL, DMNSN_OPT_QUALITY }, - { "resilience", required_argument, NULL, DMNSN_OPT_RESILIENCE }, + { "strict", no_argument, NULL, DMNSN_OPT_STRICT }, { "tokenize", no_argument, &tokenize, 1 }, { "parse", no_argument, &parse, 1 }, { 0, 0, 0, 0 } @@ -142,21 +142,9 @@ main(int argc, char **argv) } break; } - case DMNSN_OPT_RESILIENCE: - { - if (strcmp(optarg, "low") == 0) { - dmnsn_set_resilience(DMNSN_SEVERITY_LOW); - } else if (strcmp(optarg, "medium") == 0) { - dmnsn_set_resilience(DMNSN_SEVERITY_MEDIUM); - } else if (strcmp(optarg, "high") == 0) { - dmnsn_set_resilience(DMNSN_SEVERITY_HIGH); - } else { - fprintf(stderr, "Invalid argument to --resilience!\n"); - print_usage(stderr, argv[0]); - return EXIT_FAILURE; - } - break; - } + case DMNSN_OPT_STRICT: + dmnsn_die_on_warnings(true); + break; default: fprintf(stderr, "Invalid command line option!\n"); @@ -370,8 +358,7 @@ print_usage(FILE *file, const char *arg0) " Rendering options:\n" " --threads=THREADS render with THREADS parallel threads\n" " --quality=QUALITY use the quality setting QUALITY\n" - " --resilience=RES set error tolerance to RES (low, medium, or" - " high)\n\n" + " --strict treat warnings as errors\n" " Debugging options:\n" " --tokenize tokenize the input and print the token list\n" " --parse parse the input and print the abstract syntax" diff --git a/dimension/realize.c b/dimension/realize.c index 56bd846..8bb5c9a 100644 --- a/dimension/realize.c +++ b/dimension/realize.c @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2010 Tavian Barnes * + * Copyright (C) 2009-2011 Tavian Barnes * * * * This file is part of Dimension. * * * @@ -36,7 +36,7 @@ dmnsn_realize_integer(dmnsn_astnode astnode) feclearexcept(FE_ALL_EXCEPT); long ret = lrint(*(double *)astnode.ptr); if (fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)) - dmnsn_error(DMNSN_SEVERITY_HIGH, "Float out of range of integer."); + dmnsn_error("Float out of range of integer."); return ret; } @@ -742,8 +742,7 @@ dmnsn_realize_pigment(dmnsn_astnode astnode) const char *path = dmnsn_realize_str(strnode); FILE *file = fopen(path, "rb"); if (!file) { - dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Couldn't open image file."); - return NULL; + dmnsn_error("Couldn't open image file."); } dmnsn_canvas *canvas; @@ -751,8 +750,7 @@ dmnsn_realize_pigment(dmnsn_astnode astnode) case DMNSN_AST_PNG: canvas = dmnsn_png_read_canvas(file); if (!canvas) { - dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Invalid PNG file."); - return NULL; + dmnsn_error("Invalid PNG file."); } pigment = dmnsn_new_canvas_pigment(canvas); break; -- cgit v1.2.3