PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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

char* escape_single_quotes_ascii ( const char *  src)

Definition at line 33 of file quotes.c.

References i, malloc, NULL, and SQL_STR_DOUBLE.

Referenced by escape_quotes(), and write_auto_conf_file().

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 malloc(a)
Definition: header.h:45
#define NULL
Definition: c.h:226
int i
#define SQL_STR_DOUBLE(ch, escape_backslash)
Definition: c.h:503