diff options
author | Takuji Tanaka <ttk@t-lab.opal.ne.jp> | 2023-09-10 02:06:47 +0000 |
---|---|---|
committer | Takuji Tanaka <ttk@t-lab.opal.ne.jp> | 2023-09-10 02:06:47 +0000 |
commit | dea59360c18830c253ceb0bc238e03e1a6081a11 (patch) | |
tree | 5cc1e977033280a33cd056c30e8c1942a0650289 /Build/source/texk | |
parent | e7808c60820ebf7fbb0f7256ad772d35cb70c8f9 (diff) |
texlive/windows_wrapper: Convert newline from CRLF to LF
git-svn-id: svn://tug.org/texlive/trunk@68228 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk')
11 files changed, 883 insertions, 875 deletions
diff --git a/Build/source/texk/texlive/ChangeLog b/Build/source/texk/texlive/ChangeLog index 48868735a62..28432fb3f06 100644 --- a/Build/source/texk/texlive/ChangeLog +++ b/Build/source/texk/texlive/ChangeLog @@ -1,3 +1,11 @@ +2023-09-10 TANAKA Takuji <ttk@t-lab.opal.ne.jp> + + * windows_wrapper/{calldll,callexe,runscript_dll,runscript_exe, + wrunscript_exe}.c, windows_wrapper/{readme,tlmgr-gui}.txt, + windows_wrapper/context/mtxrun_{dll,exe}.c, + windows_wrapper/context/readme.txt: + Convert newline from CRLF to LF. + 2023-02-28 Luigi Scarso <luigi.scarso@gmail.com> * Makefile.am (EXTRA_DIST): now just windows_wrapper. diff --git a/Build/source/texk/texlive/windows_wrapper/calldll.c b/Build/source/texk/texlive/windows_wrapper/calldll.c index 68646929cdf..ddb17f31055 100644 --- a/Build/source/texk/texlive/windows_wrapper/calldll.c +++ b/Build/source/texk/texlive/windows_wrapper/calldll.c @@ -1,13 +1,13 @@ -/* Public domain.
- * Originally written by Akira Kakuto <kakuto@fuk.kindai.ac.jp>
- *
- * DLL calling main program for TeX & Co
- * DLLPROC must be defined in the Makefile as,
- * e.g., -DDLLPROC=dlltexmain.
- */
-
-__declspec(dllimport) DLLPROC(int ac, char **av);
-int main(int ac, char **av)
-{
- return (DLLPROC(ac, av));
-}
+/* Public domain. + * Originally written by Akira Kakuto <kakuto@fuk.kindai.ac.jp> + * + * DLL calling main program for TeX & Co + * DLLPROC must be defined in the Makefile as, + * e.g., -DDLLPROC=dlltexmain. + */ + +__declspec(dllimport) DLLPROC(int ac, char **av); +int main(int ac, char **av) +{ + return (DLLPROC(ac, av)); +} diff --git a/Build/source/texk/texlive/windows_wrapper/callexe.c b/Build/source/texk/texlive/windows_wrapper/callexe.c index 62e86979bc1..2aa041ea0da 100644 --- a/Build/source/texk/texlive/windows_wrapper/callexe.c +++ b/Build/source/texk/texlive/windows_wrapper/callexe.c @@ -1,43 +1,43 @@ -/* Public domain.
- * Originally written by Akira Kakuto <kakuto@fuk.kindai.ac.jp>
- *
- * WIN32 wrapper program replacing Unix symlinks such as,
- * e.g., ofm2opl -> omfonts.
- *
- * EXEPROG must be defined in the Makefile as,
- * e.g., -DEXEPROG=\"omfonts.exe\".
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <process.h>
-#include <string.h>
-#include <malloc.h>
-
-static int is_include_space(char *s)
-{
- char *p;
- p = strchr(s, ' ');
- if(p) return 1;
- p = strchr(s, '\t');
- if(p) return 1;
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- int i;
- char *p;
-
- for(i = 0; i < argc; i++) {
- if(is_include_space(argv[i])) {
- p = (char *)malloc(strlen(argv[i])+3);
- strcpy(p, "\"");
- strcat(p, argv[i]);
- strcat(p, "\"");
- free(argv[i]);
- argv[i] = p;
- }
- }
- argv[argc] = NULL;
- return _spawnvp(_P_WAIT, EXEPROG, (const char * const *)argv);
-}
+/* Public domain. + * Originally written by Akira Kakuto <kakuto@fuk.kindai.ac.jp> + * + * WIN32 wrapper program replacing Unix symlinks such as, + * e.g., ofm2opl -> omfonts. + * + * EXEPROG must be defined in the Makefile as, + * e.g., -DEXEPROG=\"omfonts.exe\". + */ +#include <stdio.h> +#include <stdlib.h> +#include <process.h> +#include <string.h> +#include <malloc.h> + +static int is_include_space(char *s) +{ + char *p; + p = strchr(s, ' '); + if(p) return 1; + p = strchr(s, '\t'); + if(p) return 1; + return 0; +} + +int main(int argc, char *argv[]) +{ + int i; + char *p; + + for(i = 0; i < argc; i++) { + if(is_include_space(argv[i])) { + p = (char *)malloc(strlen(argv[i])+3); + strcpy(p, "\""); + strcat(p, argv[i]); + strcat(p, "\""); + free(argv[i]); + argv[i] = p; + } + } + argv[argc] = NULL; + return _spawnvp(_P_WAIT, EXEPROG, (const char * const *)argv); +} diff --git a/Build/source/texk/texlive/windows_wrapper/context/mtxrun_dll.c b/Build/source/texk/texlive/windows_wrapper/context/mtxrun_dll.c index f5688c71870..fc2e260f5a2 100644 --- a/Build/source/texk/texlive/windows_wrapper/context/mtxrun_dll.c +++ b/Build/source/texk/texlive/windows_wrapper/context/mtxrun_dll.c @@ -1,306 +1,306 @@ -/************************************************************************
-
- Copyright:
-
- Public Domain
- Originally written in 2010 by Tomasz M. Trzeciak and Hans Hagen
-
- This program is derived from the 'runscript' program originally
- written in 2009 by T.M. Trzeciak. It has been adapted for use in
- ConTeXt MkIV.
-
- Comment:
-
- In ConTeXt MkIV we have two core scripts: luatools.lua and
- mtxrun.lua where the second one is used to launch other scripts.
- Normally a user will use a call like:
-
- mtxrun --script font --reload
-
- Here mtxrun is a lua script. In order to avoid the usage of a cmd
- file on windows this runner will start texlua directly. If the
- shared library luatex.dll is available, texlua will be started in
- the same process avoiding thus any additional overhead. Otherwise
- it will be spawned in a new proces.
-
- We also don't want to use other runners, like those that use kpse
- to locate the script as this is exactly what mtxrun itself is doing
- already. Therefore the runscript program is adapted to a more direct
- approach suitable for mtxrun.
-
- Compilation:
-
- with gcc (size optimized):
-
- gcc -Os -s -shared -o mtxrun.dll mtxrun_dll.c
- gcc -Os -s -o mtxrun.exe mtxrun_exe.c -L./ -lmtxrun
-
- with tcc (extra small size):
-
- tcc -shared -o mtxrun.dll mtxrun_dll.c
- tcc -o mtxrun.exe mtxrun_exe.c mtxrun.def
-
-************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-
-//#define STATIC
-#define IS_WHITESPACE(c) ((c == ' ') || (c == '\t'))
-#define MAX_CMD 32768
-#define DIE(...) { \
- fprintf( stderr, "mtxrun: " ); \
- fprintf( stderr, __VA_ARGS__ ); \
- return 1; \
-}
-
-static char cmdline[MAX_CMD];
-static char dirpath[MAX_PATH];
-static char progname[MAX_PATH];
-static char scriptpath[MAX_PATH];
-static char luatexpath[MAX_PATH];
-HMODULE dllluatex = NULL;
-typedef int ( *mainlikeproc )( int, char ** );
-
-#ifdef STATIC
-int main( int argc, char *argv[] )
-#else
-__declspec(dllexport) int dllrunscript( int argc, char *argv[] )
-#endif
-{
- char *binary, *s, *luatexfname, *argstr, **lua_argv;
- int k, quoted, lua_argc;
- int passprogname = 0;
- unsigned char is_jit=0;
-
- // directory of this module/executable
- HMODULE module_handle = GetModuleHandle( "mtxrun.dll" );
- // if ( module_handle == NULL ) exe path will be used, which is OK too
- k = (int) GetModuleFileName( module_handle, dirpath, MAX_PATH );
- if ( !k || ( k == MAX_PATH ) )
- DIE( "unable to determine a valid module name\n" );
- s = strrchr(dirpath, '\\');
- if ( s == NULL ) DIE( "no directory part in module path: %s\n", dirpath );
- *(++s) = '\0'; //remove file name, leave trailing backslash
-
- // program name
- k = strlen(argv[0]);
- while ( k && (argv[0][k-1] != '/') && (argv[0][k-1] != '\\') ) k--;
- strcpy(progname, &argv[0][k]);
- s = progname;
- if ( s = strrchr(s, '.') ) *s = '\0'; // remove file extension part
-
- /* check "jit" : strlen("jit") = 3 */
- if (strncmp(progname + strlen(progname) - 3, "jit", 3) == 0) {
- is_jit = 1;
- progname[strlen(progname) - 3]='\0';
- }
- else
- is_jit = 0;
-
- // script path
-
- strcpy( scriptpath, dirpath );
- k = strlen(progname);
- if ( k < 6 ) k = 6; // in case the program name is shorter than "mtxrun"
- if ( strlen(dirpath) + k + 4 >= MAX_PATH )
- DIE( "path too long: %s%s\n", dirpath, progname );
-
- if ( strcmpi(progname,"mtxrun") == 0 ) {
- strcat( scriptpath, progname );
- strcat( scriptpath, ".lua" );
- } else if ( strcmpi(progname,"luatools") == 0 ) {
- strcat( scriptpath, "mtxrun.lua" );
- strcpy( progname, "base" );
- passprogname = 1;
- } else if ( strcmpi(progname,"texmfstart") == 0 ) {
- strcat( scriptpath, "mtxrun.lua" );
- } else {
- strcat( scriptpath, "mtxrun.lua" );
- passprogname = 1;
- }
- if ( GetFileAttributes(scriptpath) == INVALID_FILE_ATTRIBUTES )
- DIE( "file not found: %s\n", scriptpath );
-
- // find luatex.exe /luajittex.exe
- if ( SearchPath(
- dirpath, // was getenv( "PATH" ), // path to search (optional)
- (is_jit ? "luajittex.exe":"luatex.exe"), // file name to search
- NULL, // file extension to add (optional)
- MAX_PATH, // output buffer size
- luatexpath, // output buffer pointer
- &luatexfname ) // pointer to a file part in the output buffer (optional)
- ) {
- binary = (is_jit ? "luajittex.exe":"luatex.exe");
- } else if ( SearchPath(
- dirpath, // was getenv( "PATH" ), // path to search (optional)
- (is_jit ? "texluajit.exe":"texlua.exe"), // file name to search
- NULL, // file extension to add (optional)
- MAX_PATH, // output buffer size
- luatexpath, // output buffer pointer
- &luatexfname ) // pointer to a file part in the output buffer (optional)
- ) {
- binary = (is_jit ? "texluajit.exe":"texlua.exe");
- } else if ( SearchPath(
- getenv("PATH"), // was dirpath, // path to search (optional)
- (is_jit ? "luajittex.exe":"luatex.exe"), // file name to search
- NULL, // file extension to add (optional)
- MAX_PATH, // output buffer size
- luatexpath, // output buffer pointer
- &luatexfname ) // pointer to a file part in the output buffer (optional)
- ) {
- binary = (is_jit ? "luajittex.exe":"luatex.exe");
- } else if ( SearchPath(
- getenv("PATH") , // was dirpath, // path to search (optional)
- (is_jit ? "texluajit.exe":"texlua.exe"), // file name to search
- NULL, // file extension to add (optional)
- MAX_PATH, // output buffer size
- luatexpath, // output buffer pointer
- &luatexfname ) // pointer to a file part in the output buffer (optional)
- ) {
- binary = (is_jit ? "texluajit.exe":"texlua.exe");
- }else {
- DIE( "unable to locate texlua.exe on the search path" );
- }
-
- /* if ( SearchPath( */
- /* dirpath, // was getenv( "PATH" ), // path to search (optional) */
- /* (is_jit ? "luajittex.exe":"luatex.exe"), // file name to search */
- /* NULL, // file extension to add (optional) */
- /* MAX_PATH, // output buffer size */
- /* luatexpath, // output buffer pointer */
- /* &luatexfname ) // pointer to a file part in the output buffer (optional) */
- /* ) { */
- /* binary = (is_jit ? "luajittex.exe":"luatex.exe"); */
- /* }else if ( SearchPath( */
- /* getenv("PATH"), // was dirpath, // path to search (optional) */
- /* (is_jit ? "luajittex.exe":"luatex.exe"), // file name to search */
- /* NULL, // file extension to add (optional) */
- /* MAX_PATH, // output buffer size */
- /* luatexpath, // output buffer pointer */
- /* &luatexfname ) // pointer to a file part in the output buffer (optional) */
- /* ) { */
- /* binary = (is_jit ? "luajittex.exe":"luatex.exe"); */
- /* }else if ( SearchPath( */
- /* dirpath, // was getenv( "PATH" ), // path to search (optional) */
- /* (is_jit ? "texluajit.exe":"texlua.exe"), // file name to search */
- /* NULL, // file extension to add (optional) */
- /* MAX_PATH, // output buffer size */
- /* luatexpath, // output buffer pointer */
- /* &luatexfname ) // pointer to a file part in the output buffer (optional) */
- /* ) { */
- /* binary = (is_jit ? "texluajit.exe":"texlua.exe"); */
- /* }else if ( SearchPath( */
- /* getenv("PATH") , // was dirpath, // path to search (optional) */
- /* (is_jit ? "texluajit.exe":"texlua.exe"), // file name to search */
- /* NULL, // file extension to add (optional) */
- /* MAX_PATH, // output buffer size */
- /* luatexpath, // output buffer pointer */
- /* &luatexfname ) // pointer to a file part in the output buffer (optional) */
- /* ) { */
- /* binary = (is_jit ? "texluajit.exe":"texlua.exe"); */
- /* }else { */
- /* DIE( "unable to locate texlua.exe on the search path" ); */
- /* } */
-
-
-
-
- // link directly with luatex.dll if available in texlua's dir
- strcpy( luatexfname, (is_jit ? "luajittex.dll":"luatex.dll") );
- if ( dllluatex = LoadLibrary(luatexpath) )
- {
- mainlikeproc dllluatexmain = (mainlikeproc) GetProcAddress( dllluatex, (is_jit ? "dllluajittexmain": "dllluatexmain" ));
- if ( dllluatexmain == NULL )
- if (is_jit)
- DIE( "unable to locate dllluatexmain procedure in luajittex.dll" )
- else
- DIE( "unable to locate dllluatexmain procedure in luatex.dll" );
-
- // set up argument list for texlua script
-
- lua_argv = (char **)malloc( (argc + 5) * sizeof(char *) );
- if ( lua_argv == NULL ) DIE( "out of memory\n" );
- lua_argv[lua_argc=0] = luatexfname;
- lua_argv[++lua_argc] = "--luaonly";
- lua_argv[++lua_argc] = scriptpath; // script to execute
- if (passprogname) {
- lua_argv[++lua_argc] = "--script";
- lua_argv[++lua_argc] = progname;
- }
- for ( k = 1; k < argc; k++ ) lua_argv[++lua_argc] = argv[k];
- lua_argv[++lua_argc] = NULL;
-
- // call texlua interpreter
- // dllluatexmain never returns, but we pretend that it does
-
- k = dllluatexmain( lua_argc, lua_argv );
- if (lua_argv) free( lua_argv );
- return k;
- }
- // we are still here, so no luatex.dll; spawn texlua.exe instead
-
- strcpy( luatexfname,binary);
- strcpy( cmdline, " --luaonly " );
- strcpy( cmdline, "\"" );
- strcat( cmdline, luatexpath );
- strcat( cmdline, "\" \"" );
- strcat( cmdline, scriptpath );
- strcat( cmdline, "\"" );
- if (passprogname) {
- strcat( cmdline, " --script " );
- strcat( cmdline, progname );
- }
- argstr = GetCommandLine(); // get the command line of this process
- if ( argstr == NULL ) DIE( "unable to retrieve the command line string\n" );
-
- // skip over argv[0] in the argument string
- // (it can contain embedded double quotes if launched from cmd.exe!)
-
- for ( quoted = 0; (*argstr) && ( !IS_WHITESPACE(*argstr) || quoted ); argstr++ )
- if (*argstr == '"') quoted = !quoted;
-
- // pass through all the arguments
-
- if ( strlen(cmdline) + strlen(argstr) >= MAX_CMD )
- DIE( "command line string too long:\n%s%s\n", cmdline, argstr );
- strcat( cmdline, argstr );
-
- // create child process
-
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- ZeroMemory( &si, sizeof(si) );
- si.cb = sizeof(si);
- si.dwFlags = STARTF_USESTDHANDLES;// | STARTF_USESHOWWINDOW;
- //si.dwFlags = STARTF_USESHOWWINDOW;
- //si.wShowWindow = SW_HIDE ; // can be used to hide console window (requires STARTF_USESHOWWINDOW flag)
- si.hStdInput = GetStdHandle( STD_INPUT_HANDLE );
- si.hStdOutput = GetStdHandle( STD_OUTPUT_HANDLE );
- si.hStdError = GetStdHandle( STD_ERROR_HANDLE );
- ZeroMemory( &pi, sizeof(pi) );
- if( !CreateProcess(
- NULL, // module name (uses command line if NULL)
- cmdline, // command line
- NULL, // process security atrributes
- NULL, // thread security atrributes
- TRUE, // handle inheritance
- 0, // creation flags, e.g. CREATE_NEW_CONSOLE, CREATE_NO_WINDOW, DETACHED_PROCESS
- NULL, // pointer to environment block (uses parent if NULL)
- NULL, // starting directory (uses parent if NULL)
- &si, // STARTUPINFO structure
- &pi ) // PROCESS_INFORMATION structure
- ) DIE( "command execution failed: %s\n", cmdline );
- DWORD ret = 0;
- CloseHandle( pi.hThread ); // thread handle is not needed
- if ( WaitForSingleObject( pi.hProcess, INFINITE ) == WAIT_OBJECT_0 ) {
- if ( !GetExitCodeProcess( pi.hProcess, &ret) )
- DIE( "unable to retrieve process exit code: %s\n", cmdline );
- } else DIE( "failed to wait for process termination: %s\n", cmdline );
- CloseHandle( pi.hProcess );
-
- // propagate exit code from the child process
- return ret;
-
-}
+/************************************************************************ + + Copyright: + + Public Domain + Originally written in 2010 by Tomasz M. Trzeciak and Hans Hagen + + This program is derived from the 'runscript' program originally + written in 2009 by T.M. Trzeciak. It has been adapted for use in + ConTeXt MkIV. + + Comment: + + In ConTeXt MkIV we have two core scripts: luatools.lua and + mtxrun.lua where the second one is used to launch other scripts. + Normally a user will use a call like: + + mtxrun --script font --reload + + Here mtxrun is a lua script. In order to avoid the usage of a cmd + file on windows this runner will start texlua directly. If the + shared library luatex.dll is available, texlua will be started in + the same process avoiding thus any additional overhead. Otherwise + it will be spawned in a new proces. + + We also don't want to use other runners, like those that use kpse + to locate the script as this is exactly what mtxrun itself is doing + already. Therefore the runscript program is adapted to a more direct + approach suitable for mtxrun. + + Compilation: + + with gcc (size optimized): + + gcc -Os -s -shared -o mtxrun.dll mtxrun_dll.c + gcc -Os -s -o mtxrun.exe mtxrun_exe.c -L./ -lmtxrun + + with tcc (extra small size): + + tcc -shared -o mtxrun.dll mtxrun_dll.c + tcc -o mtxrun.exe mtxrun_exe.c mtxrun.def + +************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <windows.h> + +//#define STATIC +#define IS_WHITESPACE(c) ((c == ' ') || (c == '\t')) +#define MAX_CMD 32768 +#define DIE(...) { \ + fprintf( stderr, "mtxrun: " ); \ + fprintf( stderr, __VA_ARGS__ ); \ + return 1; \ +} + +static char cmdline[MAX_CMD]; +static char dirpath[MAX_PATH]; +static char progname[MAX_PATH]; +static char scriptpath[MAX_PATH]; +static char luatexpath[MAX_PATH]; +HMODULE dllluatex = NULL; +typedef int ( *mainlikeproc )( int, char ** ); + +#ifdef STATIC +int main( int argc, char *argv[] ) +#else +__declspec(dllexport) int dllrunscript( int argc, char *argv[] ) +#endif +{ + char *binary, *s, *luatexfname, *argstr, **lua_argv; + int k, quoted, lua_argc; + int passprogname = 0; + unsigned char is_jit=0; + + // directory of this module/executable + HMODULE module_handle = GetModuleHandle( "mtxrun.dll" ); + // if ( module_handle == NULL ) exe path will be used, which is OK too + k = (int) GetModuleFileName( module_handle, dirpath, MAX_PATH ); + if ( !k || ( k == MAX_PATH ) ) + DIE( "unable to determine a valid module name\n" ); + s = strrchr(dirpath, '\\'); + if ( s == NULL ) DIE( "no directory part in module path: %s\n", dirpath ); + *(++s) = '\0'; //remove file name, leave trailing backslash + + // program name + k = strlen(argv[0]); + while ( k && (argv[0][k-1] != '/') && (argv[0][k-1] != '\\') ) k--; + strcpy(progname, &argv[0][k]); + s = progname; + if ( s = strrchr(s, '.') ) *s = '\0'; // remove file extension part + + /* check "jit" : strlen("jit") = 3 */ + if (strncmp(progname + strlen(progname) - 3, "jit", 3) == 0) { + is_jit = 1; + progname[strlen(progname) - 3]='\0'; + } + else + is_jit = 0; + + // script path + + strcpy( scriptpath, dirpath ); + k = strlen(progname); + if ( k < 6 ) k = 6; // in case the program name is shorter than "mtxrun" + if ( strlen(dirpath) + k + 4 >= MAX_PATH ) + DIE( "path too long: %s%s\n", dirpath, progname ); + + if ( strcmpi(progname,"mtxrun") == 0 ) { + strcat( scriptpath, progname ); + strcat( scriptpath, ".lua" ); + } else if ( strcmpi(progname,"luatools") == 0 ) { + strcat( scriptpath, "mtxrun.lua" ); + strcpy( progname, "base" ); + passprogname = 1; + } else if ( strcmpi(progname,"texmfstart") == 0 ) { + strcat( scriptpath, "mtxrun.lua" ); + } else { + strcat( scriptpath, "mtxrun.lua" ); + passprogname = 1; + } + if ( GetFileAttributes(scriptpath) == INVALID_FILE_ATTRIBUTES ) + DIE( "file not found: %s\n", scriptpath ); + + // find luatex.exe /luajittex.exe + if ( SearchPath( + dirpath, // was getenv( "PATH" ), // path to search (optional) + (is_jit ? "luajittex.exe":"luatex.exe"), // file name to search + NULL, // file extension to add (optional) + MAX_PATH, // output buffer size + luatexpath, // output buffer pointer + &luatexfname ) // pointer to a file part in the output buffer (optional) + ) { + binary = (is_jit ? "luajittex.exe":"luatex.exe"); + } else if ( SearchPath( + dirpath, // was getenv( "PATH" ), // path to search (optional) + (is_jit ? "texluajit.exe":"texlua.exe"), // file name to search + NULL, // file extension to add (optional) + MAX_PATH, // output buffer size + luatexpath, // output buffer pointer + &luatexfname ) // pointer to a file part in the output buffer (optional) + ) { + binary = (is_jit ? "texluajit.exe":"texlua.exe"); + } else if ( SearchPath( + getenv("PATH"), // was dirpath, // path to search (optional) + (is_jit ? "luajittex.exe":"luatex.exe"), // file name to search + NULL, // file extension to add (optional) + MAX_PATH, // output buffer size + luatexpath, // output buffer pointer + &luatexfname ) // pointer to a file part in the output buffer (optional) + ) { + binary = (is_jit ? "luajittex.exe":"luatex.exe"); + } else if ( SearchPath( + getenv("PATH") , // was dirpath, // path to search (optional) + (is_jit ? "texluajit.exe":"texlua.exe"), // file name to search + NULL, // file extension to add (optional) + MAX_PATH, // output buffer size + luatexpath, // output buffer pointer + &luatexfname ) // pointer to a file part in the output buffer (optional) + ) { + binary = (is_jit ? "texluajit.exe":"texlua.exe"); + }else { + DIE( "unable to locate texlua.exe on the search path" ); + } + + /* if ( SearchPath( */ + /* dirpath, // was getenv( "PATH" ), // path to search (optional) */ + /* (is_jit ? "luajittex.exe":"luatex.exe"), // file name to search */ + /* NULL, // file extension to add (optional) */ + /* MAX_PATH, // output buffer size */ + /* luatexpath, // output buffer pointer */ + /* &luatexfname ) // pointer to a file part in the output buffer (optional) */ + /* ) { */ + /* binary = (is_jit ? "luajittex.exe":"luatex.exe"); */ + /* }else if ( SearchPath( */ + /* getenv("PATH"), // was dirpath, // path to search (optional) */ + /* (is_jit ? "luajittex.exe":"luatex.exe"), // file name to search */ + /* NULL, // file extension to add (optional) */ + /* MAX_PATH, // output buffer size */ + /* luatexpath, // output buffer pointer */ + /* &luatexfname ) // pointer to a file part in the output buffer (optional) */ + /* ) { */ + /* binary = (is_jit ? "luajittex.exe":"luatex.exe"); */ + /* }else if ( SearchPath( */ + /* dirpath, // was getenv( "PATH" ), // path to search (optional) */ + /* (is_jit ? "texluajit.exe":"texlua.exe"), // file name to search */ + /* NULL, // file extension to add (optional) */ + /* MAX_PATH, // output buffer size */ + /* luatexpath, // output buffer pointer */ + /* &luatexfname ) // pointer to a file part in the output buffer (optional) */ + /* ) { */ + /* binary = (is_jit ? "texluajit.exe":"texlua.exe"); */ + /* }else if ( SearchPath( */ + /* getenv("PATH") , // was dirpath, // path to search (optional) */ + /* (is_jit ? "texluajit.exe":"texlua.exe"), // file name to search */ + /* NULL, // file extension to add (optional) */ + /* MAX_PATH, // output buffer size */ + /* luatexpath, // output buffer pointer */ + /* &luatexfname ) // pointer to a file part in the output buffer (optional) */ + /* ) { */ + /* binary = (is_jit ? "texluajit.exe":"texlua.exe"); */ + /* }else { */ + /* DIE( "unable to locate texlua.exe on the search path" ); */ + /* } */ + + + + + // link directly with luatex.dll if available in texlua's dir + strcpy( luatexfname, (is_jit ? "luajittex.dll":"luatex.dll") ); + if ( dllluatex = LoadLibrary(luatexpath) ) + { + mainlikeproc dllluatexmain = (mainlikeproc) GetProcAddress( dllluatex, (is_jit ? "dllluajittexmain": "dllluatexmain" )); + if ( dllluatexmain == NULL ) + if (is_jit) + DIE( "unable to locate dllluatexmain procedure in luajittex.dll" ) + else + DIE( "unable to locate dllluatexmain procedure in luatex.dll" ); + + // set up argument list for texlua script + + lua_argv = (char **)malloc( (argc + 5) * sizeof(char *) ); + if ( lua_argv == NULL ) DIE( "out of memory\n" ); + lua_argv[lua_argc=0] = luatexfname; + lua_argv[++lua_argc] = "--luaonly"; + lua_argv[++lua_argc] = scriptpath; // script to execute + if (passprogname) { + lua_argv[++lua_argc] = "--script"; + lua_argv[++lua_argc] = progname; + } + for ( k = 1; k < argc; k++ ) lua_argv[++lua_argc] = argv[k]; + lua_argv[++lua_argc] = NULL; + + // call texlua interpreter + // dllluatexmain never returns, but we pretend that it does + + k = dllluatexmain( lua_argc, lua_argv ); + if (lua_argv) free( lua_argv ); + return k; + } + // we are still here, so no luatex.dll; spawn texlua.exe instead + + strcpy( luatexfname,binary); + strcpy( cmdline, " --luaonly " ); + strcpy( cmdline, "\"" ); + strcat( cmdline, luatexpath ); + strcat( cmdline, "\" \"" ); + strcat( cmdline, scriptpath ); + strcat( cmdline, "\"" ); + if (passprogname) { + strcat( cmdline, " --script " ); + strcat( cmdline, progname ); + } + argstr = GetCommandLine(); // get the command line of this process + if ( argstr == NULL ) DIE( "unable to retrieve the command line string\n" ); + + // skip over argv[0] in the argument string + // (it can contain embedded double quotes if launched from cmd.exe!) + + for ( quoted = 0; (*argstr) && ( !IS_WHITESPACE(*argstr) || quoted ); argstr++ ) + if (*argstr == '"') quoted = !quoted; + + // pass through all the arguments + + if ( strlen(cmdline) + strlen(argstr) >= MAX_CMD ) + DIE( "command line string too long:\n%s%s\n", cmdline, argstr ); + strcat( cmdline, argstr ); + + // create child process + + STARTUPINFO si; + PROCESS_INFORMATION pi; + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + si.dwFlags = STARTF_USESTDHANDLES;// | STARTF_USESHOWWINDOW; + //si.dwFlags = STARTF_USESHOWWINDOW; + //si.wShowWindow = SW_HIDE ; // can be used to hide console window (requires STARTF_USESHOWWINDOW flag) + si.hStdInput = GetStdHandle( STD_INPUT_HANDLE ); + si.hStdOutput = GetStdHandle( STD_OUTPUT_HANDLE ); + si.hStdError = GetStdHandle( STD_ERROR_HANDLE ); + ZeroMemory( &pi, sizeof(pi) ); + if( !CreateProcess( + NULL, // module name (uses command line if NULL) + cmdline, // command line + NULL, // process security atrributes + NULL, // thread security atrributes + TRUE, // handle inheritance + 0, // creation flags, e.g. CREATE_NEW_CONSOLE, CREATE_NO_WINDOW, DETACHED_PROCESS + NULL, // pointer to environment block (uses parent if NULL) + NULL, // starting directory (uses parent if NULL) + &si, // STARTUPINFO structure + &pi ) // PROCESS_INFORMATION structure + ) DIE( "command execution failed: %s\n", cmdline ); + DWORD ret = 0; + CloseHandle( pi.hThread ); // thread handle is not needed + if ( WaitForSingleObject( pi.hProcess, INFINITE ) == WAIT_OBJECT_0 ) { + if ( !GetExitCodeProcess( pi.hProcess, &ret) ) + DIE( "unable to retrieve process exit code: %s\n", cmdline ); + } else DIE( "failed to wait for process termination: %s\n", cmdline ); + CloseHandle( pi.hProcess ); + + // propagate exit code from the child process + return ret; + +} diff --git a/Build/source/texk/texlive/windows_wrapper/context/mtxrun_exe.c b/Build/source/texk/texlive/windows_wrapper/context/mtxrun_exe.c index d711f85300e..0c27c272e37 100644 --- a/Build/source/texk/texlive/windows_wrapper/context/mtxrun_exe.c +++ b/Build/source/texk/texlive/windows_wrapper/context/mtxrun_exe.c @@ -1,8 +1,8 @@ -// This is the .exe part of the mtxrun program, see mtxrun_dll.c
-// for more details.
-
-#include <windows.h>
-
-__declspec(dllimport) int dllrunscript( int argc, char *argv[] );
-
-int main( int argc, char *argv[] ) { return dllrunscript( argc, argv ); }
+// This is the .exe part of the mtxrun program, see mtxrun_dll.c +// for more details. + +#include <windows.h> + +__declspec(dllimport) int dllrunscript( int argc, char *argv[] ); + +int main( int argc, char *argv[] ) { return dllrunscript( argc, argv ); } diff --git a/Build/source/texk/texlive/windows_wrapper/context/readme.txt b/Build/source/texk/texlive/windows_wrapper/context/readme.txt index 4eae76a1e20..72892ee2f11 100644 --- a/Build/source/texk/texlive/windows_wrapper/context/readme.txt +++ b/Build/source/texk/texlive/windows_wrapper/context/readme.txt @@ -1,40 +1,40 @@ -Copyright:
-
-The originally 'runscript' program was written by in 2009 by T.M.Trzeciak and is
-public domain. This derived mtxrun program is an adapted version by Hans Hagen and
-Luigi Scarso.
-
-Comment:
-
-In ConTeXt MkIV we have two core scripts: luatools.lua and mtxrun.lua where the
-second one is used to launch other scripts. The mtxrun.exe program calls luatex.exe.
-
-Normally a user will use a call like:
-
- mtxrun --script font --reload
-
-Here mtxrun is a lua script. In order to avoid the usage of a cmd file on windows this
-runner will start texlua directly. In TeXlive a runner is added for each cmd file but
-we don't want that overhead (and extra files). By using an exe we can call these
-scripts in batch files without the need for using call.
-
-The mtxrun.exe file can be copied to a mtxrunjit.exe file in which case luajittex.exe
-is called.
-
- mtxrunjit --script font --reload
-
-We also don't want to use other runners, like those that use kpse to locate the script
-as this is exactly what mtxrun itself is doing already. Therefore the runscript program
-is adapted to a more direct approach suitable for mtxrun.
-
-Compilation:
-
-with gcc (size optimized):
-
- gcc -Os -s -shared -o mtxrun.dll mtxrun_dll.c
- gcc -Os -s -o mtxrun.exe mtxrun_exe.c -L./ -lmtxrun
-
-with tcc (ver. 0.9.24), extra small size
-
- tcc -shared -o runscript.dll runscript_dll.c
- tcc -o runscript.exe runscript_exe.c runscript.def
+Copyright: + +The originally 'runscript' program was written by in 2009 by T.M.Trzeciak and is +public domain. This derived mtxrun program is an adapted version by Hans Hagen and +Luigi Scarso. + +Comment: + +In ConTeXt MkIV we have two core scripts: luatools.lua and mtxrun.lua where the +second one is used to launch other scripts. The mtxrun.exe program calls luatex.exe. + +Normally a user will use a call like: + + mtxrun --script font --reload + +Here mtxrun is a lua script. In order to avoid the usage of a cmd file on windows this +runner will start texlua directly. In TeXlive a runner is added for each cmd file but +we don't want that overhead (and extra files). By using an exe we can call these +scripts in batch files without the need for using call. + +The mtxrun.exe file can be copied to a mtxrunjit.exe file in which case luajittex.exe +is called. + + mtxrunjit --script font --reload + +We also don't want to use other runners, like those that use kpse to locate the script +as this is exactly what mtxrun itself is doing already. Therefore the runscript program +is adapted to a more direct approach suitable for mtxrun. + +Compilation: + +with gcc (size optimized): + + gcc -Os -s -shared -o mtxrun.dll mtxrun_dll.c + gcc -Os -s -o mtxrun.exe mtxrun_exe.c -L./ -lmtxrun + +with tcc (ver. 0.9.24), extra small size + + tcc -shared -o runscript.dll runscript_dll.c + tcc -o runscript.exe runscript_exe.c runscript.def diff --git a/Build/source/texk/texlive/windows_wrapper/readme.txt b/Build/source/texk/texlive/windows_wrapper/readme.txt index 8f4f3d17509..7914b67aa7a 100644 --- a/Build/source/texk/texlive/windows_wrapper/readme.txt +++ b/Build/source/texk/texlive/windows_wrapper/readme.txt @@ -1,225 +1,225 @@ -
- Script wrappers in TeX Live on Windows
-
- Rationale
-
- Wrappers enable use of scripts on Windows as regular programs.
- They are also required for some binary programs to set up the
- right environment for them.
-
- Batch scripts can be used for wrapping but they are not as universal
- as binaries (there are some odd cases where they don't work) and
- it is hard to make them robust and secure. Compiled binary wrappers
- don't suffer from these problems but they are harder to write, debug
- and maintain in comparison to scripts. For these reasons a hybrid
- approach is taken that combines a binary stub with a launcher script.
-
- Adding wrappers for user scripts
-
- The script wrapping machinery is not limited to scripts shipped with
- TeX Live. You can also use it for script programs from manually
- installed packages. This should minimize problems when using them
- with TeX Live.
-
- First, make sure that there is an interpreter program available on
- your system for the script you want to use. Interpreters for Perl
- and Lua are bundled with TeX Live, all others have to be installed
- independently. Lua scripts are the most efficient to run, so if you
- consider writing a new script, that would be the recommended choice.
-
- The following script types and their file extensions are currently
- supported and searched in that order:
-
- Lua (.tlu;.texlua;.lua) -- included
- Perl (.pl) -- included
- Ruby (.rb) -- requires installation
- Python (.py) -- requires installation
- Tcl (.tcl) -- requires installation
- Java (.jar) -- requires installation
- VBScript (.vbs) -- part of Windows
- JScript (.js) -- part of Windows
- Batch (.bat;.cmd) -- part of Windows
-
- Finally, Unix-style extensionless scripts are searched as last and
- the interpreter program is established based on the she-bang (#!)
- specification on the very first line of the script. This can be
- an arbitrary program but it must be present on the search path.
-
- Next, the script program needs to be installed somewhere below the
- 'scripts' directory under one of the TEXMF trees (consult the
- documentation or texmf/web2c/texmf.cnf file for a list). You may
- need to update the file search database afterwards with:
-
- mktexlsr [TEXMFDIR]
-
- It is also possible to use scripts that are outside of TEXMF hierarchy
- by adjusting TEXMFSCRIPTS environment or kpathsea variable, see
- kpathsea documentation for more information on setting its variables.
-
- Test if the script can be located with:
-
- kpsewhich --format=texmfscripts <script-name>.<ext>
-
- This should output the full path to the script if everything is
- properly installed and configured. If this test is successful,
- the script can be run immediately with:
-
- runscript <script-name> [script arguments]
-
- If you prefer to call the script program simply by its name, copy
- and rename bin/win32/runscript.exe to <script-name>.exe and put it
- somewhere on the search path.
-
- Wrapper structure
-
- Wrappers consist of small binary stubs and a common texlua script.
- The binary stubs are all the same, just different names (but CLI
- and GUI stubs differ, see below, and GUI stubs are actually all
- different due to different embedded icons).
-
- The job of the binary stub is twofold: (a) call the texlua launcher
- script 'runscript.tlu' from the same directory (or more precisely
- from the directory containing 'runscript.dll') and (b) pass to it
- argv[0] and the unparsed argument string as the last two arguments
- (after adding a sentinel argument, which ends with a new line
- character). Arbitrary C strings can be passed, because the script
- is executed by linking with luatex.dll and calling the lua
- interpreter internally rather than by spawning a new process.
-
- There are two flavours of the binary stub: one for CLI programs
- and another one for GUI programs. The GUI variant does not open
- a console window nor does it block the command prompt if started
- from there. It also uses a dialog box to display an error message
- in addition to outputting to stderr.
-
- The stubs are further split into a common DLL and EXE proxies
- to it. This is for maintenance reasons - updates can be done by
- replacement of a single DLL rather than all binary stubs.
-
- The launcher script knows, which variant has been used to invoke it
- based on the sentinel argument. The lack of this argument means
- that it was invoked in a standard way, i.e., through texlua.exe.
-
- All the hard work of locating a script/program to execute happens
- in the launcher script. The located script/program is always
- executed directly by spawning its interpreter (or binary) in a new
- process. The system shell (cmd.exe) is never called (except for
- batch scripts, of course). If the located script happens to be
- a (tex)lua script, it is loaded and called internally from within
- this script, i.e. no new process is spawned. Execution is done
- using a protected call, so any compile or runtime errors are catched.
-
- Source files
-
- runscript.tlu launcher script for locating and dispatching
- target scripts/programs
- runscript_dll.c common DLL part of the binary stubs; locates and
- calls the launcher script
- runscript_exe.c EXE proxy to the common DLL for CLI mode stubs
- wrunscript_exe.c EXE proxy to the common DLL for GUI mode stubs
-
- Compilation of binaries (requires luatex.dll in the same directory)
-
- with gcc (size optimized):
-
- gcc -Os -s -shared -o runscript.dll runscript_dll.c -L./ -lluatex
- gcc -Os -s -o runscript.exe runscript_exe.c -L./ -lrunscript
- gcc -mwindows -Os -s -o wrunscript.exe wrunscript_exe.c -L./ -lrunscript
-
- with tcc (extra small size):
-
- tiny_impdef luatex.dll
- tcc -shared -o runscript.dll runscript_dll.c luatex.def
- tcc -o runscript.exe runscript_exe.c runscript.def
- tcc -o wrunscript.exe wrunscript_exe.c runscript.def
-
- License
-
- Originally written in 2009 by Tomasz M. Trzeciak, Public Domain.
-
- Prior work:
- 'tl-w32-wrapper.texlua' by Reinhard Kotucha and Norbert Preining.
- 'tl-w32-wrapper.cmd' by Tomasz M. Trzeciak.
-
- Changelog
-
- 2009/12/04
- - initial version
- 2009/12/15
- - minor fixes for path & extension list parsing
- 2010/01/09
- - added support for GUI mode stubs
- 2010/02/28
- - enable GUI mode stubs for dviout, psv and texworks;
- - added generic handling of sys programs
- - added restricted repstopdf to alias_table
- 2010/03/13
- - added 'readme.txt' and changelog
- - added support and docs for calling user added scripts;
- (use path of 'runscript.dll' instead of .exe stub to
- locate 'runscript.tlu' script)
- - limit search for shell_escape_commands to system trees
- - added function for creating directory hierarchy
- - fixed directory creation for dviout & texworks aliases
- - fixed arg[0] of repstopdf & rpdfcrop
- 2010/03/28
- - restructured docs, added --help and --version options
- (available only when invoked under 'runscript' name)
- - use TEXMF_RESTRICTED_SCRIPTS kpse var for searching
- shell_escape_commands
- - changed command validation to handle a list of commands
- - prepend GUI mode command(s) to the command list
- - added support for .tcl scripts
- 2010/03/31
- - fixed fatal bug in extention_map definition for GUI mode
- 2010/04/15
- - encapsulated main chunk in a function to execute with
- pcall for more robustness and better error catching
- - added texdoctk to scripts4tlperl table
- - added tlgs and tlperl to alias_table; callable as e.g.:
- runscript tlperl ...
- - doc tweaks
- 2010/04/22
- - ensure only backslash is used in USERPROFILE variable
- (Adobe Reader crash case)
- - fixed argument processing for direct execution under texlua
- - more doc tweaks
- 2010/05/30
- - Windows XP or newer required to run TeXworks
- 2010/06/04
- - added support for Perl scripts starting with eval-exec-perl
- construct in place of she-bang (#!)
- 2010/06/25
- - run internal tlperl only with our Perl
- - added fontinst to alias_table
- - added support for all tex4ht commands from mk4ht.pl
- - removed some unsued aliases
- - some code refactoring and cleanup
- 2010/12/28
- - use of external Perl now requires kpathsea variable
- TEXLIVE_WINDOWS_TRY_EXTERNAL_PERL to be explicitly set to 1
- - alias_table replaced with if-elseif-end tests to streamline
- special cases and to avoid hardcoding of texmf* file paths
- - added a2ping to special cases (requires -x switch to Perl)
- - set ASYMPTOTE_GS (for asy) to full path to tlgs
- 2011/01/09
- - removed tex4ht commands starting with ht from mk4ht aliases;
- they have their own scripts and mk4ht calls them internally,
- so aliasing results in an infinite recursion
- - removed alias for fontinst (no fontinst.exe any more)
- - fixed GUI-mode interpreter for Ruby
- 2011/09/10
- - added -dDisableFAPI=true to psview argument list. Needed by
- gs-9.xx
- 2012/03/12
- - added '-i', '.' to psview argument list (author's request)
- - added environment clean up from Perl specific variables
- (when not using external Perl)
- 2012/08/05
- - added alias for fmtutil
- 2013/05/09
- - added alias mkluatexfontdb -> luaotfload-tool
- 2013/07/03
- - fix for psview and UNC paths in unix-style
- - remove not needed is_abs_path function
-
+ + Script wrappers in TeX Live on Windows + + Rationale + + Wrappers enable use of scripts on Windows as regular programs. + They are also required for some binary programs to set up the + right environment for them. + + Batch scripts can be used for wrapping but they are not as universal + as binaries (there are some odd cases where they don't work) and + it is hard to make them robust and secure. Compiled binary wrappers + don't suffer from these problems but they are harder to write, debug + and maintain in comparison to scripts. For these reasons a hybrid + approach is taken that combines a binary stub with a launcher script. + + Adding wrappers for user scripts + + The script wrapping machinery is not limited to scripts shipped with + TeX Live. You can also use it for script programs from manually + installed packages. This should minimize problems when using them + with TeX Live. + + First, make sure that there is an interpreter program available on + your system for the script you want to use. Interpreters for Perl + and Lua are bundled with TeX Live, all others have to be installed + independently. Lua scripts are the most efficient to run, so if you + consider writing a new script, that would be the recommended choice. + + The following script types and their file extensions are currently + supported and searched in that order: + + Lua (.tlu;.texlua;.lua) -- included + Perl (.pl) -- included + Ruby (.rb) -- requires installation + Python (.py) -- requires installation + Tcl (.tcl) -- requires installation + Java (.jar) -- requires installation + VBScript (.vbs) -- part of Windows + JScript (.js) -- part of Windows + Batch (.bat;.cmd) -- part of Windows + + Finally, Unix-style extensionless scripts are searched as last and + the interpreter program is established based on the she-bang (#!) + specification on the very first line of the script. This can be + an arbitrary program but it must be present on the search path. + + Next, the script program needs to be installed somewhere below the + 'scripts' directory under one of the TEXMF trees (consult the + documentation or texmf/web2c/texmf.cnf file for a list). You may + need to update the file search database afterwards with: + + mktexlsr [TEXMFDIR] + + It is also possible to use scripts that are outside of TEXMF hierarchy + by adjusting TEXMFSCRIPTS environment or kpathsea variable, see + kpathsea documentation for more information on setting its variables. + + Test if the script can be located with: + + kpsewhich --format=texmfscripts <script-name>.<ext> + + This should output the full path to the script if everything is + properly installed and configured. If this test is successful, + the script can be run immediately with: + + runscript <script-name> [script arguments] + + If you prefer to call the script program simply by its name, copy + and rename bin/win32/runscript.exe to <script-name>.exe and put it + somewhere on the search path. + + Wrapper structure + + Wrappers consist of small binary stubs and a common texlua script. + The binary stubs are all the same, just different names (but CLI + and GUI stubs differ, see below, and GUI stubs are actually all + different due to different embedded icons). + + The job of the binary stub is twofold: (a) call the texlua launcher + script 'runscript.tlu' from the same directory (or more precisely + from the directory containing 'runscript.dll') and (b) pass to it + argv[0] and the unparsed argument string as the last two arguments + (after adding a sentinel argument, which ends with a new line + character). Arbitrary C strings can be passed, because the script + is executed by linking with luatex.dll and calling the lua + interpreter internally rather than by spawning a new process. + + There are two flavours of the binary stub: one for CLI programs + and another one for GUI programs. The GUI variant does not open + a console window nor does it block the command prompt if started + from there. It also uses a dialog box to display an error message + in addition to outputting to stderr. + + The stubs are further split into a common DLL and EXE proxies + to it. This is for maintenance reasons - updates can be done by + replacement of a single DLL rather than all binary stubs. + + The launcher script knows, which variant has been used to invoke it + based on the sentinel argument. The lack of this argument means + that it was invoked in a standard way, i.e., through texlua.exe. + + All the hard work of locating a script/program to execute happens + in the launcher script. The located script/program is always + executed directly by spawning its interpreter (or binary) in a new + process. The system shell (cmd.exe) is never called (except for + batch scripts, of course). If the located script happens to be + a (tex)lua script, it is loaded and called internally from within + this script, i.e. no new process is spawned. Execution is done + using a protected call, so any compile or runtime errors are catched. + + Source files + + runscript.tlu launcher script for locating and dispatching + target scripts/programs + runscript_dll.c common DLL part of the binary stubs; locates and + calls the launcher script + runscript_exe.c EXE proxy to the common DLL for CLI mode stubs + wrunscript_exe.c EXE proxy to the common DLL for GUI mode stubs + + Compilation of binaries (requires luatex.dll in the same directory) + + with gcc (size optimized): + + gcc -Os -s -shared -o runscript.dll runscript_dll.c -L./ -lluatex + gcc -Os -s -o runscript.exe runscript_exe.c -L./ -lrunscript + gcc -mwindows -Os -s -o wrunscript.exe wrunscript_exe.c -L./ -lrunscript + + with tcc (extra small size): + + tiny_impdef luatex.dll + tcc -shared -o runscript.dll runscript_dll.c luatex.def + tcc -o runscript.exe runscript_exe.c runscript.def + tcc -o wrunscript.exe wrunscript_exe.c runscript.def + + License + + Originally written in 2009 by Tomasz M. Trzeciak, Public Domain. + + Prior work: + 'tl-w32-wrapper.texlua' by Reinhard Kotucha and Norbert Preining. + 'tl-w32-wrapper.cmd' by Tomasz M. Trzeciak. + + Changelog + + 2009/12/04 + - initial version + 2009/12/15 + - minor fixes for path & extension list parsing + 2010/01/09 + - added support for GUI mode stubs + 2010/02/28 + - enable GUI mode stubs for dviout, psv and texworks; + - added generic handling of sys programs + - added restricted repstopdf to alias_table + 2010/03/13 + - added 'readme.txt' and changelog + - added support and docs for calling user added scripts; + (use path of 'runscript.dll' instead of .exe stub to + locate 'runscript.tlu' script) + - limit search for shell_escape_commands to system trees + - added function for creating directory hierarchy + - fixed directory creation for dviout & texworks aliases + - fixed arg[0] of repstopdf & rpdfcrop + 2010/03/28 + - restructured docs, added --help and --version options + (available only when invoked under 'runscript' name) + - use TEXMF_RESTRICTED_SCRIPTS kpse var for searching + shell_escape_commands + - changed command validation to handle a list of commands + - prepend GUI mode command(s) to the command list + - added support for .tcl scripts + 2010/03/31 + - fixed fatal bug in extention_map definition for GUI mode + 2010/04/15 + - encapsulated main chunk in a function to execute with + pcall for more robustness and better error catching + - added texdoctk to scripts4tlperl table + - added tlgs and tlperl to alias_table; callable as e.g.: + runscript tlperl ... + - doc tweaks + 2010/04/22 + - ensure only backslash is used in USERPROFILE variable + (Adobe Reader crash case) + - fixed argument processing for direct execution under texlua + - more doc tweaks + 2010/05/30 + - Windows XP or newer required to run TeXworks + 2010/06/04 + - added support for Perl scripts starting with eval-exec-perl + construct in place of she-bang (#!) + 2010/06/25 + - run internal tlperl only with our Perl + - added fontinst to alias_table + - added support for all tex4ht commands from mk4ht.pl + - removed some unsued aliases + - some code refactoring and cleanup + 2010/12/28 + - use of external Perl now requires kpathsea variable + TEXLIVE_WINDOWS_TRY_EXTERNAL_PERL to be explicitly set to 1 + - alias_table replaced with if-elseif-end tests to streamline + special cases and to avoid hardcoding of texmf* file paths + - added a2ping to special cases (requires -x switch to Perl) + - set ASYMPTOTE_GS (for asy) to full path to tlgs + 2011/01/09 + - removed tex4ht commands starting with ht from mk4ht aliases; + they have their own scripts and mk4ht calls them internally, + so aliasing results in an infinite recursion + - removed alias for fontinst (no fontinst.exe any more) + - fixed GUI-mode interpreter for Ruby + 2011/09/10 + - added -dDisableFAPI=true to psview argument list. Needed by + gs-9.xx + 2012/03/12 + - added '-i', '.' to psview argument list (author's request) + - added environment clean up from Perl specific variables + (when not using external Perl) + 2012/08/05 + - added alias for fmtutil + 2013/05/09 + - added alias mkluatexfontdb -> luaotfload-tool + 2013/07/03 + - fix for psview and UNC paths in unix-style + - remove not needed is_abs_path function + diff --git a/Build/source/texk/texlive/windows_wrapper/runscript_dll.c b/Build/source/texk/texlive/windows_wrapper/runscript_dll.c index c9f540f4a36..617a00f7319 100644 --- a/Build/source/texk/texlive/windows_wrapper/runscript_dll.c +++ b/Build/source/texk/texlive/windows_wrapper/runscript_dll.c @@ -1,121 +1,121 @@ -/************************************************************************
-
- This file is a part of the wrapper program for launching scripts
- and programs in TeX Live on Windows. See readme.txt for more details.
-
- This file was originally written in 2009 by Tomasz M. Trzeciak and
- was placed in the Public Domain.
-
-************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-#define IS_WHITESPACE(c) ((c == ' ') || (c == '\t'))
-#define MAX_MSG 2*MAX_PATH
-#define DIE(...) { _snprintf( msg_buf, MAX_MSG - 1, __VA_ARGS__ ); goto DIE; }
-
-char module_name[] = "runscript.dll";
-char script_name[] = "runscript.tlu";
-char texlua_name[] = "texlua"; // just a bare name, luatex strips the rest anyway
-char subsys_mode[] = "CUI_MODE\n";
-char err_env_var[] = "RUNSCRIPT_ERROR_MESSAGE";
-char msg_buf[MAX_MSG];
-
-__declspec(dllimport) int dllluatexmain( int argc, char *argv[] );
-
-__declspec(dllexport) int dllrunscript( int argc, char *argv[] )
-{
- static char own_path[MAX_PATH];
- static char fpath[MAX_PATH];
- char *fname, *argline, **lua_argv;
- int k, quoted, lua_argc;
- HMODULE module_handle = NULL;
-
- // file path of the executable
- k = (int) GetModuleFileName(NULL, own_path, MAX_PATH);
- if ( !k || (k == MAX_PATH) )
- DIE("cannot get own path (may be too long): %s\n", own_path);
-
- // script path (the dir of this library)
- module_handle = GetModuleHandle(module_name);
- // if ( module_handle == NULL ) exe path will be used, which is OK too
- k = (int) GetModuleFileName(module_handle, fpath, MAX_PATH);
- if ( !k || (k == MAX_PATH) )
- DIE("cannot get module path (may be too long): %s\n", fpath);
- fname = strrchr(fpath, '\\');
- if ( fname == NULL ) DIE("no directory part in module path: %s\n", fpath);
- fname++;
- if ( fname + strlen(script_name) >= fpath + MAX_PATH - 1 )
- DIE("path too long: %s\n", fpath);
- strcpy(fname, script_name);
- if ( GetFileAttributes(fpath) == INVALID_FILE_ATTRIBUTES )
- DIE("main lua script not found: %s\n", fpath);
-
- // get command line of this process
- argline = GetCommandLine();
- if ( argline == NULL ) DIE("failed to retrieve command line string\n");
- // skip over argv[0] (it can contain embedded double quotes if launched from cmd.exe!)
- for ( quoted = 0; (*argline) && ( !IS_WHITESPACE(*argline) || quoted ); argline++ )
- if ( *argline == '"' ) quoted = !quoted;
- while ( IS_WHITESPACE(*argline) ) argline++; // remove leading whitespace if any
-
- // set up argument list for texlua script
- lua_argv = (char **)malloc( (argc + 6) * sizeof(char *) );
- lua_argv[lua_argc=0] = texlua_name;
- lua_argv[++lua_argc] = fpath; // script to execute
- for ( k = 1; k < argc; k++ ) lua_argv[++lua_argc] = argv[k]; // copy argument list
- lua_argv[++lua_argc] = subsys_mode; // sentinel argument
- lua_argv[++lua_argc] = argc ? argv[0] : own_path; // original argv[0]
- lua_argv[++lua_argc] = argline; // unparsed arguments
- lua_argv[++lua_argc] = NULL;
-
- // call texlua interpreter
- // dllluatexmain never returns, but we pretend that it does
- k = dllluatexmain( lua_argc, lua_argv );
- if (lua_argv) free(lua_argv);
- return k;
-
-DIE:
- fprintf(stderr, "%s: ", module_name);
- fprintf(stderr, msg_buf);
- if (*subsys_mode == 'G')
- MessageBox( NULL, msg_buf, module_name, MB_ICONERROR | MB_SETFOREGROUND );
- return 1;
-}
-
-void finalize( void )
-{
- // check for and display error message if any
- char *err_msg;
- if ( err_msg = (char *) getenv(err_env_var) )
- MessageBox( NULL, err_msg, script_name, MB_ICONERROR | MB_SETFOREGROUND );
-}
-
-__declspec(dllexport) int dllwrunscript(
- HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- char *argline,
- int winshow
-) {
- // set sentinel argument (G for GUI_MODE)
- *subsys_mode = 'G';
- // clear error var in case it exists already
- SetEnvironmentVariable(err_env_var, NULL);
- // register atexit handler to recover control before terminating
- atexit( finalize );
- // call the console entry point routine
-#ifdef __MSVCRT__
- // WinMain doesn't provide argc & argv, call MSVCRT proc to get them
- int argc = 0;
- char **argv, **env;
- int expand_wildcards = 0;
- int new_mode;
- __getmainargs(&argc, &argv, &env, expand_wildcards, &new_mode);
- return dllrunscript( argc, argv );
-#else
- return dllrunscript( 0, NULL );
-#endif
-}
-
-
+/************************************************************************ + + This file is a part of the wrapper program for launching scripts + and programs in TeX Live on Windows. See readme.txt for more details. + + This file was originally written in 2009 by Tomasz M. Trzeciak and + was placed in the Public Domain. + +************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <windows.h> +#define IS_WHITESPACE(c) ((c == ' ') || (c == '\t')) +#define MAX_MSG 2*MAX_PATH +#define DIE(...) { _snprintf( msg_buf, MAX_MSG - 1, __VA_ARGS__ ); goto DIE; } + +char module_name[] = "runscript.dll"; +char script_name[] = "runscript.tlu"; +char texlua_name[] = "texlua"; // just a bare name, luatex strips the rest anyway +char subsys_mode[] = "CUI_MODE\n"; +char err_env_var[] = "RUNSCRIPT_ERROR_MESSAGE"; +char msg_buf[MAX_MSG]; + +__declspec(dllimport) int dllluatexmain( int argc, char *argv[] ); + +__declspec(dllexport) int dllrunscript( int argc, char *argv[] ) +{ + static char own_path[MAX_PATH]; + static char fpath[MAX_PATH]; + char *fname, *argline, **lua_argv; + int k, quoted, lua_argc; + HMODULE module_handle = NULL; + + // file path of the executable + k = (int) GetModuleFileName(NULL, own_path, MAX_PATH); + if ( !k || (k == MAX_PATH) ) + DIE("cannot get own path (may be too long): %s\n", own_path); + + // script path (the dir of this library) + module_handle = GetModuleHandle(module_name); + // if ( module_handle == NULL ) exe path will be used, which is OK too + k = (int) GetModuleFileName(module_handle, fpath, MAX_PATH); + if ( !k || (k == MAX_PATH) ) + DIE("cannot get module path (may be too long): %s\n", fpath); + fname = strrchr(fpath, '\\'); + if ( fname == NULL ) DIE("no directory part in module path: %s\n", fpath); + fname++; + if ( fname + strlen(script_name) >= fpath + MAX_PATH - 1 ) + DIE("path too long: %s\n", fpath); + strcpy(fname, script_name); + if ( GetFileAttributes(fpath) == INVALID_FILE_ATTRIBUTES ) + DIE("main lua script not found: %s\n", fpath); + + // get command line of this process + argline = GetCommandLine(); + if ( argline == NULL ) DIE("failed to retrieve command line string\n"); + // skip over argv[0] (it can contain embedded double quotes if launched from cmd.exe!) + for ( quoted = 0; (*argline) && ( !IS_WHITESPACE(*argline) || quoted ); argline++ ) + if ( *argline == '"' ) quoted = !quoted; + while ( IS_WHITESPACE(*argline) ) argline++; // remove leading whitespace if any + + // set up argument list for texlua script + lua_argv = (char **)malloc( (argc + 6) * sizeof(char *) ); + lua_argv[lua_argc=0] = texlua_name; + lua_argv[++lua_argc] = fpath; // script to execute + for ( k = 1; k < argc; k++ ) lua_argv[++lua_argc] = argv[k]; // copy argument list + lua_argv[++lua_argc] = subsys_mode; // sentinel argument + lua_argv[++lua_argc] = argc ? argv[0] : own_path; // original argv[0] + lua_argv[++lua_argc] = argline; // unparsed arguments + lua_argv[++lua_argc] = NULL; + + // call texlua interpreter + // dllluatexmain never returns, but we pretend that it does + k = dllluatexmain( lua_argc, lua_argv ); + if (lua_argv) free(lua_argv); + return k; + +DIE: + fprintf(stderr, "%s: ", module_name); + fprintf(stderr, msg_buf); + if (*subsys_mode == 'G') + MessageBox( NULL, msg_buf, module_name, MB_ICONERROR | MB_SETFOREGROUND ); + return 1; +} + +void finalize( void ) +{ + // check for and display error message if any + char *err_msg; + if ( err_msg = (char *) getenv(err_env_var) ) + MessageBox( NULL, err_msg, script_name, MB_ICONERROR | MB_SETFOREGROUND ); +} + +__declspec(dllexport) int dllwrunscript( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + char *argline, + int winshow +) { + // set sentinel argument (G for GUI_MODE) + *subsys_mode = 'G'; + // clear error var in case it exists already + SetEnvironmentVariable(err_env_var, NULL); + // register atexit handler to recover control before terminating + atexit( finalize ); + // call the console entry point routine +#ifdef __MSVCRT__ + // WinMain doesn't provide argc & argv, call MSVCRT proc to get them + int argc = 0; + char **argv, **env; + int expand_wildcards = 0; + int new_mode; + __getmainargs(&argc, &argv, &env, expand_wildcards, &new_mode); + return dllrunscript( argc, argv ); +#else + return dllrunscript( 0, NULL ); +#endif +} + + diff --git a/Build/source/texk/texlive/windows_wrapper/runscript_exe.c b/Build/source/texk/texlive/windows_wrapper/runscript_exe.c index c97989c9a6b..29d04a93a43 100644 --- a/Build/source/texk/texlive/windows_wrapper/runscript_exe.c +++ b/Build/source/texk/texlive/windows_wrapper/runscript_exe.c @@ -1,15 +1,15 @@ -/************************************************************************
-
- This file is a part of the wrapper program for launching scripts
- and programs in TeX Live on Windows. See readme.txt for more details.
-
- This file was originally written in 2009 by Tomasz M. Trzeciak and
- was placed in the Public Domain.
-
-************************************************************************/
-
-#include <windows.h>
-
-__declspec(dllimport) int dllrunscript( int argc, char *argv[] );
-
-int main( int argc, char *argv[] ) { return dllrunscript( argc, argv ); }
+/************************************************************************ + + This file is a part of the wrapper program for launching scripts + and programs in TeX Live on Windows. See readme.txt for more details. + + This file was originally written in 2009 by Tomasz M. Trzeciak and + was placed in the Public Domain. + +************************************************************************/ + +#include <windows.h> + +__declspec(dllimport) int dllrunscript( int argc, char *argv[] ); + +int main( int argc, char *argv[] ) { return dllrunscript( argc, argv ); } diff --git a/Build/source/texk/texlive/windows_wrapper/tlmgr-gui.txt b/Build/source/texk/texlive/windows_wrapper/tlmgr-gui.txt index d744f45a239..559d97ed3f2 100644 --- a/Build/source/texk/texlive/windows_wrapper/tlmgr-gui.txt +++ b/Build/source/texk/texlive/windows_wrapper/tlmgr-gui.txt @@ -1,77 +1,77 @@ -/*
-
-Launcher stub for tlmgr gui (with hidden console window)
-
-//////////////////////////////////////////////////
-
-This version has been replaced with a version which triggers a UAC
-prompt when appropriate. See Master/source/tlmgr-gui_UAC.zip.
-
-//////////////////////////////////////////////////
-
-Originally written in 2011 by Tomasz M. Trzeciak, Public Domain
-
-compiling with gcc (size optimized):
-echo 1 ICON "tlmgr-gui.ico">tlmgr-gui.rc
-windres tlmgr-gui.rc tlmgr-gui-rc.o
-gcc -Os -s -mwindows -o tlmgr-gui.exe tlmgr-gui-rc.o tlmgr-gui.c
-
-compiling with tcc (ver. 0.9.25), extra small size
-windres tlmgr-gui.rc tlmgr-gui-rc.o
-tcc -o tlmgr-gui.exe tlmgr-gui-rc.o tlmgr-gui.c
-
-*/
-
-#include <windows.h>
-
-static char msgbuf[4*MAX_PATH];
-#define DIE(...) { \
- _snprintf( msgbuf, 4*MAX_PATH, __VA_ARGS__ ); \
- MessageBox( NULL, msgbuf, "ERROR!", MB_ICONERROR | MB_SETFOREGROUND );\
- return 1; \
-}
-
-static char cmdln[2*MAX_PATH];
-
-int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShowint ) {
-
- // get file name of this executable
-
- static char selfdir[MAX_PATH];
- char *name, *ext, *s;
- DWORD nchars = GetModuleFileName(NULL, selfdir, MAX_PATH);
- if ( !nchars || (nchars == MAX_PATH) ) DIE( "cannot get own path" );
-
- // make command to execute
-
- if ( s = strrchr(selfdir, '\\') ) *s = '\0'; // remove file name part
- strcat( cmdln, "\"" );
- strcat( cmdln, selfdir );
- strcat( cmdln, "\\tlmgr.bat\" -gui" );
-
- // create child process
-
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- ZeroMemory( &si, sizeof(si) );
- si.cb = sizeof(si);
- si.dwFlags = STARTF_USESHOWWINDOW;
- si.wShowWindow = SW_HIDE ;
- ZeroMemory( &pi, sizeof(pi) );
-
- if( !CreateProcess(
- NULL, // module name (uses command line if NULL)
- cmdln, // command line
- NULL, // process security atrributes
- NULL, // thread security atrributes
- TRUE, // handle inheritance
- 0, // creation flags, e.g. CREATE_NEW_CONSOLE, CREATE_NO_WINDOW, DETACHED_PROCESS
- NULL, // pointer to environment block (uses parent if NULL)
- NULL, // starting directory (uses parent if NULL)
- &si, // STARTUPINFO structure
- &pi ) // PROCESS_INFORMATION structure
- ) DIE( "command execution failed: %s", cmdln );
-
- return 0;
-
-}
+/* + +Launcher stub for tlmgr gui (with hidden console window) + +////////////////////////////////////////////////// + +This version has been replaced with a version which triggers a UAC +prompt when appropriate. See Master/source/tlmgr-gui_UAC.zip. + +////////////////////////////////////////////////// + +Originally written in 2011 by Tomasz M. Trzeciak, Public Domain + +compiling with gcc (size optimized): +echo 1 ICON "tlmgr-gui.ico">tlmgr-gui.rc +windres tlmgr-gui.rc tlmgr-gui-rc.o +gcc -Os -s -mwindows -o tlmgr-gui.exe tlmgr-gui-rc.o tlmgr-gui.c + +compiling with tcc (ver. 0.9.25), extra small size +windres tlmgr-gui.rc tlmgr-gui-rc.o +tcc -o tlmgr-gui.exe tlmgr-gui-rc.o tlmgr-gui.c + +*/ + +#include <windows.h> + +static char msgbuf[4*MAX_PATH]; +#define DIE(...) { \ + _snprintf( msgbuf, 4*MAX_PATH, __VA_ARGS__ ); \ + MessageBox( NULL, msgbuf, "ERROR!", MB_ICONERROR | MB_SETFOREGROUND );\ + return 1; \ +} + +static char cmdln[2*MAX_PATH]; + +int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShowint ) { + + // get file name of this executable + + static char selfdir[MAX_PATH]; + char *name, *ext, *s; + DWORD nchars = GetModuleFileName(NULL, selfdir, MAX_PATH); + if ( !nchars || (nchars == MAX_PATH) ) DIE( "cannot get own path" ); + + // make command to execute + + if ( s = strrchr(selfdir, '\\') ) *s = '\0'; // remove file name part + strcat( cmdln, "\"" ); + strcat( cmdln, selfdir ); + strcat( cmdln, "\\tlmgr.bat\" -gui" ); + + // create child process + + STARTUPINFO si; + PROCESS_INFORMATION pi; + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + si.dwFlags = STARTF_USESHOWWINDOW; + si.wShowWindow = SW_HIDE ; + ZeroMemory( &pi, sizeof(pi) ); + + if( !CreateProcess( + NULL, // module name (uses command line if NULL) + cmdln, // command line + NULL, // process security atrributes + NULL, // thread security atrributes + TRUE, // handle inheritance + 0, // creation flags, e.g. CREATE_NEW_CONSOLE, CREATE_NO_WINDOW, DETACHED_PROCESS + NULL, // pointer to environment block (uses parent if NULL) + NULL, // starting directory (uses parent if NULL) + &si, // STARTUPINFO structure + &pi ) // PROCESS_INFORMATION structure + ) DIE( "command execution failed: %s", cmdln ); + + return 0; + +} diff --git a/Build/source/texk/texlive/windows_wrapper/wrunscript_exe.c b/Build/source/texk/texlive/windows_wrapper/wrunscript_exe.c index 0bc4beb5e27..573501ae757 100644 --- a/Build/source/texk/texlive/windows_wrapper/wrunscript_exe.c +++ b/Build/source/texk/texlive/windows_wrapper/wrunscript_exe.c @@ -1,27 +1,27 @@ -/************************************************************************
-
- This file is a part of the wrapper program for launching scripts
- and programs in TeX Live on Windows. See readme.txt for more details.
-
- This file was originally written in 2009 by Tomasz M. Trzeciak and
- was placed in the Public Domain.
-
-************************************************************************/
-
-#include <windows.h>
-
-__declspec(dllimport) int dllwrunscript(
- HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- char *argline,
- int winshow
- );
-
-int APIENTRY WinMain(
- HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- char *argline,
- int winshow
-){
- return dllwrunscript( hInstance, hPrevInstance, argline, winshow );
-}
+/************************************************************************ + + This file is a part of the wrapper program for launching scripts + and programs in TeX Live on Windows. See readme.txt for more details. + + This file was originally written in 2009 by Tomasz M. Trzeciak and + was placed in the Public Domain. + +************************************************************************/ + +#include <windows.h> + +__declspec(dllimport) int dllwrunscript( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + char *argline, + int winshow + ); + +int APIENTRY WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + char *argline, + int winshow +){ + return dllwrunscript( hInstance, hPrevInstance, argline, winshow ); +} |