Commit Graph

39 Commits

Author SHA1 Message Date
Gregory Nutt
653ff2c34e Restore lib_sprintf(). It was removed because I thought was not used. But I was wrong; there is logic in drivers/syslog that depends on lib_sprintf().
This commits reverts a part of commit c271151d57.  That commit also removed lib_sscanf() which really is not needed.
2019-02-16 12:29:00 -06:00
Johannes
739561ab34 libs/libc/stdio/Make.defs: lib_dtoa.c is only used in the LIBC_CONFIG_NANO_PRINTF=n case. 2019-02-16 09:45:13 -06:00
Gregory Nutt
4bd2a9e1b2 libs/libc/stdio/nano_libvsprintf.c: Fix compile error introduced by my review of last commit. Fix some coding standard violations and a few other cosmetics. 2019-02-16 06:28:23 -06:00
Johannes
41a4a40879 libs/libc/stdio/nano_libvsprintf.c: Add long long support. CONFIG_LIBC_LONG_LONG needs at least CONFIG_NANO_PRINTLEVEL 2. Code size for compile without CONFIG_LIBC_LONG_LONG shouldn't be affected. 2019-02-15 19:10:40 -06:00
Gregory Nutt
72bc331217 Cosmetic update to some comments. 2019-02-15 18:26:06 -06:00
Gregory Nutt
c271151d57 libs/libc/stdio: Remove unused, non-standard functions lib_sscanf() and lib_sprintf(). 2019-02-15 18:01:39 -06:00
Gregory Nutt
928108036c libs/libc/stdio: In the recent changes we lost the implementation of vsscanf(). This commit restores vsscanf(). sscanf() is not just a front end for vsscanf(). 2019-02-15 17:31:58 -06:00
Gregory Nutt
d0bd4c959d arch/arm/src/tiva/hardware/tiva_ssi.h: Fix typo error found in build testing. libs/libc/stdio/lib_libsscanf.c: Fix warnings found in build testing. 2019-02-15 14:38:06 -06:00
Gregory Nutt
4dc0636f1e libs/libc/stdio: Add support for %g format which, for these purpose, is equivalent to %f except that trailing zeroes are suppressed. 2019-02-15 11:45:25 -06:00
Gregory Nutt
5739179109 Upate Kconfig comments 2019-02-15 10:04:57 -06:00
Gregory Nutt
38e93ede2b Revert "libs/libc/stdio: Fix the %f floating point output format."
The previous implementation was probably corect.  On Cygwin with GCC I see this:

int main(int argc, char **argv)
{
  printf("Value 1.2 is: [%f]\n", 1.2);
  printf("Value 0.1 is: [%f]\n", 0.1);
  printf("Value 0.0: [%f]\n", 0.0);
  printf("Value 347.6872: [%f]\n", 347.6872);
}

Generates output

Value 1.2 is: [1.200000]
Value 0.1 is: [0.100000]
Value 0.0: [0.000000]
Value 347.6872: [347.687200]

This reverts commit eb0223bc7f.
2019-02-15 10:01:44 -06:00
Gregory Nutt
eb0223bc7f libs/libc/stdio: Fix the %f floating point output format. 2019-02-15 09:56:58 -06:00
Johannes
7b9d02d496 libs/libc/stdio/lib_libvsprintf.c: No precision specifier resulted in precision 0 but should be precision 6. 2019-02-15 08:42:07 -06:00
Johannes
479363ae3b libs/libc/stdio/lib_libsscanf.c: Initialized the lastc pointer to avoid the checks for NULL. Removed a bug in the floating point parsing which allowed several signs after each other. 2019-02-14 15:43:21 -06:00
Johannes
350295d009 Squashed commit of the following:
Author: Gregory Nutt <gnutt@nuttx.org>

    TODO:  Remove 'Missing fscanf()' bug
    Clean up remaining complaints for tools/nxstyle
    Apply tools/detab, rmcr, convert-comments, lowhex, and indent.sh to the new and highly modified files.

Author: Johannes <nivus.entwicklung@gmail.com>

    - Move vscanf logic to lib_sscanf.c  Switched to stream interface (tricky, because the old implementation used massive read ahead, which isn't suitable for streams, chars already read are gone).
    - Added scanf and fscanf
    - Added hh, h, and ll modifiers
    - Fixes for standard compliance in scanf
    - Fixes for standard compliance in strto... function family (don't consume single '-' or '+', allow sign in strotul(l))
2019-02-14 07:03:02 -06:00
Gregory Nutt
a64869aa67 CONFIG_NFILE_DESCRIPTORS=0 can no longer be used to disable the file system. NuttX with no file system does not make sense.
Squashed commit of the following:

    configs/:  The few configurations that formerly set CONFIG_NFILE_DESCRIPTORS=0 should not default, rather they should set the number of descriptors to 3.
    fs/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    tools/:  Tools updates for changes to usage of CONFIG_NFILE_DESCRIPTORS.
    syscall/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    libs/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    include/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    drivers/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    Documentation/:  Remove all references to CONFIG_NFILE_DESCRIPTORS == 0
    binfmt/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    arch/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    net/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    sched/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    sched/Kconfig:  CONFIG_NFILE_DESCRIPTORS may no longer to set to a value less than 3
    configs/:  Remove all settings for CONFIG_NFILE_DESCRIPTORS < 3
2019-02-11 12:09:26 -06:00
Gregory Nutt
675a9a170a lib_sscanf.c: Remove some redundancy in debug output. 2019-02-10 07:49:42 -06:00
Gregory Nutt
6a30e22ad4 Update a README; improvie some Kconfig defaults. 2019-02-09 12:19:32 -06:00
Gregory Nutt
7ac9bd671b libs/libc/stdio/Kconfig: Update some help comments. 2019-02-07 18:47:27 -06:00
Gregory Nutt
adf28d8903 libs/libc/stdio/Kconfig: CONFIG_NANO_PRINTF should depend on CONFIG_LIBC_LONG_LONG=n. Default should be y if CONFIG_DEFAULT_MALL=yi (as suggested by Alan Carvalho de Assis). 2019-02-07 17:37:43 -06:00
Alan Carvalho de Assis
38508e72b9 libs/libc/stdio/nano_libvsprintf.c: Remove not used sign variable that was stopping the compilation 2019-02-07 16:48:38 -06:00
Gregory Nutt
e5ea84c1ff libs/libc/stdio: A few more coding standard fixes for nano-printf file: all global data names must begin with g_. All structure names must end with _s. 2019-02-06 17:05:01 -06:00
Keith Packard
e05149b745 libs/libc/stdio: Add newlib-nano fprintf as an option. This fprintf code was originally adapted from AVR libc and provides improved floating point output support, including 'g' mode and making 'f' mode include digits past the decimal by default. However, this version does not have any long long support. On a demonstration cortex M4 build, this version saves about 5kB of ROM. The newlib version can be found here: https://salsa.debian.org/electronics-team/toolchains/newlib-nano . That project is GPL overall, but the newlib-nano printf portions are BSD licensed as described in the COPYING.NEWLIB file. 2019-02-06 15:50:52 -06:00
ligd
d6740a6678 libs/libc/stdio/lib_libvsprintf.c: Correct justification for alternate forms of %p and %P 2019-01-27 06:22:01 -06:00
Gregory Nutt
3def509f4e libs/libc/stdio/lib_libfread.c: fread() should always set EOF if fewer than the requested number of bytes was not read. Per Anthony Merlino. 2018-12-07 12:18:40 -06:00
Xiang Xiao
e27b6c46ec libs/libc/stdio/lib_libvsprintf.c: Eliminate recursive in conversion functions of lib_vsprintf(). 2018-11-08 08:43:15 -06:00
Gregory Nutt
efe2ff3933 libs/libc/stdio/Kconfig: Commit d0254b1c79 removed all usage of CONFIG_NOPRINTF_FIELDWIDTH but failed to remove the selection from the Kconfig file. 2018-10-06 10:33:29 -06:00
Gregory Nutt
0487fa90f8 libs/libc/stdio/lib_libvsprintf.c: Correct another discrepancy between NuttX printf() output and glibc printf() output. 2018-10-06 09:57:06 -06:00
Gregory Nutt
079fedaa3d Update TODO list. Costmetic (only) changes to libs/libc/stdio/lib_libvsprintf.c 2018-10-05 16:09:53 -06:00
Gregory Nutt
055810d9a4 libs/libc/stdio/lib_libvsprintf.c: Correct handling of integer 'precision' in all justification types for values 9, 99, 999, 9999, 99999:
Right justification:
  009   099   999  9999 99999  %5.3u
    9    99   999  9999 99999  %5u

Right justification, zero padding
  009   099   999  9999 99999  %05.3u
00009 00099 00999 09999 99999  %05u

Left justification
009   099   999   9999  99999  %-5.3u
9     99    999   9999  99999  %-5u
2018-10-05 13:54:36 -06:00
Gregory Nutt
c958dc0f22 libs/libc/stdio/lib_libvsprintf.c: Back out most of commit d0254b1c79. While logic seemed correct, verify against glibc showed differs. The output now matches the output form glibc:
This code sequence:

  printf("%3.3u %3.3u %3.3u %3.3u %3.3u\n",
         9, 99, 999, 9999, 99999);
  printf("%3u %3u %3u %3u %3u\n",
         9, 99, 999, 9999, 99999);
  printf("%3.3lu %3.3lu %3.3lu %3.3lu %3.3lu\n",
         9L, 99L, 999L, 9999L, 99999L);
  printf("%3u %3u %3u %3u %3u\n",
         9L, 99L, 999L, 9999L, 99999L);
  printf("%3.3llu %3.3llu %3.3llu %3.3llu %3.3llu\n",
         9LL, 99LL, 999LL, 9999LL, 99999LL);
  printf("%3llu %3llu %3llu %3llu %3llu\n",
         9LL, 99LL, 999LL, 9999LL, 99999LL);

Generates:

009 099 999 9999 99999
  9  99 999 9999 99999
009 099 999 9999 99999
  9  99 999 9999 99999
009 099 999 9999 99999
  9  99 999 9999 99999

For both NuttX and glibc.
2018-10-05 13:00:18 -06:00
Gregory Nutt
d0254b1c79 Squashed commit of the following:
libs/libc/stdio/lib_libvsprintf.c:  Resolves the integer field width problem if Issue 35 for the cases of long and long long integer types.

    libs/libc/stdio/lib_libvsprintf.c:  Resolves the integer field width problem if Issue 35 for the case of integer types.

    libs/libc/stdio:  Remove CONFIG_NOPRINTF_FIELDWIDTH.  That option does, indeed, make the printf family of functions much smaller.  But it also adds a lot of complexity and makes the functions non-standard.  Removing this might break some of the tinier platforms but it is the best thing to do for long term maintanance for for OpenGroup.org compliance.
2018-10-05 09:33:48 -06:00
Gregory Nutt
8eac8ee52a Trivial updates after review of last merge. 2018-10-03 11:22:22 -06:00
Mihai Serban
b01e6e5f2a libs/libc/stdio/lib_sscanf.c: Fix conversion for format specifiers that appear right after a floating point format specifier
When performing a floating point conversion the parsing code could
consume more than required characters from the input buffer. This made
impossible to convert input of form "1.1K" using format "%f%c".

Fix the issue by advancing the input buffer with the actual characters
converted as a float point number.

Signed-off-by: Mihai Serban <mihai.serban@gmail.com>
2018-10-03 11:15:44 -06:00
Gregory Nutt
a7fd58c4db Squashed commit of the following:
many locations:  Change occurences of open() followed by file_detach() to file_open().  Change most non-controversion calls to open() to nx_open().

    fs/inode/fs_fileopen.c:  Flesh out file_open() with some interim, placeholder logic.

    fs/inode/fs_fileopen.c:  Add a framework for a file_open() implementation (no real logic in place yet).

    fs/vfs/fs_open.c:  Add nx_open() which is the same as open() except that it does not create a cancellation point nor does it modify the errno variable.
2018-09-15 10:49:41 -06:00
Xiang Xiao
6129136329 libs/libc/stdio/lib_setvbuf.c: Fix warning: 'newbuf may be used uninitialized' 2018-08-29 06:10:52 -06:00
Xiang Xiao
467d2a58ea Replace non critical PANIC with DEBUGPANIC to save the code space 2018-08-24 06:21:15 -06:00
Alan Carvalho de Assis
283b73edc5 Fix lots of typos in C comments and Kconfig help text 2018-07-08 18:24:45 -06:00
Gregory Nutt
cf99fb40c9 This commit moves all of the libraries under a common directory called libs/. This most certainly break libcxx and uClibc++ for now.
Squashed commit of the following:

    libs/libxx:  Fix some confusing in naming.  If the directory is called libxx, then the library must be libxx.a (unless perhaps LIBCXX is selected).
    libs/:  Fix paths in moved library directories.
    libs:  Brute force move of libc, libnx, and libxx to libs.  Cannot yet build it in that configuration.
2018-05-29 13:21:26 -06:00