mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.0.1735: flexible array member feature not supported by HP-UX
Problem: Flexible array member feature not supported by HP-UX. (John Marriott) Solution: Do not use the flexible array member feature of C99.
This commit is contained in:
@@ -209,16 +209,6 @@ Types ~
|
|||||||
"long long" is allowed and can be expected to be 64 bits. Use %lld in printf
|
"long long" is allowed and can be expected to be 64 bits. Use %lld in printf
|
||||||
formats. Also "long long unsigned" with %llu.
|
formats. Also "long long unsigned" with %llu.
|
||||||
|
|
||||||
Flexible array members ~
|
|
||||||
|
|
||||||
This is an array without size, used as the last member of a struct. Vim used
|
|
||||||
to have an array of size one, which causes trouble with FORTIFY_SOURCE. Using
|
|
||||||
an "unsized array" is the intended use, we will change all of them.
|
|
||||||
struct some_stuff {
|
|
||||||
size_t length;
|
|
||||||
char payload[]; // will have size "length"
|
|
||||||
};
|
|
||||||
|
|
||||||
Not to be used ~
|
Not to be used ~
|
||||||
|
|
||||||
These C99 features are not to be used, because not enough compilers support
|
These C99 features are not to be used, because not enough compilers support
|
||||||
@@ -228,6 +218,7 @@ them:
|
|||||||
- Variable length arrays (even in C11 this is an optional feature).
|
- Variable length arrays (even in C11 this is an optional feature).
|
||||||
- _Bool and _Complex types.
|
- _Bool and _Complex types.
|
||||||
- "inline" (it's hardly ever needed, let the optimizer do its work)
|
- "inline" (it's hardly ever needed, let the optimizer do its work)
|
||||||
|
- flexible array members: Not supported by HP-UX C compiler (John Marriott)
|
||||||
|
|
||||||
|
|
||||||
USE OF COMMON FUNCTIONS *style-functions*
|
USE OF COMMON FUNCTIONS *style-functions*
|
||||||
|
10
src/auto/configure
vendored
10
src/auto/configure
vendored
@@ -4188,14 +4188,10 @@ int
|
|||||||
main ()
|
main ()
|
||||||
{
|
{
|
||||||
|
|
||||||
struct with_flexible_member {
|
|
||||||
int count; // comment
|
|
||||||
char text[]; // another comment
|
|
||||||
};
|
|
||||||
enum {
|
enum {
|
||||||
one,
|
one, // one comment
|
||||||
two,
|
two, // two comments
|
||||||
three,
|
three, // three comments
|
||||||
};
|
};
|
||||||
long long int a = 1;
|
long long int a = 1;
|
||||||
long long unsigned b = 2;
|
long long unsigned b = 2;
|
||||||
|
@@ -36,14 +36,10 @@ dnl - "long long int" and "long long unsigned"
|
|||||||
dnl - flexible array member
|
dnl - flexible array member
|
||||||
AC_MSG_CHECKING(if the compiler can handle Vim code)
|
AC_MSG_CHECKING(if the compiler can handle Vim code)
|
||||||
AC_TRY_COMPILE([#include <stdio.h>], [
|
AC_TRY_COMPILE([#include <stdio.h>], [
|
||||||
struct with_flexible_member {
|
|
||||||
int count; // comment
|
|
||||||
char text[]; // another comment
|
|
||||||
};
|
|
||||||
enum {
|
enum {
|
||||||
one,
|
one, // one comment
|
||||||
two,
|
two, // two comments
|
||||||
three,
|
three, // three comments
|
||||||
};
|
};
|
||||||
long long int a = 1;
|
long long int a = 1;
|
||||||
long long unsigned b = 2;
|
long long unsigned b = 2;
|
||||||
|
@@ -40,9 +40,9 @@
|
|||||||
|
|
||||||
#define MINIMAL_SIZE 20 /* minimal size for b_str */
|
#define MINIMAL_SIZE 20 /* minimal size for b_str */
|
||||||
|
|
||||||
static buffheader_T redobuff = {NULL, NULL, 0, 0};
|
static buffheader_T redobuff = {{NULL, {NUL}}, NULL, 0, 0};
|
||||||
static buffheader_T old_redobuff = {NULL, NULL, 0, 0};
|
static buffheader_T old_redobuff = {{NULL, {NUL}}, NULL, 0, 0};
|
||||||
static buffheader_T recordbuff = {NULL, NULL, 0, 0};
|
static buffheader_T recordbuff = {{NULL, {NUL}}, NULL, 0, 0};
|
||||||
|
|
||||||
static int typeahead_char = 0; /* typeahead char that's not flushed */
|
static int typeahead_char = 0; /* typeahead char that's not flushed */
|
||||||
|
|
||||||
@@ -138,13 +138,12 @@ free_buff(buffheader_T *buf)
|
|||||||
{
|
{
|
||||||
buffblock_T *p, *np;
|
buffblock_T *p, *np;
|
||||||
|
|
||||||
for (p = buf->bh_first; p != NULL; p = np)
|
for (p = buf->bh_first.b_next; p != NULL; p = np)
|
||||||
{
|
{
|
||||||
np = p->b_next;
|
np = p->b_next;
|
||||||
vim_free(p);
|
vim_free(p);
|
||||||
}
|
}
|
||||||
buf->bh_first = NULL;
|
buf->bh_first.b_next = NULL;
|
||||||
buf->bh_curr = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -163,13 +162,13 @@ get_buffcont(
|
|||||||
buffblock_T *bp;
|
buffblock_T *bp;
|
||||||
|
|
||||||
/* compute the total length of the string */
|
/* compute the total length of the string */
|
||||||
for (bp = buffer->bh_first; bp != NULL; bp = bp->b_next)
|
for (bp = buffer->bh_first.b_next; bp != NULL; bp = bp->b_next)
|
||||||
count += (long_u)STRLEN(bp->b_str);
|
count += (long_u)STRLEN(bp->b_str);
|
||||||
|
|
||||||
if ((count || dozero) && (p = lalloc(count + 1, TRUE)) != NULL)
|
if ((count || dozero) && (p = lalloc(count + 1, TRUE)) != NULL)
|
||||||
{
|
{
|
||||||
p2 = p;
|
p2 = p;
|
||||||
for (bp = buffer->bh_first; bp != NULL; bp = bp->b_next)
|
for (bp = buffer->bh_first.b_next; bp != NULL; bp = bp->b_next)
|
||||||
for (str = bp->b_str; *str; )
|
for (str = bp->b_str; *str; )
|
||||||
*p2++ = *str++;
|
*p2++ = *str++;
|
||||||
*p2 = NUL;
|
*p2 = NUL;
|
||||||
@@ -240,10 +239,10 @@ add_buff(
|
|||||||
if (slen == 0) /* don't add empty strings */
|
if (slen == 0) /* don't add empty strings */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (buf->bh_first == NULL) /* first add to list */
|
if (buf->bh_first.b_next == NULL) /* first add to list */
|
||||||
{
|
{
|
||||||
buf->bh_space = 0;
|
buf->bh_space = 0;
|
||||||
buf->bh_curr = NULL;
|
buf->bh_curr = &(buf->bh_first);
|
||||||
}
|
}
|
||||||
else if (buf->bh_curr == NULL) /* buffer has already been read */
|
else if (buf->bh_curr == NULL) /* buffer has already been read */
|
||||||
{
|
{
|
||||||
@@ -251,9 +250,9 @@ add_buff(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (buf->bh_index != 0)
|
else if (buf->bh_index != 0)
|
||||||
mch_memmove(buf->bh_first->b_str,
|
mch_memmove(buf->bh_first.b_next->b_str,
|
||||||
buf->bh_first->b_str + buf->bh_index,
|
buf->bh_first.b_next->b_str + buf->bh_index,
|
||||||
STRLEN(buf->bh_first->b_str + buf->bh_index) + 1);
|
STRLEN(buf->bh_first.b_next->b_str + buf->bh_index) + 1);
|
||||||
buf->bh_index = 0;
|
buf->bh_index = 0;
|
||||||
|
|
||||||
if (buf->bh_space >= (int)slen)
|
if (buf->bh_space >= (int)slen)
|
||||||
@@ -268,26 +267,17 @@ add_buff(
|
|||||||
len = MINIMAL_SIZE;
|
len = MINIMAL_SIZE;
|
||||||
else
|
else
|
||||||
len = slen;
|
len = slen;
|
||||||
p = (buffblock_T *)lalloc((long_u)(sizeof(buffblock_T) + len + 1),
|
p = (buffblock_T *)lalloc((long_u)(sizeof(buffblock_T) + len),
|
||||||
TRUE);
|
TRUE);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return; /* no space, just forget it */
|
return; /* no space, just forget it */
|
||||||
buf->bh_space = (int)(len - slen);
|
buf->bh_space = (int)(len - slen);
|
||||||
vim_strncpy(p->b_str, s, (size_t)slen);
|
vim_strncpy(p->b_str, s, (size_t)slen);
|
||||||
|
|
||||||
if (buf->bh_curr == NULL)
|
|
||||||
{
|
|
||||||
p->b_next = NULL;
|
|
||||||
buf->bh_first = p;
|
|
||||||
buf->bh_curr = p;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
p->b_next = buf->bh_curr->b_next;
|
p->b_next = buf->bh_curr->b_next;
|
||||||
buf->bh_curr->b_next = p;
|
buf->bh_curr->b_next = p;
|
||||||
buf->bh_curr = p;
|
buf->bh_curr = p;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,10 +348,10 @@ add_char_buff(buffheader_T *buf, int c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* First read ahead buffer. Used for translated commands. */
|
/* First read ahead buffer. Used for translated commands. */
|
||||||
static buffheader_T readbuf1 = {NULL, NULL, 0, 0};
|
static buffheader_T readbuf1 = {{NULL, {NUL}}, NULL, 0, 0};
|
||||||
|
|
||||||
/* Second read ahead buffer. Used for redo. */
|
/* Second read ahead buffer. Used for redo. */
|
||||||
static buffheader_T readbuf2 = {NULL, NULL, 0, 0};
|
static buffheader_T readbuf2 = {{NULL, {NUL}}, NULL, 0, 0};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get one byte from the read buffers. Use readbuf1 one first, use readbuf2
|
* Get one byte from the read buffers. Use readbuf1 one first, use readbuf2
|
||||||
@@ -386,17 +376,17 @@ read_readbuf(buffheader_T *buf, int advance)
|
|||||||
char_u c;
|
char_u c;
|
||||||
buffblock_T *curr;
|
buffblock_T *curr;
|
||||||
|
|
||||||
if (buf->bh_first == NULL) /* buffer is empty */
|
if (buf->bh_first.b_next == NULL) /* buffer is empty */
|
||||||
return NUL;
|
return NUL;
|
||||||
|
|
||||||
curr = buf->bh_first;
|
curr = buf->bh_first.b_next;
|
||||||
c = curr->b_str[buf->bh_index];
|
c = curr->b_str[buf->bh_index];
|
||||||
|
|
||||||
if (advance)
|
if (advance)
|
||||||
{
|
{
|
||||||
if (curr->b_str[++buf->bh_index] == NUL)
|
if (curr->b_str[++buf->bh_index] == NUL)
|
||||||
{
|
{
|
||||||
buf->bh_first = curr->b_next;
|
buf->bh_first.b_next = curr->b_next;
|
||||||
vim_free(curr);
|
vim_free(curr);
|
||||||
buf->bh_index = 0;
|
buf->bh_index = 0;
|
||||||
}
|
}
|
||||||
@@ -410,14 +400,14 @@ read_readbuf(buffheader_T *buf, int advance)
|
|||||||
static void
|
static void
|
||||||
start_stuff(void)
|
start_stuff(void)
|
||||||
{
|
{
|
||||||
if (readbuf1.bh_first != NULL)
|
if (readbuf1.bh_first.b_next != NULL)
|
||||||
{
|
{
|
||||||
readbuf1.bh_curr = readbuf1.bh_first;
|
readbuf1.bh_curr = &(readbuf1.bh_first);
|
||||||
readbuf1.bh_space = 0;
|
readbuf1.bh_space = 0;
|
||||||
}
|
}
|
||||||
if (readbuf2.bh_first != NULL)
|
if (readbuf2.bh_first.b_next != NULL)
|
||||||
{
|
{
|
||||||
readbuf2.bh_curr = readbuf2.bh_first;
|
readbuf2.bh_curr = &(readbuf2.bh_first);
|
||||||
readbuf2.bh_space = 0;
|
readbuf2.bh_space = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -428,8 +418,8 @@ start_stuff(void)
|
|||||||
int
|
int
|
||||||
stuff_empty(void)
|
stuff_empty(void)
|
||||||
{
|
{
|
||||||
return (readbuf1.bh_first == NULL
|
return (readbuf1.bh_first.b_next == NULL
|
||||||
&& readbuf2.bh_first == NULL);
|
&& readbuf2.bh_first.b_next == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -439,7 +429,7 @@ stuff_empty(void)
|
|||||||
int
|
int
|
||||||
readbuf1_empty(void)
|
readbuf1_empty(void)
|
||||||
{
|
{
|
||||||
return (readbuf1.bh_first == NULL);
|
return (readbuf1.bh_first.b_next == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -504,7 +494,7 @@ ResetRedobuff(void)
|
|||||||
{
|
{
|
||||||
free_buff(&old_redobuff);
|
free_buff(&old_redobuff);
|
||||||
old_redobuff = redobuff;
|
old_redobuff = redobuff;
|
||||||
redobuff.bh_first = NULL;
|
redobuff.bh_first.b_next = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,7 +509,7 @@ CancelRedo(void)
|
|||||||
{
|
{
|
||||||
free_buff(&redobuff);
|
free_buff(&redobuff);
|
||||||
redobuff = old_redobuff;
|
redobuff = old_redobuff;
|
||||||
old_redobuff.bh_first = NULL;
|
old_redobuff.bh_first.b_next = NULL;
|
||||||
start_stuff();
|
start_stuff();
|
||||||
while (read_readbuffers(TRUE) != NUL)
|
while (read_readbuffers(TRUE) != NUL)
|
||||||
;
|
;
|
||||||
@@ -536,9 +526,9 @@ saveRedobuff(save_redo_T *save_redo)
|
|||||||
char_u *s;
|
char_u *s;
|
||||||
|
|
||||||
save_redo->sr_redobuff = redobuff;
|
save_redo->sr_redobuff = redobuff;
|
||||||
redobuff.bh_first = NULL;
|
redobuff.bh_first.b_next = NULL;
|
||||||
save_redo->sr_old_redobuff = old_redobuff;
|
save_redo->sr_old_redobuff = old_redobuff;
|
||||||
old_redobuff.bh_first = NULL;
|
old_redobuff.bh_first.b_next = NULL;
|
||||||
|
|
||||||
/* Make a copy, so that ":normal ." in a function works. */
|
/* Make a copy, so that ":normal ." in a function works. */
|
||||||
s = get_buffcont(&save_redo->sr_redobuff, FALSE);
|
s = get_buffcont(&save_redo->sr_redobuff, FALSE);
|
||||||
@@ -757,9 +747,9 @@ read_redo(int init, int old_redo)
|
|||||||
if (init)
|
if (init)
|
||||||
{
|
{
|
||||||
if (old_redo)
|
if (old_redo)
|
||||||
bp = old_redobuff.bh_first;
|
bp = old_redobuff.bh_first.b_next;
|
||||||
else
|
else
|
||||||
bp = redobuff.bh_first;
|
bp = redobuff.bh_first.b_next;
|
||||||
if (bp == NULL)
|
if (bp == NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
p = bp->b_str;
|
p = bp->b_str;
|
||||||
@@ -1382,9 +1372,9 @@ save_typeahead(tasave_T *tp)
|
|||||||
old_char = -1;
|
old_char = -1;
|
||||||
|
|
||||||
tp->save_readbuf1 = readbuf1;
|
tp->save_readbuf1 = readbuf1;
|
||||||
readbuf1.bh_first = NULL;
|
readbuf1.bh_first.b_next = NULL;
|
||||||
tp->save_readbuf2 = readbuf2;
|
tp->save_readbuf2 = readbuf2;
|
||||||
readbuf2.bh_first = NULL;
|
readbuf2.bh_first.b_next = NULL;
|
||||||
# ifdef USE_INPUT_BUF
|
# ifdef USE_INPUT_BUF
|
||||||
tp->save_inputbuf = get_input_buf();
|
tp->save_inputbuf = get_input_buf();
|
||||||
# endif
|
# endif
|
||||||
|
@@ -511,7 +511,7 @@ typedef struct buffheader buffheader_T;
|
|||||||
struct buffblock
|
struct buffblock
|
||||||
{
|
{
|
||||||
buffblock_T *b_next; /* pointer to next buffblock */
|
buffblock_T *b_next; /* pointer to next buffblock */
|
||||||
char_u b_str[]; /* contents (flexible array) */
|
char_u b_str[1]; /* contents (actually longer) */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -519,7 +519,7 @@ struct buffblock
|
|||||||
*/
|
*/
|
||||||
struct buffheader
|
struct buffheader
|
||||||
{
|
{
|
||||||
buffblock_T *bh_first; /* first block of the list */
|
buffblock_T bh_first; /* first (dummy) block of list */
|
||||||
buffblock_T *bh_curr; /* buffblock for appending */
|
buffblock_T *bh_curr; /* buffblock for appending */
|
||||||
int bh_index; /* index for reading */
|
int bh_index; /* index for reading */
|
||||||
int bh_space; /* space in bh_curr for appending */
|
int bh_space; /* space in bh_curr for appending */
|
||||||
|
@@ -762,6 +762,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1735,
|
||||||
/**/
|
/**/
|
||||||
1734,
|
1734,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user