Blob Blame History Raw
diff -up ast-8.0.1/channel.c.format ast-8.0.1/channel.c
--- ast-8.0.1/channel.c.format	2014-10-17 02:04:56.000000000 -0600
+++ ast-8.0.1/channel.c	2014-10-18 19:29:38.541112982 -0600
@@ -4088,13 +4088,11 @@ static void WriteBegin( AstChannel *this
    }
 
 /* Append the "Begin" keyword followed by the class name. */
-   line = astAppendString( line, &nc, "Begin " );
-   line = astAppendString( line, &nc, class );
+   line = astAppendString( line, &nc, "Begin %s", class );
 
 /* If required, also append the comment. */
    if ( astGetComment( this ) && *comment ) {
-      line = astAppendString( line, &nc, " \t# " );
-      line = astAppendString( line, &nc, comment );
+      line = astAppendString( line, &nc, " \t# %s", comment );
    }
 
 /* Write out the resulting line of text. */
@@ -4227,8 +4225,7 @@ static void WriteDouble( AstChannel *thi
       }
 
 /* Append the name string followed by " = ". */
-      line = astAppendString( line, &nc, name );
-      line = astAppendString( line, &nc, " = " );
+      line = astAppendString( line, &nc, "%s = ", name );
 
 /* Format the value as a string and append this. Make sure "-0" isn't
    produced. Use a magic string to represent bad values. */
@@ -4241,12 +4238,11 @@ static void WriteDouble( AstChannel *thi
       } else {
          strcpy( buff, BAD_STRING );
       }
-      line = astAppendString( line, &nc, buff );
+      line = astAppendString( line, &nc, "%s", buff );
 
 /* If required, also append the comment. */
       if ( astGetComment( this ) && *comment ) {
-         line = astAppendString( line, &nc, " \t# " );
-         line = astAppendString( line, &nc, comment );
+         line = astAppendString( line, &nc, " \t# %s", comment );
       }
 
 /* Write out the resulting line of text. */
@@ -4318,8 +4314,7 @@ static void WriteEnd( AstChannel *this,
    }
 
 /* Append the "End" keyword followed by the class name. */
-   line = astAppendString( line, &nc, "End " );
-   line = astAppendString( line, &nc, class );
+   line = astAppendString( line, &nc, "End %s", class );
 
 /* Write out the resulting line of text. */
    OutputTextItem( this, line, status );
@@ -4445,17 +4440,14 @@ static void WriteInt( AstChannel *this,
       }
 
 /* Append the name string followed by " = ". */
-      line = astAppendString( line, &nc, name );
-      line = astAppendString( line, &nc, " = " );
+      line = astAppendString( line, &nc, "%s = ", name );
 
 /* Format the value as a decimal string and append this. */
-      (void) sprintf( buff, "%d", value );
-      line = astAppendString( line, &nc, buff );
+      line = astAppendString( line, &nc, "%d", value );
 
 /* If required, also append the comment. */
       if ( astGetComment( this ) && *comment ) {
-         line = astAppendString( line, &nc, " \t# " );
-         line = astAppendString( line, &nc, comment );
+         line = astAppendString( line, &nc, " \t# %s", comment );
       }
 
 /* Write out the resulting line of text. */
@@ -4578,13 +4570,11 @@ static void WriteIsA( AstChannel *this,
       }
 
 /* Append the "IsA" keyword followed by the class name. */
-      line = astAppendString( line, &nc, "IsA " );
-      line = astAppendString( line, &nc, class );
+      line = astAppendString( line, &nc, "IsA %s", class );
 
 /* If required, also append the comment. */
       if ( astGetComment( this ) && *comment ) {
-         line = astAppendString( line, &nc, " \t# " );
-         line = astAppendString( line, &nc, comment );
+         line = astAppendString( line, &nc, " \t# %s", comment );
       }
 
 /* Write out the resulting line of text. */
@@ -4715,13 +4705,11 @@ static void WriteObject( AstChannel *thi
 /* Append the name string followed by " =". The absence of a value on
    the right hand side indicates an Object value, whose definition
    follows. */
-      line = astAppendString( line, &nc, name );
-      line = astAppendString( line, &nc, " =" );
+      line = astAppendString( line, &nc, "%s =", name );
 
 /* If required, also append the comment. */
       if ( astGetComment( this ) && *comment ) {
-         line = astAppendString( line, &nc, " \t# " );
-         line = astAppendString( line, &nc, comment );
+         line = astAppendString( line, &nc, " \t# %s", comment );
       }
 
 /* Write out the resulting line of text. */
@@ -4861,8 +4849,7 @@ static void WriteString( AstChannel *thi
 /* Append the name string followed by " = " and an opening quote
    character (the string will be quoted to protect leading and
    trailing spaces). */
-      line = astAppendString( line, &nc, name );
-      line = astAppendString( line, &nc, " = \"" );
+      line = astAppendString( line, &nc, "%s = \"", name );
 
 /* We now append the value string, but must inspect each character so
    that quotes (appearing inside quotes) can be doubled. Determine the
@@ -4897,8 +4884,7 @@ static void WriteString( AstChannel *thi
 
 /* If required, also append the comment. */
       if ( astGetComment( this ) && *comment ) {
-         line = astAppendString( line, &nc, " \t# " );
-         line = astAppendString( line, &nc, comment );
+         line = astAppendString( line, &nc, " \t# %s", comment );
       }
 
 /* Write out the resulting line of text. */
diff -up ast-8.0.1/frame.c.format ast-8.0.1/frame.c
--- ast-8.0.1/frame.c.format	2014-10-17 02:04:56.000000000 -0600
+++ ast-8.0.1/frame.c	2014-10-18 19:29:38.544113039 -0600
@@ -9845,8 +9845,8 @@ L1:
    numbering of the primary frame. */
                   pfrm_setting = NULL;
                   nc = 0;
-                  pfrm_setting = astAppendString( pfrm_setting, &nc, pfrm_attrib );
-                  pfrm_setting = astAppendString( pfrm_setting, &nc, setting + axis_value );
+                  pfrm_setting = astAppendString( pfrm_setting, &nc, "%s", pfrm_attrib );
+                  pfrm_setting = astAppendString( pfrm_setting, &nc, "%s", setting + axis_value );
 
 /* Attempt to set the attribute within the primary Frame. */
                   astSetAttrib( pfrm, pfrm_setting );
diff -up ast-8.0.1/memory.c.format ast-8.0.1/memory.c
--- ast-8.0.1/memory.c.format	2014-10-17 02:04:56.000000000 -0600
+++ ast-8.0.1/memory.c	2014-10-18 19:29:38.545113058 -0600
@@ -2868,14 +2868,14 @@ static char *ChrMatcher( const char *tes
 /* Concatenate the sub-strings to form the final string. */
       reslen = 0;
       for( ipart = 0; ipart < npart - 1; ipart++ ) {
-         result = astAppendString( result, &reslen, parts[ ipart ] );
+         result = astAppendString( result, &reslen, "%s", parts[ ipart ] );
          if( ipart < nsub ) {
-            result = astAppendString( result, &reslen, newsubs[ ipart ] );
+            result = astAppendString( result, &reslen, "%s", newsubs[ ipart ] );
          } else {
-            result = astAppendString( result, &reslen, matches[ ipart ] );
+            result = astAppendString( result, &reslen, "%s", matches[ ipart ] );
          }
       }
-      result = astAppendString( result, &reslen, parts[ ipart ] );
+      result = astAppendString( result, &reslen, "%s", parts[ ipart ] );
 
 /* Free resources. */
       if( newsubs && newsubs != (char **) subs ) {
diff -up ast-8.0.1/object.c.format ast-8.0.1/object.c
--- ast-8.0.1/object.c.format	2014-10-17 02:04:56.000000000 -0600
+++ ast-8.0.1/object.c	2014-10-18 19:29:38.547113096 -0600
@@ -3057,13 +3057,9 @@ static void ToStringSink( const char *te
    the length of the currently allocated memory. */
    data = astChannelData;
 
-/* Append the supplied text to the end of the string, and update the
-   string length. */
-   data->ptr = astAppendString( data->ptr, &(data->len), text );
-
-/* Append a newline character to the end of the string, and update the
-   string length. */
-   data->ptr = astAppendString( data->ptr, &(data->len), "\n" );
+/* Append the supplied text to the end of the string plus newline character,
+    and update the string length. */
+   data->ptr = astAppendString( data->ptr, &(data->len), "%s\n", text );
 }
 
 void astSet_( void *this_void, const char *settings, int *status, ... ) {
diff -up ast-8.0.1/region.c.format ast-8.0.1/region.c
--- ast-8.0.1/region.c.format	2014-10-17 02:04:56.000000000 -0600
+++ ast-8.0.1/region.c	2014-10-18 19:36:52.433619743 -0600
@@ -10154,7 +10154,6 @@ f        The global status.
 /* Local Variables: */
    AstPointSet *ps;           /* PointSet holding mesh */
    char *buffer = NULL;       /* Buffer for line output text */
-   char buf[ 40 ];            /* Buffer for floating poitn value */
    double **ptr;              /* Pointers to the mesh data */
    int i;                     /* Axis index */
    int j;                     /* Position index */
@@ -10196,13 +10195,12 @@ f        The global status.
 /* Otherwise, if required, append the formatted value to the end of the
    buffer. */
                } else if( format ){
-                  buffer = astAppendString( buffer, &nc,
+                  buffer = astAppendString( buffer, &nc, "%s",
                                          astFormat( this, i, ptr[ i ][ j ] ) );
 
 /* Otherwise, append the floating point value to the end of the buffer. */
                } else {
-                  sprintf( buf, "%g", ptr[ i ][ j ] );
-                  buffer = astAppendString( buffer, &nc, buf );
+                  buffer = astAppendString( buffer, &nc, "%g", ptr[ i ][ j ] );
                }
 /* Add a separating tab to the end of the buffer. */
                buffer = astAppendString( buffer, &nc, "\t" );
diff -up ast-8.0.1/stcschan.c.format ast-8.0.1/stcschan.c
--- ast-8.0.1/stcschan.c.format	2014-10-17 02:04:56.000000000 -0600
+++ ast-8.0.1/stcschan.c	2014-10-18 19:45:42.432028995 -0600
@@ -463,7 +463,7 @@ static char *AddItem( AstStcsChan *this,
             result = astAppendString( result, nc, "   " );
             *crem = linelen - 3;
          }
-         result = astAppendString( result, nc, prefix );
+         result = astAppendString( result, nc, "%s", prefix );
          *crem -= len;
       }
 
@@ -494,7 +494,7 @@ static char *AddItem( AstStcsChan *this,
          }
 
 /* Add the property value to the returned buffer. */
-         result = astAppendString( result, nc, word );
+         result = astAppendString( result, nc, "%s", word );
 
 /* Add a traling space to the returned buffer, if there is room. */
          if( !linelen || *crem > 0 ) {
@@ -785,12 +785,9 @@ static char *ContextFragment( WordContex
    for( i = 0; i < NEWORD; i++ ) {
       if( con->words[ j ] ) {
 
-/* Append this word to the buffer, extending the buffer size as
-   necessary. */
-         *buf = astAppendString( *buf, &nc, con->words[ j ] );
-
-/* Append a trailingh space. */
-         *buf = astAppendString( *buf, &nc, " " );
+/* Append this word plus trailing space to the buffer, extending the buffer
+   size as necessary. */
+         *buf = astAppendString( *buf, &nc, "%s ", con->words[ j ] );
       }
 
 /* Increment the index of the next word to use in the cyclic list. Wrap
@@ -1444,8 +1441,7 @@ static int GetRegionProps( AstStcsChan *
          if( centre[ i ] != AST__BAD ) {
             GetFmt( "CENTRE", spprops, i, defdigs, fmt, status );
             (void) sprintf( buf, fmt, scale*centre[ i ] );
-            prop = astAppendString( prop, &nc, buf );
-            prop = astAppendString( prop, &nc, " " );
+            prop = astAppendString( prop, &nc, "%s ", buf );
 
          } else {
             ok = 0;
@@ -1493,8 +1489,7 @@ static int GetRegionProps( AstStcsChan *
          } else {
             GetFmt( "LOLIMIT", spprops, i, defdigs, fmt, status );
             (void) sprintf( buf, fmt, scale*lbnd[ i ] );
-            prop = astAppendString( prop, &nc, buf );
-            prop = astAppendString( prop, &nc, " " );
+            prop = astAppendString( prop, &nc, "%s ", buf );
          }
       }
 
@@ -1514,8 +1509,7 @@ static int GetRegionProps( AstStcsChan *
          } else {
             GetFmt( "HILIMIT", spprops, i, defdigs, fmt, status );
             (void) sprintf( buf, fmt, scale*ubnd[ i ] );
-            prop = astAppendString( prop, &nc, buf );
-            prop = astAppendString( prop, &nc, " " );
+            prop = astAppendString( prop, &nc, " %s", buf );
          }
       }
 
@@ -1539,8 +1533,7 @@ static int GetRegionProps( AstStcsChan *
          if( centre[ i ] != AST__BAD ) {
             GetFmt( "CENTRE", spprops, i, defdigs, fmt, status );
             (void) sprintf( buf, fmt, scale*centre[ i ] );
-            prop = astAppendString( prop, &nc, buf );
-            prop = astAppendString( prop, &nc, " " );
+            prop = astAppendString( prop, &nc, "%s ", buf );
 
          } else {
             ok = 0;
@@ -1603,8 +1596,7 @@ static int GetRegionProps( AstStcsChan *
          for( i = 0; i < nspace; i++ ) {
             if( *p != AST__BAD ) {
                (void) sprintf( buf, fmt, scale*(*p) );
-               prop = astAppendString( prop, &nc, buf );
-               prop = astAppendString( prop, &nc, " " );
+               prop = astAppendString( prop, &nc, "%s ", buf );
                p += np;
             } else {
                astAddWarning( this, 1, "The supplied Polygon contains "
@@ -1647,8 +1639,7 @@ static int GetRegionProps( AstStcsChan *
             if( centre[ i ] != AST__BAD ) {
                GetFmt( "POSITION", spprops, i, defdigs, fmt, status );
                (void) sprintf( buf, fmt, scale*centre[ i ] );
-               prop = astAppendString( prop, &nc, buf );
-               prop = astAppendString( prop, &nc, " " );
+               prop = astAppendString( prop, &nc, "%s ", buf );
 
             } else {
                astAddWarning( this, 1, "The supplied PointList contains "
@@ -3963,7 +3954,7 @@ static AstKeyMap *ReadProps( AstStcsChan
 
 /* Save the current word as the start of the START value. */
          nc = 0;
-         prop = astAppendString( prop, &nc, word );
+         prop = astAppendString( prop, &nc, "%s", word );
 
 /* If the current word is "JD" or "MJD", the following word should be
    numerical. */
@@ -3979,8 +3970,7 @@ static AstKeyMap *ReadProps( AstStcsChan
 
 /* Append the second word to the first word. */
             } else {
-               prop = astAppendString( prop, &nc, " " );
-               prop = astAppendString( prop, &nc, word );
+               prop = astAppendString( prop, &nc, " %s", word );
             }
 
 /* Convert JD to MJD if required. */
@@ -4019,7 +4009,7 @@ static AstKeyMap *ReadProps( AstStcsChan
 
 /* Save the current word as the start of the STOP value. */
          nc = 0;
-         prop = astAppendString( prop, &nc, word );
+         prop = astAppendString( prop, &nc, "%s", word );
 
 /* If the current word is "JD" or "MJD", the following word should be
    numerical. */
@@ -4035,8 +4025,7 @@ static AstKeyMap *ReadProps( AstStcsChan
 
 /* Append the second word to the first word. */
             } else {
-               prop = astAppendString( prop, &nc, " " );
-               prop = astAppendString( prop, &nc, word );
+               prop = astAppendString( prop, &nc, " %s", word );
             }
 
 /* Convert JD to MJD if required. */
@@ -4081,7 +4070,7 @@ static AstKeyMap *ReadProps( AstStcsChan
 
 /* Save the current word as the start of the TIME value. */
          nc = 0;
-         prop = astAppendString( prop, &nc, word );
+         prop = astAppendString( prop, &nc, "%s", word );
 
 /* If the current word is "JD" or "MJD", the following word should be
    numerical. */
@@ -4097,8 +4086,7 @@ static AstKeyMap *ReadProps( AstStcsChan
 
 /* Append the second word to the first word. */
             } else {
-               prop = astAppendString( prop, &nc, " " );
-               prop = astAppendString( prop, &nc, word );
+               prop = astAppendString( prop, &nc, " %s", word );
             }
 
 /* Convert JD to MJD if required. */
@@ -4276,8 +4264,7 @@ static AstKeyMap *ReadProps( AstStcsChan
                             "'%s' in an STC-S description: '%s'.", status,
                             word, ContextFragment( &con, &fbuf, status ) );
                }
-               prop = astAppendString( prop, &nc, word );
-               prop = astAppendString( prop, &nc, " " );
+               prop = astAppendString( prop, &nc, "%s ", word );
                word = GetNextWord( this, &con, status );
             }
 
@@ -4401,8 +4388,7 @@ static AstKeyMap *ReadProps( AstStcsChan
                                           !strcmp( word, "keV" ) ||
                                           !strcmp( word, "MeV" ) ) ) {
 
-               prop = astAppendString( prop, &nc, word );
-               prop = astAppendString( prop, &nc, " " );
+               prop = astAppendString( prop, &nc, "%s ", word );
                nunit++;
                word = GetNextWord( this, &con, status );
             }
@@ -4453,8 +4439,7 @@ static AstKeyMap *ReadProps( AstStcsChan
             while( value != AST__BAD ) {
                if( nval < MAXVAL ) {
                   val[ nval++ ] = value;
-                  prop = astAppendString( prop, &nc, word );
-                  prop = astAppendString( prop, &nc, " " );
+                  prop = astAppendString( prop, &nc, "%s ", word );
                   word = GetNextWord( this, &con, status );
                   value = astChr2Double( word );
                } else {
@@ -4509,8 +4494,7 @@ static AstKeyMap *ReadProps( AstStcsChan
             while( value != AST__BAD ) {
                if( nval < MAXVAL ) {
                   val[ nval++ ] = value;
-                  prop = astAppendString( prop, &nc, word );
-                  prop = astAppendString( prop, &nc, " " );
+                  prop = astAppendString( prop, &nc, "%s ", word );
                   word = GetNextWord( this, &con, status );
                   value = astChr2Double( word );
                } else {
@@ -4565,8 +4549,7 @@ static AstKeyMap *ReadProps( AstStcsChan
             while( value != AST__BAD ) {
                if( nval < MAXVAL ) {
                   val[ nval++ ] = value;
-                  prop = astAppendString( prop, &nc, word );
-                  prop = astAppendString( prop, &nc, " " );
+                  prop = astAppendString( prop, &nc, "%s ", word );
                   word = GetNextWord( this, &con, status );
                   value = astChr2Double( word );
                } else {
@@ -4621,8 +4604,7 @@ static AstKeyMap *ReadProps( AstStcsChan
             while( value != AST__BAD ) {
                if( nval < MAXVAL ) {
                   val[ nval++ ] = value;
-                  prop = astAppendString( prop, &nc, word );
-                  prop = astAppendString( prop, &nc, " " );
+                  prop = astAppendString( prop, &nc, "%s ", word );
                   word = GetNextWord( this, &con, status );
                   value = astChr2Double( word );
                } else {
@@ -4804,8 +4786,7 @@ static const char *ReadSpaceArgs( AstStc
                    "'%s' in an STC-S description: '%s'.", status, word,
                    ContextFragment( con, &fbuf, status ) );
          }
-         prop = astAppendString( prop, &nc, word );
-         prop = astAppendString( prop, &nc, " " );
+         prop = astAppendString( prop, &nc, "%s ", word );
          word = GetNextWord( this, con, status );
       }
 
@@ -4824,8 +4805,7 @@ static const char *ReadSpaceArgs( AstStc
                    "'%s' in an STC-S description: '%s'.", status, word,
                    ContextFragment( con, &fbuf, status ) );
          }
-         prop = astAppendString( prop, &nc, word );
-         prop = astAppendString( prop, &nc, " " );
+         prop = astAppendString( prop, &nc, "%s ", word );
          word = GetNextWord( this, con, status );
       }
 
@@ -4856,8 +4836,7 @@ static const char *ReadSpaceArgs( AstStc
                    "'%s' in an STC-S description: '%s'.", status, word,
                    ContextFragment( con, &fbuf, status ) );
          }
-         prop = astAppendString( prop, &nc, word );
-         prop = astAppendString( prop, &nc, " " );
+         prop = astAppendString( prop, &nc, "%s ", word );
          word = GetNextWord( this, con, status );
       }
 
@@ -4897,8 +4876,7 @@ static const char *ReadSpaceArgs( AstStc
                    "'%s' in an STC-S description: '%s'.", status, word,
                    ContextFragment( con, &fbuf, status ) );
          }
-         prop = astAppendString( prop, &nc, word );
-         prop = astAppendString( prop, &nc, " " );
+         prop = astAppendString( prop, &nc, "%s ", word );
          word = GetNextWord( this, con, status );
       }
 
@@ -4964,8 +4942,7 @@ static const char *ReadSpaceArgs( AstStc
                       "'%s' in an STC-S description: '%s'.", status,
                       word, ContextFragment( con, &fbuf, status ) );
          }
-         prop = astAppendString( prop, &nc, word );
-         prop = astAppendString( prop, &nc, " " );
+         prop = astAppendString( prop, &nc, "%s ", word );
          word = GetNextWord( this, con, status );
       }
 
@@ -4984,8 +4961,7 @@ static const char *ReadSpaceArgs( AstStc
                       "'%s' in an STC-S description: '%s'.", status,
                       word, ContextFragment( con, &fbuf, status ) );
          }
-         prop = astAppendString( prop, &nc, word );
-         prop = astAppendString( prop, &nc, " " );
+         prop = astAppendString( prop, &nc, "%s ", word );
          word = GetNextWord( this, con, status );
       }
 
@@ -5015,8 +4991,7 @@ static const char *ReadSpaceArgs( AstStc
             } else {
                *p = val;
             }
-            prop = astAppendString( prop, &nc, word );
-            prop = astAppendString( prop, &nc, " " );
+            prop = astAppendString( prop, &nc, "%s ", word );
             word = GetNextWord( this, con, status );
          }
 
@@ -5039,8 +5014,7 @@ static const char *ReadSpaceArgs( AstStc
                   } else {
                      *p = val;
                   }
-                  prop = astAppendString( prop, &nc, word );
-                  prop = astAppendString( prop, &nc, " " );
+                  prop = astAppendString( prop, &nc, "%s ", word );
                   word = GetNextWord( this, con, status );
                   val = astChr2Double( word );
                }
@@ -5081,8 +5055,7 @@ static const char *ReadSpaceArgs( AstStc
                       "'%s' in an STC-S description: '%s'.", status,
                       word, ContextFragment( con, &fbuf, status ) );
          }
-         prop = astAppendString( prop, &nc, word );
-         prop = astAppendString( prop, &nc, " " );
+         prop = astAppendString( prop, &nc, "%s ", word );
          word = GetNextWord( this, con, status );
       }
 
@@ -6897,8 +6870,7 @@ static int WriteRegion( AstStcsChan *thi
                      ok = 0;
                      break;
                   }
-                  prop = astAppendString( prop, &nc, unit );
-                  prop = astAppendString( prop, &nc, " " );
+                  prop = astAppendString( prop, &nc, "%s ", unit );
                }
 
 /* Remove the trailing space, and store the property value in the KeyMap. */
@@ -7075,8 +7047,7 @@ static int WriteRegion( AstStcsChan *thi
 
                      GetFmt( "ERROR", spprops, i, defdigs, fmt, status );
                      (void) sprintf( buf, fmt, scale*error );
-                     prop = astAppendString( prop, &nc, buf );
-                     prop = astAppendString( prop, &nc, " " );
+                     prop = astAppendString( prop, &nc, "%s ", buf );
 
                   } else {
                      nc = 0;
diff -up ast-8.0.1/xml.c.format ast-8.0.1/xml.c
--- ast-8.0.1/xml.c.format	2014-10-17 02:04:56.000000000 -0600
+++ ast-8.0.1/xml.c	2014-10-18 20:01:17.384922858 -0600
@@ -750,7 +750,7 @@ static char *AppendLine( char *str1, int
    for( j = 0; j < ind; j++ ) temp = AppendChar( temp, nc, ' ', status );
 
 /* Append the supplied string. */
-   return astAppendString( temp, nc, str2 );
+   return astAppendString( temp, nc, "%s", str2 );
 }
 
 void astXmlAddAttr_( AstXmlElement *this, const char *name, const char *value,
@@ -3119,8 +3119,7 @@ static void CheckPrefName( char *name, c
 
 /* Check the string before the colon is a valid name. */
       temp = NULL;
-      temp = astAppendString( temp, &nc, noun );
-      temp = astAppendString( temp, &nc, " prefix" );
+      temp = astAppendString( temp, &nc, "%s prefix", noun );
       CheckName( name, temp, method, 0, status );
       temp = astFree( temp );
 
@@ -3990,7 +3989,7 @@ static const char *Format( AstXmlObject
 /* If this is an element... */
    if( this->type == AST__XMLELEM ) {
       temp = FormatTag( this, 1, status );
-      result = astAppendString( result, &nc, temp );
+      result = astAppendString( result, &nc, "%s", temp );
       temp = astFree( (void *) temp );
 
       elem = (AstXmlElement *) this;
@@ -4012,7 +4011,7 @@ static const char *Format( AstXmlObject
                      result = AppendLine( result, &nc, temp,
                                           ( (ind > -1) ? ind + IND_INC : -1 ), status );
                   } else {
-                     result = astAppendString( result, &nc, temp );
+                     result = astAppendString( result, &nc, "%s", temp );
                   }
                   temp = astFree( (void *) temp );
                }
@@ -4024,7 +4023,7 @@ static const char *Format( AstXmlObject
          if( ind > -1 ) {
             result = AppendLine( result, &nc, temp, ind, status );
          } else {
-            result = astAppendString( result, &nc, temp );
+            result = astAppendString( result, &nc, "%s", temp );
          }
          temp = astFree( (void *) temp );
 
@@ -4035,27 +4034,23 @@ static const char *Format( AstXmlObject
       attrib = (AstXmlAttribute *) this;
 
       if( attrib->prefix ) {
-         result = astAppendString( result, &nc, attrib->prefix );
-         result = astAppendString( result, &nc, ":" );
+         result = astAppendString( result, &nc, "%s:", attrib->prefix );
       }
 
       temp = AddEscapes( attrib->value, status );
-      result = astAppendString( result, &nc, attrib->name );
-      result = astAppendString( result, &nc, "=\"" );
-      result = astAppendString( result, &nc, temp );
-      result = astAppendString( result, &nc, "\"" );
+      result = astAppendString( result, &nc, "%s=\"%s\"", attrib->name, temp );
       temp = astFree( (void *) temp );
 
    } else if( type == AST__XMLWHITE ){
       white = (AstXmlWhite *) this;
       temp = AddEscapes( white->text, status );
-      result = astAppendString( result, &nc, temp );
+      result = astAppendString( result, &nc, "%s", temp );
       temp = astFree( (void *) temp );
 
    } else if( type == AST__XMLBLACK ){
       black = (AstXmlBlack *) this;
       temp = AddEscapes( black->text, status );
-      result = astAppendString( result, &nc, temp );
+      result = astAppendString( result, &nc, "%s", temp );
       temp = astFree( (void *) temp );
 
    } else if( type == AST__XMLCDATA ||
@@ -4065,20 +4060,16 @@ static const char *Format( AstXmlObject
               type == AST__XMLDTD ){
 
       temp = FormatTag( this, 1, status );
-      result = astAppendString( result, &nc, temp );
+      result = astAppendString( result, &nc, "%s", temp );
       temp = astFree( (void *) temp );
 
    } else if( type == AST__XMLNAME ){
       ns = (AstXmlNamespace *) this;
-      result = astAppendString( result, &nc, "xmlns:" );
-      result = astAppendString( result, &nc, ns->prefix );
-      result = astAppendString( result, &nc, "=\"" );
-      result = astAppendString( result, &nc, ns->uri );
-      result = astAppendString( result, &nc, "\"" );
+      result = astAppendString( result, &nc, "xmlns:%s=\"%s\"", ns->prefix, ns->uri );
 
    } else if( type == AST__XMLPRO ){
       pro = (AstXmlPrologue *) this;
-      result = astAppendString( result, &nc,
+      result = astAppendString( result, &nc, "%s",
                              Format( (AstXmlObject *) pro->xmldecl, ind, status ) );
 
 /* Append all the miscalleneous items before the DTD. */
@@ -4088,7 +4079,7 @@ static const char *Format( AstXmlObject
             if( ind > -1 ) {
                result = AppendLine( result, &nc, temp, ind, status );
             } else {
-               result = astAppendString( result, &nc, temp );
+               result = astAppendString( result, &nc, "%s", temp );
             }
             temp = astFree( (void *) temp );
          }
@@ -4100,7 +4091,7 @@ static const char *Format( AstXmlObject
          if( ind > -1 ) {
             result = AppendLine( result, &nc, temp, ind, status );
          } else {
-            result = astAppendString( result, &nc, temp );
+            result = astAppendString( result, &nc, "%s", temp );
          }
          temp = astFree( (void *) temp );
       }
@@ -4112,7 +4103,7 @@ static const char *Format( AstXmlObject
             if( ind > -1 ) {
                result = AppendLine( result, &nc, temp, ind, status );
             } else {
-               result = astAppendString( result, &nc, temp );
+               result = astAppendString( result, &nc, "%s", temp );
             }
             temp = astFree( (void *) temp );
          }
@@ -4122,7 +4113,7 @@ static const char *Format( AstXmlObject
       doc = (AstXmlDocument *) this;
 
 /* Format the prologue. */
-      result = astAppendString( result, &nc,
+      result = astAppendString( result, &nc, "%s",
                              Format( (AstXmlObject *) doc->prolog, ind, status ) );
 
 /* Append the root element. */
@@ -4131,7 +4122,7 @@ static const char *Format( AstXmlObject
          if( ind > -1 ) {
             result = AppendLine( result, &nc, temp, ind, status );
          } else {
-            result = astAppendString( result, &nc, temp );
+            result = astAppendString( result, &nc, "%s", temp );
          }
          temp = astFree( (void *) temp );
       }
@@ -4143,7 +4134,7 @@ static const char *Format( AstXmlObject
             if( ind > -1 ) {
                result = AppendLine( result, &nc, temp, ind, status );
             } else {
-               result = astAppendString( result, &nc, temp );
+               result = astAppendString( result, &nc, "%s", temp );
             }
             temp = astFree( (void *) temp );
          }
@@ -4233,22 +4224,19 @@ static char *FormatTag( AstXmlObject *th
       if( opening ) {
          result = astAppendString( result, &nc, "<" );
          if( elem->prefix ) {
-            result = astAppendString( result, &nc, elem->prefix );
-            result = astAppendString( result, &nc, ":" );
+            result = astAppendString( result, &nc, "%s:", elem->prefix );
          }
-         result = astAppendString( result, &nc, elem->name );
+         result = astAppendString( result, &nc, "%s", elem->name );
 
          if( elem->defns ) {
-            result = astAppendString( result, &nc, " xmlns=\"" );
-            result = astAppendString( result, &nc, elem->defns );
-            result = astAppendString( result, &nc, "\"" );
+            result = astAppendString( result, &nc, " xmlns=\"%s\"", elem->defns );
          }
 
          for( i = 0; i < elem->nnspref; i++ ) {
             temp = Format( (AstXmlObject *) elem->nsprefs[ i ], -1, status );
             if( temp ) {
                result = AppendChar( result, &nc, ' ', status );
-               result = astAppendString( result, &nc, temp );
+               result = astAppendString( result, &nc, "%s", temp );
                temp = astFree( (void *) temp );
             }
          }
@@ -4257,7 +4245,7 @@ static char *FormatTag( AstXmlObject *th
             temp = Format( (AstXmlObject *) elem->attrs[ i ], -1, status );
             if( temp ){
                result = AppendChar( result, &nc, ' ', status );
-               result = astAppendString( result, &nc, temp );
+               result = astAppendString( result, &nc, "%s", temp );
                temp = astFree( (void *) temp );
             }
          }
@@ -4268,26 +4256,20 @@ static char *FormatTag( AstXmlObject *th
       } else if( elem->nitem > 0 ) {
          result = astAppendString( result, &nc, "</" );
          if( elem->prefix ) {
-            result = astAppendString( result, &nc, elem->prefix );
-            result = astAppendString( result, &nc, ":" );
+            result = astAppendString( result, &nc, "%s:", elem->prefix );
          }
-         result = astAppendString( result, &nc, elem->name );
-         result = astAppendString( result, &nc, ">" );
+         result = astAppendString( result, &nc, "%s>", elem->name );
       }
 
    } else if( type == AST__XMLDTD ){
       dtd = (AstXmlDTDec *) this;
       if( opening && dtd->name && dtd->name[0] ) {
-         result = astAppendString( result, &nc, "<!DOCTYPE " );
-         result = astAppendString( result, &nc, dtd->name );
+         result = astAppendString( result, &nc, "<!DOCTYPE %s", dtd->name );
          if( dtd->external && dtd->external[ 0 ] ) {
-            result = astAppendString( result, &nc, " " );
-            result = astAppendString( result, &nc, dtd->external );
+            result = astAppendString( result, &nc, "%s ", dtd->external );
          }
          if( dtd->internal && dtd->internal[ 0 ] ) {
-            result = astAppendString( result, &nc, " [" );
-            result = astAppendString( result, &nc, dtd->internal );
-            result = astAppendString( result, &nc, "]" );
+            result = astAppendString( result, &nc, " [%s]" , dtd->internal );
          }
          result = astAppendString( result, &nc, ">" );
       }
@@ -4295,27 +4277,21 @@ static char *FormatTag( AstXmlObject *th
    } else if( type == AST__XMLCDATA ){
       if( opening ) {
          cdata = (AstXmlCDataSection *) this;
-         result = astAppendString( result, &nc, "<![CDATA[" );
-         result = astAppendString( result, &nc, cdata->text );
-         result = astAppendString( result, &nc, "]]>" );
+         result = astAppendString( result, &nc, "<![CDATA[%s]]>", cdata->text );
       }
 
    } else if( type == AST__XMLCOM ){
       if( opening ) {
          com = (AstXmlComment *) this;
-         result = astAppendString( result, &nc, "<!--" );
-         result = astAppendString( result, &nc, com->text );
-         result = astAppendString( result, &nc, "-->" );
+         result = astAppendString( result, &nc, "<!--%s-->", com->text );
       }
 
    } else if( type == AST__XMLPI ){
       pi = (AstXmlPI *) this;
       if( opening ) {
-         result = astAppendString( result, &nc, "<?" );
-         result = astAppendString( result, &nc, pi->target );
+         result = astAppendString( result, &nc, "<?%s", pi->target );
          if( pi->text && pi->text[0] ) {
-            result = astAppendString( result, &nc, " " );
-            result = astAppendString( result, &nc, pi->text );
+            result = astAppendString( result, &nc, " %s", pi->text );
          }
          result = astAppendString( result, &nc, "?>" );
       }
@@ -4325,8 +4301,7 @@ static char *FormatTag( AstXmlObject *th
       if( opening && xmlpi->text && xmlpi->text[0] ) {
          result = astAppendString( result, &nc, "<?xml" );
          if( xmlpi->text && xmlpi->text[0] ) {
-            result = astAppendString( result, &nc, " " );
-            result = astAppendString( result, &nc, xmlpi->text );
+            result = astAppendString( result, &nc, " %s", xmlpi->text );
          }
          result = astAppendString( result, &nc, "?>" );
       }