rework string pooling; disable our own (rely on compiler’s)…
• if HAVE_STRING_POOLING is set to 1 • if HAVE_STRING_POOLING is set to 2 and not GCC < 4 is used • if HAVE_STRING_POOLING is not set to 0 and LLVM or GCC >= 4 is used Closes: LP#1580348
This commit is contained in:
32
main.c
32
main.c
@ -34,7 +34,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.311 2016/07/24 23:10:03 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.312 2016/07/25 00:04:45 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -63,7 +63,7 @@ static const char initsubs[] =
|
||||
|
||||
static const char *initcoms[] = {
|
||||
Ttypeset, "-r", initvsn, NULL,
|
||||
Ttypeset, "-x", "HOME", "PATH", "SHELL", NULL,
|
||||
Ttypeset, "-x", "HOME", TPATH, TSHELL, NULL,
|
||||
Ttypeset, "-i10", "COLUMNS", "LINES", "SECONDS", "TMOUT", NULL,
|
||||
Talias,
|
||||
"integer=\\typeset -i",
|
||||
@ -82,12 +82,12 @@ static const char *initcoms[] = {
|
||||
/* this is what AT&T ksh seems to track, with the addition of emacs */
|
||||
Talias, "-tU",
|
||||
Tcat, "cc", "chmod", "cp", "date", "ed", "emacs", "grep", "ls",
|
||||
"make", "mv", "pr", "rm", "sed", "sh", "vi", "who", NULL,
|
||||
"make", "mv", "pr", "rm", "sed", Tsh, "vi", "who", NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const char *restr_com[] = {
|
||||
Ttypeset, "-r", "PATH", "ENV", "SHELL", NULL
|
||||
Ttypeset, "-r", TPATH, "ENV", TSHELL, NULL
|
||||
};
|
||||
|
||||
static bool initio_done;
|
||||
@ -149,7 +149,7 @@ chvt_reinit(void)
|
||||
}
|
||||
|
||||
static const char *empty_argv[] = {
|
||||
"mksh", NULL
|
||||
Tmksh, NULL
|
||||
};
|
||||
|
||||
static uint8_t
|
||||
@ -333,7 +333,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
|
||||
* Set PATH to def_path (will set the path global variable).
|
||||
* (import of environment below will probably change this setting).
|
||||
*/
|
||||
vp = global("PATH");
|
||||
vp = global(TPATH);
|
||||
/* setstr can't fail here */
|
||||
setstr(vp, def_path, KSH_RETURN_ERROR);
|
||||
|
||||
@ -366,11 +366,11 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
|
||||
substitute(initsubs, 0);
|
||||
|
||||
/* Figure out the current working directory and set $PWD */
|
||||
vp = global("PWD");
|
||||
vp = global(TPWD);
|
||||
cp = str_val(vp);
|
||||
/* Try to use existing $PWD if it is valid */
|
||||
set_current_wd((mksh_abspath(cp) && test_eval(NULL, TO_FILEQ, cp, ".",
|
||||
true)) ? cp : NULL);
|
||||
set_current_wd((mksh_abspath(cp) && test_eval(NULL, TO_FILEQ, cp,
|
||||
Tdot, true)) ? cp : NULL);
|
||||
if (current_wd[0])
|
||||
simplify_path(current_wd);
|
||||
/* Only set pwd if we know where we are or if it had a bogus value */
|
||||
@ -440,7 +440,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
|
||||
} else if (Flag(FCOMMAND)) {
|
||||
s = pushs(SSTRINGCMDLINE, ATEMP);
|
||||
if (!(s->start = s->str = argv[argi++]))
|
||||
errorf("-c %s", "requires an argument");
|
||||
errorf(Tf_optfoo, "", "", 'c', Treq_arg);
|
||||
while (*s->str) {
|
||||
if (*s->str != ' ' && ctype(*s->str, C_QUOTE))
|
||||
break;
|
||||
@ -475,7 +475,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
|
||||
SHF_MAPHI | SHF_CLEXEC);
|
||||
if (s->u.shf == NULL) {
|
||||
shl_stdout_ok = false;
|
||||
warningf(true, "%s: %s", s->file, cstrerror(errno));
|
||||
warningf(true, Tf_sD_s, s->file, cstrerror(errno));
|
||||
/* mandated by SUSv4 */
|
||||
exstat = 127;
|
||||
unwind(LERROR);
|
||||
@ -1129,7 +1129,7 @@ tty_init_fd(void)
|
||||
goto got_fd;
|
||||
}
|
||||
#endif
|
||||
if ((fd = open("/dev/tty", O_RDWR, 0)) >= 0) {
|
||||
if ((fd = open(T_devtty, O_RDWR, 0)) >= 0) {
|
||||
do_close = true;
|
||||
goto got_fd;
|
||||
}
|
||||
@ -1186,13 +1186,13 @@ vwarningf(unsigned int flags, const char *fmt, va_list ap)
|
||||
{
|
||||
if (fmt) {
|
||||
if (flags & VWARNINGF_INTERNAL)
|
||||
shf_fprintf(shl_out, "internal error: ");
|
||||
shf_fprintf(shl_out, Tf_sD_, "internal error");
|
||||
if (flags & VWARNINGF_ERRORPREFIX)
|
||||
error_prefix(tobool(flags & VWARNINGF_FILELINE));
|
||||
if ((flags & VWARNINGF_BUILTIN) &&
|
||||
/* not set when main() calls parse_args() */
|
||||
builtin_argv0 && builtin_argv0 != kshname)
|
||||
shf_fprintf(shl_out, "%s: ", builtin_argv0);
|
||||
shf_fprintf(shl_out, Tf_sD_, builtin_argv0);
|
||||
shf_vfprintf(shl_out, fmt, ap);
|
||||
shf_putchar('\n', shl_out);
|
||||
}
|
||||
@ -1301,7 +1301,7 @@ error_prefix(bool fileline)
|
||||
/* Avoid foo: foo[2]: ... */
|
||||
if (!fileline || !source || !source->file ||
|
||||
strcmp(source->file, kshname) != 0)
|
||||
shf_fprintf(shl_out, "%s: ", kshname + (*kshname == '-'));
|
||||
shf_fprintf(shl_out, Tf_sD_, kshname + (*kshname == '-'));
|
||||
if (fileline && source && source->file != NULL) {
|
||||
shf_fprintf(shl_out, "%s[%lu]: ", source->file,
|
||||
(unsigned long)(source->errline ?
|
||||
@ -1371,7 +1371,7 @@ initio(void)
|
||||
if ((lfp = getenv("SDMKSH_PATH")) == NULL) {
|
||||
if ((lfp = getenv("HOME")) == NULL || !mksh_abspath(lfp))
|
||||
errorf("cannot get home directory");
|
||||
lfp = shf_smprintf("%s/mksh-dbg.txt", lfp);
|
||||
lfp = shf_smprintf(Tf_sSs, lfp, "mksh-dbg.txt");
|
||||
}
|
||||
|
||||
if ((shl_dbg_fd = open(lfp, O_WRONLY | O_APPEND | O_CREAT, 0600)) < 0)
|
||||
|
Reference in New Issue
Block a user