git: dac5a2024bc8 - stable/13 - loader: Change version calculation to be more consistent.

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 17 Oct 2024 19:49:26 UTC
The branch stable/13 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=dac5a2024bc8bed379d3db861580056d0c670fdc

commit dac5a2024bc8bed379d3db861580056d0c670fdc
Author:     Stephen J. Kiernan <stevek@FreeBSD.org>
AuthorDate: 2023-04-17 23:27:54 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-10-17 19:08:21 +0000

    loader: Change version calculation to be more consistent.
    
    Use 1000 * major + minor when calculating the version number that
    gets set in the Ficl environment or lua loader property. This allows
    for more room if the minor number needs to go above 9.
    
    Add loader.version property to lua loader.
    
    PR: 282001
    Reviewed by:    imp
    Obtained from:  Juniper Networks, Inc.
    Differential Revision: https://reviews.freebsd.org/D39631
    
    (cherry picked from commit a50d73d5782a351ad83e8d1f84d11720a12e70d3)
---
 stand/common/bootstrap.h    | 1 +
 stand/common/interp_forth.c | 1 -
 stand/common/newvers.sh     | 2 +-
 stand/liblua/lutils.c       | 2 ++
 4 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h
index 02ddfb84b050..4afab2efa781 100644
--- a/stand/common/bootstrap.h
+++ b/stand/common/bootstrap.h
@@ -180,6 +180,7 @@ extern int isapnp_readport;
  * Version information
  */
 extern char bootprog_info[];
+extern unsigned bootprog_rev;
 
 /*
  * Interpreter information
diff --git a/stand/common/interp_forth.c b/stand/common/interp_forth.c
index 0c2829c9717e..0320e081d406 100644
--- a/stand/common/interp_forth.c
+++ b/stand/common/interp_forth.c
@@ -31,7 +31,6 @@
 #include "bootstrap.h"
 #include "ficl.h"
 
-extern unsigned bootprog_rev;
 INTERP_DEFINE("4th");
 
 /* #define BFORTH_DEBUG */
diff --git a/stand/common/newvers.sh b/stand/common/newvers.sh
index ee7678597b7a..0f30b1a4a744 100755
--- a/stand/common/newvers.sh
+++ b/stand/common/newvers.sh
@@ -55,6 +55,6 @@ fi
 
 cat > $tempfile <<EOF
 char bootprog_info[] = "$bootprog_info";
-unsigned bootprog_rev = ${r%%.*}${r##*.};
+unsigned bootprog_rev = ${r%%.*} * 1000 + ${r##*.};
 EOF
 mv $tempfile vers.c
diff --git a/stand/liblua/lutils.c b/stand/liblua/lutils.c
index 6c2cceeff3c3..bc585e0375d6 100644
--- a/stand/liblua/lutils.c
+++ b/stand/liblua/lutils.c
@@ -639,6 +639,8 @@ luaopen_loader(lua_State *L)
 	lua_pushstring(L, LUA_PATH);
 	lua_setfield(L, -2, "lua_path");
 	lua_add_features(L);
+	lua_pushinteger(L, bootprog_rev);
+	lua_setfield(L, -2, "version");
 	/* Set global printc to loader.printc */
 	lua_register(L, "printc", lua_printc);
 	return 1;