touched up a few string copy functions
This commit is contained in:
		| @ -9,7 +9,7 @@ lib_LTLIBRARIES = libqsecmn.la | ||||
| libqsecmn_la_SOURCES = \ | ||||
| 	syscall.h mem.h \ | ||||
| 	mem.c xma.c fma.c chr.c chr_cnv.c rex.c \ | ||||
| 	str_bas.c str_cnv.c str_dyn.c str_pbrk.c str_spn.c str_utl.c \ | ||||
| 	str_bas.c str_cnv.c str_cpy.c str_dyn.c str_pbrk.c str_spn.c str_utl.c \ | ||||
| 	lda.c oht.c htb.c rbt.c sll.c gdl.c dll.c opt.c \ | ||||
| 	tio.c tio_get.c tio_put.c \ | ||||
| 	fio.c pio.c sio.c \ | ||||
|  | ||||
| @ -265,7 +265,7 @@ lib_LTLIBRARIES = libqsecmn.la $(am__append_1) | ||||
| libqsecmn_la_SOURCES = \ | ||||
| 	syscall.h mem.h \ | ||||
| 	mem.c xma.c fma.c chr.c chr_cnv.c rex.c \ | ||||
| 	str_bas.c str_cnv.c str_dyn.c str_pbrk.c str_spn.c str_utl.c \ | ||||
| 	str_bas.c str_cnv.c str_cpy.c str_dyn.c str_pbrk.c str_spn.c str_utl.c \ | ||||
| 	lda.c oht.c htb.c rbt.c sll.c gdl.c dll.c opt.c \ | ||||
| 	tio.c tio_get.c tio_put.c \ | ||||
| 	fio.c pio.c sio.c \ | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * $Id: pio.c 407 2011-03-23 02:21:14Z hyunghwan.chung $ | ||||
|  * $Id: pio.c 410 2011-03-23 15:07:24Z hyunghwan.chung $ | ||||
|  * | ||||
|     Copyright 2006-2009 Chung, Hyung-Hwan. | ||||
|     This file is part of QSE. | ||||
| @ -492,9 +492,10 @@ qse_pio_t* qse_pio_init ( | ||||
| 		 *          doing better parsing of the command line. | ||||
| 		 */ | ||||
|  | ||||
| 		/* NOTE: you must separate the command name and the parameters with  | ||||
| 		 *       a space. "pstat.exe /c" is ok while "pstat.exe/c" is not. */ | ||||
| 		mptr = qse_mbschr (cmd_line, QSE_MT(' ')); | ||||
| 		/* NOTE: you must separate the command name and the parameters  | ||||
| 		 *       with a space. "pstat.exe /c" is ok while "pstat.exe/c" | ||||
| 		 *       is not. */ | ||||
| 		mptr = qse_mbspbrk (cmd_line, QSE_MT(" \t")); | ||||
| 		if (mptr) *mptr = QSE_MT('\0'); | ||||
| 		cmd_line[mn+1] = QSE_MT('\0'); /* the second '\0' at the end */ | ||||
| 		cmd_file = cmd_line; | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * $Id: str_bas.c 405 2011-03-21 14:01:10Z hyunghwan.chung $ | ||||
|  * $Id: str_bas.c 410 2011-03-23 15:07:24Z hyunghwan.chung $ | ||||
|  * | ||||
|     Copyright 2006-2009 Chung, Hyung-Hwan. | ||||
|     This file is part of QSE. | ||||
| @ -43,85 +43,6 @@ qse_size_t qse_strbytes (const qse_char_t* str) | ||||
| 	return (p - str) * QSE_SIZEOF(qse_char_t); | ||||
| } | ||||
|  | ||||
| qse_size_t qse_mbscpy (qse_mchar_t* buf, const qse_mchar_t* str) | ||||
| { | ||||
| 	qse_mchar_t* org = buf; | ||||
| 	while ((*buf++ = *str++) != QSE_MT('\0')); | ||||
| 	return buf - org - 1; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_wcscpy (qse_wchar_t* buf, const qse_wchar_t* str) | ||||
| { | ||||
| 	qse_wchar_t* org = buf; | ||||
| 	while ((*buf++ = *str++) != QSE_WT('\0')); | ||||
| 	return buf - org - 1; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_strxcpy ( | ||||
| 	qse_char_t* buf, qse_size_t bsz, const qse_char_t* str) | ||||
| { | ||||
| 	qse_char_t* p, * p2; | ||||
|  | ||||
| 	p = buf; p2 = buf + bsz - 1; | ||||
|  | ||||
| 	while (p < p2)  | ||||
| 	{ | ||||
| 		if (*str == QSE_T('\0')) break; | ||||
| 		*p++ = *str++; | ||||
| 	} | ||||
|  | ||||
| 	if (bsz > 0) *p = QSE_T('\0'); | ||||
| 	return p - buf; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_strncpy ( | ||||
| 	qse_char_t* buf, const qse_char_t* str, qse_size_t len) | ||||
| { | ||||
| 	/* | ||||
| 	const qse_char_t* end = str + len; | ||||
| 	while (str < end) *buf++ = *str++; | ||||
| 	*buf = QSE_T('\0'); | ||||
| 	return len; | ||||
| 	*/ | ||||
|  | ||||
| 	if (len > 0) | ||||
| 	{ | ||||
| 		qse_size_t n = (len-1) >> 3; /* (len-1) / 8 */ | ||||
|  | ||||
| 		switch (len & 7) /* len % 8 */ | ||||
| 		{ | ||||
| 		repeat: | ||||
| 			case 0: *buf++ = *str++; | ||||
| 			case 7: *buf++ = *str++; | ||||
| 			case 6: *buf++ = *str++; | ||||
| 			case 5: *buf++ = *str++; | ||||
| 			case 4: *buf++ = *str++; | ||||
| 			case 3: *buf++ = *str++; | ||||
| 			case 2: *buf++ = *str++; | ||||
| 			case 1: *buf++ = *str++; | ||||
| 			        if (n <= 0) break; | ||||
| 			        n--; | ||||
| 			        goto repeat; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	*buf = QSE_T('\0'); | ||||
| 	return len; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_strxncpy ( | ||||
| 	qse_char_t* buf, qse_size_t bsz, const qse_char_t* str, qse_size_t len) | ||||
| { | ||||
| 	qse_size_t n; | ||||
|  | ||||
| 	if (bsz <= 0) return 0; | ||||
| 	if ((n = bsz - 1) > len) n = len; | ||||
| 	QSE_MEMCPY (buf, str, n * QSE_SIZEOF(qse_char_t)); | ||||
| 	buf[n] = QSE_T('\0'); | ||||
|  | ||||
| 	return n; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_strxput ( | ||||
| 	qse_char_t* buf, qse_size_t bsz, const qse_char_t* str) | ||||
| { | ||||
|  | ||||
							
								
								
									
										174
									
								
								qse/lib/cmn/str_cpy.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										174
									
								
								qse/lib/cmn/str_cpy.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,174 @@ | ||||
| /* | ||||
|  * $Id: str_cnv.c 402 2011-03-18 15:07:21Z hyunghwan.chung $ | ||||
|  * | ||||
|     Copyright 2006-2009 Chung, Hyung-Hwan. | ||||
|     This file is part of QSE. | ||||
|  | ||||
|     QSE is free software: you can redistribute it and/or modify | ||||
|     it under the terms of the GNU Lesser General Public License as | ||||
|     published by the Free Software Foundation, either version 3 of | ||||
|     the License, or (at your option) any later version. | ||||
|  | ||||
|     QSE is distributed in the hope that it will be useful, | ||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|     GNU Lesser General Public License for more details. | ||||
|  | ||||
|     You should have received a copy of the GNU Lesser General Public | ||||
|     License along with QSE. If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #include <qse/cmn/str.h> | ||||
| #include "mem.h" | ||||
|  | ||||
| qse_size_t qse_mbscpy (qse_mchar_t* buf, const qse_mchar_t* str) | ||||
| { | ||||
| 	qse_mchar_t* org = buf; | ||||
| 	while ((*buf++ = *str++) != QSE_MT('\0')); | ||||
| 	return buf - org - 1; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_wcscpy (qse_wchar_t* buf, const qse_wchar_t* str) | ||||
| { | ||||
| 	qse_wchar_t* org = buf; | ||||
| 	while ((*buf++ = *str++) != QSE_WT('\0')); | ||||
| 	return buf - org - 1; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_mcsxcpy ( | ||||
| 	qse_mchar_t* buf, qse_size_t bsz, const qse_mchar_t* str) | ||||
| { | ||||
| 	qse_mchar_t* p, * p2; | ||||
|  | ||||
| 	p = buf; p2 = buf + bsz - 1; | ||||
|  | ||||
| 	while (p < p2)  | ||||
| 	{ | ||||
| 		if (*str == QSE_MT('\0')) break; | ||||
| 		*p++ = *str++; | ||||
| 	} | ||||
|  | ||||
| 	if (bsz > 0) *p = QSE_MT('\0'); | ||||
| 	return p - buf; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_wcsxcpy ( | ||||
| 	qse_wchar_t* buf, qse_size_t bsz, const qse_wchar_t* str) | ||||
| { | ||||
| 	qse_wchar_t* p, * p2; | ||||
|  | ||||
| 	p = buf; p2 = buf + bsz - 1; | ||||
|  | ||||
| 	while (p < p2)  | ||||
| 	{ | ||||
| 		if (*str == QSE_WT('\0')) break; | ||||
| 		*p++ = *str++; | ||||
| 	} | ||||
|  | ||||
| 	if (bsz > 0) *p = QSE_WT('\0'); | ||||
| 	return p - buf; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_mcsncpy ( | ||||
| 	qse_mchar_t* buf, const qse_mchar_t* str, qse_size_t len) | ||||
| { | ||||
| 	/* | ||||
| 	const qse_mchar_t* end = str + len; | ||||
| 	while (str < end) *buf++ = *str++; | ||||
| 	*buf = QSE_MT('\0'); | ||||
| 	return len; | ||||
| 	*/ | ||||
|  | ||||
| 	if (len > 0) | ||||
| 	{ | ||||
| 		qse_size_t n = (len-1) >> 3; /* (len-1) / 8 */ | ||||
|  | ||||
| 		switch (len & 7) /* len % 8 */ | ||||
| 		{ | ||||
| 		repeat: | ||||
| 			case 0: *buf++ = *str++; | ||||
| 			case 7: *buf++ = *str++; | ||||
| 			case 6: *buf++ = *str++; | ||||
| 			case 5: *buf++ = *str++; | ||||
| 			case 4: *buf++ = *str++; | ||||
| 			case 3: *buf++ = *str++; | ||||
| 			case 2: *buf++ = *str++; | ||||
| 			case 1: *buf++ = *str++; | ||||
| 			        if (n <= 0) break; | ||||
| 			        n--; | ||||
| 			        goto repeat; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	*buf = QSE_MT('\0'); | ||||
| 	return len; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_wcsncpy ( | ||||
| 	qse_wchar_t* buf, const qse_wchar_t* str, qse_size_t len) | ||||
| { | ||||
| 	/* | ||||
| 	const qse_wchar_t* end = str + len; | ||||
| 	while (str < end) *buf++ = *str++; | ||||
| 	*buf = QSE_WT('\0'); | ||||
| 	return len; | ||||
| 	*/ | ||||
|  | ||||
| 	if (len > 0) | ||||
| 	{ | ||||
| 		qse_size_t n = (len-1) >> 3; /* (len-1) / 8 */ | ||||
|  | ||||
| 		switch (len & 7) /* len % 8 */ | ||||
| 		{ | ||||
| 		repeat: | ||||
| 			case 0: *buf++ = *str++; | ||||
| 			case 7: *buf++ = *str++; | ||||
| 			case 6: *buf++ = *str++; | ||||
| 			case 5: *buf++ = *str++; | ||||
| 			case 4: *buf++ = *str++; | ||||
| 			case 3: *buf++ = *str++; | ||||
| 			case 2: *buf++ = *str++; | ||||
| 			case 1: *buf++ = *str++; | ||||
| 			        if (n <= 0) break; | ||||
| 			        n--; | ||||
| 			        goto repeat; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	*buf = QSE_WT('\0'); | ||||
| 	return len; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_mcsxncpy ( | ||||
| 	qse_mchar_t* buf, qse_size_t bsz,  | ||||
| 	const qse_mchar_t* str, qse_size_t len) | ||||
| { | ||||
| 	qse_size_t n; | ||||
|  | ||||
| 	if (bsz <= 0) return 0; | ||||
| 	if ((n = bsz - 1) > len) n = len; | ||||
| 	QSE_MEMCPY (buf, str, n * QSE_SIZEOF(qse_mchar_t)); | ||||
| 	buf[n] = QSE_MT('\0'); | ||||
|  | ||||
| 	return n; | ||||
| } | ||||
|  | ||||
| qse_size_t qse_wcsxncpy ( | ||||
| 	qse_wchar_t* buf, qse_size_t bsz,  | ||||
| 	const qse_wchar_t* str, qse_size_t len) | ||||
| { | ||||
| 	qse_size_t n; | ||||
|  | ||||
| 	if (bsz <= 0) return 0; | ||||
| 	if ((n = bsz - 1) > len) n = len; | ||||
| 	QSE_MEMCPY (buf, str, n * QSE_SIZEOF(qse_wchar_t)); | ||||
| 	buf[n] = QSE_WT('\0'); | ||||
|  | ||||
| 	return n; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -19,7 +19,6 @@ | ||||
|  */ | ||||
|  | ||||
| #include <qse/cmn/str.h> | ||||
| #include <qse/cmn/chr.h> | ||||
|  | ||||
| qse_mchar_t* qse_mbspbrk (const qse_mchar_t* str1, const qse_mchar_t* str2) | ||||
| { | ||||
|  | ||||
| @ -19,7 +19,6 @@ | ||||
|  */ | ||||
|  | ||||
| #include <qse/cmn/str.h> | ||||
| #include <qse/cmn/chr.h> | ||||
|  | ||||
| qse_size_t qse_mbsspn (const qse_mchar_t* str1, const qse_mchar_t* str2) | ||||
| { | ||||
|  | ||||
| @ -21,7 +21,7 @@ | ||||
| #include "scm.h" | ||||
|  | ||||
| static int eval_entity (qse_scm_t* scm); | ||||
|  | ||||
|  | ||||
| #if 0 | ||||
| static int save (qse_scm_t* scm, qse_scm_ent_t* ) | ||||
| { | ||||
| @ -29,8 +29,8 @@ static int save (qse_scm_t* scm, qse_scm_ent_t* ) | ||||
|  | ||||
| static int leave (qse_scm_t* scm) | ||||
| { | ||||
| } | ||||
| #endif | ||||
| } | ||||
| #endif | ||||
|  | ||||
| int qse_scm_dolambda (qse_scm_t* scm) | ||||
| { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user