* as/link/mcs51/lkarea.c (lnkarea2): handle absolute areas, restructured
[fw/sdcc] / device / lib / printf_large.c
index d684258b0ce54bb7109f0a3f205e02c9217ca0b1..7d42abc25f3b79692bebd9ad9dab5a953be01505 100644 (file)
@@ -53,6 +53,9 @@
 #ifdef tolower
 #undef tolower
 #endif
+#ifdef islower
+#undef islower
+#endif
 #ifdef isdigit
 #undef isdigit
 #endif
@@ -60,6 +63,7 @@
 //#define toupper(c) ((c)&=~0x20)
 #define toupper(c) ((c)&=0xDF)
 #define tolower(c) ((c)|=0x20)
+#define islower(c) ((unsigned char)c >= (unsigned char)'a' && (unsigned char)c <= (unsigned char)'z')
 #define isdigit(c) ((unsigned char)c >= (unsigned char)'0' && (unsigned char)c <= (unsigned char)'9')
 
 typedef union
@@ -207,6 +211,7 @@ output_float (float f, unsigned char reqWidth,
               pfn_outputchar output_char, void* p)
 {
   unsigned char charsOutputted = 0;
+  char fpBuffer[128];
 #else
 #define OUTPUT_FLOAT(F, W, D, L, Z, S, P)      output_float(F, W, D, L, Z, S, P)
 static void
@@ -214,11 +219,11 @@ output_float (float f, unsigned char reqWidth,
               signed char reqDecimals,
               BOOL left, BOOL zero, BOOL sign, BOOL space)
 {
+  xdata char fpBuffer[128];
 #endif //SDCC_STACK_AUTO
   BOOL negative = 0;
   unsigned long integerPart;
   float decimalPart;
-  char fpBuffer[128];
   char fpBI=0, fpBD;
   unsigned char minWidth, i;
 
@@ -467,11 +472,13 @@ get_conversion_spec:
         goto get_conversion_spec;
       }
 
-      lower_case = islower(c);
-      if (lower_case)
+      if (islower(c))
       {
         c = toupper(c);
+        lower_case = 1;
       }
+      else
+        lower_case = 0;
 
       switch( c )
       {
@@ -492,7 +499,11 @@ get_conversion_spec:
         goto get_conversion_spec;
 
       case 'C':
-        OUTPUT_CHAR( va_arg(ap,int), p );
+       if( char_argument )
+          c = va_arg(ap,char);
+        else
+          c = va_arg(ap,int);
+        OUTPUT_CHAR( c, p );
         break;
 
       case 'S':
@@ -521,9 +532,10 @@ get_conversion_spec:
           }
         }
 
-        while ( *PTR  && (decimals-- > 0))
+        while ( (c = *PTR)  && (decimals-- > 0))
         {
-          OUTPUT_CHAR( *PTR++, p );
+          OUTPUT_CHAR( c, p );
+          PTR++;
         }
 
         if ( left_justify && (length < width))