# HG changeset patch # User Matti Hamalainen # Date 1578261916 -7200 # Node ID 05bbe428a0abad0a2667df48cafda4dfb1783214 # Parent 5afa6052f7965cb312ea81a60d88db21ef35625e Unify SIDLib error messages. diff -r 5afa6052f796 -r 05bbe428a0ab sidlib.c --- a/sidlib.c Sun Jan 05 23:51:04 2020 +0200 +++ b/sidlib.c Mon Jan 06 00:05:16 2020 +0200 @@ -114,8 +114,7 @@ !thfread_be32(ctx, &psid->speed)) { ret = th_io_error(ctx, ctx->status, - "Could not read PSID/RSID header from '%s': %s.", - ctx->filename, th_error_str(ctx->status)); + "Could not read PSID/RSID header."); goto exit; } @@ -126,8 +125,7 @@ psid->version < 1 || psid->version > 4) { ret = th_io_error(ctx, THERR_NOT_SUPPORTED, - "Not a supported PSID or RSID file: '%s'", - ctx->filename); + "Not a supported PSID or RSID file."); goto exit; } @@ -138,8 +136,7 @@ !sidlib_fread_str(ctx, &psid->sidCopyright, SIDLIB_PSID_STR_LEN)) { ret = th_io_error(ctx, ctx->status, - "Error reading SID file header from '%s': %s.", - ctx->filename, th_error_str(ctx->status)); + "Error reading SID file header data."); goto exit; } @@ -154,8 +151,7 @@ !thfread_u8(ctx, &psid->sid3Addr)) { ret = th_io_error(ctx, ctx->status, - "Error reading PSID/RSID v2+ extra header data from '%s': %s.", - ctx->filename, th_error_str(ctx->status)); + "Error reading PSID/RSID v2+ extra header data."); goto exit; } } @@ -343,8 +339,7 @@ if ((*pnode = node = (SIDLibSLDBNode *) th_malloc0(sizeof(SIDLibSLDBNode))) == NULL) { ret = th_io_error(ctx, THERR_MALLOC, - "Error allocating new SLDB node for SongLengthDB file '%s' line #%d:\n%s", - ctx->filename, ctx->line, line); + "Error allocating new SLDB node."); goto exit; } @@ -361,8 +356,8 @@ if (line[pos] != '=') { ret = th_io_error(ctx, THERR_INVALID_DATA, - "'=' expected on column %d of SongLengthDB file '%s' line #%d:\n%s", - pos, ctx->filename, ctx->line, line); + "'=' expected on column %d.", + pos); goto exit; } @@ -392,8 +387,7 @@ if ((node->lengths = (int *) th_calloc(node->nlengths, sizeof(int))) == NULL) { ret = th_io_error(ctx, THERR_MALLOC, - "Error allocating SLDB length data for SongLengthDB file '%s' line #%d:\n%s", - ctx->filename, ctx->line, line); + "Error allocating SLDB entry length data."); goto exit; } @@ -463,8 +457,7 @@ if (hashLen != TH_MD5HASH_LENGTH_CH) { ret = th_io_error(ctx, THERR_INVALID_DATA, - "Invalid MD5-hash in SongLengthDB file '%s' line #%d:\n%s", - ctx->filename, ctx->line, line); + "Invalid MD5-hash."); goto exit; } else @@ -480,8 +473,8 @@ if (line[pos] != ';' && line[pos] != '[' && line[pos] != 0) { ret = th_io_error(ctx, THERR_INVALID_DATA, - "Invalid line in SongLengthDB file '%s' line #%d:\n%s", - ctx->filename, ctx->line, line); + "Invalid line / unexpected data at column #%d.", + pos); goto exit; } } @@ -894,8 +887,8 @@ { // Error! Invalid character found ret = th_io_error(fh, THERR_INVALID_DATA, - "Unexpected character '%c' on line #%d.", - ctx.ch, fh->line); + "Unexpected character '%c'.", + ctx.ch); goto out; } } @@ -928,8 +921,7 @@ else { ret = th_io_error(fh, THERR_INVALID_DATA, - "Entry filename too long on line #%d.", - fh->line); + "STIL entry filename too long."); goto out; } ctx.ch = -1; @@ -947,16 +939,16 @@ if (!th_get_int(tmpStr, (unsigned int *) &subtune, &neg) || neg) { ret = th_io_error(fh, THERR_INVALID_DATA, - "Entry '%s' subtune indicator not a valid integer on line #%d: '%s'", - entry->filename, fh->line, tmpStr); + "Entry '%s' subtune indicator '%s' is not a valid integer.", + entry->filename, tmpStr); goto out; } if (subtune <= 0 || subtune > 128) { th_io_error(fh, THERR_INVALID_DATA, - "Entry '%s' subtune number %d is invalid on line #%d.", - entry->filename, subtune, fh->line); + "Entry '%s' subtune number #%d is out of range/invalid.", + entry->filename, subtune); subtune = -1; } @@ -973,8 +965,7 @@ else { ret = th_io_error(fh, THERR_INVALID_DATA, - "Subtune indicator too long on line #%d.", - fh->line); + "Subtune indicator too long."); goto out; } } @@ -983,8 +974,8 @@ { sub_unexpected: ret = th_io_error(fh, THERR_INVALID_DATA, - "Unexpected character '%c' in subtune indicator on line #%d.", - ctx.ch, fh->line); + "Unexpected character '%c' in subtune indicator.", + ctx.ch); goto out; } @@ -1003,8 +994,8 @@ if (entry == NULL) { ret = th_io_error(fh, THERR_INVALID_DATA, - "No STIL entry allocated, but field '%s' found on line #%d.", - fieldName, fh->line); + "No STIL entry allocated, but field '%s' found.", + fieldName); goto out; } @@ -1018,8 +1009,7 @@ else { ret = th_io_error(fh, THERR_INVALID_DATA, - "Field name too long on line #%d.", - fieldName, fh->line); + "Field name too long."); goto out; } } @@ -1051,8 +1041,8 @@ entry, subtune, TRUE, field, tmpStr)) != THERR_OK) { ret = th_io_error(fh, THERR_MALLOC, - "Could not allocate memory for field '%s' on line #%d.", - fieldName, fh->line); + "Could not allocate memory for field '%s'.", + fieldName); goto out; } } @@ -1066,8 +1056,8 @@ else { ret = th_io_error(fh, THERR_INVALID_DATA, - "Field '%s' data too long on line #%d.", - fieldName, fh->line); + "Field '%s' data too long.", + fieldName); goto out; } ctx.ch = - 1;