summaryrefslogtreecommitdiff
path: root/lib/ofp-parse.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-03-11 11:52:12 -0800
committerBen Pfaff <blp@nicira.com>2011-03-16 14:53:16 -0700
commitdd8101bc538cdad7a99f61666760fa79e6c047af (patch)
tree35ce88c2bcbb2c0c4a91a250bc0ec2530b638996 /lib/ofp-parse.c
parent4ffd1b437cef5bb9465465ebf593548e40af76b5 (diff)
downloadopenvswitch-dd8101bc538cdad7a99f61666760fa79e6c047af.tar.gz
dynamic-string: New function ds_get_preprocessed_line().
This commit adds one user. It will be useful elsewhere in an upcoming commit.
Diffstat (limited to 'lib/ofp-parse.c')
-rw-r--r--lib/ofp-parse.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index 73c3ebc4b..f1a4cb449 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -874,27 +874,13 @@ bool
parse_ofp_add_flow_file(struct list *packets, enum nx_flow_format *cur,
FILE *stream)
{
- struct ds s = DS_EMPTY_INITIALIZER;
- bool ok = false;
+ struct ds s;
+ bool ok;
- while (!ds_get_line(&s, stream)) {
- char *line = ds_cstr(&s);
- char *comment;
-
- /* Delete comments. */
- comment = strchr(line, '#');
- if (comment) {
- *comment = '\0';
- }
-
- /* Drop empty lines. */
- if (line[strspn(line, " \t\n")] == '\0') {
- continue;
- }
-
- parse_ofp_flow_mod_str(packets, cur, line, OFPFC_ADD);
- ok = true;
- break;
+ ds_init(&s);
+ ok = ds_get_preprocessed_line(&s, stream) == 0;
+ if (ok) {
+ parse_ofp_flow_mod_str(packets, cur, ds_cstr(&s), OFPFC_ADD);
}
ds_destroy(&s);