Oh ;-D Now how to revert... eek.
Once I figure this out, I'll add a comment with a link to your post to each instance, so future confusion is unlikely. G On Thu, Apr 16, 2015 at 4:11 PM, Peter Kelly <[email protected]> wrote: > These unfortunately need to be there to compile on windows… despite Visual > Studio 2013 finally introducing C99 support it has a nasty bug which these > workaround. See commit 5bb67bd9a30be5b09b33ef480eb36d124c4af8ab, for which > I’ve included the log message below. > > Once the final release of VS 2015 is, if it fixes this bug, i’d be in > favour of making this a requirement for builds, provided it runs on windows > 7. Has anyone on the list tried it yet - and thoughts? > > commit 5bb67bd9a30be5b09b33ef480eb36d124c4af8ab > Author: Peter Kelly <[email protected]> > Date: Tue Aug 26 22:20:33 2014 +0700 > > Win32: Use ;; to work around VC++ parser bug > > When Visual Studio 2013 attempts to compile a C99 file (*not* C++), the > parser chokes whenever it encounters a variable declaration directly > after an if statement that lacks braces, when the type of that variable > declaration is either const or a typedef. > > For example, if you try compile the following code: > > if (count < 1) > return; > size_t len = 0; > > you will see this error message: > > error C2275: 'size_t' : illegal use of this type as an expression > > In contrast, the following compiles successfully: > > if (count < 1) > return; > int len = 0; > > In the first case, size_t is a typedef, and the parser seems to lack > the > context information during the parsing process to identify it as a > type, > and instead mistakes it for part of an expression. It's intetresting to > note that this problem does not occur after for or while loops. > > There are three possible solutions to this: > > 1. Always declare variables at the start of a given scope (C89-style) > 2. Put braces around the if body > 3. Add a second semicolon to the end of the if body > > Of these three, the last is the least intrusive (in terms of code > changes), and allows us to continue using single-line, no-brace bodies > for if statements. In total, there are currently 152 cases throughout > the codebase where this change has been made. The first example above > would now be written as: > > if (count < 1) > return;; > size_t len = 0; > > VS 2013 is the first version to claim support for C99 (yes, really). > Hopefully in VS 2014 this problem will be fixed, and we can go back to > using single semicolons, as has worked fine in gcc & clang for many > years. > > — > Dr Peter M. Kelly > [email protected] > > PGP key: http://www.kellypmk.net/pgp-key <http://www.kellypmk.net/pgp-key> > (fingerprint 5435 6718 59F0 DD1F BFA0 5E46 2523 BAA1 44AE 2966) > > > On 16 Apr 2015, at 8:35 pm, [email protected] wrote: > > > > Repository: incubator-corinthia > > Updated Branches: > > refs/heads/master 7015ab06f -> d82ca17f9 > > > > > > Fixed double ';;' in the listed files and functions. > > > > * DocFormats/core/src/xml/DFChanges.c > > (DFRecordChanges). > > > > * DocFormats/core/src/xml/DFNameMap.c > > (DFNameHashTableHash). > > (DFNameHashTableAdd). > > (DFNameMapFree). > > (DFNameMapFoundNamespace). > > (DFNameMapFoundNamespace). > > (DFNameMapNamespaceCount). > > (DFNameMapTagForName). > > > > * DocFormats/core/src/xml/DFXML.c > > (SAXComment). > > (SAXProcessingInstruction). > > (writeNode). > > (DFParseXMLFile). > > (DFParseXMLStorage). > > > > > > Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo > > Commit: > http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/d82ca17f > > Tree: > http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/d82ca17f > > Diff: > http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/d82ca17f > > > > Branch: refs/heads/master > > Commit: d82ca17f909840ec25d91f0f780c8c0621b9f683 > > Parents: 7015ab0 > > Author: Gabriela Gibson <[email protected]> > > Authored: Thu Apr 16 14:35:12 2015 +0100 > > Committer: Gabriela Gibson <[email protected]> > > Committed: Thu Apr 16 14:35:12 2015 +0100 > > > > ---------------------------------------------------------------------- > > DocFormats/core/src/xml/DFChanges.c | 2 +- > > DocFormats/core/src/xml/DFNameMap.c | 14 +++++++------- > > DocFormats/core/src/xml/DFXML.c | 10 +++++----- > > 3 files changed, 13 insertions(+), 13 deletions(-) > > ---------------------------------------------------------------------- > > > > > > > http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d82ca17f/DocFormats/core/src/xml/DFChanges.c > > ---------------------------------------------------------------------- > > diff --git a/DocFormats/core/src/xml/DFChanges.c > b/DocFormats/core/src/xml/DFChanges.c > > index c67b0f0..8b1ebe5 100644 > > --- a/DocFormats/core/src/xml/DFChanges.c > > +++ b/DocFormats/core/src/xml/DFChanges.c > > @@ -129,7 +129,7 @@ static void DFRecordChanges(DFNode *parent1, Tag > idAttr, DFHashTable *map) > > parent1->changed = 1; // keep going - still want to check the > children > > > > if (!identicalAttributesExcept(parent1,parent2,0)) > > - parent1->changed = 1;; // keep going - still want to check the > children > > + parent1->changed = 1; // keep going - still want to check the > children > > > > DFNode *child1 = parent1->first; > > DFNode *child2 = parent2->first; > > > > > http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d82ca17f/DocFormats/core/src/xml/DFNameMap.c > > ---------------------------------------------------------------------- > > diff --git a/DocFormats/core/src/xml/DFNameMap.c > b/DocFormats/core/src/xml/DFNameMap.c > > index eb5d868..a175944 100644 > > --- a/DocFormats/core/src/xml/DFNameMap.c > > +++ b/DocFormats/core/src/xml/DFNameMap.c > > @@ -64,7 +64,7 @@ static uint32_t DFNameHashTableHash(const char *name, > const char *URI) > > static const DFNameEntry *DFNameHashTableGet(DFNameHashTable *table, > const char *name, const char *URI) > > { > > if (URI == NULL) > > - URI = "";; > > + URI = ""; > > uint32_t hash = DFNameHashTableHash(name,URI)%HASH_TABLE_SIZE; > > for (DFNameEntry *entry = table->bins[hash]; entry != NULL; entry = > entry->next) { > > if (!strcmp(name,entry->name) && !strcmp(URI,entry->URI)) > > @@ -77,7 +77,7 @@ static void DFNameHashTableAdd(DFNameHashTable *table, > const char *name, const c > > Tag tag, unsigned int namespaceID) > > { > > if (URI == NULL) > > - URI = "";; > > + URI = ""; > > uint32_t hash = DFNameHashTableHash(name,URI)%HASH_TABLE_SIZE; > > DFNameEntry *entry = (DFNameEntry *)xmalloc(sizeof(DFNameEntry)); > > entry->name = xstrdup(name); > > @@ -218,7 +218,7 @@ void DFNameMapFree(DFNameMap *map) > > static NamespaceID NameMap_namespaceIDForURI(DFNameMap *map, const char > *URI) > > { > > if (URI == NULL) > > - return NAMESPACE_NULL;; > > + return NAMESPACE_NULL; > > DFNamespaceInfo *ns = DFHashTableLookup(map->namespacesByURI,(const > char *)URI); > > if (ns == NULL) { > > ns = DFHashTableLookup(defaultNamespacesByURI,(const char *)URI); > > @@ -246,7 +246,7 @@ NamespaceID DFNameMapFoundNamespace(DFNameMap *map, > const char *URI, const char > > return existing->nsId; > > existing = DFHashTableLookup(map->namespacesByURI,(const char *)URI); > > if (existing != NULL) > > - return existing->nsId;; > > + return existing->nsId; > > NamespaceID nsId = map->nextNamespaceId++; > > DFNameMapAddNamespace(map,nsId,URI,prefix); > > return nsId; > > @@ -255,7 +255,7 @@ NamespaceID DFNameMapFoundNamespace(DFNameMap *map, > const char *URI, const char > > const NamespaceDecl *DFNameMapNamespaceForID(DFNameMap *map, NamespaceID > nsId) > > { > > if (nsId < PREDEFINED_NAMESPACE_COUNT) > > - return &PredefinedNamespaces[nsId];; > > + return &PredefinedNamespaces[nsId]; > > DFNamespaceInfo *ns = DFHashTableLookupInt(map->namespacesByID,nsId); > > assert(ns != NULL); > > return ns->decl; > > @@ -269,7 +269,7 @@ NamespaceID DFNameMapNamespaceCount(DFNameMap *map) > > const TagDecl *DFNameMapNameForTag(DFNameMap *map, Tag tag) > > { > > if (tag < PREDEFINED_TAG_COUNT) > > - return &PredefinedTags[tag];; > > + return &PredefinedTags[tag]; > > DFTagInfo *info = DFHashTableLookupInt(map->tagsByID,tag); > > assert(info != NULL); > > return info->decl; > > @@ -282,7 +282,7 @@ Tag DFNameMapTagForName(DFNameMap *map, const char > *URI, const char *localName) > > entry = > DFNameHashTableGet(map->localTagsByNameURI,localName,URI); > > > > if (entry != NULL) > > - return entry->tag;; > > + return entry->tag; > > > > // Dynamically allocate new tag > > NamespaceID nsId = NameMap_namespaceIDForURI(map,URI); > > > > > http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d82ca17f/DocFormats/core/src/xml/DFXML.c > > ---------------------------------------------------------------------- > > diff --git a/DocFormats/core/src/xml/DFXML.c > b/DocFormats/core/src/xml/DFXML.c > > index 449f2e1..4c9ea3e 100644 > > --- a/DocFormats/core/src/xml/DFXML.c > > +++ b/DocFormats/core/src/xml/DFXML.c > > @@ -239,7 +239,7 @@ static void SAXComment(void *ctx, const xmlChar > *value) > > { > > DFSAXParser *parser = (DFSAXParser *)ctx; > > if (parser->ignoreDepth > 0) > > - return;; > > + return; > > DFNode *comment = DFCreateComment(parser->document,(const char > *)value); > > assert(parser->parent != NULL); > > DFAppendChild(parser->parent,comment); > > @@ -263,7 +263,7 @@ static void SAXProcessingInstruction(void *ctx, > const xmlChar *target, const xml > > { > > DFSAXParser *parser = (DFSAXParser *)ctx; > > if (parser->ignoreDepth > 0) > > - return;; > > + return; > > DFNode *pi = DFCreateProcessingInstruction(parser->document,(const > char *)target,(const char *)data); > > assert(parser->parent != NULL); > > DFAppendChild(parser->parent,pi); > > @@ -334,7 +334,7 @@ static void writeNode(Serialization *serialization, > DFNode *node, int depth); > > static void findUsedNamespaces(DFDocument *doc, DFNode *node, char > *used, NamespaceID count) > > { > > if (node->tag < MIN_ELEMENT_TAG) > > - return;; > > + return; > > const TagDecl *tagDecl = DFNameMapNameForTag(doc->map,node->tag); > > assert(tagDecl != NULL); > > assert(tagDecl->namespaceID < count); > > @@ -554,7 +554,7 @@ DFDocument *DFParseXMLFile(const char *filename, > DFError **error) > > { > > DFBuffer *buf = DFBufferReadFromFile(filename,error); > > if (buf == NULL) > > - return NULL;; > > + return NULL; > > DFDocument *doc = DFParseXMLString(buf->data,error); > > DFBufferRelease(buf); > > return doc; > > @@ -564,7 +564,7 @@ DFDocument *DFParseXMLStorage(DFStorage *storage, > const char *filename, DFError > > { > > DFBuffer *content = DFBufferReadFromStorage(storage,filename,error); > > if (content == NULL) > > - return NULL;; > > + return NULL; > > DFDocument *doc = DFParseXMLString(content->data,error); > > DFBufferRelease(content); > > return doc; > > > > -- Visit my Coding Diary: http://gabriela-gibson.blogspot.com/
