Anonymous avatar Anonymous committed 7c1a6c4

Persist background brush appropriately on 64-bit Windows.

Comments (0)

Files changed (5)

Source/Platform.h

 #endif
 
 #ifndef __BIG_ENDIAN__
+# define FIX_ENDIAN_INT64_INPLACE(x) ((void)(x))
+# define FIX_ENDIAN_INT64(x) (x)
 # define FIX_ENDIAN_INT32_INPLACE(x) ((void)(x))
 # define FIX_ENDIAN_INT32(x) (x)
 # define FIX_ENDIAN_INT16_INPLACE(x) ((void)(x))
 # define FIX_ENDIAN_INT16(x) (x)
 #else
+# define FIX_ENDIAN_INT64_INPLACE(x) ((x) = SWAP_ENDIAN_INT64(x))
+# define FIX_ENDIAN_INT64(x) SWAP_ENDIAN_INT64(x)
 # define FIX_ENDIAN_INT32_INPLACE(x) ((x) = SWAP_ENDIAN_INT32(x))
 # define FIX_ENDIAN_INT32(x) SWAP_ENDIAN_INT32(x)
 # define FIX_ENDIAN_INT16_INPLACE(x) ((x) = SWAP_ENDIAN_INT16(x))
 # define FIX_ENDIAN_INT16(x) SWAP_ENDIAN_INT16(x)
 #endif
+#define SWAP_ENDIAN_INT64(x) ( \
+  (((x)&0xFF00000000000000) >> 56) | \
+  (((x)&0x00FF000000000000) >> 40) | \
+  (((x)&0x0000FF0000000000) >> 24) | \
+  (((x)&0x000000FF00000000) >>  8) | \
+  (((x)&0x00000000FF000000) <<  8) | \
+  (((x)&0x0000000000FF0000) << 24) | \
+  (((x)&0x000000000000FF00) << 40) | \
+  (((x)&0x00000000000000FF) << 56) )
 #define SWAP_ENDIAN_INT32(x) ( \
   (((x)&0xFF000000) >> 24) | \
   (((x)&0x00FF0000) >>  8) | \
   (((x)&0xFF00) >> 8) | \
   (((x)&0x00FF) << 8) )
 
+#ifdef SYSTEM_X64
+# define FIX_ENDIAN_INT_PTR FIX_ENDIAN_INT64
+# define FIX_ENDIAN_INT_PTR_INPLACE FIX_ENDIAN_INT64_INPLACE
+# define SWAP_ENDIAN_INT_PTR SWAP_ENDIAN_INT64
+#else
+# define FIX_ENDIAN_INT_PTR FIX_ENDIAN_INT32
+# define FIX_ENDIAN_INT_PTR_INPLACE FIX_ENDIAN_INT32_INPLACE
+# define SWAP_ENDIAN_INT_PTR SWAP_ENDIAN_INT32
+#endif
+
 // script path separator
 
 #  define PATH_SEPARATOR_STR _T("\\")

Source/exehead/fileform.h

 #define CC_BK_SYS 8
 #define CC_BKB 16
 
+// This structure needs 4-byte packing because it is written to file and HBRUSH is
+// 8 bytes on a 64-bit system.
+#pragma pack(push, 4)
 typedef struct {
   COLORREF text;
   COLORREF bkc;
   int bkmode;
   int flags;
 } ctlcolors;
+#pragma pack(pop)
 
 // constants for myDelete (util.c)
 #define DEL_DIR 1

Source/fileform.cpp

   m_sink->write_int(data->text);
   m_sink->write_int(data->bkc);
   m_sink->write_int(data->lbStyle);
-  m_sink->write_int((INT_PTR) data->bkb);
+  m_sink->write_intptr((INT_PTR) data->bkb);
   m_sink->write_int(data->bkmode);
   m_sink->write_int(data->flags);
 }

Source/writer.cpp

   write_data(&fi, sizeof(int));
 }
 
+void writer_sink::write_intptr(const INT_PTR i)
+{
+  INT_PTR fi = FIX_ENDIAN_INT_PTR(i);
+  write_data(&fi, sizeof(INT_PTR));
+}
+
 void writer_sink::write_int_array(const int i[], const size_t len)
 {
   for (size_t l = 0; l < len; l++)
   virtual void write_byte(const unsigned char b);
   virtual void write_short(const short s);
   virtual void write_int(const int i);
+  virtual void write_intptr(const INT_PTR i);
   virtual void write_int_array(const int i[], const size_t len);
   virtual void write_string(const TCHAR *s, size_t size);
   virtual void write_growbuf(const IGrowBuf *b);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.