From: Maxim Mamontov Date: Mon, 11 May 2015 17:04:06 +0000 (+0300) Subject: Added "smart" iconv 2nd arg const-ness detection. X-Git-Tag: 2.409~184 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/19cfbaf7704434842ed81ebcaa50028376f4bd6e?hp=-c Added "smart" iconv 2nd arg const-ness detection. --- 19cfbaf7704434842ed81ebcaa50028376f4bd6e diff --git a/projects/libs/build b/projects/libs/build index 1d40d725..9b23d546 100755 --- a/projects/libs/build +++ b/projects/libs/build @@ -1,10 +1,5 @@ #!/bin/sh -# $Revision: 1.57 $ -# $Author: faust $ -# $Date: 2010/05/09 12:39:01 $ -###################################################### - # Installation path prefix #PREFIX="" @@ -183,6 +178,18 @@ else fi rm -f fake +printf "Checking for iconv 2nd argument... " +printf "#include \nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c +$CXX $CXXFLAGS $LDFLAGS -Werror build_check.c -o fake > /dev/null 2> /dev/null +if [ $? != 0 ] +then + printf "non-const\n" +else + DEFS="$DEFS -DCONST_ICONV" + printf "const\n" +fi +rm -f fake + printf "Checking for fb_config... " FB_VERSION=`fb_config --version 2> /dev/null` if [ "$?" != "0" ] diff --git a/projects/rlm_stg/build b/projects/rlm_stg/build index 433cd04f..f78a9e1f 100755 --- a/projects/rlm_stg/build +++ b/projects/rlm_stg/build @@ -137,6 +137,18 @@ else fi rm -f fake +printf "Checking for iconv 2nd argument... " +printf "#include \nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c +$CXX $CXXFLAGS $LDFLAGS -Werror build_check.c -o fake > /dev/null 2> /dev/null +if [ $? != 0 ] +then + printf "non-const\n" +else + DEFS="$DEFS -DCONST_ICONV" + printf "const\n" +fi +rm -f fake + printf "OS=$OS\n" > $CONFFILE printf "STG_TIME=yes\n" >> $CONFFILE printf "DEBUG=$DEBUG\n" >> $CONFFILE diff --git a/projects/rscriptd/build b/projects/rscriptd/build index da5c3b5b..f01f50cb 100755 --- a/projects/rscriptd/build +++ b/projects/rscriptd/build @@ -154,6 +154,19 @@ else fi fi rm -f fake + +printf "Checking for iconv 2nd argument... " +printf "#include \nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c +$CXX $CXXFLAGS $LDFLAGS -Werror build_check.c -o fake > /dev/null 2> /dev/null +if [ $? != 0 ] +then + printf "non-const\n" +else + DEFS="$DEFS -DCONST_ICONV" + printf "const\n" +fi +rm -f fake + rm -f build_check.c printf "OS=$OS\n" > $CONFFILE diff --git a/projects/sgauth/build b/projects/sgauth/build index 0e7e5f01..4f8048cc 100755 --- a/projects/sgauth/build +++ b/projects/sgauth/build @@ -156,6 +156,19 @@ else fi fi rm -f fake + +printf "Checking for iconv 2nd argument... " +printf "#include \nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c +$CXX $CXXFLAGS $LDFLAGS -Werror build_check.c -o fake > /dev/null 2> /dev/null +if [ $? != 0 ] +then + printf "non-const\n" +else + DEFS="$DEFS -DCONST_ICONV" + printf "const\n" +fi +rm -f fake + rm -f build_check.c printf "OS=$OS\n" > $CONFFILE diff --git a/projects/sgauthstress/build b/projects/sgauthstress/build index 1593af28..92be70d9 100755 --- a/projects/sgauthstress/build +++ b/projects/sgauthstress/build @@ -154,6 +154,19 @@ else fi fi rm -f fake + +printf "Checking for iconv 2nd argument... " +printf "#include \nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c +$CXX $CXXFLAGS $LDFLAGS -Werror build_check.c -o fake > /dev/null 2> /dev/null +if [ $? != 0 ] +then + printf "non-const\n" +else + DEFS="$DEFS -DCONST_ICONV" + printf "const\n" +fi +rm -f fake + rm -f build_check.c printf "Checking for fb_config... " diff --git a/projects/sgconf/build b/projects/sgconf/build index 0b25a1ca..2d6fc859 100755 --- a/projects/sgconf/build +++ b/projects/sgconf/build @@ -166,6 +166,19 @@ else printf "yes\n" fi rm -f fake + +printf "Checking for iconv 2nd argument... " +printf "#include \nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c +$CXX $CXXFLAGS $LDFLAGS -Werror build_check.c -o fake > /dev/null 2> /dev/null +if [ $? != 0 ] +then + printf "non-const\n" +else + DEFS="$DEFS -DCONST_ICONV" + printf "const\n" +fi +rm -f fake + rm -f build_check.c if [ "$CHECK_EXPAT" != "yes" ] diff --git a/projects/sgconf_xml/build b/projects/sgconf_xml/build index 7b83359b..10de5f00 100755 --- a/projects/sgconf_xml/build +++ b/projects/sgconf_xml/build @@ -159,6 +159,19 @@ else printf "yes\n" fi rm -f fake + +printf "Checking for iconv 2nd argument... " +printf "#include \nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c +$CXX $CXXFLAGS $LDFLAGS -Werror build_check.c -o fake > /dev/null 2> /dev/null +if [ $? != 0 ] +then + DEFS="$DEFS -DCONST_ICONV" + printf "non-const\n" +else + printf "const\n" +fi +rm -f fake + rm -f build_check.c if [ "$CHECK_EXPAT" != "yes" ] diff --git a/projects/sgconv/build b/projects/sgconv/build index edde35f9..2d6ce471 100755 --- a/projects/sgconv/build +++ b/projects/sgconv/build @@ -160,6 +160,18 @@ else fi rm -f fake +printf "Checking for iconv 2nd argument... " +printf "#include \nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c +$CXX $CXXFLAGS $LDFLAGS -Werror build_check.c -o fake > /dev/null 2> /dev/null +if [ $? != 0 ] +then + printf "non-const\n" +else + DEFS="$DEFS -DCONST_ICONV" + printf "const\n" +fi +rm -f fake + printf "Checking for fb_config... " FB_VERSION=`fb_config --version 2> /dev/null` if [ "$?" != "0" ] diff --git a/projects/stargazer/build b/projects/stargazer/build index 238ae194..4bf38506 100755 --- a/projects/stargazer/build +++ b/projects/stargazer/build @@ -208,6 +208,18 @@ else fi rm -f fake +printf "Checking for iconv 2nd argument... " +printf "#include \nint main(){ const char** src = 0; iconv(0, src, 0, 0, 0); }\n" > build_check.c +$CXX $CXXFLAGS $LDFLAGS -Werror build_check.c -o fake > /dev/null 2> /dev/null +if [ $? != 0 ] +then + printf "non-const\n" +else + DEFS="$DEFS -DCONST_ICONV" + printf "const\n" +fi +rm -f fake + printf "Checking for fb_config... " FB_VERSION=`fb_config --version 2> /dev/null` if [ "$?" != "0" ] diff --git a/stglibs/common.lib/common.cpp b/stglibs/common.lib/common.cpp index d91c1795..22ec354b 100644 --- a/stglibs/common.lib/common.cpp +++ b/stglibs/common.lib/common.cpp @@ -899,7 +899,7 @@ strncpy(inBuf, source.c_str(), source.length()); inBuf[source.length()] = 0; -#if defined(FREE_BSD) || defined(FREE_BSD5) || defined(WIN32) +#if defined(CONST_ICONV) const char * srcPos = inBuf; #else char * srcPos = inBuf;