Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions detok/addfcodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
*
**************************************************************************** */


/* **************************************************************************
*
* Global Variables Imported
Expand All @@ -62,7 +61,6 @@
*
**************************************************************************** */


/* **************************************************************************
*
* Global Variables Exported :
Expand Down Expand Up @@ -104,11 +102,11 @@ static u8 *vfc_buf_end;

/* Special Functions List */
/* Initial fcode-field value of -1 guarantees they won't be used */
token_t spcl_func_list[] = {
TOKEN_ENTRY( -1, "double(lit)" ), /* Entry [0] */
token_t spcl_func_list[] = {
TOKEN_ENTRY(-1, "double(lit)"), /* Entry [0] */
};

static const int spcl_func_count = (sizeof(spcl_func_list)/sizeof(token_t)) ;
static const int spcl_func_count = (sizeof(spcl_func_list) / sizeof(token_t));

/* Global Variables for "special function" identification */
/* Each is a pointer to the FCode field of the entry in
Expand All @@ -117,7 +115,6 @@ static const int spcl_func_count = (sizeof(spcl_func_list)/sizeof(token_t)) ;

u16 *double_lit_code = &spcl_func_list[0].fcode;


/* **************************************************************************
*
* Function name: skip_whitespace
Expand Down Expand Up @@ -174,7 +171,8 @@ static bool get_next_vfc_line(void)
bool retval = FALSE; /* TRUE = not at end yet */
while (vfc_remainder < vfc_buf_end) {
current_vfc_line = (char *)vfc_remainder;
vfc_remainder = (u8 *)strchr((const char *)current_vfc_line, '\n');
vfc_remainder =
(u8 *) strchr((const char *)current_vfc_line, '\n');
*vfc_remainder = 0;
vfc_remainder++;
vfc_line_no++;
Expand Down Expand Up @@ -332,8 +330,7 @@ bool add_fcodes_from_list(char *vf_file_name)
}

if (scan_result != 2) { /* That's it... */
char *strbfr =
malloc(strlen(current_vfc_line) + 65);
char *strbfr = malloc(strlen(current_vfc_line) + 65);
vfc_splash(vf_file_name);
sprintf(strbfr,
"Line #%d, invalid format. Ignoring: %s\n",
Expand Down Expand Up @@ -372,20 +369,25 @@ bool add_fcodes_from_list(char *vf_file_name)
bool found_spf = FALSE;
int indx;
for (indx = 0; indx < spcl_func_count; indx++) {
if ( strcmp( vs_fc_name, spcl_func_list[indx].name) == 0 ) {
if (strcmp
(vs_fc_name,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this (parens on the next line) really Linux style? And even if, is this something to emulate?

spcl_func_list[indx].name) == 0) {
char strbuf[64];
found_spf = TRUE;
spcl_func_list[indx].fcode = vs_fc_number;
link_token( &spcl_func_list[indx]);
spcl_func_list[indx].fcode =
vs_fc_number;
link_token(&spcl_func_list[indx]);
added_fc_count++;
sprintf( strbuf, "Added Special Function FCode "
"number 0x%03x, name %s\n", vs_fc_number, vs_fc_name);
printremark( strbuf);
sprintf(strbuf,
"Added Special Function FCode "
"number 0x%03x, name %s\n",
vs_fc_number, vs_fc_name);
printremark(strbuf);
break;
}
}

if (found_spf)
if (found_spf)
continue;
}

Expand All @@ -397,9 +399,8 @@ bool add_fcodes_from_list(char *vf_file_name)
}

if (verbose) {
char strbfr[32];
sprintf(strbfr,
"Added %d FCode numbers\n", added_fc_count);
char strbfr[32];
sprintf(strbfr, "Added %d FCode numbers\n", added_fc_count);
printremark(strbfr);
}

Expand Down
3 changes: 1 addition & 2 deletions detok/addfcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
/* For "special function" identification */
extern u16 *double_lit_code;


/* ************************************************************************** *
*
* Function Prototypes / Functions Exported:
Expand All @@ -55,4 +54,4 @@ extern u16 *double_lit_code;

bool add_fcodes_from_list(char *vf_file_name);

#endif /* _DETOK_VSFCODES_H */
#endif /* _DETOK_VSFCODES_H */
39 changes: 15 additions & 24 deletions detok/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static void pretty_print_string(void)
static void decode_lines(void)
{
if (show_linenumbers) {
printf("%6d: ",show_offsets ? token_streampos : linenum++);
printf("%6d: ", show_offsets ? token_streampos : linenum++);
}
}

Expand Down Expand Up @@ -195,7 +195,6 @@ static void output_token_name(void)
return;
}


tname = lookup_token(fcode);
printf("%s ", tname);

Expand Down Expand Up @@ -239,7 +238,6 @@ static void output_token(void)
output_token_name();
}


/* **************************************************************************
*
* Function name: decode_offset
Expand Down Expand Up @@ -330,8 +328,7 @@ static s16 decode_offset(void)
if (offs == 0) {
printremark("Error: Unresolved offset.");
} else {
printremark
("Error: Invalid offset. Ignoring...");
printremark("Error: Invalid offset. Ignoring...");
set_streampos(streampos);
}
}
Expand Down Expand Up @@ -446,7 +443,6 @@ static void decode_start(void)
fcformat = get_num8();
printf(" format: 0x%02x\n", fcformat);


/* Check for checksum correctness. */

token_streampos = get_streampos();
Expand All @@ -467,7 +463,6 @@ static void decode_start(void)
printf(" len: 0x%04x ( %d bytes)\n", fclen, fclen);
}


/* **************************************************************************
*
* Function name: decode_token
Expand Down Expand Up @@ -549,28 +544,26 @@ static void decode_token(u16 token)
decode_default();
break;

#if 0 /* Fooey on C's petty limitations! */
/* I'd like to be able to do this: */
/* Special Functions */
#if 0 /* Fooey on C's petty limitations! */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe start the comment on the next line so that the indenter knows what to do about it?

/* I'd like to be able to do this: */
/* Special Functions */
case *double_lit_code:
double_length_literal();
break;
#endif /* Fooey on C's petty limitations! */
#endif /* Fooey on C's petty limitations! */

default:
{
/* Have to do this clumsy thing instead */
if ( token == *double_lit_code )
{
double_length_literal();
break;
}
{
/* Have to do this clumsy thing instead */
if (token == *double_lit_code) {
double_length_literal();
break;
}

decode_default();
decode_default();
}
}
}
}


/* **************************************************************************
*
Expand Down Expand Up @@ -763,8 +756,7 @@ static bool another_fcode_block(void)
case 0x0f2: /* start2 */
case 0x0f3: /* start4 */
retval = TRUE;
printremark
("Subsequent FCode Block detected. Detokenizing.");
printremark("Subsequent FCode Block detected. Detokenizing.");
break;
case 0: /* Start of a zero-fill field */
/* retval already = FALSE . Nothing else to be done. */
Expand Down Expand Up @@ -816,5 +808,4 @@ void detokenize(void)
}
}


}
19 changes: 9 additions & 10 deletions detok/detok.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ bool show_offsets = FALSE;
* TRUE preceding error-exit */
static void print_copyright(bool is_error)
{
typedef void (*vfunct) (); /* Pointer to function returning void */
typedef void (*vfunct)(); /* Pointer to function returning void */
vfunct pfunct;
char buffr[512];

sprintf(buffr,
"Welcome to detok - FCode detokenizer v" DETOK_VERSION "\n"
"Welcome to detok - FCode detokenizer v" DETOK_VERSION "\n"
CORE_COPYR "\n" IBM_COPYR "\n"
"Written by Stefan Reinauer\n"
"This program is free software; you may redistribute it "
Expand Down Expand Up @@ -100,13 +100,13 @@ int main(int argc, char **argv)
#ifdef __GLIBC__
int option_index = 0;
static struct option long_options[] = {
{"verbose", 0, 0, 'v'},
{"help", 0, 0, 'h'},
{"all", 0, 0, 'a'},
{"linenumbers", 0, 0, 'n'},
{"offsets", 0, 0, 'o'},
{"fcodes", 1, 0, 'f'},
{0, 0, 0, 0}
{ "verbose", 0, 0, 'v' },
{ "help", 0, 0, 'h' },
{ "all", 0, 0, 'a' },
{ "linenumbers", 0, 0, 'n' },
{ "offsets", 0, 0, 'o' },
{ "fcodes", 1, 0, 'f' },
{ 0, 0, 0, 0 }
};

c = getopt_long(argc, argv, optstring,
Expand Down Expand Up @@ -190,4 +190,3 @@ int main(int argc, char **argv)

return 0;
}

6 changes: 2 additions & 4 deletions detok/detok.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ typedef struct token {
/* Macro for creating an entry in a token-table data-array */
#define TOKEN_ENTRY(num, name) { name, (u16)num, (token_t *)NULL }


/* Prototypes for functions exported from
* detok.c decode.c printformats.c pcihdr.c and dictionary.c
*/

void link_token(token_t *curr_token);
void link_token(token_t * curr_token);
void add_token(u16 number, char *name);
void init_dictionary(void);
void reset_dictionary(void);
Expand All @@ -70,7 +69,6 @@ void printremark(char *str);
int handle_pci_header(u8 * data_ptr);
void handle_pci_filler(u8 * filler_ptr);


/* External declarations for variables defined in or used by
* detok.c decode.c printformats.c pcihdr.c and dictionary.c
*/
Expand All @@ -90,4 +88,4 @@ extern u8 *pci_image_end;
extern unsigned int token_streampos;
extern u16 last_defined_token;

#endif /* _UTILS_DETOK_DETOK_H */
#endif /* _UTILS_DETOK_DETOK_H */
21 changes: 11 additions & 10 deletions detok/dictionary.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ char *lookup_token(u16 number)
*
**************************************************************************** */

void link_token( token_t *curr_token)
void link_token(token_t * curr_token)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the indenter mixed up multiplication and pointer type here

{
curr_token->prev = dictionary;
curr_token->prev = dictionary;

dictionary = curr_token;
}
Expand Down Expand Up @@ -134,9 +134,9 @@ void add_token(u16 number, char *name)
}

curr->name = name;
curr->fcode=number;
curr->fcode = number;

link_token( curr);
link_token(curr);

if (check_tok_seq) {
/* Error-check, but not for first time. */
Expand All @@ -145,11 +145,13 @@ void add_token(u16 number, char *name)
last_defined_token = number;
} else {
if (number <= last_defined_token) {
printremark("Warning: New token # might overlap "
"previously assigned token #(s).");
printremark
("Warning: New token # might overlap "
"previously assigned token #(s).");
} else {
printremark("Warning: New token # out of sequence with "
"previously assigned token #(s).");
printremark
("Warning: New token # out of sequence with "
"previously assigned token #(s).");
/* It's increasing; update it. */
last_defined_token = number;
}
Expand Down Expand Up @@ -546,8 +548,7 @@ token_t detok_table[] = {
TOKEN_ENTRY(0x254, "xwsplit"),
};

static const int dictionary_indx_max =
(sizeof(detok_table) / sizeof(token_t));
static const int dictionary_indx_max = (sizeof(detok_table) / sizeof(token_t));

static token_t *dictionary_reset_position;

Expand Down
Loading