- Timestamp:
- Jan 30, 2004, 4:37:05 AM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/emxomf/emxomf.c
-
Property cvs2svn:cvs-rev
changed from
1.32
to1.33
r1115 r1116 347 347 /* This variable holds the module name. See get_mod_name(). */ 348 348 static char mod_name[256]; 349 350 /* This variable holds the base(=current) directory. See get_mod_name(). */ 351 static char base_dir[256]; 349 352 350 353 /* This variable holds a normalized module name used with weak syms. See get_mod_name(). */ … … 651 654 { 652 655 FILE *wf; 656 char line [1024]; 653 657 654 658 … … 670 674 */ 671 675 672 char line [1024];673 676 while (fgets (line, sizeof (line), wf)) 674 677 { … … 2763 2766 } 2764 2767 2768 #if 0 2765 2769 /* Converts dashed filenames to somewhat absolute ones assuming that 2766 2770 the current directory is what they're relative to. */ … … 2784 2788 return psz - dst; 2785 2789 } 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. */ 2790 2802 2791 2803 static void get_mod_name (void) … … 2795 2807 char *p3; 2796 2808 2809 base_dir[0] = '\0'; 2797 2810 ok = FALSE; 2798 2811 for (i = 0; i < sym_count; ++i) … … 2801 2814 p1 = str_ptr + sym_ptr[i].n_un.n_strx; 2802 2815 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) 2804 2825 { 2805 2826 ok = TRUE; 2806 2827 _strncpy (mod_name, p1, sizeof (mod_name)); 2807 2828 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 } 2808 2842 break; 2809 2843 } … … 2818 2852 } 2819 2853 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 } 2829 2879 } 2830 2880 … … 2929 2979 { 2930 2980 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 */ 2932 2997 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. */ 2935 3005 if (hll_version <= 3 && file_grow.count >= 255) 2936 3006 { 2937 3007 warning ("Too many source files, cannot convert line number info"); 3008 free(psz); 2938 3009 return file_grow.count; 2939 3010 } 2940 3011 grow_by (&file_grow, 1); 2941 3012 i = file_grow.count++; 2942 file_list[i] = xstrdup (name);3013 file_list[i] = psz; 2943 3014 return i; 2944 3015 } … … 3070 3141 if (valid_lines <= 0 || file_grow.count <= 0) 3071 3142 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 }3082 3143 3083 3144 /* Compute the size of the file names table. */ -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.