0 Star 0 Fork 18

wangjie/IvorySQL

forked from IvorySQL/IvorySQL 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
identifier_alpha_transfor.c 1.98 KB
一键复制 编辑 原始数据 按行查看 历史
拂晓神剑 提交于 2025-06-05 16:13 +08:00 . IvorySQL:Update copyright
/*-------------------------------------------------------------------------
*
* identifier_alpha_transfor.c
*
* This file provides a string case conversion function
*
* upper_character() -- transfor lower to upper
* down_character() -- transfor upper to lower
* is_all_upper() -- Determine whether the letters in the string are all uppercase letters
* is_all_lower() -- Determine whether the letters in the string are all lowercase letters
*
*
* Portions Copyright (c) 2023-2025, IvorySQL Global Development Team
*
* src/port/identifier_alpha_transfor.c
*
* add the file for requirement "CASE SENSITIVE IDENTIFY" feature upgrade
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "c.h"
#include "common/fe_memutils.h"
/*
* transfor upper to lower
*/
char *
down_character(const char *src, int len)
{
char *res;
char *s ;
int i;
Assert(src != NULL);
Assert(len >= 0);
res = (char*)palloc(len + 1);
memcpy(res, src, len);
res[len] = '\0';
s = res;
/* transfor */
for (i = 0; i < len ; i++)
{
*s = tolower(*s);
s++;
}
return res;
}
/*
* transfor lower to upper
*/
char *
upper_character(const char *src, int len)
{
char *res;
char *s ;
int i;
Assert(src != NULL);
Assert(len >= 0);
res = (char*)palloc(len + 1);
memcpy(res, src, len);
res[len] = '\0';
s = res;
/* transfor */
for (i = 0; i < len ; i++)
{
*s = toupper(*s);
s++;
}
return res;
}
/*
* Determine whether the letters in the string are all lowercase letters
*/
bool
is_all_lower(const char *src, int len)
{
int i;
const char *s;
s = src;
for (i = 0; i < len; i++)
{
if (isalpha(*s) && isupper(*s))
return false;
s++;
}
return true;
}
/*
* Determine whether the letters in the string are all uppercase letters
*/
bool
is_all_upper(const char *src, int len)
{
int i;
const char *s;
s = src;
for (i = 0; i < len; i++)
{
if (isalpha(*s) && islower(*s))
return false;
s++;
}
return true;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/Jugier/IvorySQL.git
git@gitee.com:Jugier/IvorySQL.git
Jugier
IvorySQL
IvorySQL
master

搜索帮助