[RFC/PATCH v3 1/8] libbb: add str_isblank() macro

walter harms wharms at bfs.de
Tue Aug 25 13:09:00 UTC 2015



Am 25.08.2015 14:44, schrieb Denys Vlasenko:
> On Tue, Aug 25, 2015 at 1:09 PM, Bartosz Golaszewski
> <bartekgola at gmail.com> wrote:
>> Add a wrapper around skip_whitespace() which evaluates to true if given
>> string contains only whitespace characters.
>>
>> Signed-off-by: Bartosz Golaszewski <bartekgola at gmail.com>
>> ---
>>  include/libbb.h         |  2 ++
>>  libbb/skip_whitespace.c | 17 +++++++++++++++++
>>  2 files changed, 19 insertions(+)
>>
>> diff --git a/include/libbb.h b/include/libbb.h
>> index 2e20706..6d7b128 100644
>> --- a/include/libbb.h
>> +++ b/include/libbb.h
>> @@ -337,6 +337,8 @@ extern char *skip_whitespace(const char *) FAST_FUNC;
>>  extern char *skip_non_whitespace(const char *) FAST_FUNC;
>>  extern char *skip_dev_pfx(const char *tty_name) FAST_FUNC;
>>
>> +#define str_isblank(str) (*skip_whitespace(str) == '\0')
>> +
> 
> This can go into libbb when it has more than one user.



FYI:
the are some possible users
( find . -name "*.c" -exec grep -A2 -H "skip_whitespace" {} \; )

./miscutils/dc.c:                               token = skip_whitespace(cursor);
./miscutils/dc.c-                               if (*token == '\0')
./miscutils/dc.c-                                       break;

./networking/ifupdown.c:                        rest_of_line = skip_whitespace(rest_of_line);
./networking/ifupdown.c-
./networking/ifupdown.c-                        if (rest_of_line[0] != '\0' /* && rest_of_line[0] != '#' */)


/util-linux/hexdump.c:         p = skip_whitespace(buf);
./util-linux/hexdump.c-         if (*p && (*p != '#')) {
./util-linux/hexdump.c-                 bb_dump_add(dumper, p);


./coreutils/test.c:     if (p == s || *(skip_whitespace(p)) != '\0')
./coreutils/test.c-             syntax(s, "bad number");

./libbb/dump.c:         p = skip_whitespace(p);
./libbb/dump.c-         if (*p == '\0') {
./libbb/dump.c-                 break;


this makes a nice TODO item

re,
 wh

> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
> 


More information about the busybox mailing list