VirtualBox

Changeset 1298 in kBuild


Ignore:
Timestamp:
Dec 1, 2007 8:11:25 PM (17 years ago)
Author:
bird
Message:

better check for the kmk shell. don't freak out and use the shell on double-quote (probably a bug).

Location:
trunk/src/kmk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/job.c

    r1290 r1298  
    2929#ifdef CONFIG_WITH_KMK_BUILTIN
    3030# include "kmkbuiltin.h"
     31#endif
     32#ifdef KMK
     33# include "kbuild.h"
    3134#endif
    3235
     
    25222525  static char *sh_cmds[] = { 0 };
    25232526#else  /* must be UNIX-ish */
    2524   static char sh_chars[] = "#;\"*?[]&|<>(){}$`^~!";
    2525   static char *sh_cmds[] = { ".", ":", "break", "case", "cd", "continue",
     2527  static char sh_chars_sh[] = "#;\"*?[]&|<>(){}$`^~!";                          /* kmk: +_sh */
     2528  static char *sh_cmds_sh[] = { ".", ":", "break", "case", "cd", "continue",    /* kmk: +_sh */
    25262529                             "eval", "exec", "exit", "export", "for", "if",
    25272530                             "login", "logout", "read", "readonly", "set",
     
    25342537  static char *sh_chars_sh = sh_chars;
    25352538# endif  /* HAVE_DOS_PATHS */
     2539# ifdef KMK
     2540  char*  sh_chars = sh_chars_sh;
     2541  char** sh_cmds = sh_cmds_sh;
     2542# endif
     2543#endif
     2544#ifdef KMK
     2545  static char sh_chars_kash[] = "#;*?[]&|<>(){}$`^~!";                          /* note: no \" */
     2546  static char *sh_cmds_kash[] = {
     2547      ".", ":", "break", "case", "cd", "continue",
     2548      "echo", "eval", "exec", "exit", "export", "for", "if",
     2549      "login", "logout", "read", "readonly", "set",
     2550      "shift", "switch", "test", "times", "trap",
     2551      "umask", "wait", "while", 0
     2552  };
     2553  int is_kmk_shell = 0;
    25362554#endif
    25372555  int i;
     
    25642582
    25652583  /* See if it is safe to parse commands internally.  */
     2584#ifdef KMK /* kmk_ash and kmk_kash are both fine, kmk_ash is the default btw. */
     2585  if (shell == 0)
     2586    {
     2587      is_kmk_shell = 1;
     2588      shell = (char *)get_default_kbuild_shell ();
     2589    }
     2590  else if (!strcmp (shell, get_default_kbuild_shell()))
     2591    is_kmk_shell = 1;
     2592  else
     2593    {
     2594      const char *psz = strstr (shell, "/kmk_ash");
     2595      if (psz)
     2596        psz += sizeof ("/kmk_ash") - 1;
     2597      else
     2598        {
     2599          psz = strstr (shell, "/kmk_kash");
     2600          if (psz)
     2601            psz += sizeof ("/kmk_kash") - 1;
     2602        }
     2603# if defined (__OS2__) || defined (_WIN32) || defined (WINDOWS32)
     2604      is_kmk_shell = psz && (*psz == '\0' || !stricmp (psz, ".exe"));
     2605# else
     2606      is_kmk_shell = psz && *psz == '\0';
     2607# endif
     2608    }
     2609  if (is_kmk_shell)
     2610    {
     2611      sh_chars = sh_chars_kash;
     2612      sh_cmds = sh_cmds_kash;
     2613    }
     2614#else /* !KMK */
    25662615  if (shell == 0)
    25672616    shell = default_shell;
     2617#endif /* !KMK */
    25682618#ifdef WINDOWS32
    25692619  else if (strcmp (shell, default_shell))
     
    26132663#else  /* !__MSDOS__ */
    26142664  else if (strcmp (shell, default_shell))
    2615 # ifndef KMK
    26162665    goto slow;
    2617 # else /* KMK */
    2618     {
    2619       /* Allow ash from kBuild. */
    2620       const char *psz = strstr(shell, "/kmk_ash");
    2621       if (   !psz
    2622           || (!psz[sizeof("/kmk_ash")] && psz[sizeof("/kmk_ash")] == '.')) /* FIXME: this test looks bogus... */
    2623         goto slow;
    2624     }
    2625 # endif  /* KMK */
    26262666#endif /* !__MSDOS__ && !__EMX__ */
    26272667#endif /* not WINDOWS32 */
  • trunk/src/kmk/kbuild.c

    r1128 r1298  
    134134            szTmp[rc] = '\0';
    135135    }
    136    
     136
    137137#elif defined(WINDOWS32)
    138138    if (GetModuleFileName(GetModuleHandle(NULL), szTmp, GET_PATH_MAX))
     
    167167                    break;
    168168                }
    169             }   
     169            }
    170170
    171171            /* next */
     
    176176        free(pszCopy);
    177177    }
    178 #endif       
     178#endif
    179179
    180180    if (rc < 0)
     
    204204 * Determin the PATH_KBUILD value.
    205205 *
    206  * @returns Pointer to static buffer to be treated as read only!
     206 * @returns Pointer to static a buffer containing the value (consider it read-only).
    207207 */
    208208const char *get_path_kbuild(void)
     
    236236 * Determin the PATH_KBUILD_BIN value.
    237237 *
    238  * @returns Pointer to static buffer to be treated as read only!
     238 * @returns Pointer to static a buffer containing the value (consider it read-only).
    239239 */
    240240const char *get_path_kbuild_bin(void)
     
    276276}
    277277
     278
     279/**
     280 * Determin the location of default kBuild shell.
     281 *
     282 * @returns Pointer to static a buffer containing the location (consider it read-only).
     283 */
     284const char *get_default_kbuild_shell(void)
     285{
     286    static char *s_pszDefaultShell = NULL;
     287    if (!s_pszDefaultShell)
     288      {
     289#if defined(__OS2__) || defined(_WIN32) || defined(WINDOWS32)
     290        static const char s_szShellName[] = "/kmk_ash.exe";
     291#else
     292        static const char s_szShellName[] = "/kmk_ash";
     293#endif
     294        const char *pszBin = get_path_kbuild_bin();
     295        size_t cchBin = strlen(pszBin);
     296        s_pszDefaultShell = xmalloc(cchBin + sizeof(s_szShellName));
     297        memcpy(s_pszDefaultShell, pszBin, cchBin);
     298        memcpy(&s_pszDefaultShell[cchBin], s_szShellName, sizeof(s_szShellName));
     299      }
     300    return s_pszDefaultShell;
     301}
    278302
    279303#ifdef KMK_HELPERS
  • trunk/src/kmk/kbuild.h

    r933 r1298  
    3737const char *get_path_kbuild(void);
    3838const char *get_path_kbuild_bin(void);
     39const char *get_default_kbuild_shell(void);
    3940
    4041#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette