Revision: 10462 https://osdn.net/projects/ttssh2/scm/svn/commits/10462 Author: zmatsuo Date: 2023-01-08 00:11:54 +0900 (Sun, 08 Jan 2023) Log Message: ----------- DeleteSlashW() を追加 - DeleteSlash() は DeleteSlashW() の wrapper とした - mbctype.h の include が不要となった - _ismbblead() 不要となった - ttxssh.c の mbstring.h も不要なので削除 - Cランタイムのマルチバイト文字に関係する関数は使用していない状態となった Modified Paths: -------------- trunk/teraterm/common/ttlib.c trunk/teraterm/common/ttlib.h trunk/ttssh2/ttxssh/ttxssh.c -------------- next part -------------- Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2023-01-07 13:21:08 UTC (rev 10461) +++ trunk/teraterm/common/ttlib.c 2023-01-07 15:11:54 UTC (rev 10462) @@ -36,7 +36,6 @@ #include <stdio.h> #include <shlobj.h> #include <ctype.h> -#include <mbctype.h> // for _ismbblead #include <assert.h> #include "teraterm.h" @@ -307,21 +306,40 @@ } } -// Delete slashes at the end of a path name -void DeleteSlash(PCHAR Path) +/** + * Delete slashes at the end of a path name + * + * @return \x8Ds\x96\x96\x82\xCC '\' \x82\xAA\x8D폜\x82\xB3\x82ꂽ\x95\xB6\x8E\x9A\x97\xF1 + * \x95s\x97v\x82ɂȂ\xC1\x82\xBD\x82\xE7 free() \x82\xB7\x82邱\x82\xC6 + */ +wchar_t *DeleteSlashW(const wchar_t *Path) { - size_t i; - for (i=strlen(Path)-1; i>=0; i--) { - if (i ==0 && Path[i] == '\\' || - Path[i] == '\\' && !_ismbblead(Path[i-1])) { - Path[i] = '\0'; + wchar_t *s = _wcsdup(Path); + size_t i = wcslen(s); + while(i != 0) { + i--; + if (s[i] == '\\') { + s[i] = '\0'; } else { break; } } + return s; } +// Delete slashes at the end of a path name +void DeleteSlash(PCHAR Path) +{ + wchar_t *PathW = ToWcharA(Path); + wchar_t *deletedW = DeleteSlashW(PathW); + char *deletedA = ToCharW(deletedW); + strcpy(Path, deletedA); + free(deletedA); + free(deletedW); + free(PathW); +} + void Str2Hex(PCHAR Str, PCHAR Hex, int Len, int MaxHexLen, BOOL ConvSP) { BYTE b, low; Modified: trunk/teraterm/common/ttlib.h =================================================================== --- trunk/teraterm/common/ttlib.h 2023-01-07 13:21:08 UTC (rev 10461) +++ trunk/teraterm/common/ttlib.h 2023-01-07 15:11:54 UTC (rev 10462) @@ -61,6 +61,7 @@ void AppendSlash(PCHAR Path, int destlen); void AppendSlashW(wchar_t *Path, size_t destlen); void DeleteSlash(PCHAR Path); +wchar_t *DeleteSlashW(const wchar_t *Path); void Str2Hex(PCHAR Str, PCHAR Hex, int Len, int MaxHexLen, BOOL ConvSP); BYTE ConvHexChar(BYTE b); int Hex2Str(PCHAR Hex, PCHAR Str, int MaxLen); Modified: trunk/ttssh2/ttxssh/ttxssh.c =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.c 2023-01-07 13:21:08 UTC (rev 10461) +++ trunk/ttssh2/ttxssh/ttxssh.c 2023-01-07 15:11:54 UTC (rev 10462) @@ -50,7 +50,6 @@ #include <fcntl.h> #include <sys/stat.h> #include <time.h> -#include <mbstring.h> #include "resource.h" #include <commctrl.h>