* grub-core/normal/completion.c: Remove variable length arrays.
* grub-core/normal/menu_entry.c: Likewise. Reduces normal.mod by 496 bytes.
This commit is contained in:
parent
a07e6ad010
commit
c7037f1d0f
3 changed files with 51 additions and 49 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2013-10-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/normal/completion.c: Remove variable length arrays.
|
||||||
|
* grub-core/normal/menu_entry.c: Likewise.
|
||||||
|
|
||||||
|
Reduces normal.mod by 496 bytes.
|
||||||
|
|
||||||
2013-10-20 Vladimir Serbinenko <phcoder@gmail.com>
|
2013-10-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/fs/minix.c: Remove variable length arrays. Reduces jfs.mod
|
* grub-core/fs/minix.c: Remove variable length arrays. Reduces jfs.mod
|
||||||
|
|
|
@ -168,36 +168,27 @@ iterate_dev (const char *devname, void *data __attribute__ ((unused)))
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
{
|
|
||||||
char tmp[grub_strlen (devname) + sizeof (",")];
|
|
||||||
|
|
||||||
grub_memcpy (tmp, devname, grub_strlen (devname));
|
if (grub_strcmp (devname, current_word) == 0)
|
||||||
|
{
|
||||||
|
if (add_completion (devname, ")", GRUB_COMPLETION_TYPE_PARTITION))
|
||||||
|
{
|
||||||
|
grub_device_close (dev);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (grub_strcmp (devname, current_word) == 0)
|
if (dev->disk)
|
||||||
{
|
if (grub_partition_iterate (dev->disk, iterate_partition, NULL))
|
||||||
if (add_completion (devname, ")", GRUB_COMPLETION_TYPE_PARTITION))
|
|
||||||
{
|
{
|
||||||
grub_device_close (dev);
|
grub_device_close (dev);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (dev->disk)
|
else if (add_completion (devname, "", GRUB_COMPLETION_TYPE_DEVICE))
|
||||||
if (grub_partition_iterate (dev->disk, iterate_partition, NULL))
|
{
|
||||||
{
|
grub_device_close (dev);
|
||||||
grub_device_close (dev);
|
return 1;
|
||||||
return 1;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
grub_memcpy (tmp + grub_strlen (devname), "", sizeof (""));
|
|
||||||
if (add_completion (tmp, "", GRUB_COMPLETION_TYPE_DEVICE))
|
|
||||||
{
|
|
||||||
grub_device_close (dev);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_device_close (dev);
|
grub_device_close (dev);
|
||||||
grub_errno = GRUB_ERR_NONE;
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
|
|
@ -51,6 +51,11 @@ struct per_term_screen
|
||||||
struct grub_term_output *term;
|
struct grub_term_output *term;
|
||||||
int y_line_start;
|
int y_line_start;
|
||||||
struct grub_term_screen_geometry geo;
|
struct grub_term_screen_geometry geo;
|
||||||
|
/* Scratch variables used when updating. Having them here avoids
|
||||||
|
loads of small mallocs. */
|
||||||
|
int orig_num;
|
||||||
|
int down;
|
||||||
|
enum update_mode mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct screen
|
struct screen
|
||||||
|
@ -371,14 +376,12 @@ insert_string (struct screen *screen, const char *s, int update)
|
||||||
{
|
{
|
||||||
int region_start = screen->num_lines;
|
int region_start = screen->num_lines;
|
||||||
int region_column = 0;
|
int region_column = 0;
|
||||||
int down[screen->nterms];
|
|
||||||
enum update_mode mode[screen->nterms];
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < screen->nterms; i++)
|
for (i = 0; i < screen->nterms; i++)
|
||||||
{
|
{
|
||||||
down[i] = 0;
|
screen->terms[i].down = 0;
|
||||||
mode[i] = NO_LINE;
|
screen->terms[i].mode = NO_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*s)
|
while (*s)
|
||||||
|
@ -436,8 +439,8 @@ insert_string (struct screen *screen, const char *s, int update)
|
||||||
|
|
||||||
for (i = 0; i < screen->nterms; i++)
|
for (i = 0; i < screen->nterms; i++)
|
||||||
{
|
{
|
||||||
mode[i] = ALL_LINES;
|
screen->terms[i].mode = ALL_LINES;
|
||||||
down[i] = 1; /* XXX not optimal. */
|
screen->terms[i].down = 1; /* XXX not optimal. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move the cursor. */
|
/* Move the cursor. */
|
||||||
|
@ -451,7 +454,6 @@ insert_string (struct screen *screen, const char *s, int update)
|
||||||
const char *p;
|
const char *p;
|
||||||
struct line *current_linep;
|
struct line *current_linep;
|
||||||
int size;
|
int size;
|
||||||
int orig_num[screen->nterms], new_num[screen->nterms];
|
|
||||||
grub_uint32_t *unicode_msg;
|
grub_uint32_t *unicode_msg;
|
||||||
|
|
||||||
/* Find a string delimited by LF. */
|
/* Find a string delimited by LF. */
|
||||||
|
@ -488,12 +490,9 @@ insert_string (struct screen *screen, const char *s, int update)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < screen->nterms; i++)
|
for (i = 0; i < screen->nterms; i++)
|
||||||
orig_num[i] = get_logical_num_lines (current_linep,
|
screen->terms[i].orig_num = get_logical_num_lines (current_linep,
|
||||||
&screen->terms[i]);
|
&screen->terms[i]);
|
||||||
current_linep->len += size;
|
current_linep->len += size;
|
||||||
for (i = 0; i < screen->nterms; i++)
|
|
||||||
new_num[i] = get_logical_num_lines (current_linep,
|
|
||||||
&screen->terms[i]);
|
|
||||||
|
|
||||||
/* Update the dirty region. */
|
/* Update the dirty region. */
|
||||||
if (region_start > screen->line)
|
if (region_start > screen->line)
|
||||||
|
@ -503,13 +502,17 @@ insert_string (struct screen *screen, const char *s, int update)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < screen->nterms; i++)
|
for (i = 0; i < screen->nterms; i++)
|
||||||
if (orig_num[i] != new_num[i])
|
{
|
||||||
{
|
int new_num = get_logical_num_lines (current_linep,
|
||||||
mode[i] = ALL_LINES;
|
&screen->terms[i]);
|
||||||
down[i] = 1; /* XXX not optimal. */
|
if (screen->terms[i].orig_num != new_num)
|
||||||
}
|
{
|
||||||
else if (mode[i] != ALL_LINES)
|
screen->terms[i].mode = ALL_LINES;
|
||||||
mode[i] = SINGLE_LINE;
|
screen->terms[i].down = 1; /* XXX not optimal. */
|
||||||
|
}
|
||||||
|
else if (screen->terms[i].mode != ALL_LINES)
|
||||||
|
screen->terms[i].mode = SINGLE_LINE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Move the cursor. */
|
/* Move the cursor. */
|
||||||
advance_to (screen, screen->column + size);
|
advance_to (screen, screen->column + size);
|
||||||
|
@ -522,7 +525,8 @@ insert_string (struct screen *screen, const char *s, int update)
|
||||||
if (update)
|
if (update)
|
||||||
for (i = 0; i < screen->nterms; i++)
|
for (i = 0; i < screen->nterms; i++)
|
||||||
update_screen (screen, &screen->terms[i],
|
update_screen (screen, &screen->terms[i],
|
||||||
region_start, region_column, 0, down[i], mode[i]);
|
region_start, region_column, 0, screen->terms[i].down,
|
||||||
|
screen->terms[i].mode);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -754,11 +758,10 @@ delete_char (struct screen *screen, int update)
|
||||||
linep = screen->lines + screen->line;
|
linep = screen->lines + screen->line;
|
||||||
if (linep->len > screen->column)
|
if (linep->len > screen->column)
|
||||||
{
|
{
|
||||||
int orig_num[screen->nterms], new_num;
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < screen->nterms; i++)
|
for (i = 0; i < screen->nterms; i++)
|
||||||
orig_num[i] = get_logical_num_lines (linep, &screen->terms[i]);
|
screen->terms[i].orig_num = get_logical_num_lines (linep, &screen->terms[i]);
|
||||||
|
|
||||||
grub_memmove (linep->buf + screen->column,
|
grub_memmove (linep->buf + screen->column,
|
||||||
linep->buf + screen->column + 1,
|
linep->buf + screen->column + 1,
|
||||||
|
@ -780,8 +783,9 @@ delete_char (struct screen *screen, int update)
|
||||||
{
|
{
|
||||||
for (i = 0; i < screen->nterms; i++)
|
for (i = 0; i < screen->nterms; i++)
|
||||||
{
|
{
|
||||||
|
int new_num;
|
||||||
new_num = get_logical_num_lines (linep, &screen->terms[i]);
|
new_num = get_logical_num_lines (linep, &screen->terms[i]);
|
||||||
if (orig_num[i] != new_num)
|
if (screen->terms[i].orig_num != new_num)
|
||||||
update_screen (screen, &screen->terms[i],
|
update_screen (screen, &screen->terms[i],
|
||||||
start, column, 0, 0, ALL_LINES);
|
start, column, 0, 0, ALL_LINES);
|
||||||
else
|
else
|
||||||
|
@ -867,7 +871,6 @@ kill_line (struct screen *screen, int continuous, int update)
|
||||||
|
|
||||||
if (size > 0)
|
if (size > 0)
|
||||||
{
|
{
|
||||||
int orig_num[screen->nterms], new_num;
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
p = grub_realloc (p, offset + size + 1);
|
p = grub_realloc (p, offset + size + 1);
|
||||||
|
@ -880,15 +883,16 @@ kill_line (struct screen *screen, int continuous, int update)
|
||||||
screen->killed_text = p;
|
screen->killed_text = p;
|
||||||
|
|
||||||
for (i = 0; i < screen->nterms; i++)
|
for (i = 0; i < screen->nterms; i++)
|
||||||
orig_num[i] = get_logical_num_lines (linep, &screen->terms[i]);
|
screen->terms[i].orig_num = get_logical_num_lines (linep, &screen->terms[i]);
|
||||||
linep->len = screen->column;
|
linep->len = screen->column;
|
||||||
|
|
||||||
if (update)
|
if (update)
|
||||||
{
|
{
|
||||||
for (i = 0; i < screen->nterms; i++)
|
for (i = 0; i < screen->nterms; i++)
|
||||||
{
|
{
|
||||||
|
int new_num;
|
||||||
new_num = get_logical_num_lines (linep, &screen->terms[i]);
|
new_num = get_logical_num_lines (linep, &screen->terms[i]);
|
||||||
if (orig_num[i] != new_num)
|
if (screen->terms[i].orig_num != new_num)
|
||||||
update_screen (screen, &screen->terms[i],
|
update_screen (screen, &screen->terms[i],
|
||||||
screen->line, screen->column, 0, 1, ALL_LINES);
|
screen->line, screen->column, 0, 1, ALL_LINES);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue