src/stdlib/SDL_string.c
changeset 7728 800313a3533d
parent 7503 701f4a25df89
child 8059 e70f5749f692
equal deleted inserted replaced
7727:627ce8499c81 7728:800313a3533d
  1291 {
  1291 {
  1292     return vsnprintf(text, maxlen, fmt, ap);
  1292     return vsnprintf(text, maxlen, fmt, ap);
  1293 }
  1293 }
  1294 #else
  1294 #else
  1295  /* FIXME: implement more of the format specifiers */
  1295  /* FIXME: implement more of the format specifiers */
       
  1296 typedef enum
       
  1297 {
       
  1298     SDL_CASE_NOCHANGE,
       
  1299     SDL_CASE_LOWER,
       
  1300     SDL_CASE_UPPER
       
  1301 } SDL_letter_case;
       
  1302 
  1296 typedef struct
  1303 typedef struct
  1297 {
  1304 {
  1298     SDL_bool left_justify;
  1305     SDL_bool left_justify;
  1299     SDL_bool force_sign;
  1306     SDL_bool force_sign;
  1300     SDL_bool force_type;
  1307     SDL_bool force_type;
  1301     SDL_bool pad_zeroes;
  1308     SDL_bool pad_zeroes;
  1302     SDL_bool do_lowercase;
  1309     SDL_letter_case force_case;
  1303     int width;
  1310     int width;
  1304     int radix;
  1311     int radix;
  1305     int precision;
  1312     int precision;
  1306 } SDL_FormatInfo;
  1313 } SDL_FormatInfo;
  1307 
  1314 
  1320         }
  1327         }
  1321     }
  1328     }
  1322 
  1329 
  1323     length += SDL_strlcpy(text, string, maxlen);
  1330     length += SDL_strlcpy(text, string, maxlen);
  1324 
  1331 
  1325     if (info && info->do_lowercase) {
  1332     if (info) {
  1326         SDL_strlwr(text);
  1333         if (info->force_case == SDL_CASE_LOWER) {
       
  1334             SDL_strlwr(text);
       
  1335         } else if (info->force_case == SDL_CASE_UPPER) {
       
  1336             SDL_strupr(text);
       
  1337         }
  1327     }
  1338     }
  1328     return length;
  1339     return length;
  1329 }
  1340 }
  1330 
  1341 
  1331 static size_t
  1342 static size_t
  1571                     }
  1582                     }
  1572                     done = SDL_TRUE;
  1583                     done = SDL_TRUE;
  1573                     break;
  1584                     break;
  1574                 case 'p':
  1585                 case 'p':
  1575                 case 'x':
  1586                 case 'x':
  1576                     info.do_lowercase = SDL_TRUE;
  1587                     info.force_case = SDL_CASE_LOWER;
  1577                     /* Fall through to 'X' handling */
  1588                     /* Fall through to 'X' handling */
  1578                 case 'X':
  1589                 case 'X':
       
  1590                     if (info.force_case == SDL_CASE_NOCHANGE) {
       
  1591                         info.force_case = SDL_CASE_UPPER;
       
  1592                     }
  1579                     if (info.radix == 10) {
  1593                     if (info.radix == 10) {
  1580                         info.radix = 16;
  1594                         info.radix = 16;
  1581                     }
  1595                     }
  1582                     if (*fmt == 'p') {
  1596                     if (*fmt == 'p') {
  1583                         inttype = DO_LONG;
  1597                         inttype = DO_LONG;