[Ttssh2-commit] [7685] エラー種別を追加

scmno****@osdn***** scmno****@osdn*****
2019年 5月 18日 (土) 00:06:06 JST


Revision: 7685
          https://osdn.net/projects/ttssh2/scm/svn/commits/7685
Author:   zmatsuo
Date:     2019-05-18 00:06:06 +0900 (Sat, 18 May 2019)
Log Message:
-----------
エラー種別を追加

- exec コマンド実行失敗時 Can't execute command.

Modified Paths:
--------------
    trunk/teraterm/ttpmacro/errdlg.cpp
    trunk/teraterm/ttpmacro/errdlg.h
    trunk/teraterm/ttpmacro/ttl.c
    trunk/teraterm/ttpmacro/ttmdlg.cpp
    trunk/teraterm/ttpmacro/ttmdlg.h
    trunk/teraterm/ttpmacro/ttmparse.c
    trunk/teraterm/ttpmacro/ttmparse.h

-------------- next part --------------
Modified: trunk/teraterm/ttpmacro/errdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/errdlg.cpp	2019-05-16 15:22:07 UTC (rev 7684)
+++ trunk/teraterm/ttpmacro/errdlg.cpp	2019-05-17 15:06:06 UTC (rev 7685)
@@ -49,7 +49,7 @@
 
 // CErrDlg dialog
 
-CErrDlg::CErrDlg(PCHAR Msg, PCHAR Line, int x, int y, int lineno, int start, int end, PCHAR FileName)
+CErrDlg::CErrDlg(const char *Msg, PCHAR Line, int x, int y, int lineno, int start, int end, PCHAR FileName)
 {
 	MsgStr = Msg;
 	LineStr = Line;

Modified: trunk/teraterm/ttpmacro/errdlg.h
===================================================================
--- trunk/teraterm/ttpmacro/errdlg.h	2019-05-16 15:22:07 UTC (rev 7684)
+++ trunk/teraterm/ttpmacro/errdlg.h	2019-05-17 15:06:06 UTC (rev 7685)
@@ -35,13 +35,14 @@
 class CErrDlg : public TTCDialog
 {
 public:
-	CErrDlg(PCHAR Msg, PCHAR Line, int x, int y, int lineno, int start, int end, PCHAR FileName);
+	CErrDlg(const char *Msg, PCHAR Line, int x, int y, int lineno, int start, int end, PCHAR FileName);
 	INT_PTR DoModal();
 
 private:
 	enum { IDD = IDD_ERRDLG };
 
-	PCHAR MsgStr, LineStr;
+	const char* MsgStr;
+	PCHAR LineStr;
 	int PosX, PosY;
 	int LineNo;
 	int StartPos, EndPos;

Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2019-05-16 15:22:07 UTC (rev 7684)
+++ trunk/teraterm/ttpmacro/ttl.c	2019-05-17 15:06:06 UTC (rev 7685)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2005-2018 TeraTerm Project
+ * (C) 2005-2019 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1239,11 +1239,14 @@
 		bRet = CreateProcess(NULL, Str, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &sui, &pi);
 	else
 		bRet = CreateProcess(NULL, Str, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, CurDir, &sui, &pi);
-	// TODO: check bRet
-	if (wait) {
-		WaitForSingleObject(pi.hProcess, INFINITE);
-		GetExitCodeProcess(pi.hProcess, &ret);
-		SetResult(ret);
+	if (bRet == FALSE) {
+		Err = ErrCantExec;
+	} else {
+		if (wait) {
+			WaitForSingleObject(pi.hProcess, INFINITE);
+			GetExitCodeProcess(pi.hProcess, &ret);
+			SetResult(ret);
+		}
 	}
 	return Err;
 }

Modified: trunk/teraterm/ttpmacro/ttmdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/ttmdlg.cpp	2019-05-16 15:22:07 UTC (rev 7684)
+++ trunk/teraterm/ttpmacro/ttmdlg.cpp	2019-05-17 15:06:06 UTC (rev 7685)
@@ -229,7 +229,7 @@
 	InpDlg.DoModal();
 }
 
-int OpenErrDlg(PCHAR Msg, PCHAR Line, int lineno, int start, int end, PCHAR FileName)
+int OpenErrDlg(const char *Msg, PCHAR Line, int lineno, int start, int end, PCHAR FileName)
 {
 	CErrDlg ErrDlg(Msg,Line,DlgPosX,DlgPosY, lineno, start, end, FileName);
 	return ErrDlg.DoModal();

Modified: trunk/teraterm/ttpmacro/ttmdlg.h
===================================================================
--- trunk/teraterm/ttpmacro/ttmdlg.h	2019-05-16 15:22:07 UTC (rev 7684)
+++ trunk/teraterm/ttpmacro/ttmdlg.h	2019-05-17 15:06:06 UTC (rev 7685)
@@ -42,7 +42,7 @@
 void SetDlgPos(int x, int y);
 void OpenInpDlg(PCHAR Buff, PCHAR Text, PCHAR Caption,
                 PCHAR Default, BOOL Paswd);
-int OpenErrDlg(PCHAR Msg, PCHAR Line, int lineno, int start, int end, PCHAR FileName);
+int OpenErrDlg(const char *Msg, PCHAR Line, int lineno, int start, int end, PCHAR FileName);
 int OpenMsgDlg(PCHAR Text, PCHAR Caption, BOOL YesNo);
 void OpenStatDlg(PCHAR Text, PCHAR Caption);
 void CloseStatDlg();

Modified: trunk/teraterm/ttpmacro/ttmparse.c
===================================================================
--- trunk/teraterm/ttpmacro/ttmparse.c	2019-05-16 15:22:07 UTC (rev 7684)
+++ trunk/teraterm/ttpmacro/ttmparse.c	2019-05-17 15:06:06 UTC (rev 7685)
@@ -126,35 +126,35 @@
 
 void DispErr(WORD Err)
 {
-	char Msg[41];
+	const char *Msg;
 	int i;
 	int no, start, end;
 	char *filename;
 
-	strncpy_s(Msg, sizeof(Msg), "Unknown error message number.", _TRUNCATE);
-
 	switch (Err) {
-		case ErrCloseParent: strncpy_s(Msg, sizeof(Msg),"\")\" expected.", _TRUNCATE); break;
-		case ErrCantCall: strncpy_s(Msg, sizeof(Msg),"Can't call sub.", _TRUNCATE); break;
-		case ErrCantConnect: strncpy_s(Msg, sizeof(Msg),"Can't link macro.", _TRUNCATE); break;
-		case ErrCantOpen: strncpy_s(Msg, sizeof(Msg),"Can't open file.", _TRUNCATE); break;
-		case ErrDivByZero: strncpy_s(Msg, sizeof(Msg),"Divide by zero.", _TRUNCATE); break;
-		case ErrInvalidCtl: strncpy_s(Msg, sizeof(Msg),"Invalid control.", _TRUNCATE); break;
-		case ErrLabelAlreadyDef: strncpy_s(Msg, sizeof(Msg),"Label already defined.", _TRUNCATE); break;
-		case ErrLabelReq: strncpy_s(Msg, sizeof(Msg),"Label requiered.", _TRUNCATE); break;
-		case ErrLinkFirst: strncpy_s(Msg, sizeof(Msg),"Link macro first. Use 'connect' macro.", _TRUNCATE); break;
-		case ErrStackOver: strncpy_s(Msg, sizeof(Msg),"Stack overflow.", _TRUNCATE); break;
-		case ErrSyntax: strncpy_s(Msg, sizeof(Msg),"Syntax error.", _TRUNCATE); break;
-		case ErrTooManyLabels: strncpy_s(Msg, sizeof(Msg),"Too many labels.", _TRUNCATE); break;
-		case ErrTooManyVar: strncpy_s(Msg, sizeof(Msg),"Too many variables.", _TRUNCATE); break;
-		case ErrTypeMismatch: strncpy_s(Msg, sizeof(Msg),"Type mismatch.", _TRUNCATE); break;
-		case ErrVarNotInit: strncpy_s(Msg, sizeof(Msg),"Variable not initialized.", _TRUNCATE); break;
-		case ErrCloseComment: strncpy_s(Msg, sizeof(Msg),"\"*/\" expected.", _TRUNCATE); break;
-		case ErrOutOfRange: strncpy_s(Msg, sizeof(Msg), "Index out of range.", _TRUNCATE); break;
-		case ErrCloseBracket: strncpy_s(Msg, sizeof(Msg), "\"]\" expected.", _TRUNCATE); break;
-		case ErrFewMemory: strncpy_s(Msg, sizeof(Msg), "Can't allocate memory.", _TRUNCATE); break;
-		case ErrNotSupported: strncpy_s(Msg, sizeof(Msg), "Unknown command.", _TRUNCATE); break;
-	}
+		case ErrCloseParent: Msg = "\")\" expected."; break;
+		case ErrCantCall: Msg = "Can't call sub."; break;
+		case ErrCantConnect: Msg = "Can't link macro."; break;
+		case ErrCantOpen: Msg = "Can't open file."; break;
+		case ErrDivByZero: Msg = "Divide by zero."; break;
+		case ErrInvalidCtl: Msg = "Invalid control."; break;
+		case ErrLabelAlreadyDef: Msg = "Label already defined."; break;
+		case ErrLabelReq: Msg = "Label requiered."; break;
+		case ErrLinkFirst: Msg = "Link macro first. Use 'connect' macro."; break;
+		case ErrStackOver: Msg = "Stack overflow."; break;
+		case ErrSyntax: Msg = "Syntax error."; break;
+		case ErrTooManyLabels: Msg = "Too many labels."; break;
+		case ErrTooManyVar: Msg = "Too many variables."; break;
+		case ErrTypeMismatch: Msg = "Type mismatch."; break;
+		case ErrVarNotInit: Msg = "Variable not initialized."; break;
+		case ErrCloseComment: Msg = "\"*/\" expected."; break;
+		case ErrOutOfRange: Msg = "Index out of range."; break;
+		case ErrCloseBracket: Msg = "\"]\" expected."; break;
+		case ErrFewMemory: Msg = "Can't allocate memory."; break;
+		case ErrNotSupported: Msg = "Unknown command."; break;
+		case ErrCantExec: Msg = "Can't execute command."; break;
+		default: Msg = "Unknown error message number."; break;
+	};
 
 	no = GetLineNo();
 	start = LineParsePtr;

Modified: trunk/teraterm/ttpmacro/ttmparse.h
===================================================================
--- trunk/teraterm/ttpmacro/ttmparse.h	2019-05-16 15:22:07 UTC (rev 7684)
+++ trunk/teraterm/ttpmacro/ttmparse.h	2019-05-17 15:06:06 UTC (rev 7685)
@@ -67,6 +67,7 @@
 #define ErrCloseBracket     18
 #define ErrFewMemory        19
 #define ErrNotSupported     20
+#define ErrCantExec         21
 
 #define TypUnknown  0
 #define TypInteger  1


Ttssh2-commit メーリングリストの案内