diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-05-31 23:35:20 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-05-31 23:35:20 (GMT) |
commit | 83661bdca4f1a2a203aa03b2d27dfe81bdc23098 (patch) | |
tree | fe3e52b3b4cd2d557f490bfc68c5731d614c538a /win | |
parent | 58260d444e3b5a71fb5d06645d34f42e80d013bf (diff) | |
parent | a7ec180fc75e299b71f6d839da636eff3528a713 (diff) | |
download | tcl-83661bdca4f1a2a203aa03b2d27dfe81bdc23098.zip tcl-83661bdca4f1a2a203aa03b2d27dfe81bdc23098.tar.gz tcl-83661bdca4f1a2a203aa03b2d27dfe81bdc23098.tar.bz2 |
Merge tip-547
Diffstat (limited to 'win')
-rw-r--r-- | win/Makefile.in | 7 | ||||
-rw-r--r-- | win/makefile.vc | 7 | ||||
-rw-r--r-- | win/tclWinFCmd.c | 115 |
3 files changed, 119 insertions, 10 deletions
diff --git a/win/Makefile.in b/win/Makefile.in index faf4b77..af2b6e3 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -383,7 +383,7 @@ TOMMATH_OBJS = \ bn_mp_exch.${OBJEXT} \ bn_mp_expt_d.${OBJEXT} \ bn_mp_expt_d_ex.${OBJEXT} \ - bn_mp_get_bit.${OBJEXT} \ + bn_s_mp_get_bit.${OBJEXT} \ bn_mp_get_int.${OBJEXT} \ bn_mp_get_long.${OBJEXT} \ bn_mp_get_long_long.${OBJEXT} \ @@ -418,10 +418,7 @@ TOMMATH_OBJS = \ bn_mp_sqrt.${OBJEXT} \ bn_mp_sub.${OBJEXT} \ bn_mp_sub_d.${OBJEXT} \ - bn_mp_tc_and.${OBJEXT} \ - bn_mp_tc_div_2d.${OBJEXT} \ - bn_mp_tc_or.${OBJEXT} \ - bn_mp_tc_xor.${OBJEXT} \ + bn_mp_signed_rsh.${OBJEXT} \ bn_mp_to_unsigned_bin.${OBJEXT} \ bn_mp_to_unsigned_bin_n.${OBJEXT} \ bn_mp_toom_mul.${OBJEXT} \ diff --git a/win/makefile.vc b/win/makefile.vc index e159538..44af015 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -275,7 +275,7 @@ TOMMATHOBJS = \ $(TMP_DIR)\bn_mp_exch.obj \
$(TMP_DIR)\bn_mp_expt_d.obj \
$(TMP_DIR)\bn_mp_expt_d_ex.obj \
- $(TMP_DIR)\bn_mp_get_bit.obj \
+ $(TMP_DIR)\bn_s_mp_get_bit.obj \
$(TMP_DIR)\bn_mp_get_int.obj \
$(TMP_DIR)\bn_mp_get_long.obj \
$(TMP_DIR)\bn_mp_get_long_long.obj \
@@ -310,10 +310,7 @@ TOMMATHOBJS = \ $(TMP_DIR)\bn_mp_sqrt.obj \
$(TMP_DIR)\bn_mp_sub.obj \
$(TMP_DIR)\bn_mp_sub_d.obj \
- $(TMP_DIR)\bn_mp_tc_and.obj \
- $(TMP_DIR)\bn_mp_tc_div_2d.obj \
- $(TMP_DIR)\bn_mp_tc_or.obj \
- $(TMP_DIR)\bn_mp_tc_xor.obj \
+ $(TMP_DIR)\bn_mp_signed_rsh.obj \
$(TMP_DIR)\bn_mp_to_unsigned_bin.obj \
$(TMP_DIR)\bn_mp_to_unsigned_bin_n.obj \
$(TMP_DIR)\bn_mp_toom_mul.obj \
diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c index e8863dc..dbf2738 100644 --- a/win/tclWinFCmd.c +++ b/win/tclWinFCmd.c @@ -1969,6 +1969,121 @@ TclpObjListVolumes(void) } /* + *---------------------------------------------------------------------- + * + * TclpCreateTemporaryDirectory -- + * + * Creates a temporary directory, possibly based on the supplied bits and + * pieces of template supplied in the arguments. + * + * Results: + * An object (refcount 0) containing the name of the newly-created + * directory, or NULL on failure. + * + * Side effects: + * Accesses the native filesystem. Makes a directory. + * + *---------------------------------------------------------------------- + */ + +Tcl_Obj * +TclpCreateTemporaryDirectory( + Tcl_Obj *dirObj, + Tcl_Obj *basenameObj) +{ + Tcl_DString base, name; /* Contains WCHARs */ + int baseLen; + DWORD error; + WCHAR tempBuf[MAX_PATH + 1]; + DWORD len = GetTempPathW(MAX_PATH, tempBuf); + + /* + * Build the path in writable memory from the user-supplied pieces and + * some defaults. First, the parent temporary directory. + */ + + if (dirObj) { + Tcl_GetString(dirObj); + if (dirObj->length < 1) { + goto useSystemTemp; + } + Tcl_WinUtfToTChar(Tcl_GetString(dirObj), -1, &base); + if (dirObj->bytes[dirObj->length - 1] != '\\') { + TclUtfToWCharDString("\\", -1, &base); + } + } else { + useSystemTemp: + Tcl_DStringInit(&base); + Tcl_DStringAppend(&base, (char *) tempBuf, len * sizeof(WCHAR)); + } + + /* + * Next, the base of the directory name. + */ + +#define DEFAULT_TEMP_DIR_PREFIX "tcl" +#define SUFFIX_LENGTH 8 + + if (basenameObj) { + Tcl_WinUtfToTChar(Tcl_GetString(basenameObj), -1, &name); + TclDStringAppendDString(&base, &name); + Tcl_DStringFree(&name); + } else { + TclUtfToWCharDString(DEFAULT_TEMP_DIR_PREFIX, -1, &base); + } + TclUtfToWCharDString("_", -1, &base); + + /* + * Now we keep on trying random suffixes until we get one that works + * (i.e., that doesn't trigger the ERROR_ALREADY_EXISTS error). Note that + * SUFFIX_LENGTH is longer than on Unix because we expect to be not on a + * case-sensitive filesystem. + */ + + baseLen = Tcl_DStringLength(&base); + do { + char tempbuf[SUFFIX_LENGTH + 1]; + int i; + static const char randChars[] = + "QWERTYUIOPASDFGHJKLZXCVBNM1234567890"; + static const int numRandChars = sizeof(randChars) - 1; + + /* + * Put a random suffix on the end. + */ + + error = ERROR_SUCCESS; + tempbuf[SUFFIX_LENGTH] = '\0'; + for (i = 0 ; i < SUFFIX_LENGTH; i++) { + tempbuf[i] = randChars[(int) (rand() % numRandChars)]; + } + Tcl_DStringSetLength(&base, baseLen); + TclUtfToWCharDString(tempbuf, -1, &base); + } while (!CreateDirectoryW((LPCWSTR) Tcl_DStringValue(&base), NULL) + && (error = GetLastError()) == ERROR_ALREADY_EXISTS); + + /* + * Check for other errors. The big ones are ERROR_PATH_NOT_FOUND and + * ERROR_ACCESS_DENIED. + */ + + if (error != ERROR_SUCCESS) { + TclWinConvertError(error); + Tcl_DStringFree(&base); + return NULL; + } + + /* + * We actually made the directory, so we're done! Report what we made back + * as a (clean) Tcl_Obj. + */ + + Tcl_WinTCharToUtf((LPCWSTR) Tcl_DStringValue(&base), -1, &name); + Tcl_DStringFree(&base); + return TclDStringToObj(&name); +} + +/* * Local Variables: * mode: c * c-basic-offset: 4 |