diff --git a/setup/build_environment.py b/setup/build_environment.py index e20ad778e3..22b94b2bd0 100644 --- a/setup/build_environment.py +++ b/setup/build_environment.py @@ -6,7 +6,7 @@ __license__ = 'GPL v3' __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import os, socket, struct, subprocess, sys +import os, socket, struct, subprocess, sys, glob from distutils.spawn import find_executable from PyQt4 import pyqtconfig @@ -36,7 +36,7 @@ if iswindows: MT = os.path.join(os.path.dirname(p), 'bin', 'mt.exe') MT = os.path.join(SDK, 'bin', 'mt.exe') os.environ['QMAKESPEC'] = 'win32-msvc' - ICU = r'Q:\icu' + ICU = os.environ.get('ICU_DIR', r'Q:\icu') QMAKE = '/Volumes/sw/qt/bin/qmake' if isosx else 'qmake' if find_executable('qmake-qt4'): @@ -122,7 +122,8 @@ if iswindows: zlib_lib_dirs = [sw_lib_dir] zlib_libs = ['zlib'] - magick_inc_dirs = [os.path.join(prefix, 'build', 'ImageMagick-6.7.6')] + md = glob.glob(os.path.join(prefix, 'build', 'ImageMagick-*'))[-1] + magick_inc_dirs = [md] magick_lib_dirs = [os.path.join(magick_inc_dirs[0], 'VisualMagick', 'lib')] magick_libs = ['CORE_RL_wand_', 'CORE_RL_magick_'] podofo_inc = os.path.join(sw_inc_dir, 'podofo') diff --git a/setup/installer/windows/freeze.py b/setup/installer/windows/freeze.py index 73d9f0e38d..c8e88f4515 100644 --- a/setup/installer/windows/freeze.py +++ b/setup/installer/windows/freeze.py @@ -10,7 +10,7 @@ import sys, os, shutil, glob, py_compile, subprocess, re, zipfile, time, textwra from setup import (Command, modules, functions, basenames, __version__, __appname__) -from setup.build_environment import msvc, MT, RC +from setup.build_environment import msvc, MT, RC, is64bit from setup.installer.windows.wix import WixMixIn ICU_DIR = os.environ.get('ICU_DIR', r'Q:\icu') @@ -88,8 +88,9 @@ class Win32Freeze(Command, WixMixIn): self.archive_lib_dir() self.remove_CRT_from_manifests() self.create_installer() - self.build_portable() - self.build_portable_installer() + if not is64bit: + self.build_portable() + self.build_portable_installer() def remove_CRT_from_manifests(self): ''' diff --git a/setup/installer/windows/notes.rst b/setup/installer/windows/notes.rst index eee14151c1..9c187eec1a 100644 --- a/setup/installer/windows/notes.rst +++ b/setup/installer/windows/notes.rst @@ -549,6 +549,16 @@ Get it from http://lloyd.github.com/easylzma/ (use the trunk version) Run cmake and build the Visual Studio solution (generates CLI tools and dll and static lib automatically) +chmlib +------- + +Download the zip source code from: http://www.jedrea.com/chmlib/ +Run:: + cd src && unzip ./ChmLib-ds6.zip +Then open ChmLib.dsw in Visual Studio, change the configuration to Release +(Win32|x64) and build solution, this will generate a static library in +Release/ChmLib.lib + calibre --------- diff --git a/src/calibre/devices/mtp/windows/content_enumeration.cpp b/src/calibre/devices/mtp/windows/content_enumeration.cpp index 612ecbc915..f7e585c55e 100644 --- a/src/calibre/devices/mtp/windows/content_enumeration.cpp +++ b/src/calibre/devices/mtp/windows/content_enumeration.cpp @@ -696,7 +696,7 @@ PyObject* wpd::put_file(IPortableDevice *device, const wchar_t *parent_id, const PyBytes_AsStringAndSize(raw, &buf, &bytes_read); if (bytes_read > 0) { Py_BEGIN_ALLOW_THREADS; - hr = dest->Write(buf, bytes_read, &bytes_written); + hr = dest->Write(buf, (ULONG)bytes_read, &bytes_written); Py_END_ALLOW_THREADS; Py_DECREF(raw); if (hr == STG_E_MEDIUMFULL) { PyErr_SetString(WPDError, "Cannot write to device as it is full"); break; } diff --git a/src/calibre/ebooks/compression/palmdoc.c b/src/calibre/ebooks/compression/palmdoc.c index 922b63fe1b..ac4a6c9097 100644 --- a/src/calibre/ebooks/compression/palmdoc.c +++ b/src/calibre/ebooks/compression/palmdoc.c @@ -101,7 +101,7 @@ cpalmdoc_rfind(Byte *data, Py_ssize_t pos, Py_ssize_t chunk_length) { static Py_ssize_t cpalmdoc_do_compress(buffer *b, char *output) { Py_ssize_t i = 0, j, chunk_len, dist; - unsigned compound; + unsigned int compound; Byte c, n; bool found; char *head; @@ -119,7 +119,7 @@ cpalmdoc_do_compress(buffer *b, char *output) { dist = i - j; if (j < i && dist <= 2047) { found = true; - compound = (dist << 3) + chunk_len-3; + compound = (unsigned int)((dist << 3) + chunk_len-3); *(output++) = CHAR(0x80 + (compound >> 8 )); *(output++) = CHAR(compound & 0xFF); i += chunk_len; @@ -148,7 +148,7 @@ cpalmdoc_do_compress(buffer *b, char *output) { temp.data[temp.len++] = c; j++; } i += temp.len - 1; - *(output++) = temp.len; + *(output++) = (char)temp.len; for (j=0; j < temp.len; j++) *(output++) = (char)temp.data[j]; } } diff --git a/src/calibre/utils/fonts/winfonts.cpp b/src/calibre/utils/fonts/winfonts.cpp index f678d021c4..db023b14bb 100644 --- a/src/calibre/utils/fonts/winfonts.cpp +++ b/src/calibre/utils/fonts/winfonts.cpp @@ -167,7 +167,7 @@ static PyObject* add_font(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, "s#", &data, &sz)) return NULL; - AddFontMemResourceEx(data, sz, NULL, &num); + AddFontMemResourceEx(data, (DWORD)sz, NULL, &num); return Py_BuildValue("k", num); } diff --git a/src/calibre/utils/fonts/woff/main.c b/src/calibre/utils/fonts/woff/main.c index 9014fe250e..d38bfa18d5 100644 --- a/src/calibre/utils/fonts/woff/main.c +++ b/src/calibre/utils/fonts/woff/main.c @@ -49,7 +49,7 @@ to_woff(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, "s#", &sfnt, &sz)) return NULL; - woff = (char*)woffEncode((uint8_t*)sfnt, sz, 0, 0, &wofflen, &status); + woff = (char*)woffEncode((uint8_t*)sfnt, (uint32_t)sz, 0, 0, &wofflen, &status); if (WOFF_FAILURE(status) || woff == NULL) return woff_err(status); @@ -68,7 +68,7 @@ from_woff(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, "s#", &woff, &sz)) return NULL; - sfnt = (char*)woffDecode((uint8_t*)woff, sz, &sfntlen, &status); + sfnt = (char*)woffDecode((uint8_t*)woff, (uint32_t)sz, &sfntlen, &status); if (WOFF_FAILURE(status) || sfnt == NULL) return woff_err(status); ans = Py_BuildValue("s#", sfnt, sfntlen); diff --git a/src/calibre/utils/icu.c b/src/calibre/utils/icu.c index d90c6c0b90..3c133418b1 100644 --- a/src/calibre/utils/icu.c +++ b/src/calibre/utils/icu.c @@ -129,7 +129,7 @@ icu_Collator_actual_locale(icu_Collator *self, void *closure) { static PyObject * icu_Collator_sort_key(icu_Collator *self, PyObject *args, PyObject *kwargs) { char *input; - Py_ssize_t sz; + int32_t sz; UChar *buf; uint8_t *buf2; PyObject *ans; @@ -138,7 +138,7 @@ icu_Collator_sort_key(icu_Collator *self, PyObject *args, PyObject *kwargs) { if (!PyArg_ParseTuple(args, "es", "UTF-8", &input)) return NULL; - sz = strlen(input); + sz = (int32_t)strlen(input); buf = (UChar*)calloc(sz*4 + 1, sizeof(UChar)); @@ -177,14 +177,14 @@ icu_Collator_sort_key(icu_Collator *self, PyObject *args, PyObject *kwargs) { static PyObject * icu_Collator_strcmp(icu_Collator *self, PyObject *args, PyObject *kwargs) { char *a_, *b_; - size_t asz, bsz; + int32_t asz, bsz; UChar *a, *b; UErrorCode status = U_ZERO_ERROR; UCollationResult res = UCOL_EQUAL; if (!PyArg_ParseTuple(args, "eses", "UTF-8", &a_, "UTF-8", &b_)) return NULL; - asz = strlen(a_); bsz = strlen(b_); + asz = (int32_t)strlen(a_); bsz = (int32_t)strlen(b_); a = (UChar*)calloc(asz*4 + 1, sizeof(UChar)); b = (UChar*)calloc(bsz*4 + 1, sizeof(UChar)); @@ -208,7 +208,7 @@ icu_Collator_strcmp(icu_Collator *self, PyObject *args, PyObject *kwargs) { static PyObject * icu_Collator_find(icu_Collator *self, PyObject *args, PyObject *kwargs) { PyObject *a_, *b_; - size_t asz, bsz; + int32_t asz, bsz; UChar *a, *b; wchar_t *aw, *bw; UErrorCode status = U_ZERO_ERROR; @@ -216,7 +216,7 @@ icu_Collator_find(icu_Collator *self, PyObject *args, PyObject *kwargs) { int32_t pos = -1, length = -1; if (!PyArg_ParseTuple(args, "UU", &a_, &b_)) return NULL; - asz = PyUnicode_GetSize(a_); bsz = PyUnicode_GetSize(b_); + asz = (int32_t)PyUnicode_GetSize(a_); bsz = (int32_t)PyUnicode_GetSize(b_); a = (UChar*)calloc(asz*4 + 2, sizeof(UChar)); b = (UChar*)calloc(bsz*4 + 2, sizeof(UChar)); @@ -295,7 +295,7 @@ icu_Collator_contractions(icu_Collator *self, PyObject *args, PyObject *kwargs) static PyObject * icu_Collator_startswith(icu_Collator *self, PyObject *args, PyObject *kwargs) { PyObject *a_, *b_; - size_t asz, bsz; + int32_t asz, bsz; int32_t actual_a, actual_b; UChar *a, *b; wchar_t *aw, *bw; @@ -303,7 +303,7 @@ icu_Collator_startswith(icu_Collator *self, PyObject *args, PyObject *kwargs) { int ans = 0; if (!PyArg_ParseTuple(args, "UU", &a_, &b_)) return NULL; - asz = PyUnicode_GetSize(a_); bsz = PyUnicode_GetSize(b_); + asz = (int32_t)PyUnicode_GetSize(a_); bsz = (int32_t)PyUnicode_GetSize(b_); if (asz < bsz) Py_RETURN_FALSE; if (bsz == 0) Py_RETURN_TRUE; @@ -333,7 +333,7 @@ icu_Collator_startswith(icu_Collator *self, PyObject *args, PyObject *kwargs) { static PyObject * icu_Collator_collation_order(icu_Collator *self, PyObject *args, PyObject *kwargs) { PyObject *a_; - size_t asz; + int32_t asz; int32_t actual_a; UChar *a; wchar_t *aw; @@ -342,7 +342,7 @@ icu_Collator_collation_order(icu_Collator *self, PyObject *args, PyObject *kwarg int order = 0, len = -1; if (!PyArg_ParseTuple(args, "U", &a_)) return NULL; - asz = PyUnicode_GetSize(a_); + asz = (int32_t)PyUnicode_GetSize(a_); a = (UChar*)calloc(asz*4 + 2, sizeof(UChar)); aw = (wchar_t*)calloc(asz*4 + 2, sizeof(wchar_t)); @@ -498,7 +498,7 @@ static PyObject * icu_upper(PyObject *self, PyObject *args) { char *input, *ans, *buf3 = NULL; const char *loc; - size_t sz; + int32_t sz; UChar *buf, *buf2; PyObject *ret; UErrorCode status = U_ZERO_ERROR; @@ -506,7 +506,7 @@ icu_upper(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, "ses", &loc, "UTF-8", &input)) return NULL; - sz = strlen(input); + sz = (int32_t)strlen(input); buf = (UChar*)calloc(sz*4 + 1, sizeof(UChar)); buf2 = (UChar*)calloc(sz*8 + 1, sizeof(UChar)); @@ -543,7 +543,7 @@ static PyObject * icu_lower(PyObject *self, PyObject *args) { char *input, *ans, *buf3 = NULL; const char *loc; - size_t sz; + int32_t sz; UChar *buf, *buf2; PyObject *ret; UErrorCode status = U_ZERO_ERROR; @@ -551,7 +551,7 @@ icu_lower(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, "ses", &loc, "UTF-8", &input)) return NULL; - sz = strlen(input); + sz = (int32_t)strlen(input); buf = (UChar*)calloc(sz*4 + 1, sizeof(UChar)); buf2 = (UChar*)calloc(sz*8 + 1, sizeof(UChar)); @@ -588,7 +588,7 @@ static PyObject * icu_title(PyObject *self, PyObject *args) { char *input, *ans, *buf3 = NULL; const char *loc; - size_t sz; + int32_t sz; UChar *buf, *buf2; PyObject *ret; UErrorCode status = U_ZERO_ERROR; @@ -596,7 +596,7 @@ icu_title(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, "ses", &loc, "UTF-8", &input)) return NULL; - sz = strlen(input); + sz = (int32_t)strlen(input); buf = (UChar*)calloc(sz*4 + 1, sizeof(UChar)); buf2 = (UChar*)calloc(sz*8 + 1, sizeof(UChar)); diff --git a/src/calibre/utils/windows/winutil.c b/src/calibre/utils/windows/winutil.c index f0bb6b6f77..71eac1e414 100644 --- a/src/calibre/utils/windows/winutil.c +++ b/src/calibre/utils/windows/winutil.c @@ -625,7 +625,8 @@ winutil_get_removable_drives(PyObject *self, PyObject *args) { BOOL iterate = TRUE, ddebug = FALSE; PSP_DEVICE_INTERFACE_DETAIL_DATA interfaceDetailData; DWORD i; - unsigned int j, length; + unsigned int j; + size_t length; WCHAR volume[BUFSIZE]; struct tagDrives g_drives[MAX_DRIVES]; PyObject *volumes, *key, *candidates, *pdebug = Py_False, *temp; @@ -693,7 +694,8 @@ winutil_get_removable_drives(PyObject *self, PyObject *args) { static PyObject * winutil_get_usb_devices(PyObject *self, PyObject *args) { - unsigned int j, buffersize; + unsigned int j; + size_t buffersize; HDEVINFO hDevInfo; DWORD i; BOOL iterate = TRUE; PyObject *devices, *temp = (PyObject *)1; @@ -827,14 +829,24 @@ winutil_strftime(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "s|O:strftime", &_fmt, &tup)) return NULL; - fmtlen = mbstowcs(NULL, _fmt, strlen(_fmt)); + + if (mbstowcs_s(&fmtlen, NULL, 0, _fmt, strlen(_fmt)) != 0) { + PyErr_SetString(PyExc_ValueError, "Failed to convert fmt to wchar"); + return NULL; + } fmt = (wchar_t *)PyMem_Malloc((fmtlen+2)*sizeof(wchar_t)); if (fmt == NULL) return PyErr_NoMemory(); - mbstowcs(fmt, _fmt, fmtlen+1); + if (mbstowcs_s(&fmtlen, fmt, fmtlen+2, _fmt, strlen(_fmt)) != 0) { + PyErr_SetString(PyExc_ValueError, "Failed to convert fmt to wchar"); + goto end; + } if (tup == NULL) { time_t tt = time(NULL); - buf = *localtime(&tt); + if(localtime_s(&buf, &tt) != 0) { + PyErr_SetString(PyExc_ValueError, "Failed to get localtime()"); + goto end; + } } else if (!gettmarg(tup, &buf)) goto end; diff --git a/src/qtcurve/style/qtcurve.cpp b/src/qtcurve/style/qtcurve.cpp index b48eb9d421..48f8376595 100644 --- a/src/qtcurve/style/qtcurve.cpp +++ b/src/qtcurve/style/qtcurve.cpp @@ -10847,7 +10847,7 @@ void Style::drawBevelGradientReal(const QColor &base, QPainter *p, const QRect & QLinearGradient g(r.topLeft(), horiz ? r.bottomLeft() : r.topRight()); GradientStopCont::const_iterator it(grad->stops.begin()), end(grad->stops.end()); - int numStops(grad->stops.size()); + size_t numStops(grad->stops.size()); for(int i=0; it!=end; ++it, ++i) {