From 3c5700c255f4603b5df9c6d183d13dd71a083cc3 Mon Sep 17 00:00:00 2001 From: m-holger Date: Sat, 27 May 2023 18:19:52 +0100 Subject: Code tidy - reflow comments and strings --- libqpdf/QPDFArgParser.cc | 87 ++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 51 deletions(-) (limited to 'libqpdf/QPDFArgParser.cc') diff --git a/libqpdf/QPDFArgParser.cc b/libqpdf/QPDFArgParser.cc index 7e1980ad..78e5e843 100644 --- a/libqpdf/QPDFArgParser.cc +++ b/libqpdf/QPDFArgParser.cc @@ -139,8 +139,8 @@ QPDFArgParser::addInvalidChoiceHandler(std::string const& arg, param_arg_handler auto i = m->option_table->find(arg); if (i == m->option_table->end()) { QTC::TC("libtests", "QPDFArgParser invalid choice handler to unknown"); - throw std::logic_error("QPDFArgParser: attempt to add invalid choice handler" - " to unknown argument"); + throw std::logic_error( + "QPDFArgParser: attempt to add invalid choice handler to unknown argument"); } auto& oe = i->second; oe.invalid_choice_handler = handler; @@ -231,9 +231,9 @@ QPDFArgParser::invalidHelpArg(std::string const& p) void QPDFArgParser::handleArgFileArguments() { - // Support reading arguments from files. Create a new argv. Ensure - // that argv itself as well as all its contents are automatically - // deleted by using shared pointers to back the pointers in argv. + // Support reading arguments from files. Create a new argv. Ensure that argv itself as well as + // all its contents are automatically deleted by using shared pointers to back the pointers in + // argv. m->new_argv.push_back(QUtil::make_shared_cstr(m->argv[0])); for (int i = 1; i < m->argc; ++i) { char const* argfile = nullptr; @@ -264,12 +264,10 @@ QPDFArgParser::handleArgFileArguments() void QPDFArgParser::handleBashArguments() { - // Do a minimal job of parsing bash_line into arguments. This - // doesn't do everything the shell does (e.g. $(...), variable - // expansion, arithmetic, globs, etc.), but it should be good - // enough for purposes of handling completion. As we build up the - // new argv, we can't use m->new_argv because this code has to - // interoperate with @file arguments, so memory for both ways of + // Do a minimal job of parsing bash_line into arguments. This doesn't do everything the shell + // does (e.g. $(...), variable expansion, arithmetic, globs, etc.), but it should be good enough + // for purposes of handling completion. As we build up the new argv, we can't use m->new_argv + // because this code has to interoperate with @file arguments, so memory for both ways of // fabricating argv has to be protected. bool last_was_backslash = false; @@ -321,12 +319,11 @@ QPDFArgParser::handleBashArguments() } } if (m->bash_argv.empty()) { - // This can't happen if properly invoked by bash, but ensure - // we have a valid argv[0] regardless. + // This can't happen if properly invoked by bash, but ensure we have a valid argv[0] + // regardless. m->bash_argv.push_back(QUtil::make_shared_cstr(m->argv[0])); } - // Explicitly discard any non-space-terminated word. The "current - // word" is handled specially. + // Explicitly discard any non-space-terminated word. The "current word" is handled specially. m->bash_argv_ph = QUtil::make_shared_array(1 + m->bash_argv.size()); for (size_t i = 0; i < m->bash_argv.size(); ++i) { m->bash_argv_ph.get()[i] = m->bash_argv.at(i).get(); @@ -367,12 +364,10 @@ QPDFArgParser::checkCompletion() { // See if we're being invoked from bash completion. std::string bash_point_env; - // On Windows with mingw, there have been times when there appears - // to be no way to distinguish between an empty environment - // variable and an unset variable. There are also conditions under - // which bash doesn't set COMP_LINE. Therefore, enter this logic - // if either COMP_LINE or COMP_POINT are set. They will both be - // set together under ordinary circumstances. + // On Windows with mingw, there have been times when there appears to be no way to distinguish + // between an empty environment variable and an unset variable. There are also conditions under + // which bash doesn't set COMP_LINE. Therefore, enter this logic if either COMP_LINE or + // COMP_POINT are set. They will both be set together under ordinary circumstances. bool got_line = QUtil::get_env("COMP_LINE", &m->bash_line); bool got_point = QUtil::get_env("COMP_POINT", &bash_point_env); if (got_line || got_point) { @@ -385,15 +380,12 @@ QPDFArgParser::checkCompletion() if (p > m->bash_line.length()) { p = m->bash_line.length(); } - // Set bash_cur and bash_prev based on bash_line rather than - // relying on argv. This enables us to use bashcompinit to get - // completion in zsh too since bashcompinit sets COMP_LINE and - // COMP_POINT but doesn't invoke the command with options like - // bash does. - - // p is equal to length of the string. Walk backwards looking - // for the first separator. bash_cur is everything after the - // last separator, possibly empty. + // Set bash_cur and bash_prev based on bash_line rather than relying on argv. This enables + // us to use bashcompinit to get completion in zsh too since bashcompinit sets COMP_LINE and + // COMP_POINT but doesn't invoke the command with options like bash does. + + // p is equal to length of the string. Walk backwards looking for the first separator. + // bash_cur is everything after the last separator, possibly empty. char sep(0); while (p > 0) { --p; @@ -407,10 +399,9 @@ QPDFArgParser::checkCompletion() m->bash_cur = m->bash_line.substr(1 + p, std::string::npos); } if ((sep == ':') || (sep == '=')) { - // Bash sets prev to the non-space separator if any. - // Actually, if there are multiple separators in a row, - // they are all included in prev, but that detail is not - // important to us and not worth coding. + // Bash sets prev to the non-space separator if any. Actually, if there are multiple + // separators in a row, they are all included in prev, but that detail is not important + // to us and not worth coding. m->bash_prev = m->bash_line.substr(p, 1); } else { // Go back to the last separator and set prev based on @@ -429,8 +420,8 @@ QPDFArgParser::checkCompletion() m->bash_prev = m->bash_line.substr(0, p); } if (m->argc == 1) { - // This is probably zsh using bashcompinit. There are a - // few differences in the expected output. + // This is probably zsh using bashcompinit. There are a few differences in the expected + // output. m->zsh_completion = true; } handleBashArguments(); @@ -454,8 +445,7 @@ QPDFArgParser::parseArgs() std::string o_arg(arg); std::string arg_s(arg); if (strcmp(arg, "--") == 0) { - // Special case for -- option, which is used to break out - // of subparsers. + // Special case for -- option, which is used to break out of subparsers. oep = m->option_table->find("--"); end_option = true; if (oep == m->option_table->end()) { @@ -471,11 +461,9 @@ QPDFArgParser::parseArgs() QTC::TC("libtests", "QPDFArgParser single dash"); } - // Prevent --=something from being treated as an empty arg - // by searching for = from after the first character. We - // do this since the empty string in the option table is - // for positional arguments. Besides, it doesn't make - // sense to have an empty option. + // Prevent --=something from being treated as an empty arg by searching for = from after + // the first character. We do this since the empty string in the option table is for + // positional arguments. Besides, it doesn't make sense to have an empty option. arg_s = arg; size_t equal_pos = std::string::npos; if (arg_s.length() > 0) { @@ -489,8 +477,7 @@ QPDFArgParser::parseArgs() if ((!m->bash_completion) && (m->argc == 2) && (m->cur_arg == 1) && m->help_option_table.count(arg_s)) { - // Handle help option, which is only valid as the sole - // option. + // Handle help option, which is only valid as the sole option. QTC::TC("libtests", "QPDFArgParser help option"); oep = m->help_option_table.find(arg_s); help_option = true; @@ -500,8 +487,7 @@ QPDFArgParser::parseArgs() oep = m->option_table->find(arg_s); } } else { - // The empty string maps to the positional argument - // handler. + // The empty string maps to the positional argument handler. QTC::TC("libtests", "QPDFArgParser positional"); oep = m->option_table->find(""); parameter = arg; @@ -522,8 +508,7 @@ QPDFArgParser::parseArgs() std::string message = "--" + arg_s + " must be given as --" + arg_s + "="; if (oe.invalid_choice_handler) { oe.invalid_choice_handler(parameter); - // Method should call usage() or exit. Just in case it - // doesn't... + // Method should call usage() or exit. Just in case it doesn't... message += "option"; } else if (!oe.choices.empty()) { QTC::TC("libtests", "QPDFArgParser required choices"); @@ -609,8 +594,8 @@ QPDFArgParser::addOptionsToCompletions(option_table_t& option_table) std::string base = "--" + arg; if (oe.param_arg_handler) { if (m->zsh_completion) { - // zsh doesn't treat = as a word separator, so add all - // the options so we don't get a space after the =. + // zsh doesn't treat = as a word separator, so add all the options so we don't get a + // space after the =. addChoicesToCompletions(option_table, arg, base + "="); } m->completions.insert(base + "="); -- cgit v1.2.3-70-g09d2 From acd0acf16931ce92bc908e4960c5a1e43d53b550 Mon Sep 17 00:00:00 2001 From: m-holger Date: Mon, 29 May 2023 19:26:18 +0100 Subject: Fix doc typos --- .git-blame-ignore-revs | 1 + examples/pdf-invert-images.cc | 6 +++--- examples/pdf-name-number-tree.cc | 2 +- examples/pdf-set-form-values.cc | 14 +++++++------- include/qpdf/ClosedFileInputSource.hh | 6 +++--- include/qpdf/JSON.hh | 4 ++-- include/qpdf/PDFVersion.hh | 3 --- include/qpdf/Pl_Concatenate.hh | 2 +- include/qpdf/QPDFAnnotationObjectHelper.hh | 4 ++-- include/qpdf/QPDFDocumentHelper.hh | 12 ++++++------ include/qpdf/QPDFEFStreamObjectHelper.hh | 2 +- include/qpdf/QPDFLogger.hh | 16 ++++++++-------- include/qpdf/QPDFNameTreeObjectHelper.hh | 4 ++-- include/qpdf/QPDFNumberTreeObjectHelper.hh | 4 ++-- include/qpdf/QPDFObjectHelper.hh | 2 +- include/qpdf/QPDFOutlineDocumentHelper.hh | 2 +- include/qpdf/QPDFOutlineObjectHelper.hh | 6 +++--- include/qpdf/QPDFPageDocumentHelper.hh | 4 ++-- include/qpdf/QPDFWriter.hh | 12 ++++++------ include/qpdf/QUtil.hh | 2 +- include/qpdf/qpdfjob-c.h | 5 +++-- libqpdf/NNTree.cc | 10 +++++----- libqpdf/QPDFArgParser.cc | 2 +- libqpdf/QPDFWriter.cc | 6 +++--- 24 files changed, 65 insertions(+), 66 deletions(-) (limited to 'libqpdf/QPDFArgParser.cc') diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 9bcbf02e..6b746d82 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -14,3 +14,4 @@ d740c6ccced02147f84a39d5e5f0984d12bac6cb 60965d5f4d608bdccc2ffd4e8753e12cbbbd71d2 # Reflow comments and strings to 100 columns 698a70e6a84cf7c0db667e9d9e021b4c34c85a3e +3c5700c255f4603b5df9c6d183d13dd71a083cc3 diff --git a/examples/pdf-invert-images.cc b/examples/pdf-invert-images.cc index 0ef2169e..4ec83b84 100644 --- a/examples/pdf-invert-images.cc +++ b/examples/pdf-invert-images.cc @@ -120,9 +120,9 @@ main(int argc, char* argv[]) QPDFObjectHandle color_space = image_dict.getKey("/ColorSpace"); QPDFObjectHandle bits_per_component = image_dict.getKey("/BitsPerComponent"); - // For our example, we can only work with images 8-bit grayscale images that we can - // fully decode. Use pipeStreamData with a null pipeline to determine whether the - // image is filterable. Directly inspect keys to determine the image type. + // For our example, we can only work with 8-bit grayscale images that we can fully + // decode. Use pipeStreamData with a null pipeline to determine whether the image + // is filterable. Directly inspect keys to determine the image type. if (image.pipeStreamData(nullptr, qpdf_ef_compress, qpdf_dl_all) && color_space.isNameAndEquals("/DeviceGray") && bits_per_component.isInteger() && (bits_per_component.getIntValue() == 8)) { diff --git a/examples/pdf-name-number-tree.cc b/examples/pdf-name-number-tree.cc index 31eaf932..7701e70e 100644 --- a/examples/pdf-name-number-tree.cc +++ b/examples/pdf-name-number-tree.cc @@ -41,7 +41,7 @@ main(int argc, char* argv[]) // (root), and write an empty PDF to a file. The PDF will have no pages and won't be viewable, // but you can look at it in a text editor to see the resulting structure of the PDF. - // Create a dictionary off the root where we will hang our name and number tree. + // Create a dictionary off the root where we will hang our name and number trees. auto root = qpdf.getRoot(); auto example = QPDFObjectHandle::newDictionary(); root.replaceKey("/Example", example); diff --git a/examples/pdf-set-form-values.cc b/examples/pdf-set-form-values.cc index a1a19db1..810b9fa3 100644 --- a/examples/pdf-set-form-values.cc +++ b/examples/pdf-set-form-values.cc @@ -38,7 +38,7 @@ main(int argc, char* argv[]) qpdf.processFile(infilename); // We will iterate through form fields by starting at the page level and looking at each - // field for each page. We could also called QPDFAcroFormDocumentHelper::getFormFields to + // field for each page. We could also call QPDFAcroFormDocumentHelper::getFormFields to // iterate at the field level, but doing it as below illustrates how we can map from // annotations to fields. @@ -51,12 +51,12 @@ main(int argc, char* argv[]) // value. QPDFFormFieldObjectHelper ffh = afdh.getFieldForAnnotation(annot); if (ffh.getFieldType() == "/Tx") { - // Set the value. Passing false as the second value prevents qpdf from setting - // /NeedAppearances to true (but will not turn it off if it's already on), so we - // call generateAppearance after setting the value. You may or may not want to - // do this depending on whether the appearance streams generated by qpdf are - // good enough for your purposes. For additional details, please see comments in - // QPDFFormFieldObjectHelper.hh for this method. + // Set the value. Passing false as the second parameter prevents qpdf from + // setting /NeedAppearances to true (but will not turn it off if it's already + // on), so we call generateAppearance after setting the value. You may or may + // not want to do this depending on whether the appearance streams generated by + // qpdf are good enough for your purposes. For additional details, please see + // comments in QPDFFormFieldObjectHelper.hh for this method. ffh.setV(value, false); ffh.generateAppearance(annot); } diff --git a/include/qpdf/ClosedFileInputSource.hh b/include/qpdf/ClosedFileInputSource.hh index 9f7e4fce..41c46242 100644 --- a/include/qpdf/ClosedFileInputSource.hh +++ b/include/qpdf/ClosedFileInputSource.hh @@ -20,9 +20,9 @@ #define QPDF_CLOSEDFILEINPUTSOURCE_HH // This is an input source that reads from files, like FileInputSource, except that it opens and -// close the file surrounding every operation. This decreases efficiency, but it allows many more of -// these to exist at once than the maximum number of open file descriptors. This is used for merging -// large numbers of files. +// closes the file surrounding every operation. This decreases efficiency, but it allows many more +// of these to exist at once than the maximum number of open file descriptors. This is used for +// merging large numbers of files. #include #include // unused -- remove in qpdf 12 (see #785) diff --git a/include/qpdf/JSON.hh b/include/qpdf/JSON.hh index ce37ef50..d05a82fb 100644 --- a/include/qpdf/JSON.hh +++ b/include/qpdf/JSON.hh @@ -69,7 +69,7 @@ class JSON // to pass that `first` through to all the methods that are called to add top-level items to the // container as well as to close the container. This lets the JSON object use it to keep track // of when it's writing a first object and when it's not. If incrementally writing multiple - // levels of depth, a new `first` should used for each new container that is opened. + // levels of depth, a new `first` should be used for each new container that is opened. // // "depth" -- Indicate the level of depth. This is used for consistent indentation. When writing // incrementally, whenever you call a method to add an item to a container, the value of `depth` @@ -208,7 +208,7 @@ class JSON QPDF_DLL bool checkSchema(JSON schema, std::list& errors); - // An pointer to a Reactor class can be passed to parse, which will enable the caller to react + // A pointer to a Reactor class can be passed to parse, which will enable the caller to react // to incremental events in the construction of the JSON object. This makes it possible to // implement SAX-like handling of very large JSON objects. class QPDF_DLL_CLASS Reactor diff --git a/include/qpdf/PDFVersion.hh b/include/qpdf/PDFVersion.hh index 1b2c45de..ed072c7a 100644 --- a/include/qpdf/PDFVersion.hh +++ b/include/qpdf/PDFVersion.hh @@ -16,9 +16,6 @@ // License. At your option, you may continue to consider qpdf to be licensed under those terms. // Please see the manual for additional information. -// This class implements a simple writer for saving QPDF objects to new PDF files. See comments -// through the header file for additional details. - #ifndef PDFVERSION_HH #define PDFVERSION_HH diff --git a/include/qpdf/Pl_Concatenate.hh b/include/qpdf/Pl_Concatenate.hh index 444a7482..24977de1 100644 --- a/include/qpdf/Pl_Concatenate.hh +++ b/include/qpdf/Pl_Concatenate.hh @@ -19,7 +19,7 @@ #ifndef PL_CONCATENATE_HH #define PL_CONCATENATE_HH -// This pipeline will drop all regular finished calls rather than passing them onto next. To finish +// This pipeline will drop all regular finish calls rather than passing them onto next. To finish // downstream streams, call manualFinish. This makes it possible to pipe multiple streams (e.g. // with QPDFObjectHandle::pipeStreamData) to a downstream like Pl_Flate that can't handle multiple // calls to finish(). diff --git a/include/qpdf/QPDFAnnotationObjectHelper.hh b/include/qpdf/QPDFAnnotationObjectHelper.hh index 9da0fd39..b93f895f 100644 --- a/include/qpdf/QPDFAnnotationObjectHelper.hh +++ b/include/qpdf/QPDFAnnotationObjectHelper.hh @@ -40,7 +40,7 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper // besides widget annotations, but they are implemented with form fields so that they can // properly handle form fields when needed. - // Return the subtype of the annotation as a string (e.g. "/Widget"). Returns the empty string + // Return the subtype of the annotation as a string (e.g. "/Widget"). Returns an empty string // if the subtype (which is required by the spec) is missing. QPDF_DLL std::string getSubtype(); @@ -51,7 +51,7 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper QPDF_DLL QPDFObjectHandle getAppearanceDictionary(); - // Return the appearance state as given in "/AS", or the empty string if none is given. + // Return the appearance state as given in "/AS", or an empty string if none is given. QPDF_DLL std::string getAppearanceState(); diff --git a/include/qpdf/QPDFDocumentHelper.hh b/include/qpdf/QPDFDocumentHelper.hh index bb614843..1cd0a2e0 100644 --- a/include/qpdf/QPDFDocumentHelper.hh +++ b/include/qpdf/QPDFDocumentHelper.hh @@ -23,12 +23,12 @@ #include // This is a base class for QPDF Document Helper classes. Document helpers are classes that provide -// a convenient, higher-level API for accessing document-level structures with a PDF file. Document -// helpers are always initialized with a reference to a QPDF object, and the object can always be -// retrieved. The intention is that you may freely intermix use of document helpers with the -// underlying QPDF object unless there is a specific comment in a specific helper method that says -// otherwise. The pattern of using helper objects was introduced to allow creation of higher level -// helper functions without polluting the public interface of QPDF. +// a convenient, higher-level API for accessing document-level structures within a PDF file. +// Document helpers are always initialized with a reference to a QPDF object, and the object can +// always be retrieved. The intention is that you may freely intermix use of document helpers with +// the underlying QPDF object unless there is a specific comment in a specific helper method that +// says otherwise. The pattern of using helper objects was introduced to allow creation of higher +// level helper functions without polluting the public interface of QPDF. class QPDF_DLL_CLASS QPDFDocumentHelper { diff --git a/include/qpdf/QPDFEFStreamObjectHelper.hh b/include/qpdf/QPDFEFStreamObjectHelper.hh index ab26b2c1..cdb5c278 100644 --- a/include/qpdf/QPDFEFStreamObjectHelper.hh +++ b/include/qpdf/QPDFEFStreamObjectHelper.hh @@ -55,7 +55,7 @@ class QPDFEFStreamObjectHelper: public QPDFObjectHelper // Return the checksum as stored in the object as a binary string. This does not check // consistency with the data. If not present, return an empty string. The PDF spec specifies // this as an MD5 checksum and notes that it is not to be used for security purposes since MD5 - // is known not to be secure. + // is known to be insecure. QPDF_DLL std::string getChecksum(); diff --git a/include/qpdf/QPDFLogger.hh b/include/qpdf/QPDFLogger.hh index 0b77d57a..0b5b6186 100644 --- a/include/qpdf/QPDFLogger.hh +++ b/include/qpdf/QPDFLogger.hh @@ -31,14 +31,14 @@ class QPDFLogger static std::shared_ptr create(); // Return the default logger. In general, you should use the default logger. You can also create - // your own loggers and use them QPDF and QPDFJob objects, but there are few reasons to do so. - // One reason may if you are using multiple QPDF or QPDFJob objects in different threads and - // want to capture output and errors to different streams. (Note that a single QPDF or QPDFJob - // can't be safely used from multiple threads, but it is safe to use separate QPDF and QPDFJob - // objects on separate threads.) Another possible reason would be if you are writing an - // application that uses the qpdf library directly and qpdf is also used by a downstream library - // or if you are using qpdf from a library and don't want to interfere with potential uses of - // qpdf by other libraries or applications. + // your own loggers and use them with QPDF and QPDFJob objects, but there are few reasons to do + // so. One reason may be that you are using multiple QPDF or QPDFJob objects in different + // threads and want to capture output and errors to different streams. (Note that a single QPDF + // or QPDFJob can't be safely used from multiple threads, but it is safe to use separate QPDF + // and QPDFJob objects on separate threads.) Another possible reason would be if you are writing + // an application that uses the qpdf library directly and qpdf is also used by a downstream + // library or if you are using qpdf from a library and don't want to interfere with potential + // uses of qpdf by other libraries or applications. QPDF_DLL static std::shared_ptr defaultLogger(); diff --git a/include/qpdf/QPDFNameTreeObjectHelper.hh b/include/qpdf/QPDFNameTreeObjectHelper.hh index 9e59e1fb..90cb6856 100644 --- a/include/qpdf/QPDFNameTreeObjectHelper.hh +++ b/include/qpdf/QPDFNameTreeObjectHelper.hh @@ -52,7 +52,7 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper QPDF_DLL virtual ~QPDFNameTreeObjectHelper(); - // Return whether the number tree has an explicit entry for this number. + // Return whether the name tree has an explicit entry for this name. QPDF_DLL bool hasName(std::string const& utf8); @@ -151,7 +151,7 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper iterator insert(std::string const& key, QPDFObjectHandle value); // Remove an item. Return true if the item was found and removed; otherwise return false. If - // value is not null, initialize it to the value that was removed. + // value is not nullptr, initialize it to the value that was removed. QPDF_DLL bool remove(std::string const& key, QPDFObjectHandle* value = nullptr); diff --git a/include/qpdf/QPDFNumberTreeObjectHelper.hh b/include/qpdf/QPDFNumberTreeObjectHelper.hh index f2a66026..12603af0 100644 --- a/include/qpdf/QPDFNumberTreeObjectHelper.hh +++ b/include/qpdf/QPDFNumberTreeObjectHelper.hh @@ -145,7 +145,7 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper value_type ivalue; }; - // The iterator looks like map iterator, so i.first is a string and i.second is a + // The iterator looks like map iterator, so i.first is a numtree_number and i.second is a // QPDFObjectHandle. Incrementing end() brings you to the first item. Decrementing end() brings // you to the last item. QPDF_DLL @@ -166,7 +166,7 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper iterator insert(numtree_number key, QPDFObjectHandle value); // Remove an item. Return true if the item was found and removed; otherwise return false. If - // value is not null, initialize it to the value that was removed. + // value is not nullptr, initialize it to the value that was removed. QPDF_DLL bool remove(numtree_number key, QPDFObjectHandle* value = nullptr); diff --git a/include/qpdf/QPDFObjectHelper.hh b/include/qpdf/QPDFObjectHelper.hh index 30853a74..953ee1f1 100644 --- a/include/qpdf/QPDFObjectHelper.hh +++ b/include/qpdf/QPDFObjectHelper.hh @@ -26,7 +26,7 @@ // This is a base class for QPDF Object Helper classes. Object helpers are classes that provide a // convenient, higher-level API for working with specific types of QPDF objects. Object helpers are // always initialized with a QPDFObjectHandle, and the underlying object handle can always be -// retrieved. The intention is that you may freely intermix use of document helpers with the +// retrieved. The intention is that you may freely intermix use of object helpers with the // underlying QPDF objects unless there is a specific comment in a specific helper method that says // otherwise. The pattern of using helper objects was introduced to allow creation of higher level // helper functions without polluting the public interface of QPDFObjectHandle. diff --git a/include/qpdf/QPDFOutlineDocumentHelper.hh b/include/qpdf/QPDFOutlineDocumentHelper.hh index 23e4902c..eb5f8f9a 100644 --- a/include/qpdf/QPDFOutlineDocumentHelper.hh +++ b/include/qpdf/QPDFOutlineDocumentHelper.hh @@ -55,7 +55,7 @@ class QPDFOutlineDocumentHelper: public QPDFDocumentHelper QPDF_DLL QPDFObjectHandle resolveNamedDest(QPDFObjectHandle name); - // Return a list outlines that are known to target the specified page + // Return a list outlines that are known to target the specified page. QPDF_DLL std::vector getOutlinesForPage(QPDFObjGen const&); diff --git a/include/qpdf/QPDFOutlineObjectHelper.hh b/include/qpdf/QPDFOutlineObjectHelper.hh index 8a0b10c9..289941fa 100644 --- a/include/qpdf/QPDFOutlineObjectHelper.hh +++ b/include/qpdf/QPDFOutlineObjectHelper.hh @@ -37,7 +37,7 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper virtual ~QPDFOutlineObjectHelper() { // This must be cleared explicitly to avoid circular references that prevent cleanup of - // pointer holders. + // shared pointers. m->parent = nullptr; } @@ -66,11 +66,11 @@ class QPDFOutlineObjectHelper: public QPDFObjectHelper // Returns the value of /Count as present in the object, or 0 if not present. If count is // positive, the outline is open. If negative, it is closed. Either way, the absolute value is - // the number descendant items that would be visible if this were open. + // the number of descendant items that would be visible if this were open. QPDF_DLL int getCount(); - // Returns the title as a UTF-8 string. Returns the empty string if there is no title. + // Returns the title as a UTF-8 string. Returns an empty string if there is no title. QPDF_DLL std::string getTitle(); diff --git a/include/qpdf/QPDFPageDocumentHelper.hh b/include/qpdf/QPDFPageDocumentHelper.hh index 351a04f0..a6005a45 100644 --- a/include/qpdf/QPDFPageDocumentHelper.hh +++ b/include/qpdf/QPDFPageDocumentHelper.hh @@ -56,7 +56,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper QPDF_DLL void removeUnreferencedResources(); - // Add new page at the beginning or the end of the current pdf. The newpage parameter may be + // Add a new page at the beginning or the end of the current pdf. The newpage parameter may be // either a direct object, an indirect object from this QPDF, or an indirect object from another // QPDF. If it is a direct object, it will be made indirect. If it is an indirect object from // another QPDF, this method will call pushInheritedAttributesToPage on the other file and then @@ -76,7 +76,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper // This method does not have any specific awareness of annotations or form fields, so if you // just add a page without thinking about it, you might end up with two pages that share form // fields or annotations. While the page may look fine, it will probably not function properly - // with regard to interactive features. To work around this, you should called + // with regard to interactive features. To work around this, you should call // QPDFAcroFormDocumentHelper::fixCopiedAnnotations. A future version of qpdf will likely // provide a higher-level interface for copying pages around that will handle document-level // constructs in a less error-prone fashion. diff --git a/include/qpdf/QPDFWriter.hh b/include/qpdf/QPDFWriter.hh index 63fba056..34720119 100644 --- a/include/qpdf/QPDFWriter.hh +++ b/include/qpdf/QPDFWriter.hh @@ -103,11 +103,11 @@ class QPDFWriter // Setting Output. Output may be set only one time. If you don't use the filename version of // the QPDFWriter constructor, you must call exactly one of these methods. - // Passing null as filename means write to stdout. QPDFWriter will create a zero-length output - // file upon construction. If write fails, the empty or partially written file will not be - // deleted. This is by design: sometimes the partial file may be useful for tracking down + // Passing nullptr as filename means write to stdout. QPDFWriter will create a zero-length + // output file upon construction. If write fails, the empty or partially written file will not + // be deleted. This is by design: sometimes the partial file may be useful for tracking down // problems. If your application doesn't want the partially written file to be left behind, you - // should delete it the eventual call to write fails. + // should delete it if the eventual call to write fails. QPDF_DLL void setOutputFilename(char const* filename); @@ -184,8 +184,8 @@ class QPDFWriter // // qpdf_dl_generalized: This is the default. QPDFWriter will apply LZWDecode, ASCII85Decode, // ASCIIHexDecode, and FlateDecode filters on the input. When combined with - // setCompressStreams(true), which the default, the effect of this is that streams filtered with - // these older and less efficient filters will be recompressed with the Flate filter. By + // setCompressStreams(true), which is the default, the effect of this is that streams filtered + // with these older and less efficient filters will be recompressed with the Flate filter. By // default, as a special case, if a stream is already compressed with FlateDecode and // setCompressStreams is enabled, the original compressed data will be preserved. This behavior // can be overridden by calling setRecompressFlate(true). diff --git a/include/qpdf/QUtil.hh b/include/qpdf/QUtil.hh index 47ecf6bf..ab2727a6 100644 --- a/include/qpdf/QUtil.hh +++ b/include/qpdf/QUtil.hh @@ -224,7 +224,7 @@ namespace QUtil QPDF_DLL time_t get_current_time(); - // Portable structure representing a point in time with second granularity and time zone offset + // Portable structure representing a point in time with second granularity and time zone offset. struct QPDFTime { QPDFTime() = default; diff --git a/include/qpdf/qpdfjob-c.h b/include/qpdf/qpdfjob-c.h index 3db41d3e..5450d3d0 100644 --- a/include/qpdf/qpdfjob-c.h +++ b/include/qpdf/qpdfjob-c.h @@ -109,7 +109,7 @@ extern "C" { #endif /* QPDF_NO_WCHAR_T */ /* This function wraps QPDFJob::initializeFromJson. The return value is the same as qpdfjob_run. - * If this returns an error, it is invalid to call any other functions this job handle. + * If this returns an error, it is invalid to call any other functions using this job handle. */ QPDF_DLL int qpdfjob_initialize_from_json(qpdfjob_handle j, char const* json); @@ -135,7 +135,8 @@ extern "C" { /* This function wraps QPDFJob::writeQPDF. It returns the error code that qpdf would return with * the equivalent command-line invocation. Exit code values are defined in Constants.h in the * qpdf_exit_code_e type. NOTE it is the callers responsibility to clean up the resources - * associated qpdf_data object by calling qpdf_cleanup after the call to qpdfjob_write_qpdf. + * associated with the qpdf_data object by calling qpdf_cleanup after the call to + * qpdfjob_write_qpdf. */ QPDF_DLL int qpdfjob_write_qpdf(qpdfjob_handle j, qpdf_data qpdf); diff --git a/libqpdf/NNTree.cc b/libqpdf/NNTree.cc index 129c8734..a584ff8d 100644 --- a/libqpdf/NNTree.cc +++ b/libqpdf/NNTree.cc @@ -44,10 +44,10 @@ NNTreeIterator::updateIValue(bool allow_invalid) // various cases to ensure we don't introduce that bug in the future, but sadly it's tricky to // verify by reasoning about the code that this constraint is always satisfied. Whenever we // update what the iterator points to, we should call setItemNumber, which calls this. If we - // change what the iterator in some other way, such as replacing a value or removing an item and - // making the iterator point at a different item in potentially the same position, we must call - // updateIValue as well. These cases are handled, and for good measure, we also call - // updateIValue in operator* and operator->. + // change what the iterator points to in some other way, such as replacing a value or removing + // an item and making the iterator point at a different item in potentially the same position, + // we must call updateIValue as well. These cases are handled, and for good measure, we also + // call updateIValue in operator* and operator->. bool okay = false; if ((item_number >= 0) && this->node.isDictionary()) { @@ -226,7 +226,7 @@ NNTreeIterator::split(QPDFObjectHandle to_split, std::list::iterato // Split some node along the path to the item pointed to by this iterator, and adjust the // iterator so it points to the same item. - // In examples, for simplicity, /Nums is show to just contain numbers instead of pairs. Imagine + // In examples, for simplicity, /Nums is shown to just contain numbers instead of pairs. Imagine // this tree: // // root: << /Kids [ A B C D ] >> diff --git a/libqpdf/QPDFArgParser.cc b/libqpdf/QPDFArgParser.cc index 78e5e843..3ebec29c 100644 --- a/libqpdf/QPDFArgParser.cc +++ b/libqpdf/QPDFArgParser.cc @@ -232,7 +232,7 @@ void QPDFArgParser::handleArgFileArguments() { // Support reading arguments from files. Create a new argv. Ensure that argv itself as well as - // all its contents are automatically deleted by using shared pointers to back the pointers in + // all its contents are automatically deleted by using shared pointers back to the pointers in // argv. m->new_argv.push_back(QUtil::make_shared_cstr(m->argv[0])); for (int i = 1; i < m->argc; ++i) { diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index 94ce07b9..50594a09 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -1346,8 +1346,8 @@ QPDFWriter::unparseObject( // Make a shallow copy of this object so we can modify it safely without affecting the // original. This code has logic to skip certain keys in agreement with prepareFileForWrite // and with skip_stream_parameters so that replacing them doesn't leave unreferenced objects - // in the output. We can use unsafeShallowCopy here because we are all we are doing is - // removing or replacing top-level keys. + // in the output. We can use unsafeShallowCopy here because all we are doing is removing or + // replacing top-level keys. object = object.unsafeShallowCopy(); // Handle special cases for specific dictionaries. @@ -1701,7 +1701,7 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object) } QPDFObjectHandle obj_to_write = m->pdf.getObject(obj); if (obj_to_write.isStream()) { - // This condition occurred in a fuzz input. Ideally we should block it at at parse + // This condition occurred in a fuzz input. Ideally we should block it at parse // time, but it's not clear to me how to construct a case for this. QTC::TC("qpdf", "QPDFWriter stream in ostream"); obj_to_write.warnIfPossible("stream found inside object stream; treating as null"); -- cgit v1.2.3-70-g09d2