Changeset 2302 for trunk


Ignore:
Timestamp:
Aug 22, 2005, 5:50:15 AM (20 years ago)
Author:
bird
Message:

o Added libc_Back_gfProcessHandleHashBangScripts and

libc_Back_gfProcessHandlePCBatchScripts for use in shells which
can handle such scripts more efficiently than libc.

o Fixed some bugs related to finding the interpreter in the spawn/exec backend.

Location:
trunk/src/emx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/ChangeLog.LIBC

    • Property cvs2svn:cvs-rev changed from 1.125 to 1.126
    r2301 r2302  
    88          The old defaults were 8MB (emxbind) and 8KB (emxomfld).
    99    - libc:
     10        o Added __libc_Back_gfProcessHandleHashBangScripts and
     11          __libc_Back_gfProcessHandlePCBatchScripts for use in shells which
     12          can handle such scripts more efficiently than libc.
     13        o Fixed some bugs related to finding the interpreter in the spawn/exec backend.
    1014        o Merged the signal semaphore handling into the safe sems and
    1115          made signals use them instead.
  • trunk/src/emx/include/InnoTekLIBC/backend.h

    • Property cvs2svn:cvs-rev changed from 1.32 to 1.33
    r2301 r2302  
    905905int __libc_Back_processSetPriority(int iWhich, id_t idWho, int iPrio);
    906906
     907
     908/** When this flag is set, the exec / spawn backend will handle hash bang scripts. */
     909extern int __libc_Back_gfProcessHandleHashBangScripts;
     910/** When this flag is set, the exec / spawn backend will handle PC batch scripts. */
     911extern int __libc_Back_gfProcessHandlePCBatchScripts;
    907912
    908913/** @} */
  • trunk/src/emx/src/lib/libc.def

    • Property cvs2svn:cvs-rev changed from 1.136 to 1.137
    r2301 r2302  
    19441944    "___libc_LogErrorLeave" @1942
    19451945    "__memcpy_amd" @1943
     1946    "___libc_Back_gfProcessHandleHashBangScripts" @1944
     1947    "___libc_Back_gfProcessHandlePCBatchScripts" @1945
  • trunk/src/emx/src/lib/sys/__spawnve.c

    • Property cvs2svn:cvs-rev changed from 1.19 to 1.20
    r2301 r2302  
    1818#include <emx/syscalls.h>
    1919#include <InnoTekLIBC/sharedpm.h>
     20#include <InnoTekLIBC/backend.h>
    2021#define __LIBC_LOG_GROUP    __LIBC_LOG_GRP_PROCESS
    2122#include <InnoTekLIBC/logstrict.h>
    2223#include "syscalls.h"
     24
     25
     26/*******************************************************************************
     27*   Global Variables                                                           *
     28*******************************************************************************/
     29/** When this flag is set, the exec / spawn backend will handle hash bang scripts. */
     30int __libc_Back_gfProcessHandleHashBangScripts = 1;
     31/** When this flag is set, the exec / spawn backend will handle PC batch scripts. */
     32int __libc_Back_gfProcessHandlePCBatchScripts = 1;
    2333
    2434
     
    302312                const char *pszInterpreter = NULL;
    303313                const char *pszInterpreterArgs = NULL;
    304                 psz = _getext(pszPgmName);
    305                 if (psz && (!stricmp(psz, ".cmd") || !stricmp(psz, ".bat") || !stricmp(psz, ".btm")))
     314                if (    __libc_Back_gfProcessHandlePCBatchScripts
     315                    &&  (psz = _getext(pszPgmName))
     316                    &&  (!stricmp(psz, ".cmd") || !stricmp(psz, ".bat") || !stricmp(psz, ".btm")))
    306317                {
    307318                    pszInterpreterArgs = "/C";
     
    319330                        *psz++ = '\\';
    320331                }
    321                 else
     332                else if (__libc_Back_gfProcessHandleHashBangScripts)
    322333                {
    323334                    /*
     
    353364                                if (*psz++ == '#')
    354365                                {
    355                                     while ((ch = *psz) == ' ' && ch == '\t')
     366                                    while ((ch = *psz) == ' ' || ch == '\t')
    356367                                        psz++;
    357368                                    if (*psz++ == '!')
    358369                                    {
    359                                         while ((ch = *psz) == ' ' && ch == '\t')
     370                                        while ((ch = *psz) == ' ' || ch == '\t')
    360371                                            psz++;
    361372                                        pszInterpreter = psz;
     
    370381                                        {
    371382                                            *psz++ = '\0';
    372                                             while ((ch = *psz) == ' ' && ch == '\t')
     383                                            while ((ch = *psz) == ' ' || ch == '\t')
    373384                                                psz++;
    374385                                            if (ch)
     
    420431                 * If the specified name fails, we'll try search the path for it and
    421432                 * also adding an .exe extension before we give up.
     433                 * We omit any specified path since we're frequently faced with path
     434                 * differences between OS/2 and the UNIX where the script originated.
    422435                 */
    423436                rc = __libc_back_fsResolve(pszInterpreter, BACKFS_FLAGS_RESOLVE_FULL, &szNativePath[0], NULL);
    424437                if (rc)
    425438                {
     439                    psz = _getname(pszInterpreter);
    426440                    char szPath[512];
    427                     _searchenv(pszInterpreter, "PATH", szPath); /** @todo _searchenv is not safe, it can easily overflow szPath! */
     441                    _searchenv(psz, "PATH", szPath); /** @todo _searchenv is not safe, it can easily overflow szPath! */
    428442                    if (!szPath[0])
    429443                    {
    430                         cch = strlen(pszInterpreter);
    431                         memcpy(szNativePath, pszInterpreter, cch + 1);
     444                        cch = strlen(psz);
     445                        memcpy(szNativePath, psz, cch + 1);
    432446                        _defext(szNativePath, "exe");
    433447                        if (szNativePath[cch])
     
    437451                        rc = __libc_back_fsResolve(szPath, BACKFS_FLAGS_RESOLVE_FULL, &szNativePath[0], NULL);
    438452                    if (rc)
     453                    {
     454                        LIBCLOG_MSG("Failed to find interpreter '%s'! szPath='%s'\n", pszInterpreter, szPath);
    439455                        break;
     456                    }
    440457                }
    441458
Note: See TracChangeset for help on using the changeset viewer.