summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2021-01-29 13:52:31 +0200
committerEli Zaretskii <eliz@gnu.org>2021-01-29 13:52:31 +0200
commit75eb2d0e850352bef1afe052315de63817b2070b (patch)
tree457cc97b1f2234c20e7b8cf6b80e49718b596297 /src
parent83591e1aec86530e0d293df3078760838f37679a (diff)
downloademacs-75eb2d0e850352bef1afe052315de63817b2070b.tar.gz
Support 'operating-system-release' on MS-Windows
* src/w32fns.c (w32_version_string) [WINDOWSNT]: New function. * src/w32common.h (w32_version_string) [WINDOWSNT]: Add prototype. * src/editfns.c (init_editfns) [WINDOWSNT]: Produce a non-nil string with the OS version.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c7
-rw-r--r--src/w32common.h5
-rw-r--r--src/w32fns.c12
3 files changed, 23 insertions, 1 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 3c2a858b46e..e3285494c14 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -52,6 +52,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "window.h"
#include "blockinput.h"
+#ifdef WINDOWSNT
+# include "w32common.h"
+#endif
static void update_buffer_properties (ptrdiff_t, ptrdiff_t);
static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool);
@@ -121,12 +124,14 @@ init_editfns (void)
else if (NILP (Vuser_full_name))
Vuser_full_name = build_string ("unknown");
-#ifdef HAVE_SYS_UTSNAME_H
+#if defined HAVE_SYS_UTSNAME_H
{
struct utsname uts;
uname (&uts);
Voperating_system_release = build_string (uts.release);
}
+#elif defined WINDOWSNT
+ Voperating_system_release = build_string (w32_version_string ());
#else
Voperating_system_release = Qnil;
#endif
diff --git a/src/w32common.h b/src/w32common.h
index 94bb457e59d..714a2386a68 100644
--- a/src/w32common.h
+++ b/src/w32common.h
@@ -50,6 +50,11 @@ extern int os_subtype;
/* Cache system info, e.g., the NT page size. */
extern void cache_system_info (void);
+#ifdef WINDOWSNT
+/* Return a static buffer with the MS-Windows version string. */
+extern char * w32_version_string (void);
+#endif
+
typedef void (* VOIDFNPTR) (void);
/* Load a function address from a DLL. Cast the result via VOIDFNPTR
diff --git a/src/w32fns.c b/src/w32fns.c
index 7519c752b68..e93a0b85d93 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -9480,6 +9480,18 @@ cache_system_info (void)
w32_num_mouse_buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
}
+#ifdef WINDOWSNT
+char *
+w32_version_string (void)
+{
+ /* NNN.NNN.NNNNNNNNNN */
+ static char version_string[3 + 1 + 3 + 1 + 10 + 1];
+ _snprintf (version_string, sizeof version_string, "%d.%d.%d",
+ w32_major_version, w32_minor_version, w32_build_number);
+ return version_string;
+}
+#endif
+
#ifdef EMACSDEBUG
void
_DebPrint (const char *fmt, ...)