[BACK]Return to run.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / awk

Diff for /src/usr.bin/awk/run.c between version 1.66 and 1.67

version 1.66, 2020/07/30 17:45:44 version 1.67, 2020/08/11 16:57:05
Line 120 
Line 120 
                 if (rminlen)                  if (rminlen)
                         minlen += quantum - rminlen;                          minlen += quantum - rminlen;
                 tbuf = realloc(*pbuf, minlen);                  tbuf = realloc(*pbuf, minlen);
                 DPRINTF("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, *pbuf, tbuf);                  DPRINTF("adjbuf %s: %d %d (pbuf=%p, tbuf=%p)\n", whatrtn, *psiz, minlen, (void*)*pbuf, (void*)tbuf);
                 if (tbuf == NULL) {                  if (tbuf == NULL) {
                         if (whatrtn)                          if (whatrtn)
                                 FATAL("out of memory in %s", whatrtn);                                  FATAL("out of memory in %s", whatrtn);
Line 1526 
Line 1526 
         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;
   
Line 1541 
Line 1540 
                 /* 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);
   
Line 1941 
Line 1947 
         Cell *x;          Cell *x;
         size_t i;          size_t i;
         bool stat;          bool stat;
   
         x = execute(a[0]);          x = execute(a[0]);
         getsval(x);          getsval(x);
         stat = true;          stat = true;

Legend:
Removed from v.1.66  
changed lines
  Added in v.1.67