From 7b1e802b51979f9cd66de97ca3097d1fd5599d3d Mon Sep 17 00:00:00 2001 From: Seokhyun Kim Date: Tue, 3 Sep 2013 16:33:26 +0900 Subject: [PATCH] newlib-compat moves from appfw to compat Change-Id: I7129657000737a97011ec18821f602f1333c12da --- packaging/osp-appfw.spec | 3 +- src/CMakeLists.txt | 1 - src/appfw/CMakeLists.txt | 2 - src/newlib-compat/CMakeLists.txt | 36 - src/newlib-compat/NewlibCompatMisc.cpp | 75 -- src/newlib-compat/NewlibCompatStdio.cpp | 2102 ------------------------------ src/newlib-compat/NewlibCompatStdlib.cpp | 108 -- src/newlib-compat/NewlibCompatString.cpp | 152 --- 8 files changed, 1 insertion(+), 2478 deletions(-) delete mode 100644 src/newlib-compat/CMakeLists.txt delete mode 100644 src/newlib-compat/NewlibCompatMisc.cpp delete mode 100644 src/newlib-compat/NewlibCompatStdio.cpp delete mode 100644 src/newlib-compat/NewlibCompatStdlib.cpp delete mode 100644 src/newlib-compat/NewlibCompatString.cpp diff --git a/packaging/osp-appfw.spec b/packaging/osp-appfw.spec index 08c03b8..6c470df 100644 --- a/packaging/osp-appfw.spec +++ b/packaging/osp-appfw.spec @@ -85,7 +85,7 @@ Requires: osp-env-config >= 1.2.2.1 Requires: sqlite Requires: iniparser -Provides: libosp-appfw.so.1, libosp-newlib.so.1 +Provides: libosp-appfw.so.1 Requires(post): /sbin/ldconfig Requires(post): coreutils @@ -175,7 +175,6 @@ chmod 444 /opt/usr/etc/clocale.list /usr/share/locale/* %config /usr/etc/* %{_libdir}/osp/libosp-appfw.so* -%{_libdir}/osp/libosp-newlib.so* %{_libdir}/osp-server/libosp-appfw-server.so* %{_libdir}/osp-server/libosp-system-server.so* diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index beaeca7..81d2955 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,7 +48,6 @@ FOREACH(flag ${pkgs_CFLAGS}) ENDFOREACH(flag) ## Add SubModules -ADD_SUBDIRECTORY(newlib-compat) ADD_SUBDIRECTORY(app) ADD_SUBDIRECTORY(io) ADD_SUBDIRECTORY(base) diff --git a/src/appfw/CMakeLists.txt b/src/appfw/CMakeLists.txt index 6802ac0..4566efb 100644 --- a/src/appfw/CMakeLists.txt +++ b/src/appfw/CMakeLists.txt @@ -42,8 +42,6 @@ ENDMACRO(OSP_ADD_OBJS_IN_ARCHIVE) OSP_ADD_OBJS_IN_ARCHIVE(${STATIC_LIBS}) # add explicit dependency -SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-as-needed -losp-newlib") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed") TARGET_LINK_LIBRARIES( ${this_target} ${STATIC_LIBS}) diff --git a/src/newlib-compat/CMakeLists.txt b/src/newlib-compat/CMakeLists.txt deleted file mode 100644 index e9b2ceb..0000000 --- a/src/newlib-compat/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -SET (this_target osp-newlib) - -INCLUDE_DIRECTORIES( - ${SLP_INCLUDE_DIRS} - ${CMAKE_SOURCE_DIR}/inc -) - -SET (${this_target}_SOURCE_FILES - NewlibCompatMisc.cpp - NewlibCompatStdio.cpp - NewlibCompatStdlib.cpp - NewlibCompatString.cpp -) - -## SET EXTRA COMPILER FLAGS -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC" ) - -## SET C COMPILER FLAGS -SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") - -## SET CPP COMPILER FLAGS -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") -SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") - -SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed") - -## Create Library -ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES}) - -SET_TARGET_PROPERTIES(${this_target} - PROPERTIES - VERSION ${FULLVER} - SOVERSION ${MAJORVER} - CLEAN_DIRECT_OUTPUT 1 -) - diff --git a/src/newlib-compat/NewlibCompatMisc.cpp b/src/newlib-compat/NewlibCompatMisc.cpp deleted file mode 100644 index ff2ec29..0000000 --- a/src/newlib-compat/NewlibCompatMisc.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -// Copyright (c) 1981, 1993 -// The Regents of the University of California. All rights reserved. -// -// This code is derived from software contributed to Berkeley by -// Chris Torek. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. All advertising materials mentioning features or use of this software -// must display the following acknowledgement: -// This product includes software developed by the University of -// California, Berkeley and its contributors. -// 4. Neither the name of the University nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// - - -#include - -_OSP_EXPORT_ const char __unctrllen[256] = { - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 2, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, -}; - - diff --git a/src/newlib-compat/NewlibCompatStdio.cpp b/src/newlib-compat/NewlibCompatStdio.cpp deleted file mode 100644 index 64e4683..0000000 --- a/src/newlib-compat/NewlibCompatStdio.cpp +++ /dev/null @@ -1,2102 +0,0 @@ -// -// Copyright (c) 1990, 2007 The Regents of the University of California. -// All rights reserved. -// -// Redistribution and use in source and binary forms are permitted -// provided that the above copyright notice and this paragraph are -// duplicated in all such forms and that any documentation, -// advertising materials, and other materials related to such -// distribution and use acknowledge that the software was developed -// by the University of California, Berkeley. The name of the -// University may not be used to endorse or promote products derived -// from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -// -// This license applies to all the permissions of the below mentioned functions. -// Functions: asiprintf, iprintf, fiprintf, siprintf, sniprintf, vasiprintf, -// viprintf, vsiprintf, vsniprintf, siscanf, vfiscanf, vsiscanf, fiscanf -// - - -// -// Copyright (c) 1990 The Regents of the University of California. -// All rights reserved. -// -// This code is derived from software contributed to Berkeley by -// Chris Torek. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. All advertising materials mentioning features or use of this software -// must display the following acknowledgement: -// This product includes software developed by the University of -// California, Berkeley and its contributors. -// 4. Neither the name of the University nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This license applies to all the permissions of the below mentioned function. -// Function: vfiprintf -// - -// -// Copyright (C) 2007, 2008 Eric Blake -// Permission to use, copy, modify, and distribute this software -// is freely granted, provided that this notice is preserved. -// -// This license applies to all the permissions of the below mentioned functions. -// Functions: asnprintfc, vasnprintf, asniprintf, vasniprintf, funopen, fropen, fwopen -// - -// -// Copyright 2005, 2007 Shaun Jackman -// Permission to use, copy, modify, and distribute this software -// is freely granted, provided that this notice is preserved. -// -// This license applies to all the permissions of the below mentioned functions. -// Functions: diprintf, vdiprintf -// - - -#include - -char* -asnprintf(char* buf, size_t* lenp, const char* format, ...) -{ - va_list ap; - int len = 0; - va_start (ap, format); - len = vsnprintf (NULL, 0, format, ap); - va_end (ap); - - if (len < 0) - { - return NULL; // errno set by vsnprintf - } - - if (!buf || len >= (int)*lenp) - { - buf = (char *)realloc(buf, len + 1); - if (!buf) - { - return NULL; // errno set by malloc - } - } - - va_start (ap, format); - *lenp = vsnprintf (buf, len + 1, format, ap); - va_end (ap); - return buf; -} - - -char* -vasnprintf(char *buf, size_t *lenp, const char *format, va_list ap) -{ - va_list ap2; // don't consume the original ap, we'll need it again - va_copy(ap2, ap); - int len = 0; - len = vsnprintf (NULL, 0, format, ap2); - va_end (ap2); - - if (len < 0) - { - return NULL; // errno set by vsnprintf - } - if (!buf || len >= (int)*lenp) - { - buf = (char *)realloc(buf, len + 1); - if (!buf) - { - return NULL; // errno set by malloc - } - } - *lenp = vsnprintf(buf, len + 1, format, ap); - - return buf; -} - - -int -asiprintf(char **strp, const char *format, ...) -{ - va_list ap; - va_start (ap, format); - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - *strp = (char*)realloc(*strp, sizeof(char)*2); - strcpy(*strp, " "); - va_end (ap); - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - - ret_val = vasprintf(strp, format, ap); - va_end (ap); - return ret_val; - -done: - va_end (ap); - return EOF; -} - - -char * -asniprintf(char *buf, size_t *lenp, const char *format, ... ) -{ - va_list ap; - va_start (ap, format); - char* pret_val = NULL; - - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - va_end (ap); - return NULL; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - pret_val = vasnprintf(buf, lenp, format, ap); - va_end (ap); - return pret_val; - -done: - va_end (ap); - return NULL; -} - - -int -iprintf(const char *format, ...) -{ - va_list ap; - va_start (ap, format); - int ret_val = 0; - - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - va_end (ap); - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vprintf(format, ap); - va_end (ap); - return ret_val; - -done: - va_end (ap); - return EOF; -} - - -int -fiprintf(FILE * fp, const char *format, ...) -{ - va_list ap; - va_start (ap, format); - int ret_val = 0; - - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - va_end (ap); - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vfprintf(fp, format, ap); - va_end (ap); - return ret_val; - -done: - va_end (ap); - return EOF; -} - -int -siprintf(char *str, const char *format, ...) -{ - va_list ap; - va_start (ap, format); - int ret_val = 0; - - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - va_end (ap); - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vsprintf(str, format, ap); - va_end (ap); - return ret_val; - -done: - va_end (ap); - return EOF; -} - - -int -sniprintf(char *str, size_t size, const char *format, ...) -{ - va_list ap; - va_start (ap, format); - int ret_val = -1; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - va_end (ap); - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - - ret_val = vsnprintf(str, size, format, ap); - -done: - va_end (ap); - return ret_val; -} - -int -vasiprintf(char **strp, const char *format, va_list ap) -{ - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vasprintf(strp, format, ap); - return ret_val; - -done: return EOF; -} - - -char* -vasniprintf(char *buf, size_t *lenp, const char *format, va_list ap) -{ - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - int len = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - return NULL; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - pfmt = (char *)format; - - len = vsnprintf (NULL, 0, pfmt, ap); - va_end (ap); - - if (len < 0) - { - return NULL; // errno set by vsnprintf - } - - if (!buf || len >= (int)(*lenp)) - { - buf = (char*)malloc(len + 1); - } - - if (!buf) - { - return NULL; // errno set by malloc - } - - *lenp = vsnprintf (buf, len + 1, format, ap); - return buf; -done: return NULL; -} - - -int -vfiprintf(FILE * fp, const char *format, va_list ap) -{ - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vfprintf(fp, format, ap); - return ret_val; - -done: return EOF; -} - - -int -viprintf(const char *format, va_list ap) -{ - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vprintf(format, ap); - return ret_val; - -done: return EOF; -} - - -int -vsiprintf(char *str, const char *format, va_list ap) -{ - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vsprintf(str, format, ap); - return ret_val; - -done: return EOF; -} - - -int -vsniprintf(char *str, size_t size, const char *format, va_list ap) -{ - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vsnprintf(str, size, format, ap); - return ret_val; - -done: return EOF; -} - - -int -diprintf(int fd, const char *format, ...) -{ - va_list ap; - va_start (ap, format); - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - va_end (ap); - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vdprintf(fd, format, ap); - va_end (ap); - return ret_val; - -done: - va_end (ap); - return EOF; -} - - -int -siscanf( const char* str, const char* format, ...) -{ - va_list ap; - va_start (ap, format); - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - if (count == 0) // as no format specifier in string - { - va_end (ap); - return 0; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - va_end (ap); - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vsscanf(str, format, ap); - va_end (ap); - return ret_val; - -done: - va_end (ap); - return EOF; -} - - -int -vdiprintf(int fd, const char *format, va_list ap) -{ - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vdprintf(fd, format, ap); - return ret_val; - -done: return EOF; -} - -int vfiscanf(FILE *fp, const char *format, va_list ap) -{ - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - if (count == 0) // as no format specifier in string - { - return 0; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vfscanf(fp, format, ap); - return ret_val; - -done: return EOF; - -} - - -int -vsiscanf(const char *str, const char *format, va_list ap) -{ - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - if (count == 0) // as no format specifier in string - { - return 0; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vsscanf(str, format, ap); - return ret_val; - -done: return EOF; - -} - -int -fiscanf(FILE *fp, const char *format, ...) -{ - va_list ap; - va_start (ap, format); - int ret_val = 0; - char* pfmt = NULL; // format string - char ch = 0; // character from pfmt - int pos[100] = {0, }; - int count = 0; - int index = 0; - pfmt = (char *)format; - while (*pfmt != '\0') - { - if (*pfmt == '%') - { - pos[count++] = index; - } - index++; - pfmt++; - } - if (count == 0) // as no format specifier in string - { - va_end (ap); - return 0; - } - pfmt = (char *)format; - - if (*pfmt == '\0') - { - goto done; - } - while ((*pfmt != '%') && ( *pfmt != '\0')) - { - pfmt++; - } - index = 1; - - if (count) - { - count--; - } -rflag: ch = *pfmt++; - - switch (ch) - { - case '\'': - goto rflag; - // fall through - case ' ': - goto rflag; - // fall through - case '#': - goto rflag; - // fall through - case '*': - goto rflag; - // fall through - case '-': - goto rflag; - // fall through - case '+': - goto rflag; - // fall through - case '.': - goto rflag; - // fall through - - case '0': - goto rflag; - // fall through - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - goto rflag; - // fall through - case 'L': - goto rflag; - // fall through - case 'a': - case 'A': - case 'F': - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - va_end (ap); - return EOF; - break; - - default: // "%?" prints ?, unless ? is NUL - if (count) - { - pfmt = (char *)format; - pfmt = pfmt + pos[index++]; - count--; - pfmt++; - goto rflag; - // fall through - } - } - ret_val = vfscanf(fp, format, ap); - va_end (ap); - return ret_val; - -done: - va_end (ap); - return EOF; -} - - -typedef __ssize_t __io_read_fn (void* __cookie, char* __buf, size_t __nbytes); -typedef __ssize_t __io_write_fn (void* __cookie, __const char* __buf, size_t __n); -typedef int __io_seek_fn (void* __cookie, _IO_off64_t* __pos, int __w); -typedef int __io_close_fn (void* __cookie); - -//typedef _IO_cookie_io_functions_t ; - -//FILE* funopen(const void* cookie, funread readfn, funwrite writefn, funseek seekfn, funclose closefn); - -FILE* -funopen(const void* cookie, funread readfn, funwrite writefn, funseek seekfn, funclose closefn) -{ - cookie_io_functions_t cookiefn; - char mode[3] = {0, }; - if (readfn) - { - cookiefn.read = (__io_read_fn*)readfn; - if (writefn) - { - strcpy(mode, "r+"); - cookiefn.write = (__io_write_fn*)writefn; - } - else - { - strcpy(mode, "r"); - cookiefn.write = NULL; - } - } - else - { - strcpy(mode, "w"); - cookiefn.write = (__io_write_fn*)writefn; - cookiefn.read = NULL; - } - cookiefn.seek = (__io_seek_fn*)seekfn; - cookiefn.close = (__io_close_fn*)closefn; - - return fopencookie((void*)cookie, mode, cookiefn); -} - - -FILE* -fropen(const void* cookie, funread readfn) -{ - return funopen(cookie, readfn, (int (*)(void*, const char*, int))0, (fpos_t (*)(void*, fpos_t , int ))0, (int (*)(void*))0); -} - -FILE* -fwopen(const void* cookie, funwrite writefn) -{ - return funopen(cookie, (int (*)(void*, char*, int))0, writefn, (fpos_t (*)(void*, fpos_t , int))0, (int (*)(void*))0); -} diff --git a/src/newlib-compat/NewlibCompatStdlib.cpp b/src/newlib-compat/NewlibCompatStdlib.cpp deleted file mode 100644 index 11c18a1..0000000 --- a/src/newlib-compat/NewlibCompatStdlib.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// -// Copyright (c) 2012 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// This license applies to all functions, except for the functions under the below mentioned license -// in this file. -// - - -// -// Copyright (c) 1998, M. Warner Losh -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer.c -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This license applies to all the permissions of the below mentioned function. -// Function: reallocf -// - - -#include - -float -atoff(const char* pcStr) -{ - return strtof (pcStr, NULL); -} - -char* -ecvtf(float fval, int ndigit, int* decpt, int* sign) -{ - return ecvt((double)fval, ndigit, decpt, sign); -} - - -char* -ecvtbuf(double invalue, int ndigit, int* decpt, int* sign, char* ecvt_buf) -{ - char* pecvt_ret = ecvt(invalue, ndigit, decpt, sign); - strcpy(ecvt_buf, pecvt_ret); - return ecvt_buf; -} - - -char* -fcvtf( float fval, int ndigit, int* decpt, int* sign) -{ - return fcvt((double)fval, ndigit, decpt, sign); -} - - -char* -fcvtbuf(double invalue, int ndigit, int* decpt, int* sign, char* fcvt_buf) -{ - char* pfcvt_ret = fcvt( invalue, ndigit, decpt, sign); - strcpy(fcvt_buf, pfcvt_ret); - return fcvt_buf; -} - - -char* -gcvtf( float fval, int ndigit, char* buf) -{ - return gcvt((double)fval, ndigit, buf); -} - - -void* -reallocf(void* ptr, unsigned int size) -{ - void* ptemp = NULL; - ptemp = realloc( ptr, size); - if (!ptemp && ptr) - { - free( ptr); - } - return (ptemp); -} diff --git a/src/newlib-compat/NewlibCompatString.cpp b/src/newlib-compat/NewlibCompatString.cpp deleted file mode 100644 index 1b49d8e..0000000 --- a/src/newlib-compat/NewlibCompatString.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// -// Copyright (c) 2012 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// This license applies to all functions, except for the functions under the below mentioned license -// in this file. -// - - -// -// Copyright (c) 1998 Todd C. Miller -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. The name of the author may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -// THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// This license applies to all the permissions of the below mentioned functions. -// Functions: wcslcat, wcslcpy -// - - -#include - -char* -strlwr(char* pcStr) -{ - unsigned char* pucs = (unsigned char*) pcStr; - while (*pucs != '\0') - { - *pucs = tolower(*pucs); - pucs++; - } - return pcStr; -} - - -char* -strupr(char* pcStr) -{ - unsigned char *pucs = (unsigned char*) pcStr; - while (*pucs != '\0') - { - *pucs = toupper(*pucs); - pucs++; - } - return pcStr; -} - - -size_t -wcslcat(wchar_t* wcDst, const wchar_t* wcSrc, size_t siz) -{ - wchar_t* pdst = wcDst; - const wchar_t* psrc = wcSrc; - size_t count = siz; - size_t dlen = 0; - - // Find the end of pdst and adjust bytes left but don't go past end - while ((*pdst != '\0') && (count-- != 0)) - { - pdst++; - } - - dlen = pdst - wcDst; - count = siz - dlen; - - if (count == 0) - { - return (dlen + wcslen (psrc)); - } - - while (*psrc != '\0') - { - if (count != 1) - { - *pdst++ = *psrc; - count--; - } - psrc++; - } - *pdst = '\0'; - - return (dlen + (psrc - wcSrc)); // count does not include NUL -} - - -size_t -wcslcpy( wchar_t* wcDst, const wchar_t* wcSrc, size_t siz) -{ - wchar_t* pdst = wcDst; - const wchar_t* psrc = wcSrc; - size_t count = siz; - - // CopyPanel as many bytes as will fit - if ((count != 0) && (--count != 0)) - { - do - { - if ((*pdst++ = *psrc++) == 0) - { - break; - } - } - while (--count != 0); - } - - // Not enough room in pdst, add NUL and traverse rest of psrc - if (count == 0) - { - if (siz != 0) - { - *pdst = '\0'; // NUL-terminate pdst - } - while (*psrc++) - { - ; - } - } - - return (psrc - wcSrc - 1); // count does not include NUL -} - -- 2.7.4