]> pd.if.org Git - pdclib/blobdiff - functions/_PDCLIB/print.c
Status review.
[pdclib] / functions / _PDCLIB / print.c
index 8d19fe57e856ad3c6c564f81b758de4157febba2..8f019796c757342a5610e29e6e92f575d01d3daa 100644 (file)
    i - pointer to number of characters already delivered in this call
    n - pointer to maximum number of characters to be delivered in this call
    s - the buffer into which the character shall be delivered
-   TODO: ref. fputs() for a better way to buffer handling
 */
 #define DELIVER( x ) \
 do { \
+    int character = x; \
     if ( status->i < status->n ) { \
         if ( status->stream != NULL ) \
-            putc( x, status->stream ); \
+            putc( character, status->stream ); \
         else \
-            status->s[status->i] = x; \
+            status->s[status->i] = character; \
     } \
     ++(status->i); \
 } while ( 0 )
@@ -498,7 +498,7 @@ const char * _PDCLIB_print( const char * spec, struct _PDCLIB_status_t * status
                 ++(status->current);
             }
         }
-        if ( status->i >= status->n )
+        if ( status->i >= status->n && status->n > 0 )
         {
             status->s[status->n - 1] = '\0';
         }