diff options
author | pgen <p.gen.progs@gmail.com> | 2018-01-31 23:04:45 +0100 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2018-01-31 23:04:45 +0100 |
commit | e6b8b4ba8881dbb985f22bd349577c5658ff9936 (patch) | |
tree | bc754d66cff415cfbc107b371f2a15dd820f8fb9 | |
parent | 1d29b0dd699cf1d536beba922fea9864915724f2 (diff) |
Use isgraph if it is available and an alternative otherwise
-rw-r--r-- | config.h.in | 3 | ||||
-rwxr-xr-x | configure | 26 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | smenu.c | 10 |
4 files changed, 37 insertions, 7 deletions
diff --git a/config.h.in b/config.h.in index a9956b5..e25e9e0 100644 --- a/config.h.in +++ b/config.h.in @@ -6,6 +6,9 @@ /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have the `isgraph' function. */ +#undef HAVE_ISGRAPH + /* Define to 1 if you have the <langinfo.h> header file. */ #undef HAVE_LANGINFO_H @@ -4969,8 +4969,7 @@ $as_echo "#define realloc rpl_realloc" >>confdefs.h fi -for ac_func in mblen memset nl_langinfo pathconf regcomp \ - setlocale strchr strrchr strspn +for ac_func in mblen memset nl_langinfo pathconf regcomp setlocale do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -4982,6 +4981,29 @@ _ACEOF fi done +for ac_func in strchr strrchr strspn +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +for ac_func in isgraph +do : + ac_fn_c_check_func "$LINENO" "isgraph" "ac_cv_func_isgraph" +if test "x$ac_cv_func_isgraph" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_ISGRAPH 1 +_ACEOF + +fi +done + # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || diff --git a/configure.ac b/configure.ac index de48dec..7ead12d 100644 --- a/configure.ac +++ b/configure.ac @@ -34,8 +34,9 @@ AC_TYPE_SIZE_T # Checks for library functions. AC_FUNC_MALLOC AC_FUNC_REALLOC -AC_CHECK_FUNCS([mblen memset nl_langinfo pathconf regcomp \ - setlocale strchr strrchr strspn]) +AC_CHECK_FUNCS([mblen memset nl_langinfo pathconf regcomp setlocale]) +AC_CHECK_FUNCS([strchr strrchr strspn]) +AC_CHECK_FUNCS([isgraph]) AC_CANONICAL_HOST # OS-specific tests @@ -2158,7 +2158,7 @@ parse_selectors(char * str, int * filter, char * unparsed, break; default: - if (!isgraph(c)) + if (!my_isprint(c)) return; *filter = INCLUDE_FILTER; @@ -2226,8 +2226,8 @@ parse_selectors(char * str, int * filter, char * unparsed, /* Check is we have found a well describes regular expression */ /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - if (ptr - str > start + 2 && delim1 == delim2 && isgraph(delim1) - && isgraph(delim2) && !isdigit(delim1) && !isdigit(delim2)) + if (ptr - str > start + 2 && delim1 == delim2 && my_isprint(delim1) + && my_isprint(delim2) && !isdigit(delim1) && !isdigit(delim2)) { /* Process the regex */ /* """"""""""""""""" */ @@ -5435,6 +5435,9 @@ main(int argc, char * argv[]) else langinfo.utf8 = 0; +#if HAVE_ISGRAPH + my_isprint = isgraph; +#else /* my_isprint is a function pointer that points to the 7 or 8-bit */ /* version of isprint according to the content of UTF-8 */ /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ @@ -5442,6 +5445,7 @@ main(int argc, char * argv[]) my_isprint = isprint8; else my_isprint = isprint7; +#endif /* Set terminal in noncanonical, noecho mode */ /* """"""""""""""""""""""""""""""""""""""""" */ |