#include #include "proto.h" /* Avance dans un liste de token jusqu'a une ouverture parenthèse. nbskip permet de sauter un certain nombre de parenthèse avant de retourner. Retourne -1 si erreur */ int cproto_findpar (TOKEN_LIST *tokl, int nbskip) { int ret = -1; TOKEN *tok; while ((tok=tokrec_get (tokl))!=NULL){ if (tok->type == TOK_OPNPAR){ if (nbskip == 0){ ret = 0; break; } nbskip--; } tokrec_next (tokl); } return ret; } /* Verifie si un debut de collecte est un declaration nouvelle ou ancienne Retourne 1 si ancien, 0 si nouveau (ansi) Retourne -1 si invalide tokl contient ... ( ... ) Attention: Si la fonction n'a pas d'argument, cette fonction retourne 1 comme si c'était une déclaration K&R. Dans ce cas, il n'y a pas de différence de syntaxe. */ int cproto_isold (TOKEN_LIST *tokl) { int old = -1; TOKEN *tok; tokrec_inilec (tokl); if (cproto_findpar (tokl,0)!=-1){ int nbid = 0; tokrec_descend (tokl); old = 1; if ((tok=tokrec_get(tokl))!=NULL && tok->type == TOK_STAR){ /* Fonction qui retourne pointeur de fonction */ if (cproto_findpar(tokl,0) != -1){ tokrec_descend (tokl); } } while ((tok=tokrec_get (tokl))!=NULL && tok->type != TOK_CLSPAR){ if (tok->type == TOK_ID){ if (nbid > 0) old = 0; nbid++; }else if (tok->type == TOK_VIRGULE){ nbid = 0; }else{ old = 0; } tokrec_next (tokl); } } return old; }