Procházet zdrojové kódy

cleanup the error header a bit by moving the printf-macros out
and remove the using std::string

David Kalnischkies před 16 roky
rodič
revize
8f3d83eeae
2 změnil soubory, kde provedl 16 přidání a 23 odebrání
  1. 7 23
      apt-pkg/contrib/error.h
  2. 9 0
      apt-pkg/contrib/macros.h

+ 7 - 23
apt-pkg/contrib/error.h

@@ -40,28 +40,15 @@
 #ifndef PKGLIB_ERROR_H
 #ifndef PKGLIB_ERROR_H
 #define PKGLIB_ERROR_H
 #define PKGLIB_ERROR_H
 
 
-
-
-#ifdef __GNUG__
-// Methods have a hidden this parameter that is visible to this attribute
-#define APT_MFORMAT1 __attribute__ ((format (printf, 2, 3)))
-#define APT_MFORMAT2 __attribute__ ((format (printf, 3, 4)))
-#else
-#define APT_MFORMAT1
-#define APT_MFORMAT2    
-#endif    
-    
-#include <string>
-
 #include <apt-pkg/macros.h>
 #include <apt-pkg/macros.h>
 
 
-using std::string;
+#include <string>
 
 
 class GlobalError
 class GlobalError
 {
 {
    struct Item
    struct Item
    {
    {
-      string Text;
+      std::string Text;
       bool Error;
       bool Error;
       Item *Next;
       Item *Next;
    };
    };
@@ -73,18 +60,18 @@ class GlobalError
    public:
    public:
 
 
    // Call to generate an error from a library call.
    // Call to generate an error from a library call.
-   bool Errno(const char *Function,const char *Description,...) APT_MFORMAT2 __cold;
-   bool WarningE(const char *Function,const char *Description,...) APT_MFORMAT2 __cold;
+   bool Errno(const char *Function,const char *Description,...) __like_printf_2 __cold;
+   bool WarningE(const char *Function,const char *Description,...) __like_printf_2 __cold;
 
 
    /* A warning should be considered less severe than an error, and may be
    /* A warning should be considered less severe than an error, and may be
       ignored by the client. */
       ignored by the client. */
-   bool Error(const char *Description,...) APT_MFORMAT1 __cold;
-   bool Warning(const char *Description,...) APT_MFORMAT1 __cold;
+   bool Error(const char *Description,...) __like_printf_1 __cold;
+   bool Warning(const char *Description,...) __like_printf_1 __cold;
 
 
    // Simple accessors
    // Simple accessors
    inline bool PendingError() {return PendingFlag;};
    inline bool PendingError() {return PendingFlag;};
    inline bool empty() {return List == 0;};
    inline bool empty() {return List == 0;};
-   bool PopMessage(string &Text);
+   bool PopMessage(std::string &Text);
    void Discard();
    void Discard();
 
 
    // Usefull routine to dump to cerr
    // Usefull routine to dump to cerr
@@ -97,7 +84,4 @@ class GlobalError
 GlobalError *_GetErrorObj();
 GlobalError *_GetErrorObj();
 #define _error _GetErrorObj()
 #define _error _GetErrorObj()
 
 
-#undef APT_MFORMAT1
-#undef APT_MFORMAT2
-
 #endif
 #endif

+ 9 - 0
apt-pkg/contrib/macros.h

@@ -76,4 +76,13 @@
         #define __cold  /* no cold marker */
         #define __cold  /* no cold marker */
 #endif
 #endif
 
 
+#ifdef __GNUG__
+// Methods have a hidden this parameter that is visible to this attribute
+	#define __like_printf_1 __attribute__ ((format (printf, 2, 3)))
+	#define __like_printf_2 __attribute__ ((format (printf, 3, 4)))
+#else
+	#define __like_printf_1
+	#define __like_printf_2
+#endif
+
 #endif
 #endif