Lua中文语言编程源码-第七节,更改lstrlib.c 标准字符串操作与模式匹配库函数, 使Lua加载中文库关键词(标准字符串操作与模式匹配库相关)

源码已经更新在优快云的码库里:

git clone https://gitcode.com/funsion/CLua.git

在src文件夹下的lstrlib.c 标准字符串操作与模式匹配库函数,表明这个C源文件实现了Lua的标准字符串操作与模式匹配库,即提供了与字符串操作相关的API和功能实现。


增加中文版stringmetamethods 元方法列表,保留英文版stringmetamethods元方法列表。


原始的代码为:
static const luaL_Reg stringmetamethods[] = {
  {"__add", arith_add},
  {"__sub", arith_sub},
  {"__mul", arith_mul},
  {"__mod", arith_mod},
  {"__pow", arith_pow},
  {"__div", arith_div},
  {"__idiv", arith_idiv},
  {"__unm", arith_unm},
  {"__index", NULL},  /* placeholder */
  {NULL, NULL}
};
 更改成以下代码:
static const luaL_Reg stringmetamethods[] = {
  {"__add", arith_add}, {"__加",arith_add},
  {"__sub", arith_sub}, {"__减",arith_sub},
  {"__mul", arith_mul}, {"__乘",arith_mul},
  {"__mod", arith_mod}, {"__模",arith_mod},
  {"__pow", arith_pow}, {"__幂",arith_pow},
  {"__div", arith_div}, {"__除",arith_div},
  {"__idiv", arith_idiv}, {"__整除",arith_idiv},
  {"__unm", arith_unm}, {"__负",arith_unm},
  {"__index", NULL},  {"__索引",NULL},
  {NULL, NULL}
};
原始的代码为:

static const luaL_Reg strlib[] = {
  {"byte", str_byte},
  {"char", str_char},
  {"dump", str_dump},
  {"find", str_find},
  {"format", str_format},
  {"gmatch", gmatch},
  {"gsub", str_gsub},
  {"len", str_len},
  {"lower", str_lower},
  {"match", st
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值