Invoke the shell using /bin/bash instead of /bin/sh.

Use convert_to/from_utf8() directly instead of the homebrewn proxy methods.
Removed CodeConv from the repository.
Remove UTF8WidthTbl.c from the repository, since it's not used anymore.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34894 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2010-01-04 18:37:37 +00:00
parent 9f7a3e3406
commit 74d2e1599a
12 changed files with 691 additions and 9119 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ Arguments::Arguments()
fShellArguments(NULL),
fTitle(NULL)
{
const char *argv[] = { "/bin/sh", "--login" };
const char *argv[] = { "/bin/bash", "--login" };
_SetShellArguments(2, argv);
}
@@ -13,7 +13,6 @@
#include <String.h>
#include "CodeConv.h"
#include "TermConst.h"
#include "TerminalCharClassifier.h"
#include "TerminalLine.h"
@@ -550,8 +549,6 @@ BasicTerminalBuffer::InsertChar(UTF8Char c, uint32 width, uint32 attributes)
{
//debug_printf("BasicTerminalBuffer::InsertChar('%.*s' (%d), %#lx)\n",
//(int)c.ByteCount(), c.bytes, c.bytes[0], attributes);
// TODO: Check if this method can be removed completely
//int width = CodeConv::UTF8GetFontWidth(c.bytes);
if ((int32)width == FULL_WIDTH)
attributes |= A_WIDTH;
@@ -589,8 +586,6 @@ BasicTerminalBuffer::InsertChar(UTF8Char c, uint32 width, uint32 attributes)
void
BasicTerminalBuffer::FillScreen(UTF8Char c, uint32 width, uint32 attributes)
{
// TODO: Check if this method can be removed completely
//int width = CodeConv::UTF8GetFontWidth(c.bytes);
if ((int32)width == FULL_WIDTH)
attributes |= A_WIDTH;
-181
View File
@@ -1,181 +0,0 @@
/*
* Copyright (c) 2001-2007, Haiku, Inc.
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
* Distributed under the terms of the MIT license.
*/
/*********************************************************************
MuTerminal Code Conversion class (MC3).
version 1.1 Internal coding system is UTF8.
Code conversion member functions are convert character code and calc
font width.
Available coding systems.
ISO-8859-1 ... 10
Shift JIS
EUC-jp
UTF8
************************************************************************/
#include <UTF8.h>
#include <string.h>
#include "CodeConv.h"
#define BEGINS_CHAR(byte) ((byte & 0xc0) >= 0x80)
extern char gUTF8WidthTable[]; // defined in UTF8WidthTbl.c
//! get font width in coding.
/* static */
int32
CodeConv::UTF8GetFontWidth(const char *string)
{
ushort unicode = UTF8toUnicode(string);
uchar width = gUTF8WidthTable[unicode >> 3];
ushort offset = unicode & 0x07;
uchar point = 0x80 >> offset;
return (width & point) > 0 ? 2 : 1;
}
//! Convert internal coding from src coding.
/* static */
int32
CodeConv::ConvertFromInternal(const char *src, int32 srclen, char *dst, int coding)
{
if (srclen == -1)
srclen = strlen(src);
if (coding == M_UTF8) {
memcpy(dst, src, srclen);
dst[srclen] = '\0';
return srclen;
}
int32 dstlen = srclen * 256;
long state = 0;
convert_from_utf8(coding, (char *)src, &srclen,
(char *)dst, &dstlen, &state, '?');
// TODO: Apart from this particular case, looks like we could use the
// system api for code conversion... check if this (which looks a lot like a workaround)
// applies to haiku, and if not, get rid of this class and just use the system api directly.
if (coding == B_EUC_CONVERSION && state != 0) {
const char *end_of_jis = "\033(B";
strncpy((char *)dst + dstlen, end_of_jis, 3);
dstlen += 3;
}
dst[dstlen] = '\0';
return dstlen;
}
//! Convert internal coding to src coding.
/* static */
int32
CodeConv::ConvertToInternal(const char *src, int32 srclen, char *dst, int coding)
{
if (srclen == -1)
srclen = strlen(src);
if (coding == M_UTF8) {
memcpy(dst, src, srclen);
dst[srclen] = '\0';
return srclen;
}
#if 0
#ifndef __INTEL__
if (coding = M_EUC_JP) {
uchar buf[2];
memcpy (buf, src, 2);
euc_to_sjis (buf);
srclen = 2;
convert_to_utf8 (B_SJIS_CONVERSION, (char*) buf, &srclen,
(char *)dst, &dstlen,
&state, '?');
dst[dstlen] = '\0';
return;
}
#endif
#endif
int32 dstlen = 4;
long state = 0;
convert_to_utf8(coding, (char *)src, &srclen,
(char *)dst, &dstlen, &state, '?');
dst[dstlen] = '\0';
return dstlen;
}
/* static */
unsigned short
CodeConv::UTF8toUnicode(const char *utf8)
{
uchar tmp;
unsigned short unicode = 0x0000;
tmp = *utf8 & 0xe0;
if (tmp < 0x80) {
unicode = (unsigned short)*utf8;
} else if (tmp < 0xe0) {
unicode = (unsigned short)*utf8++ & 0x1f;
unicode = unicode << 6;
unicode = unicode | ((unsigned short)*utf8 & 0x3f);
} else if (tmp < 0xf0) {
unicode = (unsigned short)*utf8++ & 0x0f;
unicode = unicode << 6;
unicode = unicode | ((unsigned short)*utf8++ & 0x3f);
unicode = unicode << 6;
unicode = unicode | ((unsigned short)*utf8 & 0x3f);
}
return unicode;
}
/* static */
void
CodeConv::euc_to_sjis(uchar *buf)
{
int gl, gr;
int p;
int c1, c2;
gl = *buf & 0x7F;
gr = *(buf + 1) & 0x7F;
gl -= 0x21;
gr -= 0x21;
p = gl * 94 + gr;
c1 = p / 188;
c2 = p % 188;
if (c1 >= 31)
c1 = c1 - 31 + 0xE0;
else
c1 += 0x81;
if (c2 >= 63)
c2 = c2 - 63 + 0x80;
else
c2 += 0x40;
*buf++ = c1;
*buf = c2;
}
-31
View File
@@ -1,31 +0,0 @@
/*
* Copyright (c) 2001-2005, Haiku, Inc.
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
* Distributed under the terms of the MIT license.
*/
#ifndef CODECONV_H
#define CODECONV_H
#include <SupportDefs.h>
#include "Encoding.h"
class CodeConv {
public:
static int32 UTF8GetFontWidth(const char *string);
/* internal(UTF8) -> coding */
static int32 ConvertFromInternal(const char *src, int32 bytes, char *dst, int coding);
/* coding -> internal(UTF8) */
static int32 ConvertToInternal(const char *src, int32 bytes, char *dst, int coding);
private:
static void euc_to_sjis(uchar *buf);
static unsigned short UTF8toUnicode(const char *utf8);
};
#endif /* CODECONV_H */
+1
View File
@@ -4,6 +4,7 @@
*/
#include "Encoding.h"
#include "TermConst.h"
#include <string.h>
-1
View File
@@ -35,7 +35,6 @@
#include <SupportDefs.h>
#include <UTF8.h>
#define M_UTF8 (-1)
status_t get_next_encoding(int i, int *id);
-2
View File
@@ -8,7 +8,6 @@ Application Terminal :
AppearPrefView.cpp
Arguments.cpp
BasicTerminalBuffer.cpp
CodeConv.cpp
Encoding.cpp
FindWindow.cpp
Globals.cpp
@@ -25,7 +24,6 @@ Application Terminal :
TermScrollView.cpp
TermView.cpp
TermWindow.cpp
UTF8WidthTbl.c
VTKeyTbl.c
VTPrsTbl.c
: be tracker textencoding $(TARGET_LIBSUPC++)
+2
View File
@@ -152,6 +152,8 @@ enum{
SCRDOWN
};
#define M_UTF8 -1
#define TAB_WIDTH 8
#define MIN_COLS 10
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -56,14 +56,14 @@ public:
status_t StopThreads();
private:
inline status_t _NextParseChar(uchar &c);
inline uchar _NextParseChar();
// Initialize TermParse and PtyReader thread.
status_t InitTermParse();
status_t InitPtyReader();
status_t _InitTermParse();
status_t _InitPtyReader();
void StopTermParse();
void StopPtyReader();
void _StopTermParse();
void _StopPtyReader();
int32 EscParse();
int32 PtyReader();
+12 -10
View File
@@ -48,7 +48,7 @@
#include <StringView.h>
#include <Window.h>
#include "CodeConv.h"
#include "Encoding.h"
#include "InlineInput.h"
#include "Shell.h"
#include "TermConst.h"
@@ -343,15 +343,15 @@ TermView::_InitObject(int32 argc, const char** argv)
SetTermFont(be_fixed_font);
status_t status = fShell->Open(fRows, fColumns,
error = fShell->Open(fRows, fColumns,
EncodingAsShortString(fEncoding), argc, argv);
if (status < B_OK)
return status;
if (error < B_OK)
return error;
status = _AttachShell(fShell);
if (status < B_OK)
return status;
error = _AttachShell(fShell);
if (error < B_OK)
return error;
SetLowColor(fTextBackColor);
SetViewColor(B_TRANSPARENT_32_BIT);
@@ -1243,10 +1243,12 @@ TermView::KeyDown(const char *bytes, int32 numBytes)
if (numBytes > 1) {
if (fEncoding != M_UTF8) {
char destBuffer[16];
int cnum = CodeConv::ConvertFromInternal(bytes, numBytes,
(char *)destBuffer, fEncoding);
int32 destLen;
long state = 0;
convert_from_utf8(fEncoding, bytes, &numBytes, destBuffer,
&destLen, &state, '?');
_ScrollTo(0, true);
fShell->Write(destBuffer, cnum);
fShell->Write(destBuffer, destLen);
return;
}
File diff suppressed because it is too large Load Diff