interim commit

- added wide-to-multibyte charater conversion in pio
This commit is contained in:
hyung-hwan 2009-01-08 04:26:55 +00:00
parent e606d9f9e1
commit 37344d7e09
19 changed files with 237 additions and 19 deletions

View File

@ -1,5 +1,19 @@
/*
* $Id: ctype.h 223 2008-06-26 06:44:41Z baconevi $
*
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_CHR_H_

View File

@ -1,7 +1,19 @@
/*
* $Id: map.h 223 2008-06-26 06:44:41Z baconevi $
*
* {License}
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_DLL_H_

View File

@ -1,5 +1,19 @@
/*
* $Id$
*
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_FIO_H_

View File

@ -1,5 +1,19 @@
/*
* $Id: sysapi.h,v 1.56 2006/03/21 16:15:16 bacon Ease $
*
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_IO_H_

View File

@ -1,7 +1,19 @@
/*
* $Id: lda.h 363 2008-09-04 10:58:08Z baconevi $
*
* {License}
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_LDA_H_

View File

@ -1,7 +1,19 @@
/*
* $Id: map.h 496 2008-12-15 09:56:48Z baconevi $
*
* {License}
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_MAP_H_

View File

@ -1,7 +1,19 @@
/*
* $Id: mem.h 337 2008-08-20 09:17:25Z baconevi $
*
* {License}
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_MEM_H_

View File

@ -1,7 +1,19 @@
/*
* $Id: getopt.h 290 2008-07-27 06:16:54Z baconevi $
*
* {License}
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_OPT_H_

View File

@ -1,5 +1,19 @@
/*
* $Id$
*
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_PIO_H_

View File

@ -1,7 +1,19 @@
/*
* $Id: rex.h 223 2008-06-26 06:44:41Z baconevi $
*
* {License}
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_REX_H_

View File

@ -1,5 +1,19 @@
/*
* $Id: sio.h,v 1.29 2005/12/26 05:38:24 bacon Ease $
*
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_SIO_H_

View File

@ -1,7 +1,19 @@
/*
* $Id: sll.h 223 2008-06-26 06:44:41Z baconevi $
*
* {License}
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_SLL_H_

View File

@ -1,7 +1,19 @@
/*
* $Id: str.h 496 2008-12-15 09:56:48Z baconevi $
*
* {License}
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_STR_H_

View File

@ -1,5 +1,19 @@
/*
* $Id$
*
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_TIME_H_

View File

@ -1,5 +1,19 @@
/*
* $Id: tio.h,v 1.19 2006/01/01 13:50:24 bacon Exp $
*
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_CMN_TIO_H_

View File

@ -1,7 +1,19 @@
/*
* $Id: lsp.h 183 2008-06-03 08:18:55Z baconevi $
*
* {License}
Copyright 2006-2008 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_LSP_LSP_H_

View File

@ -173,18 +173,27 @@ qse_pio_t* qse_pio_init (
if (flags & QSE_PIO_SHELL)
{
const qse_mchar_t* mcmd;
#ifdef QSE_CHAR_IS_MCHAR
const char* mcmd = cmd;
mcmd = cmd;
#else
qse_size_t n, mn;
const char mcmd[1024];
mn = QSE_COUNTOF (mcmd);
n = qse_wcstombslen (cmd, &mn);
if (cmd[n] != QSE_WT('\0'))
{
/* cmd has illegal sequence */
goto child_oops;
}
mn = mn + 1;
mcmd = QSE_MMGR_ALLOC (
pio->mmgr, mn*QSE_SIZEOF(*mcmd));
if (mcmd == QSE_NULL) goto child_oops;
n = qse_wcstombs (cmd, mcmd, &mn);
if (cmd[n] != QSE_WT('\0')) goto child_oops;
if (mn >= QSE_COUNTOF(mcmd)) goto child_oops;
execl ("/bin/sh", "sh", "-c", mcmd, QSE_NULL);
}
else

View File

@ -238,9 +238,12 @@ qse_size_t qse_wcstombslen (const qse_wchar_t* wcs, qse_size_t* mbslen)
p++; mlen += n;
}
/* this length excludes the terminating null character. */
*mbslen = mlen;
/* returns the number of characters handled. */
/* returns the number of characters handled.
* if the function has encountered an illegal character in
* the while loop above, wcs[p-wcs] will not be a null character */
return p - wcs;
}

View File

@ -18,7 +18,7 @@ static int test1 (void)
QSE_NULL,
0,
QSE_T("ls -laF"),
QSE_PIO_READERR|QSE_PIO_WRITEIN|QSE_PIO_ERRTOOUT|QSE_PIO_ERRTONUL | QSE_PIO_INTONUL
QSE_PIO_READOUT|QSE_PIO_WRITEIN|QSE_PIO_SHELL
);
if (pio == QSE_NULL)
{
@ -33,7 +33,7 @@ static int test1 (void)
qse_byte_t buf[128];
/*qse_pio_canread (pio, QSE_PIO_ERR, 1000)*/
qse_ssize_t n = qse_pio_read (pio, buf, sizeof(buf), QSE_PIO_ERR);
qse_ssize_t n = qse_pio_read (pio, buf, sizeof(buf), QSE_PIO_OUT);
if (n == 0) break;
if (n < 0)
{