diff options
| author | Andrew Innes | 2000-08-22 22:49:27 +0000 |
|---|---|---|
| committer | Andrew Innes | 2000-08-22 22:49:27 +0000 |
| commit | a302c7ae2b6758b54e046df758fa9a9e720e4911 (patch) | |
| tree | 9c492ef28840492b566bfaefe037e25177c2f47b | |
| parent | 739cc391758f1779ef4337726d49e1025e82b026 (diff) | |
| download | emacs-a302c7ae2b6758b54e046df758fa9a9e720e4911.tar.gz emacs-a302c7ae2b6758b54e046df758fa9a9e720e4911.zip | |
(GetCachedVolumeInformation): Use xmalloc, xfree and xstrdup.
(add_volume_info): Use xstrdup.
(init_environment): Call _access.
(check_windows_init_file): Call _close.
(init_user_info): Call _putenv.
(init_environment): Call _putenv and _strdup.
(init_ntproc): Reset volume info cache on startup.
(unc_volume_file_attributes):
(open_unc_volume): Make arg const.
(gettimeofday): Use struct timeb, not struct _timeb.
(map_w32_filename, read_unc_volume): Fix compile warning.
(sys_strerror): Use sys_nerr instead of _sys_nerr. Use
sys_errlist instead of _sys_errlist.
(get_emacs_configuration_options): New function.
| -rw-r--r-- | src/w32.c | 87 |
1 files changed, 65 insertions, 22 deletions
| @@ -677,11 +677,11 @@ init_environment (char ** argv) | |||
| 677 | read-only filesystem, like CD-ROM or a write-protected floppy. | 677 | read-only filesystem, like CD-ROM or a write-protected floppy. |
| 678 | The only way to be really sure is to actually create a file and | 678 | The only way to be really sure is to actually create a file and |
| 679 | see if it succeeds. But I think that's too much to ask. */ | 679 | see if it succeeds. But I think that's too much to ask. */ |
| 680 | if (tmp && access (tmp, D_OK) == 0) | 680 | if (tmp && _access (tmp, D_OK) == 0) |
| 681 | { | 681 | { |
| 682 | char * var = alloca (strlen (tmp) + 8); | 682 | char * var = alloca (strlen (tmp) + 8); |
| 683 | sprintf (var, "TMPDIR=%s", tmp); | 683 | sprintf (var, "TMPDIR=%s", tmp); |
| 684 | putenv (var); | 684 | _putenv (var); |
| 685 | break; | 685 | break; |
| 686 | } | 686 | } |
| 687 | } | 687 | } |
| @@ -744,7 +744,7 @@ init_environment (char ** argv) | |||
| 744 | if (*p == '\\') *p = '/'; | 744 | if (*p == '\\') *p = '/'; |
| 745 | 745 | ||
| 746 | _snprintf (buf, sizeof(buf)-1, "emacs_dir=%s", modname); | 746 | _snprintf (buf, sizeof(buf)-1, "emacs_dir=%s", modname); |
| 747 | putenv (strdup (buf)); | 747 | _putenv (strdup (buf)); |
| 748 | } | 748 | } |
| 749 | } | 749 | } |
| 750 | 750 | ||
| @@ -769,14 +769,14 @@ init_environment (char ** argv) | |||
| 769 | 769 | ||
| 770 | ExpandEnvironmentStrings ((LPSTR) lpval, buf1, sizeof(buf1)); | 770 | ExpandEnvironmentStrings ((LPSTR) lpval, buf1, sizeof(buf1)); |
| 771 | _snprintf (buf2, sizeof(buf2)-1, "%s=%s", env_vars[i].name, buf1); | 771 | _snprintf (buf2, sizeof(buf2)-1, "%s=%s", env_vars[i].name, buf1); |
| 772 | putenv (strdup (buf2)); | 772 | _putenv (strdup (buf2)); |
| 773 | } | 773 | } |
| 774 | else if (dwType == REG_SZ) | 774 | else if (dwType == REG_SZ) |
| 775 | { | 775 | { |
| 776 | char buf[SET_ENV_BUF_SIZE]; | 776 | char buf[SET_ENV_BUF_SIZE]; |
| 777 | 777 | ||
| 778 | _snprintf (buf, sizeof(buf)-1, "%s=%s", env_vars[i].name, lpval); | 778 | _snprintf (buf, sizeof(buf)-1, "%s=%s", env_vars[i].name, lpval); |
| 779 | putenv (strdup (buf)); | 779 | _putenv (strdup (buf)); |
| 780 | } | 780 | } |
| 781 | 781 | ||
| 782 | if (!dont_free) | 782 | if (!dont_free) |
| @@ -845,13 +845,12 @@ init_environment (char ** argv) | |||
| 845 | user enter it, so we define EMACS_CONFIGURATION to invoke this runtime | 845 | user enter it, so we define EMACS_CONFIGURATION to invoke this runtime |
| 846 | routine. */ | 846 | routine. */ |
| 847 | 847 | ||
| 848 | static char configuration_buffer[32]; | ||
| 849 | |||
| 850 | char * | 848 | char * |
| 851 | get_emacs_configuration (void) | 849 | get_emacs_configuration (void) |
| 852 | { | 850 | { |
| 853 | char *arch, *oem, *os; | 851 | char *arch, *oem, *os; |
| 854 | int build_num; | 852 | int build_num; |
| 853 | static char configuration_buffer[32]; | ||
| 855 | 854 | ||
| 856 | /* Determine the processor type. */ | 855 | /* Determine the processor type. */ |
| 857 | switch (get_processor_type ()) | 856 | switch (get_processor_type ()) |
| @@ -890,8 +889,17 @@ get_emacs_configuration (void) | |||
| 890 | break; | 889 | break; |
| 891 | } | 890 | } |
| 892 | 891 | ||
| 893 | /* Let oem be "*" until we figure out how to decode the OEM field. */ | 892 | /* Use the OEM field to reflect the compiler/library combination. */ |
| 894 | oem = "*"; | 893 | #ifdef _MSC_VER |
| 894 | #define COMPILER_NAME "msvc" | ||
| 895 | #else | ||
| 896 | #ifdef __GNUC__ | ||
| 897 | #define COMPILER_NAME "mingw" | ||
| 898 | #else | ||
| 899 | #define COMPILER_NAME "unknown" | ||
| 900 | #endif | ||
| 901 | #endif | ||
| 902 | oem = COMPILER_NAME; | ||
| 895 | 903 | ||
| 896 | switch (osinfo_cache.dwPlatformId) { | 904 | switch (osinfo_cache.dwPlatformId) { |
| 897 | case VER_PLATFORM_WIN32_NT: | 905 | case VER_PLATFORM_WIN32_NT: |
| @@ -927,13 +935,45 @@ get_emacs_configuration (void) | |||
| 927 | return configuration_buffer; | 935 | return configuration_buffer; |
| 928 | } | 936 | } |
| 929 | 937 | ||
| 938 | char * | ||
| 939 | get_emacs_configuration_options (void) | ||
| 940 | { | ||
| 941 | static char options_buffer[256]; | ||
| 942 | |||
| 943 | /* Work out the effective configure options for this build. */ | ||
| 944 | #ifdef _MSC_VER | ||
| 945 | #define COMPILER_VERSION "--with-msvc (%d.%02d)", _MSC_VER / 100, _MSC_VER % 100 | ||
| 946 | #else | ||
| 947 | #ifdef __GNUC__ | ||
| 948 | #define COMPILER_VERSION "--with-gcc (%d.%d)", __GNUC__, __GNUC_MINOR__ | ||
| 949 | #else | ||
| 950 | #define COMPILER_VERSION "" | ||
| 951 | #endif | ||
| 952 | #endif | ||
| 953 | |||
| 954 | sprintf (options_buffer, COMPILER_VERSION); | ||
| 955 | #ifdef EMACSDEBUG | ||
| 956 | strcat (options_buffer, " --no-opt"); | ||
| 957 | #endif | ||
| 958 | #ifdef USER_CFLAGS | ||
| 959 | strcat (options_buffer, " --cflags"); | ||
| 960 | strcat (options_buffer, USER_CFLAGS); | ||
| 961 | #endif | ||
| 962 | #ifdef USER_LDFLAGS | ||
| 963 | strcat (options_buffer, " --ldflags"); | ||
| 964 | strcat (options_buffer, USER_LDFLAGS); | ||
| 965 | #endif | ||
| 966 | return options_buffer; | ||
| 967 | } | ||
| 968 | |||
| 969 | |||
| 930 | #include <sys/timeb.h> | 970 | #include <sys/timeb.h> |
| 931 | 971 | ||
| 932 | /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95). */ | 972 | /* Emulate gettimeofday (Ulrich Leodolter, 1/11/95). */ |
| 933 | void | 973 | void |
| 934 | gettimeofday (struct timeval *tv, struct timezone *tz) | 974 | gettimeofday (struct timeval *tv, struct timezone *tz) |
| 935 | { | 975 | { |
| 936 | struct _timeb tb; | 976 | struct timeb tb; |
| 937 | _ftime (&tb); | 977 | _ftime (&tb); |
| 938 | 978 | ||
| 939 | tv->tv_sec = tb.time; | 979 | tv->tv_sec = tb.time; |
| @@ -1024,7 +1064,7 @@ lookup_volume_info (char * root_dir) | |||
| 1024 | static void | 1064 | static void |
| 1025 | add_volume_info (char * root_dir, volume_info_data * info) | 1065 | add_volume_info (char * root_dir, volume_info_data * info) |
| 1026 | { | 1066 | { |
| 1027 | info->root_dir = strdup (root_dir); | 1067 | info->root_dir = xstrdup (root_dir); |
| 1028 | info->next = volume_cache; | 1068 | info->next = volume_cache; |
| 1029 | volume_cache = info; | 1069 | volume_cache = info; |
| 1030 | } | 1070 | } |
| @@ -1107,15 +1147,15 @@ GetCachedVolumeInformation (char * root_dir) | |||
| 1107 | } | 1147 | } |
| 1108 | else | 1148 | else |
| 1109 | { | 1149 | { |
| 1110 | free (info->name); | 1150 | xfree (info->name); |
| 1111 | free (info->type); | 1151 | xfree (info->type); |
| 1112 | } | 1152 | } |
| 1113 | 1153 | ||
| 1114 | info->name = strdup (name); | 1154 | info->name = xstrdup (name); |
| 1115 | info->serialnum = serialnum; | 1155 | info->serialnum = serialnum; |
| 1116 | info->maxcomp = maxcomp; | 1156 | info->maxcomp = maxcomp; |
| 1117 | info->flags = flags; | 1157 | info->flags = flags; |
| 1118 | info->type = strdup (type); | 1158 | info->type = xstrdup (type); |
| 1119 | info->timestamp = GetTickCount (); | 1159 | info->timestamp = GetTickCount (); |
| 1120 | } | 1160 | } |
| 1121 | 1161 | ||
| @@ -1200,7 +1240,7 @@ map_w32_filename (const char * name, const char ** pPath) | |||
| 1200 | return shortname; | 1240 | return shortname; |
| 1201 | } | 1241 | } |
| 1202 | 1242 | ||
| 1203 | if (is_fat_volume (name, &path)) /* truncate to 8.3 */ | 1243 | if (is_fat_volume (name, (const char **)&path)) /* truncate to 8.3 */ |
| 1204 | { | 1244 | { |
| 1205 | register int left = 8; /* maximum number of chars in part */ | 1245 | register int left = 8; /* maximum number of chars in part */ |
| 1206 | register int extn = 0; /* extension added? */ | 1246 | register int extn = 0; /* extension added? */ |
| @@ -1453,9 +1493,9 @@ open_unc_volume (char *path) | |||
| 1453 | char * | 1493 | char * |
| 1454 | read_unc_volume (HANDLE henum, char *readbuf, int size) | 1494 | read_unc_volume (HANDLE henum, char *readbuf, int size) |
| 1455 | { | 1495 | { |
| 1456 | int count; | 1496 | DWORD count; |
| 1457 | int result; | 1497 | int result; |
| 1458 | int bufsize = 512; | 1498 | DWORD bufsize = 512; |
| 1459 | char *buffer; | 1499 | char *buffer; |
| 1460 | char *ptr; | 1500 | char *ptr; |
| 1461 | 1501 | ||
| @@ -2539,8 +2579,8 @@ sys_strerror(int error_no) | |||
| 2539 | int i; | 2579 | int i; |
| 2540 | static char unknown_msg[40]; | 2580 | static char unknown_msg[40]; |
| 2541 | 2581 | ||
| 2542 | if (error_no >= 0 && error_no < _sys_nerr) | 2582 | if (error_no >= 0 && error_no < sys_nerr) |
| 2543 | return _sys_errlist[error_no]; | 2583 | return sys_errlist[error_no]; |
| 2544 | 2584 | ||
| 2545 | for (i = 0; _wsa_errlist[i].errnum >= 0; i++) | 2585 | for (i = 0; _wsa_errlist[i].errnum >= 0; i++) |
| 2546 | if (_wsa_errlist[i].errnum == error_no) | 2586 | if (_wsa_errlist[i].errnum == error_no) |
| @@ -2752,7 +2792,7 @@ sys_gethostname (char * name, int namelen) | |||
| 2752 | return pfn_gethostname (name, namelen); | 2792 | return pfn_gethostname (name, namelen); |
| 2753 | 2793 | ||
| 2754 | if (namelen > MAX_COMPUTERNAME_LENGTH) | 2794 | if (namelen > MAX_COMPUTERNAME_LENGTH) |
| 2755 | return !GetComputerName (name, &namelen); | 2795 | return !GetComputerName (name, (DWORD *)&namelen); |
| 2756 | 2796 | ||
| 2757 | h_errno = EFAULT; | 2797 | h_errno = EFAULT; |
| 2758 | return SOCKET_ERROR; | 2798 | return SOCKET_ERROR; |
| @@ -3279,7 +3319,7 @@ check_windows_init_file () | |||
| 3279 | } | 3319 | } |
| 3280 | else | 3320 | else |
| 3281 | { | 3321 | { |
| 3282 | close (fd); | 3322 | _close (fd); |
| 3283 | } | 3323 | } |
| 3284 | } | 3324 | } |
| 3285 | } | 3325 | } |
| @@ -3389,6 +3429,9 @@ init_ntproc () | |||
| 3389 | 3429 | ||
| 3390 | (*drive)++; | 3430 | (*drive)++; |
| 3391 | } | 3431 | } |
| 3432 | |||
| 3433 | /* Reset the volume info cache. */ | ||
| 3434 | volume_cache = NULL; | ||
| 3392 | } | 3435 | } |
| 3393 | 3436 | ||
| 3394 | /* Check to see if Emacs has been installed correctly. */ | 3437 | /* Check to see if Emacs has been installed correctly. */ |