This repository was archived by the owner on Jul 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 345
Minor fixes and cleanup #1
Open
josharian
wants to merge
5
commits into
rsc:master
Choose a base branch
from
josharian:nyt
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// generated by stringer -type=ValueKind; DO NOT EDIT | ||
|
||
package pdf | ||
|
||
import "fmt" | ||
|
||
const _ValueKind_name = "NullBoolIntegerRealStringNameDictArrayStream" | ||
|
||
var _ValueKind_index = [...]uint8{4, 8, 15, 19, 25, 29, 33, 38, 44} | ||
|
||
func (i ValueKind) String() string { | ||
if i < 0 || i >= ValueKind(len(_ValueKind_index)) { | ||
return fmt.Sprintf("ValueKind(%d)", i) | ||
} | ||
hi := _ValueKind_index[i] | ||
lo := uint8(0) | ||
if i > 0 { | ||
lo = _ValueKind_index[i-1] | ||
} | ||
return _ValueKind_name[lo:hi] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this panic here might cause undocumented and unexpected problems for users. I was using the package earlier on the bus back from school and wrote code that invoked p.Content() without explicitly checking the Kind(). Perhaps we can just make an explicit check for Array then let the contentForStream handle be the catch all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there other known cases? Would contentForStream handle them correctly?
It's been ages since I've looked at this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question @josharian: I am not sure, I am not well versed with the PDF spec but I thought it was a little unexpected to panic on other types. So far I've only seen mentions of Stream and Array for "Content" in the spec.
Perhaps: I think it would handle the "other cases" properly because it contains the almost the same code before this patch, and that has worked in the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or it was silently returning junk before this patch. I'd rather be explicit, all else being equal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, yap that makes sense to me now.