[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

[MD:1071]script execution on 1.03a3



堀口です.

 call-process/start-process でのスクリプト実行関係の修正および プ
ログラム(スクリプト)ファイル名, INFILE, STDERR-FILE などのパラメー
タにマルチバイト文字を入れても正しく動作するようにする修正です.
 1.03a3 からの差分です.(多分..)

 内部的には ENCODE_FILE を使ってしまっていますがかまわないでしょ
うか?

At 08 Mar 1999 16:44:07 +0900, Miyashita Hisashi(宮下 尚:HIMI) <himi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in <u1zj0e88o.fsf@xxxxxxxxxxxxxxxxx>
> >   b) call-process/start-process の中で openp が nil を返したとき
> >     は再度 opnep(!exec_only)を行って処理を続行する.
> 
> ううむ、はじめから!exec_onlyで呼び出したほうがよさそうですね。
> どうせ、exec_onlyで呼び出したときに tを返すものは!exec_onlyでも
> tを返しますからね。

 というわけでずいぶんシンプルになりました. 簡単に確認をしたら同じ
名前のスクリプトと exe とでは実行順序(というか検出順序)は exe が
優先になってますね. いまのところ問題なし.

 あと, openp は exec_only 出ないときは fd を返していて, これを放っ
ておくとどんどん資源をガメていってしまうのでその場で close するよ
うにしています.

# meadow で (call-process) したファイルの名前が変えられなくなるこ
# とで気づいたのですが..

> ## ついでにChangeLog.Meadowも^^;;;

 むむ? わたしの怪しい英語でよろしければとりあえず書いてみました.
--
堀口恭太郎
*** callproc.c.org	Wed Feb 24 18:49:48 1999
--- callproc.c	Mon Mar 08 21:59:54 1999
***************
*** 383,388 ****
--- 383,389 ----
  
    display = nargs >= 4 ? args[3] : Qnil;
  
+   infile = ENCODE_FILE (infile);
    filefd = open (XSTRING (infile)->data, O_RDONLY, 0);
    if (filefd < 0)
      {
***************
*** 393,409 ****
      struct gcpro gcpro1;
  
      GCPRO1 (current_dir);
      openp (Vexec_path, args[0], EXEC_SUFFIXES, &path, 1);
      UNGCPRO;
    }
    if (NILP (path))
      {
- #ifndef MEADOW /* For argument editing, check it later. */
        close (filefd);
        report_file_error ("Searching for program", Fcons (args[0], Qnil));
- #else
-       path = args[0];
- #endif
      }
    new_argv[0] = XSTRING (path)->data;
    if (nargs > 4)
--- 394,412 ----
      struct gcpro gcpro1;
  
      GCPRO1 (current_dir);
+ #ifndef MEADOW
      openp (Vexec_path, args[0], EXEC_SUFFIXES, &path, 1);
+ #else
+     /* for script execution on MSWindows, not apply exec_only for openp */
+     /* openp without exec_only returns fd not used, free it immediately */
+     close(openp (Vexec_path, args[0], EXEC_SUFFIXES, &path, 0));
+ #endif
      UNGCPRO;
    }
    if (NILP (path))
      {
        close (filefd);
        report_file_error ("Searching for program", Fcons (args[0], Qnil));
      }
    new_argv[0] = XSTRING (path)->data;
    if (nargs > 4)
***************
*** 511,516 ****
--- 514,520 ----
      else if (STRINGP (error_file))
        {
  #ifdef DOS_NT
+ 	error_file = ENCODE_FILE (error_file);
  	fd_error = open (XSTRING (error_file)->data,
  			 O_WRONLY | O_TRUNC | O_CREAT | O_TEXT,
  			 S_IREAD | S_IWRITE);
*** process.c.org	Thu Feb 04 15:43:36 1999
--- process.c	Mon Mar 08 21:52:00 1999
***************
*** 1162,1168 ****
--- 1162,1174 ----
  
        tem = Qnil;
        GCPRO4 (name, program, buffer, current_dir);
+ #ifndef MEADOW
        openp (Vexec_path, program, EXEC_SUFFIXES, &tem, 1);
+ #else
+       /* for script execution on Windows, not apply exec_only for openp */
+       /* openp without exec_only returns fd not used, free it immediately */
+       close(openp (Vexec_path, program, EXEC_SUFFIXES, &tem, 0));
+ #endif
        UNGCPRO;
        if (NILP (tem))
  	report_file_error ("Searching for program", Fcons (program, Qnil));
*** w32proc.c.org	Sat Feb 27 19:36:26 1999
--- w32proc.c	Mon Mar 08 21:54:16 1999
***************
*** 859,864 ****
--- 859,865 ----
        struct gcpro gcpro1;
  
        GCPRO1 (program);
+ #ifndef MEADOW
        openp (Vexec_path, program, EXEC_SUFFIXES, &full, 1);
        UNGCPRO;
        if (NILP (full))
***************
*** 868,875 ****
  	    errno = ENOEXEC;
  	  return -1;
  	}
      }
! 
      unixtodos_filename(cmdname);
    }
  #else /* not MEADOW */
--- 869,883 ----
  	    errno = ENOEXEC;
  	  return -1;
  	}
+ #else
+       /* for script execution on Windows, not apply exec_only for openp */
+       /* openp without exec_only returns fd not used, free it immediately */
+       close(openp (Vexec_path, program, EXEC_SUFFIXES, &full, 0));
+       UNGCPRO;
+       if (NILP (full))
+ 	  return -1;
      }
! #endif
      unixtodos_filename(cmdname);
    }
  #else /* not MEADOW */
*** lread.c.org	Thu Feb 04 15:43:28 1999
--- lread.c	Mon Mar 08 21:45:06 1999
***************
*** 35,40 ****
--- 35,41 ----
  #include "commands.h"
  #include "keyboard.h"
  #include "termhooks.h"
+ #include "coding.h"
  #endif
  
  #ifdef lint
***************
*** 882,887 ****
--- 883,889 ----
  	    continue;
  	}
  
+       filename = ENCODE_FILE (filename);
        /* Calculate maximum size of any filename made from
  	 this path element/specified file name and any possible suffix.  */
        want_size = strlen (suffix) + XSTRING (filename)->size + 1;
*** ChangeLog.Meadow.org	Sat Feb 27 01:17:24 1999
--- ChangeLog.Meadow	Mon Mar 08 22:06:48 1999
***************
*** 1,3 ****
--- 1,18 ----
+ 1999-03-08  Horiguchi Kyotaro  <kyota@xxxxxxxxxxxxx>
+ 
+ 	* callproc.c (Fcall_process), process.c (Fstart_process)
+           w32proc.c (sys_spawnve), 
+ 	PROGRAM, INFILE, STDERR-FILE and cmdname are allowed to be a
+ 	string containing mutibyte characters (Using ENCODE_FILE to encode
+ 	string)
+         For argument editing, any program pathes are allowed to pass
+ 	argument editing program. (Changes on 1999-02-24 has been vanished
+ 	without aware?)
+ 
+ 	* lread.c (openp)
+ 	str is allowed to be a string containig multibyte characters. This
+ 	change allows to check files correctly whose names are such strings.
+ 
  1999-02-28  Miyashita Hisashi  <himi@xxxxxxxxxxxxxxxxxxxxxxxxx>
  
  	* w32.c (w32_get_long_filename):