Author: rfm
Date: Fri Mar  4 15:58:01 2016
New Revision: 39452

URL: http://svn.gna.org/viewcvs/gnustep?rev=39452&view=rev
Log:
fix 64bit issue

Modified:
    libs/base/trunk/ChangeLog
    libs/base/trunk/Headers/Foundation/NSCalendar.h
    libs/base/trunk/Source/NSCalendar.m

Modified: libs/base/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=39452&r1=39451&r2=39452&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog   (original)
+++ libs/base/trunk/ChangeLog   Fri Mar  4 15:58:01 2016
@@ -1,3 +1,7 @@
+2016-03-04  Richard Frith-Macdonald <[email protected]>
+
+       * Source/NSCalendar.m: Fix 64bit issue with undefined components.
+
 2016-03-01  Richard Frith-Macdonald <[email protected]>
 
        Modifications to last batch of changes in order to get the code to

Modified: libs/base/trunk/Headers/Foundation/NSCalendar.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Headers/Foundation/NSCalendar.h?rev=39452&r1=39451&r2=39452&view=diff
==============================================================================
--- libs/base/trunk/Headers/Foundation/NSCalendar.h     (original)
+++ libs/base/trunk/Headers/Foundation/NSCalendar.h     Fri Mar  4 15:58:01 2016
@@ -72,7 +72,8 @@
 
 enum
 {
-  NSUndefinedDateComponent = 0x7fffffff
+  NSDateComponentUndefined = NSIntegerMax,
+  NSUndefinedDateComponent = NSDateComponentUndefined
 };
 
 

Modified: libs/base/trunk/Source/NSCalendar.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSCalendar.m?rev=39452&r1=39451&r2=39452&view=diff
==============================================================================
--- libs/base/trunk/Source/NSCalendar.m (original)
+++ libs/base/trunk/Source/NSCalendar.m Fri Mar  4 15:58:01 2016
@@ -378,7 +378,7 @@
   cal, units, components, toDate, nsunit, setSel, uunit, err) \
 do \
   { \
-    if (units & nsunit) \
+    if (nsunit == (units & nsunit)) \
       { \
         int32_t uunit ## Diff \
           = ucal_getFieldDifference(cal, toDate, uunit, &err); \
@@ -474,7 +474,7 @@
                             options: (NSUInteger) opts
 {
 #if GS_USE_ICU == 1
-  int32_t amount;
+  NSInteger amount;
   UErrorCode err = U_ZERO_ERROR;
   UDate udate;
   
@@ -487,49 +487,49 @@
     ucal_roll (my->cal, c, n, &err); \
   else \
     ucal_add (my->cal, c, n, &err);
-  if ((amount = (int32_t)[comps era]) != NSUndefinedDateComponent)
-    {
-      _ADD_COMPONENT(UCAL_ERA, amount);
-    }
-  if ((amount = (int32_t)[comps year]) != NSUndefinedDateComponent)
-    {
-      _ADD_COMPONENT(UCAL_YEAR, amount);
-    }
-  if ((amount = (int32_t)[comps month]) != NSUndefinedDateComponent)
-    {
-      _ADD_COMPONENT(UCAL_MONTH, amount);
-    }
-  if ((amount = (int32_t)[comps day]) != NSUndefinedDateComponent)
-    {
-      _ADD_COMPONENT(UCAL_DAY_OF_MONTH, amount);
-    }
-  if ((amount = (int32_t)[comps hour]) != NSUndefinedDateComponent)
-    {
-      _ADD_COMPONENT(UCAL_HOUR_OF_DAY, amount);
-    }
-  if ((amount = (int32_t)[comps minute]) != NSUndefinedDateComponent)
-    {
-      _ADD_COMPONENT(UCAL_MINUTE, amount);
-    }
-  if ((amount = (int32_t)[comps second]) != NSUndefinedDateComponent)
-    {
-      _ADD_COMPONENT(UCAL_SECOND, amount);
-    }
-  if ((amount = (int32_t)[comps week]) != NSUndefinedDateComponent)
-    {
-      _ADD_COMPONENT(UCAL_WEEK_OF_YEAR, amount);
-    }
-  if ((amount = (int32_t)[comps weekday]) != NSUndefinedDateComponent)
-    {
-      _ADD_COMPONENT(UCAL_DAY_OF_WEEK, amount);
-    }
-  if ((amount = (int32_t)[comps weekOfMonth]) != NSUndefinedDateComponent)
-    {
-      _ADD_COMPONENT(UCAL_WEEK_OF_MONTH, amount);
-    }
-  if ((amount = (int32_t)[comps yearForWeekOfYear]) != 
NSUndefinedDateComponent)
-    {
-      _ADD_COMPONENT(UCAL_YEAR_WOY, amount);
+  if ((amount = [comps era]) != NSDateComponentUndefined)
+    {
+      _ADD_COMPONENT(UCAL_ERA, (int32_t)amount);
+    }
+  if ((amount = [comps year]) != NSDateComponentUndefined)
+    {
+      _ADD_COMPONENT(UCAL_YEAR, (int32_t)amount);
+    }
+  if ((amount = [comps month]) != NSDateComponentUndefined)
+    {
+      _ADD_COMPONENT(UCAL_MONTH, (int32_t)amount);
+    }
+  if ((amount = [comps day]) != NSDateComponentUndefined)
+    {
+      _ADD_COMPONENT(UCAL_DAY_OF_MONTH, (int32_t)amount);
+    }
+  if ((amount = [comps hour]) != NSDateComponentUndefined)
+    {
+      _ADD_COMPONENT(UCAL_HOUR_OF_DAY, (int32_t)amount);
+    }
+  if ((amount = [comps minute]) != NSDateComponentUndefined)
+    {
+      _ADD_COMPONENT(UCAL_MINUTE, (int32_t)amount);
+    }
+  if ((amount = [comps second]) != NSDateComponentUndefined)
+    {
+      _ADD_COMPONENT(UCAL_SECOND, (int32_t)amount);
+    }
+  if ((amount = [comps week]) != NSDateComponentUndefined)
+    {
+      _ADD_COMPONENT(UCAL_WEEK_OF_YEAR, (int32_t)amount);
+    }
+  if ((amount = [comps weekday]) != NSDateComponentUndefined)
+    {
+      _ADD_COMPONENT(UCAL_DAY_OF_WEEK, (int32_t)amount);
+    }
+  if ((amount = [comps weekOfMonth]) != NSDateComponentUndefined)
+    {
+      _ADD_COMPONENT(UCAL_WEEK_OF_MONTH, (int32_t)amount);
+    }
+  if ((amount = [comps yearForWeekOfYear]) != NSDateComponentUndefined)
+    {
+      _ADD_COMPONENT(UCAL_YEAR_WOY, (int32_t)amount);
     }
 #undef _ADD_COMPONENT
   
@@ -546,56 +546,56 @@
 - (NSDate *) dateFromComponents: (NSDateComponents *) comps
 {
 #if GS_USE_ICU == 1
-  int32_t amount;
+  NSInteger amount;
   UDate udate;
   UErrorCode err = U_ZERO_ERROR;
   
   [self _resetCalendar];
   ucal_clear (my->cal);
   
-  if ((amount = (int32_t)[comps era]) != NSUndefinedDateComponent)
-    {
-      ucal_set (my->cal, UCAL_ERA, amount);
-    }
-  if ((amount = (int32_t)[comps year]) != NSUndefinedDateComponent)
-    {
-      ucal_set (my->cal, UCAL_YEAR, amount);
-    }
-  if ((amount = (int32_t)[comps month]) != NSUndefinedDateComponent)
+  if ((amount = [comps era]) != NSDateComponentUndefined)
+    {
+      ucal_set (my->cal, UCAL_ERA, (int32_t)amount);
+    }
+  if ((amount = [comps year]) != NSDateComponentUndefined)
+    {
+      ucal_set (my->cal, UCAL_YEAR, (int32_t)amount);
+    }
+  if ((amount = [comps month]) != NSDateComponentUndefined)
     {
       ucal_set (my->cal, UCAL_MONTH, amount-1);
     }
-  if ((amount = (int32_t)[comps day]) != NSUndefinedDateComponent)
-    {
-      ucal_set (my->cal, UCAL_DAY_OF_MONTH, amount);
-    }
-  if ((amount = (int32_t)[comps hour]) != NSUndefinedDateComponent)
-    {
-      ucal_set (my->cal, UCAL_HOUR_OF_DAY, amount);
-    }
-  if ((amount = (int32_t)[comps minute]) != NSUndefinedDateComponent)
-    {
-      ucal_set (my->cal, UCAL_MINUTE, amount);
-    }
-  if ((amount = (int32_t)[comps second]) != NSUndefinedDateComponent)
-    {
-      ucal_set (my->cal, UCAL_SECOND, amount);
-    }
-  if ((amount = (int32_t)[comps week]) != NSUndefinedDateComponent)
-    {
-      ucal_set (my->cal, UCAL_WEEK_OF_YEAR, amount);
-    }
-  if ((amount = (int32_t)[comps weekday]) != NSUndefinedDateComponent)
-    {
-      ucal_set (my->cal, UCAL_DAY_OF_WEEK, amount);
-    }
-  if ((amount = (int32_t)[comps weekOfMonth]) != NSUndefinedDateComponent)
-    {
-      ucal_set (my->cal, UCAL_WEEK_OF_MONTH, amount);
-    }
-  if ((amount = (int32_t)[comps yearForWeekOfYear]) != 
NSUndefinedDateComponent)
-    {
-      ucal_set (my->cal, UCAL_YEAR_WOY, amount);
+  if ((amount = [comps day]) != NSDateComponentUndefined)
+    {
+      ucal_set (my->cal, UCAL_DAY_OF_MONTH, (int32_t)amount);
+    }
+  if ((amount = [comps hour]) != NSDateComponentUndefined)
+    {
+      ucal_set (my->cal, UCAL_HOUR_OF_DAY, (int32_t)amount);
+    }
+  if ((amount = [comps minute]) != NSDateComponentUndefined)
+    {
+      ucal_set (my->cal, UCAL_MINUTE, (int32_t)amount);
+    }
+  if ((amount = [comps second]) != NSDateComponentUndefined)
+    {
+      ucal_set (my->cal, UCAL_SECOND, (int32_t)amount);
+    }
+  if ((amount = [comps week]) != NSDateComponentUndefined)
+    {
+      ucal_set (my->cal, UCAL_WEEK_OF_YEAR, (int32_t)amount);
+    }
+  if ((amount = [comps weekday]) != NSDateComponentUndefined)
+    {
+      ucal_set (my->cal, UCAL_DAY_OF_WEEK, (int32_t)amount);
+    }
+  if ((amount = [comps weekOfMonth]) != NSDateComponentUndefined)
+    {
+      ucal_set (my->cal, UCAL_WEEK_OF_MONTH, (int32_t)amount);
+    }
+  if ((amount = [comps yearForWeekOfYear]) != NSDateComponentUndefined)
+    {
+      ucal_set (my->cal, UCAL_YEAR_WOY, (int32_t)amount);
     }
   
   udate = ucal_getMillis (my->cal, &err);
@@ -860,19 +860,19 @@
       NSZoneCalloc([self zone], sizeof(DateComp), 1);
 #endif
 
-      my->era = NSUndefinedDateComponent;
-      my->year = NSUndefinedDateComponent;
-      my->month = NSUndefinedDateComponent;
-      my->day = NSUndefinedDateComponent;
-      my->hour = NSUndefinedDateComponent;
-      my->minute = NSUndefinedDateComponent;
-      my->second = NSUndefinedDateComponent;
-      my->week = NSUndefinedDateComponent;
-      my->weekday = NSUndefinedDateComponent;
-      my->weekdayOrdinal = NSUndefinedDateComponent;
-      my->quarter = NSUndefinedDateComponent;
-      my->weekOfMonth = NSUndefinedDateComponent;
-      my->yearForWeekOfYear = NSUndefinedDateComponent;
+      my->era = NSDateComponentUndefined;
+      my->year = NSDateComponentUndefined;
+      my->month = NSDateComponentUndefined;
+      my->day = NSDateComponentUndefined;
+      my->hour = NSDateComponentUndefined;
+      my->minute = NSDateComponentUndefined;
+      my->second = NSDateComponentUndefined;
+      my->week = NSDateComponentUndefined;
+      my->weekday = NSDateComponentUndefined;
+      my->weekdayOrdinal = NSDateComponentUndefined;
+      my->quarter = NSDateComponentUndefined;
+      my->weekOfMonth = NSDateComponentUndefined;
+      my->yearForWeekOfYear = NSDateComponentUndefined;
       my->cal = NULL;
       my->tz = NULL;
      } 


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to