maint.mk has long had a syntax-check rule that requests that users use STREQ (a, b) instead of open-coding (strcmp (a, b) == 0); but nothing in gnulib actually provided that macro. This adds a new module to provide it, and an inline function streq. --- ChangeLog | 8 ++++++++ lib/stringops.h | 36 ++++++++++++++++++++++++++++++++++++ modules/stringops | 22 ++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 lib/stringops.h create mode 100644 modules/stringops
diff --git a/ChangeLog b/ChangeLog index fc8a081..0462a74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-05-25 Kieran Colford <colfo...@gmail.com> + + stringops: add new module + maint.mk has long had a syntax-check rule that requests that users use + STREQ (a, b) instead of open-coding (strcmp (a, b) == 0); but nothing in + gnulib actually provided that macro. This adds a new module to provide + it, and an inline function streq. + 2014-05-22 Pádraig Brady <p...@draigbrady.com> getlogin_r-tests: check return value rather than errno diff --git a/lib/stringops.h b/lib/stringops.h new file mode 100644 index 0000000..7242281 --- /dev/null +++ b/lib/stringops.h @@ -0,0 +1,36 @@ +/* General string operations. + + Copyright (C) 2014 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* Written by Kieran Colford. */ + +#ifndef _GL_STRINGOPS_H +#define _GL_STRINGOPS_H + +#include <string.h> +#include <stdbool.h> + +/* Test if the strings X and Y are equal. */ +#define STREQ(X, Y) (strcmp (X, Y) == 0) + +/* Test if the strings a and b are equal. */ +static inline bool +streq (const char *a, const char *b) +{ + return strcmp (a, b) == 0; +} + +#endif diff --git a/modules/stringops b/modules/stringops new file mode 100644 index 0000000..18d2992 --- /dev/null +++ b/modules/stringops @@ -0,0 +1,22 @@ +Description: +Add useful macros for common string operations. + +Files: +lib/stringops.h + +Depends-on: +stdbool +string + +configure.ac: + +Makefile.am: + +Include: +"stringops.h" + +License: +LGPLv2+ + +Maintainer: +Kieran Colford -- 1.7.9.5