mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Improve file position handling on Big Engian machines
Added swap_HALFs(dest, src, len) function to byteswap.c. Calc can now handle Big Engian file position sizes that are a multiple of BASEB bits in length. Before handle Big Engian file positions could only be 32 and 64 bits in length. This will allow, for example, a Big Engian file position size of 128 (assuming that 128/BASEB is is an integer).
This commit is contained in:
@@ -96,7 +96,7 @@ main(int UNUSED(argc), char **argv)
|
||||
/*
|
||||
* print the file position information
|
||||
*/
|
||||
#if defined(HAVE_FPOS_POS)
|
||||
#if defined(HAVE_FPOS_POS) && defined(FPOS_POS_BITS)
|
||||
fileposlen = FPOS_POS_BITS;
|
||||
#else /* ! HAVE_FPOS_POS */
|
||||
# if defined(FPOS_BITS)
|
||||
@@ -119,8 +119,12 @@ main(int UNUSED(argc), char **argv)
|
||||
} else if (fileposlen == 32) {
|
||||
printf("#define SWAP_HALF_IN_FILEPOS(dest, src)\t\t%s\n",
|
||||
"SWAP_HALF_IN_B32(dest, src)");
|
||||
} else if (fileposlen%BASEB == 0) {
|
||||
printf("#define SWAP_HALF_IN_FILEPOS(dest, src)\t\t"
|
||||
"swap_HALFs((HALF *)dest, (HALF *)src, (LEN)%d)\n",
|
||||
fileposlen/BASEB);
|
||||
} else {
|
||||
fprintf(stderr, "%s: unexpected FILEPOS bit size: %d\n",
|
||||
fprintf(stderr, "%s: unexpected BIG_ENDIAN FILEPOS bit size: %d\n",
|
||||
program, fileposlen);
|
||||
exit(1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user