PostgreSQL Source Code  git master
quotes.c File Reference
#include "c.h"
Include dependency graph for quotes.c:

Go to the source code of this file.

Functions

char * escape_single_quotes_ascii (const char *src)
 

Function Documentation

◆ escape_single_quotes_ascii()

char* escape_single_quotes_ascii ( const char *  src)

Definition at line 33 of file quotes.c.

34 {
35  int len = strlen(src),
36  i,
37  j;
38  char *result = malloc(len * 2 + 1);
39 
40  if (!result)
41  return NULL;
42 
43  for (i = 0, j = 0; i < len; i++)
44  {
45  if (SQL_STR_DOUBLE(src[i], true))
46  result[j++] = src[i];
47  result[j++] = src[i];
48  }
49  result[j] = '\0';
50  return result;
51 }
#define SQL_STR_DOUBLE(ch, escape_backslash)
Definition: c.h:1166
#define malloc(a)
Definition: header.h:50
int j
Definition: isn.c:74
int i
Definition: isn.c:73
const void size_t len

References i, j, len, malloc, and SQL_STR_DOUBLE.

Referenced by escape_quotes(), and write_auto_conf_file().