66 *
77 *
88 * 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 $
1010 *
1111 *-------------------------------------------------------------------------
1212 */
@@ -137,7 +137,8 @@ CopySendChar(char c, FILE *fp)
137137 *backend->frontend functions
138138 *
139139 * 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)
141142 *
142143 * NB: no data conversion is applied by these functions
143144 */
@@ -1106,18 +1107,6 @@ GetIndexRelations(Oid main_relation_oid,
11061107}
11071108}
11081109
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-
11211110/*
11221111 * Reads input from fp until an end of line is seen.
11231112 */
@@ -1171,19 +1160,24 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
11711160
11721161* isnull = (bool ) false;/* set default */
11731162
1174- if (CopyGetEof (fp ))
1175- gotoendOfFile ;
1176-
11771163for (;;)
11781164{
11791165c = CopyGetChar (fp );
1180- if (CopyGetEof ( fp ) )
1166+ if (c == EOF )
11811167gotoendOfFile ;
1182-
1168+ if (c == '\n' )
1169+ {
1170+ * newline = 1 ;
1171+ break ;
1172+ }
1173+ if (strchr (delim ,c ))
1174+ {
1175+ break ;
1176+ }
11831177if (c == '\\' )
11841178{
11851179c = CopyGetChar (fp );
1186- if (CopyGetEof ( fp ) )
1180+ if (c == EOF )
11871181gotoendOfFile ;
11881182switch (c )
11891183{
@@ -1213,14 +1207,14 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
12131207}
12141208else
12151209{
1216- if (CopyGetEof ( fp ) )
1210+ if (c == EOF )
12171211gotoendOfFile ;
12181212CopyDonePeek (fp ,c ,0 );/* Return to stream! */
12191213}
12201214}
12211215else
12221216{
1223- if (CopyGetEof ( fp ) )
1217+ if (c == EOF )
12241218gotoendOfFile ;
12251219CopyDonePeek (fp ,c ,0 );/* Return to stream! */
12261220}
@@ -1231,7 +1225,7 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
12311225 rather then just 'N' to provide compatibility with
12321226 the default NULL output. -- pe */
12331227case 'N' :
1234- appendStringInfoChar (& attribute_buf ,'\\' );
1228+ appendStringInfoCharMacro (& attribute_buf ,'\\' );
12351229c = 'N' ;
12361230break ;
12371231case 'b' :
@@ -1257,26 +1251,19 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline, char *null_
12571251if (c != '\n' )
12581252elog (ERROR ,"CopyReadAttribute - end of record marker corrupted. line: %d" ,lineno );
12591253gotoendOfFile ;
1260- break ;
12611254}
12621255}
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 );
12701257#ifdef MULTIBYTE
12711258/* get additional bytes of the char, if any */
12721259s [0 ]= c ;
12731260mblen = pg_encoding_mblen (encoding ,s );
12741261for (j = 1 ;j < mblen ;j ++ )
12751262{
12761263c = CopyGetChar (fp );
1277- if (CopyGetEof ( fp ) )
1264+ if (c == EOF )
12781265gotoendOfFile ;
1279- appendStringInfoChar (& attribute_buf ,c );
1266+ appendStringInfoCharMacro (& attribute_buf ,c );
12801267}
12811268#endif
12821269}