src/stdlib/SDL_string.c
changeset 12254 f1ac9de30ee1
parent 12253 2dbf011db466
child 12256 9f3949b8ec40
equal deleted inserted replaced
12253:2dbf011db466 12254:f1ac9de30ee1
  1359 } SDL_letter_case;
  1359 } SDL_letter_case;
  1360 
  1360 
  1361 typedef struct
  1361 typedef struct
  1362 {
  1362 {
  1363     SDL_bool left_justify; /* for now: ignored. */
  1363     SDL_bool left_justify; /* for now: ignored. */
  1364     SDL_bool force_sign;   /* for now: used only by float printer, ignored otherwise. */
  1364     SDL_bool force_sign;
  1365     SDL_bool force_type;   /* for now: used only by float printer, ignored otherwise. */
  1365     SDL_bool force_type;   /* for now: used only by float printer, ignored otherwise. */
  1366     SDL_bool pad_zeroes;
  1366     SDL_bool pad_zeroes;
  1367     SDL_letter_case force_case;
  1367     SDL_letter_case force_case;
  1368     int width;
  1368     int width;
  1369     int radix;
  1369     int radix;
  1451 }
  1451 }
  1452 
  1452 
  1453 static size_t
  1453 static size_t
  1454 SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
  1454 SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
  1455 {
  1455 {
  1456     char num[130];
  1456     char num[130], *p = num;
  1457 
  1457 
  1458     SDL_ltoa(value, num, info ? info->radix : 10);
  1458     if (info->force_sign && value >= 0L) {
       
  1459         *p++ = '+';
       
  1460     }
       
  1461 
       
  1462     SDL_ltoa(value, p, info ? info->radix : 10);
  1459     SDL_IntPrecisionAdjust(num, maxlen, info);
  1463     SDL_IntPrecisionAdjust(num, maxlen, info);
  1460     return SDL_PrintString(text, maxlen, info, num);
  1464     return SDL_PrintString(text, maxlen, info, num);
  1461 }
  1465 }
  1462 
  1466 
  1463 static size_t
  1467 static size_t
  1471 }
  1475 }
  1472 
  1476 
  1473 static size_t
  1477 static size_t
  1474 SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
  1478 SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
  1475 {
  1479 {
  1476     char num[130];
  1480     char num[130], *p = num;
  1477 
  1481 
  1478     SDL_lltoa(value, num, info ? info->radix : 10);
  1482     if (info->force_sign && value >= (Sint64)0) {
       
  1483         *p++ = '+';
       
  1484     }
       
  1485 
       
  1486     SDL_lltoa(value, p, info ? info->radix : 10);
  1479     SDL_IntPrecisionAdjust(num, maxlen, info);
  1487     SDL_IntPrecisionAdjust(num, maxlen, info);
  1480     return SDL_PrintString(text, maxlen, info, num);
  1488     return SDL_PrintString(text, maxlen, info, num);
  1481 }
  1489 }
  1482 
  1490 
  1483 static size_t
  1491 static size_t
  1735                     if (info.radix == 10) {
  1743                     if (info.radix == 10) {
  1736                         info.radix = 8;
  1744                         info.radix = 8;
  1737                     }
  1745                     }
  1738                     /* Fall through to unsigned handling */
  1746                     /* Fall through to unsigned handling */
  1739                 case 'u':
  1747                 case 'u':
       
  1748                     info.force_sign = SDL_FALSE;
  1740                     if (info.precision >= 0) {
  1749                     if (info.precision >= 0) {
  1741                         info.pad_zeroes = SDL_FALSE;
  1750                         info.pad_zeroes = SDL_FALSE;
  1742                     }
  1751                     }
  1743                     switch (inttype) {
  1752                     switch (inttype) {
  1744                     case DO_INT:
  1753                     case DO_INT: