Escape input string suitable for INSERT.
If no characters require escaping, simply return the input pointer. Otherwise return a new allocated string.
Definition at line 176 of file shp2pgsql-core.c.
177{
178
179
180
181
182
183
184
186 char *ptr, *optr;
187 int toescape = 0;
188 size_t size;
189
191
192
193 while (*ptr)
194 {
195 if (*ptr == '\'')
196 toescape++;
197
198 ptr++;
199 }
200
201
202 if (toescape == 0)
204
205 size = ptr -
str + toescape + 1;
209
210 while (*ptr)
211 {
212 if (*ptr == '\'')
213 *optr++='\'';
214
215 *optr++ = *ptr++;
216 }
217
218 *optr='\0';
219
221}
char result[OUT_DOUBLE_BUFFER_SIZE]
References result, and str.
Referenced by ShpLoaderGenerateSQLRowStatement().