#983781 init.c: various additions and corrections

Package:
src:nn
Source:
nn
Submitter:
Bjarni Ingi Gislason
Date:
2021-03-01 18:21:04 UTC
Severity:
normal
Tags:
#983781#5
Date:
2021-03-01 18:19:41 UTC
From:
To:
Dear Maintainer,

  Remove a repeated declaration of "in_menu_mode".

  Add external variable "init_on_entry"; used here and in "nn.c".

  Add information to a message.

  Define "dflt_init_files[]" with type "const".

  Add the character array "init_files[]".

  Use "snprintf()" instead of "sprintf()".

  Declare the variable "code" to be of type "intptr_t", not "int":

init.c:793:9: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  793 |  code = (int) m_define("-2", initf);
      |         ^

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 init.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/init.c b/init.c
index 676bc85..e222108 100644
--- a/init.c
+++ b/init.c
@@ -6,6 +6,7 @@
  */

 #include <unistd.h>
+#include <stdint.h> /* For type intptr_t */
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
@@ -74,12 +75,11 @@ extern int      terminal_speed, slow_speed;
 extern char    *pname;
 extern char    *start_up_macro;
 extern char    *newsrc_file;
-extern int      in_menu_mode;
 extern int      do_kill_handling;
 extern char     printer[];
 extern char    *mail_box;

-
+extern int	init_on_entry;

 void
 init_message(char *fmt,...)
@@ -237,7 +237,7 @@ chain_file:
 		    *seq_hook_ptr = init;
 		    return;	/* no close !! */
 		} else {
-		    init_message("load file contains 'sequence'");
+		    init_message("load file %s contains 'sequence'", init);
 		    fclose(init);
 		    return;
 		}
@@ -247,23 +247,26 @@ chain_file:
     fclose(init);
 }