From 2ff85e8b61a91a45996e8d9a47776e6fb6f2a1ab Mon Sep 17 00:00:00 2001 From: slidedraw Date: Fri, 10 May 2002 16:08:58 +0000 Subject: [PATCH] Checked in some Alpha portability fixes. --- cole/cole.c | 4 ++-- cole/oledecod.c | 6 +++--- cole/support.c | 34 ++++++++++------------------------ xlhtml/ChangeLog | 1 + xlhtml/xlhtml.c | 13 +++++++------ xlhtml/xlhtml.h | 1 - xlhtml/xml.c | 8 ++++---- 7 files changed, 27 insertions(+), 40 deletions(-) diff --git a/cole/cole.c b/cole/cole.c index 4a656d5..decd6da 100644 --- a/cole/cole.c +++ b/cole/cole.c @@ -274,7 +274,7 @@ __cole_print_tree_inroot(COLEDIR *cd, void *info, COLERRNO *colerrno) char *entry_name; printf ("DIR "); - printf (" %7u", cole_dir_getsize (cd)); + printf (" %7zu", cole_dir_getsize (cd)); printf (" %08lx-%08lx %08lx-%08lx", cole_dir_getdays1 (cd), cole_dir_getsec1 (cd), @@ -315,7 +315,7 @@ __cole_print_tree_indirentry(COLEDIRENT *cde, void *info, COLERRNO *colerrno) printf ("FILE"); else printf ("????"); - printf (" %7u", cole_direntry_getsize (cde)); + printf (" %7zu", cole_direntry_getsize (cde)); printf (" %08lx-%08lx %08lx-%08lx", cole_direntry_getdays1 (cde), cole_direntry_getsec1 (cde), diff --git a/cole/oledecod.c b/cole/oledecod.c index 42d84f5..4d0f314 100644 --- a/cole/oledecod.c +++ b/cole/oledecod.c @@ -658,14 +658,14 @@ nextff (cff); { for (i = 0; i < level * 3; i++) printf (" "); - printf ("FILE %02lx %8ld '%c%s'\n", pps_list[entry].ppsnumber, - pps_list[entry].size, !isprint((int)pps_list[entry].name[0]) ? ' ' : pps_list[entry].name[0], pps_list[entry].name+1); + printf ("FILE %02x %8d '%c%s'\n", (int)pps_list[entry].ppsnumber, + (int)pps_list[entry].size, !isprint((int)pps_list[entry].name[0]) ? ' ' : pps_list[entry].name[0], pps_list[entry].name+1); } else { for (i = 0; i < level * 3; i++) printf (" "); - printf ("DIR %02lx '%c%s'\n", pps_list[entry].ppsnumber, + printf ("DIR %02x '%c%s'\n", (int)pps_list[entry].ppsnumber, !isprint((int)pps_list[entry].name[0]) ? ' ' : pps_list[entry].name[0], pps_list[entry].name+1); verbosePPSTree (pps_list, pps_list[entry].dir, level + 1); } diff --git a/cole/support.c b/cole/support.c index b5795d2..984a419 100644 --- a/cole/support.c +++ b/cole/support.c @@ -27,45 +27,31 @@ */ - +#include #include "support.h" U16 fil_sreadU16 (U8 * in) { -#ifdef WORDS_BIGENDIAN - U16 ret; - *( (U8*)(&ret) ) = *(in+1); - *( ((U8*)(&ret)) + 1 ) = *in; - return ret; -#else /* !WORDS_BIGENDIAN */ - return *((U16 *)in); -#endif +return (in[1] << 8) | in[0]; } U32 fil_sreadU32 (U8 * in) { -#ifdef WORDS_BIGENDIAN - U32 ret; - *( ((U8*)(&ret)) + 3 ) = *in; - *( ((U8*)(&ret)) + 2 ) = *(in+1); - *( ((U8*)(&ret)) + 1 ) = *(in+2); - *( (U8*)(&ret) ) = *(in+3); - return ret; -#else /* !WORDS_BIGENDIAN */ - return *((U32 *)in); -#endif + U32 i0 = in[0], i1 = in[1], i2 = in[2], i3 = in[3]; + + return (i3 << 24) | (i2 << 16) | (i1 << 8) | i0; } F64 fil_sreadF64 (U8 * in) { -#ifdef WORDS_BIGENDIAN F64 ret; + #ifdef WORDS_BIGENDIAN *( ((U8*)(&ret)) + 7 ) = *in; *( ((U8*)(&ret)) + 6 ) = *(in+1); *( ((U8*)(&ret)) + 5 ) = *(in+2); @@ -74,10 +60,10 @@ fil_sreadF64 (U8 * in) *( ((U8*)(&ret)) + 2 ) = *(in+5); *( ((U8*)(&ret)) + 1 ) = *(in+6); *( (U8*)(&ret) ) = *(in+7); - return ret; #else /* !WORDS_BIGENDIAN */ - return *((F64 *)in); + memcpy (&ret, in, 8); #endif +return ret; } @@ -138,13 +124,13 @@ __cole_dump (void *_m, void *_start, int length, char *msg) buff[8] = '-'; buff[17] = 0; if (msg != NULL) - printf ("VERBOSE: %s (from 0x%08x length 0x%08x (%d)):\n", + printf ("VERBOSE: %s (from 0x%08tx length 0x%08x (%d)):\n", msg, m - start, length, length); for (pm = m; pm - m < length; pm++) { achar = (pm - m) % 16; /* print offset */ if (achar == 0) - printf ("%08x ", (pm - m) + (m - start)); + printf ("%08tx ", (pm - m) + (m - start)); /* write char in the right column buffer */ buff[achar + (achar < 8 ? 0 : 1)] = (char)((isprint (*pm) ? *pm : '.')); /* print next char */ diff --git a/xlhtml/ChangeLog b/xlhtml/ChangeLog index 62de247..4b844b0 100644 --- a/xlhtml/ChangeLog +++ b/xlhtml/ChangeLog @@ -11,6 +11,7 @@ HEAD of * Made rowspan and colspan attributes instead of content of in XML output + * Added some Alpha portability fixes. 0.5 04/13/02 * Fixed some memory leaks diff --git a/xlhtml/xlhtml.c b/xlhtml/xlhtml.c index 71c76e5..f3c1edc 100644 --- a/xlhtml/xlhtml.c +++ b/xlhtml/xlhtml.c @@ -28,6 +28,7 @@ #include "xlhtml.h" +static U16 HARD_MAX_ROWS = HARD_MAX_ROWS_97; static char SectionName[2][12] = /* The section of the Excel Stream where the workbooks are kept */ { @@ -611,9 +612,9 @@ void scan_file(COLEDIRENT *cde, void *_info) printf("There are %d pages total.\n", sheet_count+1); for (i=0; i<=sheet_count; i++) { - printf("Page:%d Name:%s MaxRow:%ld MaxCol:%d\n", i, + printf("Page:%d Name:%s MaxRow:%ld MaxCol:%ld\n", i, ws_array[i]->ws_title.str ? (char *)ws_array[i]->ws_title.str : "(Unknown Page)", - ws_array[i]->biggest_row, ws_array[i]->biggest_col); + (long)ws_array[i]->biggest_row, (long)ws_array[i]->biggest_col); } } else if (Xtract) @@ -628,9 +629,9 @@ void scan_file(COLEDIRENT *cde, void *_info) printf("

There are %d pages total.

\n", sheet_count+1); for (i=0; i<=sheet_count; i++) { - printf("

Page:%d Name:%s MaxRow:%ld MaxCol:%d

\n", i, + printf("

Page:%d Name:%s MaxRow:%ld MaxCol:%ld

\n", i, ws_array[i]->ws_title.str ? (char *)ws_array[i]->ws_title.str : "(Unknown Page)", - ws_array[i]->biggest_row, ws_array[i]->biggest_col); + (long)ws_array[i]->biggest_row, (long)ws_array[i]->biggest_col); } output_footer(); @@ -700,7 +701,7 @@ void SetupExtraction(void) { if (Ascii) fprintf(stderr, "Error - Row not in range during extraction" - " (%d or %d not in [%ld..%ld])\n", xr1, xr2, ws_array[xp]->first_row, ws_array[xp]->biggest_row); + " (%d or %d not in [%ld..%ld])\n", xr1, xr2, (long)ws_array[xp]->first_row, (long)ws_array[xp]->biggest_row); else { printf("Error - Row not in range during extraction."); @@ -1496,7 +1497,7 @@ void main_line_processor(U16 opcode, U16 version, U32 count, U16 last, U8 data) sprintf(temp, "%.15g", d / 100.0); break; case 2: - sprintf(temp, "%ld", (S32)n2); + sprintf(temp, "%ld", (long)n2); break; default: d = (F64) n2; diff --git a/xlhtml/xlhtml.h b/xlhtml/xlhtml.h index 4f5e153..b0ad64a 100644 --- a/xlhtml/xlhtml.h +++ b/xlhtml/xlhtml.h @@ -23,7 +23,6 @@ #define HARD_MAX_ROWS_95 0x3FFF /*!< Used in add_wb_array to prevent OOM */ #define HARD_MAX_COLS 256 /*!< Used in add_wb_array to prevent OOM */ -static U16 HARD_MAX_ROWS = HARD_MAX_ROWS_97; /********************************** * * Don't change anything below here... diff --git a/xlhtml/xml.c b/xlhtml/xml.c index 74945d7..9e908d3 100644 --- a/xlhtml/xml.c +++ b/xlhtml/xml.c @@ -86,10 +86,10 @@ void OutputTableXML(void) printf("\t\t\t(Unknown Page)\n"); } - printf( "\t\t\t%ld\n", ws_array[i]->first_row ); - printf( "\t\t\t%ld\n", ws_array[i]->biggest_row ); - printf( "\t\t\t%d\n", ws_array[i]->first_col ); - printf( "\t\t\t%d\n", ws_array[i]->biggest_col ); + printf( "\t\t\t%ld\n", (unsigned long)ws_array[i]->first_row ); + printf( "\t\t\t%ld\n", (int) ws_array[i]->biggest_row ); + printf( "\t\t\t%d\n", (long) ws_array[i]->first_col ); + printf( "\t\t\t%d\n", (int)ws_array[i]->biggest_col ); printf( "\t\t\t\n" ); for (j=ws_array[i]->first_row; j<=ws_array[i]->biggest_row; j++)