Re-design vsprintf so that it does not use so much stack; handle 8051's 2-byte generic pointers.

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@38 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2007-03-05 20:38:39 +00:00
parent 24f2e6a0a4
commit af1289c019
11 changed files with 1342 additions and 619 deletions
+2 -1
View File
@@ -52,7 +52,8 @@ STDIO_SRCS = lib_fopen.c lib_fclose.c \
lib_ungetc.c \
lib_printf.c lib_vprintf.c lib_fprintf.c lib_rawprintf.c lib_lowprintf.c \
lib_vfprintf.c lib_sprintf.c lib_libsprintf.c lib_vsprintf.c \
lib_libvsprintf.c lib_stdstream.c lib_memstream.c lib_rawstream.c lib_lowstream.c \
lib_libvsprintf.c lib_stdstream.c lib_memstream.c \
lib_rawstream.c lib_lowstream.c lib_nullstream.c \
lib_sscanf.c
STDLIB_SRCS = lib_getenv.c lib_rand.c
MATH_SRCS = lib_rint.c
+4
View File
@@ -128,6 +128,10 @@ extern void lib_rawstream(struct lib_rawstream_s *rawstream,
extern void lib_lowstream(struct lib_stream_s *rawstream);
#endif
/* Defined in lib_nullstream.c */
extern void lib_nullstream(struct lib_stream_s *nullstream);
/* Defined in lib_libsprintf.c */
extern int lib_sprintf (struct lib_stream_s *obj,
+1221 -617
View File
File diff suppressed because it is too large Load Diff
+62
View File
@@ -0,0 +1,62 @@
/************************************************************
* lib_nullstream.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* 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. Neither the name Gregory Nutt 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 COPYRIGHT HOLDERS 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
* COPYRIGHT OWNER 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.
*
************************************************************/
/************************************************************
* Included Files
************************************************************/
#include <stdio.h>
#include <errno.h>
#include "lib_internal.h"
/************************************************************
* Private Functions
************************************************************/
static void nullstream_putc(struct lib_stream_s *this, int ch)
{
this->nput++;
}
/************************************************************
* Public Functions
************************************************************/
void lib_nullstream(struct lib_stream_s *nullstream)
{
nullstream->put = nullstream_putc;
nullstream->nput = 0;
}