Skip to content
This repository
Browse code

Fixed string formatting in a FMTAssertNotNil macro

  • Loading branch information...
commit 6f97e44c9dd6c8e2aeaf9d300b60755109faec1b 1 parent 7895dc9
Filip Krikava authored February 11, 2013

Showing 1 changed file with 19 additions and 24 deletions. Show diff stats Hide diff stats

  1. 43  ShiftIt/FMT/FMTDefines.h
43  ShiftIt/FMT/FMTDefines.h
@@ -58,39 +58,34 @@ static inline NSString* FMTStr(NSString *fmt, ...) {
58 58
 typedef void (^FMTDebugBlock)(void);
59 59
 static inline void FMTInDebugOnly(FMTDebugBlock block) {
60 60
 #ifndef NDEBUG
61  
-    block();
  61
+  block();
62 62
 #endif
63 63
 }
64 64
 
65 65
 #ifndef FMTAssert
66  
-
67  
-#if !defined(NS_BLOCK_ASSERTIONS)
68  
-
69  
-#define FMTAssert(condition, ...)                                       \
70  
-do {                                                                      \
71  
-if (!(condition)) {                                                     \
72  
-[[NSAssertionHandler currentHandler]                                  \
73  
-handleFailureInFunction:[NSString stringWithUTF8String:__PRETTY_FUNCTION__] \
74  
-file:[NSString stringWithUTF8String:__FILE__]  \
75  
-lineNumber:__LINE__                                  \
76  
-description:__VA_ARGS__];                             \
77  
-}                                                                       \
78  
-} while(0)
79  
-
80  
-#define FMTAssertNotNil(var) FMTAssert(var != nil, FMTStr(@"Variable %@ must not be nil", @#var));
81  
-
82  
-#else // !defined(NS_BLOCK_ASSERTIONS)
83  
-#define FMTAssert(condition, ...) do { } while (0)
84  
-#endif // !defined(NS_BLOCK_ASSERTIONS)
85  
-
  66
+  #if !defined(NS_BLOCK_ASSERTIONS)
  67
+    #define FMTAssert(condition, ...)                                       \
  68
+      do {                                                                      \
  69
+        if (!(condition)) {                                                     \
  70
+          [[NSAssertionHandler currentHandler]                                  \
  71
+              handleFailureInFunction:[NSString stringWithUTF8String:__PRETTY_FUNCTION__] \
  72
+                                 file:[NSString stringWithUTF8String:__FILE__]  \
  73
+                           lineNumber:__LINE__                                  \
  74
+                          description:__VA_ARGS__];                             \
  75
+        }                                                                       \
  76
+      } while(0)
  77
+  #else // !defined(NS_BLOCK_ASSERTIONS)
  78
+    #define FMTAssert(condition, ...) do { } while (0)
  79
+  #endif // !defined(NS_BLOCK_ASSERTIONS)
86 80
 #endif // FMTAssert
87 81
 
88 82
 #ifndef FMTFail
89  
-
90  
-#define FMTFail(...) FMTAssert(NO,##__VA_ARGS__)
91  
-
  83
+  #define FMTFail(...) FMTAssert(NO,##__VA_ARGS__)
92 84
 #endif // FMTFail
93 85
 
  86
+#ifndef FMTAssertNotNil
  87
+  #define FMTAssertNotNil(var) FMTAssert(var != nil, @"Variable %@ must not be nil", @#var);
  88
+#endif // FMTAssertNotNil
94 89
 
95 90
 /// This macro implements the various methods needed to make a safe singleton.
96 91
 ///

0 notes on commit 6f97e44

Please sign in to comment.
Something went wrong with that request. Please try again.