Several fixes

This commit is contained in:
Vladimir Serbinenko committed 2013-10-28 17:42:40 +01:00
1 parent 951ce61283
commit 7699d54233
25 files changed
+149 -176

No files matched your search

+1 -1
View File
@@ -85,7 +85,7 @@ HOST_CPPFLAGS="$HOST_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Dfloat=__float__bug__ -Ddouble=__double__bug__ -DGRUB_RUNTIME=1" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DGRUB_RUNTIME=1"
case "$target_cpu" in case "$target_cpu" in
i[[3456]]86) target_cpu=i386 ;; i[[3456]]86) target_cpu=i386 ;;
+3 -3
View File
@@ -642,8 +642,8 @@ module = {
name = regexp; name = regexp;
common = commands/regexp.c; common = commands/regexp.c;
common = commands/wildcard.c; common = commands/wildcard.c;
ldadd = libgnulib.a; ldadd = libregexp.a;
dependencies = libgnulib.a; dependencies = libregexp.a;
cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)'; cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)'; cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
}; };
@@ -835,7 +835,7 @@ module = {
name = verify; name = verify;
common = commands/verify.c; common = commands/verify.c;
cflags = '$(CFLAGS_POSIX)'; cflags = '$(CFLAGS_POSIX)';
cppflags = '-I$(srcdir)/lib/posix_wrap'; cppflags = '-I$(srcdir)/lib/posix_wrap/include';
}; };
module = { module = {
+3 -3
View File
@@ -45,8 +45,8 @@ grub_cmd_help (grub_extcmd_context_t ctxt __attribute__ ((unused)), int argc,
struct grub_term_output *term; struct grub_term_output *term;
const char *summary_translated = _(cmd->summary); const char *summary_translated = _(cmd->summary);
char *command_help; char *command_help;
grub_wchar_t *unicode_command_help; grub_uint32_t *unicode_command_help;
grub_wchar_t *unicode_last_position; grub_uint32_t *unicode_last_position;
command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated); command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated);
if (!command_help) if (!command_help)
@@ -58,7 +58,7 @@ grub_cmd_help (grub_extcmd_context_t ctxt __attribute__ ((unused)), int argc,
FOR_ACTIVE_TERM_OUTPUTS(term) FOR_ACTIVE_TERM_OUTPUTS(term)
{ {
unsigned stringwidth; unsigned stringwidth;
grub_wchar_t *unicode_last_screen_position; grub_uint32_t *unicode_last_screen_position;
unicode_last_screen_position = unicode_command_help; unicode_last_screen_position = unicode_command_help;
-1
View File
@@ -554,7 +554,6 @@ GRUB_MOD_INIT (gettext)
COMPILE_TIME_ASSERT (ARRAY_SIZE (domains) == CONTEXT_CNT); COMPILE_TIME_ASSERT (ARRAY_SIZE (domains) == CONTEXT_CNT);
for (i = 0; i < ARRAY_SIZE (domains); i++) for (i = 0; i < ARRAY_SIZE (domains); i++)
{ {
grub_err_t err;
err = grub_gettext_init_ext (&main_context[i], lang, err = grub_gettext_init_ext (&main_context[i], lang,
grub_env_get ("locale_dir"), grub_env_get ("locale_dir"),
grub_env_get ("prefix"), domains[i]); grub_env_get ("prefix"), domains[i]);
+3 -3
View File
@@ -42,7 +42,7 @@ grub_font_draw_string (const char *str, grub_font_t font,
int left_x, int baseline_y) int left_x, int baseline_y)
{ {
int x; int x;
grub_wchar_t *logical; grub_uint32_t *logical;
grub_ssize_t logical_len, visual_len; grub_ssize_t logical_len, visual_len;
struct grub_unicode_glyph *visual, *ptr; struct grub_unicode_glyph *visual, *ptr;
@@ -83,9 +83,9 @@ int
grub_font_get_string_width (grub_font_t font, const char *str) grub_font_get_string_width (grub_font_t font, const char *str)
{ {
int width = 0; int width = 0;
grub_wchar_t *ptr; grub_uint32_t *ptr;
grub_ssize_t logical_len; grub_ssize_t logical_len;
grub_wchar_t *logical; grub_uint32_t *logical;
logical_len = grub_utf8_to_ucs4_alloc (str, &logical, 0); logical_len = grub_utf8_to_ucs4_alloc (str, &logical, 0);
if (logical_len < 0) if (logical_len < 0)
File renamed without changes.
File renamed without changes.
@@ -25,14 +25,14 @@
#define errno grub_posix_errno #define errno grub_posix_errno
#define EINVAL GRUB_ERR_BAD_NUMBER #define EINVAL GRUB_ERR_BAD_NUMBER
#define ENOMEM GRUB_ERR_OUT_OF_MEMORY #define ENOMEM GRUB_ERR_OUT_OF_MEMORY
#define EAGAIN GRUB_ERR_AGAIN #define EAGAIN GRUB_ERR_WAIT
/* FIXME: Disambiguate this. */ /* FIXME: Disambiguate this. */
#define ENODEV GRUB_ERR_IO #define ENODEV GRUB_ERR_IO
#define ENOSYS GRUB_ERR_IO #define ENOSYS GRUB_ERR_IO
#define ENOENT GRUB_ERR_IO #define ENOENT GRUB_ERR_IO
#define EIO GRUB_ERR_IO #define EIO GRUB_ERR_IO
#define EROFS GRUB_ERR_POSIX_EROFS #define EROFS GRUB_ERR_POSIX_EROFS
#define EINTR GRUB_ERR_AGAIN #define EINTR GRUB_ERR_WAIT
#define EACCES GRUB_ERR_ACCESS_DENIED #define EACCES GRUB_ERR_ACCESS_DENIED
#define ERANGE GRUB_ERR_BAD_ARGUMENT #define ERANGE GRUB_ERR_BAD_ARGUMENT
#define EEXIST GRUB_ERR_POSIX_EEXIST #define EEXIST GRUB_ERR_POSIX_EEXIST
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -97,9 +97,11 @@ atol (const char *nptr)
} }
static inline grub_size_t static inline grub_size_t
mbstowcs (grub_wchar_t *dest, const char *src, grub_size_t n) mbstowcs (wchar_t *dest, const char *src, grub_size_t n)
{ {
grub_size_t ret = grub_utf8_to_ucs4 (dest, n, (const grub_uint8_t *) src, COMPILE_TIME_ASSERT( sizeof (grub_uint32_t) == sizeof (wchar_t));
grub_size_t ret = grub_utf8_to_ucs4 ((grub_uint32_t *) dest,
n, (const grub_uint8_t *) src,
-1, NULL); -1, NULL);
if (ret < n) if (ret < n)
dest[ret] = 0; dest[ret] = 0;
@@ -167,8 +167,8 @@ strdup (const char *s)
return grub_strdup (s); return grub_strdup (s);
} }
static inline grub_wchar_t * static inline wchar_t *
wmempcpy (grub_wchar_t *dest, const grub_wchar_t *src, grub_size_t n) wmempcpy (wchar_t *dest, const wchar_t *src, grub_size_t n)
{ {
grub_memcpy (dest, src, sizeof (dest[0]) * n); grub_memcpy (dest, src, sizeof (dest[0]) * n);
return dest + n; return dest + n;
@@ -215,7 +215,7 @@ static inline char *
mbschr (const char *src, int c) mbschr (const char *src, int c)
{ {
int count = 0; int count = 0;
grub_wchar_t code = 0; grub_uint32_t code = 0;
const char *last_start = src; const char *last_start = src;
while (1) while (1)
@@ -233,7 +233,7 @@ mbschr (const char *src, int c)
continue; continue;
if (code == 0) if (code == 0)
break; break;
if (code == c) if ((int) code == c)
return (char *) last_start; return (char *) last_start;
last_start = src; last_start = src;
} }
File renamed without changes.
@@ -22,8 +22,8 @@
#include <grub/charset.h> #include <grub/charset.h>
#include <grub/misc.h> #include <grub/misc.h>
#define wint_t grub_posix_wint_t #include <stddef.h>
#define wchar_t grub_posix_wchar_t
#define mbstate_t grub_posix_mbstate_t #define mbstate_t grub_posix_mbstate_t
/* UCS-4. */ /* UCS-4. */
@@ -32,20 +32,21 @@ enum
WEOF = -1 WEOF = -1
}; };
typedef int wint_t;
typedef struct mbstate { typedef struct mbstate {
grub_wchar_t code; grub_uint32_t code;
int count; int count;
} mbstate_t; } mbstate_t;
/* UTF-8. */ /* UTF-8. */
#define MB_CUR_MAX 4 #define MB_CUR_MAX 4
#define MB_LEN_MAX 4 #define MB_LEN_MAX 4
static inline grub_size_t static inline grub_size_t
mbrtowc (grub_wchar_t *pwc, const char *s, grub_size_t n, mbstate_t *ps) mbrtowc (wchar_t *pwc, const char *s, grub_size_t n, mbstate_t *ps)
{ {
COMPILE_TIME_ASSERT (sizeof (wchar_t) == sizeof (grub_wchar_t));
COMPILE_TIME_ASSERT (GRUB_WCHAR_MAX == WCHAR_MAX);
const char *ptr; const char *ptr;
if (!s) if (!s)
{ {
@@ -149,22 +150,22 @@ wmemcmp (const wchar_t *s1, const wchar_t *s2, grub_size_t n)
return 0; return 0;
} }
static inline grub_wchar_t * static inline wchar_t *
wmemchr (const grub_wchar_t *s, grub_wchar_t c, grub_size_t n) wmemchr (const wchar_t *s, wchar_t c, grub_size_t n)
{ {
for (; n--; s++) for (; n--; s++)
{ {
if (*s == c) if (*s == c)
return (grub_wchar_t *) s; return (wchar_t *) s;
} }
return 0; return 0;
} }
static inline grub_size_t static inline grub_size_t
wcslen (const grub_wchar_t *s) wcslen (const wchar_t *s)
{ {
const grub_wchar_t *ptr; const wchar_t *ptr;
for (ptr = s; *ptr; ptr++); for (ptr = s; *ptr; ptr++);
return ptr - s; return ptr - s;
} }
@@ -196,7 +197,7 @@ mbslen (const char *src)
{ {
int count = 0; int count = 0;
grub_size_t ret = 0; grub_size_t ret = 0;
grub_wchar_t code = 0; grub_uint32_t code = 0;
while (1) while (1)
{ {
File renamed without changes.
+42 -42
View File
@@ -29,10 +29,10 @@
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/charset.h> #include <grub/charset.h>
static grub_wchar_t *kill_buf; static grub_uint32_t *kill_buf;
static int hist_size; static int hist_size;
static grub_wchar_t **hist_lines = 0; static grub_uint32_t **hist_lines = 0;
static int hist_pos = 0; static int hist_pos = 0;
static int hist_end = 0; static int hist_end = 0;
static int hist_used = 0; static int hist_used = 0;
@@ -40,8 +40,8 @@ static int hist_used = 0;
grub_err_t grub_err_t
grub_set_history (int newsize) grub_set_history (int newsize)
{ {
grub_wchar_t **old_hist_lines = hist_lines; grub_uint32_t **old_hist_lines = hist_lines;
hist_lines = grub_malloc (sizeof (hist_lines[0]) * newsize); hist_lines = grub_malloc (sizeof (grub_uint32_t *) * newsize);
/* Copy the old lines into the new buffer. */ /* Copy the old lines into the new buffer. */
if (old_hist_lines) if (old_hist_lines)
@@ -68,16 +68,16 @@ grub_set_history (int newsize)
if (hist_pos < hist_end) if (hist_pos < hist_end)
grub_memmove (hist_lines, old_hist_lines + hist_pos, grub_memmove (hist_lines, old_hist_lines + hist_pos,
(hist_end - hist_pos) * sizeof (grub_wchar_t *)); (hist_end - hist_pos) * sizeof (grub_uint32_t *));
else if (hist_used) else if (hist_used)
{ {
/* Copy the older part. */ /* Copy the older part. */
grub_memmove (hist_lines, old_hist_lines + hist_pos, grub_memmove (hist_lines, old_hist_lines + hist_pos,
(hist_size - hist_pos) * sizeof (grub_wchar_t *)); (hist_size - hist_pos) * sizeof (grub_uint32_t *));
/* Copy the newer part. */ /* Copy the newer part. */
grub_memmove (hist_lines + hist_size - hist_pos, old_hist_lines, grub_memmove (hist_lines + hist_size - hist_pos, old_hist_lines,
hist_end * sizeof (grub_wchar_t *)); hist_end * sizeof (grub_uint32_t *));
} }
} }
@@ -91,7 +91,7 @@ grub_set_history (int newsize)
/* Get the entry POS from the history where `0' is the newest /* Get the entry POS from the history where `0' is the newest
entry. */ entry. */
static grub_wchar_t * static grub_uint32_t *
grub_history_get (unsigned pos) grub_history_get (unsigned pos)
{ {
pos = (hist_pos + pos) % hist_size; pos = (hist_pos + pos) % hist_size;
@@ -99,9 +99,9 @@ grub_history_get (unsigned pos)
} }
static grub_size_t static grub_size_t
strlen_ucs4 (const grub_wchar_t *s) strlen_ucs4 (const grub_uint32_t *s)
{ {
const grub_wchar_t *p = s; const grub_uint32_t *p = s;
while (*p) while (*p)
p++; p++;
@@ -111,23 +111,23 @@ strlen_ucs4 (const grub_wchar_t *s)
/* Replace the history entry on position POS with the string S. */ /* Replace the history entry on position POS with the string S. */
static void static void
grub_history_set (int pos, grub_wchar_t *s, grub_size_t len) grub_history_set (int pos, grub_uint32_t *s, grub_size_t len)
{ {
grub_free (hist_lines[pos]); grub_free (hist_lines[pos]);
hist_lines[pos] = grub_malloc ((len + 1) * sizeof (grub_wchar_t)); hist_lines[pos] = grub_malloc ((len + 1) * sizeof (grub_uint32_t));
if (!hist_lines[pos]) if (!hist_lines[pos])
{ {
grub_print_error (); grub_print_error ();
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
return ; return ;
} }
grub_memcpy (hist_lines[pos], s, len * sizeof (grub_wchar_t)); grub_memcpy (hist_lines[pos], s, len * sizeof (grub_uint32_t));
hist_lines[pos][len] = 0; hist_lines[pos][len] = 0;
} }
/* Insert a new history line S on the top of the history. */ /* Insert a new history line S on the top of the history. */
static void static void
grub_history_add (grub_wchar_t *s, grub_size_t len) grub_history_add (grub_uint32_t *s, grub_size_t len)
{ {
/* Remove the oldest entry in the history to make room for a new /* Remove the oldest entry in the history to make room for a new
entry. */ entry. */
@@ -154,7 +154,7 @@ grub_history_add (grub_wchar_t *s, grub_size_t len)
/* Replace the history entry on position POS with the string S. */ /* Replace the history entry on position POS with the string S. */
static void static void
grub_history_replace (unsigned pos, grub_wchar_t *s, grub_size_t len) grub_history_replace (unsigned pos, grub_uint32_t *s, grub_size_t len)
{ {
grub_history_set ((hist_pos + pos) % hist_size, s, len); grub_history_set ((hist_pos + pos) % hist_size, s, len);
} }
@@ -219,16 +219,16 @@ char *
grub_cmdline_get (const char *prompt_translated) grub_cmdline_get (const char *prompt_translated)
{ {
grub_size_t lpos, llen; grub_size_t lpos, llen;
grub_wchar_t *buf; grub_uint32_t *buf;
grub_size_t max_len = 256; grub_size_t max_len = 256;
int key; int key;
int histpos = 0; int histpos = 0;
auto void cl_insert (const grub_wchar_t *str); auto void cl_insert (const grub_uint32_t *str);
auto void cl_delete (unsigned len); auto void cl_delete (unsigned len);
auto inline void __attribute__ ((always_inline)) cl_print (struct cmdline_term *cl_term, int pos, auto inline void __attribute__ ((always_inline)) cl_print (struct cmdline_term *cl_term, int pos,
grub_wchar_t c); grub_uint32_t c);
auto void cl_set_pos (struct cmdline_term *cl_term); auto void cl_set_pos (struct cmdline_term *cl_term);
auto void cl_print_all (int pos, grub_wchar_t c); auto void cl_print_all (int pos, grub_uint32_t c);
auto void cl_set_pos_all (void); auto void cl_set_pos_all (void);
auto void init_clterm (struct cmdline_term *cl_term_cur); auto void init_clterm (struct cmdline_term *cl_term_cur);
auto void init_clterm_all (void); auto void init_clterm_all (void);
@@ -251,9 +251,9 @@ grub_cmdline_get (const char *prompt_translated)
cl_set_pos (&cl_terms[i]); cl_set_pos (&cl_terms[i]);
} }
inline void __attribute__ ((always_inline)) cl_print (struct cmdline_term *cl_term, int pos, grub_wchar_t c) inline void __attribute__ ((always_inline)) cl_print (struct cmdline_term *cl_term, int pos, grub_uint32_t c)
{ {
grub_wchar_t *p; grub_uint32_t *p;
for (p = buf + pos; p < buf + llen; p++) for (p = buf + pos; p < buf + llen; p++)
{ {
@@ -274,22 +274,22 @@ grub_cmdline_get (const char *prompt_translated)
} }
} }
void cl_print_all (int pos, grub_wchar_t c) void cl_print_all (int pos, grub_uint32_t c)
{ {
unsigned i; unsigned i;
for (i = 0; i < nterms; i++) for (i = 0; i < nterms; i++)
cl_print (&cl_terms[i], pos, c); cl_print (&cl_terms[i], pos, c);
} }
void cl_insert (const grub_wchar_t *str) void cl_insert (const grub_uint32_t *str)
{ {
grub_size_t len = strlen_ucs4 (str); grub_size_t len = strlen_ucs4 (str);
if (len + llen >= max_len) if (len + llen >= max_len)
{ {
grub_wchar_t *nbuf; grub_uint32_t *nbuf;
max_len *= 2; max_len *= 2;
nbuf = grub_realloc (buf, sizeof (nbuf[0]) * max_len); nbuf = grub_realloc (buf, sizeof (grub_uint32_t) * max_len);
if (nbuf) if (nbuf)
buf = nbuf; buf = nbuf;
else else
@@ -303,8 +303,8 @@ grub_cmdline_get (const char *prompt_translated)
if (len + llen < max_len) if (len + llen < max_len)
{ {
grub_memmove (buf + lpos + len, buf + lpos, grub_memmove (buf + lpos + len, buf + lpos,
(llen - lpos + 1) * sizeof (grub_wchar_t)); (llen - lpos + 1) * sizeof (grub_uint32_t));
grub_memmove (buf + lpos, str, len * sizeof (grub_wchar_t)); grub_memmove (buf + lpos, str, len * sizeof (grub_uint32_t));
llen += len; llen += len;
cl_set_pos_all (); cl_set_pos_all ();
@@ -327,7 +327,7 @@ grub_cmdline_get (const char *prompt_translated)
cl_set_pos_all (); cl_set_pos_all ();
grub_memmove (buf + lpos, buf + lpos + len, grub_memmove (buf + lpos, buf + lpos + len,
sizeof (grub_wchar_t) * (llen - lpos + 1)); sizeof (grub_uint32_t) * (llen - lpos + 1));
llen -= len; llen -= len;
cl_print_all (lpos, 0); cl_print_all (lpos, 0);
cl_set_pos_all (); cl_set_pos_all ();
@@ -350,7 +350,7 @@ grub_cmdline_get (const char *prompt_translated)
init_clterm (&cl_terms[i]); init_clterm (&cl_terms[i]);
} }
buf = grub_malloc (max_len * sizeof (grub_wchar_t)); buf = grub_malloc (max_len * sizeof (grub_uint32_t));
if (!buf) if (!buf)
return 0; return 0;
@@ -371,7 +371,7 @@ grub_cmdline_get (const char *prompt_translated)
{ {
struct cmdline_term *cl_term_cur; struct cmdline_term *cl_term_cur;
struct grub_term_output *cur; struct grub_term_output *cur;
grub_wchar_t *unicode_msg; grub_uint32_t *unicode_msg;
grub_size_t msg_len = grub_strlen (prompt_translated) + 3; grub_size_t msg_len = grub_strlen (prompt_translated) + 3;
nterms = 0; nterms = 0;
@@ -383,7 +383,7 @@ grub_cmdline_get (const char *prompt_translated)
return 0; return 0;
cl_term_cur = cl_terms; cl_term_cur = cl_terms;
unicode_msg = grub_malloc (msg_len * sizeof (grub_wchar_t)); unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t));
if (!unicode_msg) if (!unicode_msg)
return 0;; return 0;;
msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len - 1, msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len - 1,
@@ -447,7 +447,7 @@ grub_cmdline_get (const char *prompt_translated)
int restore; int restore;
char *insertu8; char *insertu8;
char *bufu8; char *bufu8;
grub_wchar_t c; grub_uint32_t c;
c = buf[lpos]; c = buf[lpos];
buf[lpos] = '\0'; buf[lpos] = '\0';
@@ -481,10 +481,10 @@ grub_cmdline_get (const char *prompt_translated)
{ {
grub_size_t insertlen; grub_size_t insertlen;
grub_ssize_t t; grub_ssize_t t;
grub_wchar_t *insert; grub_uint32_t *insert;
insertlen = grub_strlen (insertu8); insertlen = grub_strlen (insertu8);
insert = grub_malloc ((insertlen + 1) * sizeof (insert[0])); insert = grub_malloc ((insertlen + 1) * sizeof (grub_uint32_t));
if (!insert) if (!insert)
{ {
grub_free (insertu8); grub_free (insertu8);
@@ -524,7 +524,7 @@ grub_cmdline_get (const char *prompt_translated)
grub_free (kill_buf); grub_free (kill_buf);
kill_buf = grub_malloc ((llen - lpos + 1) kill_buf = grub_malloc ((llen - lpos + 1)
* sizeof (grub_wchar_t)); * sizeof (grub_uint32_t));
if (grub_errno) if (grub_errno)
{ {
grub_print_error (); grub_print_error ();
@@ -533,7 +533,7 @@ grub_cmdline_get (const char *prompt_translated)
else else
{ {
grub_memcpy (kill_buf, buf + lpos, grub_memcpy (kill_buf, buf + lpos,
(llen - lpos + 1) * sizeof (grub_wchar_t)); (llen - lpos + 1) * sizeof (grub_uint32_t));
kill_buf[llen - lpos] = 0; kill_buf[llen - lpos] = 0;
} }
@@ -544,7 +544,7 @@ grub_cmdline_get (const char *prompt_translated)
case GRUB_TERM_CTRL | 'n': case GRUB_TERM_CTRL | 'n':
case GRUB_TERM_KEY_DOWN: case GRUB_TERM_KEY_DOWN:
{ {
grub_wchar_t *hist; grub_uint32_t *hist;
lpos = 0; lpos = 0;
@@ -564,7 +564,7 @@ grub_cmdline_get (const char *prompt_translated)
case GRUB_TERM_KEY_UP: case GRUB_TERM_KEY_UP:
case GRUB_TERM_CTRL | 'p': case GRUB_TERM_CTRL | 'p':
{ {
grub_wchar_t *hist; grub_uint32_t *hist;
lpos = 0; lpos = 0;
@@ -588,7 +588,7 @@ grub_cmdline_get (const char *prompt_translated)
grub_free (kill_buf); grub_free (kill_buf);
kill_buf = grub_malloc ((n + 1) * sizeof(grub_wchar_t)); kill_buf = grub_malloc ((n + 1) * sizeof(grub_uint32_t));
if (grub_errno) if (grub_errno)
{ {
grub_print_error (); grub_print_error ();
@@ -596,7 +596,7 @@ grub_cmdline_get (const char *prompt_translated)
} }
if (kill_buf) if (kill_buf)
{ {
grub_memcpy (kill_buf, buf, n * sizeof(grub_wchar_t)); grub_memcpy (kill_buf, buf, n * sizeof(grub_uint32_t));
kill_buf[n] = 0; kill_buf[n] = 0;
} }
@@ -634,7 +634,7 @@ grub_cmdline_get (const char *prompt_translated)
default: default:
if (grub_isprint (key)) if (grub_isprint (key))
{ {
grub_wchar_t str[2]; grub_uint32_t str[2];
str[0] = key; str[0] = key;
str[1] = '\0'; str[1] = '\0';
@@ -652,7 +652,7 @@ grub_cmdline_get (const char *prompt_translated)
histpos = 0; histpos = 0;
if (strlen_ucs4 (buf) > 0) if (strlen_ucs4 (buf) > 0)
{ {
grub_wchar_t empty[] = { 0 }; grub_uint32_t empty[] = { 0 };
grub_history_replace (histpos, buf, llen); grub_history_replace (histpos, buf, llen);
grub_history_add (empty, 0); grub_history_add (empty, 0);
} }
+21 -41
View File
@@ -247,36 +247,17 @@ grub_normal_init_page (struct grub_term_output *term,
grub_term_cls (term); grub_term_cls (term);
if (!grub_term_is_tiny (term)) msg_formatted = grub_xasprintf (msg, PACKAGE_VERSION);
if (!msg_formatted)
return;
msg_len = grub_utf8_to_ucs4_alloc (msg_formatted,
&unicode_msg, &last_position);
grub_free (msg_formatted);
if (msg_len < 0)
{ {
int msg_len; return;
int posx;
const char *msg = _("GNU GRUB version %s");
char *msg_formatted;
grub_wchar_t *unicode_msg;
grub_wchar_t *last_position;
msg_formatted = grub_xasprintf (msg, PACKAGE_VERSION);
if (!msg_formatted)
return;
msg_len = grub_utf8_to_ucs4_alloc (msg_formatted,
&unicode_msg, &last_position);
grub_free (msg_formatted);
if (msg_len < 0)
{
return;
}
posx = grub_getstringwidth (unicode_msg, last_position, term);
posx = (grub_term_width (term) - posx) / 2;
grub_term_gotoxy (term, posx, 1);
grub_print_ucs4 (unicode_msg, last_position, 0, 0, term);
grub_putcode ('\n', term);
grub_putcode ('\n', term);
grub_free (unicode_msg);
} }
posx = grub_getstringwidth (unicode_msg, last_position, term); posx = grub_getstringwidth (unicode_msg, last_position, term);
@@ -426,19 +407,18 @@ grub_normal_reader_init (int nested)
return grub_errno; return grub_errno;
FOR_ACTIVE_TERM_OUTPUTS(term) FOR_ACTIVE_TERM_OUTPUTS(term)
if (!grub_term_is_tiny (term)) {
{ grub_normal_init_page (term, 1);
grub_normal_init_page (term, 1); grub_term_setcursor (term, 1);
grub_term_setcursor (term, 1);
if (grub_term_width (term) > 3 + STANDARD_MARGIN + 20) if (grub_term_width (term) > 3 + STANDARD_MARGIN + 20)
grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN, term); grub_print_message_indented (msg_formatted, 3, STANDARD_MARGIN, term);
else else
grub_print_message_indented (msg_formatted, 0, 0, term); grub_print_message_indented (msg_formatted, 0, 0, term);
grub_putcode ('\n', term); grub_putcode ('\n', term);
grub_putcode ('\n', term); grub_putcode ('\n', term);
grub_putcode ('\n', term); grub_putcode ('\n', term);
} }
grub_free (msg_formatted); grub_free (msg_formatted);
return 0; return 0;
+53 -60
View File
@@ -29,8 +29,8 @@
struct term_state struct term_state
{ {
struct term_state *next; struct term_state *next;
const struct grub_unicode_glyph *backlog_glyphs; struct grub_unicode_glyph *backlog_glyphs;
const grub_wchar_t *backlog_ucs4; const grub_uint32_t *backlog_ucs4;
int backlog_fixed_tab; int backlog_fixed_tab;
grub_size_t backlog_len; grub_size_t backlog_len;
@@ -59,7 +59,7 @@ static struct term_state *term_states = NULL;
static int grub_more; static int grub_more;
static void static void
putcode_real (grub_wchar_t code, struct grub_term_output *term, int fixed_tab); putcode_real (grub_uint32_t code, struct grub_term_output *term, int fixed_tab);
void void
grub_normal_reset_more (void) grub_normal_reset_more (void)
@@ -75,7 +75,7 @@ print_more (void)
char key; char key;
struct grub_term_coordinate *pos; struct grub_term_coordinate *pos;
grub_term_output_t term; grub_term_output_t term;
grub_wchar_t *unicode_str, *unicode_last_position; grub_uint32_t *unicode_str, *unicode_last_position;
pos = grub_term_save_pos (); pos = grub_term_save_pos ();
@@ -146,45 +146,10 @@ enum
GRUB_CP437_CORNER_UL = 0xda, GRUB_CP437_CORNER_UL = 0xda,
}; };
char static grub_uint32_t
grub_translit (grub_wchar_t in) map_code (grub_uint32_t in, struct grub_term_output *term)
{ {
if (!(in & ~0x7f)) if (in <= 0x7f)
return in;
switch (in)
{
case GRUB_UNICODE_LEFTARROW:
return '<';
case GRUB_UNICODE_UPARROW:
return '^';
case GRUB_UNICODE_RIGHTARROW:
return '>';
case GRUB_UNICODE_DOWNARROW:
return 'v';
case GRUB_UNICODE_HLINE:
return '-';
case GRUB_UNICODE_VLINE:
return '|';
case GRUB_UNICODE_CORNER_UL:
case GRUB_UNICODE_CORNER_UR:
case GRUB_UNICODE_CORNER_LL:
case GRUB_UNICODE_CORNER_LR:
return '+';
}
return '?';
}
static grub_wchar_t
map_code (grub_wchar_t in, struct grub_term_output *term)
{
if (!(in & ~0x7f))
return in; return in;
switch (term->flags & GRUB_TERM_CODE_TYPE_MASK) switch (term->flags & GRUB_TERM_CODE_TYPE_MASK)
@@ -215,9 +180,37 @@ map_code (grub_wchar_t in, struct grub_term_output *term)
case GRUB_UNICODE_CORNER_LR: case GRUB_UNICODE_CORNER_LR:
return GRUB_CP437_CORNER_LR; return GRUB_CP437_CORNER_LR;
} }
return '?';
case GRUB_TERM_CODE_TYPE_ASCII: case GRUB_TERM_CODE_TYPE_ASCII:
/* Better than nothing. */ /* Better than nothing. */
return grub_translit (in); switch (in)
{
case GRUB_UNICODE_LEFTARROW:
return '<';
case GRUB_UNICODE_UPARROW:
return '^';
case GRUB_UNICODE_RIGHTARROW:
return '>';
case GRUB_UNICODE_DOWNARROW:
return 'v';
case GRUB_UNICODE_HLINE:
return '-';
case GRUB_UNICODE_VLINE:
return '|';
case GRUB_UNICODE_CORNER_UL:
case GRUB_UNICODE_CORNER_UR:
case GRUB_UNICODE_CORNER_LL:
case GRUB_UNICODE_CORNER_LR:
return '+';
}
return '?';
} }
return in; return in;
} }
@@ -225,7 +218,7 @@ map_code (grub_wchar_t in, struct grub_term_output *term)
void void
grub_puts_terminal (const char *str, struct grub_term_output *term) grub_puts_terminal (const char *str, struct grub_term_output *term)
{ {
grub_wchar_t *unicode_str, *unicode_last_position; grub_uint32_t *unicode_str, *unicode_last_position;
grub_error_push (); grub_error_push ();
grub_utf8_to_ucs4_alloc (str, &unicode_str, grub_utf8_to_ucs4_alloc (str, &unicode_str,
&unicode_last_position); &unicode_last_position);
@@ -470,7 +463,7 @@ putglyph (const struct grub_unicode_glyph *c, struct grub_term_output *term,
for (i = -1; i < (int) c->ncomb; i++) for (i = -1; i < (int) c->ncomb; i++)
{ {
grub_uint8_t u8[20], *ptr; grub_uint8_t u8[20], *ptr;
grub_wchar_t code; grub_uint32_t code;
if (i == -1) if (i == -1)
{ {
@@ -508,7 +501,7 @@ putglyph (const struct grub_unicode_glyph *c, struct grub_term_output *term,
} }
static void static void
putcode_real (grub_wchar_t code, struct grub_term_output *term, int fixed_tab) putcode_real (grub_uint32_t code, struct grub_term_output *term, int fixed_tab)
{ {
struct grub_unicode_glyph c = struct grub_unicode_glyph c =
{ {
@@ -524,7 +517,7 @@ putcode_real (grub_wchar_t code, struct grub_term_output *term, int fixed_tab)
/* Put a Unicode character. */ /* Put a Unicode character. */
void void
grub_putcode (grub_wchar_t code, struct grub_term_output *term) grub_putcode (grub_uint32_t code, struct grub_term_output *term)
{ {
/* Combining character by itself? */ /* Combining character by itself? */
if (grub_unicode_get_comb_type (code) != GRUB_UNICODE_COMB_NONE) if (grub_unicode_get_comb_type (code) != GRUB_UNICODE_COMB_NONE)
@@ -565,8 +558,8 @@ fill_margin (struct grub_term_output *term, int r)
} }
static int static int
print_ucs4_terminal (const grub_wchar_t * str, print_ucs4_terminal (const grub_uint32_t * str,
const grub_wchar_t * last_position, const grub_uint32_t * last_position,
int margin_left, int margin_right, int margin_left, int margin_right,
struct grub_term_output *term, struct grub_term_output *term,
struct term_state *state, struct term_state *state,
@@ -575,12 +568,12 @@ print_ucs4_terminal (const grub_wchar_t * str,
grub_uint32_t contchar, grub_uint32_t contchar,
int primitive_wrap, int fill_right, struct grub_term_pos *pos) int primitive_wrap, int fill_right, struct grub_term_pos *pos)
{ {
const grub_wchar_t *ptr; const grub_uint32_t *ptr;
grub_ssize_t startwidth = dry_run ? 0 : get_startwidth (term, margin_left); grub_ssize_t startwidth = dry_run ? 0 : get_startwidth (term, margin_left);
grub_ssize_t line_width = startwidth; grub_ssize_t line_width = startwidth;
grub_ssize_t lastspacewidth = 0; grub_ssize_t lastspacewidth = 0;
grub_ssize_t max_width = get_maxwidth (term, margin_left, margin_right); grub_ssize_t max_width = get_maxwidth (term, margin_left, margin_right);
const grub_wchar_t *line_start = str, *last_space = str - 1; const grub_uint32_t *line_start = str, *last_space = str - 1;
int lines = 0; int lines = 0;
int i; int i;
struct term_state local_state; struct term_state local_state;
@@ -642,7 +635,7 @@ print_ucs4_terminal (const grub_wchar_t * str,
if (line_width > max_width || *ptr == '\n') if (line_width > max_width || *ptr == '\n')
{ {
const grub_wchar_t *ptr2; const grub_uint32_t *ptr2;
int wasn = (*ptr == '\n'); int wasn = (*ptr == '\n');
if (wasn) if (wasn)
@@ -740,7 +733,7 @@ print_ucs4_terminal (const grub_wchar_t * str,
lines++; lines++;
if (!dry_run && !skip_lines && max_lines) if (!dry_run && !skip_lines && max_lines)
{ {
const grub_wchar_t *ptr2; const grub_uint32_t *ptr2;
for (ptr2 = line_start; ptr2 < last_position; ptr2++) for (ptr2 = line_start; ptr2 < last_position; ptr2++)
{ {
@@ -880,8 +873,8 @@ getcharwidth (const struct grub_unicode_glyph *c, void *term)
} }
static int static int
print_ucs4_real (const grub_wchar_t * str, print_ucs4_real (const grub_uint32_t * str,
const grub_wchar_t * last_position, const grub_uint32_t * last_position,
int margin_left, int margin_right, int margin_left, int margin_right,
struct grub_term_output *term, int backlog, struct grub_term_output *term, int backlog,
int dry_run, int fixed_tab, unsigned skip_lines, int dry_run, int fixed_tab, unsigned skip_lines,
@@ -995,8 +988,8 @@ grub_print_ucs4_menu (const grub_uint32_t * str,
} }
void void
grub_print_ucs4 (const grub_wchar_t * str, grub_print_ucs4 (const grub_uint32_t * str,
const grub_wchar_t * last_position, const grub_uint32_t * last_position,
int margin_left, int margin_right, int margin_left, int margin_right,
struct grub_term_output *term) struct grub_term_output *term)
{ {
@@ -1005,8 +998,8 @@ grub_print_ucs4 (const grub_wchar_t * str,
} }
int int
grub_ucs4_count_lines (const grub_wchar_t * str, grub_ucs4_count_lines (const grub_uint32_t * str,
const grub_wchar_t * last_position, const grub_uint32_t * last_position,
int margin_left, int margin_right, int margin_left, int margin_right,
struct grub_term_output *term) struct grub_term_output *term)
{ {
@@ -1017,7 +1010,7 @@ grub_ucs4_count_lines (const grub_wchar_t * str,
void void
grub_xnputs (const char *str, grub_size_t msg_len) grub_xnputs (const char *str, grub_size_t msg_len)
{ {
grub_wchar_t *unicode_str = NULL, *unicode_last_position; grub_uint32_t *unicode_str = NULL, *unicode_last_position;
int backlog = 0; int backlog = 0;
grub_term_output_t term; grub_term_output_t term;
-2
View File
@@ -59,9 +59,7 @@
#define ALIGN_UP_OVERHEAD(addr, align) ((-(addr)) & ((typeof (addr)) (align) - 1)) #define ALIGN_UP_OVERHEAD(addr, align) ((-(addr)) & ((typeof (addr)) (align) - 1))
#define ALIGN_DOWN(addr, align) \ #define ALIGN_DOWN(addr, align) \
((addr) & ~((typeof (addr)) align - 1)) ((addr) & ~((typeof (addr)) align - 1))
#ifndef GRUB_POSIX
#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0])) #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
#endif
#define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; } #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
#define grub_dprintf(condition, fmt, args...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, fmt, ## args) #define grub_dprintf(condition, fmt, args...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, fmt, ## args)