Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

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, and SQL_STR_DOUBLE.

Referenced by escape_quotes().

{
    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;
}