summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2012-03-16 09:07:32 +0100
committerPaolo Bonzini <bonzini@gnu.org>2012-03-16 10:08:35 +0100
commit24b6cccd075d3f485aa4089db21f4df2f2a533b9 (patch)
tree6487b15b5ed1ef4363f3a82621dc41021f8afdbd
parentfd772887c362ff3b877ed52983bd10d9cabe8be5 (diff)
downloadsed-24b6cccd075d3f485aa4089db21f4df2f2a533b9.tar.gz
unconditionally compile for MBCS
2012-03-16 Paolo Bonzini <bonzini@gnu.org> * sed/execute.c: Unconditionally compile for MBCS. * sed/mbcs.c: Unconditionally compile for MBCS. * sed/sed.h: Unconditionally compile for MBCS.
-rw-r--r--ChangeLog6
-rw-r--r--sed/execute.c52
-rw-r--r--sed/mbcs.c6
-rw-r--r--sed/sed.h15
4 files changed, 6 insertions, 73 deletions
diff --git a/ChangeLog b/ChangeLog
index 92ba840..6079991 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2012-03-16 Paolo Bonzini <bonzini@gnu.org>
+ * sed/execute.c: Unconditionally compile for MBCS.
+ * sed/mbcs.c: Unconditionally compile for MBCS.
+ * sed/sed.h: Unconditionally compile for MBCS.
+
+2012-03-16 Paolo Bonzini <bonzini@gnu.org>
+
* basicdefs.h: Enjoy gnulib's headers.
* sed/compile.c: Likewise.
* sed/execute.c: Likewise.
diff --git a/sed/execute.c b/sed/execute.c
index 8f3a609..6e96ee5 100644
--- a/sed/execute.c
+++ b/sed/execute.c
@@ -55,16 +55,10 @@ struct line {
size_t length; /* Length of text (or active, if used). */
size_t alloc; /* Allocated space for active. */
bool chomped; /* Was a trailing newline dropped? */
-#ifdef HAVE_MBRTOWC
mbstate_t mbstate;
-#endif
};
-#ifdef HAVE_MBRTOWC
#define SIZEOF_LINE offsetof (struct line, mbstate)
-#else
-#define SIZEOF_LINE (sizeof (struct line))
-#endif
/* A queue of text to write out at the end of a cycle
(filled by the "a", "r" and "R" commands.) */
@@ -185,7 +179,6 @@ str_append(to, string, length)
MEMCPY(to->active + to->length, string, length);
to->length = new_length;
-#ifdef HAVE_MBRTOWC
if (mb_cur_max > 1 && !is_utf8)
while (length)
{
@@ -206,7 +199,6 @@ str_append(to, string, length)
else
break;
}
-#endif
}
static void str_append_modified P_((struct line *, const char *, size_t,
@@ -218,7 +210,6 @@ str_append_modified(to, string, length, type)
size_t length;
enum replacement_types type;
{
-#ifdef HAVE_MBRTOWC
mbstate_t from_stat;
if (type == REPL_ASIS)
@@ -284,39 +275,6 @@ str_append_modified(to, string, length, type)
abort ();
}
}
-#else
- size_t old_length = to->length;
- char *start, *end;
-
- str_append(to, string, length);
- start = to->active + old_length;
- end = start + length;
-
- /* Now do the required modifications. First \[lu]... */
- if (type & REPL_UPPERCASE_FIRST)
- {
- *start = toupper(*start);
- start++;
- type &= ~REPL_UPPERCASE_FIRST;
- }
- else if (type & REPL_LOWERCASE_FIRST)
- {
- *start = tolower(*start);
- start++;
- type &= ~REPL_LOWERCASE_FIRST;
- }
-
- if (type == REPL_ASIS)
- return;
-
- /* ...and then \[LU] */
- if (type == REPL_UPPERCASE)
- for (; start != end; start++)
- *start = toupper(*start);
- else
- for (; start != end; start++)
- *start = tolower(*start);
-#endif
}
/* Initialize a "struct line" buffer. Copy multibyte state from `state'
@@ -334,12 +292,10 @@ line_init(buf, state, initial_size)
buf->length = 0;
buf->chomped = true;
-#ifdef HAVE_MBRTOWC
if (state)
memcpy (&buf->mbstate, &state->mbstate, sizeof (buf->mbstate));
else
memset (&buf->mbstate, 0, sizeof (buf->mbstate));
-#endif
}
/* Reset a "struct line" buffer to length zero. Copy multibyte state from
@@ -354,12 +310,10 @@ line_reset(buf, state)
else
{
buf->length = 0;
-#ifdef HAVE_MBRTOWC
if (state)
memcpy (&buf->mbstate, &state->mbstate, sizeof (buf->mbstate));
else
memset (&buf->mbstate, 0, sizeof (buf->mbstate));
-#endif
}
}
@@ -394,10 +348,8 @@ line_copy(from, to, state)
to->chomped = from->chomped;
MEMCPY(to->active, from->active, from->length);
-#ifdef HAVE_MBRTOWC
if (state)
MEMCPY(&to->mbstate, &from->mbstate, sizeof (from->mbstate));
-#endif
}
/* Append the contents of the line `from' to the line `to'.
@@ -413,10 +365,8 @@ line_append(from, to, state)
str_append(to, from->active, from->length);
to->chomped = from->chomped;
-#ifdef HAVE_MBRTOWC
if (state)
MEMCPY (&to->mbstate, &from->mbstate, sizeof (from->mbstate));
-#endif
}
/* Exchange two "struct line" buffers.
@@ -1604,7 +1554,6 @@ execute_program(vec, input)
case 'y':
{
-#ifdef HAVE_MBRTOWC
if (mb_cur_max > 1)
{
int idx, prev_idx; /* index in the input line. */
@@ -1672,7 +1621,6 @@ execute_program(vec, input)
}
}
else
-#endif /* HAVE_MBRTOWC */
{
unsigned char *p, *e;
p = CAST(unsigned char *)line.active;
diff --git a/sed/mbcs.c b/sed/mbcs.c
index 5746fd5..964e352 100644
--- a/sed/mbcs.c
+++ b/sed/mbcs.c
@@ -24,7 +24,6 @@
int mb_cur_max;
bool is_utf8;
-#ifdef HAVE_MBRTOWC
/* Add a byte to the multibyte character represented by the state
CUR_STAT, and answer its length if a character is completed,
or -2 if it is yet to be completed. */
@@ -46,7 +45,6 @@ int brlen (ch, cur_stat)
return result;
}
-#endif
void
initialize_mbcs ()
@@ -57,10 +55,6 @@ initialize_mbcs ()
codeset_name = locale_charset ();
is_utf8 = (strcmp (codeset_name, "UTF-8") == 0);
-#ifdef HAVE_MBRTOWC
mb_cur_max = MB_CUR_MAX;
-#else
- mb_cur_max = 1;
-#endif
}
diff --git a/sed/sed.h b/sed/sed.h
index 9e22850..2f5cd19 100644
--- a/sed/sed.h
+++ b/sed/sed.h
@@ -241,8 +241,6 @@ extern bool use_extended_syntax_p;
extern int mb_cur_max;
extern bool is_utf8;
-#ifdef HAVE_MBRTOWC
-#ifdef HAVE_BTOWC
#define MBRTOWC(pwc, s, n, ps) \
(mb_cur_max == 1 ? \
(*(pwc) = btowc (*(unsigned char *) (s)), 1) : \
@@ -252,13 +250,6 @@ extern bool is_utf8;
(mb_cur_max == 1 ? \
(*(s) = wctob ((wint_t) (wc)), 1) : \
wcrtomb ((s), (wc), (ps)))
-#else
-#define MBRTOWC(pwc, s, n, ps) \
- mbrtowc ((pwc), (s), (n), (ps))
-
-#define WCRTOMB(s, wc, ps) \
- wcrtomb ((s), (wc), (ps))
-#endif
#define MBSINIT(s) \
(mb_cur_max == 1 ? 1 : mbsinit ((s)))
@@ -269,11 +260,5 @@ extern bool is_utf8;
#define BRLEN(ch, ps) \
(mb_cur_max == 1 ? 1 : brlen (ch, ps))
-#else
-#define MBSINIT(s) 1
-#define MBRLEN(s, n, ps) 1
-#define BRLEN(ch, ps) 1
-#endif
-
extern int brlen P_ ((int ch, mbstate_t *ps));