Mercurial > hg > dmlib
changeset 855:f70d6f9532cd
Merge.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 23 Oct 2014 02:14:15 +0300 |
parents | 9406aa7fdd61 (current diff) ca5b4696be21 (diff) |
children | 415cc781e127 |
files | |
diffstat | 3 files changed, 58 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dmeval.c Tue Oct 21 20:42:57 2014 +0300 +++ b/src/dmeval.c Thu Oct 23 02:14:15 2014 +0300 @@ -218,7 +218,7 @@ DMEvalNode *next = node->next; int i; - for (i = 0; i < DM_MAX_ARGS; i++) + for (i = 0; i < DM_EVAL_MAX_ARGS; i++) { dmEvalTreeFree(node->args[i]); node->args[i] = NULL;
--- a/src/dmeval.h Tue Oct 21 20:42:57 2014 +0300 +++ b/src/dmeval.h Thu Oct 23 02:14:15 2014 +0300 @@ -7,7 +7,7 @@ typedef double DMValue; #define DMCONVTYPE (int) -#define DM_MAX_ARGS 8 +#define DM_EVAL_MAX_ARGS 4 enum @@ -78,7 +78,7 @@ int type; // Type (SYM_*) int nargs; // Number of arguments, if SYM_FUNC - DMValue (*func)(DMValue arg[DM_MAX_ARGS]); + DMValue (*func)(DMValue arg[DM_EVAL_MAX_ARGS]); DMValue *var; // Pointer to variable value if SYM_VAR DMValue cvalue; // Const value, if SYM_CVAR @@ -91,7 +91,7 @@ DMValue val; // Value, if immediate constant DMEvalSymbol *symbol; // Symbol pointer, if function/variable/constvar - struct DMEvalNode *args[DM_MAX_ARGS]; // Arguments, if function + struct DMEvalNode *args[DM_EVAL_MAX_ARGS]; // Arguments, if function struct DMEvalNode *subexpr, *left, *right, *next, *prev; } DMEvalNode;
--- a/tools/gfxconv.c Tue Oct 21 20:42:57 2014 +0300 +++ b/tools/gfxconv.c Thu Oct 23 02:14:15 2014 +0300 @@ -36,6 +36,14 @@ }; +enum +{ + CROP_NONE = 0, + CROP_AUTO, + CROP_SIZE, +}; + + typedef struct { char *name; @@ -120,6 +128,10 @@ optForcedFormat = -1, optInSkip = 0; +int optCropMode = CROP_NONE, + optCropX0, optCropY0, + optCropW, optCropH; + BOOL optInMulticolor = FALSE, optSequential = FALSE, optRemapColors = FALSE, @@ -423,24 +435,22 @@ BOOL dmParseMapOptionString(char *opt, void *values, int *nvalues, const int nmax, const BOOL requireIndex, const char *msg) { - char *end, *start = opt; + char *start = opt; *nvalues = 0; - while (*nvalues < nmax && *start && (end = strchr(start, ',')) != NULL) + while (*start && *nvalues < nmax) { + char *end = strchr(start, ','); + if (!dmParseMapOptionItem(start, end, values, *nvalues, nmax, requireIndex, msg)) return FALSE; + (*nvalues)++; + + if (!end) + break; + start = end + 1; - (*nvalues)++; - } - - if (*start && *nvalues < nmax) - { - if (!dmParseMapOptionItem(start, NULL, values, *nvalues, nmax, requireIndex, msg)) - return FALSE; - - (*nvalues)++; } return TRUE; @@ -689,6 +699,39 @@ optRemapColors = TRUE; break; + case 19: + { + int tx0, ty0, tx1, ty1; + if (strcasecmp(optArg, "auto") == 0) + { + optCropMode = CROP_AUTO; + } + else + if (sscanf(optArg, "%d:%d-%d:%d", &tx0, &ty0, &tx1, &ty1) == 4) + { + optCropMode = CROP_SIZE; + optCropX0 = tx0; + optCropY0 = ty0; + optCropW = tx1 - tx0 + 1; + optCropH = ty1 - ty0 + 1; + } + else + if (sscanf(optArg, "%d:%d:%d:%d", &tx0, &ty0, &tx1, &ty1) == 4) + { + optCropMode = CROP_SIZE; + optCropX0 = tx0; + optCropY0 = ty0; + optCropW = tx1; + optCropH = ty1; + } + else + { + dmError("Invalid crop mode / argument '%s'.\n", optArg); + return FALSE; + } + } + break; + default: dmError("Unknown option '%s'.\n", currArg); return FALSE;