MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / convert_pipe

Function convert_pipe

extra/replace.c:1011–1050  ·  view source on GitHub ↗
(rep,in,out)

Source from the content-addressed store, hash-verified

1009 /* Global variable update is set if something was changed */
1010
1011static int convert_pipe(rep,in,out)
1012REPLACE *rep;
1013FILE *in,*out;
1014{
1015 int retain,error;
1016 uint length;
1017 char save_char,*end_of_line,*start_of_line;
1018 DBUG_ENTER("convert_pipe");
1019
1020 updated=retain=0;
1021 reset_buffer();
1022
1023 while ((error=fill_buffer_retaining(my_fileno(in),retain)) > 0)
1024 {
1025 end_of_line=buffer ;
1026 buffer[bufbytes]=0; /* Sentinel */
1027 for (;;)
1028 {
1029 start_of_line=end_of_line;
1030 while (end_of_line[0] != '\n' && end_of_line[0])
1031 end_of_line++;
1032 if (end_of_line == buffer+bufbytes)
1033 {
1034 retain= (int) (end_of_line - start_of_line);
1035 break; /* No end of line, read more */
1036 }
1037 save_char=end_of_line[0];
1038 end_of_line[0]=0;
1039 end_of_line++;
1040 if ((length=replace_strings(rep,&out_buff,&out_length,start_of_line)) ==
1041 (uint) -1)
1042 return 1;
1043 if (!my_eof)
1044 out_buff[length++]=save_char; /* Don't write added newline */
1045 if (my_fwrite(out, (uchar*) out_buff, length, MYF(MY_WME | MY_NABP)))
1046 DBUG_RETURN(1);
1047 }
1048 }
1049 DBUG_RETURN(error);
1050}
1051
1052
1053static int convert_file(REPLACE *rep, char * name)

Callers 2

mainFunction · 0.85
convert_fileFunction · 0.85

Calls 5

reset_bufferFunction · 0.85
fill_buffer_retainingFunction · 0.85
my_filenoFunction · 0.85
replace_stringsFunction · 0.85
my_fwriteFunction · 0.85

Tested by

no test coverage detected