Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ jobs:
set -e
export PATH=/usr/local/sbin:/usr/local/bin:$PATH
meson setup build \
-Denable-bgets-workaround=true \
-Denable-tests=true \
-Dpkg_config_path=/usr/lib/amd64/pkgconfig
meson compile -C build
Expand Down
2 changes: 1 addition & 1 deletion bstring/bstrlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,7 @@ bgetsa(bstring b, bNgetc getcPtr, void *parm, char terminator)
}

bstring
#if defined(HAVE_LIBGEN_H_BGETS)
#if defined(HAVE_BGETS)
bgetstream(bNgetc getcPtr, void *parm, char terminator)
#else
bgets(bNgetc getcPtr, void *parm, char terminator)
Expand Down
2 changes: 1 addition & 1 deletion bstring/bstrlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ typedef size_t (*bNread)(void *buff, size_t elsize, size_t nelem, void *parm);
* character. This is consistent with the semantics of fgets.)
*/
BSTR_PUBLIC bstring
#if defined(HAVE_LIBGEN_H_BGETS)
#if defined(HAVE_BGETS)
bgetstream(bNgetc getcPtr, void *parm, char terminator);
#else
bgets(bNgetc getcPtr, void *parm, char terminator);
Expand Down
20 changes: 3 additions & 17 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,12 @@ add_project_arguments('-fno-common', language: 'c')
add_project_arguments('-fvisibility=hidden', language: 'c')

bstring_inc = include_directories(['.', 'bstring'])

bgets_test_code = '''
#include <stdio.h>
#include <libgen.h>
int main() {
char buffer[256];
char delim = '\n';
FILE *fp = stdin;
char *result = bgets(buffer, sizeof(buffer), fp, &delim);
return 0;
}
'''

has_bgets = cc.compiles(bgets_test_code, name: 'bgets defined in standard C library')
conf_data = configuration_data()

if has_bgets or get_option('force-bgets-workaround')
conf_data.set('HAVE_LIBGEN_H_BGETS', '1')
if get_option('enable-bgets-workaround')
conf_data.set('HAVE_BGETS', '1')
else
conf_data.set('HAVE_LIBGEN_H_BGETS', '0')
conf_data.set('HAVE_BGETS', '0')
endif

configure_file(
Expand Down
6 changes: 3 additions & 3 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
option(
'force-bgets-workaround',
'enable-bgets-workaround',
type: 'boolean',
value: true,
description: 'Always use workaround that renames bgets function to bgetstring',
value: false,
description: 'Enable workaround that renames bgets function to bgetstring',
)
option(
'enable-docs',
Expand Down
4 changes: 2 additions & 2 deletions tests/bstest.c
Original file line number Diff line number Diff line change
Expand Up @@ -2577,15 +2577,15 @@ START_TEST(core_038)
int ret = test38_aux_bnopen(&f, &shortBstring);
ck_assert_int_eq(ret, 0);
/* Creation/reads */
#if defined(HAVE_LIBGEN_H_BGETS)
#if defined(HAVE_BGETS)
b0 = bgetstream((bNgetc)test38_aux_bngetc, &f, 'b');
#else
b0 = bgets((bNgetc)test38_aux_bngetc, &f, 'b');
#endif
ck_assert(b0 != NULL);
b1 = bread((bNread)test38_aux_bnread, &f);
ck_assert(b1 != NULL);
#if defined(HAVE_LIBGEN_H_BGETS)
#if defined(HAVE_BGETS)
b2 = bgetstream((bNgetc)test38_aux_bngetc, &f, '\0');
#else
b2 = bgets((bNgetc)test38_aux_bngetc, &f, '\0');
Expand Down