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


 173                         *(make_machines_list_mb +
 174                           strlen(MAKE_MACHINES->string_mb) +
 175                           1 +
 176                           make_machines_buf.st_size) = (int) nul_char;
 177                         if (putenv(make_machines_list_mb) != 0) {
 178                                 warning(gettext("Couldn't put contents of %s in environment"),
 179                                         make_machines_name->string_mb);
 180                         } else {
 181                                 make_machines_list_mb += strlen(MAKE_MACHINES->string_mb) + 1;
 182                                 make_machines_list = ALLOC_WC(strlen(make_machines_list_mb) + 1);
 183                                 (void) mbstowcs(make_machines_list,
 184                                                 make_machines_list_mb,
 185                                                 (strlen(make_machines_list_mb) + 1));
 186                         }
 187                 }
 188         }
 189 
 190         uname(&uts_info);
 191         strcpy(local_host_mb, &uts_info.nodename[0]);
 192         MBSTOWCS(local_host, local_host_mb);
 193         local_host_wslen = wslen(local_host);
 194 
 195         // There is no getdomainname() function on Solaris.
 196         // And netname2host() function does not work on Linux.
 197         // So we have to use different APIs.
 198         if (host2netname(mbs_buffer, NULL, NULL) &&
 199             netname2host(mbs_buffer, mbs_buffer2, MAXNETNAMELEN+1)) {
 200                 MBSTOWCS(full_host, mbs_buffer2);
 201                 full_host_wslen = wslen(full_host);
 202         }
 203 
 204         for (ms = make_machines_list;
 205              (ms) && (*ms );
 206              ) {
 207                 /*
 208                  * Skip white space and comments till you reach
 209                  * a machine name.
 210                  */
 211                 pskip_till_next_word(&ms);
 212 
 213                 /*
 214                  * If we haven't reached the end of file, process the
 215                  * machine name.
 216                  */
 217                 if (*ms) {
 218                         /* 
 219                          * If invalid machine name decrement counter 
 220                          * and skip line.
 221                          */
 222                         mp = ms;
 223                         SKIPWORD(ms);
 224                         c = *ms;
 225                         *ms++ = '\0'; /* Append null to machine name. */
 226                         /*
 227                          * If this was the beginning of a comment
 228                          * (we overwrote a # sign) and it's not
 229                          * end of line yet, shift the # sign.
 230                          */
 231                         if ((c == '#') && (*ms != '\n') && (*ms)) {
 232                                 *ms = '#';
 233                         }
 234                         WCSTOMBS(mbs_buffer, mp);
 235                         /*
 236                          * Print "Ignoring unknown host" if:
 237                          * 1) hostname is longer than MAX_HOSTNAMELEN, or
 238                          * 2) hostname is unknown
 239                          */
 240                         if ((wslen(mp) > MAX_HOSTNAMELEN) ||
 241                             ((hp = gethostbyname(mbs_buffer)) == NULL)) {
 242                                 warning(gettext("Ignoring unknown host %s"),
 243                                         mbs_buffer);
 244                                 SKIPTOEND(ms);
 245                                 /* Increment ptr if not end of file. */
 246                                 if (*ms) {
 247                                         ms++;
 248                                 }
 249                         } else {
 250                                 /* Compare current hostname with local_host. */
 251                                 if (wslen(mp) == local_host_wslen &&
 252                                     IS_WEQUALN(mp, local_host, local_host_wslen)) {
 253                                         /*
 254                                          * Bingo, local_host is in .make.machines.
 255                                          * Continue reading.
 256                                          */
 257                                         pmake_max_jobs = PMAKE_DEF_MAX_JOBS;
 258                                 /* Compare current hostname with full_host. */
 259                                 } else if (wslen(mp) == full_host_wslen &&
 260                                            IS_WEQUALN(mp, full_host, full_host_wslen)) {
 261                                         /*
 262                                          * Bingo, full_host is in .make.machines.
 263                                          * Continue reading.
 264                                          */
 265                                         pmake_max_jobs = PMAKE_DEF_MAX_JOBS;
 266                                 } else {
 267                                         if (c != '\n') {
 268                                             SKIPTOEND(ms);
 269                                             if (*ms) {
 270                                                 ms++;
 271                                             }
 272                                         }
 273                                         continue;
 274                                 }
 275                                 /* If we get here, local_host is in .make.machines. */
 276                                 if (c != '\n')  {
 277                                         /* Now look for keyword 'max'. */
 278                                         MBSTOWCS(wcs_buffer, "max");
 279                                         SKIPSPACE(ms);




 173                         *(make_machines_list_mb +
 174                           strlen(MAKE_MACHINES->string_mb) +
 175                           1 +
 176                           make_machines_buf.st_size) = (int) nul_char;
 177                         if (putenv(make_machines_list_mb) != 0) {
 178                                 warning(gettext("Couldn't put contents of %s in environment"),
 179                                         make_machines_name->string_mb);
 180                         } else {
 181                                 make_machines_list_mb += strlen(MAKE_MACHINES->string_mb) + 1;
 182                                 make_machines_list = ALLOC_WC(strlen(make_machines_list_mb) + 1);
 183                                 (void) mbstowcs(make_machines_list,
 184                                                 make_machines_list_mb,
 185                                                 (strlen(make_machines_list_mb) + 1));
 186                         }
 187                 }
 188         }
 189 
 190         uname(&uts_info);
 191         strcpy(local_host_mb, &uts_info.nodename[0]);
 192         MBSTOWCS(local_host, local_host_mb);
 193         local_host_wslen = wcslen(local_host);
 194 
 195         // There is no getdomainname() function on Solaris.
 196         // And netname2host() function does not work on Linux.
 197         // So we have to use different APIs.
 198         if (host2netname(mbs_buffer, NULL, NULL) &&
 199             netname2host(mbs_buffer, mbs_buffer2, MAXNETNAMELEN+1)) {
 200                 MBSTOWCS(full_host, mbs_buffer2);
 201                 full_host_wslen = wcslen(full_host);
 202         }
 203 
 204         for (ms = make_machines_list;
 205              (ms) && (*ms );
 206              ) {
 207                 /*
 208                  * Skip white space and comments till you reach
 209                  * a machine name.
 210                  */
 211                 pskip_till_next_word(&ms);
 212 
 213                 /*
 214                  * If we haven't reached the end of file, process the
 215                  * machine name.
 216                  */
 217                 if (*ms) {
 218                         /* 
 219                          * If invalid machine name decrement counter 
 220                          * and skip line.
 221                          */
 222                         mp = ms;
 223                         SKIPWORD(ms);
 224                         c = *ms;
 225                         *ms++ = '\0'; /* Append null to machine name. */
 226                         /*
 227                          * If this was the beginning of a comment
 228                          * (we overwrote a # sign) and it's not
 229                          * end of line yet, shift the # sign.
 230                          */
 231                         if ((c == '#') && (*ms != '\n') && (*ms)) {
 232                                 *ms = '#';
 233                         }
 234                         WCSTOMBS(mbs_buffer, mp);
 235                         /*
 236                          * Print "Ignoring unknown host" if:
 237                          * 1) hostname is longer than MAX_HOSTNAMELEN, or
 238                          * 2) hostname is unknown
 239                          */
 240                         if ((wcslen(mp) > MAX_HOSTNAMELEN) ||
 241                             ((hp = gethostbyname(mbs_buffer)) == NULL)) {
 242                                 warning(gettext("Ignoring unknown host %s"),
 243                                         mbs_buffer);
 244                                 SKIPTOEND(ms);
 245                                 /* Increment ptr if not end of file. */
 246                                 if (*ms) {
 247                                         ms++;
 248                                 }
 249                         } else {
 250                                 /* Compare current hostname with local_host. */
 251                                 if (wcslen(mp) == local_host_wslen &&
 252                                     IS_WEQUALN(mp, local_host, local_host_wslen)) {
 253                                         /*
 254                                          * Bingo, local_host is in .make.machines.
 255                                          * Continue reading.
 256                                          */
 257                                         pmake_max_jobs = PMAKE_DEF_MAX_JOBS;
 258                                 /* Compare current hostname with full_host. */
 259                                 } else if (wcslen(mp) == full_host_wslen &&
 260                                            IS_WEQUALN(mp, full_host, full_host_wslen)) {
 261                                         /*
 262                                          * Bingo, full_host is in .make.machines.
 263                                          * Continue reading.
 264                                          */
 265                                         pmake_max_jobs = PMAKE_DEF_MAX_JOBS;
 266                                 } else {
 267                                         if (c != '\n') {
 268                                             SKIPTOEND(ms);
 269                                             if (*ms) {
 270                                                 ms++;
 271                                             }
 272                                         }
 273                                         continue;
 274                                 }
 275                                 /* If we get here, local_host is in .make.machines. */
 276                                 if (c != '\n')  {
 277                                         /* Now look for keyword 'max'. */
 278                                         MBSTOWCS(wcs_buffer, "max");
 279                                         SKIPSPACE(ms);