src/table.c
void
multilines_detection(DataDesc *desc)
{
	LineBufferIter	lbi;
	LineBufferMark	lbm;
	int				recno = 1;

	bool		border0 = (desc->border_type == 0);
	bool		border1 = (desc->border_type == 1);
	bool		border2 = (desc->border_type == 2);

	bool		has_multilines = false;

	if (desc->multilines_already_tested)
		return;

	init_lbi_ddesc(&lbi, desc, 0);

	while (lbi_set_mark_next(&lbi, &lbm))
	{
		char	   *str;
		int			lineno;
		int			pos = 0;
		bool		found_continuation_symbol = false;
		LineInfo   *linfo;

		(void) lbm_get_line(&lbm, &str, &linfo, &lineno);

		if (lineno < desc->first_data_row || lineno > desc->last_data_row)
			continue;

		/*
		 * This routine can be repeated until progressive load
		 * is not finished. But we don't need to repeat searching
		 * multilines detection.
		 */
		if (!linfo ||
			!(linfo->mask & LINEINFO_CONTINUATION ||
			  linfo->mask & LINEINFO_HASNOT_CONTINUATION))
		{
			/*
			 * This implementation doesn't support old-ascii format
			 */
			while (pos < desc->headline_char_size)
			{
				if (border0)
				{
					if (pos + 1 == desc->headline_char_size)
					{
						char	*sym;

						sym = str + charlen(str);
						if (*sym != '\0')
							found_continuation_symbol = is_line_continuation_char(sym, desc);
					}
					else if (desc->headline_transl[pos] == 'I')
						found_continuation_symbol = is_line_continuation_char(str, desc);
				}
				else if (border1)
				{
					if ((pos + 1 < desc->headline_char_size && desc->headline_transl[pos + 1] == 'I') ||
						  (pos + 1 == desc->headline_char_size))
						found_continuation_symbol = is_line_continuation_char(str, desc);
				}
				else if (border2)
				{
					if ((pos + 1 < desc->headline_char_size) &&
						  (desc->headline_transl[pos + 1] == 'I' || desc->headline_transl[pos + 1] == 'R'))
						found_continuation_symbol = is_line_continuation_char(str, desc);
				}

				if (found_continuation_symbol)
				{
					lbm_xor_mask(&lbm, LINEINFO_CONTINUATION);
					has_multilines = true;
					break;
				}

				pos += dsplen(str);
				str += charlen(str);
			}

			if (!found_continuation_symbol)
				lbm_xor_mask(&lbm, LINEINFO_HASNOT_CONTINUATION);
		}
		else
			found_continuation_symbol = linfo->mask & LINEINFO_CONTINUATION;

		lbm_recno_offset(&lbm, lineno - recno);

		if (!found_continuation_symbol)
			recno += 1;
	}

	if (desc->completed)
		desc->multilines_already_tested = true;

	desc->has_multilines = has_multilines;
}
/*
 * Try to detect multiline rows.
 */
Try to detect multiline rows.
Try to detect multiline rows .
void
multilines_detection(DataDesc *desc)
{
	LineBufferIter	lbi;
	LineBufferMark	lbm;
	int				recno = 1;
	bool		border0 = (desc->border_type == 0);
	bool		border1 = (desc->border_type == 1);
	bool		border2 = (desc->border_type == 2);
	bool		has_multilines = false;
	if (desc->multilines_already_tested)
		return;
	init_lbi_ddesc(&lbi, desc, 0);
	while (lbi_set_mark_next(&lbi, &lbm))
	{
		char	   *str;
		int			lineno;
		int			pos = 0;
		bool		found_continuation_symbol = false;
		LineInfo   *linfo;
		(void) lbm_get_line(&lbm, &str, &linfo, &lineno);
		if (lineno < desc->first_data_row || lineno > desc->last_data_row)
			continue;
		if (!linfo ||
			!(linfo->mask & LINEINFO_CONTINUATION ||
			  linfo->mask & LINEINFO_HASNOT_CONTINUATION))
		{
			while (pos < desc->headline_char_size)
			{
				if (border0)
				{
					if (pos + 1 == desc->headline_char_size)
					{
						char	*sym;
						sym = str + charlen(str);
						if (*sym != '\0')
							found_continuation_symbol = is_line_continuation_char(sym, desc);
					}
					else if (desc->headline_transl[pos] == 'I')
						found_continuation_symbol = is_line_continuation_char(str, desc);
				}
				else if (border1)
				{
					if ((pos + 1 < desc->headline_char_size && desc->headline_transl[pos + 1] == 'I') ||
						  (pos + 1 == desc->headline_char_size))
						found_continuation_symbol = is_line_continuation_char(str, desc);
				}
				else if (border2)
				{
					if ((pos + 1 < desc->headline_char_size) &&
						  (desc->headline_transl[pos + 1] == 'I' || desc->headline_transl[pos + 1] == 'R'))
						found_continuation_symbol = is_line_continuation_char(str, desc);
				}
				if (found_continuation_symbol)
				{
					lbm_xor_mask(&lbm, LINEINFO_CONTINUATION);
					has_multilines = true;
					break;
				}
				pos += dsplen(str);
				str += charlen(str);
			}
			if (!found_continuation_symbol)
				lbm_xor_mask(&lbm, LINEINFO_HASNOT_CONTINUATION);
		}
		else
			found_continuation_symbol = linfo->mask & LINEINFO_CONTINUATION;
		lbm_recno_offset(&lbm, lineno - recno);
		if (!found_continuation_symbol)
			recno += 1;
	}
	if (desc->completed)
		desc->multilines_already_tested = true;
	desc->has_multilines = has_multilines;
}
void multilines_detection ( DataDesc * desc ) { LineBufferIter lbi ; LineBufferMark lbm ; int recno = 1 ; bool border0 = ( desc -> border_type == 0 ) ; bool border1 = ( desc -> border_type == 1 ) ; bool border2 = ( desc -> border_type == 2 ) ; bool has_multilines = false ; if ( desc -> multilines_already_tested ) return ; init_lbi_ddesc ( & lbi , desc , 0 ) ; while ( lbi_set_mark_next ( & lbi , & lbm ) ) { char * str ; int lineno ; int pos = 0 ; bool found_continuation_symbol = false ; LineInfo * linfo ; ( void ) lbm_get_line ( & lbm , & str , & linfo , & lineno ) ; if ( lineno < desc -> first_data_row || lineno > desc -> last_data_row ) continue ; if ( ! linfo || ! ( linfo -> mask & LINEINFO_CONTINUATION || linfo -> mask & LINEINFO_HASNOT_CONTINUATION ) ) { while ( pos < desc -> headline_char_size ) { if ( border0 ) { if ( pos + 1 == desc -> headline_char_size ) { char * sym ; sym = str + charlen ( str ) ; if ( * sym != ' \0 ' ) found_continuation_symbol = is_line_continuation_char ( sym , desc ) ; } else if ( desc -> headline_transl [ pos ] == ' ' ) found_continuation_symbol = is_line_continuation_char ( str , desc ) ; } else if ( border1 ) { if ( ( pos + 1 < desc -> headline_char_size && desc -> headline_transl [ pos + 1 ] == ' ' ) || ( pos + 1 == desc -> headline_char_size ) ) found_continuation_symbol = is_line_continuation_char ( str , desc ) ; } else if ( border2 ) { if ( ( pos + 1 < desc -> headline_char_size ) && ( desc -> headline_transl [ pos + 1 ] == ' ' || desc -> headline_transl [ pos + 1 ] == ' ' ) ) found_continuation_symbol = is_line_continuation_char ( str , desc ) ; } if ( found_continuation_symbol ) { lbm_xor_mask ( & lbm , LINEINFO_CONTINUATION ) ; has_multilines = true ; break ; } pos += dsplen ( str ) ; str += charlen ( str ) ; } if ( ! found_continuation_symbol ) lbm_xor_mask ( & lbm , LINEINFO_HASNOT_CONTINUATION ) ; } else found_continuation_symbol = linfo -> mask & LINEINFO_CONTINUATION ; lbm_recno_offset ( & lbm , lineno - recno ) ; if ( ! found_continuation_symbol ) recno += 1 ; } if ( desc -> completed ) desc -> multilines_already_tested = true ; desc -> has_multilines = has_multilines ; }
Try to detect multiline rows.
Try to detect multiline rows .
/*
		 * This routine can be repeated until progressive load
		 * is not finished. But we don't need to repeat searching
		 * multilines detection.
		 */ /*
			 * This implementation doesn't support old-ascii format
			 */