From: nhmall Date: Sun, 24 Nov 2019 05:40:00 +0000 (-0500) Subject: Revert "attempt to avoid questpgr convert woes on cross-compile by making the int... X-Git-Tag: NetHack-3.7.0_WIP~242 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac315adaf15a2fd74cff03b4917337d3ae7c5629;p=nethack Revert "attempt to avoid questpgr convert woes on cross-compile by making the int sizes fixed" This reverts commit b8a6d82c57b1e9407223c83ab719bd1fb674d9f8. --- diff --git a/include/qtext.h b/include/qtext.h index efec908e9..29993d29a 100644 --- a/include/qtext.h +++ b/include/qtext.h @@ -5,21 +5,14 @@ #ifndef QTEXT_H #define QTEXT_H -#ifndef INTEGER_H -#include "integer.h" -#endif - #define N_HDR 16 /* Maximum number of categories */ /* (i.e., num roles + 1) */ #define LEN_HDR 3 /* Maximum length of a category name */ -#define QTOFFSIZ int64_t -#define QT_PREPROC 64 - struct qtmsg { - int32_t msgnum; + int msgnum; char delivery; - QTOFFSIZ offset, size, summary_size; + long offset, size, summary_size; }; #if defined(MAKEDEFS_C) || defined(MDLIB_C) /***** MAKEDEFS *****/ @@ -27,14 +20,14 @@ struct qtmsg { #define N_MSG 100 /* arbitrary */ struct msghdr { - int32_t n_msg; + int n_msg; struct qtmsg qt_msg[N_MSG]; }; struct qthdr { - int32_t n_hdr; + int n_hdr; char id[N_HDR][LEN_HDR]; - QTOFFSIZ offset[N_HDR]; + long offset[N_HDR]; }; /* Error message macros */ diff --git a/src/questpgr.c b/src/questpgr.c index 0fb4ce259..f0cf6283f 100644 --- a/src/questpgr.c +++ b/src/questpgr.c @@ -16,27 +16,21 @@ #endif static void NDECL(dump_qtlist); -static void FDECL(Fread, (genericptr_t, int32_t, int32_t, dlb *)); -static struct qtmsg *FDECL(construct_qtlist, (QTOFFSIZ)); +static void FDECL(Fread, (genericptr_t, int, int, dlb *)); +static struct qtmsg *FDECL(construct_qtlist, (long)); static const char *NDECL(intermed); static struct obj *FDECL(find_qarti, (struct obj *)); static const char *NDECL(neminame); static const char *NDECL(guardname); static const char *NDECL(homebase); static void FDECL(qtext_pronoun, (CHAR_P, CHAR_P)); -static struct qtmsg *FDECL(msg_in, (struct qtmsg *, int32_t)); +static struct qtmsg *FDECL(msg_in, (struct qtmsg *, int)); static void FDECL(convert_arg, (CHAR_P)); static void FDECL(convert_line, (char *,char *)); static void FDECL(deliver_by_pline, (struct qtmsg *)); -static void FDECL(deliver_by_window, (struct qtmsg *, int32_t)); +static void FDECL(deliver_by_window, (struct qtmsg *, int)); static boolean FDECL(skip_pager, (BOOLEAN_P)); -#if (QT_PREPROC == 64) && defined(WIN32) -#define LONGCAST (long) -#else -#define LONGCAST -#endif - /* dump the character msg list to check appearance; build with DEBUG enabled and use DEBUGFILES=questpgr.c in sysconf file or environment */ @@ -50,7 +44,7 @@ dump_qtlist() return; for (msg = g.qt_list.chrole; msg->msgnum > 0; msg++) { - (void) dlb_fseek(g.msg_file, LONGCAST msg->offset, SEEK_SET); + (void) dlb_fseek(g.msg_file, msg->offset, SEEK_SET); deliver_by_window(msg, NHW_MAP); } #endif /* DEBUG */ @@ -60,7 +54,7 @@ dump_qtlist() static void Fread(ptr, size, nitems, stream) genericptr_t ptr; -int32_t size, nitems; +int size, nitems; dlb *stream; { int cnt; @@ -73,13 +67,13 @@ dlb *stream; static struct qtmsg * construct_qtlist(hdr_offset) -QTOFFSIZ hdr_offset; +long hdr_offset; { struct qtmsg *msg_list; - int32_t n_msgs; + int n_msgs; (void) dlb_fseek(g.msg_file, hdr_offset, SEEK_SET); - Fread(&n_msgs, sizeof(int32_t), 1, g.msg_file); + Fread(&n_msgs, sizeof(int), 1, g.msg_file); msg_list = (struct qtmsg *) alloc((unsigned) (n_msgs + 1) * sizeof (struct qtmsg)); @@ -89,16 +83,16 @@ QTOFFSIZ hdr_offset; Fread((genericptr_t) msg_list, n_msgs * sizeof (struct qtmsg), 1, g.msg_file); - msg_list[n_msgs].msgnum = (int32_t) -1; + msg_list[n_msgs].msgnum = -1; return msg_list; } void load_qtlist() { - int32_t n_classes, i; + int n_classes, i; char qt_classes[N_HDR][LEN_HDR]; - QTOFFSIZ qt_offsets[N_HDR]; + long qt_offsets[N_HDR]; g.msg_file = dlb_fopen(QTEXT_FILE, RDBMODE); if (!g.msg_file) @@ -109,9 +103,9 @@ load_qtlist() * each header. */ - Fread(&n_classes, sizeof (int32_t), 1, g.msg_file); + Fread(&n_classes, sizeof (int), 1, g.msg_file); Fread(&qt_classes[0][0], sizeof (char) * LEN_HDR, n_classes, g.msg_file); - Fread(qt_offsets, sizeof (QTOFFSIZ), n_classes, g.msg_file); + Fread(qt_offsets, sizeof (long), n_classes, g.msg_file); /* * Now construct the message lists for quick reference later @@ -313,7 +307,7 @@ char who, /* 'd' => deity, 'l' => leader, 'n' => nemesis, 'o' => artifact */ static struct qtmsg * msg_in(qtm_list, msgnum) struct qtmsg *qtm_list; -int32_t msgnum; +int msgnum; { struct qtmsg *qt_msg; @@ -528,9 +522,9 @@ struct qtmsg *qt_msg; static void deliver_by_window(qt_msg, how) struct qtmsg *qt_msg; -int32_t how; +int how; { - QTOFFSIZ size; + long size; char in_line[BUFSZ], out_line[BUFSZ]; boolean qtdump = (how == NHW_MAP); winid datawin = create_nhwindow(qtdump ? NHW_TEXT : how); @@ -548,7 +542,7 @@ int32_t how; putstr(datawin, 0, ""); } #endif - for (size = 0; size < qt_msg->size; size += (QTOFFSIZ) strlen(in_line)) { + for (size = 0; size < qt_msg->size; size += (long) strlen(in_line)) { (void) dlb_fgets(in_line, sizeof in_line, g.msg_file); convert_line(in_line, out_line); putstr(datawin, 0, out_line); @@ -606,7 +600,7 @@ int msgnum; return; } - (void) dlb_fseek(g.msg_file, LONGCAST qt_msg->offset, SEEK_SET); + (void) dlb_fseek(g.msg_file, qt_msg->offset, SEEK_SET); if (qt_msg->delivery == 'p') deliver_by_pline(qt_msg); else if (msgnum == 1) @@ -641,7 +635,7 @@ int msgnum; return; } - (void) dlb_fseek(g.msg_file, LONGCAST qt_msg->offset, SEEK_SET); + (void) dlb_fseek(g.msg_file, qt_msg->offset, SEEK_SET); if (qt_msg->delivery == 'p' && strcmp(windowprocs.name, "X11")) deliver_by_pline(qt_msg); else diff --git a/util/makedefs.c b/util/makedefs.c index 5dfd5a0cb..c6a7a8cb4 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -22,7 +22,6 @@ #include "context.h" #include "flag.h" #include "dlb.h" -#include "integer.h" /* version information */ #ifdef SHORT_FILENAMES @@ -2089,7 +2088,7 @@ static void adjust_qt_hdrs() { int i, j; - QTOFFSIZ count = 0L, hdr_offset = sizeof(int) + long count = 0L, hdr_offset = sizeof(int) + (sizeof(char) * LEN_HDR + sizeof(long)) * qt_hdr.n_hdr; @@ -2124,15 +2123,7 @@ put_qt_hdrs() qt_hdr.n_hdr, ofp); if (debug) { for (i = 0; i < qt_hdr.n_hdr; i++) -#if (QT_PREPROC == 64) -#ifdef WIN32 - Fprintf(stderr, "%s @ %I64d, ", qt_hdr.id[i], qt_hdr.offset[i]); -#else - Fprintf(stderr, "%s @ %I64ld, ", qt_hdr.id[i], qt_hdr.offset[i]); -#endif -#else Fprintf(stderr, "%s @ %ld, ", qt_hdr.id[i], qt_hdr.offset[i]); -#endif Fprintf(stderr, "\n"); } @@ -2151,28 +2142,12 @@ put_qt_hdrs() int j; for (j = 0; j < msg_hdr[i].n_msg; j++) { -#if (QT_PREPROC == 64) -#ifdef WIN32 - Fprintf(stderr, "msg %d @ %I64d (%I64d)", -#else - Fprintf(stderr, "msg %d @ %I64ld (%I64ld)", -#endif -#else Fprintf(stderr, "msg %d @ %ld (%ld)", -#endif msg_hdr[i].qt_msg[j].msgnum, msg_hdr[i].qt_msg[j].offset, msg_hdr[i].qt_msg[j].size); if (msg_hdr[i].qt_msg[j].summary_size) -#if (QT_PREPROC == 64) -#ifdef WIN32 - Fprintf(stderr, " [%I64d]", -#else - Fprintf(stderr, " [%I64ld]", -#endif -#else Fprintf(stderr, " [%ld]", -#endif msg_hdr[i].qt_msg[j].summary_size); Fprintf(stderr, "\n"); }