Changeset 1116 for trunk/src


Ignore:
Timestamp:
Jan 30, 2004, 4:37:05 AM (22 years ago)
Author:
bird
Message:

#733: fixed source file matching and completion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/emxomf/emxomf.c

    • Property cvs2svn:cvs-rev changed from 1.32 to 1.33
    r1115 r1116  
    347347/* This variable holds the module name.  See get_mod_name(). */
    348348static char mod_name[256];
     349
     350/* This variable holds the base(=current) directory.  See get_mod_name(). */
     351static char base_dir[256];
    349352
    350353/* This variable holds a normalized module name used with weak syms.  See get_mod_name(). */
     
    651654{
    652655  FILE *wf;
     656  char line [1024];
    653657
    654658
     
    670674  */
    671675
    672   char line [1024];
    673676  while (fgets (line, sizeof (line), wf))
    674677    {
     
    27632766}
    27642767
     2768#if 0
    27652769/* Converts dashed filenames to somewhat absolute ones assuming that
    27662770   the current directory is what they're relative to. */
     
    27842788  return psz - dst;
    27852789}
    2786 
    2787 /* Derive the module name and store it to the mod_name variable.
    2788    Search the symbol table for an N_SO symbol.  If there is no such
    2789    symbol, use the output file name. */
     2790#endif
     2791
     2792/* Derive the module name and store it in the mod_name variable.
     2793   Derive the current director and store it in the base_dir variable.
     2794   
     2795   Search the symbol table for N_SO symbols. There are two kinds, base dir
     2796   and main source file name. The base dir one ends with a slash.
     2797   
     2798   We assume that the base dir name comes first, and that is it's prefect
     2799   but maybe for a drive letter.
     2800   
     2801   If there is no such symbol, use the output file name. */
    27902802
    27912803static void get_mod_name (void)
     
    27952807  char *p3;
    27962808
     2809  base_dir[0] = '\0';
    27972810  ok = FALSE;
    27982811  for (i = 0; i < sym_count; ++i)
     
    28012814        p1 = str_ptr + sym_ptr[i].n_un.n_strx;
    28022815        len = strlen (p1);
    2803         if (len > 0 && p1[len-1] != '/')
     2816        if (len > 0 && p1[len-1] == '/' )
     2817          {
     2818            if (!base_dir[0])
     2819              {
     2820                _strncpy (base_dir, p1, sizeof(base_dir));
     2821                convert_filename (base_dir);
     2822              }
     2823          }
     2824        else if (len > 0)
    28042825          {
    28052826            ok = TRUE;
    28062827            _strncpy (mod_name, p1, sizeof (mod_name));
    28072828            convert_filename (mod_name);
     2829            /* The base dir doesn't currently have any drive letter.
     2830               steal that from the source filename if possible.
     2831               ASSUME: that it's more like that source is right than curdir
     2832                       bacause of stuff like makeomflibs.cmd and autoconv. */
     2833            if (   (base_dir[0] == '\\' ||  base_dir[0] == '/')
     2834                &&  base_dir[1] != '\\' &&  base_dir[1] != '/' /* unc */
     2835                &&  mod_name[1] == ':')
     2836              {
     2837                len = strlen(base_dir) + 1;
     2838                memmove(base_dir + 2, base_dir, len);
     2839                base_dir[0] = mod_name[0];
     2840                base_dir[1] = mod_name[1];
     2841              }
    28082842            break;
    28092843          }
     
    28182852    }
    28192853
    2820   /* Find the base name and lenght (excluding extension)
    2821      This is used for weak symbol handling. */
    2822   for (p1 = "\\/:", p2 = mod_name; *p1; p1++)
    2823     if ((p3 = strrchr(p2, *p1)) != NULL)
    2824       p2 = p3 + 1;
    2825   for (p3 = weak_mod_name; *p2; p2++)
    2826     if (isalnum(*p2) || *p2 == '$' || *p2 == '_' || *p2 == '@')
    2827         *p3++ = *p2;
    2828   *p3 = '\0';
     2854  /* make sure we have base_dir and that it's an abspath */
     2855  if (!base_dir[0])
     2856      getcwd(base_dir, sizeof(base_dir));
     2857  else if (   (base_dir[0] == '\\' ||  base_dir[0] == '/')
     2858           &&  base_dir[1] != '\\' &&  base_dir[1] != '/') /* unc */
     2859    {   /* make it absolute using current drive */
     2860      len = strlen(base_dir) + 1;
     2861      memmove(base_dir + 2, base_dir, len);
     2862      base_dir[0] = _getdrive();
     2863      base_dir[1] = ':';
     2864    }
     2865
     2866  /* do we need a weak module name? */
     2867  if (weak_list_filename)
     2868    {
     2869      /* Find the base name and length (excluding extension)
     2870         This is used for weak symbol handling. */
     2871      for (p1 = "\\/:", p2 = mod_name; *p1; p1++)
     2872        if ((p3 = strrchr(p2, *p1)) != NULL)
     2873          p2 = p3 + 1;
     2874      for (p3 = weak_mod_name; *p2; p2++)
     2875        if (isalnum(*p2) || *p2 == '$' || *p2 == '_' || *p2 == '@')
     2876            *p3++ = *p2;
     2877      *p3 = '\0';
     2878    }
    28292879}
    28302880
     
    29292979{
    29302980  int i;
    2931 
     2981  char *psz;
     2982 
     2983  /* canonize the filename - slashes and possibly abs path. */
     2984  if (name[0] != '/' && name[0] != '\\' && name[1] != ':')
     2985    { /* need to add base_dir. */
     2986      int cch1 = strlen(base_dir);
     2987      int cch2 = strlen(name) + 1;
     2988      psz = xmalloc(cch1 + cch2);
     2989      memcpy(psz, base_dir, cch1);
     2990      memcpy(psz + cch1, name, cch2);
     2991    }
     2992  else
     2993    psz = xstrdup(name);
     2994  convert_filename(psz);
     2995
     2996  /* search for previous instances */
    29322997  for (i = 0; i < file_grow.count; ++i)
    2933     if (strcmp (file_list[i], name) == 0)
    2934       return i;
     2998    if (!strcmp(file_list[i], psz))
     2999      {
     3000        free(psz);
     3001        return i;
     3002      }
     3003
     3004  /* new source file, add it if possible. */
    29353005  if (hll_version <= 3 && file_grow.count >= 255)
    29363006    {
    29373007      warning ("Too many source files, cannot convert line number info");
     3008      free(psz);
    29383009      return file_grow.count;
    29393010    }
    29403011  grow_by (&file_grow, 1);
    29413012  i = file_grow.count++;
    2942   file_list[i] = xstrdup (name);
     3013  file_list[i] = psz;
    29433014  return i;
    29443015}
     
    30703141  if (valid_lines <= 0 || file_grow.count <= 0)
    30713142      return;
    3072 
    3073   /* Make the paths absolute - TODO: this might be done by GCC as well.. */
    3074 
    3075   for (i = 0; i < file_grow.count; ++i)
    3076     {
    3077       char buf[260];
    3078       len = abspath_filename (buf, file_list[i], 255);
    3079       file_list[i] = xrealloc(file_list[i], len + 1);
    3080       memcpy(file_list[i], buf, len + 1);
    3081     }
    30823143
    30833144  /* Compute the size of the file names table. */
Note: See TracChangeset for help on using the changeset viewer.