Ignore:
Timestamp:
Jan 16, 2001, 8:49:10 PM (25 years ago)
Author:
umoeller
Message:

Fixes for V0.9.7.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/winh.c

    r21 r23  
    24322432 *
    24332433 *@@added V0.9.6 (2000-10-16) [umoeller]
     2434 *@@changed V0.9.7 (2001-01-15) [umoeller]: now using XSTRING
    24342435 */
    24352436
    24362437VOID CallBatchCorrectly(PPROGDETAILS pProgDetails,
    2437                         PSZ *ppszParams,            // in/out: modified parameters (reallocated)
     2438                        PXSTRING pstrParams,        // in/out: modified parameters (reallocated)
    24382439                        const char *pcszEnvVar,     // in: env var spec'g command proc
    24392440                                                    // (e.g. "OS2_SHELL"); can be NULL
     
    24422443    // XXX.CMD file as executable:
    24432444    // fix args to /C XXX.CMD
    2444     XSTRING strNewParams;
    2445     xstrInit(&strNewParams, 200);
    2446     xstrcpy(&strNewParams, "/C ");
    2447     xstrcat(&strNewParams, pProgDetails->pszExecutable);
    2448     if (*ppszParams)
    2449     {
    2450         // append old params
    2451         xstrcat(&strNewParams, " ");
    2452         xstrcat(&strNewParams, *ppszParams);
    2453         free(*ppszParams);
    2454     }
    2455     *ppszParams = strNewParams.psz;
    2456             // freed by caller
     2445
     2446    PSZ     pszOldParams = NULL;
     2447    ULONG   ulOldParamsLength = pstrParams->ulLength;
     2448    if (ulOldParamsLength)
     2449        // we have parameters already:
     2450        // make a backup... we'll append that later
     2451        pszOldParams = strdup(pstrParams->psz);
     2452
     2453    // set new params to "/C filename.cmd"
     2454    xstrcpy(pstrParams, "/C ", 0);
     2455    xstrcat(pstrParams,
     2456            pProgDetails->pszExecutable,
     2457            0);
     2458
     2459    if (pszOldParams)
     2460    {
     2461        // .cmd had params:
     2462        // append space and old params
     2463        xstrcatc(pstrParams, ' ');
     2464        xstrcat(pstrParams,
     2465                pszOldParams,
     2466                ulOldParamsLength);
     2467        free(pszOldParams);
     2468    }
    24572469
    24582470    // set executable to $(OS2_SHELL)
     
    25082520{
    25092521    HAPP            happ = NULLHANDLE;
    2510     PSZ             pszParamsPatched = NULL;
     2522    XSTRING         strParamsPatched;
    25112523    BOOL            fIsWindowsApp = FALSE,
    25122524                    fIsWindowsEnhApp = FALSE;
     
    25272539    // we need this for string manipulations below...
    25282540    if (ProgDetails.pszParameters)
    2529         pszParamsPatched = strdup(ProgDetails.pszParameters);
     2541        xstrInitCopy(&strParamsPatched,
     2542                     ProgDetails.pszParameters,
     2543                     100);
     2544    else
     2545        // no old params:
     2546        xstrInit(&strParamsPatched, 100);
    25302547
    25312548    // _Pmpf((__FUNCTION__ ": old progc: 0x%lX", pcProgDetails->progt.progc));
     
    25872604        {
    25882605            // enhanced Win-OS/2 session:
    2589             XSTRING str2;
    2590             xstrInit(&str2, 200);
    2591             xstrcpy(&str2, "/3 ");
    2592             if (pszParamsPatched)
     2606            PSZ psz = NULL;
     2607            if (strParamsPatched.ulLength)
     2608                // "/3 " + existing params
     2609                psz = strdup(strParamsPatched.psz);
     2610
     2611            xstrcpy(&strParamsPatched, "/3 ", 0);
     2612
     2613            if (psz)
    25932614            {
    2594                 // append existing params
    2595                 xstrcat(&str2, pszParamsPatched);
    2596                 free(pszParamsPatched);
     2615                xstrcat(&strParamsPatched, psz, 0);
     2616                free(psz);
    25972617            }
    2598 
    2599             pszParamsPatched = str2.psz;
    26002618        }
    26012619
     
    26332651                    {
    26342652                        CallBatchCorrectly(&ProgDetails,
    2635                                            &pszParamsPatched,
     2653                                           &strParamsPatched,
    26362654                                           "OS2_SHELL",
    26372655                                           "CMD.EXE");
     
    26492667                    {
    26502668                        CallBatchCorrectly(&ProgDetails,
    2651                                            &pszParamsPatched,
     2669                                           &strParamsPatched,
    26522670                                           NULL,
    26532671                                           "COMMAND.COM");
     
    27162734    // _Pmpf(("    new progc: 0x%lX", ProgDetails.progt.progc));
    27172735
    2718     ProgDetails.pszParameters = pszParamsPatched;
     2736    ProgDetails.pszParameters = strParamsPatched.psz;
    27192737
    27202738    happ = WinStartApp(hwndNotify,
    27212739                                // receives WM_APPTERMINATENOTIFY
    27222740                       &ProgDetails,
    2723                        pszParamsPatched,
     2741                       strParamsPatched.psz,
    27242742                       NULL,            // "reserved", PMREF says...
    27252743                       SAF_INSTALLEDCMDLINE);
     
    27342752    // _Pmpf((__FUNCTION__ ": got happ 0x%lX", happ));
    27352753
    2736     if (pszParamsPatched)
    2737         free(pszParamsPatched);
     2754    xstrClear(&strParamsPatched);
    27382755    if (pszWinOS2Env)
    27392756        free(pszWinOS2Env);
     
    30683085 *@@ winhReplaceWindowText:
    30693086 *      this is a combination of winhQueryWindowText
    3070  *      and xstrrpl (stringh.c) to replace substrings
    3071  *      in a window.
     3087 *      and strhFindReplace to replace substrings in a window.
    30723088 *
    30733089 *      This is useful for filling in placeholders
     
    30933109    {
    30943110        ULONG ulOfs = 0;
    3095         if (strhrpl(&pszText, &ulOfs, pszSearch, pszReplaceWith) > 0)
     3111        if (strhFindReplace(&pszText, &ulOfs, pszSearch, pszReplaceWith) > 0)
    30963112        {
    30973113            WinSetWindowText(hwnd, pszText);
Note: See TracChangeset for help on using the changeset viewer.