Fix Issue #92; see FIXES.
This commit is contained in:
parent
9b80a7c137
commit
1b3984634f
5
FIXES
5
FIXES
@ -25,6 +25,11 @@ THIS SOFTWARE.
|
|||||||
This file lists all bug fixes, changes, etc., made since the AWK book
|
This file lists all bug fixes, changes, etc., made since the AWK book
|
||||||
was sent to the printers in August, 1987.
|
was sent to the printers in August, 1987.
|
||||||
|
|
||||||
|
August 4, 2020:
|
||||||
|
In run.c, use non-restartable multibyte routines to attain
|
||||||
|
portability to DJGPP. Should fix Issue 92. Thanks to Albert Wik
|
||||||
|
for the report and to Todd Miller for the suggested fix.
|
||||||
|
|
||||||
July 30, 2020:
|
July 30, 2020:
|
||||||
Merge PRs 88-91 which fix small bugs. Thanks to Todd Miller and
|
Merge PRs 88-91 which fix small bugs. Thanks to Todd Miller and
|
||||||
Tim van der Molen for the fixes.
|
Tim van der Molen for the fixes.
|
||||||
|
2
main.c
2
main.c
@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|||||||
THIS SOFTWARE.
|
THIS SOFTWARE.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
const char *version = "version 20200730";
|
const char *version = "version 20200804";
|
||||||
|
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
16
run.c
16
run.c
@ -1521,7 +1521,6 @@ static char *nawk_convert(const char *s, int (*fun_c)(int),
|
|||||||
char *pbuf = NULL;
|
char *pbuf = NULL;
|
||||||
const char *ps = NULL;
|
const char *ps = NULL;
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
mbstate_t mbs, mbs2;
|
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
size_t sz = MB_CUR_MAX;
|
size_t sz = MB_CUR_MAX;
|
||||||
|
|
||||||
@ -1536,17 +1535,24 @@ static char *nawk_convert(const char *s, int (*fun_c)(int),
|
|||||||
/* upper/lower character may be shorter/longer */
|
/* upper/lower character may be shorter/longer */
|
||||||
buf = tostringN(s, strlen(s) * sz + 1);
|
buf = tostringN(s, strlen(s) * sz + 1);
|
||||||
|
|
||||||
memset(&mbs, 0, sizeof(mbs));
|
(void) mbtowc(NULL, NULL, 0); /* reset internal state */
|
||||||
memset(&mbs2, 0, sizeof(mbs2));
|
/*
|
||||||
|
* Reset internal state here too.
|
||||||
|
* Assign result to avoid a compiler warning. (Casting to void
|
||||||
|
* doesn't work.)
|
||||||
|
* Increment said variable to avoid a different warning.
|
||||||
|
*/
|
||||||
|
int unused = wctomb(NULL, L'\0');
|
||||||
|
unused++;
|
||||||
|
|
||||||
ps = s;
|
ps = s;
|
||||||
pbuf = buf;
|
pbuf = buf;
|
||||||
while (n = mbrtowc(&wc, ps, sz, &mbs),
|
while (n = mbtowc(&wc, ps, sz),
|
||||||
n > 0 && n != (size_t)-1 && n != (size_t)-2)
|
n > 0 && n != (size_t)-1 && n != (size_t)-2)
|
||||||
{
|
{
|
||||||
ps += n;
|
ps += n;
|
||||||
|
|
||||||
n = wcrtomb(pbuf, fun_wc(wc), &mbs2);
|
n = wctomb(pbuf, fun_wc(wc));
|
||||||
if (n == (size_t)-1)
|
if (n == (size_t)-1)
|
||||||
FATAL("illegal wide character %s", s);
|
FATAL("illegal wide character %s", s);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user