mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-13 13:11:41 +00:00
d95efa7698
This way dvi and any other potential user gets it for free The diff is huge, but the synctex files are just moves. And the code in core/ is also mostly just a move from the generator_pdf.cpp code Acked by Luigi REVIEW: 120311
36 lines
1.4 KiB
Diff
36 lines
1.4 KiB
Diff
_vscprintf() is specific for MSVC; thus in _synctex_error(), for any other
|
|
compiler on Windows, use _vsnprintf() and grow the buffer until necessary.
|
|
|
|
Patch provided by Patrick Spendrin <ps_ml@gmx.de>.
|
|
diff --git a/generators/poppler/synctex/synctex_parser_utils.c b/generators/poppler/synctex/synctex_parser_utils.c
|
|
index e85ca73..ef1645e 100644
|
|
--- a/generators/poppler/synctex/synctex_parser_utils.c
|
|
+++ b/generators/poppler/synctex/synctex_parser_utils.c
|
|
@@ -90,8 +90,26 @@ int _synctex_error(const char * reason,...) {
|
|
char *buff;
|
|
size_t len;
|
|
OutputDebugStringA("SyncTeX ERROR: ");
|
|
+# ifdef _MSC_VER
|
|
len = _vscprintf(reason, arg) + 1;
|
|
buff = (char*)malloc( len * sizeof(char) );
|
|
+#else /* MinGW */
|
|
+ size_t buffersize = 1024;
|
|
+ size_t max_buffersize = 1024 * buffersize;
|
|
+ int result;
|
|
+ buff = (char*)malloc(buffersize * sizeof(char));
|
|
+ result = _vsnprintf(buff, buffersize - 1, reason, arg);
|
|
+ while(-1 == result && buffersize <= max_buffersize) {
|
|
+ buffersize = buffersize * 2;
|
|
+ buff = (char*)realloc(buff, buffersize * sizeof(char));
|
|
+ result = _vsnprintf(buff, buffersize - 1, reason, arg);
|
|
+ }
|
|
+ if(-1 == result) {
|
|
+ // could not make the buffer big enough or simply could not write to it
|
|
+ free(buff);
|
|
+ return -1;
|
|
+ }
|
|
+#endif
|
|
result = vsprintf(buff, reason, arg) +strlen("SyncTeX ERROR: ");
|
|
OutputDebugStringA(buff);
|
|
OutputDebugStringA("\n");
|