Skip to Content.
Sympa Menu

freetds - [freetds] fieldterm and rowterm for freebcp

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Craig A. Berry" <craigberry AT mac.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] fieldterm and rowterm for freebcp
  • Date: Tue, 11 Feb 2003 19:44:40 -0600

freebcp was going to a lot of trouble to collect the -t and -r options, but
it nevertheless had \t and \n hard-wired as the column and row terminators,
respectively. The patch below makes it send what it got to bcp_colfmt() and
also protects against the case where an option was specified but not given a
value.

--- src/apps/freebcp.c;-0 Tue Feb 4 07:28:28 2003
+++ src/apps/freebcp.c Tue Feb 11 19:23:49 2003
@@ -379,11 +379,11 @@
if (pdata->cflag) {
/* Fill in some default values */

- if (!pdata->tflag) { /* field terminator not specified */
+ if (!pdata->tflag || !pdata->fieldterm) { /* field
terminator not specified */
pdata->fieldterm = (char *) malloc(2);
strcpy(pdata->fieldterm, "\t");
}
- if (!pdata->rflag) { /* row terminator not specified */
+ if (!pdata->rflag || !pdata->rowterm) { /* row
terminator not specified */
pdata->rowterm = (char *) malloc(2);
strcpy(pdata->rowterm, "\n");
}
@@ -480,13 +480,15 @@
}

for (i = 1; i <= li_numcols - 1; i++) {
- if (bcp_colfmt(dbproc, i, SYBCHAR, 0, -1, (const BYTE
*) "\t", sizeof(char), i) == FAIL) {
+ if (bcp_colfmt(dbproc, i, SYBCHAR, 0, -1, (const BYTE
*) pdata->fieldterm,
+ strlen(pdata->fieldterm), i) == FAIL)
{
printf("Error in bcp_colfmt col %d\n", i);
return FALSE;
}
}

- if (bcp_colfmt(dbproc, li_numcols, SYBCHAR, 0, -1, (const
BYTE *) "\n", sizeof(char), li_numcols) == FAIL) {
+ if (bcp_colfmt(dbproc, li_numcols, SYBCHAR, 0, -1, (const
BYTE *) pdata->rowterm,
+ strlen(pdata->rowterm), li_numcols) == FAIL) {
printf("Error in bcp_colfmt col %d\n", li_numcols);
return FALSE;
}
[end of patch]





Archive powered by MHonArc 2.6.24.

Top of Page