Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.
Closed
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
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ AC_TYPE_SIZE_T
AC_FUNC_MALLOC
AC_CHECK_FUNCS([floor getcwd strtol])

CXX11_NULLPTR

# Checks for testing.
AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests], [enable testing the build]),
[enable_tests="$enableval"], [enable_tests=no])
Expand Down
12 changes: 12 additions & 0 deletions m4/cxx11_nullptr.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#serial 1
AC_DEFUN([CXX11_NULLPTR],
[
AC_REQUIRE([CXX11_STD_AVAILABLE])
CXX11_STD_TRY([nullptr], [], [[char *s = nullptr;]],
[ $cxx11_cv_prog_cxx_cxx11 ],
[
AC_DEFINE([HAVE_CXX11_NULLPTR],[1],
[Define to 1 C++11 nullptr is available])
],
[])
])
54 changes: 54 additions & 0 deletions m4/cxx11_std_try.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#serial 1
# CXX11_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
# ----------------------------------------------------------------
# Check whether the C++ compiler accepts features of STANDARD (e.g
# `cxx98', `cxx11') by trying to compile a program of TEST-PROLOGUE
# and TEST-BODY. If this fails, try again with each compiler option
# in the space-separated OPTION-LIST; if one helps, append it to CXX.
# If eventually successful, run ACTION-IF-AVAILABLE, else
# ACTION-IF-UNAVAILABLE.
AC_DEFUN([_CXX11_STD_TRY],
[
AC_LANG_PUSH(C++)dnl
AC_CACHE_VAL(cxx11_cv_prog_cxx_$1,
[cxx11_cv_prog_cxx_$1=no
cxx11_save_CXX=$CXX
AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
for cxx11_arg in $4
do
CXX="$cxx11_save_CXX $cxx11_arg"
_AS_ECHO_N([$cxx11_arg ])
AC_COMPILE_IFELSE([], [cxx11_cv_prog_cxx_$1=$cxx11_arg])
test "x$cxx11_cv_prog_cxx_$1" != "xno" && break
done
rm -f conftest.$ac_ext
CXX=$cxx11_save_CXX
])# AC_CACHE_VAL
cxx11_prog_cxx_stdcxx_options=
case "x$cxx11_cv_prog_cxx_$1" in
x)
AC_MSG_RESULT([working as-is]) ;;
xno)
AC_MSG_RESULT([not working]) ;;
*)
cxx11_prog_cxx_stdcxx_options=" $cxx11_cv_prog_cxx_$1"
CXX=$CXX$cxx11_prog_cxx_stdcxx_options
AC_MSG_RESULT([working]) ;;
esac
AC_LANG_POP(C++)dnl
])# _CXX11_STD_TRY
AC_DEFUN([CXX11_STD_TRY],
[
AC_MSG_CHECKING([for $CXX option to enable ]m4_translit($1, [x], [+])[ feature])
_CXX11_STD_TRY($1, $2, $3, ["" m4_expand($4)])
AS_IF([test "x$cxx11_cv_prog_cxx_$1" != xno], [$5], [$6])
])
AC_DEFUN([CXX11_STD_AVAILABLE],
[
cxx11_save_CXX=$CXX
AC_MSG_CHECKING([for $CXX to have C++11 rvalue references])
_CXX11_STD_TRY([cxx11], [], [[double&& d = 2]],
[[ -std=c++11 -std=c++0x -qlanglvl=extended0x -AA ]])
CXX=$cxx11_save_CXX
])
14 changes: 13 additions & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ namespace Sass {

// convert the extracted hex string to code point value
// ToDo: Maybe we could do this without creating a substring
#ifndef HAVE_CXX11_NULLPTR
#define nullptr (char **)0
#endif
uint32_t cp = strtol(s.substr (i + 1, len - 1).c_str(), nullptr, 16);
#ifndef HAVE_CXX11_NULLPTR
#undef nullptr
#endif

if (cp == 0) cp = 0xFFFD;

Expand Down Expand Up @@ -401,7 +407,13 @@ namespace Sass {

// convert the extracted hex string to code point value
// ToDo: Maybe we could do this without creating a substring
uint32_t cp = strtol(s.substr (i + 1, len - 1).c_str(), nullptr, 16);
#ifndef HAVE_CXX11_NULLPTR
#define nullptr (char **)0
#endif
uint32_t cp = strtol(s.substr (i + 1, len - 1).c_str(), nullptr, 16);
#ifndef HAVE_CXX11_NULLPTR
#undef nullptr
#endif

if (s[i + len] == ' ') ++ len;

Expand Down