Print this page
make: use the more modern wchar routines, not widec.h

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/lib/mksh/misc.cc
          +++ new/usr/src/cmd/make/lib/mksh/misc.cc
↓ open down ↓ 162 lines elided ↑ open up ↑
 163  163          register Name           np;
 164  164          static Name_rec         empty_Name;
 165  165          char                    *tmp_mbs_buffer = NULL;
 166  166          char                    *mbs_name = mbs_buffer;
 167  167  
 168  168          /*
 169  169           * First figure out how long the string is.
 170  170           * If the len argument is -1 we count the chars here.
 171  171           */
 172  172          if (len == FIND_LENGTH) {
 173      -                length = wslen(name);
      173 +                length = wcslen(name);
 174  174          } else {
 175  175                  length = len;
 176  176          }
 177  177  
 178  178          Wstring ws;
 179  179          ws.init(name, length);
 180  180          if (length >= MAXPATHLEN) {
 181  181                  mbs_name = tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1);
 182  182          }
 183  183          (void) wcstombs(mbs_name, ws.get_string(), (length * MB_LEN_MAX) + 1);
↓ open down ↓ 490 lines elided ↑ open up ↑
 674  674   *              from            The source (C style) string
 675  675   *              to              The destination (make style) string
 676  676   *              length          The length of the from string
 677  677   *
 678  678   *      Global variables used:
 679  679   */
 680  680  void
 681  681  append_string(register wchar_t *from, register String to, register int length)
 682  682  {
 683  683          if (length == FIND_LENGTH) {
 684      -                length = wslen(from);
      684 +                length = wcslen(from);
 685  685          }
 686  686          if (to->buffer.start == NULL) {
 687  687                  expand_string(to, 32 + length);
 688  688          }
 689  689          if (to->buffer.end - to->text.p <= length) {
 690  690                  expand_string(to,
 691  691                                (to->buffer.end - to->buffer.start) * 2 +
 692  692                                length);
 693  693          }
 694  694          if (length > 0) {
 695      -                (void) wsncpy(to->text.p, from, length);
      695 +                (void) wcsncpy(to->text.p, from, length);
 696  696                  to->text.p += length;
 697  697          }
 698  698          *(to->text.p) = (int) nul_char;
 699  699  }
 700  700  
 701  701  wchar_t * get_wstring(char *from) {
 702  702          if(from == NULL) {
 703  703                  return NULL;
 704  704          }
 705  705          getwstring_count++;
↓ open down ↓ 54 lines elided ↑ open up ↑
 760  760          if (string->buffer.end - string->buffer.start >= length) {
 761  761                  /* If we really don't need more memory. */
 762  762                  return;
 763  763          }
 764  764          /*
 765  765           * Get more memory, copy the string and free the old buffer if
 766  766           * it is was malloc()'ed.
 767  767           */
 768  768          expandstring_count++;
 769  769          p = ALLOC_WC(length);
 770      -        (void) wscpy(p, string->buffer.start);
      770 +        (void) wcscpy(p, string->buffer.start);
 771  771          string->text.p = p + (string->text.p - string->buffer.start);
 772  772          string->text.end = p + (string->text.end - string->buffer.start);
 773  773          string->buffer.end = p + length;
 774  774          if (string->free_after_use) {
 775  775                  retmem(string->buffer.start);
 776  776          }
 777  777          string->buffer.start = p;
 778  778          string->free_after_use = true;
 779  779  }
 780  780  
↓ open down ↓ 333 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX