Skip to content
Snippets Groups Projects
  1. Mar 28, 2023
    • Sven M. Hallberg's avatar
      allow partial results from parse_xrefs · f844fce3
      Sven M. Hallberg authored
      This was intended to be a 'break' statement, returning any xref sections
      parsed up to that point. Note that parse_xrefs() is *not* supposed to be
      the validating parser proper for the document. It is a utility that is
      needed before the actual parser can run, so if it returns partial data
      in a best effort, that is fine.
      f844fce3
    • Sven M. Hallberg's avatar
      remove erroneous comment · bc05e4c6
      Sven M. Hallberg authored
      As far as I can tell, this is not a case for SEV_DONTCARE. It's
      (conceptually) a parse error.
      bc05e4c6
    • Sven M. Hallberg's avatar
      comments · cbf3a1bb
      Sven M. Hallberg authored
      cbf3a1bb
    • Sven M. Hallberg's avatar
      expand a comment · ecb984e9
      Sven M. Hallberg authored
      ecb984e9
    • Sven M. Hallberg's avatar
      revert to shadowing a variable instead of overwriting it · 3de6efd6
      Sven M. Hallberg authored
      As indicated by the XXX, this line of code was never meant to be
      considered as "proper", mainly because it allocates a new parser
      that is never freed for every xref section in the file.
      
      The reason that this line was introduced in place of the commented-out
      original above it is that the latter does not bounds-check the offset
      but h_seek() does. It was a quick and reliable way to make invalid
      offsets fail the parse.
      
      Anyway, creating a new HParser *p that incidentally shadows the
      previous occurance was meant to signal that this is just a temporary
      name that we need real quick (on the next line), not a "proper" variable,
      and that it probably wasn't there to stay. So with that sense in mind, I
      am putting it back.
      
      Remove -Wshadow from CFLAGS.
      3de6efd6
    • Sven M. Hallberg's avatar
      remove superfluous assignment · 83bdf6cd
      Sven M. Hallberg authored
      How did that get in there? The very next line overwrites it.
      83bdf6cd
    • Sven M. Hallberg's avatar
      parse_xrefs: remove unconditional initialization of result · b606013c
      Sven M. Hallberg authored
      The purpose of parse_xrefs() is not to initialize the aux environment,
      that is done in main. The design of the function is to fill a particular
      part of that environment *if* it succeeds and not touch it otherwise.
      Thus the late write to 'aux' at the end of the function.
      b606013c
  2. Mar 14, 2023
  3. Mar 01, 2023
    • Sven M. Hallberg's avatar
      bring the two loops in act_txtobj into alignment · 222781c8
      Sven M. Hallberg authored
      The function act_txtobj() performs two passes over the sequence of
      text operators. The first pass tracks position and length of the
      string. Then an array is allocated of the indicated length and a
      second pass fills it with the actual characters.
      
      The two passes must be close carbon copies of each other or a mismatch
      between the predetermined length and the actual number of characters
      produced might occur and cause the assertion "txtlen == idx" to fail.
      
      This code structure is obviously bad, a text book example of why code
      duplication should be avoided. Nevertheless, before rewriting it
      entirely, this patch at least corrects an immediate bug.
      
      Fixes #44.
      222781c8
    • Sven M. Hallberg's avatar
      get rid of ts variable in act_txtobj · fbbf2c68
      Sven M. Hallberg authored
      The node member of TextState_T seems to be written only in one place in
      parse_pagenode(), and in such a way that the assertion "ts->node == node"
      must always hold. So we might as well assign node where it said ts->node
      and get rid of ts completely.
      fbbf2c68
    • Sven M. Hallberg's avatar
      access text state consistently through node · 76cb6955
      Sven M. Hallberg authored
      This one line going through another variable seems to spurious.
      Note that ts is always equal to &node->ts.
      76cb6955
    • Sven M. Hallberg's avatar
      df03908f
    • Sven M. Hallberg's avatar
      avoid an assert in parse_fonts · dee6c415
      Sven M. Hallberg authored
      This is an assertion of the type that catches an error (in user-supplied
      data) that should be handled, namely the case where the /Font entry
      of a dictionary is expected to be itself a dictionary but isn't.
      The code already contains a path for the case where the /Font entry
      is missing (return false) and I suppose the same, including the
      TODO item "figure out how to handle", might as well apply instead
      of the assertion.
      
      Fixes #45.
      dee6c415
  4. Feb 28, 2023
  5. Feb 27, 2023
  6. Feb 17, 2023
  7. Jan 13, 2023
  8. Jan 06, 2023
  9. Jan 05, 2023
  10. Dec 21, 2022
  11. Dec 20, 2022
    • Sven M. Hallberg's avatar
      style/comment · e10c9f98
      Sven M. Hallberg authored
      e10c9f98
    • Sven M. Hallberg's avatar
      lzw: simplify grammar by using h_bind to choose code length · 8e6bcd9c
      Sven M. Hallberg authored
      This replaces the validations on code9 etc. with one continuation that
      picks the appropriate parser.
      
      Also relaxes the parser to allow further output codes after the table is
      full. Looking at the spec, it seems to me at this times that the
      requirement for a clear code when the table is full is a requirement on
      producers of PDF files, but not on the file format itself. As far as I
      understand, conforming files can be created by a non-conforming process.
      
      Note: The implementation uses a slight trick to handle the last code
      (4095) correctly. Quoting the comment in act_output():
      
          Rather than going through the effort of ensuring that the last
          code is only updated once, we simply assign one more code as a
          dummy.
      
      So, the table is now 4097 entries in actual size. The last one will
      receive a bogus update every cycle, so that the last real code does not.
      This is less work than actually detecting and avoiding the bogus updates.
      8e6bcd9c
  12. Dec 19, 2022
Loading