changed awk to less sensitive about encoding when loading environment.
fixed a bug of setting encoding wrongly with --script-encoding in cmd/awk/awk.c
This commit is contained in:
parent
9588bf2910
commit
ca1d1ede66
@ -812,7 +812,7 @@ static int comparg (int argc, qse_char_t* argv[], struct arg_t* arg)
|
|||||||
for (i = 0; i < isfl ; i++)
|
for (i = 0; i < isfl ; i++)
|
||||||
{
|
{
|
||||||
if (isf[i].type == QSE_AWK_PARSESTD_FILE)
|
if (isf[i].type == QSE_AWK_PARSESTD_FILE)
|
||||||
isf[isfl].u.file.cmgr = arg->script_cmgr;
|
isf[i].u.file.cmgr = arg->script_cmgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
isf[isfl].type = QSE_AWK_PARSESTD_NULL;
|
isf[isfl].type = QSE_AWK_PARSESTD_NULL;
|
||||||
@ -1225,7 +1225,6 @@ int qse_main (int argc, qse_achar_t* argv[])
|
|||||||
/* nothing special */
|
/* nothing special */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qse_openstdsios ();
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
codepage = GetConsoleOutputCP();
|
codepage = GetConsoleOutputCP();
|
||||||
@ -1256,7 +1255,9 @@ int qse_main (int argc, qse_achar_t* argv[])
|
|||||||
|
|
||||||
open_mpi (&mpi, argc, argv);
|
open_mpi (&mpi, argc, argv);
|
||||||
|
|
||||||
|
qse_openstdsios ();
|
||||||
ret = qse_runmain (argc, argv, awk_main);
|
ret = qse_runmain (argc, argv, awk_main);
|
||||||
|
qse_closestdsios ();
|
||||||
|
|
||||||
close_mpi (&mpi);
|
close_mpi (&mpi);
|
||||||
|
|
||||||
@ -1264,7 +1265,6 @@ int qse_main (int argc, qse_achar_t* argv[])
|
|||||||
WSACleanup ();
|
WSACleanup ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qse_closestdsios ();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1945,8 +1945,6 @@ int qse_main (int argc, qse_achar_t* argv[])
|
|||||||
/* nothing */
|
/* nothing */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qse_openstdsios ();
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
codepage = GetConsoleOutputCP();
|
codepage = GetConsoleOutputCP();
|
||||||
@ -1980,7 +1978,9 @@ int qse_main (int argc, qse_achar_t* argv[])
|
|||||||
SSL_library_init ();
|
SSL_library_init ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
qse_openstdsios ();
|
||||||
ret = qse_runmain (argc, argv, httpd_main);
|
ret = qse_runmain (argc, argv, httpd_main);
|
||||||
|
qse_closestdsios ();
|
||||||
|
|
||||||
#if defined(HAVE_SSL)
|
#if defined(HAVE_SSL)
|
||||||
/* ERR_remove_state() should be called for each thread if the application is thread */
|
/* ERR_remove_state() should be called for each thread if the application is thread */
|
||||||
@ -1995,6 +1995,5 @@ int qse_main (int argc, qse_achar_t* argv[])
|
|||||||
WSACleanup ();
|
WSACleanup ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qse_closestdsios ();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1029,8 +1029,6 @@ int qse_main (int argc, qse_achar_t* argv[])
|
|||||||
/* nothing */
|
/* nothing */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qse_openstdsios ();
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
codepage = GetConsoleOutputCP();
|
codepage = GetConsoleOutputCP();
|
||||||
if (codepage == CP_UTF8)
|
if (codepage == CP_UTF8)
|
||||||
@ -1051,9 +1049,10 @@ int qse_main (int argc, qse_achar_t* argv[])
|
|||||||
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
qse_openstdsios ();
|
||||||
ret = qse_runmain (argc, argv, sed_main);
|
ret = qse_runmain (argc, argv, sed_main);
|
||||||
|
|
||||||
qse_closestdsios ();
|
qse_closestdsios ();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1914,16 +1914,16 @@ static int __build_environ (
|
|||||||
|
|
||||||
*eq = QSE_MT('\0');
|
*eq = QSE_MT('\0');
|
||||||
|
|
||||||
kptr = qse_mbstowcsdup (envarr[count], &klen, rtx->awk->mmgr);
|
/* mbstowcsdup() may fail for invalid encoding. as the environment
|
||||||
vptr = qse_mbstowcsdup (eq + 1, QSE_NULL, rtx->awk->mmgr);
|
* variaables are not under control, call mbstowcsalldup() instead
|
||||||
|
* to go on despite encoding failure */
|
||||||
|
kptr = qse_mbstowcsalldup (envarr[count], &klen, rtx->awk->mmgr);
|
||||||
|
vptr = qse_mbstowcsalldup (eq + 1, QSE_NULL, rtx->awk->mmgr);
|
||||||
if (kptr == QSE_NULL || vptr == QSE_NULL)
|
if (kptr == QSE_NULL || vptr == QSE_NULL)
|
||||||
{
|
{
|
||||||
if (kptr) QSE_MMGR_FREE (rtx->awk->mmgr, kptr);
|
if (kptr) QSE_MMGR_FREE (rtx->awk->mmgr, kptr);
|
||||||
qse_awk_rtx_refdownval (rtx, v_env);
|
qse_awk_rtx_refdownval (rtx, v_env);
|
||||||
|
|
||||||
/* mbstowcsdup() may fail for invalid encoding.
|
|
||||||
* so setting the error code to ENOMEM may not
|
|
||||||
* be really accurate */
|
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1942,9 +1942,6 @@ static int __build_environ (
|
|||||||
if (kptr) QSE_MMGR_FREE (rtx->awk->mmgr, kptr);
|
if (kptr) QSE_MMGR_FREE (rtx->awk->mmgr, kptr);
|
||||||
qse_awk_rtx_refdownval (rtx, v_env);
|
qse_awk_rtx_refdownval (rtx, v_env);
|
||||||
|
|
||||||
/* mbstowcsdup() may fail for invalid encoding.
|
|
||||||
* so setting the error code to ENOMEM may not
|
|
||||||
* be really accurate */
|
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user