Re: [sqlite] Get rid of old-style function declarations/definitions in lemon.c

2017-04-14 Thread Guy Harris
On Apr 14, 2017, at 3:59 AM, Richard Damon  wrote:

> In C (as opposed to C++), it is the only way to provide a real prototype for 
> such a function. The empty parameter list means with an unspecified parameter 
> list in C.

Exactly.  Perhaps some future C standard will finally get rid of that support 
for legacy C, but, for now, if you want to say "this function takes no 
arguments", you have no choice but to declare it as noargs(void) - and I think 
explicitly declaring that is a Very Good Thing, as it means that the compiler 
will reject calls to the function that pass it arguments, as it should.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Get rid of old-style function declarations/definitions in lemon.c

2017-04-14 Thread Richard Damon

On 4/14/17 4:47 AM, Dominique Devienne wrote:

On Fri, Apr 14, 2017 at 4:54 AM, Guy Harris  wrote:


On Apr 13, 2017, at 2:36 AM, Dominique Devienne 
wrote:




-PRIVATE struct config *newconfig(){
+PRIVATE struct config *newconfig(void){


Personally I've never been a fan of explicitly "void'ing" arg-less
functions. FWIW.
But I do see others (in the patch's unchanged text), so why not.
Let's now see if DRH applies your patch or not. --DD

In C (as opposed to C++), it is the only way to provide a real prototype 
for such a function. The empty parameter list means with an unspecified 
parameter list in C.


--
Richard Damon

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Get rid of old-style function declarations/definitions in lemon.c

2017-04-14 Thread Dominique Devienne
On Fri, Apr 14, 2017 at 4:54 AM, Guy Harris  wrote:

> On Apr 13, 2017, at 2:36 AM, Dominique Devienne 
> wrote:
>


> -PRIVATE struct config *newconfig(){
> +PRIVATE struct config *newconfig(void){
>

Personally I've never been a fan of explicitly "void'ing" arg-less
functions. FWIW.
But I do see others (in the patch's unchanged text), so why not.
Let's now see if DRH applies your patch or not. --DD
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Get rid of old-style function declarations/definitions in lemon.c

2017-04-13 Thread Guy Harris
On Apr 13, 2017, at 2:36 AM, Dominique Devienne  wrote:

> On Thu, Apr 13, 2017 at 6:18 AM, Guy Harris  wrote:
> 
>> Here's a patch, against the current Fossil repository, including some
>> changes we've made to lemon.c in Wireshark, that gets rid of old-style K
>> function definitions/declarations, and also removes trailing white space
>> from some lines (the Wireshark pre-commit hook complains about them):
> 
> Attachments are stripped on this list.
> Paste the diff/patch as text in your message,
> if you want it to be considered. --DD

OK:

Index: tool/lemon.c
==
--- tool/lemon.c
+++ tool/lemon.c
@@ -166,16 +166,16 @@
 
 static struct action *Action_new(void);
 static struct action *Action_sort(struct action *);
 
 /** From the file "build.h" /
-void FindRulePrecedences();
-void FindFirstSets();
-void FindStates();
-void FindLinks();
-void FindFollowSets();
-void FindActions();
+void FindRulePrecedences(struct lemon *);
+void FindFirstSets(struct lemon *);
+void FindStates(struct lemon *);
+void FindLinks(struct lemon *);
+void FindFollowSets(struct lemon *);
+void FindActions(struct lemon *);
 
 /* From the file "configlist.h" */
 void Configlist_init(void);
 struct config *Configlist_add(struct rule *, int);
 struct config *Configlist_addbasis(struct rule *, int);
@@ -455,11 +455,11 @@
 int Configcmp(const char *, const char *);
 struct state *State_new(void);
 void State_init(void);
 int State_insert(struct state *, struct config *);
 struct state *State_find(struct config *);
-struct state **State_arrayof(/*  */);
+struct state **State_arrayof(void);
 
 /* Routines used for efficiency in Configlist_add */
 
 void Configtable_init(void);
 int Configtable_insert(struct config *);
@@ -559,12 +559,12 @@
 ** of the lookahead input, then the value of the action_number output is
 ** aAction[X].action.  If the lookaheads do not match then the
 ** default action for the state_number is returned.
 **
 ** All actions associated with a single state_number are first entered
-** into aLookahead[] using multiple calls to acttab_action().  Then the 
-** actions for that single state_number are placed into the aAction[] 
+** into aLookahead[] using multiple calls to acttab_action().  Then the
+** actions for that single state_number are placed into the aAction[]
 ** array with a single call to acttab_insert().  The acttab_insert() call
 ** also resets the aLookahead[] array in preparation for the next
 ** state number.
 */
 struct lookahead_action {
@@ -610,11 +610,11 @@
   }
   memset(p, 0, sizeof(*p));
   return p;
 }
 
-/* Add a new action to the current transaction set.  
+/* Add a new action to the current transaction set.
 **
 ** This routine is called once for each lookahead for a particular
 ** state.
 */
 void acttab_action(acttab *p, int lookahead, int action){
@@ -672,11 +672,11 @@
   p->aAction[i].lookahead = -1;
   p->aAction[i].action = -1;
 }
   }
 
-  /* Scan the existing action table looking for an offset that is a 
+  /* Scan the existing action table looking for an offset that is a
   ** duplicate of the current transaction set.  Fall out of the loop
   ** if and when the duplicate is found.
   **
   ** i is the index in p->aAction[] where p->mnLookahead is inserted.
   */
@@ -750,11 +750,11 @@
 ** Routines to construction the finite state machine for the LEMON
 ** parser generator.
 */
 
 /* Find a precedence symbol of every rule in the grammar.
-** 
+**
 ** Those rules which have a precedence symbol coded in the input
 ** grammar using the "[symbol]" construct will already have the
 ** rp->precsym field filled.  Other rules take as their precedence
 ** symbol the first RHS symbol with a defined precedence.  If there
 ** are not RHS symbols with a defined precedence, the precedence
@@ -1070,11 +1070,11 @@
   for(i=0; instate; i++){
 for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){
   cfp->status = INCOMPLETE;
 }
   }
-  
+
   do{
 progress = 0;
 for(i=0; instate; i++){
   for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){
 if( cfp->status==COMPLETE ) continue;
@@ -1101,11 +1101,11 @@
   struct config *cfp;
   struct state *stp;
   struct symbol *sp;
   struct rule *rp;
 
-  /* Add all of the reduce actions 
+  /* Add all of the reduce actions
   ** A reduce action is added for each element of the followset of
   ** a configuration which has its dot at the extreme right.
   */
   for(i=0; instate; i++){   /* Loop over all states */
 stp = lemp->sorted[i];
@@ -1218,11 +1218,11 @@
   apy->type = RD_RESOLVED;
 }else if( spx->precprec ){
   apx->type = RD_RESOLVED;
 }
   }else{
-assert( 
+assert(
   apx->type==SH_RESOLVED ||
   apx->type==RD_RESOLVED ||
   apx->type==SSCONFLICT ||
   apx->type==SRCONFLICT ||
   

Re: [sqlite] Get rid of old-style function declarations/definitions in lemon.c

2017-04-13 Thread Dominique Devienne
On Thu, Apr 13, 2017 at 6:18 AM, Guy Harris  wrote:

> Here's a patch, against the current Fossil repository, including some
> changes we've made to lemon.c in Wireshark, that gets rid of old-style K
> function definitions/declarations, and also removes trailing white space
> from some lines (the Wireshark pre-commit hook complains about them):
>

Attachments are stripped on this list.
Paste the diff/patch as text in your message,
if you want it to be considered. --DD
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Get rid of old-style function declarations/definitions in lemon.c

2017-04-12 Thread Guy Harris
Here's a patch, against the current Fossil repository, including some changes 
we've made to lemon.c in Wireshark, that gets rid of old-style K function 
definitions/declarations, and also removes trailing white space from some lines 
(the Wireshark pre-commit hook complains about them):

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users