This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
fixed segfault when file does not exist #10
Open
cyocum
wants to merge
77
commits into
master
Choose a base branch
from
file_not_exist
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.
Conversation
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
On Alpine Linux 3.5 running in Docker swprintf does not handle the format string L"%hs" properly and the written string becomes empty, therefore swprintf cannot be used to convert the uri:s passed as argument (as char*) to wide characters (wchar_t*). To work around this the uri:s are converted manually character by character, taking into account that the uri is utf8 coded (which only make a difference if the uri contains non-ascii characters).
On Windows wchar_t is 2 bytes large, and use UTF-16. This means that for the case of code points > 0xFFFF (and wchar_t is only 2 bytes large), the code point read from the UTF-8 source need to be converted to two UTF-16 surrogates (wchar_t wide characters).
Windows does not use UTF-8 by default. To make sure that UTF-8 is used in the output, do manual conversion from unicode/UTF-16 to an UTF-8 byte sequence for output. It seems safer that to try to add Windows specific code to set UTF-8 output on that platform.
To support a wider range of compilers, remove the C90 breaches so that the code compiles also with -ansi and/or -std=c90 (using gcc). Another reason to not use swprintf is that on many Windows compilers swprintf has a different signature than the ISO standard specification. When cleaning up commented out code in gherkin_generate_tokens.c (to remove the usage of // for comments), settle to use the FileTokenScanner to get coverage of it in the acceptance tests. The code does not compile with -std=c90 -pedantic (using gcc), the conformance to C90 is not taken that far.
Technically C does not support repeated typedefs until C11, however modern compilers do allow it (gcc also using -std=c90). But since gcc <v4.6 does not support that, remove the usage of them.
CMake support
Fixes #266
Sharing tag objects between Pickles from Scenario Outlines can result in segmentation fault.
Tescase illustrating a segfault
subrepo: subdir: "gherkin/c" merged: "7d673816" upstream: origin: "https://github.com/cucumber/gherkin-c.git" branch: "master" commit: "62e7ab25" git-subrepo: version: "0.4.0" origin: "https://github.com/ingydotnet/git-subrepo" commit: "db54757"
gherkin: add language parameter to API
* Added VERSION file * Removed make install/unintstall * Added cat'ing the VERSION file to create the libgherkin file name
This reverts commit 1cc5148.
* Added libs_so to all target * Removed erroneous dependancy on ../bin/gherkin
Travis artifacts
Added a test for this. Updated other language implementations. The Obj-C implementation does not appear to support pickles so I didn't change it. There is a generated parser change in the javascript. Not sure why - if it was accidentally left out before, or is environmental ( different versions of something?)
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This addresses #9 by checking the if the result of fopen is NULL. If it is, it puts a space character in the buffer then returns it. This causes the system to complete successfully with the following output from gherkin-cli: