/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2016 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return ds->length > 0 ? (unsigned char) ds->string[ds->length - 1] : EOF;
}
-void
+bool
ds_chomp(struct ds *ds, int c)
{
if (ds->length > 0 && ds->string[ds->length - 1] == (char) c) {
ds->string[--ds->length] = '\0';
+ return true;
+ } else {
+ return false;
}
}
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2015 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void ds_swap(struct ds *, struct ds *);
int ds_last(const struct ds *);
-void ds_chomp(struct ds *, int c);
+bool ds_chomp(struct ds *, int c);
\f
/* Inline functions. */