Skip to content

Commit

Permalink
Do not pass addrlen to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
xyproto committed Feb 5, 2024
1 parent 444615e commit 881e2f4
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,12 @@ int hex_cinclude(const bool colsgiven, int cols, int octspergrp, const bool reve
return 0;
}

int hex_bits(const bool colsgiven, int cols, int octspergrp, const bool revert, int c, int grplen, int e, const long length, int addrlen, const char* decimal_format_string, const long seekoff, const unsigned long displayoff, int x, const bool color, int nonzero, const bool ascii, const bool autoskip)
int hex_bits(const bool colsgiven, int cols, int octspergrp, const bool revert, int c, int grplen, int e, const long length, const char* decimal_format_string, const long seekoff, const unsigned long displayoff, int x, const bool color, int nonzero, const bool ascii, const bool autoskip)
{
static char l[LLEN + 1]; // static because it may be too big for stack
int p = 0;
int n = 0;
int addrlen = 9;
if (!colsgiven || !cols) {
cols = 6;
} else if (cols < 1 || cols > COLS) {
Expand Down Expand Up @@ -611,12 +612,13 @@ int hex_bits(const bool colsgiven, int cols, int octspergrp, const bool revert,
return 0;
}

int hex_normal(const bool colsgiven, int cols, int octspergrp, const bool revert, const int negseek, const long seekoff, int e, const bool color, int grplen, const bool ascii, const long length, int addrlen, const char* decimal_format_string, const unsigned long displayoff, int c, int x, const char* hex_digits, int nonzero, const bool autoskip)
int hex_normal(const bool colsgiven, int cols, int octspergrp, const bool revert, const int negseek, const long seekoff, int e, const bool color, int grplen, const bool ascii, const long length, const char* decimal_format_string, const unsigned long displayoff, int c, int x, const char* hex_digits, int nonzero, const bool autoskip)
{
static char l[LLEN + 1]; // static because it may be too big for stack
char color_digit = 0;
int p = 0;
int n = 0;
int addrlen = 9;

if (!colsgiven || !cols) {
cols = 16;
Expand Down Expand Up @@ -751,9 +753,10 @@ int hex_normal(const bool colsgiven, int cols, int octspergrp, const bool revert
return 0;
}

int hex_littleendian(const bool colsgiven, int cols, int octspergrp, const bool revert, const long seekoff, const bool color, int grplen, int e, const long length, int addrlen, const char* decimal_format_string, const unsigned long displayoff, int c, const bool ascii, const char* hex_digits, int nonzero, const bool autoskip)
int hex_littleendian(const bool colsgiven, int cols, int octspergrp, const bool revert, const long seekoff, const bool color, int grplen, int e, const long length, const char* decimal_format_string, const unsigned long displayoff, int c, const bool ascii, const char* hex_digits, int nonzero, const bool autoskip)
{
static char l[LLEN + 1]; // static because it may be too big for stack
int addrlen = 9;
if (!colsgiven || !cols) {
cols = 16;
} else if (cols < 1 || cols > COLS) {
Expand Down Expand Up @@ -862,7 +865,8 @@ int main(int argc, char* argv[])
char* varname = NULL;
bool autoskip = false, capitalize = false, colsgiven = false, decimal_offset = false;
bool ascii = true, revert = false, uppercase_hex = false;
int addrlen = 9, c = 0, cols = 0, e = 0, grplen = 0, negseek = 0, nonzero = 0;

int c = 0, cols = 0, e = 0, grplen = 0, negseek = 0, nonzero = 0;
int octspergrp = -1, relseek = 0, x = 0;
long length = -1, seekoff = 0;
unsigned long displayoff = 0;
Expand Down Expand Up @@ -1058,30 +1062,27 @@ int main(int argc, char* argv[])
if (e >= 0) {
seekoff = ftell(input_file);
} else {
long s = seekoff;
while (s--) {
for (long s = seekoff; s > 0; s--) {
getc_or_die(&c);
if (c == EOF) {
exit_with_error(4, "Sorry, cannot seek.");
}
}
}
}

const char* hex_digits = uppercase_hex ? upper_hex_digits : lower_hex_digits;
const char* decimal_format_string = decimal_offset ? "%08ld:" : "%08lx:";

switch (hextype) {
case HEX_POSTSCRIPT:
return hex_postscript(colsgiven, cols, octspergrp, revert, e, length, negseek, seekoff, hex_digits);
case HEX_CINCLUDE:
return hex_cinclude(colsgiven, cols, octspergrp, revert, e, c, capitalize, varname, argv[1], uppercase_hex, length);
case HEX_BITS:
return hex_bits(colsgiven, cols, octspergrp, revert, c, grplen, e, length, addrlen, decimal_format_string, seekoff, displayoff, x, color, nonzero, ascii, autoskip);
return hex_bits(colsgiven, cols, octspergrp, revert, c, grplen, e, length, decimal_format_string, seekoff, displayoff, x, color, nonzero, ascii, autoskip);
case HEX_NORMAL:
return hex_normal(colsgiven, cols, octspergrp, revert, negseek, seekoff, e, color, grplen, ascii, length, addrlen, decimal_format_string, displayoff, c, x, hex_digits, nonzero, autoskip);
return hex_normal(colsgiven, cols, octspergrp, revert, negseek, seekoff, e, color, grplen, ascii, length, decimal_format_string, displayoff, c, x, hex_digits, nonzero, autoskip);
case HEX_LITTLEENDIAN:
return hex_littleendian(colsgiven, cols, octspergrp, revert, seekoff, color, grplen, e, length, addrlen, decimal_format_string, displayoff, c, ascii, hex_digits, nonzero, autoskip);
return hex_littleendian(colsgiven, cols, octspergrp, revert, seekoff, color, grplen, e, length, decimal_format_string, displayoff, c, ascii, hex_digits, nonzero, autoskip);
}
return 0;
}

0 comments on commit 881e2f4

Please sign in to comment.