You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2020/06/02 09:18:26 UTC

[incubator-nuttx] branch master updated (4f0957a -> 86b7c20)

This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 4f0957a  threads.h: Support mtx_timedlock and recursive mutex
     new d884dd3  Fix nxstyle complaints
     new 86b7c20  Implement "j" modifier for printf format

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 libs/libc/stdio/lib_libvsprintf.c | 64 +++++++++++++++++++++++----------------
 1 file changed, 38 insertions(+), 26 deletions(-)


[incubator-nuttx] 01/02: Fix nxstyle complaints

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit d884dd301fee130698e4a2e2f47f4463d188edeb
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Tue Jun 2 13:55:55 2020 +0900

    Fix nxstyle complaints
    
    various nxstyle fixed to avoid the CI warnings
---
 libs/libc/stdio/lib_libvsprintf.c | 52 +++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/libs/libc/stdio/lib_libvsprintf.c b/libs/libc/stdio/lib_libvsprintf.c
index af79164..e1101d8 100644
--- a/libs/libc/stdio/lib_libvsprintf.c
+++ b/libs/libc/stdio/lib_libvsprintf.c
@@ -137,11 +137,11 @@ struct arg
   } value;
 };
 
- /****************************************************************************
-  * Private Constant Data
-  ****************************************************************************/
+/****************************************************************************
+ * Private Constant Data
+ ****************************************************************************/
 
- static const char g_nullstring[] = "(null)";
+static const char g_nullstring[] = "(null)";
 
 /****************************************************************************
  * Public Functions
@@ -250,7 +250,6 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
                 {
                   if ((flags & FL_ARGNUMBER) == 0)
                     {
-
                       /* No other flag except FL_WIDTH or FL_ZFILL (leading
                        * zeros) and argument number must be at least 1
                        */
@@ -281,11 +280,12 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
                         {
                           index = prec;
                         }
+
                       if (index > 0 && index <= numargs)
                         {
                           if (stream == NULL)
                             {
-                              arglist[index-1].type = TYPE_INT;
+                              arglist[index - 1].type = TYPE_INT;
                               if (index > total_len)
                                 {
                                   total_len = index;
@@ -295,11 +295,11 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
                             {
                               if ((flags & FL_PREC) == 0)
                                 {
-                                  width = (int)arglist[index-1].value.u;
+                                  width = (int)arglist[index - 1].value.u;
                                 }
                               else
                                 {
-                                  prec = (int)arglist[index-1].value.u;
+                                  prec = (int)arglist[index - 1].value.u;
                                 }
                             }
                         }
@@ -382,7 +382,8 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
                 {
                   /* The only known cases that the default will be hit are
                    * (1) the eZ80 which has sizeof(size_t) = 3 which is the
-                   * same as the sizeof(int).  And (2) if CONFIG_LIBC_LONG_LONG
+                   * same as the sizeof(int).  And (2) if
+                   * CONFIG_LIBC_LONG_LONG
                    * is not enabled and sizeof(size_t) is equal to
                    * sizeof(unsigned long long).  This latter case is an
                    * error.
@@ -473,36 +474,37 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
                   if ((c >= 'E' && c <= 'G')
                       || (c >= 'e' && c <= 'g'))
                     {
-                      arglist[argnumber-1].type = TYPE_DOUBLE;
+                      arglist[argnumber - 1].type = TYPE_DOUBLE;
                     }
                   else if (c == 'i' || c == 'd' || c == 'u' || c == 'p')
                     {
                       if ((flags & FL_LONG) == 0)
                         {
-                          arglist[argnumber-1].type = TYPE_INT;
+                          arglist[argnumber - 1].type = TYPE_INT;
                         }
                       else if ((flags & FL_REPD_TYPE) == 0)
                         {
-                          arglist[argnumber-1].type = TYPE_LONG;
+                          arglist[argnumber - 1].type = TYPE_LONG;
                         }
                       else
                         {
-                          arglist[argnumber-1].type = TYPE_LONG_LONG;
+                          arglist[argnumber - 1].type = TYPE_LONG_LONG;
                         }
                     }
                   else if (c == 'c')
                     {
-                      arglist[argnumber-1].type = TYPE_INT;
+                      arglist[argnumber - 1].type = TYPE_INT;
                     }
                   else if (c == 's')
                     {
-                      arglist[argnumber-1].type = TYPE_CHAR_POINTER;
+                      arglist[argnumber - 1].type = TYPE_CHAR_POINTER;
                     }
 
                   if (argnumber > total_len)
                     {
                       total_len = argnumber;
                     }
+
                   continue; /* We do only parsing */
                 }
             }
@@ -572,7 +574,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
 #ifdef CONFIG_LIBC_NUMBERED_ARGS
           if ((flags & FL_ARGNUMBER) != 0)
             {
-              value = arglist[argnumber-1].value.d;
+              value = arglist[argnumber - 1].value.d;
             }
           else
             {
@@ -751,7 +753,6 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
               n = exp > 0 ? exp : 0;    /* Exponent of left digit */
               do
                 {
-
                   /* Insert decimal point at correct place */
 
                   if (n == -1)
@@ -855,12 +856,11 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
 
       switch (c)
         {
-
         case 'c':
 #ifdef CONFIG_LIBC_NUMBERED_ARGS
           if ((flags & FL_ARGNUMBER) != 0)
             {
-              buf[0] = (int)arglist[argnumber-1].value.u;
+              buf[0] = (int)arglist[argnumber - 1].value.u;
             }
           else
             {
@@ -878,7 +878,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
 #ifdef CONFIG_LIBC_NUMBERED_ARGS
           if ((flags & FL_ARGNUMBER) != 0)
             {
-              pnt = (FAR char *)arglist[argnumber-1].value.cp;
+              pnt = (FAR char *)arglist[argnumber - 1].value.cp;
             }
           else
             {
@@ -930,7 +930,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
 #ifdef CONFIG_LIBC_NUMBERED_ARGS
               if ((flags & FL_ARGNUMBER) != 0)
                 {
-                  x = (long long)arglist[argnumber-1].value.ull;
+                  x = (long long)arglist[argnumber - 1].value.ull;
                 }
               else
                 {
@@ -947,7 +947,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
 #ifdef CONFIG_LIBC_NUMBERED_ARGS
               if ((flags & FL_ARGNUMBER) != 0)
                 {
-                  x = (long)arglist[argnumber-1].value.ul;
+                  x = (long)arglist[argnumber - 1].value.ul;
                 }
               else
                 {
@@ -962,7 +962,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
 #ifdef CONFIG_LIBC_NUMBERED_ARGS
               if ((flags & FL_ARGNUMBER) != 0)
                 {
-                  x = (int)arglist[argnumber-1].value.u;
+                  x = (int)arglist[argnumber - 1].value.u;
                 }
               else
                 {
@@ -1013,7 +1013,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
 #ifdef CONFIG_LIBC_NUMBERED_ARGS
               if ((flags & FL_ARGNUMBER) != 0)
                 {
-                  x = arglist[argnumber-1].value.ull;
+                  x = arglist[argnumber - 1].value.ull;
                 }
               else
                 {
@@ -1030,7 +1030,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
 #ifdef CONFIG_LIBC_NUMBERED_ARGS
               if ((flags & FL_ARGNUMBER) != 0)
                 {
-                  x = arglist[argnumber-1].value.ul;
+                  x = arglist[argnumber - 1].value.ul;
                 }
               else
                 {
@@ -1045,7 +1045,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
 #ifdef CONFIG_LIBC_NUMBERED_ARGS
               if ((flags & FL_ARGNUMBER) != 0)
                 {
-                  x = (unsigned int)arglist[argnumber-1].value.u;
+                  x = (unsigned int)arglist[argnumber - 1].value.u;
                 }
               else
                 {


[incubator-nuttx] 02/02: Implement "j" modifier for printf format

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 86b7c20b7d090c5720e297829757323253b2ba0c
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Tue Jun 2 13:51:12 2020 +0900

    Implement "j" modifier for printf format
    
    It's a part of C99 and commonly used these days.
---
 libs/libc/stdio/lib_libvsprintf.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libs/libc/stdio/lib_libvsprintf.c b/libs/libc/stdio/lib_libvsprintf.c
index e1101d8..7a0f018 100644
--- a/libs/libc/stdio/lib_libvsprintf.c
+++ b/libs/libc/stdio/lib_libvsprintf.c
@@ -410,6 +410,18 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream,
                 }
             }
 
+          if (c == 'j')
+            {
+              /* Same as long long if available. Otherwise, long. */
+
+#ifdef CONFIG_LIBC_LONG_LONG
+              flags |= FL_REPD_TYPE;
+#endif
+              flags |= FL_LONG;
+              flags &= ~FL_SHORT;
+              continue;
+            }
+
           if (c == 'l')
             {
               if ((flags & FL_LONG) != 0)