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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/bin/read2.cc
          +++ new/usr/src/cmd/make/bin/read2.cc
↓ open down ↓ 103 lines elided ↑ open up ↑
 104  104                  append_string(string_start, string, string_end - string_start);
 105  105                  string_start = string->buffer.start;
 106  106                  string_end = string->text.p;
 107  107          }
 108  108          ch = *string_end;
 109  109          *string_end = (int) nul_char;
 110  110          /*
 111  111           * Check if there are any ( or [ that are not prefixed with $.
 112  112           * If there are, we have to deal with the lib.a(members) format.
 113  113           */
 114      -        for (cp = (wchar_t *) wschr(string_start, (int) parenleft_char);
      114 +        for (cp = (wchar_t *) wcschr(string_start, (int) parenleft_char);
 115  115               cp != NULL;
 116      -             cp = (wchar_t *) wschr(cp + 1, (int) parenleft_char)) {
      116 +             cp = (wchar_t *) wcschr(cp + 1, (int) parenleft_char)) {
 117  117                  if (*(cp - 1) != (int) dollar_char) {
 118  118                          *string_end = ch;
 119  119                          return enter_member_name(string_start,
 120  120                                                   cp,
 121  121                                                   string_end,
 122  122                                                   current_names,
 123  123                                                   extra_names);
 124  124                  }
 125  125          }
 126  126          *string_end = ch;
↓ open down ↓ 82 lines elided ↑ open up ↑
 209  209          lib = GETNAME(lib_start, member_start - lib_start);
 210  210          lib->is_member = true;
 211  211          member_start++;
 212  212          if (*member_start == (int) parenleft_char) {
 213  213                  /* This is really the "lib.a((entries))" format */
 214  214                  entry = true;
 215  215                  member_start++;
 216  216          }
 217  217          /* Move the library name to the buffer where we intend to build the */
 218  218          /* "lib.a(member)" for each member */
 219      -        (void) wsncpy(buffer, lib_start, member_start - lib_start);
      219 +        (void) wcsncpy(buffer, lib_start, member_start - lib_start);
 220  220          memberp = buffer + (member_start-lib_start);
 221  221          while (1) {
 222  222                  long_member_name = NULL;
 223  223                  /* Skip leading spaces */
 224  224                  for (;
 225  225                       (member_start < string_end) && iswspace(*member_start);
 226  226                       member_start++);
 227  227                  /* Find the end of the member name. Allow nested (). Detect $*/
 228  228                  for (cq = memberp, has_dollar = false, paren_count = 0;
 229  229                       (member_start < string_end) &&
↓ open down ↓ 8 lines elided ↑ open up ↑
 238  238                          case parenright_char:
 239  239                                  paren_count--;
 240  240                                  break;
 241  241                          case dollar_char:
 242  242                                  has_dollar = true;
 243  243                          }
 244  244                  }
 245  245                  /* Internalize the member name */
 246  246                  member = GETNAME(memberp, cq - memberp);
 247  247                  *cq = 0;
 248      -                if ((q = (wchar_t *) wsrchr(memberp, (int) slash_char)) == NULL) {
      248 +                if ((q = (wchar_t *) wcsrchr(memberp, (int) slash_char)) == NULL) {
 249  249                          q = memberp;
 250  250                  }
 251  251                  if ((cq - q > (int) ar_member_name_len) &&
 252  252                      !has_dollar) {
 253  253                          *cq++ = (int) parenright_char;
 254  254                          if (entry) {
 255  255                                  *cq++ = (int) parenright_char;
 256  256                          }
 257  257                          long_member_name = GETNAME(buffer, cq - buffer);
 258  258                          cq = q + (int) ar_member_name_len;
↓ open down ↓ 131 lines elided ↑ open up ↑
 390  390           * Now scan for <name>/../ and remove such combinations iff <name>
 391  391           * is not another ..
 392  392           * Each time something is removed, the whole process is restarted.
 393  393           */
 394  394  removed_one:
 395  395          name_string = string;
 396  396          string2 = name_string;          /*save for free*/
 397  397          current_component =
 398  398            cdp =
 399  399              string =
 400      -              ALLOC_WC((length = wslen(name_string)) + 1);
      400 +              ALLOC_WC((length = wcslen(name_string)) + 1);
 401  401          while (length > 0) {
 402  402                  if (((length > 3) &&
 403  403                       (name_string[0] == (int) slash_char) &&
 404  404                       (name_string[1] == (int) period_char) &&
 405  405                       (name_string[2] == (int) period_char) &&
 406  406                       (name_string[3] == (int) slash_char)) ||
 407  407                      ((length == 3) &&
 408  408                       (name_string[0] == (int) slash_char) &&
 409  409                       (name_string[1] == (int) period_char) &&
 410  410                       (name_string[2] == (int) period_char))) {
↓ open down ↓ 240 lines elided ↑ open up ↑
 651  651                  line2->body.recursive.in_depinfo = false;
 652  652                  return;
 653  653          }
 654  654          /* If this is the first target that doesnt start with a "." in the */
 655  655          /* makefile we remember that */
 656  656          Wstring tstr(target);
 657  657          wchar_t * wcb = tstr.get_string();
 658  658          if ((makefile_type == reading_makefile) &&
 659  659              (default_target_to_build == NULL) &&
 660  660              ((wcb[0] != (int) period_char) ||
 661      -             wschr(wcb, (int) slash_char))) {
      661 +             wcschr(wcb, (int) slash_char))) {
 662  662  
 663  663  /* BID 1181577: $(EMPTY_MACRO) + $(EMPTY_MACRO):
 664  664  ** The target with empty name cannot be default_target_to_build
 665  665  */
 666  666                  if (target->hash.length != 0)
 667  667                          default_target_to_build = target;
 668  668          }
 669  669          /* Check if the line is ":" or "::" */
 670  670          if (makefile_type == reading_makefile) {
 671  671                  if (target->colons == no_colon) {
↓ open down ↓ 68 lines elided ↑ open up ↑
 740  740          /* treat things differently */
 741  741          switch (makefile_type) {
 742  742          case reading_makefile:
 743  743                  /* Reading regular makefile. Just notice whether this */
 744  744                  /* redefines the rule for the  target */
 745  745                  if (command != NULL) {
 746  746                          if (line->body.line.command_template != NULL) {
 747  747                                  line->body.line.command_template_redefined =
 748  748                                    true;
 749  749                                  if ((wcb[0] == (int) period_char) &&
 750      -                                    !wschr(wcb, (int) slash_char)) {
      750 +                                    !wcschr(wcb, (int) slash_char)) {
 751  751                                          line->body.line.command_template =
 752  752                                            command;
 753  753                                  }
 754  754                          } else {
 755  755                                  line->body.line.command_template = command;
 756  756                          }
 757  757                  } else {
 758  758                          if ((wcb[0] == (int) period_char) &&
 759      -                            !wschr(wcb, (int) slash_char)) {
      759 +                            !wcschr(wcb, (int) slash_char)) {
 760  760                                  line->body.line.command_template = command;
 761  761                          }
 762  762                  }
 763  763                  break;
 764  764          case rereading_statefile:
 765  765                  /* Rereading the statefile. We only enter thing that changed */
 766  766                  /* since the previous time we read it */
 767  767                  if (!built_last_make_run_seen) {
 768  768                          for (Cmd_line next, cmd = command; cmd != NULL; cmd = next) {
 769  769                                  next = cmd->next;
↓ open down ↓ 170 lines elided ↑ open up ↑
 940  940          result->command_template = command;
 941  941          result->being_expanded = false;
 942  942          result->name = target;
 943  943          result->dependencies = NULL;
 944  944          result->target_group = target_group;
 945  945  
 946  946          /* get patterns count */
 947  947          Wstring wcb(target);
 948  948          cp = wcb.get_string();
 949  949          while (true) {
 950      -                cp = (wchar_t *) wschr(cp, (int) percent_char);
      950 +                cp = (wchar_t *) wcschr(cp, (int) percent_char);
 951  951                  if (cp != NULL) {
 952  952                          result->patterns_total++;
 953  953                          cp++;
 954  954                  } else {
 955  955                          break;
 956  956                  }
 957  957          }
 958  958          result->patterns_total++;
 959  959  
 960  960          /* allocate storage for patterns */
 961  961          result->patterns = (Name *) getmem(sizeof(Name) * result->patterns_total);
 962  962  
 963  963          /* then create patterns */
 964  964          cp = wcb.get_string();
 965  965          pattern = 0;
 966  966          while (true) {
 967      -                cp1 = (wchar_t *) wschr(cp, (int) percent_char);
      967 +                cp1 = (wchar_t *) wcschr(cp, (int) percent_char);
 968  968                  if (cp1 != NULL) {
 969  969                          result->patterns[pattern] = GETNAME(cp, cp1 - cp);
 970  970                          cp = cp1 + 1;
 971  971                          pattern++;
 972  972                  } else {
 973  973                          result->patterns[pattern] = GETNAME(cp, (int) target->hash.length - (cp - wcb.get_string()));
 974  974                          break;
 975  975                  }
 976  976          }
 977  977  
↓ open down ↓ 13 lines elided ↑ open up ↑
 991  991                          depe->target_group = NULL;
 992  992  
 993  993                          *depe_tail = depe;
 994  994                          depe_tail = &depe->next;
 995  995  
 996  996                          if (depe->name->percent) {
 997  997                                  /* get patterns count */
 998  998                                  wcb1.init(depe->name);
 999  999                                  cp = wcb1.get_string();
1000 1000                                  while (true) {
1001      -                                        cp = (wchar_t *) wschr(cp, (int) percent_char);
     1001 +                                        cp = (wchar_t *) wcschr(cp, (int) percent_char);
1002 1002                                          if (cp != NULL) {
1003 1003                                                  depe->patterns_total++;
1004 1004                                                  cp++;
1005 1005                                          } else {
1006 1006                                                  break;
1007 1007                                          }
1008 1008                                  }
1009 1009                                  depe->patterns_total++;
1010 1010  
1011 1011                                  /* allocate storage for patterns */
1012 1012                                  depe->patterns = (Name *) getmem(sizeof(Name) * depe->patterns_total);
1013 1013  
1014 1014                                  /* then create patterns */
1015 1015                                  cp = wcb1.get_string();
1016 1016                                  pattern = 0;
1017 1017                                  while (true) {
1018      -                                        cp1 = (wchar_t *) wschr(cp, (int) percent_char);
     1018 +                                        cp1 = (wchar_t *) wcschr(cp, (int) percent_char);
1019 1019                                          if (cp1 != NULL) {
1020 1020                                                  depe->patterns[pattern] = GETNAME(cp, cp1 - cp);
1021 1021                                                  cp = cp1 + 1;
1022 1022                                                  pattern++;
1023 1023                                          } else {
1024 1024                                                  depe->patterns[pattern] = GETNAME(cp, (int) depe->name->hash.length - (cp - wcb1.get_string()));
1025 1025                                                  break;
1026 1026                                          }
1027 1027                                  }
1028 1028                          }
↓ open down ↓ 532 lines elided ↑ open up ↑
1561 1561          wchar_t                 *from;
1562 1562          wchar_t                 *allocated;
1563 1563          wchar_t                 *cp;
1564 1564          wchar_t                 *tocomp;
1565 1565          int                     ncomps;
1566 1566          int                     i;
1567 1567          int                     len;
1568 1568  
1569 1569          /* Check if the path is already relative. */
1570 1570          if (to[0] != (int) slash_char) {
1571      -                (void) wscpy(result, to);
     1571 +                (void) wcscpy(result, to);
1572 1572                  return;
1573 1573          }
1574 1574  
1575 1575          MBSTOWCS(wcs_buffer, get_current_path());
1576      -        from = allocated = (wchar_t *) wsdup(wcs_buffer);
     1576 +        from = allocated = (wchar_t *) wcsdup(wcs_buffer);
1577 1577  
1578 1578          /*
1579 1579           * Find the number of components in the from name.
1580 1580           * ncomp = number of slashes + 1.
1581 1581           */
1582 1582          ncomps = 1;
1583 1583          for (cp = from; *cp != (int) nul_char; cp++) {
1584 1584                  if (*cp == (int) slash_char) {
1585 1585                          ncomps++;
1586 1586                  }
↓ open down ↓ 14 lines elided ↑ open up ↑
1601 1601                  to++;
1602 1602          }
1603 1603  
1604 1604          /*
1605 1605           * Now for some special cases. Check for exact matches and
1606 1606           * for either name terminating exactly.
1607 1607           */
1608 1608          if (*from == (int) nul_char) {
1609 1609                  if (*to == (int) nul_char) {
1610 1610                          MBSTOWCS(wcs_buffer, ".");
1611      -                        (void) wscpy(result, wcs_buffer);
     1611 +                        (void) wcscpy(result, wcs_buffer);
1612 1612                          retmem(allocated);
1613 1613                          return;
1614 1614                  }
1615 1615                  if (*to == (int) slash_char) {
1616 1616                          ncomps--;
1617 1617                          tocomp = &to[1];
1618 1618                  }
1619 1619          } else if ((*from == (int) slash_char) && (*to == (int) nul_char)) {
1620 1620                  ncomps--;
1621 1621                  tocomp = to;
1622 1622          }
1623 1623          /* Add on the ".."s. */
1624 1624          for (i = 0; i < ncomps; i++) {
1625 1625                  MBSTOWCS(wcs_buffer, "../");
1626      -                (void) wscat(result, wcs_buffer);
     1626 +                (void) wcscat(result, wcs_buffer);
1627 1627          }
1628 1628  
1629 1629          /* Add on the remainder of the to name, if any. */
1630 1630          if (*tocomp == (int) nul_char) {
1631      -                len = wslen(result);
     1631 +                len = wcslen(result);
1632 1632                  result[len - 1] = (int) nul_char;
1633 1633          } else {
1634      -                (void) wscat(result, tocomp);
     1634 +                (void) wcscat(result, tocomp);
1635 1635          }
1636 1636          retmem(allocated);
1637 1637          return;
1638 1638  }
1639 1639  
1640 1640  /*
1641 1641   *      print_rule(command)
1642 1642   *
1643 1643   *      Used when tracing the reading of rules
1644 1644   *
↓ open down ↓ 154 lines elided ↑ open up ↑
1799 1799          static wchar_t  colon_sh[4];
1800 1800          static wchar_t  colon_shell[7];
1801 1801  
1802 1802          if (colon_sh[0] == (int) nul_char) {
1803 1803                  MBSTOWCS(colon_sh, ":sh");
1804 1804                  MBSTOWCS(colon_shell, ":shell");
1805 1805          }
1806 1806          Wstring nms((*name));
1807 1807          wchar_t * wcb = nms.get_string();
1808 1808  
1809      -        colon = (wchar_t *) wsrchr(wcb, (int) colon_char);
     1809 +        colon = (wchar_t *) wcsrchr(wcb, (int) colon_char);
1810 1810          if ((colon != NULL) && (IS_WEQUAL(colon, colon_sh) || IS_WEQUAL(colon, colon_shell))) {
1811 1811                  INIT_STRING_FROM_STACK(destination, buffer);
1812 1812  
1813 1813                  if(*value == NULL) {
1814 1814                          buffer[0] = 0;
1815 1815                  } else {
1816 1816                          Wstring wcb1((*value));
1817 1817                          if (IS_WEQUAL(colon, colon_shell)) {
1818 1818                                  INIT_STRING_FROM_STACK(command, buffer1);
1819 1819                                  expand_value(*value, &command, false);
↓ open down ↓ 79 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX