improve sfctool messages

This commit is contained in:
nhmall
2025-05-29 09:59:29 -04:00
parent c258011fbc
commit a99944fb09
7 changed files with 117 additions and 37 deletions

View File

@@ -957,20 +957,21 @@ copy_bytes(int ifd, int ofd)
struct datamodel_information {
int sz[MAX_D];
const char *datamodel;
const char *dmplatform;
};
static struct datamodel_information dm[] = {
{ { (int) sizeof(short), (int) sizeof(int), (int) sizeof(long),
(int) sizeof(long long), (int) sizeof(genericptr_t) },
"" },
{ { 2, 4, 4, 8, 4 }, "ILP32LL64" }, /* Windows, Unix x86 */
{ { 2, 4, 4, 8, 8 }, "IL32LLP64" }, /* Windows x64 */
{ { 2, 4, 8, 8, 8 }, "I32LP64" }, /* Unix 64-bit */
{ { 2, 8, 8, 8, 8 }, "ILP64" }, /* HAL, SPARC64 */
"", "" },
{ { 2, 4, 4, 8, 4 }, "ILP32LL64", "x86 32-bit" }, /* Windows or Unix */
{ { 2, 4, 4, 8, 8 }, "IL32LLP64", "Windows x64 64-bit" },
{ { 2, 4, 8, 8, 8 }, "I32LP64", "Unix 64-bit"},
{ { 2, 8, 8, 8, 8 }, "ILP64", "Unix ILP64"}, /* HAL, SPARC64 */
};
const char *
datamodel(void)
datamodel(int retidx)
{
int i, j, matchcount;
static const char *unknown = "Unknown";
@@ -982,13 +983,13 @@ datamodel(void)
++matchcount;
}
if (matchcount == MAX_D)
return dm[i].datamodel;
return (retidx == 0) ? dm[i].datamodel : dm[i].dmplatform;
}
return unknown;
}
const char *
what_datamodel_is_this(int szshort, int szint, int szlong, int szll,
what_datamodel_is_this(int retidx, int szshort, int szint, int szlong, int szll,
int szptr)
{
int i;
@@ -998,7 +999,7 @@ what_datamodel_is_this(int szshort, int szint, int szlong, int szll,
if (szshort == dm[i].sz[0] && szint == dm[i].sz[1]
&& szlong == dm[i].sz[2] && szll == dm[i].sz[3]
&& szptr == dm[i].sz[4])
return dm[i].datamodel;
return (retidx == 0) ? dm[i].datamodel : dm[i].dmplatform;
}
return unknown;
}

View File

@@ -56,7 +56,7 @@
static boolean date_via_env = FALSE;
extern unsigned long md_ignored_features(void);
extern const char *datamodel(void);
extern const char *datamodel(int);
char *version_id_string(char *, size_t, const char *) NONNULL NONNULLPTRS;
char *bannerc_string(char *, size_t, const char *) NONNULL NONNULLPTRS;
int case_insensitive_comp(const char *, const char *) NONNULLPTRS;
@@ -696,7 +696,7 @@ build_options(void)
STOREOPTTEXT(optbuf);
optbuf[0] = '\0';
length = COLNO + 1; /* force 1st item onto new line */
Strcat(strcpy(buf, datamodel()), " data model,");
Strcat(strcpy(buf, datamodel(0)), " data model,");
opt_out_words(buf, &length);
for (i = 0; i < SIZE(build_opts); i++) {
#if !defined(MAKEDEFS_C) && defined(FOR_RUNTIME)

View File

@@ -778,9 +778,10 @@ compare_critical_bytes(NHFILE *nhfp, int *idx_1st_mismatch, unsigned long utdfla
}
for (i = 1; i < cnt; ++i) {
if (cscbuf[i] != critical_sizes[i].ucsize) {
const char *dm = datamodel(), *dmfile;
const char *dm = datamodel(0), *dmfile;
dmfile = what_datamodel_is_this(cscbuf[1], /* short */
dmfile = what_datamodel_is_this(0,
cscbuf[1], /* short */
cscbuf[2], /* int */
cscbuf[3], /* long */
cscbuf[4], /* long long */