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


 108  *      Global variables used:
 109  *              envvar          A list of environment vars with $ in value
 110  */
 111 void
 112 setvar_envvar(void)
 113 {
 114         wchar_t                 buffer[STRING_BUFFER_LENGTH];
 115         int                     length;
 116         register        char    *mbs, *tmp_mbs_buffer = NULL;
 117         register        char    *env, *tmp_mbs_buffer2 = NULL;
 118         Envvar                  p;
 119         String_rec              value;
 120 
 121         for (p = envvar; p != NULL; p = p->next) {
 122                 if (p->already_put
 123                     ) {
 124                         continue;
 125                 }
 126                 INIT_STRING_FROM_STACK(value, buffer);          
 127                 expand_value(p->value, &value, false);
 128                 if ((length = wslen(value.buffer.start)) >= MAXPATHLEN) {
 129                         mbs = tmp_mbs_buffer = getmem((length + 1) * MB_LEN_MAX);
 130                         (void) wcstombs(mbs,
 131                                         value.buffer.start,
 132                                         (length + 1) * MB_LEN_MAX);
 133                 } else {
 134                         mbs = mbs_buffer;
 135                         WCSTOMBS(mbs, value.buffer.start);
 136                 }
 137                 length = 2 + strlen(p->name->string_mb) + strlen(mbs);
 138                 if (!p->already_put || length > (MAXPATHLEN * MB_LEN_MAX)) {
 139                         env = tmp_mbs_buffer2 = getmem(length);
 140                 } else {
 141                         env = mbs_buffer2;
 142                 }
 143                 (void) sprintf(env,
 144                                "%s=%s",
 145                                p->name->string_mb,
 146                                mbs);
 147                 if (!p->already_put) {
 148                         (void) putenv(env);


 108  *      Global variables used:
 109  *              envvar          A list of environment vars with $ in value
 110  */
 111 void
 112 setvar_envvar(void)
 113 {
 114         wchar_t                 buffer[STRING_BUFFER_LENGTH];
 115         int                     length;
 116         register        char    *mbs, *tmp_mbs_buffer = NULL;
 117         register        char    *env, *tmp_mbs_buffer2 = NULL;
 118         Envvar                  p;
 119         String_rec              value;
 120 
 121         for (p = envvar; p != NULL; p = p->next) {
 122                 if (p->already_put
 123                     ) {
 124                         continue;
 125                 }
 126                 INIT_STRING_FROM_STACK(value, buffer);          
 127                 expand_value(p->value, &value, false);
 128                 if ((length = wcslen(value.buffer.start)) >= MAXPATHLEN) {
 129                         mbs = tmp_mbs_buffer = getmem((length + 1) * MB_LEN_MAX);
 130                         (void) wcstombs(mbs,
 131                                         value.buffer.start,
 132                                         (length + 1) * MB_LEN_MAX);
 133                 } else {
 134                         mbs = mbs_buffer;
 135                         WCSTOMBS(mbs, value.buffer.start);
 136                 }
 137                 length = 2 + strlen(p->name->string_mb) + strlen(mbs);
 138                 if (!p->already_put || length > (MAXPATHLEN * MB_LEN_MAX)) {
 139                         env = tmp_mbs_buffer2 = getmem(length);
 140                 } else {
 141                         env = mbs_buffer2;
 142                 }
 143                 (void) sprintf(env,
 144                                "%s=%s",
 145                                p->name->string_mb,
 146                                mbs);
 147                 if (!p->already_put) {
 148                         (void) putenv(env);