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


  84                 return;
  85         } else {
  86                 depinfo_already_read = true;
  87         }
  88                                         
  89         search_dir = getenv("NSE_DEP");
  90         if (search_dir == NULL) {
  91                 return;
  92         }
  93         (void) sprintf(nse_depinfo, "%s/%s", search_dir, NSE_DEPINFO);
  94         fp = fopen(nse_depinfo, "r");
  95         if (fp == NULL) {
  96                 return;
  97         }
  98         line_size = MAXPATHLEN;
  99         line_index = line_size - 1;
 100         line = ALLOC_WC(line_size);
 101         Wstring rns(recursive_name);
 102         wchar_t * wcb = rns.get_string();
 103         while (fgetws(line, line_size, fp) != NULL) {
 104                 while (wslen(line) == line_index) {
 105                         if (line[wslen(line) - 1] == '\n') {
 106                                 continue;
 107                         }
 108                         bigger_line = ALLOC_WC(2 * line_size);
 109                         wscpy(bigger_line, line);
 110                         retmem(line);
 111                         line = bigger_line;
 112                         if (fgetws(&line[line_index], line_size, fp) == NULL)
 113                                 continue;
 114                         line_index = 2 * line_index;
 115                         line_size = 2 * line_size;
 116                 }
 117 
 118                 colon = (wchar_t *) wschr(line, (int) colon_char);
 119                 if (colon == NULL) {
 120                         continue;
 121                 }
 122                 dollar = (wchar_t *) wschr(line, (int) dollar_char);
 123                 line[wslen(line) - 1] = (int) nul_char;
 124                 if (IS_WEQUALN(&colon[2], wcb,
 125                     (int) recursive_name->hash.length)) {
 126                         /*
 127                          * If this entry is an old entry, ignore it
 128                          */
 129                         MBSTOWCS(wcs_buffer, DEPINFO_FMT_VERSION);
 130                         if (dollar == NULL ||
 131                             !IS_WEQUALN(wcs_buffer, (dollar+1) - VER_LEN, VER_LEN)){
 132                                 continue;
 133                             }
 134                         rp = ALLOC(Recursive_make);
 135                         (void) memset((char *) rp, 0, sizeof (Recursive_make_rec));
 136                         /*
 137                          * set conditional_macro_string if string is present
 138                          */
 139                         rp->oldline = (wchar_t *) wsdup(line);
 140                         if ( dollar != NULL ){
 141                                 rp->cond_macrostring = 
 142                                     (wchar_t *) wsdup(dollar - VER_LEN + 1);
 143                         }
 144                         /* 
 145                          * get target name into recursive struct
 146                          */
 147                         *colon = (int) nul_char;
 148                         rp->target = (wchar_t *) wsdup(line);
 149                         *bpatch = rp;
 150                         bpatch = &rp->next;
 151                 }
 152         }
 153         (void) fclose(fp);
 154 }
 155 
 156 /*
 157  *      report_recursive_dep(target, line)
 158  *
 159  *      Report a target as recursive.
 160  *
 161  *      Parameters:
 162  *              line            Dependency line reported
 163  *
 164  *      Static variables used:
 165  *              bpatch          Points to slot where next cell should be added
 166  *              changed         Written if report set changed
 167  */
 168 void
 169 report_recursive_dep(Name target, wchar_t *line)
 170 {
 171         Recursive_make  rp;
 172         wchar_t         rec_buf[STRING_BUFFER_LENGTH];
 173         String_rec      string;
 174 
 175         INIT_STRING_FROM_STACK(string, rec_buf);
 176         cond_macros_into_string(target, &string);
 177         /* 
 178          * find an applicable recursive entry, if there isn't one, create it
 179          */
 180         rp = find_recursive_target(target);
 181         if (rp == NULL) {
 182                 rp = ALLOC(Recursive_make);
 183                 (void) memset((char *) rp, 0, sizeof (Recursive_make_rec));
 184                 wchar_t * wcb = get_wstring(target->string_mb); // XXX Tolik: needs retmem
 185                 rp->target = wcb;
 186                 rp->newline = (wchar_t *) wsdup(line);
 187                 rp->cond_macrostring = (wchar_t *) wsdup(rec_buf);
 188                 *bpatch = rp;
 189                 bpatch = &rp->next;
 190                 changed = true;
 191         } else {
 192                 if ((rp->oldline != NULL) && !IS_WEQUAL(rp->oldline, line)) {
 193                         rp->newline = (wchar_t *) wsdup(line);
 194                         changed = true;
 195                 }
 196                 rp->removed = false;
 197         }
 198 }
 199 
 200 /*
 201  *      find_recursive_target(target)
 202  *
 203  *      Search the list for a given target.
 204  *
 205  *      Return value:
 206  *                              The target cell
 207  *
 208  *      Parameters:
 209  *              target          The target we need
 210  *              top_level_target more info used to determinde the 
 211  *                               target we need
 212  *
 213  *      Static variables used:




  84                 return;
  85         } else {
  86                 depinfo_already_read = true;
  87         }
  88                                         
  89         search_dir = getenv("NSE_DEP");
  90         if (search_dir == NULL) {
  91                 return;
  92         }
  93         (void) sprintf(nse_depinfo, "%s/%s", search_dir, NSE_DEPINFO);
  94         fp = fopen(nse_depinfo, "r");
  95         if (fp == NULL) {
  96                 return;
  97         }
  98         line_size = MAXPATHLEN;
  99         line_index = line_size - 1;
 100         line = ALLOC_WC(line_size);
 101         Wstring rns(recursive_name);
 102         wchar_t * wcb = rns.get_string();
 103         while (fgetws(line, line_size, fp) != NULL) {
 104                 while (wcslen(line) == line_index) {
 105                         if (line[wcslen(line) - 1] == '\n') {
 106                                 continue;
 107                         }
 108                         bigger_line = ALLOC_WC(2 * line_size);
 109                         wcscpy(bigger_line, line);
 110                         retmem(line);
 111                         line = bigger_line;
 112                         if (fgetws(&line[line_index], line_size, fp) == NULL)
 113                                 continue;
 114                         line_index = 2 * line_index;
 115                         line_size = 2 * line_size;
 116                 }
 117 
 118                 colon = (wchar_t *) wcschr(line, (int) colon_char);
 119                 if (colon == NULL) {
 120                         continue;
 121                 }
 122                 dollar = (wchar_t *) wcschr(line, (int) dollar_char);
 123                 line[wcslen(line) - 1] = (int) nul_char;
 124                 if (IS_WEQUALN(&colon[2], wcb,
 125                     (int) recursive_name->hash.length)) {
 126                         /*
 127                          * If this entry is an old entry, ignore it
 128                          */
 129                         MBSTOWCS(wcs_buffer, DEPINFO_FMT_VERSION);
 130                         if (dollar == NULL ||
 131                             !IS_WEQUALN(wcs_buffer, (dollar+1) - VER_LEN, VER_LEN)){
 132                                 continue;
 133                             }
 134                         rp = ALLOC(Recursive_make);
 135                         (void) memset((char *) rp, 0, sizeof (Recursive_make_rec));
 136                         /*
 137                          * set conditional_macro_string if string is present
 138                          */
 139                         rp->oldline = (wchar_t *) wcsdup(line);
 140                         if ( dollar != NULL ){
 141                                 rp->cond_macrostring = 
 142                                     (wchar_t *) wcsdup(dollar - VER_LEN + 1);
 143                         }
 144                         /* 
 145                          * get target name into recursive struct
 146                          */
 147                         *colon = (int) nul_char;
 148                         rp->target = (wchar_t *) wcsdup(line);
 149                         *bpatch = rp;
 150                         bpatch = &rp->next;
 151                 }
 152         }
 153         (void) fclose(fp);
 154 }
 155 
 156 /*
 157  *      report_recursive_dep(target, line)
 158  *
 159  *      Report a target as recursive.
 160  *
 161  *      Parameters:
 162  *              line            Dependency line reported
 163  *
 164  *      Static variables used:
 165  *              bpatch          Points to slot where next cell should be added
 166  *              changed         Written if report set changed
 167  */
 168 void
 169 report_recursive_dep(Name target, wchar_t *line)
 170 {
 171         Recursive_make  rp;
 172         wchar_t         rec_buf[STRING_BUFFER_LENGTH];
 173         String_rec      string;
 174 
 175         INIT_STRING_FROM_STACK(string, rec_buf);
 176         cond_macros_into_string(target, &string);
 177         /* 
 178          * find an applicable recursive entry, if there isn't one, create it
 179          */
 180         rp = find_recursive_target(target);
 181         if (rp == NULL) {
 182                 rp = ALLOC(Recursive_make);
 183                 (void) memset((char *) rp, 0, sizeof (Recursive_make_rec));
 184                 wchar_t * wcb = get_wstring(target->string_mb); // XXX Tolik: needs retmem
 185                 rp->target = wcb;
 186                 rp->newline = (wchar_t *) wcsdup(line);
 187                 rp->cond_macrostring = (wchar_t *) wcsdup(rec_buf);
 188                 *bpatch = rp;
 189                 bpatch = &rp->next;
 190                 changed = true;
 191         } else {
 192                 if ((rp->oldline != NULL) && !IS_WEQUAL(rp->oldline, line)) {
 193                         rp->newline = (wchar_t *) wcsdup(line);
 194                         changed = true;
 195                 }
 196                 rp->removed = false;
 197         }
 198 }
 199 
 200 /*
 201  *      find_recursive_target(target)
 202  *
 203  *      Search the list for a given target.
 204  *
 205  *      Return value:
 206  *                              The target cell
 207  *
 208  *      Parameters:
 209  *              target          The target we need
 210  *              top_level_target more info used to determinde the 
 211  *                               target we need
 212  *
 213  *      Static variables used: