~ubuntu-branches/ubuntu/trusty/gnustep-base/trusty

« back to all changes in this revision

Viewing changes to Source/GSFormat.m

Tags: upstream-1.20.0
ImportĀ upstreamĀ versionĀ 1.20.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
   Boston, MA 02111 USA.
39
39
*/
40
40
 
41
 
#include "config.h"
 
41
#include "common.h"
42
42
 
43
 
/* We need to define _GNU_SOURCE on systems (SuSE) to get LONG_LONG_MAX.  */
44
 
#ifndef _GNU_SOURCE
45
 
#define _GNU_SOURCE
 
43
#if     !defined(LLONG_MAX)
 
44
#  if   defined(__LONG_LONG_MAX__)
 
45
#    define LLONG_MAX __LONG_LONG_MAX__
 
46
#    define LLONG_MIN   (-LLONG_MAX-1)
 
47
#    define ULLONG_MAX  (LLONG_MAX * 2ULL + 1)
 
48
#  else
 
49
#    error Neither LLONG_MAX nor __LONG_LONG_MAX__ found
 
50
#  endif
46
51
#endif
47
52
 
48
 
#ifdef HAVE_STDINT_H
49
 
#include <stdint.h>
 
53
#ifdef HAVE_MALLOC_H
 
54
#include <malloc.h>
50
55
#endif
51
56
#ifdef HAVE_ALLOCA_H
52
57
#include <alloca.h>
53
58
#endif
54
 
#include <limits.h>
55
59
 
56
60
#include <stdio.h>
57
61
#include <string.h>
58
62
 
59
 
#import "GNUstepBase/preface.h"
60
 
#import "Foundation/NSString.h"
61
63
#import "Foundation/NSArray.h"
62
64
#import "Foundation/NSCharacterSet.h"
63
65
#import "Foundation/NSException.h"
75
77
#import "Foundation/NSURL.h"
76
78
#import "Foundation/NSMapTable.h"
77
79
#import "Foundation/NSLock.h"
78
 
#import "Foundation/NSZone.h"
79
 
#import "Foundation/NSDebug.h"
80
80
#import "GNUstepBase/GSLocale.h"
81
81
 
82
82
#import "GSPrivate.h"
104
104
typedef unsigned long long uintmax_t;
105
105
#endif
106
106
 
107
 
/* BSD and Solaris have this */
108
 
#if defined(HANDLE_LLONG_MAX) && !defined(HANDLE_LONG_LONG_MAX)
109
 
#define LONG_LONG_MAX LLONG_MAX
110
 
#define LONG_LONG_MIN LLONG_MIN
111
 
#define ULONG_LONG_MAX ULLONG_MAX
112
 
#else
113
 
/* Darwin 1.0 CPP can't handle this */
114
 
#ifndef HANDLE_LONG_LONG_MAX
115
 
#undef LONG_LONG_MAX
116
 
#endif
117
 
#endif
118
 
 
119
 
#if     defined(HANDLE_LONG_LONG_MAX) && !defined(LONG_LONG_MAX)
120
 
#error handle_long_long_max defined without long_long_max being defined
121
 
#else
122
 
#if     defined(HANDLE_LLONG_MAX) && !defined(LONG_LONG_MAX)
123
 
#error handle_llong_max defined without llong_max being defined
124
 
#endif
125
 
#endif
126
 
 
127
 
 
128
 
#include "GNUstepBase/Unicode.h"
 
107
 
 
108
#import "GNUstepBase/Unicode.h"
129
109
 
130
110
struct printf_info
131
111
{
638
618
    case 'Z':
639
619
      /* ints are size_ts.  */
640
620
      NSCParameterAssert (sizeof (size_t) <= sizeof (unsigned long long int));
641
 
#if defined(LONG_LONG_MAX)
642
 
#if LONG_MAX != LONG_LONG_MAX
 
621
#if defined(LLONG_MAX)
 
622
#if LONG_MAX != LLONG_MAX
643
623
      spec->info.is_long_double = sizeof (size_t) > sizeof (unsigned long int);
644
624
#endif
645
625
#endif
647
627
      break;
648
628
    case 't':
649
629
      NSCParameterAssert (sizeof (ptrdiff_t) <= sizeof (long long int));
650
 
#if defined(LONG_LONG_MAX)
651
 
#if LONG_MAX != LONG_LONG_MAX
 
630
#if defined(LLONG_MAX)
 
631
#if LONG_MAX != LLONG_MAX
652
632
      spec->info.is_long_double = (sizeof (ptrdiff_t) > sizeof (long int));
653
633
#endif
654
634
#endif
656
636
      break;
657
637
    case 'j':
658
638
      NSCParameterAssert (sizeof (uintmax_t) <= sizeof (unsigned long long int));
659
 
#if defined(LONG_LONG_MAX)
660
 
#if LONG_MAX != LONG_LONG_MAX
 
639
#if defined(LLONG_MAX)
 
640
#if LONG_MAX != LLONG_MAX
661
641
      spec->info.is_long_double = (sizeof (uintmax_t)
662
642
                                   > sizeof (unsigned long int));
663
643
#endif
684
664
        case 'o':
685
665
        case 'X':
686
666
        case 'x':
687
 
#if defined(LONG_LONG_MAX)
688
 
#if LONG_MAX != LONG_LONG_MAX
 
667
#if defined(LLONG_MAX)
 
668
#if LONG_MAX != LLONG_MAX
689
669
          if (spec->info.is_long_double)
690
670
            spec->data_arg_type = PA_INT|PA_FLAG_LONG_LONG;
691
671
          else
775
755
/* For handling long_double and longlong we use the same flag.  If
776
756
   `long' and `long long' are effectively the same type define it to
777
757
   zero.  */
778
 
#if defined(LONG_LONG_MAX)
779
 
#if LONG_MAX == LONG_LONG_MAX
 
758
#if defined(LLONG_MAX)
 
759
#if LONG_MAX == LLONG_MAX
780
760
# define is_longlong 0
781
761
#else
782
762
# define is_longlong is_long_double
1116
1096
        int left = specs[nspecs_done].info.left;
1117
1097
        int showsign = specs[nspecs_done].info.showsign;
1118
1098
        int group = specs[nspecs_done].info.group;
1119
 
#if defined(LONG_LONG_MAX) && (LONG_MAX != LONG_LONG_MAX)
 
1099
#if defined(LLONG_MAX) && (LONG_MAX != LLONG_MAX)
1120
1100
        int is_long_double = specs[nspecs_done].info.is_long_double;
1121
1101
#endif
1122
1102
        int is_short = specs[nspecs_done].info.is_short;
1173
1153
            int string_malloced;
1174
1154
      do
1175
1155
        {
1176
 
          const void *ptr;
1177
 
          ptr = NOT_IN_JUMP_RANGE (spec) ? REF (form_unknown)
1178
 
            : step4_jumps[CHAR_CLASS (spec)];
 
1156
          void *ptr;
 
1157
          ptr = NOT_IN_JUMP_RANGE (spec) ? (void*)REF (form_unknown)
 
1158
            : (void*)step4_jumps[CHAR_CLASS (spec)];
1179
1159
          goto *ptr;
1180
1160
        }
1181
1161
      while (0);
1416
1396
            {
1417
1397
              int temp = width;
1418
1398
              width = prec;
1419
 
              PAD ('0');;
 
1399
              PAD ('0');
1420
1400
              width = temp;
1421
1401
            }
1422
1402