[exim-cvs] teach sprint_vformat() size_t z modifier (jgh)

Pàgina inicial
Delete this message
Reply to this message
Autor: Exim Git Commits Mailing List
Data:  
A: exim-cvs
Assumpte: [exim-cvs] teach sprint_vformat() size_t z modifier (jgh)
Gitweb: http://git.exim.org/exim.git/commitdiff/91a246f68ff8f8e0f6740def15dc7107b6dcd584
Commit:     91a246f68ff8f8e0f6740def15dc7107b6dcd584
Parent:     1f00591e43de58718045ab86916011cc564e5201
Author:     Phil Pennock <pdp@???>
AuthorDate: Sat May 26 20:18:31 2012 -0400
Committer:  Phil Pennock <pdp@???>
CommitDate: Sat May 26 20:18:31 2012 -0400


    teach sprint_vformat() size_t z modifier (jgh)


    Jeremy wrote this, mostly; I just fixed up a comment and pedantically numbered the enum values
---
 src/src/string.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/src/src/string.c b/src/src/string.c
index 08e6045..0e73e2c 100644
--- a/src/src/string.c
+++ b/src/src/string.c
@@ -1134,7 +1134,8 @@ return yield;
BOOL
string_vformat(uschar *buffer, int buflen, const char *format, va_list ap)
{
-enum { L_NORMAL, L_SHORT, L_LONG, L_LONGLONG, L_LONGDOUBLE };
+/* We assume numbered ascending order, C does not guarantee that */
+enum { L_NORMAL=1, L_SHORT=2, L_LONG=3, L_LONGLONG=4, L_LONGDOUBLE=5, L_SIZE=6 };

 BOOL yield = TRUE;
 int width, precision;
@@ -1204,7 +1205,7 @@ while (*fp != 0)
       }
     }


- /* Skip over 'h', 'L', 'l', and 'll', remembering the item length */
+ /* Skip over 'h', 'L', 'l', 'll' and 'z', remembering the item length */

   if (*fp == 'h')
     { fp++; length = L_SHORT; }
@@ -1223,6 +1224,8 @@ while (*fp != 0)
       length = L_LONG;
       }
     }
+  else if (*fp == 'z')
+    { fp++; length = L_SIZE; }


/* Handle each specific format type. */

@@ -1252,6 +1255,7 @@ while (*fp != 0)
       case L_NORMAL:   sprintf(CS p, newformat, va_arg(ap, int)); break;
       case L_LONG:     sprintf(CS p, newformat, va_arg(ap, long int)); break;
       case L_LONGLONG: sprintf(CS p, newformat, va_arg(ap, LONGLONG_T)); break;
+      case L_SIZE:     sprintf(CS p, newformat, va_arg(ap, size_t)); break;
       }
     while (*p) p++;
     break;