projects
/
m17n
/
m17n-lib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(run_stages): Fix previous change.
[m17n/m17n-lib.git]
/
src
/
mtext.c
diff --git
a/src/mtext.c
b/src/mtext.c
index
ce87b1a
..
0499ac0
100644
(file)
--- a/
src/mtext.c
+++ b/
src/mtext.c
@@
-17,7
+17,7
@@
You should have received a copy of the GNU Lesser General Public
License along with the m17n library; if not, write to the Free
You should have received a copy of the GNU Lesser General Public
License along with the m17n library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
02111-1307, USA. */
/***en
02111-1307, USA. */
/***en
@@
-971,6
+971,7
@@
mtext__init ()
M17N_OBJECT_ADD_ARRAY (mtext_table, "M-text");
M_charbag = msymbol_as_managing_key (" charbag");
mtext_table.count = 0;
M17N_OBJECT_ADD_ARRAY (mtext_table, "M-text");
M_charbag = msymbol_as_managing_key (" charbag");
mtext_table.count = 0;
+ Mlanguage = msymbol ("language");
return 0;
}
return 0;
}
@@
-1532,7
+1533,7
@@
mtext__uppercase (MText *mt, int pos, int end)
else
{
else
{
- if (pl = (MPlist *) mchartable_lookup (case_mapping, c))
+ if ((pl = (MPlist *) mchartable_lookup (case_mapping, c)) != NULL)
{
MText *upper;
int ulen;
{
MText *upper;
int ulen;
@@
-1585,6
+1586,12
@@
const int MTEXT_FORMAT_UTF_32 = MTEXT_FORMAT_UTF_32LE;
/*** @{ */
/*=*/
/*** @{ */
/*=*/
+/***en The symbol whose name is "language". */
+/***ja "language" ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë. */
+MSymbol Mlanguage;
+
+/*=*/
+
/***en
@brief Allocate a new M-text.
/***en
@brief Allocate a new M-text.
@@
-1664,7
+1671,7
@@
mtext ()
short ñ°Ì¤Ç¤¢¤ë¡£
$FORMAT ¤¬ #MTEXT_FORMAT_UTF_32LE ¤« #MTEXT_FORMAT_UTF_32BE ¤Ê¤é¤Ð¡¢
short ñ°Ì¤Ç¤¢¤ë¡£
$FORMAT ¤¬ #MTEXT_FORMAT_UTF_32LE ¤« #MTEXT_FORMAT_UTF_32BE ¤Ê¤é¤Ð¡¢
- $DATA ¤ÎÆâÍƤÏ@c unsigned ·¿¤Ç¤¢¤ê¡¢$NITEMS ¤Ï unsigned ñ°Ì¤Ç¤¢¤ë¡£
+ $DATA ¤ÎÆâÍÆ¤Ï @c unsigned ·¿¤Ç¤¢¤ê¡¢$NITEMS ¤Ï unsigned ñ°Ì¤Ç¤¢¤ë¡£
³ä¤êÅö¤Æ¤é¤ì¤¿ M-text ¤Îʸ»úÎó¤ÏÊѹ¹¤Ç¤¤Ê¤¤¡£$DATA ¤ÎÆâÍƤÏ
M-text ¤¬Í¸ú¤Ê´Ö¤ÏÊѹ¹¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
³ä¤êÅö¤Æ¤é¤ì¤¿ M-text ¤Îʸ»úÎó¤ÏÊѹ¹¤Ç¤¤Ê¤¤¡£$DATA ¤ÎÆâÍƤÏ
M-text ¤¬Í¸ú¤Ê´Ö¤ÏÊѹ¹¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
@@
-2016,7
+2023,7
@@
mtext_cat_char (MText *mt, int c)
nunits = CHAR_UNITS (c, mt->format);
if ((mt->nbytes + nunits + 1) * unit_bytes > mt->allocated)
{
nunits = CHAR_UNITS (c, mt->format);
if ((mt->nbytes + nunits + 1) * unit_bytes > mt->allocated)
{
- mt->allocated = (mt->nbytes + nunits + 1) * unit_bytes;
+ mt->allocated = (mt->nbytes + nunits * 16 + 1) * unit_bytes;
MTABLE_REALLOC (mt->data, mt->allocated, MERROR_MTEXT);
}
MTABLE_REALLOC (mt->data, mt->allocated, MERROR_MTEXT);
}
@@
-2263,7
+2270,8
@@
mtext_ncpy (MText *mt1, MText *mt2, int n)
(exclusive) while inheriting all the text properties of $MT. $MT
itself is not modified.
(exclusive) while inheriting all the text properties of $MT. $MT
itself is not modified.
- @return If the operation was successful, mtext_duplicate ()
+ @return
+ If the operation was successful, mtext_duplicate ()
returns a pointer to the created M-text. If an error is detected,
it returns NULL and assigns an error code to the external variable
#merror_code. */
returns a pointer to the created M-text. If an error is detected,
it returns NULL and assigns an error code to the external variable
#merror_code. */
@@
-2368,9
+2376,9
@@
mtext_copy (MText *mt1, int pos, MText *mt2, int from, int to)
/***ja
@brief »ØÄêÈϰϤÎʸ»ú¤òÇ˲õŪ¤Ë¼è¤ê½ü¤¯.
/***ja
@brief »ØÄêÈϰϤÎʸ»ú¤òÇ˲õŪ¤Ë¼è¤ê½ü¤¯.
- ´Ø¿ô mtext_del () ¤Ï¡¢M-text $MT ¤Î $FROM ¡Ê$FROM ¼«ÂΤâ´Þ¤à¡Ë¤«¤é $TO
- ¡Ê$TO ¼«ÂΤϴޤޤʤ¤¡Ë¤Þ¤Ç¤Îʸ»ú¤òÇ˲õŪ¤Ë¼è¤ê½ü¤¯¡£·ë²ÌŪ¤Ë $MT ¤ÏŤµ¤¬ ($TO @c
- - $FROM) ¤À¤±½Ì¤à¤³¤È¤Ë¤Ê¤ë¡£
+ ´Ø¿ô mtext_del () ¤Ï¡¢M-text $MT ¤Î $FROM ¡Ê$FROM ¼«ÂΤâ´Þ¤à¡Ë¤«¤é
+ $TO ¡Ê$TO ¼«ÂΤϴޤޤʤ¤¡Ë¤Þ¤Ç¤Îʸ»ú¤òÇ˲õŪ¤Ë¼è¤ê½ü¤¯¡£·ë²ÌŪ¤Ë
+ $MT ¤ÏŤµ¤¬ ($TO @c - $FROM) ¤À¤±½Ì¤à¤³¤È¤Ë¤Ê¤ë¡£
@return
½èÍý¤¬À®¸ù¤¹¤ì¤Ð mtext_del () ¤Ï 0 ¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð -1
@return
½èÍý¤¬À®¸ù¤¹¤ì¤Ð mtext_del () ¤Ï 0 ¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð -1
@@
-2474,7
+2482,8
@@
mtext_ins (MText *mt1, int pos, MText *mt2)
On insertion, all the text properties of the sub-text of $MT2 are
inherited.
On insertion, all the text properties of the sub-text of $MT2 are
inherited.
- @return If the operation was successful, mtext_insert () returns
+ @return
+ If the operation was successful, mtext_insert () returns
0. Otherwise, it returns -1 and assigns an error code to the
external variable #merror_code. */
0. Otherwise, it returns -1 and assigns an error code to the
external variable #merror_code. */
@@
-2622,11
+2631,12
@@
mtext_ins_char (MText *mt, int pos, int c, int n)
@brief Replace sub-text of M-text with another.
The mtext_replace () function replaces sub-text of M-text $MT1
@brief Replace sub-text of M-text with another.
The mtext_replace () function replaces sub-text of M-text $MT1
- between $FROM1 (inclusive) and $TO1 (exclusinve) with the sub-text
- of M-text $MT2 between $FROM2 (inclusive) and $TO2 (exclusinve).
+ between $FROM1 (inclusive) and $TO1 (exclusive) with the sub-text
+ of M-text $MT2 between $FROM2 (inclusive) and $TO2 (exclusive).
The new sub-text inherits text properties of the old sub-text.
The new sub-text inherits text properties of the old sub-text.
- @return If the operation was successful, mtext_replace () returns
+ @return
+ If the operation was successful, mtext_replace () returns
0. Otherwise, it returns -1 and assigns an error code to the
external variable #merror_code. */
0. Otherwise, it returns -1 and assigns an error code to the
external variable #merror_code. */
@@
-2639,7
+2649,8
@@
mtext_ins_char (MText *mt, int pos, int c, int n)
¤´¹¤¨¤ë¡£¿·¤·¤¯ÁÞÆþ¤µ¤ì¤¿Éôʬ¤Ï¡¢ÃÖ¤´¹¤¨¤ëÁ°¤Î¥Æ¥¥¹¥È¥×¥í¥Ñ¥Æ¥£
¤¹¤Ù¤Æ¤ò·Ñ¾µ¤¹¤ë¡£
¤´¹¤¨¤ë¡£¿·¤·¤¯ÁÞÆþ¤µ¤ì¤¿Éôʬ¤Ï¡¢ÃÖ¤´¹¤¨¤ëÁ°¤Î¥Æ¥¥¹¥È¥×¥í¥Ñ¥Æ¥£
¤¹¤Ù¤Æ¤ò·Ñ¾µ¤¹¤ë¡£
- @return ½èÍý¤¬À®¸ù¤¹¤ì¤Ð¡¢ mtext_replace () ¤Ï 0 ¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê
+ @return
+ ½èÍý¤¬À®¸ù¤¹¤ì¤Ð¡¢ mtext_replace () ¤Ï 0 ¤òÊÖ¤¹¡£¤½¤¦¤Ç¤Ê
¤±¤ì¤Ð -1 ¤òÊÖ¤·¡¢³°ÉôÊÑ¿ô #merror_code ¤Ë¥¨¥é¡¼¥³¡¼¥É¤òÀßÄꤹ¤ë¡£ */
/***
¤±¤ì¤Ð -1 ¤òÊÖ¤·¡¢³°ÉôÊÑ¿ô #merror_code ¤Ë¥¨¥é¡¼¥³¡¼¥É¤òÀßÄꤹ¤ë¡£ */
/***
@@
-3434,7
+3445,8
@@
mtext_case_compare (MText *mt1, int from1, int to1,
*/
/***
*/
/***
- @seealso mtext_titlecase (), mtext_uppercase ()
+ @seealso
+ mtext_titlecase (), mtext_uppercase ()
*/
int
*/
int
@@
-3454,7
+3466,7
@@
mtext_lowercase (MText *mt)
The mtext_titlecase () function destructively converts the first
character with the cased property in M-text $MT to titlecase and
the others to lowercase. The length of $MT may change. If the
The mtext_titlecase () function destructively converts the first
character with the cased property in M-text $MT to titlecase and
the others to lowercase. The length of $MT may change. If the
- character cannot be converted to titlercase, it is left unchanged.
+ character cannot be converted to titlecase, it is left unchanged.
All the text properties are inherited.
@return
All the text properties are inherited.
@return
@@
-3475,7
+3487,8
@@
mtext_lowercase (MText *mt)
*/
/***
*/
/***
- @seealso mtext_lowercase (), mtext_uppercase ()
+ @seealso
+ mtext_lowercase (), mtext_uppercase ()
*/
int
*/
int
@@
-3502,8
+3515,9
@@
mtext_titlecase (MText *mt)
/* Go through following combining characters. */
for (to = from + 1;
/* Go through following combining characters. */
for (to = from + 1;
- to < len &&
- mchartable_lookup (combining_class, mtext_ref_char (mt, to)) > 0;
+ (to < len
+ && ((int) mchartable_lookup (combining_class, mtext_ref_char (mt, to))
+ > 0));
to++);
/* Titlecase the region and prepare for next lowercase operation.
to++);
/* Titlecase the region and prepare for next lowercase operation.
@@
-3544,7
+3558,8
@@
mtext_titlecase (MText *mt)
*/
/***
*/
/***
- @seealso mtext_lowercase (), mtext_titlecase ()
+ @seealso
+ mtext_lowercase (), mtext_titlecase ()
*/
int
*/
int
@@
-3588,32
+3603,39
@@
mtext_uppercase (MText *mt)
MText *
mdebug_dump_mtext (MText *mt, int indent, int fullp)
{
MText *
mdebug_dump_mtext (MText *mt, int indent, int fullp)
{
- char *prefix = (char *) alloca (indent + 1);
int i;
int i;
- unsigned char *p;
- memset (prefix, 32, indent);
- prefix[indent] = 0;
-
- fprintf (stderr,
- "(mtext (size %d %d %d) (cache %d %d)",
- mt->nchars, mt->nbytes, mt->allocated,
- mt->cache_char_pos, mt->cache_byte_pos);
if (! fullp)
{
if (! fullp)
{
- fprintf (stderr, " \"");
+ fprintf (stderr, "\"");
for (i = 0; i < mt->nchars; i++)
{
int c = mtext_ref_char (mt, i);
for (i = 0; i < mt->nchars; i++)
{
int c = mtext_ref_char (mt, i);
- if (c >= ' ' && c < 127)
+
+ if (c == '"' || c == '\\')
+ fprintf (stderr, "\\%c", c);
+ else if ((c >= ' ' && c < 127) || c == '\n')
fprintf (stderr, "%c", c);
else
fprintf (stderr, "\\x%02X", c);
}
fprintf (stderr, "\"");
fprintf (stderr, "%c", c);
else
fprintf (stderr, "\\x%02X", c);
}
fprintf (stderr, "\"");
+ return mt;
}
}
- else if (mt->nchars > 0)
+
+ fprintf (stderr,
+ "(mtext (size %d %d %d) (cache %d %d)",
+ mt->nchars, mt->nbytes, mt->allocated,
+ mt->cache_char_pos, mt->cache_byte_pos);
+
+ if (mt->nchars > 0)
{
{
+ char *prefix = (char *) alloca (indent + 1);
+ unsigned char *p;
+
+ memset (prefix, 32, indent);
+ prefix[indent] = 0;
+
fprintf (stderr, "\n%s (bytes \"", prefix);
for (i = 0; i < mt->nbytes; i++)
fprintf (stderr, "\\x%02x", mt->data[i]);
fprintf (stderr, "\n%s (bytes \"", prefix);
for (i = 0; i < mt->nbytes; i++)
fprintf (stderr, "\\x%02x", mt->data[i]);
@@
-3625,7
+3647,9
@@
mdebug_dump_mtext (MText *mt, int indent, int fullp)
int len;
int c = STRING_CHAR_AND_BYTES (p, len);
int len;
int c = STRING_CHAR_AND_BYTES (p, len);
- if (c >= ' ' && c < 127 && c != '\\' && c != '\"')
+ if (c == '"' || c == '\\')
+ fprintf (stderr, "\\%c", c);
+ else if (c >= ' ' && c < 127)
fputc (c, stderr);
else
fprintf (stderr, "\\x%X", c);
fputc (c, stderr);
else
fprintf (stderr, "\\x%X", c);