Source: nn Version: 6.7.3-14 Severity: normal Tags: patch Dear Maintainer,
>From 5fa6eef9a1162d9ce90a8a45f6dad138502d60e2 Mon Sep 17 00:00:00 2001 >From: Bjarni Ingi Gislason <bjarn...@rhi.hi.is> >Date: Mon, 1 Mar 2021 02:29:22 +0000 >Subject: [PATCH] init.c: Include <stdint.h> for the declaration of the data type "intptr_t". 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 <bjarn...@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); } -static char dflt_init_files[] = ",init"; +static const char dflt_init_files[] = ",init"; void visit_init_file(int only_seq, char *first_arg) { char *next_arg; + char init_files[sizeof dflt_init_files]; in_init = 1; load_init_file(relative(lib_directory, "setup"), (FILE **) NULL, 0); in_init = 0; + strcpy(init_files, dflt_init_files); + if (first_arg && strncmp(first_arg, "-I", 2) == 0) { if (first_arg[2] == NUL) return; first_arg += 2; } else - first_arg = dflt_init_files; + first_arg = init_files; in_init = 1; while (first_arg) { @@ -439,7 +442,7 @@ alt_completion(char *buf, int index) case 2: other_compl = file_completion; - sprintf(buffer, "%s.%s", + snprintf(buffer, FILENAME, "%s.%s", relative(help_directory, "help"), head); len = strlen(buffer); head = buffer + len; @@ -739,7 +742,9 @@ err: static int do_map(FILE * initf) { - int code, map_menu, map_show, must_redraw = 0; + intptr_t code; + int map_menu, map_show, must_redraw = 0; + key_type bind_to; register struct key_map_def *map_def; register int *map; @@ -790,7 +795,7 @@ do_map(FILE * initf) map_menu = map_def->km_flag & K_BIND_ORIG; if (ARG(3, "(")) { - code = (int) m_define("-2", initf); + code = (intptr_t) m_define("-2", initf); must_redraw = 1; if (code == K_UNBOUND) goto mac_err; @@ -943,11 +948,14 @@ parse_on_to_end(FILE * f) if (ARGTAIL) { for (ii = 2; argv(ii); ii++) { start_group_search(argv(ii)); - while ((gh = get_group_search())) + while ((gh = get_group_search())) { gh->enter_macro = macro; + } } } else dflt_enter_macro = macro; +/* Repeat reading the init file if "on entry" is there */ + init_on_entry = 1; return; } -- 2.30.1 -- System Information: Debian Release: bullseye/sid APT prefers testing APT policy: (500, 'testing'), (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 5.10.9-1 (SMP w/2 CPU threads) Locale: LANG=is_IS.iso88591, LC_CTYPE=is_IS.iso88591 (charmap=ISO-8859-1), LANGUAGE not set Shell: /bin/sh linked to /bin/dash Init: sysvinit (via /sbin/init) -- debconf information excluded -- Bjarni I. Gislason