No need to add varargs magic to a simple regex wrapper.
Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com> Acked-by: Stefan Reinauer <stefan.reinauer@coreboot.org> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6308 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
1c2734f5b6
commit
bf64985e3b
|
@ -88,8 +88,8 @@ cmos_write_t *process_input_file(FILE * f)
|
||||||
list = NULL;
|
list = NULL;
|
||||||
p = &list;
|
p = &list;
|
||||||
|
|
||||||
compile_reg_exprs(REG_EXTENDED | REG_NEWLINE, 2, blank_or_comment_regex,
|
compile_reg_expr(REG_EXTENDED | REG_NEWLINE, blank_or_comment_regex, &blank_or_comment);
|
||||||
&blank_or_comment, assignment_regex, &assignment);
|
compile_reg_expr(REG_EXTENDED | REG_NEWLINE, assignment_regex, &assignment);
|
||||||
|
|
||||||
/* each iteration processes one line from input file */
|
/* each iteration processes one line from input file */
|
||||||
for (line_num = 1; get_input_file_line(f, line, LINE_BUF_SIZE) == OK; line_num++) { /* skip comments and blank lines */
|
for (line_num = 1; get_input_file_line(f, line, LINE_BUF_SIZE) == OK; line_num++) { /* skip comments and blank lines */
|
||||||
|
@ -142,7 +142,8 @@ cmos_write_t *process_input_file(FILE * f)
|
||||||
p = &item->next;
|
p = &item->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
free_reg_exprs(2, &blank_or_comment, &assignment);
|
regfree(&blank_or_comment);
|
||||||
|
regfree(&assignment);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,14 +262,13 @@ void write_cmos_layout(FILE * f)
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static void process_layout_file(FILE * f)
|
static void process_layout_file(FILE * f)
|
||||||
{
|
{
|
||||||
compile_reg_exprs(REG_EXTENDED | REG_NEWLINE, 7,
|
compile_reg_expr(REG_EXTENDED | REG_NEWLINE, blank_or_comment_regex, &blank_or_comment_expr);
|
||||||
blank_or_comment_regex, &blank_or_comment_expr,
|
compile_reg_expr(REG_EXTENDED | REG_NEWLINE, start_entries_regex, &start_entries_expr);
|
||||||
start_entries_regex, &start_entries_expr,
|
compile_reg_expr(REG_EXTENDED | REG_NEWLINE, entries_line_regex, &entries_line_expr);
|
||||||
entries_line_regex, &entries_line_expr,
|
compile_reg_expr(REG_EXTENDED | REG_NEWLINE, start_enums_regex, &start_enums_expr);
|
||||||
start_enums_regex, &start_enums_expr,
|
compile_reg_expr(REG_EXTENDED | REG_NEWLINE, enums_line_regex, &enums_line_expr);
|
||||||
enums_line_regex, &enums_line_expr,
|
compile_reg_expr(REG_EXTENDED | REG_NEWLINE, start_checksums_regex, &start_checksums_expr);
|
||||||
start_checksums_regex, &start_checksums_expr,
|
compile_reg_expr(REG_EXTENDED | REG_NEWLINE, checksum_line_regex, &checksum_line_expr);
|
||||||
checksum_line_regex, &checksum_line_expr);
|
|
||||||
line_num = 1;
|
line_num = 1;
|
||||||
skip_past_start(f);
|
skip_past_start(f);
|
||||||
|
|
||||||
|
@ -322,10 +321,13 @@ static void process_layout_file(FILE * f)
|
||||||
*/
|
*/
|
||||||
skip_remaining_lines(f);
|
skip_remaining_lines(f);
|
||||||
|
|
||||||
free_reg_exprs(7, &blank_or_comment_expr, &start_entries_expr,
|
regfree(&blank_or_comment_expr);
|
||||||
&entries_line_expr, &start_enums_expr,
|
regfree(&start_entries_expr);
|
||||||
&enums_line_expr, &start_checksums_expr,
|
regfree(&entries_line_expr);
|
||||||
&checksum_line_expr);
|
regfree(&start_enums_expr);
|
||||||
|
regfree(&enums_line_expr);
|
||||||
|
regfree(&start_checksums_expr);
|
||||||
|
regfree(&checksum_line_expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
|
@ -33,25 +33,15 @@
|
||||||
#include "reg_expr.h"
|
#include "reg_expr.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* compile_reg_exprs
|
* compile_reg_expr
|
||||||
*
|
*
|
||||||
* Compile a bunch of regular expressions.
|
* Compile a regular expression.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void compile_reg_exprs(int cflags, int num_exprs,
|
void compile_reg_expr(int cflags, const char *expr, regex_t *reg)
|
||||||
/* const char *expr1, regex_t *reg1, */ ...)
|
|
||||||
{
|
{
|
||||||
static const size_t ERROR_BUF_SIZE = 256;
|
static const size_t ERROR_BUF_SIZE = 256;
|
||||||
char error_msg[ERROR_BUF_SIZE];
|
char error_msg[ERROR_BUF_SIZE];
|
||||||
va_list ap;
|
int result;
|
||||||
regex_t *reg;
|
|
||||||
const char *expr;
|
|
||||||
int i, result;
|
|
||||||
|
|
||||||
va_start(ap, num_exprs);
|
|
||||||
|
|
||||||
for (i = 0; i < num_exprs; i++) {
|
|
||||||
expr = va_arg(ap, const char *);
|
|
||||||
reg = va_arg(ap, regex_t *);
|
|
||||||
|
|
||||||
if ((result = regcomp(reg, expr, cflags)) != 0) {
|
if ((result = regcomp(reg, expr, cflags)) != 0) {
|
||||||
regerror(result, reg, error_msg, ERROR_BUF_SIZE);
|
regerror(result, reg, error_msg, ERROR_BUF_SIZE);
|
||||||
|
@ -60,23 +50,3 @@ void compile_reg_exprs(int cflags, int num_exprs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* free_reg_exprs
|
|
||||||
*
|
|
||||||
* Destroy a bunch of previously compiled regular expressions.
|
|
||||||
****************************************************************************/
|
|
||||||
void free_reg_exprs(int num_exprs, /* regex_t *reg1, */ ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
va_start(ap, num_exprs);
|
|
||||||
|
|
||||||
for (i = 0; i < num_exprs; i++)
|
|
||||||
regfree(va_arg(ap, regex_t *));
|
|
||||||
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
|
@ -34,8 +34,6 @@
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
void compile_reg_exprs(int cflags, int num_exprs,
|
void compile_reg_expr(int cflags, const char *expr, regex_t *reg);
|
||||||
/* const char *expr1, regex_t *reg1, */ ...);
|
|
||||||
void free_reg_exprs(int num_exprs, /* regex_t *reg1, */ ...);
|
|
||||||
|
|
||||||
#endif /* REG_EXPR_H */
|
#endif /* REG_EXPR_H */
|
||||||
|
|
Loading…
Reference in New Issue