Mercurial > hg > dmlib
changeset 2459:567b4543f73b
Rename labels more unformly.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 16 Apr 2020 07:48:36 +0300 |
parents | f6278408bfae |
children | 2723cf62d039 |
files | tools/gfxconv.c |
diffstat | 1 files changed, 41 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/gfxconv.c Thu Apr 16 07:39:19 2020 +0300 +++ b/tools/gfxconv.c Thu Apr 16 07:48:36 2020 +0300 @@ -408,13 +408,13 @@ char *end, *split, *opt = dm_strdup(popt); if (opt == NULL) - goto error; + goto out; if ((end = split = strchr(opt, ':')) == NULL) { dmErrorMsg("Invalid %s value '%s', expected <(#|%%)RRGGBB|[$|0x]index>:<[$|0x]index>.\n", msg, opt); - goto error; + goto out; } // Trim whitespace @@ -438,7 +438,7 @@ sscanf(opt + 1, "%2X%2X%2X", &colR, &colG, &colB) != 3) { dmErrorMsg("Invalid %s value '%s', expected a hex triplet, got '%s'.\n", msg, popt, opt + 1); - goto error; + goto out; } value->color.r = colR; @@ -451,7 +451,7 @@ if (!dmGetIntVal(opt, &value->from, NULL)) { dmErrorMsg("Invalid %s value '%s', could not parse source value '%s'.\n", msg, popt, opt); - goto error; + goto out; } value->triplet = FALSE; } @@ -464,25 +464,25 @@ if (!dmGetIntVal(split, &value->to, NULL)) { dmErrorMsg("Invalid %s value '%s', could not parse destination value '%s'.\n", msg, popt, split); - goto error; + goto out; } if (!value->triplet && value->from > 255) { dmErrorMsg("Invalid %s map source color index value %d, must be [0..255].\n", msg, value->from); - goto error; + goto out; } if (value->to > nmax) { dmErrorMsg("Invalid %s map destination color index value %d, must be [0..%d].\n", msg, value->to, nmax); - goto error; + goto out; } dmFree(opt); return TRUE; -error: +out: dmFree(opt); return FALSE; } @@ -574,19 +574,19 @@ if (*start != 0 && *start != ';') { if (!dmParseMapOptionMapItem(line, &values[*nvalue], nmax, "mapping file")) - goto error; + goto out; (*nvalue)++; if (*nvalue >= nmax) { dmErrorMsg("Too many mapping pairs in '%s', maximum is %d.\n", filename, nmax); - goto error; + goto out; } } } -error: +out: fclose(fp); return res; } @@ -1080,20 +1080,20 @@ { res = dmError(DMERR_MALLOC, "Could not allocate memory for reused palette.\n"); - goto error; + goto out; } if ((res = dmPaletteAlloc(&tmpPal, src->pal->ncolors, -1)) != DMERR_OK) { dmErrorMsg("Could not allocate memory for remap palette.\n"); - goto error; + goto out; } if ((dst = *pdst = dmImageAlloc(src->width, src->height, src->pixfmt, src->bpp)) == NULL) { res = dmError(DMERR_MALLOC, "Could not allocate memory for remapped image.\n"); - goto error; + goto out; } dmMsg(1, "Remapping %d output image colors of %d colors.\n", @@ -1219,10 +1219,10 @@ { res = dmError(DMERR_MALLOC, "Could not allocate memory for final remapped palette.\n"); - goto error; + goto out; } -error: +out: dmFree(mapping); dmFree(mapped); dmFree(used); @@ -1429,7 +1429,7 @@ if ((res = dmC64EncodeBMP(&buf, image, fmt)) != DMERR_OK) { dmErrorMsg("Error encoding bitmap data: %s\n", dmErrorStr(res)); - goto error; + goto out; } // And output the file @@ -1438,7 +1438,7 @@ res = dmWriteDataFile(NULL, filename, buf.data, buf.len); -error: +out: dmGrowBufFree(&buf); return res; } @@ -1538,7 +1538,7 @@ { res = dmError(DMERR_MALLOC, "Could not allocate memory for filename strings? :O\n"); - goto err; + goto out; } // Replace any non-alphanumerics in palette ID @@ -1584,7 +1584,7 @@ { dmErrorMsg("Could not open file '%s' for writing.\n", filename); - goto err; + goto out; } res = fmt->write(fp, image, spec); @@ -1592,7 +1592,7 @@ dmf_close(fp); } -err: +out: if (allocated) dmImageFree(image); @@ -1618,14 +1618,14 @@ if ((res = dmf_open_stdio(filename, "wb", &fp)) != DMERR_OK) { - dmErrorMsg("Could not open file '%s' for writing.\n", - filename); - goto err; + dmErrorMsg("Could not open file '%s' for writing: %s\n", + filename, dmErrorStr(res)); + goto out; } res = fmt->write(fp, palette); -err: +out: dmf_close(fp); return res; @@ -1729,7 +1729,7 @@ default: ret = dmError(DMERR_INVALID_ARGS, "Invalid output format %d, internal error.\n", outFormat); - goto error; + goto out; } if (outBlockW < 1 || outBlockH < 1) @@ -1737,7 +1737,7 @@ ret = dmError(DMERR_INVALID_ARGS, "Source image dimensions too small for conversion, block dimensions %d x %d.\n", outBlockW, outBlockH); - goto error; + goto out; } if ((outFile = fopen(filename, "wb")) == NULL) @@ -1745,7 +1745,7 @@ ret = dmGetErrno(); dmErrorMsg("Could not open '%s' for writing: %s.\n", filename, dmErrorStr(ret)); - goto error; + goto out; } if ((tmpBuf = dmMalloc(outBufSize)) == NULL) @@ -1753,7 +1753,7 @@ dmErrorMsg("Could not allocate %" DM_PRIu_SIZE_T " bytes for conversion buffer.\n", outBufSize); - goto error; + goto out; } dmMsg(1, "Writing %d x %d = %d blocks of %s data...\n", @@ -1770,7 +1770,7 @@ multicolor)) { ret = DMERR_DATA_ERROR; - goto error; + goto out; } break; @@ -1780,7 +1780,7 @@ multicolor)) { ret = DMERR_DATA_ERROR; - goto error; + goto out; } break; } @@ -1790,11 +1790,11 @@ ret = dmGetErrno(); dmError(ret, "Error writing data block %d,%d to '%s': %s.\n", bx, by, filename, dmErrorStr(ret)); - goto error; + goto out; } } -error: +out: // Cleanup if (outFile != NULL) fclose(outFile); @@ -1847,7 +1847,7 @@ ret = dmGetErrno(); dmError(ret, "Error opening output file '%s': %s.\n", optOutFilename, dmErrorStr(ret)); - goto error; + goto out; } while (offs + outSize < dataSize && !error && (optItemCount < 0 || itemCount < optItemCount)) @@ -1881,7 +1881,7 @@ if (optOutFilename == NULL) { dmErrorMsg("Sequential image output requires filename template.\n"); - goto error; + goto out; } outImage = dmImageAlloc(outWidthPX, outHeight, DM_PIXFMT_PALETTE, -1); @@ -1897,7 +1897,7 @@ if (optItemCount <= 0) { dmErrorMsg("Single-image output requires count to be set (-n).\n"); - goto error; + goto out; } outIWidth = optPlanedWidth; @@ -1911,7 +1911,7 @@ if ((err = dmC64SetImagePalette(outImage, &optC64Spec, FALSE)) != DMERR_OK) { dmErrorMsg("Could not allocate C64 palette for output image: %d\n", err); - goto error; + goto out; } while (offs + outSize < dataSize && (optItemCount < 0 || itemCount < optItemCount)) @@ -1920,7 +1920,7 @@ dataBuf + offs, outWidth, outHeight, optInMulticolor, optColorMap)) != DMERR_OK) { dmErrorMsg("Internal error in conversion of raw data to bitmap: %d.\n", err); - goto error; + goto out; } if (optSequential) @@ -1933,7 +1933,7 @@ if (outFilename == NULL) { dmErrorMsg("Could not allocate memory for filename template?\n"); - goto error; + goto out; } ret = dmWriteImage(outFilename, outImage, &optSpec, @@ -1981,11 +1981,11 @@ { ret = dmError(DMERR_INVALID_ARGS, "Sequential output not supported for spr/char -> bitmap conversion.\n"); - goto error; + goto out; } } -error: +out: return ret; }