3.1.1 win32 src

From: Jay Krell <jay.krell_at_cornell.edu>
Date: Sat, 28 Sep 1996 06:20:17 -0400

I don't have anything working yet, but here are some
Win32 source tips for 3.1.1:

in unix.c:

The code that finds files treats DWORD GetLastErrror()
as a string. Try
    if (handle == INVALID_HANDLE_VALUE) {
#define JAYK_X(x) # x
#define JAYK_Y(x) JAYK_X(x)
          char nbuf[sizeof(JAYK_Y(UINT_MAX))];
#undef JAYK_Y
#undef JAYK_X
          sprintf(nbuf, "%lu", (unsigned long) GetLastError());
          Err("Cannot find files, error = ", STk_makestring(nbuf));


Further down the compiler flags a wrong level of indirection warning
or error when an array of char is treated as a char, so I believe
the line
      if ((wfd.cFileName == '.') && (*rem != '.')) continue;
should be
      if ((wfd.cFileName[0] == '.') && (*rem != '.')) continue;

Also, according to the docs, if you #include <process.h>,
you can use _getpid as a replacement or getpid, possibly this is
specific to msvc.

And, tilde expansion can be done like this, again, it's doced but
I can't build yet (problems linking with Tcl):

In the Win32 include section at the top, I have like

#define WIN32_EXTRA_LEAN /* include fewer files */
#define WIN32_LEAN_AND_MEAN /* include fewer files */
#include <limits.h>
#include <process.h>
#define getpid _getpid
#include <windows.h>

change #ifdef MSC_VER to #ifdef _MSC_VER and then:

static char *tilde_expand(char *name, char *result)
    char *dir, *p;

  if (name[0] != '~') {
    strcpy(result, name);
    return name;
#ifdef WIN32
  if (name[0] == '~' && (name[1] == '/' || name[1] == '\\' || name[1] == '\0'))
        const int max_chars = 64; /* 256? do we know? */
        int ignore_length = ExpandEnvironmentStrings("%HOME%", result,
        if (result[0] == '%') {
                Err("couldn't find HOME environment for expanding ",
        return result;
  } else {
        Err("Only default user in tilde expansion presently supported on
Win32.", STk_makestring(result));
  return name;
#else /* same Posix code, but note I moved common code to top. */

Pardon the formatting, Netscape doesn't like newlines anf horizontal
spacing is munged.

In the makefile, I had to change stuff like
CC = cl -nologo
CC=cl -nologo

Using msvc 4.0 here..

Are those uses of Err and STk_makestring correct?

 - Jay, jay.krell_at_cornell.edu
Received on Sat Sep 28 1996 - 15:17:26 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST