0 Star 0 Fork 18

wangjie/IvorySQL

forked from IvorySQL/IvorySQL 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
quotes.c 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
Bruce Momjian 提交于 2024-01-04 09:49 +08:00 . Update copyright for 2024
/*-------------------------------------------------------------------------
*
* quotes.c
* string quoting and escaping functions
*
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* src/port/quotes.c
*
*-------------------------------------------------------------------------
*/
#include "c.h"
/*
* Escape (by doubling) any single quotes or backslashes in given string
*
* Note: this is used to process postgresql.conf entries and to quote
* string literals in pg_basebackup for writing the recovery configuration.
* Since postgresql.conf strings are defined to treat backslashes as escapes,
* we have to double backslashes here.
*
* Since this function is only used for parsing or creating configuration
* files, we do not care about encoding considerations.
*
* Returns a malloced() string that it's the responsibility of the caller
* to free.
*/
char *
escape_single_quotes_ascii(const char *src)
{
int len = strlen(src),
i,
j;
char *result = malloc(len * 2 + 1);
if (!result)
return NULL;
for (i = 0, j = 0; i < len; i++)
{
if (SQL_STR_DOUBLE(src[i], true))
result[j++] = src[i];
result[j++] = src[i];
}
result[j] = '\0';
return result;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/Jugier/IvorySQL.git
git@gitee.com:Jugier/IvorySQL.git
Jugier
IvorySQL
IvorySQL
master

搜索帮助