Commit d526d4c17f9de11c4a7a2cd5f27e7e4419d9b33a
1 parent
88891a75
QPDFJob: convert Under/Overlay to use shared pointers
Showing
3 changed files
with
7 additions
and
9 deletions
include/qpdf/QPDFJob.hh
| ... | ... | @@ -148,8 +148,6 @@ class QPDFJob |
| 148 | 148 | { |
| 149 | 149 | UnderOverlay(char const* which) : |
| 150 | 150 | which(which), |
| 151 | - filename(0), | |
| 152 | - password(0), | |
| 153 | 151 | to_nr("1-z"), |
| 154 | 152 | from_nr("1-z"), |
| 155 | 153 | repeat_nr("") |
| ... | ... | @@ -157,8 +155,8 @@ class QPDFJob |
| 157 | 155 | } |
| 158 | 156 | |
| 159 | 157 | std::string which; |
| 160 | - char const* filename; | |
| 161 | - char const* password; | |
| 158 | + std::string filename; | |
| 159 | + std::shared_ptr<char> password; | |
| 162 | 160 | std::string to_nr; |
| 163 | 161 | std::string from_nr; |
| 164 | 162 | std::string repeat_nr; | ... | ... |
libqpdf/QPDFJob.cc
| ... | ... | @@ -1934,13 +1934,13 @@ QPDFJob::processInputSource( |
| 1934 | 1934 | void |
| 1935 | 1935 | QPDFJob::validateUnderOverlay(QPDF& pdf, QPDFJob::UnderOverlay* uo) |
| 1936 | 1936 | { |
| 1937 | - if (0 == uo->filename) | |
| 1937 | + if (uo->filename.empty()) | |
| 1938 | 1938 | { |
| 1939 | 1939 | return; |
| 1940 | 1940 | } |
| 1941 | 1941 | QPDFPageDocumentHelper main_pdh(pdf); |
| 1942 | 1942 | int main_npages = QIntC::to_int(main_pdh.getAllPages().size()); |
| 1943 | - uo->pdf = processFile(uo->filename, uo->password); | |
| 1943 | + uo->pdf = processFile(uo->filename.c_str(), uo->password.get()); | |
| 1944 | 1944 | QPDFPageDocumentHelper uo_pdh(*(uo->pdf)); |
| 1945 | 1945 | int uo_npages = QIntC::to_int(uo_pdh.getAllPages().size()); |
| 1946 | 1946 | try | ... | ... |
libqpdf/QPDFJob_argv.cc
| ... | ... | @@ -1135,7 +1135,7 @@ ArgParser::argEnd256BitEncryption() |
| 1135 | 1135 | void |
| 1136 | 1136 | ArgParser::argUOPositional(char* arg) |
| 1137 | 1137 | { |
| 1138 | - if (o.under_overlay->filename) | |
| 1138 | + if (! o.under_overlay->filename.empty()) | |
| 1139 | 1139 | { |
| 1140 | 1140 | usage(o.under_overlay->which + " file already specified"); |
| 1141 | 1141 | } |
| ... | ... | @@ -1175,13 +1175,13 @@ ArgParser::argUORepeat(char* parameter) |
| 1175 | 1175 | void |
| 1176 | 1176 | ArgParser::argUOPassword(char* parameter) |
| 1177 | 1177 | { |
| 1178 | - o.under_overlay->password = parameter; | |
| 1178 | + o.under_overlay->password = QUtil::make_shared_cstr(parameter); | |
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | 1181 | void |
| 1182 | 1182 | ArgParser::argEndUnderlayOverlay() |
| 1183 | 1183 | { |
| 1184 | - if (0 == o.under_overlay->filename) | |
| 1184 | + if (o.under_overlay->filename.empty()) | |
| 1185 | 1185 | { |
| 1186 | 1186 | usage(o.under_overlay->which + " file not specified"); |
| 1187 | 1187 | } | ... | ... |