changeset 33988:7c30841c60a0 v9.0.2180

patch 9.0.2180: POSIX function name in exarg causes issues Commit: https://github.com/vim/vim/commit/6fdb6280821a822768df5689a5d727e37d38306c Author: Zoltan Arpadffy <zoltan.arpadffy@gmail.com> Date: Tue Dec 19 20:53:07 2023 +0100 patch 9.0.2180: POSIX function name in exarg causes issues Problem: POSIX function name in exarg struct causes issues on OpenVMS Solution: Rename getline member in exarg struct to ea_getline, remove isinf() workaround for VMS There are compilers that do not treat well POSIX functions - like getline - usage in the structs. Older VMS compilers could digest this... but the newer OpenVMS compilers ( like VSI C x86-64 X7.4-843 (GEM 50XB9) ) cannot deal with these structs. This could be limited to getline() that is defined via getdelim() and might not affect all POSIX functions in general - but avoiding POSIX function names usage in the structs is a "safe side" practice without compromising the functionality or the code readability. The previous OpenVMS X86 port used a workaround limiting the compiler capabilities using __CRTL_VER_OVERRIDE=80400000 In order to make the OpenVMS port future proof, this pull request proposes a possible solution. closes: #13704 Signed-off-by: Zoltan Arpadffy <zoltan.arpadffy@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Dec 2023 21:00:04 +0100
parents 30297bf4537f
children 5af7f3817a6f
files src/Make_vms.mms src/digraph.c src/eval.c src/evalvars.c src/ex_cmds.c src/ex_cmds.h src/ex_cmds2.c src/ex_docmd.c src/ex_getln.c src/macros.h src/pty.c src/scriptfile.c src/usercmd.c src/userfunc.c src/version.c src/vim9class.c src/vim9compile.c
diffstat 17 files changed, 46 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/src/Make_vms.mms
+++ b/src/Make_vms.mms
@@ -112,8 +112,8 @@ CCVER	=
 CC_DEF  = cc
 PREFIX  = /prefix=all/name=(upper,short)
 OPTIMIZE= /opt
-.IFDEF MMSX86_64 # This is needed because of getline function name used in stucts like ex_cmds.h  
-ARCH_DEF= ,__CRTL_VER_OVERRIDE=80400000
+.IFDEF MMSX86_64
+ARCH_DEF=        # ,__CRTL_VER_OVERRIDE=80400000 
 .ENDIF
 .ENDIF
 
--- a/src/digraph.c
+++ b/src/digraph.c
@@ -2315,7 +2315,7 @@ ex_loadkeymap(exarg_T *eap)
      */
     for (;;)
     {
-	line = eap->getline(0, eap->cookie, 0, TRUE);
+	line = eap->ea_getline(0, eap->cookie, 0, TRUE);
 	if (line == NULL)
 	    break;
 
--- a/src/eval.c
+++ b/src/eval.c
@@ -133,9 +133,9 @@ fill_evalarg_from_eap(evalarg_T *evalarg
 	return;
 
     evalarg->eval_cstack = eap->cstack;
-    if (sourcing_a_script(eap) || eap->getline == get_list_line)
-    {
-	evalarg->eval_getline = eap->getline;
+    if (sourcing_a_script(eap) || eap->ea_getline == get_list_line)
+    {
+	evalarg->eval_getline = eap->ea_getline;
 	evalarg->eval_cookie = eap->cookie;
     }
 }
@@ -7542,7 +7542,7 @@ ex_execute(exarg_T *eap)
 	    sticky_cmdmod_flags = cmdmod.cmod_flags
 						& (CMOD_LEGACY | CMOD_VIM9CMD);
 	    do_cmdline((char_u *)ga.ga_data,
-		       eap->getline, eap->cookie, DOCMD_NOWAIT|DOCMD_VERBOSE);
+		       eap->ea_getline, eap->cookie, DOCMD_NOWAIT|DOCMD_VERBOSE);
 	    sticky_cmdmod_flags = save_sticky_cmdmod_flags;
 	}
     }
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -776,7 +776,7 @@ heredoc_get(exarg_T *eap, char_u *cmd, i
     cctx_T	*cctx = vim9compile ? eap->cookie : NULL;
     int		count = 0;
 
-    if (eap->getline == NULL)
+    if (eap->ea_getline == NULL)
     {
 	emsg(_(e_cannot_use_heredoc_here));
 	return NULL;
@@ -856,7 +856,7 @@ heredoc_get(exarg_T *eap, char_u *cmd, i
 	int	ti = 0;
 
 	vim_free(theline);
-	theline = eap->getline(NUL, eap->cookie, 0, FALSE);
+	theline = eap->ea_getline(NUL, eap->cookie, 0, FALSE);
 	if (theline == NULL)
 	{
 	    semsg(_(e_missing_end_marker_str), marker);
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3347,7 +3347,7 @@ ex_append(exarg_T *eap)
 		indent = get_indent_lnum(lnum);
 	}
 	ex_keep_indent = FALSE;
-	if (eap->getline == NULL)
+	if (eap->ea_getline == NULL)
 	{
 	    // No getline() function, use the lines that follow. This ends
 	    // when there is no more.
@@ -3368,7 +3368,7 @@ ex_append(exarg_T *eap)
 	    // Set State to avoid the cursor shape to be set to MODE_INSERT
 	    // state when getline() returns.
 	    State = MODE_CMDLINE;
-	    theline = eap->getline(
+	    theline = eap->ea_getline(
 #ifdef FEAT_EVAL
 		    eap->cstack->cs_looplevel > 0 ? -1 :
 #endif
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -1950,7 +1950,7 @@ struct exarg
     int		bad_char;	// BAD_KEEP, BAD_DROP or replacement byte
     int		useridx;	// user command index
     char	*errmsg;	// returned error message
-    char_u	*(*getline)(int, void *, int, getline_opt_T);
+    char_u	*(*ea_getline)(int, void *, int, getline_opt_T);
     void	*cookie;	// argument for getline()
 #ifdef FEAT_EVAL
     cstack_T	*cstack;	// condition stack for ":if" etc.
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -610,7 +610,7 @@ ex_listdo(exarg_T *eap)
 	    ++i;
 
 	    // execute the command
-	    do_cmdline(eap->arg, eap->getline, eap->cookie,
+	    do_cmdline(eap->arg, eap->ea_getline, eap->cookie,
 						DOCMD_VERBOSE + DOCMD_NOWAIT);
 
 	    if (eap->cmdidx == CMD_bufdo)
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -400,7 +400,7 @@ struct loop_cookie
     int		current_line;		// last read line from growarray
     int		repeating;		// TRUE when looping a second time
     // When "repeating" is FALSE use "getline" and "cookie" to get lines
-    char_u	*(*getline)(int, void *, int, getline_opt_T);
+    char_u	*(*lc_getline)(int, void *, int, getline_opt_T);
     void	*cookie;
 };
 
@@ -940,7 +940,7 @@ do_cmdline(
 	    cmd_cookie = (void *)&cmd_loop_cookie;
 	    cmd_loop_cookie.lines_gap = &lines_ga;
 	    cmd_loop_cookie.current_line = current_line;
-	    cmd_loop_cookie.getline = fgetline;
+	    cmd_loop_cookie.lc_getline = fgetline;
 	    cmd_loop_cookie.cookie = cookie;
 	    cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len);
 
@@ -1468,10 +1468,10 @@ get_loop_line(int c, void *cookie, int i
 	    return NULL;	// trying to read past ":endwhile"/":endfor"
 
 	// First time inside the ":while"/":for": get line normally.
-	if (cp->getline == NULL)
+	if (cp->lc_getline == NULL)
 	    line = getcmdline(c, 0L, indent, 0);
 	else
-	    line = cp->getline(c, cp->cookie, indent, options);
+	    line = cp->lc_getline(c, cp->cookie, indent, options);
 	if (line != NULL && store_loop_line(cp->lines_gap, line) == OK)
 	    ++cp->current_line;
 
@@ -1534,7 +1534,7 @@ getline_equal(
     cp = (struct loop_cookie *)cookie;
     while (gp == get_loop_line)
     {
-	gp = cp->getline;
+	gp = cp->lc_getline;
 	cp = cp->cookie;
     }
     return gp == func;
@@ -1563,7 +1563,7 @@ getline_cookie(
     cp = (struct loop_cookie *)cookie;
     while (gp == get_loop_line)
     {
-	gp = cp->getline;
+	gp = cp->lc_getline;
 	cp = cp->cookie;
     }
     return cp;
@@ -1598,7 +1598,7 @@ getline_peek(
 	    wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line + 1;
 	    return wp->line;
 	}
-	gp = cp->getline;
+	gp = cp->lc_getline;
 	cp = cp->cookie;
     }
     if (gp == getsourceline)
@@ -1780,7 +1780,7 @@ do_one_cmd(
     // The "ea" structure holds the arguments that can be used.
     ea.cmd = *cmdlinep;
     ea.cmdlinep = cmdlinep;
-    ea.getline = fgetline;
+    ea.ea_getline = fgetline;
     ea.cookie = cookie;
 #ifdef FEAT_EVAL
     ea.cstack = cstack;
@@ -2844,8 +2844,8 @@ parse_command_modifiers(
 
 	// in ex mode, an empty command (after modifiers) works like :+
 	if (*eap->cmd == NUL && exmode_active
-		   && (getline_equal(eap->getline, eap->cookie, getexmodeline)
-		       || getline_equal(eap->getline, eap->cookie, getexline))
+		   && (getline_equal(eap->ea_getline, eap->cookie, getexmodeline)
+		       || getline_equal(eap->ea_getline, eap->cookie, getexline))
 			&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)
 	{
 	    use_plus_cmd = TRUE;
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4753,7 +4753,7 @@ script_get(exarg_T *eap UNUSED, char_u *
     char_u	*s;
     garray_T	ga;
 
-    if (cmd[0] != '<' || cmd[1] != '<' || eap->getline == NULL)
+    if (cmd[0] != '<' || cmd[1] != '<' || eap->ea_getline == NULL)
 	return NULL;
     cmd += 2;
 
--- a/src/macros.h
+++ b/src/macros.h
@@ -278,10 +278,6 @@
      static inline int isnan(double x)
 	{ return x != x; }
 #   endif
-#   if defined(VMS) && defined(X86_64)
-     static inline int isinf(double x)
-        { return !isnan(x) && !finite(x); }
-#   endif
 #   ifndef HAVE_ISINF
      static inline int isinf(double x)
 	{ return !isnan(x) && isnan(x - x); }
--- a/src/pty.c
+++ b/src/pty.c
@@ -357,7 +357,7 @@ mch_openpty(char **ttyn)
 static char PtyProto[] = "/dev/ptym/ptyXY";
 static char TtyProto[] = "/dev/pty/ttyXY";
 # else
-#  ifdef(__HAIKU__)
+#  ifdef __HAIKU__
 static char PtyProto[] = "/dev/pt/XY";
 static char TtyProto[] = "/dev/tt/XY";
 #  else
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -2469,7 +2469,7 @@ getsourceline(
     int
 sourcing_a_script(exarg_T *eap)
 {
-    return (getline_equal(eap->getline, eap->cookie, getsourceline));
+    return (getline_equal(eap->ea_getline, eap->cookie, getsourceline));
 }
 
 /*
@@ -2497,7 +2497,7 @@ ex_scriptencoding(exarg_T *eap)
 	name = eap->arg;
 
     // Setup for conversion from the specified encoding to 'encoding'.
-    sp = (source_cookie_T *)getline_cookie(eap->getline, eap->cookie);
+    sp = (source_cookie_T *)getline_cookie(eap->ea_getline, eap->cookie);
     convert_setup(&sp->conv, name, p_enc);
 
     if (name != eap->arg)
@@ -2561,7 +2561,7 @@ do_finish(exarg_T *eap, int reanimate)
     int		idx;
 
     if (reanimate)
-	((source_cookie_T *)getline_cookie(eap->getline,
+	((source_cookie_T *)getline_cookie(eap->ea_getline,
 					      eap->cookie))->finished = FALSE;
 
     // Cleanup (and inactivate) conditionals, but stop when a try conditional
@@ -2575,7 +2575,7 @@ do_finish(exarg_T *eap, int reanimate)
 	report_make_pending(CSTP_FINISH, NULL);
     }
     else
-	((source_cookie_T *)getline_cookie(eap->getline,
+	((source_cookie_T *)getline_cookie(eap->ea_getline,
 					       eap->cookie))->finished = TRUE;
 }
 
--- a/src/usercmd.c
+++ b/src/usercmd.c
@@ -1110,7 +1110,7 @@ may_get_cmd_block(exarg_T *eap, char_u *
     char_u *retp = p;
 
     if (*p == '{' && ends_excmd2(eap->arg, skipwhite(p + 1))
-						       && eap->getline != NULL)
+						    && eap->ea_getline != NULL)
     {
 	garray_T    ga;
 	char_u	    *line = NULL;
@@ -1127,7 +1127,7 @@ may_get_cmd_block(exarg_T *eap, char_u *
 	    for (;;)
 	    {
 		vim_free(line);
-		if ((line = eap->getline(':', eap->cookie,
+		if ((line = eap->ea_getline(':', eap->cookie,
 					   0, GETLINE_CONCAT_CONTBAR)) == NULL)
 		{
 		    emsg(_(e_missing_rcurly));
@@ -1955,7 +1955,7 @@ do_ucmd(exarg_T *eap)
 #endif
     }
 
-    (void)do_cmdline(buf, eap->getline, eap->cookie,
+    (void)do_cmdline(buf, eap->ea_getline, eap->cookie,
 				   DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED);
 
     // Careful: Do not use "cmd" here, it may have become invalid if a user
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -198,10 +198,10 @@ get_function_line(
 {
     char_u *theline;
 
-    if (eap->getline == NULL)
+    if (eap->ea_getline == NULL)
 	theline = getcmdline(':', 0L, indent, 0);
     else
-	theline = eap->getline(':', eap->cookie, indent, getline_options);
+	theline = eap->ea_getline(':', eap->cookie, indent, getline_options);
     if (theline != NULL)
     {
 	if (lines_to_free->ga_len > 0
@@ -264,7 +264,7 @@ get_function_args(
     p = arg;
     while (*p != endchar)
     {
-	while (eap != NULL && eap->getline != NULL
+	while (eap != NULL && eap->ea_getline != NULL
 			 && (*p == NUL || (VIM_ISWHITE(*whitep) && *p == '#')))
 	{
 	    // End of the line, get the next one.
@@ -889,7 +889,7 @@ get_function_body(
 
     // Detect having skipped over comment lines to find the return
     // type.  Add NULL lines to keep the line count correct.
-    sourcing_lnum_off = get_sourced_lnum(eap->getline, eap->cookie);
+    sourcing_lnum_off = get_sourced_lnum(eap->ea_getline, eap->cookie);
     if (SOURCING_LNUM < sourcing_lnum_off)
     {
 	sourcing_lnum_off -= SOURCING_LNUM;
@@ -952,7 +952,7 @@ get_function_body(
 	}
 
 	// Detect line continuation: SOURCING_LNUM increased more than one.
-	sourcing_lnum_off = get_sourced_lnum(eap->getline, eap->cookie);
+	sourcing_lnum_off = get_sourced_lnum(eap->ea_getline, eap->cookie);
 	if (SOURCING_LNUM < sourcing_lnum_off)
 	    sourcing_lnum_off -= SOURCING_LNUM;
 	else
@@ -1349,7 +1349,7 @@ lambda_function_body(
 	fill_exarg_from_cctx(&eap, evalarg->eval_cctx);
     else
     {
-	eap.getline = evalarg->eval_getline;
+	eap.ea_getline = evalarg->eval_getline;
 	eap.cookie = evalarg->eval_cookie;
     }
 
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2180,
+/**/
     2179,
 /**/
     2178,
--- a/src/vim9class.c
+++ b/src/vim9class.c
@@ -1369,7 +1369,7 @@ ex_class(exarg_T *eap)
 
     if (!current_script_is_vim9()
 		|| (cmdmod.cmod_flags & CMOD_LEGACY)
-		|| !getline_equal(eap->getline, eap->cookie, getsourceline))
+		|| !getline_equal(eap->ea_getline, eap->cookie, getsourceline))
     {
 	if (is_class)
 	    emsg(_(e_class_can_only_be_defined_in_vim9_script));
@@ -1530,7 +1530,7 @@ early_ret:
     for (;;)
     {
 	vim_free(theline);
-	theline = eap->getline(':', eap->cookie, 0, GETLINE_CONCAT_ALL);
+	theline = eap->ea_getline(':', eap->cookie, 0, GETLINE_CONCAT_ALL);
 	if (theline == NULL)
 	    break;
 	char_u *line = skipwhite(theline);
@@ -1778,7 +1778,7 @@ early_ret:
 	    ea.cmd = line;
 	    ea.arg = p;
 	    ea.cmdidx = CMD_def;
-	    ea.getline = eap->getline;
+	    ea.ea_getline = eap->ea_getline;
 	    ea.cookie = eap->cookie;
 
 	    ga_init2(&lines_to_free, sizeof(char_u *), 50);
@@ -2177,7 +2177,7 @@ ex_type(exarg_T *eap UNUSED)
 
     if (!current_script_is_vim9()
 		|| (cmdmod.cmod_flags & CMOD_LEGACY)
-		|| !getline_equal(eap->getline, eap->cookie, getsourceline))
+		|| !getline_equal(eap->ea_getline, eap->cookie, getsourceline))
     {
 	emsg(_(e_type_can_only_be_defined_in_vim9_script));
 	return;
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -971,7 +971,7 @@ exarg_getline(
     void
 fill_exarg_from_cctx(exarg_T *eap, cctx_T *cctx)
 {
-    eap->getline = exarg_getline;
+    eap->ea_getline = exarg_getline;
     eap->cookie = cctx;
     eap->skip = cctx->ctx_skip == SKIP_YES;
 }
@@ -2628,7 +2628,7 @@ compile_assignment(
 	list_T	   *l;
 
 	// [let] varname =<< [trim] {end}
-	eap->getline = exarg_getline;
+	eap->ea_getline = exarg_getline;
 	eap->cookie = cctx;
 	l = heredoc_get(eap, op + 3, FALSE, TRUE);
 	if (l == NULL)