Escape input string suitable for COPY.
If no characters require escaping, simply return the input pointer. Otherwise return a new allocated string.
Definition at line 121 of file shp2pgsql-core.c.
122{
123
124
125
126
127
128
129
130
131
133 char *ptr, *optr;
134 int toescape = 0;
135 size_t size;
136
138
139
140 while (*ptr)
141 {
142 if (*ptr == '\t' || *ptr == '\\' || *ptr == '\n' || *ptr == '\r')
143 toescape++;
144
145 ptr++;
146 }
147
148
149 if (toescape == 0)
151
152 size = ptr -
str + toescape + 1;
156
157 while (*ptr)
158 {
159 if ( *ptr == '\t' || *ptr == '\\' || *ptr == '\n' || *ptr == '\r' )
160 *optr++ = '\\';
161
162 *optr++ = *ptr++;
163 }
164
165 *optr = '\0';
166
168}
char result[OUT_DOUBLE_BUFFER_SIZE]
References result, and str.
Referenced by ShpLoaderGenerateSQLRowStatement().