6
6
*
7
7
*
8
8
* IDENTIFICATION
9
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.97 2000/01/19 23:54:56 tgl Exp $
9
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.98 2000/01/22 03:52:04 tgl Exp $
10
10
*
11
11
*-------------------------------------------------------------------------
12
12
*/
@@ -137,7 +137,8 @@ CopySendChar(char c, FILE *fp)
137
137
* backend->frontend functions
138
138
*
139
139
* CopyGetChar does the same for single characters
140
- * CopyGetEof checks if it's EOF on the input
140
+ * CopyGetEof checks if it's EOF on the input (or, check for EOF result
141
+ * from CopyGetChar)
141
142
*
142
143
* NB: no data conversion is applied by these functions
143
144
*/
@@ -1106,18 +1107,6 @@ GetIndexRelations(Oid main_relation_oid,
1106
1107
}
1107
1108
}
1108
1109
1109
-
1110
- /*
1111
- returns 1 if c is in s
1112
- */
1113
- static bool
1114
- inString (char c , char * s )
1115
- {
1116
- if (s && c )
1117
- return strchr (s , c ) != NULL ;
1118
- return 0 ;
1119
- }
1120
-
1121
1110
/*
1122
1111
* Reads input from fp until an end of line is seen.
1123
1112
*/
@@ -1171,19 +1160,24 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
1171
1160
1172
1161
* isnull = (bool ) false; /* set default */
1173
1162
1174
- if (CopyGetEof (fp ))
1175
- goto endOfFile ;
1176
-
1177
1163
for (;;)
1178
1164
{
1179
1165
c = CopyGetChar (fp );
1180
- if (CopyGetEof ( fp ) )
1166
+ if (c == EOF )
1181
1167
goto endOfFile ;
1182
-
1168
+ if (c == '\n' )
1169
+ {
1170
+ * newline = 1 ;
1171
+ break ;
1172
+ }
1173
+ if (strchr (delim , c ))
1174
+ {
1175
+ break ;
1176
+ }
1183
1177
if (c == '\\' )
1184
1178
{
1185
1179
c = CopyGetChar (fp );
1186
- if (CopyGetEof ( fp ) )
1180
+ if (c == EOF )
1187
1181
goto endOfFile ;
1188
1182
switch (c )
1189
1183
{
@@ -1213,14 +1207,14 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
1213
1207
}
1214
1208
else
1215
1209
{
1216
- if (CopyGetEof ( fp ) )
1210
+ if (c == EOF )
1217
1211
goto endOfFile ;
1218
1212
CopyDonePeek (fp , c , 0 ); /* Return to stream! */
1219
1213
}
1220
1214
}
1221
1215
else
1222
1216
{
1223
- if (CopyGetEof ( fp ) )
1217
+ if (c == EOF )
1224
1218
goto endOfFile ;
1225
1219
CopyDonePeek (fp , c , 0 ); /* Return to stream! */
1226
1220
}
@@ -1231,7 +1225,7 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
1231
1225
rather then just 'N' to provide compatibility with
1232
1226
the default NULL output. -- pe */
1233
1227
case 'N' :
1234
- appendStringInfoChar (& attribute_buf , '\\' );
1228
+ appendStringInfoCharMacro (& attribute_buf , '\\' );
1235
1229
c = 'N' ;
1236
1230
break ;
1237
1231
case 'b' :
@@ -1257,26 +1251,19 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
1257
1251
if (c != '\n' )
1258
1252
elog (ERROR , "CopyReadAttribute - end of record marker corrupted. line: %d" , lineno );
1259
1253
goto endOfFile ;
1260
- break ;
1261
1254
}
1262
1255
}
1263
- else if (c == '\n' || inString (c , delim ))
1264
- {
1265
- if (c == '\n' )
1266
- * newline = 1 ;
1267
- break ;
1268
- }
1269
- appendStringInfoChar (& attribute_buf , c );
1256
+ appendStringInfoCharMacro (& attribute_buf , c );
1270
1257
#ifdef MULTIBYTE
1271
1258
/* get additional bytes of the char, if any */
1272
1259
s [0 ] = c ;
1273
1260
mblen = pg_encoding_mblen (encoding , s );
1274
1261
for (j = 1 ; j < mblen ; j ++ )
1275
1262
{
1276
1263
c = CopyGetChar (fp );
1277
- if (CopyGetEof ( fp ) )
1264
+ if (c == EOF )
1278
1265
goto endOfFile ;
1279
- appendStringInfoChar (& attribute_buf , c );
1266
+ appendStringInfoCharMacro (& attribute_buf , c );
1280
1267
}
1281
1268
#endif
1282
1269
}
0 commit comments