Skip to content

Commit 1fcdb9d

Browse files
author
Stefan Reinauer
committed
fix indentation
git-svn-id: svn://coreboot.org/openbios/fcode-utils@96 f158a5a8-5612-0410-a976-696ce0be7e32
1 parent f3423ca commit 1fcdb9d

10 files changed

Lines changed: 1164 additions & 1214 deletions

File tree

detok/addfcodes.c

Lines changed: 120 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,15 @@ static char *vfc_buf_end;
9797
*
9898
**************************************************************************** */
9999

100-
static void skip_whitespace( char **string_line_ptr)
100+
static void skip_whitespace(char **string_line_ptr)
101101
{
102-
char *cur_char_ptr = *string_line_ptr;
103-
for ( ; *cur_char_ptr != 0 ; cur_char_ptr++ )
104-
{
105-
if ( (*cur_char_ptr != '\t') && (*cur_char_ptr != ' ') )
106-
{
107-
*string_line_ptr = cur_char_ptr;
108-
break;
102+
char *cur_char_ptr = *string_line_ptr;
103+
for (; *cur_char_ptr != 0; cur_char_ptr++) {
104+
if ((*cur_char_ptr != '\t') && (*cur_char_ptr != ' ')) {
105+
*string_line_ptr = cur_char_ptr;
106+
break;
107+
}
109108
}
110-
}
111109
}
112110

113111
/* **************************************************************************
@@ -134,24 +132,26 @@ static void skip_whitespace( char **string_line_ptr)
134132
*
135133
**************************************************************************** */
136134

137-
static bool get_next_vfc_line( void )
135+
static bool get_next_vfc_line(void)
138136
{
139-
bool retval = FALSE; /* TRUE = not at end yet */
140-
while ( vfc_remainder < vfc_buf_end )
141-
{
142-
current_vfc_line = vfc_remainder;
143-
vfc_remainder = strchr( current_vfc_line, '\n');
144-
*vfc_remainder = 0;
145-
vfc_remainder++;
146-
vfc_line_no++;
147-
skip_whitespace( &current_vfc_line);
148-
if ( *current_vfc_line == 0 ) continue; /* Blank line */
149-
if ( *current_vfc_line == '#' ) continue; /* Comment */
150-
if ( *current_vfc_line == '\\' ) continue; /* Comment */
151-
retval = TRUE;
152-
break; /* Found something */
153-
}
154-
return( retval);
137+
bool retval = FALSE; /* TRUE = not at end yet */
138+
while (vfc_remainder < vfc_buf_end) {
139+
current_vfc_line = vfc_remainder;
140+
vfc_remainder = strchr(current_vfc_line, '\n');
141+
*vfc_remainder = 0;
142+
vfc_remainder++;
143+
vfc_line_no++;
144+
skip_whitespace(&current_vfc_line);
145+
if (*current_vfc_line == 0)
146+
continue; /* Blank line */
147+
if (*current_vfc_line == '#')
148+
continue; /* Comment */
149+
if (*current_vfc_line == '\\')
150+
continue; /* Comment */
151+
retval = TRUE;
152+
break; /* Found something */
153+
}
154+
return (retval);
155155
}
156156

157157
/* **************************************************************************
@@ -176,20 +176,19 @@ static bool get_next_vfc_line( void )
176176
*
177177
**************************************************************************** */
178178
static bool did_not_splash = TRUE;
179-
static void vfc_splash( char *vf_file_name)
179+
static void vfc_splash(char *vf_file_name)
180180
{
181-
if ( did_not_splash )
182-
{
183-
/* Temporary substring buffer */
184-
/* Guarantee that the malloc will be big enough. */
185-
char *strbfr = malloc( strlen( vf_file_name) +65 ) ;
186-
sprintf( strbfr,
187-
"Reading additional FCodes from file: %s\n",
188-
vf_file_name);
189-
printremark( strbfr);
190-
free( strbfr);
191-
did_not_splash = FALSE;
192-
}
181+
if (did_not_splash) {
182+
/* Temporary substring buffer */
183+
/* Guarantee that the malloc will be big enough. */
184+
char *strbfr = malloc(strlen(vf_file_name) + 65);
185+
sprintf(strbfr,
186+
"Reading additional FCodes from file: %s\n",
187+
vf_file_name);
188+
printremark(strbfr);
189+
free(strbfr);
190+
did_not_splash = FALSE;
191+
}
193192
}
194193

195194
/* **************************************************************************
@@ -240,104 +239,98 @@ static void vfc_splash( char *vf_file_name)
240239
*
241240
**************************************************************************** */
242241

243-
bool add_fcodes_from_list( char *vf_file_name)
242+
bool add_fcodes_from_list(char *vf_file_name)
244243
{
245-
bool retval = FALSE;
246-
int added_fc_count = 0;
247-
check_tok_seq = FALSE;
244+
bool retval = FALSE;
245+
int added_fc_count = 0;
246+
check_tok_seq = FALSE;
248247

249-
if ( verbose ) vfc_splash( vf_file_name);
248+
if (verbose)
249+
vfc_splash(vf_file_name);
250250

251-
if ( init_stream( vf_file_name) != 0 )
252-
{
253-
char *strbfr = malloc( strlen( vf_file_name) +65 );
254-
sprintf( strbfr,
255-
"Could not open Additional FCodes file: %s\n",
256-
vf_file_name);
257-
printremark( strbfr);
258-
free( strbfr);
259-
exit(1);
260-
}
261-
vfc_remainder = indata;
262-
vfc_buf_end = indata + stream_max -1;
251+
if (init_stream(vf_file_name) != 0) {
252+
char *strbfr = malloc(strlen(vf_file_name) + 65);
253+
sprintf(strbfr,
254+
"Could not open Additional FCodes file: %s\n",
255+
vf_file_name);
256+
printremark(strbfr);
257+
free(strbfr);
258+
exit(1);
259+
}
260+
vfc_remainder = indata;
261+
vfc_buf_end = indata + stream_max - 1;
263262

264-
while ( get_next_vfc_line() )
265-
{
266-
char vs_fc_name[36];
267-
int vs_fc_number;
268-
int scan_result;
269-
char *lookup_result;
270-
char *fc_name_cpy;
263+
while (get_next_vfc_line()) {
264+
char vs_fc_name[36];
265+
int vs_fc_number;
266+
int scan_result;
267+
char *lookup_result;
268+
char *fc_name_cpy;
271269

272-
scan_result = sscanf( current_vfc_line, "0x%x %32s",
273-
&vs_fc_number, vs_fc_name);
270+
scan_result = sscanf(current_vfc_line, "0x%x %32s",
271+
&vs_fc_number, vs_fc_name);
274272

275-
if ( scan_result != 2 ) /* Allow a capital 0X */
276-
{
277-
scan_result = sscanf( current_vfc_line, "0X%x %32s",
278-
&vs_fc_number, vs_fc_name);
279-
}
280-
if ( scan_result != 2 ) /* Try it without the 0x */
281-
{
282-
scan_result = sscanf( current_vfc_line, "%x %32s",
283-
&vs_fc_number, vs_fc_name);
284-
}
273+
if (scan_result != 2) { /* Allow a capital 0X */
274+
scan_result = sscanf(current_vfc_line, "0X%x %32s",
275+
&vs_fc_number, vs_fc_name);
276+
}
277+
if (scan_result != 2) { /* Try it without the 0x */
278+
scan_result = sscanf(current_vfc_line, "%x %32s",
279+
&vs_fc_number, vs_fc_name);
280+
}
285281

286-
if ( scan_result != 2 ) /* That's it... */
287-
{
288-
char *strbfr = malloc( strlen( current_vfc_line) +65 );
289-
vfc_splash( vf_file_name);
290-
sprintf( strbfr,
291-
"Line #%d, invalid format. Ignoring: %s\n",
292-
vfc_line_no, current_vfc_line);
293-
printremark( strbfr);
294-
free( strbfr);
295-
continue;
296-
}
282+
if (scan_result != 2) { /* That's it... */
283+
char *strbfr =
284+
malloc(strlen(current_vfc_line) + 65);
285+
vfc_splash(vf_file_name);
286+
sprintf(strbfr,
287+
"Line #%d, invalid format. Ignoring: %s\n",
288+
vfc_line_no, current_vfc_line);
289+
printremark(strbfr);
290+
free(strbfr);
291+
continue;
292+
}
297293

298-
if ( ( vs_fc_number < 0x10 ) || ( vs_fc_number > 0x7ff ) )
299-
{
300-
char *strbfr = malloc( 85 );
301-
vfc_splash( vf_file_name);
302-
sprintf( strbfr,
303-
"Line #%d, FCode number out of range: 0x%x Ignoring.\n",
304-
vfc_line_no, vs_fc_number);
305-
printremark( strbfr);
306-
free( strbfr);
307-
continue;
308-
}
294+
if ((vs_fc_number < 0x10) || (vs_fc_number > 0x7ff)) {
295+
char *strbfr = malloc(85);
296+
vfc_splash(vf_file_name);
297+
sprintf(strbfr,
298+
"Line #%d, FCode number out of range: 0x%x Ignoring.\n",
299+
vfc_line_no, vs_fc_number);
300+
printremark(strbfr);
301+
free(strbfr);
302+
continue;
303+
}
309304

310-
lookup_result = lookup_token( (u16)vs_fc_number);
311-
if ( strcmp( lookup_result, "ferror") != 0 )
312-
{
313-
char *strbfr = malloc( strlen( lookup_result) + 85 );
314-
vfc_splash( vf_file_name);
315-
sprintf( strbfr,
316-
"Line #%d. FCode number 0x%x is already "
317-
"defined as %s Ignoring.\n",
318-
vfc_line_no, vs_fc_number, lookup_result);
319-
printremark( strbfr);
320-
free( strbfr);
321-
continue;
322-
}
305+
lookup_result = lookup_token((u16) vs_fc_number);
306+
if (strcmp(lookup_result, "ferror") != 0) {
307+
char *strbfr = malloc(strlen(lookup_result) + 85);
308+
vfc_splash(vf_file_name);
309+
sprintf(strbfr,
310+
"Line #%d. FCode number 0x%x is already "
311+
"defined as %s Ignoring.\n",
312+
vfc_line_no, vs_fc_number, lookup_result);
313+
printremark(strbfr);
314+
free(strbfr);
315+
continue;
316+
}
323317

324-
/* We've passed all the tests! */
325-
fc_name_cpy = strdup( vs_fc_name);
326-
add_token( (u16)vs_fc_number, fc_name_cpy);
327-
added_fc_count++;
328-
retval = TRUE;
329-
}
318+
/* We've passed all the tests! */
319+
fc_name_cpy = strdup(vs_fc_name);
320+
add_token((u16) vs_fc_number, fc_name_cpy);
321+
added_fc_count++;
322+
retval = TRUE;
323+
}
330324

331-
if ( verbose )
332-
{
333-
char *strbfr = malloc( 85 );
334-
sprintf( strbfr,
335-
"Added %d FCode numbers\n", added_fc_count);
336-
printremark( strbfr);
337-
free( strbfr);
338-
}
325+
if (verbose) {
326+
char *strbfr = malloc(85);
327+
sprintf(strbfr,
328+
"Added %d FCode numbers\n", added_fc_count);
329+
printremark(strbfr);
330+
free(strbfr);
331+
}
339332

340-
close_stream();
341-
check_tok_seq = TRUE;
342-
return( retval);
333+
close_stream();
334+
check_tok_seq = TRUE;
335+
return (retval);
343336
}

detok/addfcodes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@
4343
*
4444
**************************************************************************** */
4545

46-
bool add_fcodes_from_list( char *vf_file_name);
46+
bool add_fcodes_from_list(char *vf_file_name);
4747

48-
#endif /* _DETOK_VSFCODES_H */
48+
#endif /* _DETOK_VSFCODES_H */

0 commit comments

Comments
 (0)