@@ -2916,11 +2916,11 @@ stuff_inserted(
29162916 long count , // Repeat this many times
29172917 int no_esc ) // Don't add an ESC at the end
29182918{
2919- string_T * insert ; // text to be inserted
2919+ string_T insert ; // text to be inserted
29202920 char_u last = ' ' ;
29212921
29222922 insert = get_last_insert ();
2923- if (insert -> string == NULL )
2923+ if (insert . string == NULL )
29242924 {
29252925 emsg (_ (e_no_inserted_text_yet ));
29262926 return FAIL ;
@@ -2930,39 +2930,39 @@ stuff_inserted(
29302930 if (c != NUL )
29312931 stuffcharReadbuff (c );
29322932
2933- if (insert -> length > 0 )
2933+ if (insert . length > 0 )
29342934 {
29352935 char_u * p ;
29362936
29372937 // look for the last ESC in 'insert'
2938- for (p = insert -> string + insert -> length - 1 ; p >= insert -> string ; -- p )
2938+ for (p = insert . string + insert . length - 1 ; p >= insert . string ; -- p )
29392939 {
29402940 if (* p == ESC )
29412941 {
2942- insert -> length = (size_t )(p - insert -> string );
2942+ insert . length = (size_t )(p - insert . string );
29432943 break ;
29442944 }
29452945 }
29462946 }
29472947
2948- if (insert -> length > 0 )
2948+ if (insert . length > 0 )
29492949 {
2950- char_u * p = insert -> string + insert -> length - 1 ;
2950+ char_u * p = insert . string + insert . length - 1 ;
29512951
29522952 // when the last char is either "0" or "^" it will be quoted if no ESC
29532953 // comes after it OR if it will insert more than once and "ptr"
29542954 // starts with ^D. -- Acevedo
29552955 if ((* p == '0' || * p == '^' )
2956- && (no_esc || (* insert -> string == Ctrl_D && count > 1 )))
2956+ && (no_esc || (* insert . string == Ctrl_D && count > 1 )))
29572957 {
29582958 last = * p ;
2959- -- insert -> length ;
2959+ -- insert . length ;
29602960 }
29612961 }
29622962
29632963 do
29642964 {
2965- stuffReadbuffLen (insert -> string , insert -> length );
2965+ stuffReadbuffLen (insert . string , insert . length );
29662966 // a trailing "0" is inserted as "<C-V>048", "^" as "<C-V>^"
29672967 switch (last )
29682968 {
@@ -2991,23 +2991,18 @@ stuff_inserted(
29912991 return OK ;
29922992}
29932993
2994- string_T *
2994+ string_T
29952995get_last_insert (void )
29962996{
2997- static string_T insert = {NULL , 0 };
2997+ string_T insert = {NULL , 0 };
29982998
2999- if (last_insert .string == NULL )
3000- {
3001- insert .string = NULL ;
3002- insert .length = 0 ;
3003- }
3004- else
2999+ if (last_insert .string != NULL )
30053000 {
30063001 insert .string = last_insert .string + last_insert_skip ;
30073002 insert .length = (size_t )(last_insert .length - last_insert_skip );
30083003 }
30093004
3010- return & insert ;
3005+ return insert ;
30113006}
30123007
30133008/*
@@ -3017,22 +3012,17 @@ get_last_insert(void)
30173012 char_u *
30183013get_last_insert_save (void )
30193014{
3020- string_T * insert = get_last_insert ();
3015+ string_T insert = get_last_insert ();
30213016 char_u * s ;
30223017
3023- if (insert -> string == NULL )
3018+ if (insert . string == NULL )
30243019 return NULL ;
3025- s = vim_strnsave (insert -> string , insert -> length );
3020+ s = vim_strnsave (insert . string , insert . length );
30263021 if (s == NULL )
30273022 return NULL ;
30283023
3029- if (insert -> length > 0 )
3030- {
3031- // remove trailing ESC
3032- -- insert -> length ;
3033- if (s [insert -> length ] == ESC )
3034- s [insert -> length ] = NUL ;
3035- }
3024+ if (insert .length > 0 && s [insert .length - 1 ] == ESC ) // remove trailing ESC
3025+ s [insert .length - 1 ] = NUL ;
30363026 return s ;
30373027}
30383028
0 commit comments