Bug 1060419 - remove SprintfState typedef; r=froydnj
authorTom Tromey <tom@tromey.com>
Fri, 13 Jan 2017 14:54:14 -0700
changeset 343524 6f71d06ae7090568bba2999a1b2fcc030ea25f10
parent 343523 5d287c298e2e62fceed440b930b63d8384c0523a
child 343525 e5f4fa3617fdbc1dccf66b681b1e8c6cac8757b7
push id31381
push userkwierso@gmail.com
push dateFri, 17 Feb 2017 20:45:51 +0000
treeherdermozilla-central@f302def88fe5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1060419
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1060419 - remove SprintfState typedef; r=froydnj MozReview-Commit-ID: 9ygDxy8pBLT
xpcom/string/nsTextFormatter.cpp
--- a/xpcom/string/nsTextFormatter.cpp
+++ b/xpcom/string/nsTextFormatter.cpp
@@ -41,21 +41,19 @@
 #ifdef HAVE_VA_COPY
 #define VARARGS_ASSIGN(foo, bar)        VA_COPY(foo,bar)
 #elif defined(HAVE_VA_LIST_AS_ARRAY)
 #define VARARGS_ASSIGN(foo, bar)	foo[0] = bar[0]
 #else
 #define VARARGS_ASSIGN(foo, bar)	(foo) = (bar)
 #endif
 
-typedef struct SprintfStateStr SprintfState;
-
 struct SprintfStateStr
 {
-  int (*stuff)(SprintfState* aState, const char16_t* aStr, uint32_t aLen);
+  int (*stuff)(SprintfStateStr* aState, const char16_t* aStr, uint32_t aLen);
 
   char16_t* base;
   char16_t* cur;
   uint32_t maxlen;
 
   void* stuffclosure;
 };
 
@@ -96,17 +94,17 @@ struct NumArgState
 #define ELEMENTS_OF(array_) (sizeof(array_) / sizeof(array_[0]))
 
 #define PR_CHECK_DELETE(nas) if (nas && (nas != nasArray)) { PR_DELETE(nas); }
 
 /*
 ** Fill into the buffer using the data in src
 */
 static int
-fill2(SprintfState* aState, const char16_t* aSrc, int aSrcLen, int aWidth,
+fill2(SprintfStateStr* aState, const char16_t* aSrc, int aSrcLen, int aWidth,
       int aFlags)
 {
   char16_t space = ' ';
   int rv;
 
   aWidth -= aSrcLen;
   /* Right adjusting */
   if ((aWidth > 0) && ((aFlags & _LEFT) == 0)) {
@@ -138,17 +136,17 @@ fill2(SprintfState* aState, const char16
   }
   return 0;
 }
 
 /*
 ** Fill a number. The order is: optional-sign zero-filling conversion-digits
 */
 static int
-fill_n(SprintfState* aState, const char16_t* aSrc, int aSrcLen, int aWidth,
+fill_n(SprintfStateStr* aState, const char16_t* aSrc, int aSrcLen, int aWidth,
        int aPrec, int aType, int aFlags)
 {
   int zerowidth   = 0;
   int precwidth   = 0;
   int signwidth   = 0;
   int leftspaces  = 0;
   int rightspaces = 0;
   int cvtwidth;
@@ -234,17 +232,17 @@ fill_n(SprintfState* aState, const char1
   }
   return 0;
 }
 
 /*
 ** Convert a long into its printable form
 */
 static int
-cvt_l(SprintfState* aState, long aNum, int aWidth, int aPrec, int aRadix,
+cvt_l(SprintfStateStr* aState, long aNum, int aWidth, int aPrec, int aRadix,
       int aType, int aFlags, const char16_t* aHexStr)
 {
   char16_t cvtbuf[100];
   char16_t* cvt;
   int digits;
 
   /* according to the man page this needs to happen */
   if ((aPrec == 0) && (aNum == 0)) {
@@ -275,17 +273,17 @@ cvt_l(SprintfState* aState, long aNum, i
   */
   return fill_n(aState, cvt, digits, aWidth, aPrec, aType, aFlags);
 }
 
 /*
 ** Convert a 64-bit integer into its printable form
 */
 static int
-cvt_ll(SprintfState* aState, int64_t aNum, int aWidth, int aPrec, int aRadix,
+cvt_ll(SprintfStateStr* aState, int64_t aNum, int aWidth, int aPrec, int aRadix,
        int aType, int aFlags, const char16_t* aHexStr)
 {
   char16_t cvtbuf[100];
   char16_t* cvt;
   int digits;
   int64_t rad;
 
   /* according to the man page this needs to happen */
@@ -318,17 +316,17 @@ cvt_ll(SprintfState* aState, int64_t aNu
   return fill_n(aState, cvt, digits, aWidth, aPrec, aType, aFlags);
 }
 
 /*
 ** Convert a double precision floating point number into its printable
 ** form.
 */
 static int
-cvt_f(SprintfState* aState, double aDouble, int aWidth, int aPrec,
+cvt_f(SprintfStateStr* aState, double aDouble, int aWidth, int aPrec,
       const char16_t aType, int aFlags)
 {
   int    mode = 2;
   int    decpt;
   int    sign;
   char   buf[256];
   char*  bufp = buf;
   int    bufsz = 256;
@@ -506,17 +504,17 @@ cvt_f(SprintfState* aState, double aDoub
 }
 
 /*
 ** Convert a string into its printable form. |aWidth| is the output
 ** width. |aPrec| is the maximum number of characters of |aStr| to output,
 ** where -1 means until NUL.
 */
 static int
-cvt_S(SprintfState* aState, const char16_t* aStr, int aWidth, int aPrec,
+cvt_S(SprintfStateStr* aState, const char16_t* aStr, int aWidth, int aPrec,
       int aFlags)
 {
   int slen;
 
   if (aPrec == 0) {
     return 0;
   }
 
@@ -533,17 +531,17 @@ cvt_S(SprintfState* aState, const char16
 }
 
 /*
 ** Convert a string into its printable form.  |aWidth| is the output
 ** width. |aPrec| is the maximum number of characters of |aStr| to output,
 ** where -1 means until NUL.
 */
 static int
-cvt_s(SprintfState* aState, const char* aStr, int aWidth, int aPrec, int aFlags)
+cvt_s(SprintfStateStr* aState, const char* aStr, int aWidth, int aPrec, int aFlags)
 {
   NS_ConvertUTF8toUTF16 utf16Val(aStr);
   return cvt_S(aState, utf16Val.get(), aWidth, aPrec, aFlags);
 }
 
 /*
 ** BuildArgArray stands for Numbered Argument list Sprintf
 ** for example,
@@ -814,17 +812,17 @@ BuildArgArray(const char16_t* aFmt, va_l
   return nas;
 }
 
 
 /*
 ** The workhorse sprintf code.
 */
 static int
-dosprintf(SprintfState* aState, const char16_t* aFmt, va_list aAp)
+dosprintf(SprintfStateStr* aState, const char16_t* aFmt, va_list aAp)
 {
   char16_t c;
   int flags, width, prec, radix, type;
   union
   {
     char16_t ch;
     int i;
     long l;
@@ -1193,17 +1191,17 @@ dosprintf(SprintfState* aState, const ch
   PR_CHECK_DELETE(nas);
 
   return rv;
 }
 
 /************************************************************************/
 
 static int
-StringStuff(SprintfState* aState, const char16_t* aStr, uint32_t aLen)
+StringStuff(SprintfStateStr* aState, const char16_t* aStr, uint32_t aLen)
 {
   if (*aStr == '\0') {
     return 0;
   }
 
   ptrdiff_t off = aState->cur - aState->base;
 
   nsAString* str = static_cast<nsAString*>(aState->stuffclosure);
@@ -1215,17 +1213,17 @@ StringStuff(SprintfState* aState, const 
   return 0;
 }
 
 /*
 ** Stuff routine that automatically grows the malloc'd output buffer
 ** before it overflows.
 */
 static int
-GrowStuff(SprintfState* aState, const char16_t* aStr, uint32_t aLen)
+GrowStuff(SprintfStateStr* aState, const char16_t* aStr, uint32_t aLen)
 {
   ptrdiff_t off;
   char16_t* newbase;
   uint32_t newlen;
 
   off = aState->cur - aState->base;
   if (off + aLen >= aState->maxlen) {
     /* Grow the buffer */
@@ -1279,32 +1277,32 @@ nsTextFormatter::ssprintf(nsAString& aOu
   rv = nsTextFormatter::vssprintf(aOut, aFmt, ap);
   va_end(ap);
   return rv;
 }
 
 uint32_t
 nsTextFormatter::vssprintf(nsAString& aOut, const char16_t* aFmt, va_list aAp)
 {
-  SprintfState ss;
+  SprintfStateStr ss;
   ss.stuff = StringStuff;
   ss.base = 0;
   ss.cur = 0;
   ss.maxlen = 0;
   ss.stuffclosure = &aOut;
 
   aOut.Truncate();
   int n = dosprintf(&ss, aFmt, aAp);
   return n ? n - 1 : n;
 }
 
 char16_t*
 nsTextFormatter::vsmprintf(const char16_t* aFmt, va_list aAp)
 {
-  SprintfState ss;
+  SprintfStateStr ss;
   int rv;
 
   ss.stuff = GrowStuff;
   ss.base = 0;
   ss.cur = 0;
   ss.maxlen = 0;
   rv = dosprintf(&ss, aFmt, aAp);
   if (rv < 0) {
@@ -1315,17 +1313,17 @@ nsTextFormatter::vsmprintf(const char16_
   }
   return ss.base;
 }
 
 /*
 ** Stuff routine that discards overflow data
 */
 static int
-LimitStuff(SprintfState* aState, const char16_t* aStr, uint32_t aLen)
+LimitStuff(SprintfStateStr* aState, const char16_t* aStr, uint32_t aLen)
 {
   uint32_t limit = aState->maxlen - (aState->cur - aState->base);
 
   if (aLen > limit) {
     aLen = limit;
   }
   while (aLen) {
     --aLen;
@@ -1355,17 +1353,17 @@ nsTextFormatter::snprintf(char16_t* aOut
   va_end(ap);
   return rv;
 }
 
 uint32_t
 nsTextFormatter::vsnprintf(char16_t* aOut, uint32_t aOutLen,
                            const char16_t* aFmt, va_list aAp)
 {
-  SprintfState ss;
+  SprintfStateStr ss;
   uint32_t n;
 
   MOZ_ASSERT((int32_t)aOutLen > 0);
   if ((int32_t)aOutLen <= 0) {
     return 0;
   }
 
   ss.stuff = LimitStuff;