mirror of
https://github.com/openvswitch/ovs
synced 2025-08-29 13:27:59 +00:00
dynamic-string: Make ds_chomp() return true if it removed a character.
This will be used in an upcoming commit. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Jarno Rajahalme <jarno@ovn.org>
This commit is contained in:
parent
250bd94d1e
commit
29100ef2ba
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -446,10 +446,13 @@ ds_last(const struct ds *ds)
|
|||||||
return ds->length > 0 ? (unsigned char) ds->string[ds->length - 1] : EOF;
|
return ds->length > 0 ? (unsigned char) ds->string[ds->length - 1] : EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
ds_chomp(struct ds *ds, int c)
|
ds_chomp(struct ds *ds, int c)
|
||||||
{
|
{
|
||||||
if (ds->length > 0 && ds->string[ds->length - 1] == (char) c) {
|
if (ds->length > 0 && ds->string[ds->length - 1] == (char) c) {
|
||||||
ds->string[--ds->length] = '\0';
|
ds->string[--ds->length] = '\0';
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -73,7 +73,7 @@ void ds_destroy(struct ds *);
|
|||||||
void ds_swap(struct ds *, struct ds *);
|
void ds_swap(struct ds *, struct ds *);
|
||||||
|
|
||||||
int ds_last(const struct ds *);
|
int ds_last(const struct ds *);
|
||||||
void ds_chomp(struct ds *, int c);
|
bool ds_chomp(struct ds *, int c);
|
||||||
|
|
||||||
/* Inline functions. */
|
/* Inline functions. */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user