Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

fixed segfault when file does not exist #10

Open
wants to merge 77 commits into
base: master
Choose a base branch
from
Open

Conversation

cyocum
Copy link
Contributor

@cyocum cyocum commented Apr 24, 2018

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:

{
  "type": "source",
  "media": {
    "encoding": "utf-8",
    "type": "text/x.cucumber.gherkin+plain"
  },
  "uri": "test.fea",
  "data": " "
}
{
  "type": "gherkin-document",
  "uri": "test.fea",
  "document": {
    "type": "GherkinDocument",
    "comments": []
  }
}

aslakhellesoy and others added 30 commits March 12, 2017 21:46
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.
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"
Chris Yocum and others added 28 commits January 25, 2018 10:06
* Added VERSION file
* Removed make install/unintstall
* Added cat'ing the VERSION file to create the libgherkin file name
* Added libs_so to all target
* Removed erroneous dependancy on ../bin/gherkin
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.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants