equal
deleted
inserted
replaced
66 inFilePath = defFilesBasePath; |
66 inFilePath = defFilesBasePath; |
67 inFilePath += IN_SFX; |
67 inFilePath += IN_SFX; |
68 |
68 |
69 if (isreadable(inFilePath.c_str())) |
69 if (isreadable(inFilePath.c_str())) |
70 { |
70 { |
|
71 int |
|
72 res; |
71 |
73 |
72 duplicatedStdInFD_ = dup(STDIN_FILENO); |
74 duplicatedStdInFD_ = dup(STDIN_FILENO); |
73 if (duplicatedStdInFD_ == -1) |
75 if (duplicatedStdInFD_ == -1) |
74 { |
76 { |
75 throw IOCaptureExc("Can't dup(stdin)"); |
77 throw IOCaptureExc("Can't dup(stdin)"); |
77 |
79 |
78 Cpt_EINTR_RETRY(inFileFD_, |
80 Cpt_EINTR_RETRY(inFileFD_, |
79 open(inFilePath.c_str(),O_RDONLY)); |
81 open(inFilePath.c_str(),O_RDONLY)); |
80 if (inFileFD_ == -1) |
82 if (inFileFD_ == -1) |
81 { |
83 { |
82 Cpt_EINTR_RETRY_SP(close(duplicatedStdInFD_)); |
84 Cpt_EINTR_RETRY(res,close(duplicatedStdInFD_)); |
83 throw IOCaptureExc(inFilePath.c_str()); |
85 throw IOCaptureExc(inFilePath.c_str()); |
84 } |
86 } |
85 int |
87 int |
86 newStdIn = dup2(inFileFD_, |
88 newStdIn = dup2(inFileFD_, |
87 STDIN_FILENO); |
89 STDIN_FILENO); |
88 if (newStdIn == -1) |
90 if (newStdIn == -1) |
89 { |
91 { |
90 Cpt_EINTR_RETRY_SP(close(inFileFD_)); |
92 Cpt_EINTR_RETRY(res,close(inFileFD_)); |
91 Cpt_EINTR_RETRY_SP(close(duplicatedStdInFD_)); |
93 Cpt_EINTR_RETRY(res,close(duplicatedStdInFD_)); |
92 throw IOCaptureExc("Can't dup2(infile,stdin)"); |
94 throw IOCaptureExc("Can't dup2(infile,stdin)"); |
93 } |
95 } |
94 } |
96 } |
95 } |
97 } |
96 |
98 |
104 STDIN_FILENO); |
106 STDIN_FILENO); |
105 // we can't possibly do anything sensible about these |
107 // we can't possibly do anything sensible about these |
106 // failures here, but they must not go unnoticed |
108 // failures here, but they must not go unnoticed |
107 assert(fd != -1); |
109 assert(fd != -1); |
108 |
110 |
109 Cpt_EINTR_RETRY_SP(close(inFileFD_)); |
111 int |
110 Cpt_EINTR_RETRY_SP(close(duplicatedStdInFD_)); |
112 res; |
|
113 Cpt_EINTR_RETRY(res,close(inFileFD_)); |
|
114 Cpt_EINTR_RETRY(res,close(duplicatedStdInFD_)); |
111 } |
115 } |
112 } |
116 } |
113 |
117 |
114 |
118 |
115 |
119 |
279 "Could not open for reading"); |
283 "Could not open for reading"); |
280 return; |
284 return; |
281 } |
285 } |
282 Cpt::FileSentry resFsSentry( resFs ); |
286 Cpt::FileSentry resFsSentry( resFs ); |
283 |
287 |
284 ssize_t |
288 size_t |
285 firstDifferingLine = -1, |
289 firstDifferingLine = -1, |
286 currentLine = 1; |
290 currentLine = 1; |
287 string |
291 string |
288 expLine, |
292 expLine, |
289 resLine; |
293 resLine; |