]> git.lyx.org Git - lyx.git/blob - development/Win32/win32_kludge.diff
Replace Asger's huge patch with the kludges needed to compile LyX with MSVC.
[lyx.git] / development / Win32 / win32_kludge.diff
1 Index: src/DepTable.C
2 ===================================================================
3 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/DepTable.C,v
4 retrieving revision 1.41
5 diff -u -r1.41 DepTable.C
6 --- src/DepTable.C      13 Oct 2003 01:01:33 -0000      1.41
7 +++ src/DepTable.C      19 Jan 2005 10:35:54 -0000
8 @@ -26,7 +26,9 @@
9  #include <fstream>
10  
11  #ifndef CXX_GLOBAL_CSTD
12 +# ifndef _WIN32
13  using std::time;
14 +# endif
15  #endif
16  
17  using lyx::support::ltrim;
18 Index: src/buffer.C
19 ===================================================================
20 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
21 retrieving revision 1.609
22 diff -u -r1.609 buffer.C
23 --- src/buffer.C        31 Jan 2005 10:42:17 -0000      1.609
24 +++ src/buffer.C        31 Jan 2005 11:08:10 -0000
25 @@ -77,7 +77,11 @@
26  #include <boost/bind.hpp>
27  #include <boost/filesystem/operations.hpp>
28  
29 -#include <utime.h>
30 +#ifdef _WIN32
31 +# include <windows.h>
32 +#else
33 +# include <utime.h>
34 +#endif
35  
36  #include <iomanip>
37  #include <stack>
38 Index: src/cursor.C
39 ===================================================================
40 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/cursor.C,v
41 retrieving revision 1.119
42 diff -u -r1.119 cursor.C
43 --- src/cursor.C        18 Jan 2005 14:15:55 -0000      1.119
44 +++ src/cursor.C        31 Jan 2005 11:08:09 -0000
45 @@ -58,7 +58,9 @@
46  using std::vector;
47  using std::endl;
48  #ifndef CXX_GLOBAL_CSTD
49 +# ifndef _WIN32
50  using std::isalpha;
51 +# endif
52  #endif
53  using std::min;
54  using std::swap;
55 Index: src/ispell.C
56 ===================================================================
57 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ispell.C,v
58 retrieving revision 1.25
59 diff -u -r1.25 ispell.C
60 --- src/ispell.C        20 Jan 2005 16:17:36 -0000      1.25
61 +++ src/ispell.C        23 Jan 2005 12:09:37 -0000
62 @@ -24,11 +24,17 @@
63  
64  #include "support/forkedcall.h"
65  
66 +#ifdef _WIN32
67 +# include "support/os_win32.h"
68 +#endif
69 +
70  // HP-UX 11.x doesn't have this header
71  #ifdef HAVE_SYS_SELECT_H
72  #include <sys/select.h>
73  #endif
74 -#include <sys/time.h>
75 +#ifndef _WIN32
76 +# include <sys/time.h>
77 +#endif
78  
79  using boost::shared_ptr;
80  
81 @@ -88,6 +94,7 @@
82         }
83  
84         // child process
85 +#ifndef _WIN32
86         dup2(pipein[0], STDIN_FILENO);
87         dup2(pipeout[1], STDOUT_FILENO);
88         dup2(pipeerr[1], STDERR_FILENO);
89 @@ -180,6 +187,7 @@
90  
91         lyxerr << "LyX: Failed to start ispell!" << endl;
92         _exit(0);
93 +#endif
94  }
95  
96  
97 @@ -191,6 +199,7 @@
98  {
99         lyxerr[Debug::GUI] << "Created ispell" << endl;
100  
101 +#ifndef _WIN32
102         // static due to the setvbuf. Ugly.
103         static char o_buf[BUFSIZ];
104  
105 @@ -275,6 +284,7 @@
106         close(pipeerr[1]);
107         child_->kill();
108         child_.reset(0);
109 +#endif
110  }
111  
112  
113 @@ -295,18 +305,23 @@
114                 fclose(out);
115         }
116  
117 +#ifndef _WIN32
118         close(pipein[0]);
119         close(pipein[1]);
120         close(pipeout[0]);
121         close(pipeout[1]);
122         close(pipeerr[0]);
123         close(pipeerr[1]);
124 +#endif
125         delete [] str;
126  }
127  
128  
129  bool ISpell::select(bool & err_read)
130  {
131 +#ifdef _WIN32
132 +       return false;
133 +#else
134         fd_set infds;
135         struct timeval tv;
136         int retval = 0;
137 @@ -316,11 +331,15 @@
138         tv.tv_sec = 2;
139         tv.tv_usec = 0;
140  
141 +#ifdef HAVE_SELECT
142         retval = ::select(SELECT_TYPE_ARG1 (max(pipeout[0], pipeerr[0]) + 1),
143                         SELECT_TYPE_ARG234 (&infds),
144                         0,
145                         0,
146                         SELECT_TYPE_ARG5 (&tv));
147 +#else
148 +       retval = -1;
149 +#endif
150  
151         // error
152         if (retval <= 0)
153 @@ -335,6 +354,7 @@
154         fgets(buf, BUFSIZ, in);
155         err_read = false;
156         return false;
157 +#endif
158  }
159  
160  
161 Index: src/lyx_cb.C
162 ===================================================================
163 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v
164 retrieving revision 1.247
165 diff -u -r1.247 lyx_cb.C
166 --- src/lyx_cb.C        31 Jan 2005 10:42:18 -0000      1.247
167 +++ src/lyx_cb.C        31 Jan 2005 10:57:53 -0000
168 @@ -44,6 +44,10 @@
169  #include "support/path.h"
170  #include "support/systemcall.h"
171  
172 +#ifdef _WIN32
173 +# include "support/os_win32.h" // fork()
174 +#endif
175 +
176  #include <boost/shared_ptr.hpp>
177  #include <boost/filesystem/operations.hpp>
178  
179 Index: src/lyxserver.C
180 ===================================================================
181 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxserver.C,v
182 retrieving revision 1.59
183 diff -u -r1.59 lyxserver.C
184 --- src/lyxserver.C     20 Jan 2005 15:07:36 -0000      1.59
185 +++ src/lyxserver.C     21 Jan 2005 09:47:31 -0000
186 @@ -54,6 +54,10 @@
187  #include <sys/stat.h>
188  #include <fcntl.h>
189  
190 +#ifdef _WIN32
191 +# include "support/os_win32.h" // F_SETFL, O_NONBLOCK, fcntl
192 +#endif
193 +
194  #ifdef __EMX__
195  #include <cstdlib>
196  #include <io.h>
197 @@ -182,6 +186,8 @@
198         // Imported handles can be used both with OS/2 APIs and emx
199         // library functions.
200         fd = _imphandle(os2fd);
201 +#elif defined(_WIN32)
202 +
203  #else
204         if (::access(filename.c_str(), F_OK) == 0) {
205                 lyxerr << "LyXComm: Pipe " << filename << " already exists.\n"
206 @@ -236,10 +242,12 @@
207         }
208  #endif
209  
210 +#ifndef _WIN32
211         if (::close(fd) < 0) {
212                 lyxerr << "LyXComm: Could not close pipe " << filename
213                        << '\n' << strerror(errno) << endl;
214         }
215 +#endif
216  
217  // OS/2 pipes are deleted automatically
218  #ifndef __EMX__
219 @@ -275,7 +283,13 @@
220         errno = 0;
221         int status;
222         // the single = is intended here.
223 -       while ((status = ::read(infd, charbuf, charbuf_size - 1))) {
224 +       while ((status = 
225 +#ifndef _WIN32
226 +               ::read(infd, charbuf, charbuf_size - 1)
227 +#else
228 +               -1
229 +#endif
230 +               )) {
231  
232                 if (status > 0) {
233                         charbuf[status] = '\0'; // turn it into a c string
234 @@ -332,6 +346,9 @@
235  
236         if (pipename.empty()) return;
237  
238 +#ifdef _WIN32
239 +       return;
240 +#else
241         if (!ready) {
242                 lyxerr << "LyXComm: Pipes are closed. Could not send "
243                        << msg << endl;
244 @@ -342,6 +359,7 @@
245                 closeConnection();
246                 openConnection();
247         }
248 +#endif
249  #ifdef __EMX__
250         APIRET rc;
251         int errnum;
252 Index: src/lyxsocket.C
253 ===================================================================
254 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxsocket.C,v
255 retrieving revision 1.6
256 diff -u -r1.6 lyxsocket.C
257 --- src/lyxsocket.C     23 Jul 2004 19:01:48 -0000      1.6
258 +++ src/lyxsocket.C     19 Jan 2005 11:18:01 -0000
259 @@ -68,7 +68,9 @@
260  LyXServerSocket::~LyXServerSocket()
261  {
262         lyx_gui::unregister_socket_callback(fd_);
263 +#ifndef _WIN32
264         ::close(fd_);
265 +#endif
266         lyx::support::unlink(address_);
267         lyxerr[Debug::LYXSERVER] << "lyx: Server socket quitting" << endl;
268  }
269 @@ -155,7 +157,11 @@
270  {
271         string const linen(line + '\n');
272         int const size = linen.size();
273 +#ifndef _WIN32
274         int const written = ::write(fd_, linen.c_str(), size);
275 +#else
276 +       int const written = -1;
277 +#endif
278         if (written < size) { // Allways mean end of connection.
279                 if ((written == -1) && (errno == EPIPE)) {
280                         // The program will also receive a SIGPIPE
281 @@ -194,7 +200,9 @@
282  
283  LyXDataSocket::~LyXDataSocket()
284  {
285 +#ifndef _WIN32
286         ::close(fd_);
287 +#endif
288  
289         lyx_gui::unregister_socket_callback(fd_);
290         lyxerr[Debug::LYXSERVER] << "lyx: Data socket " << fd_ << " quitting."
291 @@ -216,7 +224,13 @@
292         int count;
293  
294         // read and store characters in buffer
295 -       while ((count = ::read(fd_, charbuf, charbuf_size - 1)) > 0) {
296 +       while ((count = 
297 +#ifndef _WIN32
298 +               ::read(fd_, charbuf, charbuf_size - 1)
299 +#else
300 +               0
301 +#endif
302 +               ) > 0) {
303                 buffer_.append(charbuf, charbuf + count);
304         }
305  
306 @@ -250,7 +264,11 @@
307  {
308         string const linen(line + '\n');
309         int const size = linen.size();
310 +#ifndef _WIN32
311         int const written = ::write(fd_, linen.c_str(), size);
312 +#else
313 +       int const written = -1;
314 +#endif
315         if (written < size) { // Allways mean end of connection.
316                 if ((written == -1) && (errno == EPIPE)) {
317                         // The program will also receive a SIGPIPE
318 Index: src/client/client.C
319 ===================================================================
320 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/client/client.C,v
321 retrieving revision 1.7
322 diff -u -r1.7 client.C
323 --- src/client/client.C 20 Jan 2005 15:38:13 -0000      1.7
324 +++ src/client/client.C 21 Jan 2005 09:43:09 -0000
325 @@ -25,12 +25,14 @@
326  # include <unistd.h>
327  #endif
328  
329 +#ifndef _WIN32
330  // select()
331 -#include <sys/select.h>
332 +# include <sys/select.h>
333  
334  // socket(), connect()
335 -#include <sys/socket.h>
336 -#include <sys/un.h>
337 +# include <sys/socket.h>
338 +# include <sys/un.h>
339 +#endif
340  
341  // fcntl()
342  #include <fcntl.h>
343 Index: src/frontends/LyXView.C
344 ===================================================================
345 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.C,v
346 retrieving revision 1.49
347 diff -u -r1.49 LyXView.C
348 --- src/frontends/LyXView.C     20 Jan 2005 15:38:14 -0000      1.49
349 +++ src/frontends/LyXView.C     21 Jan 2005 09:43:10 -0000
350 @@ -39,7 +39,9 @@
351  
352  #include <boost/bind.hpp>
353  
354 -#include <sys/time.h>
355 +#ifndef _WIN32
356 +# include <sys/time.h>
357 +#endif
358  #ifdef HAVE_UNISTD_H
359  # include <unistd.h>
360  #endif
361 Index: src/support/filetools.C
362 ===================================================================
363 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
364 retrieving revision 1.204
365 diff -u -r1.204 filetools.C
366 --- src/support/filetools.C     31 Jan 2005 10:42:23 -0000      1.204
367 +++ src/support/filetools.C     31 Jan 2005 11:08:10 -0000
368 @@ -1153,6 +1153,11 @@
369  
370  cmd_ret const RunCommand(string const & cmd)
371  {
372 +#ifdef _WIN32
373 +       // TODO: Implement this, or merge it into forkedcall.
374 +       // Used for lyx2lyx in buffer.C, echo in math_extern and kpse in this file
375 +       return make_pair(-1, string());
376 +#else
377         // FIXME: replace all calls to RunCommand with ForkedCall
378         // (if the output is not needed) or the code in ispell.C
379         // (if the output is needed).
380 @@ -1193,6 +1198,7 @@
381         sigprocmask(SIG_SETMASK, &oldMask, 0);
382  
383         return make_pair(pret, ret);
384 +#endif
385  }
386  
387  
388 Index: src/support/forkedcall.C
389 ===================================================================
390 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcall.C,v
391 retrieving revision 1.21
392 diff -u -r1.21 forkedcall.C
393 --- src/support/forkedcall.C    20 Jan 2005 15:38:14 -0000      1.21
394 +++ src/support/forkedcall.C    25 Jan 2005 12:41:14 -0000
395 @@ -30,6 +30,10 @@
396  #include "support/lyxlib.h"
397  #include "support/filetools.h"
398  #include "support/os.h"
399 +#ifdef _WIN32
400 +#include "os_win32.h"
401 +#include <process.h>
402 +#endif
403  
404  #include "debug.h"
405  
406 @@ -41,7 +45,9 @@
407  #include <csignal>
408  #include <cstdlib>
409  #include <sys/types.h>
410 -#include <sys/wait.h>
411 +#ifndef _WIN32
412 +# include <sys/wait.h>
413 +#endif
414  #ifdef HAVE_UNISTD_H
415  # include <unistd.h>
416  #endif
417 @@ -70,7 +76,9 @@
418                 if (secs > 0) {
419                         new Murder(secs, pid);
420                 } else if (pid != 0) {
421 +#ifdef SIGKILL
422                         lyx::support::kill(pid, SIGKILL);
423 +#endif
424                 }
425         }
426  
427 @@ -78,7 +86,9 @@
428         void kill()
429         {
430                 if (pid_ != 0) {
431 +#ifdef SIGKILL
432                         lyx::support::kill(pid_, SIGKILL);
433 +#endif
434                 }
435                 lyxerr << "Killed " << pid_ << std::endl;
436                 delete this;
437 @@ -152,14 +162,16 @@
438         if (!pid())
439                 return false;
440  
441 +#ifndef _WIN32
442         // Un-UNIX like, but we don't have much use for
443         // knowing if a zombie exists, so just reap it first.
444         int waitstatus;
445         waitpid(pid(), &waitstatus, WNOHANG);
446  
447         // Racy of course, but it will do.
448 -       if (::kill(pid(), 0) && errno == ESRCH)
449 +       if (lyx::kill(pid(), 0) && errno == ESRCH)
450                 return false;
451 +#endif
452         return true;
453  }
454  
455 @@ -178,6 +190,7 @@
456                 Murder::killItDead(0, pid());
457  
458         } else {
459 +#ifdef SIGHUP
460                 int ret = lyx::support::kill(pid(), SIGHUP);
461  
462                 // The process is already dead if wait_for_death is false
463 @@ -186,6 +199,7 @@
464                 if (wait_for_death) {
465                         Murder::killItDead(tolerance, pid());
466                 }
467 +#endif
468         }
469  }
470  
471 @@ -195,6 +209,7 @@
472  {
473         // We'll pretend that the child returns 1 on all error conditions.
474         retval_ = 1;
475 +#ifndef _WIN32
476         int status;
477         bool wait = true;
478         while (wait) {
479 @@ -223,6 +238,7 @@
480                         wait = false;
481                 }
482         }
483 +#endif
484         return retval_;
485  }
486  
487 @@ -299,7 +315,12 @@
488                 std::cout << *ait << std::endl;
489         argv.push_back(0);
490  
491 -#ifndef __EMX__
492 +#ifdef __EMX
493 +       pid_t const cpid = spawnvp(P_SESSION|P_DEFAULT|P_MINIMIZE|P_BACKGROUND,
494 +                                  argv[0], &*argv.begin());
495 +#elif defined(_WIN32)
496 +       pid_t const cpid = spawnvp(_P_NOWAIT, argv[0], &*argv.begin());
497 +#else
498         pid_t const cpid = ::fork();
499         if (cpid == 0) {
500                 // Child
501 @@ -310,9 +331,6 @@
502                        << strerror(errno) << endl;
503                 _exit(1);
504         }
505 -#else
506 -       pid_t const cpid = spawnvp(P_SESSION|P_DEFAULT|P_MINIMIZE|P_BACKGROUND,
507 -                                  argv[0], &*argv.begin());
508  #endif
509  
510         if (cpid < 0) {
511 Index: src/support/forkedcall.h
512 ===================================================================
513 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcall.h,v
514 retrieving revision 1.19
515 diff -u -r1.19 forkedcall.h
516 --- src/support/forkedcall.h    26 Sep 2004 14:19:47 -0000      1.19
517 +++ src/support/forkedcall.h    17 Jan 2005 12:17:09 -0000
518 @@ -31,6 +31,10 @@
519  
520  #include <sys/types.h>
521  
522 +#ifdef _WIN32
523 +typedef int pid_t;
524 +#endif
525 +
526  namespace lyx {
527  namespace support {
528  
529 Index: src/support/forkedcontr.C
530 ===================================================================
531 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcontr.C,v
532 retrieving revision 1.27
533 diff -u -r1.27 forkedcontr.C
534 --- src/support/forkedcontr.C   20 Jan 2005 15:38:14 -0000      1.27
535 +++ src/support/forkedcontr.C   21 Jan 2005 09:51:07 -0000
536 @@ -19,14 +19,22 @@
537  
538  #include "debug.h"
539  
540 +#ifdef _WIN32
541 +#include "os_win32.h"
542 +#include <windows.h>
543 +#endif
544 +
545  #include <boost/bind.hpp>
546  
547  #include <cerrno>
548  #include <cstdlib>
549 +
550  #ifdef HAVE_UNISTD_H
551  # include <unistd.h>
552  #endif
553 -#include <sys/wait.h>
554 +#ifndef _WIN32
555 +# include <sys/wait.h>
556 +#endif
557  
558  using boost::bind;
559  
560 @@ -176,7 +184,9 @@
561         ForkedcallsController::Data & store =
562                 fcc.reaped_children[++fcc.current_child];
563         // Clean up the child process.
564 +#ifndef _WIN32
565         store.pid = wait(&store.status);
566 +#endif
567  }
568  
569  } // namespace anon
570 @@ -193,11 +203,12 @@
571  ForkedcallsController::ForkedcallsController()
572         : reaped_children(50), current_child(-1)
573  {
574 +#ifndef _WIN32
575         signal(SIGCHLD, child_handler);
576 -
577         sigemptyset(&oldMask);
578         sigemptyset(&newMask);
579         sigaddset(&newMask, SIGCHLD);
580 +#endif
581  }
582  
583  
584 @@ -206,7 +217,9 @@
585  // I want to print or something.
586  ForkedcallsController::~ForkedcallsController()
587  {
588 +#ifndef _WIN32
589         signal(SIGCHLD, SIG_DFL);
590 +#endif
591  }
592  
593  
594 @@ -215,6 +228,7 @@
595         forkedCalls.push_back(newcall.clone());
596  
597         if (forkedCalls.size() > reaped_children.size()) {
598 +#ifndef _WIN32
599                 // Block the SIGCHLD signal.
600                 sigprocmask(SIG_BLOCK, &newMask, &oldMask);
601  
602 @@ -222,6 +236,7 @@
603  
604                 // Unblock the SIGCHLD signal and restore the old mask.
605                 sigprocmask(SIG_SETMASK, &oldMask, 0);
606 +#endif
607         }
608  }
609  
610 @@ -255,8 +270,10 @@
611         if (current_child == -1)
612                 return;
613  
614 +#ifndef _WIN32
615         // Block the SIGCHLD signal.
616         sigprocmask(SIG_BLOCK, &newMask, &oldMask);
617 +#endif
618  
619         for (int i = 0; i != 1 + current_child; ++i) {
620                 Data & store = reaped_children[i];
621 @@ -312,8 +329,10 @@
622         // Reset the counter
623         current_child = -1;
624  
625 +#ifndef _WIN32
626         // Unblock the SIGCHLD signal and restore the old mask.
627         sigprocmask(SIG_SETMASK, &oldMask, 0);
628 +#endif
629  }
630  
631  } // namespace support
632 Index: src/support/forkedcontr.h
633 ===================================================================
634 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcontr.h,v
635 retrieving revision 1.18
636 diff -u -r1.18 forkedcontr.h
637 --- src/support/forkedcontr.h   7 Nov 2004 13:22:51 -0000       1.18
638 +++ src/support/forkedcontr.h   23 Jan 2005 12:25:33 -0000
639 @@ -19,7 +19,10 @@
640  #include <boost/shared_ptr.hpp>
641  
642  #include <csignal>
643 -//#include <sys/types.h> // needed for pid_t
644 +#ifdef _WIN32
645 +typedef int pid_t;
646 +#endif
647 +#include <sys/types.h> // needed for pid_t
648  #include <list>
649  #include <vector>
650  
651 @@ -79,8 +82,10 @@
652         /// The child processes
653         ListType forkedCalls;
654  
655 +#ifndef _WIN32
656         /// Used to block SIGCHLD signals.
657         sigset_t newMask, oldMask;
658 +#endif
659  };
660  
661  } // namespace support
662 Index: src/support/socktools.C
663 ===================================================================
664 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/socktools.C,v
665 retrieving revision 1.6
666 diff -u -r1.6 socktools.C
667 --- src/support/socktools.C     20 Jan 2005 15:38:14 -0000      1.6
668 +++ src/support/socktools.C     21 Jan 2005 09:43:42 -0000
669 @@ -15,8 +15,10 @@
670  
671  #include "debug.h"
672  
673 +#ifndef _WIN32
674  #include <sys/socket.h>
675  #include <sys/un.h>
676 +#endif
677  #include <fcntl.h>
678  #ifdef HAVE_UNISTD_H
679  # include <unistd.h>
680 @@ -48,6 +50,7 @@
681  // special file 'name' will be created in the filesystem.
682  int listen(string const & name, int queue)
683  {
684 +#ifndef _WIN32
685         int fd; // File descriptor for the socket
686         sockaddr_un addr; // Structure that hold the socket address
687  
688 @@ -105,14 +108,17 @@
689                 lyx::support::unlink(name);
690                 return -1;
691         }
692 -
693         return fd;
694 +#else
695 +       return -1;
696 +#endif
697  }
698  
699  // Returns a file descriptor for a new connection from the socket
700  // descriptor 'sd' (or -1 in case of error)
701  int accept(int sd)
702  {
703 +#ifndef _WIN32
704         int fd;
705  
706         // Returns the new file descriptor or -1 in case of error
707 @@ -132,6 +138,9 @@
708                 return -1;
709         }
710         return fd;
711 +#else
712 +       return -1;
713 +#endif
714  }
715  
716  } // namespace socktools
717 Index: src/support/tempname.C
718 ===================================================================
719 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/tempname.C,v
720 retrieving revision 1.25
721 diff -u -r1.25 tempname.C
722 --- src/support/tempname.C      20 Jan 2005 15:38:14 -0000      1.25
723 +++ src/support/tempname.C      24 Jan 2005 07:51:08 -0000
724 @@ -30,6 +30,10 @@
725  # include <sys/stat.h>
726  #endif
727  
728 +#ifdef _WIN32
729 +# include <io.h>
730 +#endif
731 +
732  using boost::scoped_array;
733  
734  using std::string;
735 @@ -42,6 +46,9 @@
736  {
737  #if defined(HAVE_MKSTEMP)
738         return ::mkstemp(templ);
739 +#elif defined(_WIN32)
740 +       ::_mktemp(templ);
741 +       return (int) ::fopen(templ, "w");
742  #elif defined(HAVE_MKTEMP)
743         // This probably just barely works...
744         ::mktemp(templ);
745 @@ -58,7 +65,9 @@
746  {
747         string const tmpdir(dir.empty() ? package().temp_dir() : dir);
748         string tmpfl(AddName(tmpdir, mask));
749 +#ifndef _WIN32
750         tmpfl += convert<string>(getpid());
751 +#endif
752         tmpfl += "XXXXXX";
753  
754         // The supposedly safe mkstemp version
755 @@ -69,7 +78,11 @@
756         int const tmpf = make_tempfile(tmpl.get());
757         if (tmpf != -1) {
758                 string const t(tmpl.get());
759 +#ifdef _WIN32
760 +               ::fclose((FILE *) tmpf);
761 +#else
762                 ::close(tmpf);
763 +#endif
764                 lyxerr[Debug::FILES] << "Temporary file `" << t
765                                      << "' created." << endl;
766                 return t;
767 Index: src/support/userinfo.C
768 ===================================================================
769 RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/userinfo.C,v
770 retrieving revision 1.9
771 diff -u -r1.9 userinfo.C
772 --- src/support/userinfo.C      20 Jan 2005 15:38:14 -0000      1.9
773 +++ src/support/userinfo.C      21 Jan 2005 09:43:42 -0000
774 @@ -15,7 +15,9 @@
775  
776  #include <boost/assert.hpp>
777  
778 -#include <pwd.h>
779 +#ifndef _WIN32
780 +# include <pwd.h>
781 +#endif
782  #ifdef HAVE_UNISTD_H
783  # include <unistd.h>
784  #endif
785 @@ -28,6 +30,7 @@
786  
787  string const user_name()
788  {
789 +#ifndef _WIN32
790         struct passwd * pw(getpwuid(geteuid()));
791         BOOST_ASSERT(pw);
792  
793 @@ -35,6 +38,9 @@
794         if (name.empty())
795                 name = pw->pw_name;
796         return name;
797 +#else
798 +       return "dummy";
799 +#endif
800  }
801  
802