From: evans1629 Date: Fri, 31 May 2002 20:33:14 +0000 (+0000) Subject: Committed to enable merge. X-Git-Tag: splint-3_1_0~111 X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/commitdiff_plain/140c27a82ebb7e4c8d1e59ab5fce12c793e587f8 Committed to enable merge. --- diff --git a/lib/unix.h b/lib/unix.h index 00e01fc..ea5cb03 100644 --- a/lib/unix.h +++ b/lib/unix.h @@ -290,22 +290,24 @@ int ioctl (int d, int /*@alt long@*/ request, /*@out@*/ void *arg) pid_t vfork (void) /*@modifies fileSystem@*/ ; +/* +** sys/uio.h +*/ struct iovec { - void *iov_base; - size_t iov_len; + void *iov_base; + size_t iov_len; /*: maxSet(iov_base) = iov_len */ }; +/* from limits.h */ /*@constant int UIO_MAXIOV@*/ /* BSD */ /*@constant int IOV_MAX@*/ /* supposedly SVR4 */ - extern ssize_t -readv (int fd, const struct iovec iov[], int iovcnt) - /*@modifies iov[].iov_base, fileSystem, errno@*/; +ssize_t readv (int fd, const struct iovec *iov, int iovcnt) + /*@modifies iov->iov_base, fileSystem, errno@*/; - extern ssize_t -writev (int fd, const struct iovec iov[], int iovcnt) - /*@modifies errno@*/; +ssize_t writev (int fd, const struct iovec *iov, int iovcnt) + /*@modifies errno@*/; /*________________________________________________________________________ * poll.h @@ -343,34 +345,34 @@ extern void free (/*@notnull@*/ /*@out@*/ /*@only@*/ void *p) /*@modifies *p@*/ * sys/socket.h */ -/*@constant int SOCK_STREAM@*/ -/*@constant int SOCK_DGRAM@*/ -/*@constant int SOCK_RAW@*/ + + + /*@constant int SOCK_RDM@*/ -/*@constant int SOCK_SEQPACKET@*/ -/*@constant int SO_DEBUG@*/ -/*@constant int SO_ACCEPTCONN@*/ -/*@constant int SO_REUSEADDR@*/ -/*@constant int SO_KEEPALIVE@*/ -/*@constant int SO_DONTROUTE@*/ -/*@constant int SO_BROADCAST@*/ + + + + + + + /*@constant int SO_USELOOPBACK@*/ -/*@constant int SO_LINGER@*/ -/*@constant int SO_OOBINLINE@*/ + + /*@constant int SO_REUSEPORT@*/ -/*@constant int SO_SNDBUF@*/ -/*@constant int SO_RCVBUF@*/ -/*@constant int SO_SNDLOWAT@*/ -/*@constant int SO_RCVLOWAT@*/ -/*@constant int SO_SNDTIMEO@*/ -/*@constant int SO_RCVTIMEO@*/ -/*@constant int SO_ERROR@*/ -/*@constant int SO_TYPE@*/ -/*@constant int SOL_SOCKET@*/ -/*@constant int AF_UNSPEC@*/ + + + + + + + + + + /*@constant int AF_LOCAL@*/ -/*@constant int AF_UNIX@*/ -/*@constant int AF_INET@*/ + + /*@constant int AF_IMPLINK@*/ /*@constant int AF_PUP@*/ /*@constant int AF_CHAOS@*/ @@ -398,13 +400,12 @@ extern void free (/*@notnull@*/ /*@out@*/ /*@only@*/ void *p) /*@modifies *p@*/ /*@constant int AF_ISDN@*/ /*@constant int AF_E164@*/ /*@constant int AF_MAX@*/ -/*@constant int MSG_OOB@*/ -/*@constant int MSG_PEEK@*/ -/*@constant int MSG_DONTROUTE@*/ -/*@constant int MSG_EOR@*/ -/*@constant int MSG_TRUNC@*/ -/*@constant int MSG_CTRUNC@*/ -/*@constant int MSG_WAITALL@*/ + + + + + + /*@constant int MSG_DONTWAIT@*/ /*@constant int MSG_EOF@*/ /*@constant int MSG_COMPAT@*/ @@ -443,58 +444,119 @@ extern void free (/*@notnull@*/ /*@out@*/ /*@only@*/ void *p) /*@modifies *p@*/ /*@constant int NET_RT_FLAGS@*/ /*@constant int NET_RT_IFLIST@*/ /*@constant int NET_RT_MAXID@*/ -/*@constant int SOMAXCONN@*/ -/*@constant int SCM_RIGHTS@*/ - struct sockaddr { - u_char sa_len; /* total length */ - u_char sa_family; /* address family */ - char sa_data[14]; /* actually longer; address value */ -}; - struct linger { - int l_onoff; /* option on/off */ - int l_linger; /* linger time */ -}; - struct sockproto { - u_short sp_family; /* address family */ - u_short sp_protocol; /* protocol */ +/* +** sys/socket.h +** (updated 26 May 2002) +*/ + +typedef /*@unsignedintegraltype@*/ socklen_t; + +struct sockaddr { + sa_family_t sa_family; /* address family */ + char sa_data[]; /* variable length */ }; - struct msghdr { - caddr_t msg_name; /* optional address */ - u_int msg_namelen; /* size of address */ - struct iovec *msg_iov; /* scatter/gather array */ - u_int msg_iovlen; /* # elements in msg_iov */ - caddr_t msg_control; /* ancillary data, see below */ - u_int msg_controllen; /* ancillary data buffer len */ - int msg_flags; /* flags on received message */ + +struct sockaddr_storage { + sa_family_t ss_family; +} ; + +struct msghdr { + void *msg_name; + socklen_t msg_namelen; /*: maxSet (msg_name) >= msg_namelen */ + struct iovec *msg_iov; /* scatter/gather array */ + int msg_iovlen; /* # elements in msg_iov */ /*: maxSet (msg_iov) >= msg_iovlen */ + void *msg_control; /* ancillary data, see below */ + socklen_t msg_controllen; /*: maxSet (msg_control) >= msg_controllen */ + int msg_flags; /* flags on received message */ +} ; + +struct cmsghdr { + socklen_t cmsg_len; /* data byte count, including hdr */ + int cmsg_level; /* originating protocol */ + int cmsg_type; /* protocol-specific type */ +} ; + +/*@constant int SCM_RIGHTS@*/ + +/*@exposed@*/ unsigned char *CMSG_DATA (/*@sef@*/ struct cmsghdr *) /*@*/ ; +/*@null@*/ /*@exposed@*/ struct cmsghdr *CMSG_NXTHDR (struct msghdr *, struct cmsghdr *) /*@*/ ; +/*@null@*/ /*@exposed@*/ struct cmsghdr *CMSG_FIRSTHDR (struct msghdr *) /*@*/ ; + +struct linger { + int l_onoff; + int l_linger; }; - struct cmsghdr { - u_int cmsg_len; /* data byte count, including hdr */ - int cmsg_level; /* originating protocol */ - int cmsg_type; /* protocol-specific type */ -/* followed by u_char cmsg_data[]; */ +/*@constant int SOCK_DGRAM@*/ +/*@constant int SOCK_RAW@*/ +/*@constant int SOCK_SEQPACKET@*/ +/*@constant int SOCK_STREAM@*/ + +/*@constant int SOL_SOCKET@*/ + +/*@constant int SO_ACCEPTCONN@*/ +/*@constant int SO_BROADCAST@*/ +/*@constant int SO_DEBUG@*/ +/*@constant int SO_DONTROUTE@*/ +/*@constant int SO_ERROR@*/ +/*@constant int SO_KEEPALIVE@*/ +/*@constant int SO_LINGER@*/ +/*@constant int SO_OOBINLINE@*/ +/*@constant int SO_RCVBUF@*/ +/*@constant int SO_RCVLOWAT@*/ +/*@constant int SO_RCVTIMEO@*/ +/*@constant int SO_REUSEADDR@*/ +/*@constant int SO_SNDBUF@*/ +/*@constant int SO_SNDLOWAT@*/ +/*@constant int SO_SNDTIMEO@*/ +/*@constant int SO_TYPE@*/ + +/*@constant int SOMAXCONN@*/ + +/*@constant int MSG_CTRUNC@*/ +/*@constant int MSG_DONTROUTE@*/ +/*@constant int MSG_EOR@*/ +/*@constant int MSG_OOB@*/ +/*@constant int MSG_PEEK@*/ +/*@constant int MSG_TRUNC@*/ +/*@constant int MSG_WAITALL@*/ + +/*@constant int AF_INET@*/ +/*@constant int AF_INET6@*/ +/*@constant int AF_UNIX@*/ +/*@constant int AF_UNSPEC@*/ + +/*@constant int SHUT_RD@*/ +/*@constant int SHUT_RDWR@*/ +/*@constant int SHUT_WR@*/ + +# if 0 +/* +** These were in the old unix.h spec, but are not in SUS6 +*/ + +struct sockproto { + u_short sp_family; /* address family */ + u_short sp_protocol; /* protocol */ }; - extern int -accept (int s, struct sockaddr *addr, int *addrlen) - /*@modifies *addrlen, errno@*/; +# endif - extern int -bind (int s, struct sockaddr *name, int namelen) - /*@modifies errno, fileSystem@*/; +int accept (int s, struct sockaddr *addr, int *addrlen) + /*@modifies *addrlen, errno@*/; - extern int -connect (int s, struct sockaddr *name, int namelen) - /*@modifies errno, internalState@*/; +int bind (int s, const struct sockaddr *name, int namelen) + /*@modifies errno, fileSystem@*/; -int getpeername (int s, /*@out@*/ struct sockaddr *name, size_t *namelen) - /*@modifies *name, *namelen, errno@*/; - - typedef /*@unsignedintegraltype@*/ socklen_t; +int connect (int s, const struct sockaddr *name, int namelen) + /*@modifies errno, internalState@*/; +int getpeername (int s, /*@out@*/ struct sockaddr *restrict name, socklen_t *restrict namelen) + /*@modifies *name, *namelen, errno@*/; + #ifdef STRICT int getsockname (int s, /*@out@*/ struct sockaddr *address, socklen_t *address_len) @@ -856,46 +918,37 @@ int gethostname (/*@out@*/ char *address, size_t address_len) int initgroups (const char *name, int basegid) /*@modifies internalState@*/; - extern int -lchown (const char *path, uid_t owner, gid_t group) - /*@modifies errno, fileSystem@*/; - - extern int -select (int mfd, fd_set /*@null@*/ *r, fd_set /*@null@*/ *w, fd_set /*@null@*/ *e, struct timeval *t) - /*@modifies *r, *w, *e, *t, errno@*/; - - extern int -setegid (gid_t egid) - /*@modifies errno, internalState@*/; - - extern int -seteuid (uid_t euid) - /*@modifies errno, internalState@*/; - - extern int -setgroups (int ngroups, const gid_t *gidset) - /*@modifies errno, internalState@*/; - - extern int -setregid (gid_t rgid, gid_t egid) - /*@modifies errno, internalState@*/; - - extern int -setreuid (gid_t ruid, gid_t euid) - /*@modifies errno, internalState@*/; - - extern void -sync (void) - /*@modifies fileSystem@*/; +int lchown (const char *path, uid_t owner, gid_t group) + /*@modifies errno, fileSystem@*/; + +int select (int mfd, fd_set /*@null@*/ *r, fd_set /*@null@*/ *w, fd_set /*@null@*/ *e, /*@null@*/ struct timeval *t) + /*@modifies *r, *w, *e, *t, errno@*/; + /* evans - 2002-05-26: added null for t, bug reported by Enrico Scholz */ - extern int -symlink (const char *path, const char *path2) - /*@modifies fileSystem@*/; - - extern int -truncate (const char *name, off_t length) - /*@modifies errno, fileSystem@*/; +int setegid (gid_t egid) + /*@modifies errno, internalState@*/; +int seteuid (uid_t euid) + /*@modifies errno, internalState@*/; + +int setgroups (int ngroups, const gid_t *gidset) + /*@modifies errno, internalState@*/; + +int setregid (gid_t rgid, gid_t egid) + /*@modifies errno, internalState@*/; + +int setreuid (gid_t ruid, gid_t euid) + /*@modifies errno, internalState@*/; + +void sync (void) + /*@modifies fileSystem@*/; + +int symlink (const char *path, const char *path2) + /*@modifies fileSystem@*/; + +int truncate (const char *name, off_t length) + /*@modifies errno, fileSystem@*/; + /*@constant int EBADRPC@*/ /*@constant int ERPCMISMATCH@*/ /*@constant int EPROGUNAVAIL@*/ diff --git a/src/Headers/basic.h b/src/Headers/basic.h index 79cf80d..b6007cd 100644 --- a/src/Headers/basic.h +++ b/src/Headers/basic.h @@ -110,6 +110,7 @@ # include "stateCombinationTable.h" # include "mtincludes.h" # include "functionConstraint.h" +# include "fileIdList.h" # include "context.h" # include "constants.h" diff --git a/src/Headers/cstringList.h b/src/Headers/cstringList.h index c076646..617ad97 100644 --- a/src/Headers/cstringList.h +++ b/src/Headers/cstringList.h @@ -27,6 +27,8 @@ extern /*@unused@*/ /*@falsewhennull@*/ bool cstringList_empty (/*@sef@*/ cstrin extern cstring cstringList_unparseSep (cstringList p_s, cstring p_sep) /*@*/ ; +extern /*@exposed@*/ /*@null@*/ bn_mstring *cstringList_getElements (cstringList) /*@*/ ; + extern /*@unused@*/ /*@only@*/ cstringList cstringList_new (void) /*@*/ ; extern /*@only@*/ cstringList cstringList_single (/*@keep@*/ cstring p_el) /*@*/ ; diff --git a/src/Headers/cstringSList.h b/src/Headers/cstringSList.h index 03c51dd..a1bf382 100644 --- a/src/Headers/cstringSList.h +++ b/src/Headers/cstringSList.h @@ -8,12 +8,12 @@ typedef /*@observer@*/ cstring ob_cstring; -abst_typedef /*@null@*/ struct s_cstringSList +struct s_cstringSList { int nelements; int nspace; /*@reldef@*/ /*@relnull@*/ ob_cstring *elements; -} *cstringSList ; +} ; /*@constant null cstringSList cstringSList_undefined;@*/ # define cstringSList_undefined ((cstringSList) NULL) @@ -42,7 +42,7 @@ extern void cstringSList_alphabetize (cstringSList p_s); extern /*@observer@*/ cstring cstringSList_get (cstringSList p_s, int p_index) /*@*/ ; extern /*@only@*/ cstring cstringSList_unparseAbbrev (cstringSList p_s) /*@*/ ; -extern /*@unused@*/ /*@only@*/ cstring cstringSList_unparse (cstringSList p_s) ; +extern /*@unused@*/ /*@only@*/ cstring cstringSList_unparse (cstringSList p_s) /*@*/ ; extern void cstringSList_free (/*@only@*/ cstringSList p_s) ; extern void cstringSList_printSpaced (cstringSList p_s, size_t p_indent, size_t p_gap, int p_linelen); diff --git a/src/Headers/ctypeList.h b/src/Headers/ctypeList.h index 7c3fecc..55823b7 100644 --- a/src/Headers/ctypeList.h +++ b/src/Headers/ctypeList.h @@ -13,12 +13,12 @@ ** (that is, not void, so any number of arguments is okay.) */ -abst_typedef /*@null@*/ struct +struct s_ctypeList { int nelements; int nspace; /*@reldef@*/ /*@relnull@*/ ctype *elements; -} *ctypeList ; +} ; extern int ctypeList_size (/*@sef@*/ ctypeList p_s) /*@*/ ; # define ctypeList_size(s) (ctypeList_isDefined(s) ? (s)->nelements : 0) diff --git a/src/Headers/fileIdList.h b/src/Headers/fileIdList.h index 0e5b171..a7c87f5 100644 --- a/src/Headers/fileIdList.h +++ b/src/Headers/fileIdList.h @@ -13,7 +13,9 @@ /*@access ctype fileId ctypeList@*/ /*@+allmacros@*/ -abst_typedef /*@null@*/ ctypeList fileIdList; +/* in forwardTypes: + abst_typedef null ctypeList fileIdList; +*/ extern /*@falsewhennull@*/ bool fileIdList_isDefined (fileIdList p_f); # define fileIdList_isDefined(f) (ctypeList_isDefined (f)) @@ -27,6 +29,9 @@ extern /*@falsewhennull@*/ bool fileIdList_isDefined (fileIdList p_f); # define end_fileIdList_elements }} +/*@constant null fileIdList fileIdList_undefined; @*/ +# define fileIdList_undefined ctypeList_undefined + extern fileIdList fileIdList_create (void); # define fileIdList_create() ctypeList_new() diff --git a/src/Headers/flags.h b/src/Headers/flags.h index 5f491ce..4cf14a2 100644 --- a/src/Headers/flags.h +++ b/src/Headers/flags.h @@ -105,8 +105,15 @@ extern bool flagcode_isHelpFlag (flagcode p_f) /*@*/ ; extern void flags_initMod (void) /*@modifies internalState@*/ ; -extern bool flags_processFlags (int p_argc, char **p_argv) - /*@requires maxRead(p_argv) >= p_argc - 1@*/ +extern void +flags_processFlags (bool p_inCommandLine, + fileIdList p_xfiles, + fileIdList p_cfiles, + fileIdList p_lclfiles, + fileIdList p_mtfiles, + cstringSList *p_passThroughArgs, + int p_argc, /*@null@*/ char **p_argv) + /*@requires maxRead(p_argv) >= (p_argc - 1) @*/ /* returns true if normal, false if execution should exit */ ; # else diff --git a/src/Headers/forwardTypes.h b/src/Headers/forwardTypes.h index 1f67834..73407d6 100644 --- a/src/Headers/forwardTypes.h +++ b/src/Headers/forwardTypes.h @@ -71,12 +71,12 @@ abst_typedef sRefSet globSet; abst_typedef /*@null@*/ struct s_constraint *constraint; abst_typedef /*@null@*/ struct s_constraintList *constraintList; +abst_typedef /*@null@*/ struct s_ctypeList *ctypeList; +abst_typedef /*@null@*/ ctypeList fileIdList; /* DRL modified 9 26 00 */ -abst_typedef /*@null@*/ struct s_constraintExpr * constraintExpr; - - +abst_typedef /*@null@*/ struct s_constraintExpr *constraintExpr; /*@-cppnames@*/ typedef int bool; @@ -85,6 +85,10 @@ typedef int bool; abst_typedef /*@untainted@*/ /*@null@*/ char *cstring; typedef /*@only@*/ cstring o_cstring; +abst_typedef /*@null@*/ struct s_cstringSList *cstringSList; + +typedef enum e_LSLInitRuleCode LSLInitRuleCode; + immut_typedef int ctype; /* sRef -> bool */ diff --git a/src/Headers/help.h b/src/Headers/help.h new file mode 100644 index 0000000..afd1139 --- /dev/null +++ b/src/Headers/help.h @@ -0,0 +1,23 @@ +/* +** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2001. +** See ../LICENSE for license information. +** +*/ +/* +** help.h +*/ + +# ifndef HELP_H +# define HELP_H + +extern void help_processFlags (int p_argc, char **p_argv) ; +extern void help_showAvailableHelp (void) ; + +# else +# error "Multiple include" +# endif + + + + + diff --git a/src/Headers/lclinit.h b/src/Headers/lclinit.h index 77c8a6b..6139fb5 100644 --- a/src/Headers/lclinit.h +++ b/src/Headers/lclinit.h @@ -10,9 +10,8 @@ typedef LSLInitRuleCode LCLInitRuleCode; -extern void LCLProcessInitFile(void); - -extern void LCLProcessInitFileInit(void); -extern void LCLProcessInitFileReset(void); -extern void LCLProcessInitFileCleanup(void); +extern void lclinit_process (void); +extern void lclinit_initMod (void); +extern void lclinit_reset (void); +extern void lclinit_cleanup (void); diff --git a/src/Headers/lctype.h b/src/Headers/lctype.h index 4e2d0a8..f5357e7 100644 --- a/src/Headers/lctype.h +++ b/src/Headers/lctype.h @@ -237,12 +237,14 @@ extern ctype ctype_baseArrayPtr (ctype p_c) /*@*/ ; extern ctype ctype_combine (ctype p_dominant, ctype p_modifier) ; extern ctype ctype_createAbstract (typeId p_u) /*@*/ ; -extern ctype - ctype_createEnum (/*@keep@*/ cstring p_tag, /*@keep@*/ enumNameList p_el); + extern ctype ctype_createForwardStruct (/*@only@*/ cstring p_n) /*@*/ ; extern ctype ctype_createForwardUnion (/*@only@*/ cstring p_n) /*@*/ ; +extern ctype ctype_createForwardEnum (/*@only@*/ cstring p_n) /*@*/ ; + extern ctype ctype_createStruct (/*@only@*/ cstring p_n, /*@only@*/ uentryList p_f); extern ctype ctype_createUnion (/*@only@*/ cstring p_n, /*@only@*/ uentryList p_f); +extern ctype ctype_createEnum (/*@keep@*/ cstring p_tag, /*@keep@*/ enumNameList p_el); extern ctype ctype_createUnnamedStruct (/*@only@*/ uentryList p_f) ; extern ctype ctype_createUnnamedUnion (/*@only@*/ uentryList p_f) ; diff --git a/src/Headers/llmain.h b/src/Headers/llmain.h index 89ca3dc..3d7b0fc 100644 --- a/src/Headers/llmain.h +++ b/src/Headers/llmain.h @@ -10,21 +10,17 @@ extern int main (int p_argc, char *p_argv[]) # ifdef NOLCL /*@globals killed undef g_currentloc, killed undef yyin, - undef g_warningstream, - @*/ - /*@modifies g_currentloc, fileSystem, internalState, yyin; - @*/ + undef g_warningstream;@*/ + /*@modifies g_currentloc, fileSystem, internalState, yyin;@*/ # else /*@globals killed undef g_currentloc, - killed g_localSpecPath, killed undef g_currentSpec, killed undef g_currentSpecName, killed undef g_currentloc, killed undef yyin, undef g_warningstream; @*/ - /*@modifies g_currentloc, - g_localSpecPath, g_currentSpec, g_currentSpecName, + /*@modifies g_currentloc, g_currentSpec, g_currentSpecName, yyin, internalState, fileSystem; @*/ # endif diff --git a/src/Headers/lslinit.h b/src/Headers/lslinit.h index bc7d259..8895c8c 100644 --- a/src/Headers/lslinit.h +++ b/src/Headers/lslinit.h @@ -7,191 +7,188 @@ ** lslinit.h */ -typedef enum { - /* initFile: */ - INITFILE1, /* initLines EOF */ - - - - /* initLines: */ - INITLINES1, /* */ - INITLINES2, /* initLine */ - INITLINES3, /* initLines initLine */ - - /* initLine: */ - INITLINE1, /* EOL */ - INITLINE2, /* classification EOL */ - - /* classification: */ - CLASSIFICATION1, /* charClass */ - CLASSIFICATION2, /* tokenClass */ - CLASSIFICATION3, /* synClass */ - - /* charClass: */ - CHARCLASS1, /* ENDCOMMENTCHAR endCommentChars */ - CHARCLASS2, /* IDCHAR idChars */ - CHARCLASS3, /* OPCHAR opChars */ - CHARCLASS4, /* CHC_EXTENSION extensionChar */ - CHARCLASS5, /* SINGLECHAR singChars */ - CHARCLASS6, /* WHITECHAR whiteChars */ - - - /* endCommentChars: */ - LRC_ENDCOMMENT1, /* endCommentChar */ - LRC_ENDCOMMENT2, /* endCommentChars endCommentChar */ - - /* idChars: */ - IDCHARS1, /* idChar */ - IDCHARS2, /* idChars idChar */ - - /* opChars */ - OPCHARS1, /* opChar */ - OPCHARS2, /* opChars opChar */ - - /* ExtensionChar */ - LRC_EXTENSIONCHAR1, /* singleChar */ - - /* singChars */ - SINGCHARS1, /* singChar */ - SINGCHARS2, /* singChars singChar */ - - /* whiteChars */ - WHITECHARS1, /* whiteChar */ - WHITECHARS2, /* whiteChars whiteChar */ - - - /* endCommentChar */ - LRC_ENDCOMMENTCHAR1, /* commentChar */ - - /* idChar */ - IDCHAR1, /* singleChar */ - - /* opChar */ - OPCHAR1, /* singleChar */ - - /* singChar */ - SINGCHAR1, /* singleChar */ - - /* whiteChar */ - WHITECHAR1, /* singleChar */ - - /* tokenClass: */ - TOKENCLASS1, /* QUANTIFIERSYM quantifierSymToks */ - TOKENCLASS2, /* LOGICALOP logicalOpToks */ - TOKENCLASS3, /* EQOP eqOpToks */ - TOKENCLASS4, /* EQUATIONSYM equationSymToks */ - TOKENCLASS5, /* EQSEPSYM eqSepSymToks */ - TOKENCLASS6, /* SELECTSYM selectSymToks */ - TOKENCLASS7, /* OPENSYM openSymToks */ - TOKENCLASS8, /* SEPSYM sepSymToks */ - TOKENCLASS9, /* CLOSESYM closeSymToks */ - TOKENCLASS10, /* SIMPLEID simpleIdToks */ - TOKENCLASS11, /* MAPSYM mapSymToks */ - TOKENCLASS12, /* MARKERSYM markerSymToks */ - TOKENCLASS13, /* COMMENTSYM commentSymToks */ - - /* quantifierSymToks */ - QUANTIFIERSYMTOKS1,/* quantifierSymTok */ - QUANTIFIERSYMTOKS2,/* quantifierSymToks quantifierSymTok */ - - /* logicalOpToks */ - LOGICALOPTOKS1, /* logicalOpTok */ - LOGICALOPTOKS2, /* logicalOpToks logicalOpTok */ - - /* eqOpToks */ - LRC_EQOPTOKS1, /* eqOpTok */ - LRC_EQOPTOKS2, /* eqOpToks eqOpTok */ - - /* equationSymToks */ - LRC_EQUATIONSYMTOKS1, /* equationSymTok */ - LRC_EQUATIONSYMTOKS2, /* equationSymToks equationSymTok */ - - /* eqSepSymToks */ - LRC_EQSEPSYMTOKS1, /* eqSepSymTok */ - LRC_EQSEPSYMTOKS2, /* eqSepSymToks eqSepSymTok */ - - /* selectSymToks */ - SELECTSYMTOKS1, /* selectSymTok */ - SELECTSYMTOKS2, /* selectSymToks selectSymTok */ - - /* openSymToks */ - OPENSYMTOKS1, /* openSymTok */ - OPENSYMTOKS2, /* openSymToks openSymTok */ - - /* sepSymToks */ - SEPSYMTOKS1, /* sepSymTok */ - SEPSYMTOKS2, /* sepSymToks sepSymTok */ - - /* closeSymToks */ - CLOSESYMTOKS1, /* closeSymTok */ - CLOSESYMTOKS2, /* closeSymToks closeSymTok */ - - /* simpleIdToks */ - SIMPLEIDTOKS1, /* simpleIdTok */ - SIMPLEIDTOKS2, /* simpleIdToks simpleIdTok */ - - /* mapSymToks */ - MAPSYMTOKS1, /* mapSymTok */ - MAPSYMTOKS2, /* mapSymToks mapSymTok */ - - /* markerSymToks */ - MARKERSYMTOKS1, /* markerSymTok */ - MARKERSYMTOKS2, /* markerSymToks markerSymTok */ - - /* commentSymToks */ - COMMENTSYMTOKS1, /* commentSymTok */ - COMMENTSYMTOKS2, /* commentSymToks commentSymTok */ - - /* quantifierSymTok */ - QUANTIFIERSYMTOK1, /* token */ - - /* logicalOpTok */ - LOGICALOPTOK1, /* token */ - - /* eqOpTok */ - LRC_EQOPTOK1, /* token */ - - /* equationSymTok */ - LRC_EQUATIONSYMTOK1, /* token */ - - /* eqSepSymTok */ - LRC_EQSEPSYMTOK1, /* token */ - - /* selectSymTok */ - SELECTSYMTOK1, /* token */ - - /* openSymTok */ - OPENSYMTOK1, /* token */ - - /* sepSymTok */ - SEPSYMTOK1, /* token */ - - /* closeSymTok */ - CLOSESYMTOK1, /* token */ - - /* simpleIdTok */ - SIMPLEIDTOK1, /* token */ - - /* mapSymTok */ - MAPSYMTOK1, /* token */ - - /* markerSymTok */ - MARKERSYMTOK1, /* token */ - - /* commentSymTok */ - COMMENTSYMTOK1, /* token */ - - /* synClass: */ - SYNCLASS1, /* SYNONYM oldToken newToken */ - - /* oldToken: */ - OLDTOKEN1, /* token */ - - /* newToken: */ - NEWTOKEN1 /* token */ - -} LSLInitRuleCode; - -extern void LSLProcessInitFile (void); -extern void LSLProcessInitFileInit (void); - +enum e_LSLInitRuleCode { + /* initFile: */ + INITFILE1, /* initLines EOF */ + /* initLines: */ + INITLINES1, /* */ + INITLINES2, /* initLine */ + INITLINES3, /* initLines initLine */ + + /* initLine: */ + INITLINE1, /* EOL */ + INITLINE2, /* classification EOL */ + + /* classification: */ + CLASSIFICATION1, /* charClass */ + CLASSIFICATION2, /* tokenClass */ + CLASSIFICATION3, /* synClass */ + + /* charClass: */ + CHARCLASS1, /* ENDCOMMENTCHAR endCommentChars */ + CHARCLASS2, /* IDCHAR idChars */ + CHARCLASS3, /* OPCHAR opChars */ + CHARCLASS4, /* CHC_EXTENSION extensionChar */ + CHARCLASS5, /* SINGLECHAR singChars */ + CHARCLASS6, /* WHITECHAR whiteChars */ + + /* endCommentChars: */ + LRC_ENDCOMMENT1, /* endCommentChar */ + LRC_ENDCOMMENT2, /* endCommentChars endCommentChar */ + + /* idChars: */ + IDCHARS1, /* idChar */ + IDCHARS2, /* idChars idChar */ + + /* opChars */ + OPCHARS1, /* opChar */ + OPCHARS2, /* opChars opChar */ + + /* ExtensionChar */ + LRC_EXTENSIONCHAR1, /* singleChar */ + + /* singChars */ + SINGCHARS1, /* singChar */ + SINGCHARS2, /* singChars singChar */ + + /* whiteChars */ + WHITECHARS1, /* whiteChar */ + WHITECHARS2, /* whiteChars whiteChar */ + + /* endCommentChar */ + LRC_ENDCOMMENTCHAR1, /* commentChar */ + + /* idChar */ + IDCHAR1, /* singleChar */ + + /* opChar */ + OPCHAR1, /* singleChar */ + + /* singChar */ + SINGCHAR1, /* singleChar */ + + /* whiteChar */ + WHITECHAR1, /* singleChar */ + + /* tokenClass: */ + TOKENCLASS1, /* QUANTIFIERSYM quantifierSymToks */ + TOKENCLASS2, /* LOGICALOP logicalOpToks */ + TOKENCLASS3, /* EQOP eqOpToks */ + TOKENCLASS4, /* EQUATIONSYM equationSymToks */ + TOKENCLASS5, /* EQSEPSYM eqSepSymToks */ + TOKENCLASS6, /* SELECTSYM selectSymToks */ + TOKENCLASS7, /* OPENSYM openSymToks */ + TOKENCLASS8, /* SEPSYM sepSymToks */ + TOKENCLASS9, /* CLOSESYM closeSymToks */ + TOKENCLASS10, /* SIMPLEID simpleIdToks */ + TOKENCLASS11, /* MAPSYM mapSymToks */ + TOKENCLASS12, /* MARKERSYM markerSymToks */ + TOKENCLASS13, /* COMMENTSYM commentSymToks */ + + /* quantifierSymToks */ + QUANTIFIERSYMTOKS1,/* quantifierSymTok */ + QUANTIFIERSYMTOKS2,/* quantifierSymToks quantifierSymTok */ + + /* logicalOpToks */ + LOGICALOPTOKS1, /* logicalOpTok */ + LOGICALOPTOKS2, /* logicalOpToks logicalOpTok */ + + /* eqOpToks */ + LRC_EQOPTOKS1, /* eqOpTok */ + LRC_EQOPTOKS2, /* eqOpToks eqOpTok */ + + /* equationSymToks */ + LRC_EQUATIONSYMTOKS1, /* equationSymTok */ + LRC_EQUATIONSYMTOKS2, /* equationSymToks equationSymTok */ + + /* eqSepSymToks */ + LRC_EQSEPSYMTOKS1, /* eqSepSymTok */ + LRC_EQSEPSYMTOKS2, /* eqSepSymToks eqSepSymTok */ + + /* selectSymToks */ + SELECTSYMTOKS1, /* selectSymTok */ + SELECTSYMTOKS2, /* selectSymToks selectSymTok */ + + /* openSymToks */ + OPENSYMTOKS1, /* openSymTok */ + OPENSYMTOKS2, /* openSymToks openSymTok */ + + /* sepSymToks */ + SEPSYMTOKS1, /* sepSymTok */ + SEPSYMTOKS2, /* sepSymToks sepSymTok */ + + /* closeSymToks */ + CLOSESYMTOKS1, /* closeSymTok */ + CLOSESYMTOKS2, /* closeSymToks closeSymTok */ + + /* simpleIdToks */ + SIMPLEIDTOKS1, /* simpleIdTok */ + SIMPLEIDTOKS2, /* simpleIdToks simpleIdTok */ + + /* mapSymToks */ + MAPSYMTOKS1, /* mapSymTok */ + MAPSYMTOKS2, /* mapSymToks mapSymTok */ + + /* markerSymToks */ + MARKERSYMTOKS1, /* markerSymTok */ + MARKERSYMTOKS2, /* markerSymToks markerSymTok */ + + /* commentSymToks */ + COMMENTSYMTOKS1, /* commentSymTok */ + COMMENTSYMTOKS2, /* commentSymToks commentSymTok */ + + /* quantifierSymTok */ + QUANTIFIERSYMTOK1, /* token */ + + /* logicalOpTok */ + LOGICALOPTOK1, /* token */ + + /* eqOpTok */ + LRC_EQOPTOK1, /* token */ + + /* equationSymTok */ + LRC_EQUATIONSYMTOK1, /* token */ + + /* eqSepSymTok */ + LRC_EQSEPSYMTOK1, /* token */ + + /* selectSymTok */ + SELECTSYMTOK1, /* token */ + + /* openSymTok */ + OPENSYMTOK1, /* token */ + + /* sepSymTok */ + SEPSYMTOK1, /* token */ + + /* closeSymTok */ + CLOSESYMTOK1, /* token */ + + /* simpleIdTok */ + SIMPLEIDTOK1, /* token */ + + /* mapSymTok */ + MAPSYMTOK1, /* token */ + + /* markerSymTok */ + MARKERSYMTOK1, /* token */ + + /* commentSymTok */ + COMMENTSYMTOK1, /* token */ + + /* synClass: */ + SYNCLASS1, /* SYNONYM oldToken newToken */ + + /* oldToken: */ + OLDTOKEN1, /* token */ + + /* newToken: */ + NEWTOKEN1 /* token */ +} ; + +extern void lslinit_setInitFile (/*@only@*/ inputStream p_s) + /*@modifies internalState@*/ ; + +extern void lslinit_process (void) + /*@globals undef g_symtab; @*/ + /*@modifies g_symtab, internalState, fileSystem; @*/ ; diff --git a/src/Headers/osd.h b/src/Headers/osd.h index fe797ce..f4f8f64 100644 --- a/src/Headers/osd.h +++ b/src/Headers/osd.h @@ -53,7 +53,8 @@ typedef enum { OSD_FILEFOUND, OSD_FILENOTFOUND, - OSD_PATHTOOLONG } filestatus; + OSD_PATHTOOLONG +} filestatus; extern /*@only@*/ cstring LSLRootName (cstring p_filespec) /*@*/ ; diff --git a/src/Headers/rcfiles.h b/src/Headers/rcfiles.h new file mode 100644 index 0000000..fa0e0aa --- /dev/null +++ b/src/Headers/rcfiles.h @@ -0,0 +1,18 @@ +/* +** Copyright (C) University of Virginia, Massachusetts Institue of Technology 1994-2001. +** See ../LICENSE for license information. +** +*/ +/* +** rcfiles.h +*/ + +# ifndef RCFILES_H +# define RCFILES_H + +extern bool rcfiles_read (cstring p_fname, + cstringSList *p_passThroughArgs, + bool p_report) + /*@modifies fileSystem, internalState, *p_passThroughArgs@*/ ; + +# endif diff --git a/src/Makefile.am b/src/Makefile.am index 55b8539..b53ddab 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -42,7 +42,7 @@ CSRC = context.c uentry.c cprim.c macrocache.c qual.c qtype.c stateClause.c \ functionClauseList.c metaStateConstraint.c metaStateConstraintList.c \ metaStateExpression.c metaStateSpecifier.c functionConstraint.c -SPLINTSRC = exprNode.c exprChecks.c llmain.c +SPLINTSRC = exprNode.c exprChecks.c llmain.c help.c rcfiles.c CHECKSRC = structNames.c transferChecks.c varKinds.c nameChecks.c GLOBSRC = globals.c flags.c general.c osd.c reader.c mtreader.c @@ -152,7 +152,7 @@ HEADERSRC = Headers/abstBodyNode.h Headers/ltokenList.h \ Headers/exprNode.h Headers/quantifierNode.h \ Headers/exprNodeList.h Headers/quantifierNodeList.h \ Headers/exprNodeSList.h Headers/randomNumbers.h \ - Headers/fcnNode.h \ + Headers/fcnNode.h Headers/rcfiles.h \ Headers/fcnNodeList.h Headers/reader.h \ Headers/fileId.h Headers/refTable-branch.h \ Headers/fileIdList.h Headers/renamingNode.h \ @@ -374,7 +374,7 @@ etags: lintnew: splintme splintme: - ./splint $(DEFAULT_INCLUDES) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) +singleinclude $(LINTSRC) $(OVERFLOWCHSRC) $(LCLSRC) -dump lclint +forcehints -misplacedsharequal +showsourceloc -unrecogcomments -supcounts -fcnuse -incondefs -exportlocal -constuse -mts file -mts filerw + ./splint $(DEFAULT_INCLUDES) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) +singleinclude $(LINTSRC) $(OVERFLOWCHSRC) $(LCLSRC) -dump lclint +forcehints -misplacedsharequal +showsourceloc -unrecogcomments -supcounts -fcnuse -incondefs -exportlocal -constuse -mts file -mts filerw splintsome: ./splint $(DEFAULT_INCLUDES) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) +singleinclude lcllib.c -dump lclint +forcehints -misplacedsharequal +showsourceloc -unrecogcomments -supcounts -fcnuse -incondefs -exportlocal -constuse -mts file -mts filerw +partial diff --git a/src/Makefile.in b/src/Makefile.in index 9c9affc..799ecbd 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -124,7 +124,7 @@ CSRC = context.c uentry.c cprim.c macrocache.c qual.c qtype.c stateClause.c \ metaStateExpression.c metaStateSpecifier.c functionConstraint.c -SPLINTSRC = exprNode.c exprChecks.c llmain.c +SPLINTSRC = exprNode.c exprChecks.c llmain.c help.c rcfiles.c CHECKSRC = structNames.c transferChecks.c varKinds.c nameChecks.c GLOBSRC = globals.c flags.c general.c osd.c reader.c mtreader.c @@ -238,7 +238,7 @@ HEADERSRC = Headers/abstBodyNode.h Headers/ltokenList.h \ Headers/exprNode.h Headers/quantifierNode.h \ Headers/exprNodeList.h Headers/quantifierNodeList.h \ Headers/exprNodeSList.h Headers/randomNumbers.h \ - Headers/fcnNode.h \ + Headers/fcnNode.h Headers/rcfiles.h \ Headers/fcnNodeList.h Headers/reader.h \ Headers/fileId.h Headers/refTable-branch.h \ Headers/fileIdList.h Headers/renamingNode.h \ @@ -444,11 +444,11 @@ am_splint_OBJECTS = cgrammar.$(OBJEXT) cscanner.$(OBJEXT) \ mtDefaultsDecl.$(OBJEXT) mtMergeItem.$(OBJEXT) \ mtMergeClause.$(OBJEXT) mtMergeClauseList.$(OBJEXT) \ exprNode.$(OBJEXT) exprChecks.$(OBJEXT) llmain.$(OBJEXT) \ - constraintGeneration.$(OBJEXT) constraintTerm.$(OBJEXT) \ - constraintExprData.$(OBJEXT) constraintExpr.$(OBJEXT) \ - constraint.$(OBJEXT) constraintList.$(OBJEXT) \ - constraintResolve.$(OBJEXT) constraintOutput.$(OBJEXT) \ - loopHeuristics.$(OBJEXT) + help.$(OBJEXT) rcfiles.$(OBJEXT) constraintGeneration.$(OBJEXT) \ + constraintTerm.$(OBJEXT) constraintExprData.$(OBJEXT) \ + constraintExpr.$(OBJEXT) constraint.$(OBJEXT) \ + constraintList.$(OBJEXT) constraintResolve.$(OBJEXT) \ + constraintOutput.$(OBJEXT) loopHeuristics.$(OBJEXT) splint_OBJECTS = $(am_splint_OBJECTS) splint_LDFLAGS = @@ -495,9 +495,9 @@ depcomp = $(SHELL) $(top_srcdir)/config/depcomp @AMDEP_TRUE@ $(DEPDIR)/general.Po $(DEPDIR)/genericTable.Po \ @AMDEP_TRUE@ $(DEPDIR)/globSet.Po $(DEPDIR)/globals.Po \ @AMDEP_TRUE@ $(DEPDIR)/globalsClause.Po $(DEPDIR)/guardSet.Po \ -@AMDEP_TRUE@ $(DEPDIR)/idDecl.Po $(DEPDIR)/idDeclList.Po \ -@AMDEP_TRUE@ $(DEPDIR)/importNodeList.Po $(DEPDIR)/imports.Po \ -@AMDEP_TRUE@ $(DEPDIR)/initDeclNodeList.Po \ +@AMDEP_TRUE@ $(DEPDIR)/help.Po $(DEPDIR)/idDecl.Po \ +@AMDEP_TRUE@ $(DEPDIR)/idDeclList.Po $(DEPDIR)/importNodeList.Po \ +@AMDEP_TRUE@ $(DEPDIR)/imports.Po $(DEPDIR)/initDeclNodeList.Po \ @AMDEP_TRUE@ $(DEPDIR)/inputStream.Po $(DEPDIR)/intSet.Po \ @AMDEP_TRUE@ $(DEPDIR)/interfaceNodeList.Po \ @AMDEP_TRUE@ $(DEPDIR)/lclctypes.Po $(DEPDIR)/lclinit.Po \ @@ -548,15 +548,15 @@ depcomp = $(SHELL) $(top_srcdir)/config/depcomp @AMDEP_TRUE@ $(DEPDIR)/programNodeList.Po $(DEPDIR)/qtype.Po \ @AMDEP_TRUE@ $(DEPDIR)/qual.Po $(DEPDIR)/qualList.Po \ @AMDEP_TRUE@ $(DEPDIR)/quantifierNodeList.Po \ -@AMDEP_TRUE@ $(DEPDIR)/randomNumbers.Po $(DEPDIR)/reader.Po \ -@AMDEP_TRUE@ $(DEPDIR)/replaceNodeList.Po $(DEPDIR)/sRef.Po \ -@AMDEP_TRUE@ $(DEPDIR)/sRefList.Po $(DEPDIR)/sRefSet.Po \ -@AMDEP_TRUE@ $(DEPDIR)/sRefSetList.Po $(DEPDIR)/sRefTable.Po \ -@AMDEP_TRUE@ $(DEPDIR)/scan.Po $(DEPDIR)/scanline.Po \ -@AMDEP_TRUE@ $(DEPDIR)/shift.Po $(DEPDIR)/sigNodeSet.Po \ -@AMDEP_TRUE@ $(DEPDIR)/signature.Po $(DEPDIR)/sort.Po \ -@AMDEP_TRUE@ $(DEPDIR)/sortList.Po $(DEPDIR)/sortSet.Po \ -@AMDEP_TRUE@ $(DEPDIR)/sortSetList.Po \ +@AMDEP_TRUE@ $(DEPDIR)/randomNumbers.Po $(DEPDIR)/rcfiles.Po \ +@AMDEP_TRUE@ $(DEPDIR)/reader.Po $(DEPDIR)/replaceNodeList.Po \ +@AMDEP_TRUE@ $(DEPDIR)/sRef.Po $(DEPDIR)/sRefList.Po \ +@AMDEP_TRUE@ $(DEPDIR)/sRefSet.Po $(DEPDIR)/sRefSetList.Po \ +@AMDEP_TRUE@ $(DEPDIR)/sRefTable.Po $(DEPDIR)/scan.Po \ +@AMDEP_TRUE@ $(DEPDIR)/scanline.Po $(DEPDIR)/shift.Po \ +@AMDEP_TRUE@ $(DEPDIR)/sigNodeSet.Po $(DEPDIR)/signature.Po \ +@AMDEP_TRUE@ $(DEPDIR)/sort.Po $(DEPDIR)/sortList.Po \ +@AMDEP_TRUE@ $(DEPDIR)/sortSet.Po $(DEPDIR)/sortSetList.Po \ @AMDEP_TRUE@ $(DEPDIR)/stDeclNodeList.Po \ @AMDEP_TRUE@ $(DEPDIR)/stateClause.Po \ @AMDEP_TRUE@ $(DEPDIR)/stateClauseList.Po \ @@ -691,6 +691,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/globals.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/globalsClause.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/guardSet.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/help.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/idDecl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/idDeclList.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/importNodeList.Po@am__quote@ @@ -768,6 +769,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/qualList.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/quantifierNodeList.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/randomNumbers.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rcfiles.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/reader.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/replaceNodeList.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sRef.Po@am__quote@ @@ -1051,7 +1053,7 @@ etags: lintnew: splintme splintme: - ./splint $(DEFAULT_INCLUDES) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) +singleinclude $(LINTSRC) $(OVERFLOWCHSRC) $(LCLSRC) -dump lclint +forcehints -misplacedsharequal +showsourceloc -unrecogcomments -supcounts -fcnuse -incondefs -exportlocal -constuse -mts file -mts filerw + ./splint $(DEFAULT_INCLUDES) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) +singleinclude $(LINTSRC) $(OVERFLOWCHSRC) $(LCLSRC) -dump lclint +forcehints -misplacedsharequal +showsourceloc -unrecogcomments -supcounts -fcnuse -incondefs -exportlocal -constuse -mts file -mts filerw splintsome: ./splint $(DEFAULT_INCLUDES) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) +singleinclude lcllib.c -dump lclint +forcehints -misplacedsharequal +showsourceloc -unrecogcomments -supcounts -fcnuse -incondefs -exportlocal -constuse -mts file -mts filerw +partial diff --git a/src/clabstract.c b/src/clabstract.c index db7300c..5628c15 100644 --- a/src/clabstract.c +++ b/src/clabstract.c @@ -1810,7 +1810,7 @@ handleEnum (cstring id) } else { - return (declareEnum (id, enumNameList_new ())); + return (ctype_createForwardEnum (id)); } } diff --git a/src/context.c b/src/context.c index 5a43530..ba5b7ad 100644 --- a/src/context.c +++ b/src/context.c @@ -42,7 +42,6 @@ # include "exprChecks.h" # include "filelocStack.h" -# include "fileIdList.h" # include "llmain.h" # include "intSet.h" # include "osd.h" @@ -3024,13 +3023,13 @@ context_setString (flagcode flag, cstring val) { ; /* Okay not handle everything in this switch */ } - } /* evans 2002-03-24: splintme reports a spurious (I think) warning here...need to look into it */ + /*@i523@*/ } /* evans 2002-03-24: splintme reports a spurious (I think) warning here...need to look into it */ if (cstring_length (val) >= 1 && cstring_firstChar (val) == '\"') { llerror_flagWarning (message - ("setting %s to string beginning with \". You probably " + ("Setting %s to string beginning with \". You probably " "don't meant to have the \"'s.", flagcode_unparse (flag))); } @@ -3705,7 +3704,9 @@ context_inFunctionName (void) void context_userSetFlag (flagcode f, bool b) { - DPRINTF (("set flag: %s", flagcode_unparse (f))); + DPRINTF (("set flag: %s / %s", + flagcode_unparse (f), + bool_unparse (context_getFlag (f)))); if (f == FLG_NEVERINCLUDE && b) { @@ -3713,7 +3714,7 @@ context_userSetFlag (flagcode f, bool b) { llerror_flagWarning (cstring_makeLiteral - ("setting +neverinclude after +exportheader. " + ("Setting +neverinclude after +exportheader. " "Turning off exportheader, since headers are not checked " "when +neverinclude is used.")); @@ -3728,7 +3729,7 @@ context_userSetFlag (flagcode f, bool b) { llerror_flagWarning (cstring_makeLiteral - ("setting +exportheader after +neverinclude. " + ("Setting +exportheader after +neverinclude. " "Not setting exportheader, since headers are not checked " "when +neverinclude is used.")); gc.flags[FLG_EXPORTHEADER] = FALSE; @@ -3747,7 +3748,7 @@ context_userSetFlag (flagcode f, bool b) && !flagcode_hasArgument (f)) { llerror_flagWarning - (message ("setting %s%s redundant with current value", + (message ("Setting %s%s redundant with current value", cstring_makeLiteralTemp (b ? "+" : "-"), flagcode_unparse (f))); } @@ -3758,7 +3759,7 @@ context_userSetFlag (flagcode f, bool b) if (!context_getFlag (FLG_WARNUSE)) { llerror_flagWarning - (message ("flag +%s is canceled by -warnuse", + (message ("Flag +%s is canceled by -warnuse", flagcode_unparse (f))); } } @@ -3770,7 +3771,7 @@ context_userSetFlag (flagcode f, bool b) && gc.library != f) { llerror_flagWarning - (message ("selecting library %s after library %s was " + (message ("Selecting library %s after library %s was " "selected (only one library may be used)", flagcode_unparse (f), flagcode_unparse (gc.library))); @@ -3782,7 +3783,7 @@ context_userSetFlag (flagcode f, bool b) { llerror_flagWarning (cstring_makeLiteral - ("selecting unix library. Unix library is " + ("Selecting unix library. Unix library is " "ad hoc addition to POSIX library. Recommend " "use +posixlib to select POSIX library instead. " "Use -warnunixlib to suppress this message.")); @@ -3796,7 +3797,7 @@ context_userSetFlag (flagcode f, bool b) { llerror_flagWarning (message - ("setting +%s will not produce warnings with -namechecks. " + ("Setting +%s will not produce warnings with -namechecks. " "Must set +namechecks also.", flagcode_unparse (f))); } diff --git a/src/cpplib.c b/src/cpplib.c index 58dc81d..243e875 100644 --- a/src/cpplib.c +++ b/src/cpplib.c @@ -1169,8 +1169,18 @@ copy_rest_of_line (cppReader *pfile) case EOF: goto end_directive; case '\\': - if (cppReader_peekC (pfile) == '\n') + /* + ** Patch from Brian St. Pierre for handling MS-DOS files. + */ + + if (cppReader_peekC (pfile) == '\n' + || cppReader_peekC (pfile) == '\r') { + if (cppReader_peekC (pfile) == '\r') + { + cppReader_forward (pfile, 1); + } + cppReader_forward (pfile, 1); continue; } diff --git a/src/cppmain.c b/src/cppmain.c index 9c568d9..b05ddc4 100644 --- a/src/cppmain.c +++ b/src/cppmain.c @@ -174,6 +174,8 @@ void cppAddIncludeDir (cstring dir) ** Add the -I- code. This code provided by Robin Watts */ + DPRINTF (("Adding include: %s", dir)); + if (cstring_equalLit (dir, "-I-")) { struct cppOptions *opts = CPPOPTIONS (&g_cppState); @@ -184,8 +186,11 @@ void cppAddIncludeDir (cstring dir) /* -I option (Add directory to include path) */ struct file_name_list *dirtmp = (struct file_name_list *) dmalloc (sizeof (*dirtmp)); + llassert (cstring_firstChar (dir) == 'I'); + dir = cstring_suffix (dir, 1); + DPRINTF (("Add include: %s", dir)); - + dirtmp->next = 0; /* New one goes on the end */ dirtmp->control_macro = 0; dirtmp->c_system_include_path = FALSE; diff --git a/src/cscanner.l b/src/cscanner.l index 0d05b48..b1e7d78 100644 --- a/src/cscanner.l +++ b/src/cscanner.l @@ -84,8 +84,6 @@ ULSuffix ({U}{L}|{L}{U}) # include "cgrammar.h" # include "cgrammar_tokens.h" - -# include "fileIdList.h" # include "portab.h" static bool lastWasString = FALSE; @@ -2049,33 +2047,30 @@ static int handleLlSpecial () { ; } - else if (flagcode_isInvalid (fflag)) + else if (flagcode_isModeName (fflag)) { - if (isMode (flagname)) + if (ynm_isMaybe (set)) { - if (ynm_isMaybe (set)) - { - llerror - (FLG_BADFLAG, - message - ("Semantic comment attempts to restore flag %s. " - "A mode flag cannot be restored.", - flagname)); - } - else - { - context_setMode (flagname); - } + llerror + (FLG_BADFLAG, + message + ("Semantic comment attempts to restore flag %s. " + "A mode flag cannot be restored.", + flagname)); } else { - voptgenerror - (FLG_UNRECOGFLAGCOMMENTS, - message ("Unrecognized option in semantic comment: %s", - flagname), - loc); + context_setMode (flagname); } } + else if (flagcode_isInvalid (fflag)) + { + voptgenerror + (FLG_UNRECOGFLAGCOMMENTS, + message ("Unrecognized option in semantic comment: %s", + flagname), + loc); + } else if (flagcode_isGlobalFlag (fflag)) { voptgenerror diff --git a/src/cstringList.c b/src/cstringList.c index 145c8d2..479b4be 100644 --- a/src/cstringList.c +++ b/src/cstringList.c @@ -339,3 +339,16 @@ cstringList_get (cstringList s, int index) llassertretnull (index < s->nelements); return s->elements[index]; } + +ob_mstring * +cstringList_getElements (cstringList s) +{ + if (cstringList_isDefined (s)) + { + /*@i423@*/ return s->elements; + } + else + { + return NULL; + } +} diff --git a/src/ctype.c b/src/ctype.c index 29c0a6b..d246bf7 100644 --- a/src/ctype.c +++ b/src/ctype.c @@ -2212,6 +2212,16 @@ ctype_createForwardUnion (cstring n) return (ct); } +ctype +ctype_createForwardEnum (cstring n) +{ + uentry ue = uentry_makeEnumTag (n, ctype_unknown, fileloc_undefined); + ctype ct = usymtab_supForwardTypeEntry (ue); + + cstring_free (n); + return (ct); +} + ctype ctype_removePointers (ctype c) { diff --git a/src/fileIdList.c b/src/fileIdList.c index cbff8d4..18b7472 100644 --- a/src/fileIdList.c +++ b/src/fileIdList.c @@ -27,4 +27,7 @@ # include "splintMacros.nf" # include "basic.h" -# include "fileIdList.h" + +/* +** No code needed (all from ctypeList) +*/ diff --git a/src/fileTable.c b/src/fileTable.c index 2d6b9a7..03a6be1 100644 --- a/src/fileTable.c +++ b/src/fileTable.c @@ -324,7 +324,7 @@ fileTable_addFilePrim (fileTable ft, /*@temp@*/ cstring name, cstring absname = osd_absolutePath (NULL, name); int tindex = fileTable_getIndex (ft, absname); - DPRINTF (("Got abs path: %s", absname)); + /*@i534 fprintf (stderr, "Got abs path: %s", absname); */ llassert (ft != fileTable_undefined); if (tindex != NOT_FOUND) @@ -809,7 +809,7 @@ fileTable_cleanup (fileTable ft) if (msg) { (void) fflush (g_warningstream); - fprintf (stderr, "< cleaning"); + displayScanOpen (cstring_makeLiteral ("< cleaning")); } for (i = 0; i < ft->nentries; i++) @@ -851,21 +851,13 @@ fileTable_cleanup (fileTable ft) if (msg && ((i % skip) == 0)) { - (void) fflush (g_warningstream); - - if (i == 0) { - fprintf (stderr, " "); - } else { - fprintf (stderr, "."); - } - - (void) fflush (stderr); + displayScan (cstring_makeLiteral (i == 0 ? " " : ".")); } } - + if (msg) { - fprintf (stderr, " >\n"); + displayScanClose (); } } diff --git a/src/fileloc.c b/src/fileloc.c index 729c633..bce4b0c 100644 --- a/src/fileloc.c +++ b/src/fileloc.c @@ -35,7 +35,6 @@ # include "splintMacros.nf" # include "llbasic.h" -# include "fileIdList.h" # include "osd.h" # include "portab.h" @@ -600,7 +599,14 @@ fileloc_filename (fileloc f) { if (fileloc_isDefined (f)) { - return osd_outputPath (fileTable_rootFileName (f->fid)); + if (fileId_isValid (f->fid)) + { + return osd_outputPath (fileTable_rootFileName (f->fid)); + } + else + { + return cstring_makeLiteral (""); + } } else { @@ -645,16 +651,24 @@ fileloc_column (fileloc f) /*@only@*/ cstring fileloc_unparse (fileloc f) { + static in_funparse = FALSE; bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT); bool htmlFormat = context_getFlag (FLG_HTMLFILEFORMAT); cstring res = cstring_undefined; + /* watch out for recursive calls when debugging... */ + llassert (!in_funparse); + in_funparse = TRUE; + if (fileloc_isDefined (f)) { switch (f->kind) { case FL_BUILTIN: - return (cstring_makeLiteral ("Command Line")); + { + res = cstring_makeLiteral ("Command Line"); + break; + } case FL_IMPORT: if (parenFormat) { @@ -753,7 +767,8 @@ fileloc_unparse (fileloc f) { res = cstring_makeLiteral ("< Location unknown >"); } - + + in_funparse = FALSE; return res; } diff --git a/src/flags.c b/src/flags.c index a56ab38..27e018e 100644 --- a/src/flags.c +++ b/src/flags.c @@ -27,7 +27,10 @@ # include "splintMacros.nf" # include "basic.h" +# include "osd.h" # include "portab.h" +# include "rcfiles.h" +# include "lslinit.h" /* ** from the CC man page: @@ -1241,6 +1244,7 @@ flags_identifyFlagAux (cstring s, bool quiet) else if (flags_isModeName (cflag)) { res = MODENAME_FLAG; + } else { res = INVALID_FLAG; @@ -1548,15 +1552,111 @@ bool flagcode_isNamePrefixFlag (flagcode f) return FALSE; } } - -bool flags_processFlags (bool inCommandLine, int argc, char **argv) + +static cstring findLarchPathFile (/*@temp@*/ cstring s) { - int i; + cstring pathName; + filestatus status; + + status = osd_getPath (context_getLarchPath (), s, &pathName); + + if (status == OSD_FILEFOUND) + { + return pathName; + } + else if (status == OSD_FILENOTFOUND) + { + showHerald (); + lldiagmsg (message ("Cannot find file on LARCH_PATH: %s", s)); + } + else if (status == OSD_PATHTOOLONG) + { + /* Directory and filename are too long. Report error. */ + llbuglit ("soure_getPath: Filename plus directory from search path too long"); + } + else + { + BADBRANCH; + } + + return cstring_undefined; +} + +static void addLarchPathFile (fileIdList files, /*@temp@*/ cstring s) +{ + cstring pathName = findLarchPathFile (s); + + if (cstring_isDefined (pathName)) + { + if (fileTable_exists (context_fileTable (), pathName)) + { + showHerald (); + lldiagmsg (message ("File listed multiple times: %s", pathName)); + cstring_free (pathName); + } + else + { + fileIdList_add (files, fileTable_addFileOnly (context_fileTable (), pathName)); + } + } +} + + +static void addFile (fileIdList files, /*@only@*/ cstring s) +{ + if (fileTable_exists (context_fileTable (), s)) + { + showHerald (); + lldiagmsg (message ("File listed multiple times: %s", s)); + cstring_free (s); + } + else + { + fileIdList_add (files, fileTable_addFileOnly (context_fileTable (), s)); + } +} + +static void addXHFile (fileIdList files, /*@temp@*/ cstring s) +{ + cstring pathName = findLarchPathFile (s); + + if (cstring_isDefined (pathName)) + { + if (fileTable_exists (context_fileTable (), pathName)) + { + showHerald (); + lldiagmsg (message ("File listed multiple times: %s", s)); + } + else + { + fileIdList_add (files, fileTable_addXHFile (context_fileTable (), pathName)); + } + } + cstring_free (pathName); +} + +void +flags_processFlags (bool inCommandLine, + fileIdList xfiles, + fileIdList cfiles, + fileIdList lclfiles, + fileIdList mtfiles, + cstringSList *passThroughArgs, + int argc, char **argv) +{ + int i; + cstringSList fl = cstringSList_undefined; + for (i = 0; i < argc; i++) { - char *thisarg = argv[i]; - + char *thisarg; + + llassert (argv != NULL); + thisarg = argv[i]; + + DPRINTF (("thisarg: %s", thisarg)); + if (*thisarg == '-' || *thisarg == '+') { bool set = (*thisarg == '+'); @@ -1590,7 +1690,39 @@ bool flags_processFlags (bool inCommandLine, int argc, char **argv) g_currentloc); } } - else if (flagcode_isModeNameFlag (opt)) + else if (flagcode_isPassThrough (opt)) /* preprocessor flag: -D or -U */ + { + /* + ** Following space is optional, don't include the - + */ + + *passThroughArgs = cstringSList_add (*passThroughArgs, + cstring_fromChars (thisarg + 1)); + } + else if (opt == FLG_INCLUDEPATH || opt == FLG_SPECPATH) + { + cstring dir = cstring_suffix (cstring_fromChars (thisarg), 1); /* skip over I */ + + DPRINTF (("Directory: %s", dir)); + + switch (opt) + { + case FLG_INCLUDEPATH: + cppAddIncludeDir (dir); + /*@switchbreak@*/ break; + case FLG_SPECPATH: + /*@-mustfree@*/ + g_localSpecPath = cstring_toCharsSafe + (message ("%s%h%s", + cstring_fromChars (g_localSpecPath), + PATH_SEPARATOR, + dir)); + /*@=mustfree@*/ + /*@switchbreak@*/ break; + BADDEFAULT; + } + } + else if (flagcode_isModeName (opt)) { context_setMode (flagname); } @@ -1615,223 +1747,179 @@ bool flags_processFlags (bool inCommandLine, int argc, char **argv) if (flagcode_hasArgument (opt)) { - if (flagcode_isPassThrough (opt)) /* -D or -U */ - { - /* - ** Following space is optional - */ - - flags_recordPassThroughArg (flagname); - - passThroughArgs = cstringSList_add - (passThroughArgs, cstring_fromChars (thisarg)); - } - else if (flagcode_hasNumber (opt)) + if (flagcode_hasNumber (opt)) + { + if (++i < argc) { - if (++i < argc) - { - setValueFlag (opt, cstring_fromChars (argv[i])); - } - else - { - llfatalerror - (message - ("Flag %s must be followed by a number", - flagcode_unparse (opt))); - } - } - else if (flagcode_hasChar (opt)) + setValueFlag (opt, cstring_fromChars (argv[i])); + } + else { - if (++i < argc) - { - setValueFlag (opt, cstring_fromChars (argv[i])); - } - else - { - llfatalerror - (message - ("Flag %s must be followed by a character", - flagcode_unparse (opt))); - } - } - else if (opt == FLG_INCLUDEPATH || opt == FLG_SPECPATH) + voptgenerror + (FLG_BADFLAG, + message + ("Flag %s must be followed by a number", + flagcode_unparse (opt)), + g_currentloc); + } + } + else if (flagcode_hasChar (opt)) + { + if (++i < argc) { - cstring dir = cstring_suffix (cstring_fromChars (thisarg), 1); /* skip over I */ - - switch (opt) - { - case FLG_INCLUDEPATH: - cppAddIncludeDir (dir); - /*@switchbreak@*/ break; - case FLG_SPECPATH: - /*@-mustfree@*/ - g_localSpecPath = cstring_toCharsSafe - (message ("%s%h%s", - cstring_fromChars (g_localSpecPath), - PATH_SEPARATOR, - dir)); - /*@=mustfree@*/ - /*@switchbreak@*/ break; - BADDEFAULT; - } + setValueFlag (opt, cstring_fromChars (argv[i])); + } + else + { + voptgenerror + (FLG_BADFLAG, + message + ("Flag %s must be followed by a character", + flagcode_unparse (opt)), + g_currentloc); } - else if (flagcode_hasString (opt) - || opt == FLG_INIT || opt == FLG_OPTF) + } + else if (flagcode_hasString (opt) + || opt == FLG_INIT || opt == FLG_OPTF) + { + if (++i < argc) { - if (++i < argc) + cstring arg = cstring_fromChars (argv[i]); + + if (opt == FLG_OPTF) { - cstring arg = cstring_fromChars (argv[i]); - - if (opt == FLG_OPTF) + if (inCommandLine) { ; /* -f already processed */ } - else if (opt == FLG_INIT) + else { + (void) rcfiles_read (arg, passThroughArgs, TRUE); + } + } + else if (opt == FLG_INIT) + { # ifndef NOLCL - initFile = inputStream_create - (arg, - cstring_makeLiteralTemp (LCLINIT_SUFFIX), - FALSE); + lslinit_setInitFile (inputStream_create + (arg, + cstring_makeLiteralTemp (LCLINIT_SUFFIX), + FALSE)); # endif - break; + break; + } + else + { + DPRINTF (("String flag: %s / %s", + flagcode_unparse (opt), arg)); + if (opt == FLG_MTSFILE) + { + /* + ** arg identifies mts files + */ + cstring tmp = message ("%s%s", arg, MTS_EXTENSION); + addLarchPathFile (mtfiles, tmp); + cstring_free (tmp); + tmp = message ("%s%s", arg, XH_EXTENSION); + addXHFile (xfiles, tmp); + cstring_free (tmp); } else { - DPRINTF (("String flag: %s / %s", - flagcode_unparse (opt), arg)); - if (opt == FLG_MTSFILE) - { - /* - ** arg identifies mts files - */ - cstring tmp = message ("%s%s", arg, MTS_EXTENSION); - addLarchPathFile (mtfiles, tmp); - cstring_free (tmp); - tmp = message ("%s%s", arg, XH_EXTENSION); - addXHFile (xfiles, tmp); - cstring_free (tmp); - } - else - { - setStringFlag (opt, cstring_copy (arg)); - } + setStringFlag (opt, cstring_copy (arg)); } } - else - { - llfatalerror - (message - ("Flag %s must be followed by a string", - flagcode_unparse (opt))); - } } else { - /* no argument */ + voptgenerror + (FLG_BADFLAG, + message + ("Flag %s must be followed by a string", + flagcode_unparse (opt)), + g_currentloc); } } + else + { + /* no argument */ + } } } - else /* its a filename */ - { - DPRINTF (("Adding filename: %s", thisarg)); - fl = cstringSList_add (fl, cstring_fromChars (thisarg)); - } + } + else /* its a filename */ + { + DPRINTF (("Adding filename: %s", thisarg)); + fl = cstringSList_add (fl, cstring_fromChars (thisarg)); } } -} - -void flags_processHelp (int argc, char **argv) -{ - - if (showhelp) + /* + ** create lists of C and LCL files + */ + + if (inCommandLine) + { + cstringSList_elements (fl, current) { - if (allhelp) - { - showHerald (); - } - - allhelp = FALSE; + cstring ext = fileLib_getExtension (current); - if (*thisarg == '-' || *thisarg == '+') - { - thisarg++; /* skip '-' */ - } - if (mstring_equal (thisarg, "modes")) - { - llmsg (describeModes ()); - } - else if (mstring_equal (thisarg, "vars") || mstring_equal (thisarg, "env")) - { - describeVars (); - } - else if (mstring_equal (thisarg, "annotations")) - { - printAnnotations (); - } - else if (mstring_equal (thisarg, "parseerrors")) + if (cstring_isUndefined (ext)) { - printParseErrors (); + /* no extension --- both C and LCL with default extensions */ + + addFile (cfiles, message ("%s%s", current, C_EXTENSION)); + addFile (lclfiles, message ("%s%s", current, LCL_EXTENSION)); } - else if (mstring_equal (thisarg, "comments")) + else if (cstring_equal (ext, XH_EXTENSION)) { - printComments (); + addXHFile (xfiles, current); } - else if (mstring_equal (thisarg, "prefixcodes")) + else if (cstring_equal (ext, PP_EXTENSION)) { - describePrefixCodes (); + if (!context_getFlag (FLG_NOPP)) + { + voptgenerror + (FLG_FILEEXTENSIONS, + message ("File extension %s used without +nopp flag (will be processed as C source code): %s", + ext, current), + g_currentloc); + } + + addFile (cfiles, cstring_copy (current)); } - else if (mstring_equal (thisarg, "references") - || mstring_equal (thisarg, "refs")) + else if (cstring_equal (ext, LCL_EXTENSION)) { - printReferences (); + addFile (lclfiles, cstring_copy (current)); } - else if (mstring_equal (thisarg, "mail")) + else if (fileLib_isCExtension (ext)) { - printMail (); + addFile (cfiles, cstring_copy (current)); } - else if (mstring_equal (thisarg, "maintainer") - || mstring_equal (thisarg, "version")) + else if (cstring_equal (ext, MTS_EXTENSION)) { - printMaintainer (); + addLarchPathFile (mtfiles, current); } - else if (mstring_equal (thisarg, "flags")) + else { - if (i + 1 < argc) - { - char *next = argv[i + 1]; - - if (specialFlagsHelp (next)) - { - i++; - } - else - { - flagkind k = identifyCategory (cstring_fromChars (next)); - - if (k != FK_NONE) - { - printCategory (k); - i++; - } - } - } - else - { - printFlags (); - } - } - else - { - cstring s = describeFlag (cstring_fromChars (thisarg)); + voptgenerror + (FLG_FILEEXTENSIONS, + message ("Unrecognized file extension: %s (assuming %s is C source code)", + current, ext), + g_currentloc); - if (cstring_isDefined (s)) - { - llmsg (s); - } + addFile (cfiles, cstring_copy (current)); } - } - else + } end_cstringSList_elements; + } + else + { + if (cstringSList_size (fl) != 0) { + /* Cannot list files in .splintrc files */ + voptgenerror (FLG_BADFLAG, + message ("Cannot list files in .splintrc files: %s (probable missing + or -)", + cstringSList_unparse (fl)), + g_currentloc); + } + } +} diff --git a/src/help.c b/src/help.c new file mode 100644 index 0000000..60f0324 --- /dev/null +++ b/src/help.c @@ -0,0 +1,565 @@ +/* +** Splint - annotation-assisted static program checker +** Copyright (C) 1994-2002 University of Virginia, +** Massachusetts Institute of Technology +** +** This program is free software; you can redistribute it and/or modify it +** under the terms of the GNU General Public License as published by the +** Free Software Foundation; either version 2 of the License, or (at your +** option) any later version. +** +** This program is distributed in the hope that it will be useful, but +** WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** +** The GNU General Public License is available from http://www.gnu.org/ or +** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +** MA 02111-1307, USA. +** +** For information on splint: info@splint.org +** To report a bug: splint-bug@splint.org +** For more information: http://www.splint.org +*/ +/* +** help.c +*/ + +# include "splintMacros.nf" +# include "basic.h" +# include "help.h" +# include "osd.h" +# include "portab.h" +# include "version.h" + +static void +describeVars (void) +{ + cstring eval; + cstring def; + + eval = context_getLarchPath (); + def = osd_getEnvironmentVariable (LARCH_PATH); + + if (cstring_isDefined (def) || + !cstring_equal (eval, cstring_fromChars (DEFAULT_LARCHPATH))) + { + llmsg (message ("LARCH_PATH = %s", eval)); + } + else + { + llmsg (message ("LARCH_PATH = (default = %s)", + cstring_fromChars (DEFAULT_LARCHPATH))); + } + + llmsglit (" --- path used to find larch initialization files and LSL traits"); + + eval = context_getLCLImportDir (); + def = osd_getEnvironmentVariable (cstring_makeLiteralTemp (LCLIMPORTDIR)); + + if (cstring_isDefined (def) || + !cstring_equal (eval, cstring_fromChars (DEFAULT_LCLIMPORTDIR))) + { + llmsg (message ("%q = %s", cstring_makeLiteral (LCLIMPORTDIR), eval)); + } + else + { + llmsg (message ("%s = ", cstring_makeLiteralTemp (LCLIMPORTDIR), + cstring_makeLiteralTemp (DEFAULT_LCLIMPORTDIR))); + } + + llmsglit (" --- directory containing lcl standard library files " + "(import with < ... >)");; + + llmsg (message + ("include path = %q (set by environment variable %s and -I flags)", + cppReader_getIncludePath (), INCLUDEPATH_VAR)); + + llmsglit (" --- path used to find #include'd files"); + + llmsg (message + ("systemdirs = %s (set by -systemdirs or environment variable %s)", /*@i413223@*/ + context_getString (FLG_SYSTEMDIRS), + INCLUDEPATH_VAR)); + + llmsglit (" --- if file is found on this path, it is treated as a system file for error reporting"); +} + +static void +printAnnotations (void) +{ + llmsglit ("Annotations"); + llmsglit ("-----------"); + llmsglit (""); + llmsglit ("Annotations are semantic comments that document certain " + "assumptions about functions, variables, parameters, and types. "); + llmsglit (""); + llmsglit ("They may be used to indicate where the representation of a " + "user-defined type is hidden, to limit where a global variable may " + "be used or modified, to constrain what a function implementation " + "may do to its parameters, and to express checked assumptions about " + "variables, types, structure fields, function parameters, and " + "function results."); + llmsglit (""); + llmsglit ("Annotations are introduced by \"/*@\". The role of the @ may be " + "played by any printable character, selected using -commentchar ."); + llmsglit (""); + llmsglit ("Consult the User's Guide for descriptions of checking associated with each annotation."); + llmsglit (""); + llmsglit ("Globals: (in function declarations)"); + llmsglit (" /*@globals ,+ @*/"); + llmsglit (" globitem is an identifier, internalState or fileSystem"); + llmsglit (""); + llmsglit ("Modifies: (in function declarations)"); + llmsglit (" /*@modifies ,+ @*/"); + llmsglit (" moditem is an lvalue"); + llmsglit (" /*@modifies nothing @*/"); + llmsglit (" /*@*/ (Abbreviation for no globals and modifies nothing.)"); + llmsglit (""); + llmsglit ("Iterators:"); + llmsglit (" /*@iter () @*/ - declare an iterator"); + llmsglit (""); + llmsglit ("Constants:"); + llmsglit (" /*@constant @*/ - declares a constant"); + llmsglit (""); + llmsglit ("Alternate Types:"); + llmsglit (" /*@alt ,+ @*/"); + llmsglit (" (e.g., int /*@alt char@*/ is a type matching either int or char)"); + llmsglit (""); + llmsglit ("Declarator Annotations"); + llmsglit (""); + llmsglit ("Type Definitions:"); + llmsglit (" /*@abstract@*/ - representation is hidden from clients"); + llmsglit (" /*@concrete@*/ - representation is visible to clients"); + llmsglit (" /*@immutable@*/ - instances of the type cannot change value"); + llmsglit (" /*@mutable@*/ - instances of the type can change value"); + llmsglit (" /*@refcounted@*/ - reference counted type"); + llmsglit (""); + llmsglit ("Global Variables:"); + llmsglit (" /*@unchecked@*/ - weakest checking for global use"); + llmsglit (" /*@checkmod@*/ - check modification by not use of global"); + llmsglit (" /*@checked@*/ - check use and modification of global"); + llmsglit (" /*@checkedstrict@*/ - check use of global strictly"); + llmsglit (""); + llmsglit ("Memory Management:"); + llmsglit (" /*@dependent@*/ - a reference to externally-owned storage"); + llmsglit (" /*@keep@*/ - a parameter that is kept by the called function"); + llmsglit (" /*@killref@*/ - a refcounted parameter, killed by the call"); + llmsglit (" /*@only@*/ - an unshared reference"); + llmsglit (" /*@owned@*/ - owner of storage that may be shared by /*@dependent@*/ references"); + llmsglit (" /*@shared@*/ - shared reference that is never deallocated"); + llmsglit (" /*@temp@*/ - temporary parameter"); + llmsglit (""); + llmsglit ("Aliasing:"); + llmsglit (" /*@unique@*/ - may not be aliased by any other visible reference"); + llmsglit (" /*@returned@*/ - may be aliased by the return value"); + llmsglit (""); + llmsglit ("Exposure:"); + llmsglit (" /*@observer@*/ - reference that cannot be modified"); + llmsglit (" /*@exposed@*/ - exposed reference to storage in another object"); + llmsglit (""); + llmsglit ("Definition State:"); + llmsglit (" /*@out@*/ - storage reachable from reference need not be defined"); + llmsglit (" /*@in@*/ - all storage reachable from reference must be defined"); + llmsglit (" /*@partial@*/ - partially defined, may have undefined fields"); + llmsglit (" /*@reldef@*/ - relax definition checking"); + llmsglit (""); + llmsglit ("Global State: (for globals lists, no /*@, since list is already in /*@\'s)"); + llmsglit (" undef - variable is undefined before the call"); + llmsglit (" killed - variable is undefined after the call"); + llmsglit (""); + llmsglit ("Null State:"); + llmsglit (" /*@null@*/ - possibly null pointer"); + llmsglit (" /*@notnull@*/ - definitely non-null pointer"); + llmsglit (" /*@relnull@*/ - relax null checking"); + llmsglit (""); + llmsglit ("Null Predicates:"); + llmsglit (" /*@nullwhentrue@*/ - if result is TRUE, first parameter is NULL"); + llmsglit (" /*@falsewhennull@*/ - if result is TRUE, first parameter is not NULL"); + llmsglit (""); + llmsglit ("Execution:"); + llmsglit (" /*@noreturn@*/ - function never returns"); + llmsglit (" /*@maynotreturn@*/ - function may or may not return"); + llmsglit (" /*@noreturnwhentrue@*/ - function does not return if first parameter is TRUE"); + llmsglit (" /*@noreturnwhenfalse@*/ - function does not return if first parameter if FALSE"); + llmsglit (" /*@alwaysreturns@*/ - function always returns"); + llmsglit (""); + llmsglit ("Side-Effects:"); + llmsglit (" /*@sef@*/ - corresponding actual parameter has no side effects"); + llmsglit (""); + llmsglit ("Declaration:"); + llmsglit (" /*@unused@*/ - need not be used (no unused errors reported)"); + llmsglit (" /*@external@*/ - defined externally (no undefined error reported)"); + llmsglit (""); + llmsglit ("Case:"); + llmsglit (" /*@fallthrough@*/ - fall-through case"); + llmsglit (""); + llmsglit ("Break:"); + llmsglit (" /*@innerbreak@*/ - break is breaking an inner loop or switch"); + llmsglit (" /*@loopbreak@*/ - break is breaking a loop"); + llmsglit (" /*@switchbreak@*/ - break is breaking a switch"); + llmsglit (" /*@innercontinue@*/ - continue is continuing an inner loop"); + llmsglit (""); + llmsglit ("Unreachable Code:"); + llmsglit (" /*@notreached@*/ - statement may be unreachable."); + llmsglit (""); + llmsglit ("Special Functions:"); + llmsglit (" /*@printflike@*/ - check variable arguments like printf"); + llmsglit (" /*@scanflike@*/ - check variable arguments like scanf"); +} + +static void +printComments (void) +{ + llmsglit ("Control Comments"); + llmsglit ("----------------"); + llmsglit (""); + llmsglit ("Setting Flags"); + llmsglit (""); + llmsglit ("Most flags (all except those characterized as \"globally-settable only\") can be set locally using control comments. A control comment can set flags locally to override the command line settings. The original flag settings are restored before processing the next file."); + llmsglit (""); + llmsglit ("The syntax for setting flags in control comments is the same as that of the command line, except that flags may also be preceded by = to restore their setting to the original command-line value. For instance,"); + llmsglit (" /*@+boolint -modifies =showfunc@*/"); + llmsglit ("sets boolint on (this makes bool and int indistinguishable types), sets modifies off (this prevents reporting of modification errors), and sets showfunc to its original setting (this controls whether or not the name of a function is displayed before a message)."); + llmsglit (""); + llmsglit ("Error Suppression"); + llmsglit (""); + llmsglit ("Several comments are provided for suppressing messages. In general, it is usually better to use specific flags to suppress a particular error permanently, but the general error suppression flags may be more convenient for quickly suppressing messages for code that will be corrected or documented later."); + llmsglit (""); + llmsglit ("/*@ignore@*/ ... /*@end@*/"); + llgenindentmsgnoloc + (cstring_makeLiteral + ("No errors will be reported in code regions between /*@ignore@*/ and /*@end@*/. These comments can be used to easily suppress an unlimited number of messages.")); + llmsglit ("/*@i@*/"); + llgenindentmsgnoloc + (cstring_makeLiteral + ("No errors will be reported from an /*@i@*/ comment to the end of the line.")); + llmsglit ("/*@i@*/"); + llgenindentmsgnoloc + (cstring_makeLiteral + ("No errors will be reported from an /*@i@*/ (e.g., /*@i3@*/) comment to the end of the line. If there are not exactly n errors suppressed from the comment point to the end of the line, Splint will report an error.")); + llmsglit ("/*@t@*/, /*@t@*/"); + llgenindentmsgnoloc + (cstring_makeLiteral + ("Like i and i, except controlled by +tmpcomments flag. These can be used to temporarily suppress certain errors. Then, -tmpcomments can be set to find them again.")); + llmsglit (""); + llmsglit ("Type Access"); + llmsglit (""); + llmsglit ("/*@access @*/"); + llmsglit (" Allows the following code to access the representation of "); + llmsglit ("/*@noaccess @*/"); + llmsglit (" Hides the representation of "); + llmsglit (""); + llmsglit ("Macro Expansion"); + llmsglit (""); + llmsglit ("/*@notfunction@*/"); + llgenindentmsgnoloc + (cstring_makeLiteral + ("Indicates that the next macro definition is not intended to be a " + "function, and should be expanded in line instead of checked as a " + "macro function definition.")); +} + +static void +printFlags (void) +{ + llmsglit ("Flag Categories"); + llmsglit ("---------------"); + listAllCategories (); + llmsglit ("\nTo see the flags in a flag category, do\n splint -help flags "); + llmsglit ("To see a list of all flags in alphabetical order, do\n splint -help flags alpha"); + llmsglit ("To see a full description of all flags, do\n splint -help flags full"); +} + +static void +printMaintainer (void) +{ + llmsg (message ("Maintainer: %s", cstring_makeLiteralTemp (SPLINT_MAINTAINER))); + llmsglit (LCL_COMPILE); +} + +static void +printMail (void) +{ + llmsglit ("Mailing Lists"); + llmsglit ("-------------"); + llmsglit (""); + llmsglit ("There are two mailing lists associated with Splint: "); + llmsglit (""); + llmsglit (" lclint-announce@virginia.edu"); + llmsglit (""); + llmsglit (" Reserved for announcements of new releases and bug fixes."); + llmsglit (" To subscribe, send a message to majordomo@virginia.edu with body: "); + llmsglit (" subscribe lclint-announce"); + llmsglit (""); + llmsglit (" lclint-interest@virginia.edu"); + llmsglit (""); + llmsglit (" Informal discussions on the use and development of Splint."); + llmsglit (" To subscribe, send a message to majordomo@virginia.edu with body: "); + llmsglit (" subscribe lclint-interest"); +} + +static void +printReferences (void) +{ + llmsglit ("References"); + llmsglit ("----------"); + llmsglit (""); + llmsglit ("For more information, see the Splint web site: http://www.splint.org"); +} + +static void +describePrefixCodes (void) +{ + llmsglit ("Prefix Codes"); + llmsglit ("------------"); + llmsglit (""); + llmsglit ("These characters have special meaning in name prefixes:"); + llmsglit (""); + llmsg (message (" %h Any uppercase letter [A-Z]", PFX_UPPERCASE)); + llmsg (message (" %h Any lowercase letter [a-z]", PFX_LOWERCASE)); + llmsg (message (" %h Any character (valid in a C identifier)", PFX_ANY)); + llmsg (message (" %h Any digit [0-9]", PFX_DIGIT)); + llmsg (message (" %h Any non-uppercase letter [a-z0-9_]", PFX_NOTUPPER)); + llmsg (message (" %h Any non-lowercase letter [A-Z0-9_]", PFX_NOTLOWER)); + llmsg (message (" %h Any letter [A-Za-z]", PFX_ANYLETTER)); + llmsg (message (" %h Any letter or digit [A-Za-z0-9]", PFX_ANYLETTERDIGIT)); + llmsglit (" * Zero or more repetitions of the previous character class until the end of the name"); +} + +void help_showAvailableHelp (void) +{ + showHerald (); + + llmsg (message ("Source files are .c, .h and %s files. If there is no suffix,", + LCL_EXTENSION)); + llmsg (message (" Splint will look for .c and %s.", LCL_EXTENSION)); + llmsglit (""); + llmsglit ("Use splint -help for more information"); + llmsglit (""); + llmsglit ("Topics:"); + llmsglit (""); + llmsglit (" annotations (describes source-code annotations)"); + llmsglit (" comments (describes control comments)"); + llmsglit (" flags (describes flag categories)"); + llmsglit (" flags (describes flags in category)"); + llmsglit (" flags all (short description of all flags)"); + llmsglit (" flags alpha (list all flags alphabetically)"); + llmsglit (" flags full (full description of all flags)"); + llmsglit (" mail (information on mailing lists)"); + llmsglit (" modes (show mode settings)"); + llmsglit (" parseerrors (help on handling parser errors)"); + llmsglit (" prefixcodes (character codes in namespace prefixes)"); + llmsglit (" references (sources for more information)"); + llmsglit (" vars (environment variables)"); + llmsglit (" version (information on compilation, maintainer)"); + llmsglit (""); +} + +static bool +specialFlagsHelp (char *next) +{ + if ((next != NULL) && (*next != '-') && (*next != '+')) + { + if (mstring_equal (next, "alpha")) + { + printAlphaFlags (); + return TRUE; + } + else if (mstring_equal (next, "all")) + { + printAllFlags (TRUE, FALSE); + return TRUE; + } + else if (mstring_equal (next, "categories") + || mstring_equal (next, "cats")) + { + listAllCategories (); + return TRUE; + } + else if (mstring_equal (next, "full")) + { + printAllFlags (FALSE, TRUE); + return TRUE; + } + else if (mstring_equal (next, "manual")) + { + printFlagManual (FALSE); + return TRUE; + } + else if (mstring_equal (next, "webmanual")) + { + printFlagManual (TRUE); + return TRUE; + } + else + { + return FALSE; + } + } + else + { + return FALSE; + } +} + +static void +printParseErrors (void) +{ + llmsglit ("Parse Errors"); + llmsglit ("------------"); + llmsglit (""); + llmsglit ("Splint will sometimes encounter a parse error for code that " + "can be parsed with a local compiler. There are a few likely " + "causes for this and a number of techniques that can be used " + "to work around the problem."); + llmsglit (""); + llmsglit ("Compiler extensions --- compilers sometimes extend the C " + "language with compiler-specific keywords and syntax. While " + "it is not advisible to use these, oftentimes one has no choice " + "when the system header files use compiler extensions. "); + llmsglit (""); + llmsglit ("Splint supports some of the GNU (gcc) compiler extensions, " + "if the +gnuextensions flag is set. You may be able to workaround " + "other compiler extensions by using a pre-processor define. " + "Alternately, you can surround the unparseable code with"); + llmsglit (""); + llmsglit (" # ifndef S_SPLINT_S"); + llmsglit (" ..."); + llmsglit (" # endif"); + llmsglit (""); + /* evans 2000-12-21 fixed typo reported by Jeroen Ruigrok/Asmodai */ + llmsglit ("Missing type definitions --- an undefined type name will usually " + "lead to a parse error. This often occurs when a standard header " + "file defines some type that is not part of the standard library. "); + llmsglit ("By default, Splint does not process the local files corresponding " + "to standard library headers, but uses a library specification " + "instead so dependencies on local system headers can be detected. " + "If another system header file that does not correspond to a " + "standard library header uses one of these superfluous types, " + "a parse error will result."); + llmsglit (""); + llmsglit ("If the parse error is inside a posix standard header file, the " + "first thing to try is +posixlib. This makes Splint use " + "the posix library specification instead of reading the posix " + "header files."); + llmsglit (""); + llmsglit ("Otherwise, you may need to either manually define the problematic " + "type (e.g., add -Dmlink_t=int to your .splintrc file) or force " + "splint to process the header file that defines it. This is done " + "by setting -skipisoheaders or -skipposixheaders before " + "the file that defines the type is #include'd."); + llmsglit ("(See splint -help " + "skipisoheaders and splint -help skipposixheaders for a list of " + "standard headers.) For example, if uses a type " + "defined by posix header but not defined by the " + "posix library, we might do: "); + llmsglit (""); + llmsglit (" /*@-skipposixheaders@*/"); + llmsglit (" # include "); + llmsglit (" /*@=skipposixheaders@*/"); + llmsglit (" # include "); + llmsglit (""); + llmsglit ("to force Splint to process ."); + llmsglit (""); + llmsglit ("At last resort, +trytorecover can be used to make Splint attempt " + "to continue after a parse error. This is usually not successful " + "and the author does not consider assertion failures when +trytorecover " + "is used to be bugs."); +} + +void help_processFlags (int argc, char **argv) +{ + int i; + + showHerald (); + + if (argc == 0) + { + help_showAvailableHelp (); + } + + for (i = 0; i < argc; i++) + { + char *thisarg = argv[i]; + + if (*thisarg == '-' || *thisarg == '+') + { + thisarg++; /* skip '-' */ + } + if (mstring_equal (thisarg, "modes")) + { + llmsg (describeModes ()); + } + else if (mstring_equal (thisarg, "vars") + || mstring_equal (thisarg, "env")) + { + describeVars (); + } + else if (mstring_equal (thisarg, "annotations")) + { + printAnnotations (); + } + else if (mstring_equal (thisarg, "parseerrors")) + { + printParseErrors (); + } + else if (mstring_equal (thisarg, "comments")) + { + printComments (); + } + else if (mstring_equal (thisarg, "prefixcodes")) + { + describePrefixCodes (); + } + else if (mstring_equal (thisarg, "references") + || mstring_equal (thisarg, "refs")) + { + printReferences (); + } + else if (mstring_equal (thisarg, "mail")) + { + printMail (); + } + else if (mstring_equal (thisarg, "maintainer") + || mstring_equal (thisarg, "version")) + { + printMaintainer (); + } + else if (mstring_equal (thisarg, "flags")) + { + if (i + 1 < argc) + { + char *next = argv[i + 1]; + + if (specialFlagsHelp (next)) + { + i++; + } + else + { + flagkind k = identifyCategory (cstring_fromChars (next)); + + if (k != FK_NONE) + { + printCategory (k); + i++; + } + } + } + else + { + printFlags (); + } + } + else + { + cstring s = describeFlag (cstring_fromChars (thisarg)); + + if (cstring_isDefined (s)) + { + llmsg (s); + } + } + } +} diff --git a/src/lclinit.c b/src/lclinit.c index 58a1260..f6f697a 100644 --- a/src/lclinit.c +++ b/src/lclinit.c @@ -153,7 +153,7 @@ hasFirstChar (ltoken tok) /*@*/ } void -LCLProcessInitFile (void) +lclinit_process (void) { InitLines (); @@ -171,8 +171,6 @@ InitLines (void) setCodePoint (); InitReduce (INITLINES1); - - if (ltoken_getCode (nextToken) != LEOFTOKEN) { InitLine (); @@ -189,15 +187,14 @@ InitLines (void) static void InitLine (void) { - if (ltoken_getCode (nextToken) == LLT_EOL) { /* Nothing on line. */ - InitReduce (INITLINE1); + InitReduce (INITLINE1); } else { - Classification (); + Classification (); InitReduce (INITLINE2); } @@ -205,15 +202,14 @@ InitLine (void) { LocalUserError (nextToken, "Unexpected tokens on line"); } - + nextToken = LCLScanNextToken (); /* Discard EOL */ - } +} static void Classification (void) { lsymbol ntext = ltoken_getRawText (nextToken); - if (ntext == ltoken_getText (endCommentCharToken) || ntext == ltoken_getText (idCharToken) @@ -251,7 +247,7 @@ Classification (void) { llbug (message ("Expected character, token, or synonym classification: %s", ltoken_getRawString (nextToken))); - /* pop off all tokens on this line */ + /* pop off all tokens on this line */ } } @@ -259,9 +255,7 @@ static void CharClass (void) { ltoken charClassToken; - charClassToken = nextToken; - nextToken = LCLScanNextToken (); /* Discard char class keyword. */ if (ltoken_getRawText (charClassToken) == ltoken_getText (endCommentCharToken)) @@ -451,7 +445,7 @@ static void WhiteChar (void) /*@modifies nextToken@*/ } static void - TokenClass (void) /*@modifies nextToken@*/ +TokenClass (void) /*@modifies nextToken@*/ { ltoken tokenClassToken; lsymbol ttext = ltoken_getRawText (nextToken); @@ -1471,7 +1465,7 @@ static void */ void -LCLProcessInitFileInit (void) +lclinit_initMod (void) { int i; @@ -1536,14 +1530,15 @@ LCLProcessInitFileInit (void) } void -LCLProcessInitFileReset (void) +lclinit_reset (void) { nextToken = LCLScanNextToken (); } void -LCLProcessInitFileCleanup (void) +lclinit_cleanup (void) { + ; } diff --git a/src/llerror.c b/src/llerror.c index 95c9621..067128d 100644 --- a/src/llerror.c +++ b/src/llerror.c @@ -173,16 +173,7 @@ void llerror_flagWarning (cstring s) { if (context_getFlag (FLG_WARNFLAGS)) { - showHerald (); - - if (fileloc_isBuiltin (g_currentloc)) - { - llmsg (message ("Warning: %q", s)); - } - else - { - llgenmsg (message ("Warning: %q", s), g_currentloc); - } + llgenmsg (s, g_currentloc); } else { diff --git a/src/llmain.c b/src/llmain.c index 0ebce76..2a5d46c 100644 --- a/src/llmain.c +++ b/src/llmain.c @@ -51,6 +51,7 @@ # include "splintMacros.nf" # include "llbasic.h" # include "osd.h" +# include "help.h" # ifndef NOLCL # include "gram.h" @@ -70,7 +71,6 @@ # endif # include "Headers/version.h" /* Visual C++ finds the wrong version.h */ -# include "fileIdList.h" # include "lcllib.h" # include "cgrammar.h" # include "llmain.h" @@ -78,28 +78,9 @@ extern /*@external@*/ int yydebug; - -static void printMail (void); -static void printMaintainer (void); -static void printReferences (void); -static void printFlags (void); -static void printAnnotations (void); -static void printParseErrors (void); -static void printComments (void); -static void describePrefixCodes (void); static void cleanupFiles (void); -static void showHelp (void); static void interrupt (int p_i); -static bool readOptionsFile (cstring p_fname, - cstringSList *p_passThroughArgs, - bool p_report) - /*@modifies fileSystem, internalState, *p_passThroughArgs@*/ ; - -static void loadrc (FILE *p_rcfile, cstringSList *p_passThroughArgs) - /*@modifies *p_passThroughArgs, p_rcfile@*/ - /*@ensures closed p_rcfile@*/ ; - static void describeVars (void); static bool specialFlagsHelp (char *p_next); static bool hasShownHerald = FALSE; @@ -109,8 +90,6 @@ static char *specFullName (char *p_specfile, /*@out@*/ char **p_inpath) static bool anylcl = FALSE; static clock_t inittime; -static /*@only@*/ /*@null@*/ inputStream initFile = inputStream_undefined; - static fileIdList preprocessFiles (fileIdList, bool) /*@modifies fileSystem@*/ ; @@ -151,163 +130,6 @@ void lslCleanup (void) sort_destroyMod (); } -static - void lslInit (void) - /*@globals undef g_symtab; @*/ - /*@modifies g_symtab, internalState, fileSystem; @*/ -{ - /* - ** Open init file provided by user, or use the default LCL init file - */ - - cstring larchpath = context_getLarchPath (); - inputStream LSLinitFile = inputStream_undefined; - - setCodePoint (); - - if (inputStream_isUndefined (initFile)) - { - initFile = inputStream_create (cstring_makeLiteral (INITFILENAME), - cstring_makeLiteralTemp (LCLINIT_SUFFIX), - FALSE); - - if (!inputStream_getPath (larchpath, initFile)) - { - lldiagmsg (message ("Continuing without LCL init file: %s", - inputStream_fileName (initFile))); - } - else - { - if (!inputStream_open (initFile)) - { - lldiagmsg (message ("Continuing without LCL init file: %s", - inputStream_fileName (initFile))); - } - } - } - else - { - if (!inputStream_open (initFile)) - { - lldiagmsg (message ("Continuing without LCL init file: %s", - inputStream_fileName (initFile))); - } - } - - /* Initialize checker */ - - lsymbol_initMod (); - LCLSynTableInit (); - - setCodePoint (); - - LCLSynTableReset (); - LCLTokenTableInit (); - - setCodePoint (); - - LCLScanLineInit (); - setCodePoint (); - LCLScanLineReset (); - setCodePoint (); - LCLScanInit (); - - setCodePoint (); - - /* need this to initialize LCL checker */ - - llassert (inputStream_isDefined (initFile)); - if (inputStream_isOpen (initFile)) - { - setCodePoint (); - - LCLScanReset (initFile); - LCLProcessInitFileInit (); - LCLProcessInitFileReset (); - - setCodePoint (); - LCLProcessInitFile (); - LCLProcessInitFileCleanup (); - - setCodePoint (); - check (inputStream_close (initFile)); - } - - /* Initialize LSL init files, for parsing LSL signatures from LSL */ - - LSLinitFile = inputStream_create (cstring_makeLiteral ("lslinit.lsi"), - cstring_makeLiteralTemp (".lsi"), - FALSE); - - if (!inputStream_getPath (larchpath, LSLinitFile)) - { - lldiagmsg (message ("Continuing without LSL init file: %s", - inputStream_fileName (LSLinitFile))); - } - else - { - if (!inputStream_open (LSLinitFile)) - { - lldiagmsg (message ("Continuing without LSL init file: %s", - inputStream_fileName (LSLinitFile))); - } - } - - setCodePoint (); - lsynTableInit (); - lsynTableReset (); - - setCodePoint (); - ltokenTableInit (); - - setCodePoint (); - lscanLineInit (); - lscanLineReset (); - LSLScanInit (); - - if (inputStream_isOpen (LSLinitFile)) - { - setCodePoint (); - LSLScanReset (LSLinitFile); - LSLProcessInitFileInit (); - setCodePoint (); - LSLProcessInitFile (); - setCodePoint (); - check (inputStream_close (LSLinitFile)); - } - - inputStream_free (LSLinitFile); - - if (lclHadError ()) - { - lclplainerror - (cstring_makeLiteral ("LSL init file error. Attempting to continue.")); - } - - setCodePoint (); - g_symtab = symtable_new (); - - /* - ** sort_init must come after symtab has been initialized - */ - sort_init (); - abstract_init (); - setCodePoint (); - - inittime = clock (); - - /* - ** Equivalent to importing old spec_csupport.lcl - ** define immutable LCL type "bool" and bool constants TRUE and FALSE - ** and initialized them to be equal to LSL's "true" and "false". - ** - ** Reads in CTrait.syms (derived from CTrait.lsl) on LARCH_PATH. - */ - - LCLBuiltins (); - LCLReportEolTokens (FALSE); -} - static void lslProcess (fileIdList lclfiles) /*@globals undef g_currentSpec, undef g_currentSpecName, g_currentloc, @@ -318,8 +140,9 @@ lslProcess (fileIdList lclfiles) bool parser_status = FALSE; bool overallStatus = FALSE; - lslInit (); - + lslinit_process (); + inittime = clock (); + context_resetSpecLines (); fileIdList_elements (lclfiles, fid) @@ -534,88 +357,6 @@ void showHerald (void) } } -static cstring findLarchPathFile (/*@temp@*/ cstring s) -{ - cstring pathName; - filestatus status; - - status = osd_getPath (context_getLarchPath (), s, &pathName); - - if (status == OSD_FILEFOUND) - { - return pathName; - } - else if (status == OSD_FILENOTFOUND) - { - showHerald (); - lldiagmsg (message ("Cannot find file on LARCH_PATH: %s", s)); - } - else if (status == OSD_PATHTOOLONG) - { - /* Directory and filename are too long. Report error. */ - llbuglit ("soure_getPath: Filename plus directory from search path too long"); - } - else - { - BADBRANCH; - } - - return cstring_undefined; -} - -static void addLarchPathFile (fileIdList files, /*@temp@*/ cstring s) -{ - cstring pathName = findLarchPathFile (s); - - if (cstring_isDefined (pathName)) - { - if (fileTable_exists (context_fileTable (), pathName)) - { - showHerald (); - lldiagmsg (message ("File listed multiple times: %s", pathName)); - cstring_free (pathName); - } - else - { - fileIdList_add (files, fileTable_addFileOnly (context_fileTable (), pathName)); - } - } -} - -static void addFile (fileIdList files, /*@only@*/ cstring s) -{ - if (fileTable_exists (context_fileTable (), s)) - { - showHerald (); - lldiagmsg (message ("File listed multiple times: %s", s)); - cstring_free (s); - } - else - { - fileIdList_add (files, fileTable_addFileOnly (context_fileTable (), s)); - } -} - -static void addXHFile (fileIdList files, /*@temp@*/ cstring s) -{ - cstring pathName = findLarchPathFile (s); - - if (cstring_isDefined (pathName)) - { - if (fileTable_exists (context_fileTable (), pathName)) - { - showHerald (); - lldiagmsg (message ("File listed multiple times: %s", s)); - } - else - { - fileIdList_add (files, fileTable_addXHFile (context_fileTable (), pathName)); - } - } - - cstring_free (pathName); -} - /* ** Disable MSVC++ warning about return value. Methinks humbly splint control ** comments are a mite more legible. @@ -636,16 +377,14 @@ int main (int argc, char *argv[]) @*/ # else /*@globals killed undef g_currentloc, - killed undef initFile, killed g_localSpecPath, killed undef g_currentSpec, killed undef g_currentSpecName, killed undef yyin, undef g_warningstream, g_messagestream, g_errorstream; @*/ - /*@modifies g_currentloc, initFile, - g_localSpecPath, g_currentSpec, g_currentSpecName, fileSystem, - yyin; + /*@modifies g_currentloc, g_localSpecPath, g_currentSpec, g_currentSpecName, + fileSystem, yyin; @*/ # endif { @@ -654,7 +393,6 @@ int main (int argc, char *argv[]) inputStream sourceFile = inputStream_undefined; fileIdList dercfiles; - cstringSList fl = cstringSList_undefined; cstringSList passThroughArgs = cstringSList_undefined; fileIdList cfiles, xfiles, lclfiles, mtfiles; clock_t before, lcltime, libtime, pptime, cptime, rstime; @@ -671,11 +409,6 @@ int main (int argc, char *argv[]) (void) signal (SIGINT, interrupt); (void) signal (SIGSEGV, interrupt); - cfiles = fileIdList_create (); - xfiles = fileIdList_create (); - lclfiles = fileIdList_create (); - mtfiles = fileIdList_create (); - flags_initMod (); clabstract_initMod (); typeIdSet_initMod (); @@ -693,14 +426,18 @@ int main (int argc, char *argv[]) if (argc <= 1) { - showHelp (); + help_showAvailableHelp (); llexit (LLSUCCESS); } /* -help must be the first flag to get help */ - if (flagcode_isHelpFlag (flags_identifyFlag (argv[1]))) + if (flagcode_isHelpFlag (flags_identifyFlag (cstring_fromChars (argv[1])))) { - flags_processHelp (argc - 1, argv + 1); + /* + ** Skip first flag and help flag + */ + + help_processFlags (argc - 2, argv + 2); llexit (LLSUCCESS); } @@ -779,6 +516,10 @@ int main (int argc, char *argv[]) ** check RCFILE for default flags */ + /* + ** Process command line message formatting flags before reading rc file + */ + { cstring home = osd_getHomeDir (); cstring fname = cstring_undefined; @@ -826,10 +567,12 @@ int main (int argc, char *argv[]) } else { - llfatalerror - (message + voptgenerror + (FLG_BADFLAG, + message ("Flag %s must be followed by a string", - flagcode_unparse (opt))); + flagcode_unparse (opt)), + g_currentloc); } } } @@ -839,7 +582,7 @@ int main (int argc, char *argv[]) { defaultf = FALSE; fname = cstring_fromChars (argv[i]); - (void) readOptionsFile (fname, &passThroughArgs, TRUE); + (void) rcfiles_read (fname, &passThroughArgs, TRUE); } else llfatalerror @@ -870,7 +613,7 @@ int main (int argc, char *argv[]) homename = message ("%s%h%s", home, CONNECTCHAR, cstring_fromChars (RCFILE)); - readhomerc = readOptionsFile (homename, &passThroughArgs, FALSE); + readhomerc = rcfiles_read (homename, &passThroughArgs, FALSE); /* ** Try ~/.splintrc also for historical accuracy @@ -878,7 +621,7 @@ int main (int argc, char *argv[]) altname = message ("%s%h%s", home, CONNECTCHAR, cstring_fromChars (ALTRCFILE)); - readaltrc = readOptionsFile (altname, &passThroughArgs, FALSE); + readaltrc = rcfiles_read (altname, &passThroughArgs, FALSE); if (readhomerc && readaltrc) { @@ -905,8 +648,8 @@ int main (int argc, char *argv[]) cstring altname = message ("%s%s",osd_getCurrentDirectory (), cstring_fromChars (ALTRCFILE)); bool readrc, readaltrc; - readrc = readOptionsFile (rcname, &passThroughArgs, FALSE); - readaltrc = readOptionsFile (altname, &passThroughArgs, FALSE); + readrc = rcfiles_read (rcname, &passThroughArgs, FALSE); + readaltrc = rcfiles_read (altname, &passThroughArgs, FALSE); if (readrc && readaltrc) { @@ -925,83 +668,21 @@ int main (int argc, char *argv[]) } setCodePoint (); + llassert (fileloc_isBuiltin (g_currentloc)); + + cfiles = fileIdList_create (); + xfiles = fileIdList_create (); + lclfiles = fileIdList_create (); + mtfiles = fileIdList_create (); /* argv[0] is the program name, don't pass it to flags_processFlags */ - flags_processFlags (argc - 1, argv + 1); + flags_processFlags (TRUE, xfiles, cfiles, + lclfiles, mtfiles, + &passThroughArgs, + argc - 1, argv + 1); showHerald (); - /* - ** create lists of C and LCL files - */ - - cstringSList_elements (fl, current) - { - cstring ext = fileLib_getExtension (current); - - if (cstring_isUndefined (ext)) - { - /* no extension --- both C and LCL with default extensions */ - - addFile (cfiles, message ("%s%s", current, C_EXTENSION)); - addFile (lclfiles, message ("%s%s", current, LCL_EXTENSION)); - } - else if (cstring_equal (ext, XH_EXTENSION)) - { - addXHFile (xfiles, current); - } - else if (cstring_equal (ext, PP_EXTENSION)) - { - if (!context_getFlag (FLG_NOPP)) - { - voptgenerror - (FLG_FILEEXTENSIONS, - message ("File extension %s used without +nopp flag (will be processed as C source code): %s", - ext, current), - g_currentloc); - } - - addFile (cfiles, cstring_copy (current)); - } - else if (cstring_equal (ext, LCL_EXTENSION)) - { - addFile (lclfiles, cstring_copy (current)); - } - else if (fileLib_isCExtension (ext)) - { - addFile (cfiles, cstring_copy (current)); - } - else if (cstring_equal (ext, MTS_EXTENSION)) - { - addLarchPathFile (mtfiles, current); - } - else - { - voptgenerror - (FLG_FILEEXTENSIONS, - message ("Unrecognized file extension: %s (assuming %s is C source code)", - current, ext), - g_currentloc); - - addFile (cfiles, cstring_copy (current)); - } - } end_cstringSList_elements; - - if (showhelp) - { - if (allhelp) - { - showHelp (); - } - fprintf (g_warningstream, "\n"); - - fileIdList_free (cfiles); - fileIdList_free (xfiles); - fileIdList_free (lclfiles); - - llexit (LLSUCCESS); - } - # ifdef DOANNOTS initAnnots (); # endif @@ -1077,12 +758,14 @@ int main (int argc, char *argv[]) */ context_setInCommandLine (); - + DPRINTF (("Pass through: %s", cstringSList_unparse (passThroughArgs))); - cstringSList_elements (passThroughArgs, thisarg) { - handlePassThroughFlag (cstring_toCharsSafe (thisarg)); - } end_cstringSList_elements; + cstringSList_elements (passThroughArgs, thisarg) + { + handlePassThroughFlag (cstring_toCharsSafe (thisarg)); + } + end_cstringSList_elements; cstringSList_free (passThroughArgs); @@ -1400,22 +1083,25 @@ int main (int argc, char *argv[]) { clock_t ttime = clock () - before; int specLines = context_getSpecLinesProcessed (); - + cstring specmsg = cstring_undefined; + rstime = clock (); if (specLines > 0) { - fprintf (g_warningstream, "%d spec, ", specLines); + specmsg = message ("%d spec, ", specLines); } # ifndef CLOCKS_PER_SEC - fprintf (g_warningstream, "%d source lines in %ld time steps (steps/sec unknown)\n", - context_getLinesProcessed (), - (long) ttime); + lldiagmsg (message ("%s%d source lines in %d time steps (steps/sec unknown)\n", + specmsg, + context_getLinesProcessed (), + (int) ttime)); # else - fprintf (g_warningstream, "%d source lines in %.2f s.\n", - context_getLinesProcessed (), - (double) ttime / CLOCKS_PER_SEC); + lldiagmsg (message ("%s%d source lines in %f s.\n", + specmsg, + context_getLinesProcessed (), + (double) ttime / CLOCKS_PER_SEC)); # endif } else @@ -1468,444 +1154,6 @@ int main (int argc, char *argv[]) # pragma warning (default:4035) # endif -void -showHelp (void) -{ - showHerald (); - - llmsg (message ("Source files are .c, .h and %s files. If there is no suffix,", - LCL_EXTENSION)); - llmsg (message (" Splint will look for .c and %s.", LCL_EXTENSION)); - llmsglit (""); - llmsglit ("Use splint -help for more information"); - llmsglit (""); - llmsglit ("Topics:"); - llmsglit (""); - llmsglit (" annotations (describes source-code annotations)"); - llmsglit (" comments (describes control comments)"); - llmsglit (" flags (describes flag categories)"); - llmsglit (" flags (describes flags in category)"); - llmsglit (" flags all (short description of all flags)"); - llmsglit (" flags alpha (list all flags alphabetically)"); - llmsglit (" flags full (full description of all flags)"); - llmsglit (" mail (information on mailing lists)"); - llmsglit (" modes (show mode settings)"); - llmsglit (" parseerrors (help on handling parser errors)"); - llmsglit (" prefixcodes (character codes in namespace prefixes)"); - llmsglit (" references (sources for more information)"); - llmsglit (" vars (environment variables)"); - llmsglit (" version (information on compilation, maintainer)"); - llmsglit (""); -} - -static bool -specialFlagsHelp (char *next) -{ - if ((next != NULL) && (*next != '-') && (*next != '+')) - { - if (mstring_equal (next, "alpha")) - { - printAlphaFlags (); - return TRUE; - } - else if (mstring_equal (next, "all")) - { - printAllFlags (TRUE, FALSE); - return TRUE; - } - else if (mstring_equal (next, "categories") - || mstring_equal (next, "cats")) - { - listAllCategories (); - return TRUE; - } - else if (mstring_equal (next, "full")) - { - printAllFlags (FALSE, TRUE); - return TRUE; - } - else if (mstring_equal (next, "manual")) - { - printFlagManual (FALSE); - return TRUE; - } - else if (mstring_equal (next, "webmanual")) - { - printFlagManual (TRUE); - return TRUE; - } - else - { - return FALSE; - } - } - else - { - return FALSE; - } -} - -void -printParseErrors (void) -{ - llmsglit ("Parse Errors"); - llmsglit ("------------"); - llmsglit (""); - llmsglit ("Splint will sometimes encounter a parse error for code that " - "can be parsed with a local compiler. There are a few likely " - "causes for this and a number of techniques that can be used " - "to work around the problem."); - llmsglit (""); - llmsglit ("Compiler extensions --- compilers sometimes extend the C " - "language with compiler-specific keywords and syntax. While " - "it is not advisible to use these, oftentimes one has no choice " - "when the system header files use compiler extensions. "); - llmsglit (""); - llmsglit ("Splint supports some of the GNU (gcc) compiler extensions, " - "if the +gnuextensions flag is set. You may be able to workaround " - "other compiler extensions by using a pre-processor define. " - "Alternately, you can surround the unparseable code with"); - llmsglit (""); - llmsglit (" # ifndef S_SPLINT_S"); - llmsglit (" ..."); - llmsglit (" # endif"); - llmsglit (""); - /* evans 2000-12-21 fixed typo reported by Jeroen Ruigrok/Asmodai */ - llmsglit ("Missing type definitions --- an undefined type name will usually " - "lead to a parse error. This often occurs when a standard header " - "file defines some type that is not part of the standard library. "); - llmsglit ("By default, Splint does not process the local files corresponding " - "to standard library headers, but uses a library specification " - "instead so dependencies on local system headers can be detected. " - "If another system header file that does not correspond to a " - "standard library header uses one of these superfluous types, " - "a parse error will result."); - llmsglit (""); - llmsglit ("If the parse error is inside a posix standard header file, the " - "first thing to try is +posixlib. This makes Splint use " - "the posix library specification instead of reading the posix " - "header files."); - llmsglit (""); - llmsglit ("Otherwise, you may need to either manually define the problematic " - "type (e.g., add -Dmlink_t=int to your .splintrc file) or force " - "splint to process the header file that defines it. This is done " - "by setting -skipisoheaders or -skipposixheaders before " - "the file that defines the type is #include'd."); - llmsglit ("(See splint -help " - "skipisoheaders and splint -help skipposixheaders for a list of " - "standard headers.) For example, if uses a type " - "defined by posix header but not defined by the " - "posix library, we might do: "); - llmsglit (""); - llmsglit (" /*@-skipposixheaders@*/"); - llmsglit (" # include "); - llmsglit (" /*@=skipposixheaders@*/"); - llmsglit (" # include "); - llmsglit (""); - llmsglit ("to force Splint to process ."); - llmsglit (""); - llmsglit ("At last resort, +trytorecover can be used to make Splint attempt " - "to continue after a parse error. This is usually not successful " - "and the author does not consider assertion failures when +trytorecover " - "is used to be bugs."); -} - -void -printAnnotations (void) -{ - llmsglit ("Annotations"); - llmsglit ("-----------"); - llmsglit (""); - llmsglit ("Annotations are semantic comments that document certain " - "assumptions about functions, variables, parameters, and types. "); - llmsglit (""); - llmsglit ("They may be used to indicate where the representation of a " - "user-defined type is hidden, to limit where a global variable may " - "be used or modified, to constrain what a function implementation " - "may do to its parameters, and to express checked assumptions about " - "variables, types, structure fields, function parameters, and " - "function results."); - llmsglit (""); - llmsglit ("Annotations are introduced by \"/*@\". The role of the @ may be " - "played by any printable character, selected using -commentchar ."); - llmsglit (""); - llmsglit ("Consult the User's Guide for descriptions of checking associated with each annotation."); - llmsglit (""); - llmsglit ("Globals: (in function declarations)"); - llmsglit (" /*@globals ,+ @*/"); - llmsglit (" globitem is an identifier, internalState or fileSystem"); - llmsglit (""); - llmsglit ("Modifies: (in function declarations)"); - llmsglit (" /*@modifies ,+ @*/"); - llmsglit (" moditem is an lvalue"); - llmsglit (" /*@modifies nothing @*/"); - llmsglit (" /*@*/ (Abbreviation for no globals and modifies nothing.)"); - llmsglit (""); - llmsglit ("Iterators:"); - llmsglit (" /*@iter () @*/ - declare an iterator"); - llmsglit (""); - llmsglit ("Constants:"); - llmsglit (" /*@constant @*/ - declares a constant"); - llmsglit (""); - llmsglit ("Alternate Types:"); - llmsglit (" /*@alt ,+ @*/"); - llmsglit (" (e.g., int /*@alt char@*/ is a type matching either int or char)"); - llmsglit (""); - llmsglit ("Declarator Annotations"); - llmsglit (""); - llmsglit ("Type Definitions:"); - llmsglit (" /*@abstract@*/ - representation is hidden from clients"); - llmsglit (" /*@concrete@*/ - representation is visible to clients"); - llmsglit (" /*@immutable@*/ - instances of the type cannot change value"); - llmsglit (" /*@mutable@*/ - instances of the type can change value"); - llmsglit (" /*@refcounted@*/ - reference counted type"); - llmsglit (""); - llmsglit ("Global Variables:"); - llmsglit (" /*@unchecked@*/ - weakest checking for global use"); - llmsglit (" /*@checkmod@*/ - check modification by not use of global"); - llmsglit (" /*@checked@*/ - check use and modification of global"); - llmsglit (" /*@checkedstrict@*/ - check use of global strictly"); - llmsglit (""); - llmsglit ("Memory Management:"); - llmsglit (" /*@dependent@*/ - a reference to externally-owned storage"); - llmsglit (" /*@keep@*/ - a parameter that is kept by the called function"); - llmsglit (" /*@killref@*/ - a refcounted parameter, killed by the call"); - llmsglit (" /*@only@*/ - an unshared reference"); - llmsglit (" /*@owned@*/ - owner of storage that may be shared by /*@dependent@*/ references"); - llmsglit (" /*@shared@*/ - shared reference that is never deallocated"); - llmsglit (" /*@temp@*/ - temporary parameter"); - llmsglit (""); - llmsglit ("Aliasing:"); - llmsglit (" /*@unique@*/ - may not be aliased by any other visible reference"); - llmsglit (" /*@returned@*/ - may be aliased by the return value"); - llmsglit (""); - llmsglit ("Exposure:"); - llmsglit (" /*@observer@*/ - reference that cannot be modified"); - llmsglit (" /*@exposed@*/ - exposed reference to storage in another object"); - llmsglit (""); - llmsglit ("Definition State:"); - llmsglit (" /*@out@*/ - storage reachable from reference need not be defined"); - llmsglit (" /*@in@*/ - all storage reachable from reference must be defined"); - llmsglit (" /*@partial@*/ - partially defined, may have undefined fields"); - llmsglit (" /*@reldef@*/ - relax definition checking"); - llmsglit (""); - llmsglit ("Global State: (for globals lists, no /*@, since list is already in /*@\'s)"); - llmsglit (" undef - variable is undefined before the call"); - llmsglit (" killed - variable is undefined after the call"); - llmsglit (""); - llmsglit ("Null State:"); - llmsglit (" /*@null@*/ - possibly null pointer"); - llmsglit (" /*@notnull@*/ - definitely non-null pointer"); - llmsglit (" /*@relnull@*/ - relax null checking"); - llmsglit (""); - llmsglit ("Null Predicates:"); - llmsglit (" /*@nullwhentrue@*/ - if result is TRUE, first parameter is NULL"); - llmsglit (" /*@falsewhennull@*/ - if result is TRUE, first parameter is not NULL"); - llmsglit (""); - llmsglit ("Execution:"); - llmsglit (" /*@noreturn@*/ - function never returns"); - llmsglit (" /*@maynotreturn@*/ - function may or may not return"); - llmsglit (" /*@noreturnwhentrue@*/ - function does not return if first parameter is TRUE"); - llmsglit (" /*@noreturnwhenfalse@*/ - function does not return if first parameter if FALSE"); - llmsglit (" /*@alwaysreturns@*/ - function always returns"); - llmsglit (""); - llmsglit ("Side-Effects:"); - llmsglit (" /*@sef@*/ - corresponding actual parameter has no side effects"); - llmsglit (""); - llmsglit ("Declaration:"); - llmsglit (" /*@unused@*/ - need not be used (no unused errors reported)"); - llmsglit (" /*@external@*/ - defined externally (no undefined error reported)"); - llmsglit (""); - llmsglit ("Case:"); - llmsglit (" /*@fallthrough@*/ - fall-through case"); - llmsglit (""); - llmsglit ("Break:"); - llmsglit (" /*@innerbreak@*/ - break is breaking an inner loop or switch"); - llmsglit (" /*@loopbreak@*/ - break is breaking a loop"); - llmsglit (" /*@switchbreak@*/ - break is breaking a switch"); - llmsglit (" /*@innercontinue@*/ - continue is continuing an inner loop"); - llmsglit (""); - llmsglit ("Unreachable Code:"); - llmsglit (" /*@notreached@*/ - statement may be unreachable."); - llmsglit (""); - llmsglit ("Special Functions:"); - llmsglit (" /*@printflike@*/ - check variable arguments like printf"); - llmsglit (" /*@scanflike@*/ - check variable arguments like scanf"); -} - -void -printComments (void) -{ - llmsglit ("Control Comments"); - llmsglit ("----------------"); - llmsglit (""); - llmsglit ("Setting Flags"); - llmsglit (""); - llmsglit ("Most flags (all except those characterized as \"globally-settable only\") can be set locally using control comments. A control comment can set flags locally to override the command line settings. The original flag settings are restored before processing the next file."); - llmsglit (""); - llmsglit ("The syntax for setting flags in control comments is the same as that of the command line, except that flags may also be preceded by = to restore their setting to the original command-line value. For instance,"); - llmsglit (" /*@+boolint -modifies =showfunc@*/"); - llmsglit ("sets boolint on (this makes bool and int indistinguishable types), sets modifies off (this prevents reporting of modification errors), and sets showfunc to its original setting (this controls whether or not the name of a function is displayed before a message)."); - llmsglit (""); - llmsglit ("Error Suppression"); - llmsglit (""); - llmsglit ("Several comments are provided for suppressing messages. In general, it is usually better to use specific flags to suppress a particular error permanently, but the general error suppression flags may be more convenient for quickly suppressing messages for code that will be corrected or documented later."); - llmsglit (""); - llmsglit ("/*@ignore@*/ ... /*@end@*/"); - llgenindentmsgnoloc - (cstring_makeLiteral - ("No errors will be reported in code regions between /*@ignore@*/ and /*@end@*/. These comments can be used to easily suppress an unlimited number of messages.")); - llmsglit ("/*@i@*/"); - llgenindentmsgnoloc - (cstring_makeLiteral - ("No errors will be reported from an /*@i@*/ comment to the end of the line.")); - llmsglit ("/*@i@*/"); - llgenindentmsgnoloc - (cstring_makeLiteral - ("No errors will be reported from an /*@i@*/ (e.g., /*@i3@*/) comment to the end of the line. If there are not exactly n errors suppressed from the comment point to the end of the line, Splint will report an error.")); - llmsglit ("/*@t@*/, /*@t@*/"); - llgenindentmsgnoloc - (cstring_makeLiteral - ("Like i and i, except controlled by +tmpcomments flag. These can be used to temporarily suppress certain errors. Then, -tmpcomments can be set to find them again.")); - llmsglit (""); - llmsglit ("Type Access"); - llmsglit (""); - llmsglit ("/*@access @*/"); - llmsglit (" Allows the following code to access the representation of "); - llmsglit ("/*@noaccess @*/"); - llmsglit (" Hides the representation of "); - llmsglit (""); - llmsglit ("Macro Expansion"); - llmsglit (""); - llmsglit ("/*@notfunction@*/"); - llgenindentmsgnoloc - (cstring_makeLiteral - ("Indicates that the next macro definition is not intended to be a " - "function, and should be expanded in line instead of checked as a " - "macro function definition.")); -} - - -void -printFlags (void) -{ - llmsglit ("Flag Categories"); - llmsglit ("---------------"); - listAllCategories (); - llmsglit ("\nTo see the flags in a flag category, do\n splint -help flags "); - llmsglit ("To see a list of all flags in alphabetical order, do\n splint -help flags alpha"); - llmsglit ("To see a full description of all flags, do\n splint -help flags full"); -} - -void -printMaintainer (void) -{ - llmsg (message ("Maintainer: %s", cstring_makeLiteralTemp (SPLINT_MAINTAINER))); - llmsglit (LCL_COMPILE); -} - -void -printMail (void) -{ - llmsglit ("Mailing Lists"); - llmsglit ("-------------"); - llmsglit (""); - llmsglit ("There are two mailing lists associated with Splint: "); - llmsglit (""); - llmsglit (" lclint-announce@virginia.edu"); - llmsglit (""); - llmsglit (" Reserved for announcements of new releases and bug fixes."); - llmsglit (" To subscribe, send a message to majordomo@virginia.edu with body: "); - llmsglit (" subscribe lclint-announce"); - llmsglit (""); - llmsglit (" lclint-interest@virginia.edu"); - llmsglit (""); - llmsglit (" Informal discussions on the use and development of Splint."); - llmsglit (" To subscribe, send a message to majordomo@virginia.edu with body: "); - llmsglit (" subscribe lclint-interest"); -} - -void -printReferences (void) -{ - llmsglit ("References"); - llmsglit ("----------"); - llmsglit (""); - llmsglit ("For more information, see the Splint web site: http://www.splint.org"); -} - -void -describePrefixCodes (void) -{ - llmsglit ("Prefix Codes"); - llmsglit ("------------"); - llmsglit (""); - llmsglit ("These characters have special meaning in name prefixes:"); - llmsglit (""); - llmsg (message (" %h Any uppercase letter [A-Z]", PFX_UPPERCASE)); - llmsg (message (" %h Any lowercase letter [a-z]", PFX_LOWERCASE)); - llmsg (message (" %h Any character (valid in a C identifier)", PFX_ANY)); - llmsg (message (" %h Any digit [0-9]", PFX_DIGIT)); - llmsg (message (" %h Any non-uppercase letter [a-z0-9_]", PFX_NOTUPPER)); - llmsg (message (" %h Any non-lowercase letter [A-Z0-9_]", PFX_NOTLOWER)); - llmsg (message (" %h Any letter [A-Za-z]", PFX_ANYLETTER)); - llmsg (message (" %h Any letter or digit [A-Za-z0-9]", PFX_ANYLETTERDIGIT)); - llmsglit (" * Zero or more repetitions of the previous character class until the end of the name"); -} - -void -describeVars (void) -{ - cstring eval; - cstring def; - - eval = context_getLarchPath (); - def = osd_getEnvironmentVariable (LARCH_PATH); - - if (cstring_isDefined (def) || - !cstring_equal (eval, cstring_fromChars (DEFAULT_LARCHPATH))) - { - llmsg (message ("LARCH_PATH = %s", eval)); - } - else - { - llmsg (message ("LARCH_PATH = (default = %s)", - cstring_fromChars (DEFAULT_LARCHPATH))); - } - - llmsglit (" --- path used to find larch initialization files and LSL traits"); - - eval = context_getLCLImportDir (); - def = osd_getEnvironmentVariable (cstring_makeLiteralTemp (LCLIMPORTDIR)); - - if (cstring_isDefined (def) || - !cstring_equal (eval, cstring_fromChars (DEFAULT_LCLIMPORTDIR))) - { - llmsg (message ("%q = %s", cstring_makeLiteral (LCLIMPORTDIR), eval)); - } - else - { - llmsg (message ("%s = ", cstring_makeLiteralTemp (LCLIMPORTDIR), - cstring_makeLiteralTemp (DEFAULT_LCLIMPORTDIR))); - } - - llmsglit (" --- directory containing lcl standard library files " - "(import with < ... >)");; - - llmsg (message - ("include path = %q (set by environment variable %s and -I flags)", - cppReader_getIncludePath (), INCLUDEPATH_VAR)); - - llmsglit (" --- path used to find #include'd files"); - - llmsg (message - ("systemdirs = %s (set by -systemdirs or environment variable %s)", /*@i413223@*/ - context_getString (FLG_SYSTEMDIRS), - INCLUDEPATH_VAR)); - - llmsglit (" --- if file is found on this path, it is treated as a system file for error reporting"); -} - void interrupt (int i) { @@ -2021,384 +1269,6 @@ llexit (int status) exit ((status == LLSUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE); } -bool readOptionsFile (cstring fname, cstringSList *passThroughArgs, bool report) -{ - bool res = FALSE; - - if (fileTable_exists (context_fileTable (), fname)) - { - if (report) - { - voptgenerror - (FLG_WARNRC, - message ("Multiple attempts to read options file: %s", fname), - g_currentloc); - } - } - else - { - FILE *innerf = fileTable_openReadFile (context_fileTable (), fname); - - if (innerf != NULL) - { - fileloc fc = g_currentloc; - g_currentloc = fileloc_createRc (fname); - - displayScan (message ("< reading options from %q >", - fileloc_outputFilename (g_currentloc))); - - loadrc (innerf, passThroughArgs); - fileloc_reallyFree (g_currentloc); - g_currentloc = fc; - res = TRUE; - } - else - { - if (report) - { - voptgenerror - (FLG_WARNRC, - message ("Cannot open options file: %s", fname), - g_currentloc); - } - } - } - - return res; -} - -/* -** This shouldn't be necessary, but Apple Darwin can't handle '"''s. -*/ - -void -loadrc (/*:open:*/ FILE *rcfile, cstringSList *passThroughArgs) - /*@modifies rcfile@*/ - /*@ensures closed rcfile@*/ -{ - char *s = mstring_create (MAX_LINE_LENGTH); - char *os = s; - - DPRINTF (("Pass through: %s", cstringSList_unparse (*passThroughArgs))); - - s = os; - - while (reader_readLine (rcfile, s, MAX_LINE_LENGTH) != NULL) - { - char c; - bool set = FALSE; - char *thisflag; - flagcode opt; - - DPRINTF (("Line: %s", s)); - DPRINTF (("Pass through: %s", cstringSList_unparse (*passThroughArgs))); - - while (*s == ' ' || *s == '\t') - { - s++; - incColumn (); - } - - while (*s != '\0') - { - bool escaped = FALSE; - bool quoted = FALSE; - c = *s; - - DPRINTF (("Process: %s", s)); - DPRINTF (("Pass through: %s", cstringSList_unparse (*passThroughArgs))); - /* comment characters */ - if (c == '#' || c == ';' || c == '\n') - { - /*@innerbreak@*/ - break; - } - - if (c == '-' || c == '+') - { - set = (c == '+'); - } - else - { - showHerald (); - voptgenerror (FLG_BADFLAG, - message ("Bad flag syntax (+ or - expected, " - "+ is assumed): %s", - cstring_fromChars (s)), - g_currentloc); - s--; - set = TRUE; - } - - s++; - incColumn (); - - thisflag = s; - - while ((c = *s) != '\0') - { /* remember to handle spaces and quotes in -D and -U ... */ - if (escaped) - { - escaped = FALSE; - } - else if (quoted) - { - if (c == '\\') - { - escaped = TRUE; - } - else if (c == '\"') - { - quoted = FALSE; - } - else - { - ; - } - } - else if (c == '\"') - { - quoted = TRUE; - } - else - { - if (c == ' ' || c == '\t' || c == '\n') - { - /*@innerbreak@*/ break; - } - } - - s++; - incColumn (); - } - - DPRINTF (("Nulling: %c", *s)); - *s = '\0'; - - if (mstring_isEmpty (thisflag)) - { - llfatalerror (message ("Missing flag: %s", - cstring_fromChars (os))); - } - - DPRINTF (("Flag: %s", thisflag)); - - opt = flags_identifyFlag (cstring_fromChars (thisflag)); - - if (flagcode_isSkip (opt)) - { - ; - } - else if (flagcode_isInvalid (opt)) - { - DPRINTF (("Invalid: %s", thisflag)); - - if (flags_isModeName (cstring_fromChars (thisflag))) - { - context_setMode (cstring_fromChars (thisflag)); - } - else - { - voptgenerror (FLG_BADFLAG, - message ("Unrecognized option: %s", - cstring_fromChars (thisflag)), - g_currentloc); - } - } - else - { - context_userSetFlag (opt, set); - - if (flagcode_hasArgument (opt)) - { - if (opt == FLG_HELP) - { - showHerald (); - voptgenerror (FLG_BADFLAG, - message ("Cannot use help in rc files"), - g_currentloc); - } - else if (flagcode_isPassThrough (opt)) /* -D or -U */ - { - cstring arg = cstring_fromCharsNew (thisflag); - cstring_markOwned (arg); - *passThroughArgs = cstringSList_add (*passThroughArgs, arg); - DPRINTF (("Pass through: %s", - cstringSList_unparse (*passThroughArgs))); - } - else if (opt == FLG_INCLUDEPATH - || opt == FLG_SPECPATH) - { - cstring dir; - - /* - ** Either -I or -I - */ - - if (cstring_length (thisflag) > 1) - { - dir = cstring_suffix (cstring_fromChars (thisflag), 1); /* skip over I/S */ - } - else - { - BADBRANCH; /*@!!!!@*/ - } - - switch (opt) - { - case FLG_INCLUDEPATH: - cppAddIncludeDir (dir); - /*@switchbreak@*/ break; - case FLG_SPECPATH: - /*@-mustfree@*/ - g_localSpecPath = cstring_toCharsSafe - (message ("%s:%s", cstring_fromChars (g_localSpecPath), dir)); - /*@=mustfree@*/ - /*@switchbreak@*/ break; - BADDEFAULT; - } - } - else if (flagcode_hasString (opt) - || flagcode_hasNumber (opt) - || flagcode_hasChar (opt) - || opt == FLG_INIT || opt == FLG_OPTF) - { - cstring extra = cstring_undefined; - char *rest, *orest; - char rchar; - - *s = c; - rest = mstring_copy (s); - DPRINTF (("Here: rest = %s", rest)); - orest = rest; - *s = '\0'; - - while ((rchar = *rest) != '\0' - && (isspace ((int) rchar))) - { - rest++; - s++; - } - - DPRINTF (("Yo: %s", rest)); - - while ((rchar = *rest) != '\0' - && !isspace ((int) rchar)) - { - extra = cstring_appendChar (extra, rchar); - rest++; - s++; - } - - DPRINTF (("Yo: %s", extra)); - sfree (orest); - - if (cstring_isUndefined (extra)) - { - showHerald (); - voptgenerror - (FLG_BADFLAG, - message - ("Flag %s must be followed by an argument", - flagcode_unparse (opt)), - g_currentloc); - } - else - { - s--; - - DPRINTF (("Here we are: %s", extra)); - - if (flagcode_hasNumber (opt) || flagcode_hasChar (opt)) - { - DPRINTF (("Set value flag: %s", extra)); - setValueFlag (opt, extra); - } - else if (opt == FLG_OPTF) - { - (void) readOptionsFile (extra, passThroughArgs, TRUE); - } - else if (opt == FLG_INIT) - { -# ifndef NOLCL - llassert (inputStream_isUndefined (initFile)); - - initFile = inputStream_create - (cstring_copy (extra), - cstring_makeLiteralTemp (LCLINIT_SUFFIX), - FALSE); -# endif - } - else if (flagcode_hasString (opt)) - { - DPRINTF (("Here: %s", extra)); - - /* - ** If it has "'s, we need to remove them. - */ - - if (cstring_firstChar (extra) == '\"') - { - if (cstring_lastChar (extra) == '\"') - { - cstring unquoted = cstring_copyLength - (cstring_toCharsSafe (cstring_suffix (extra, 1)), - cstring_length (extra) - 2); - - DPRINTF (("string flag: %s -> %s", extra, unquoted)); - setStringFlag (opt, unquoted); - cstring_free (extra); - } - else - { - voptgenerror - (FLG_BADFLAG, - message ("Unmatched \" in option string: %s", - extra), - g_currentloc); - setStringFlag (opt, extra); - } - } - else - { - DPRINTF (("No quotes: %s", extra)); - setStringFlag (opt, extra); - } - - extra = cstring_undefined; - } - else - { - BADEXIT; - } - } - - cstring_free (extra); - } - else - { - BADEXIT; - } - } - } - - *s = c; - DPRINTF (("Pass through: %s", cstringSList_unparse (*passThroughArgs))); - while ((c == ' ') || (c == '\t')) - { - c = *(++s); - incColumn (); - } - } - DPRINTF (("Pass through: %s", cstringSList_unparse (*passThroughArgs))); - s = os; - } - - DPRINTF (("Pass through: %s", cstringSList_unparse (*passThroughArgs))); - sfree (os); - check (fileTable_closeFile (context_fileTable (), rcfile)); -} - static fileIdList preprocessFiles (fileIdList fl, bool xhfiles) /*@modifies fileSystem@*/ { @@ -2436,13 +1306,11 @@ static fileIdList preprocessFiles (fileIdList fl, bool xhfiles) if ((filesprocessed % skip) == 0) { if (filesprocessed == 0) { - fprintf (g_messagestream, " "); + displayScan (cstring_makeLiteral (" ")); } else { - fprintf (g_messagestream, "."); + displayScan (cstring_makeLiteral (".")); } - - (void) fflush (g_messagestream); } filesprocessed++; } diff --git a/src/lslinit.c b/src/lslinit.c deleted file mode 100644 index 01fbdad..0000000 --- a/src/lslinit.c +++ /dev/null @@ -1,1555 +0,0 @@ -/* -** Splint - annotation-assisted static program checker -** Copyright (C) 1994-2002 University of Virginia, -** Massachusetts Institute of Technology -** -** This program is free software; you can redistribute it and/or modify it -** under the terms of the GNU General Public License as published by the -** Free Software Foundation; either version 2 of the License, or (at your -** option) any later version. -** -** This program is distributed in the hope that it will be useful, but -** WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** -** The GNU General Public License is available from http://www.gnu.org/ or -** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -** MA 02111-1307, USA. -** -** For information on splint: info@splint.org -** To report a bug: splint-bug@splint.org -** For more information: http://www.splint.org -*/ -/* -** lslinit.c -** -** Processor for Larch Shared Language Init Files -*/ - -# include "splintMacros.nf" -# include "llbasic.h" -# include "signature.h" -# include "signature2.h" -# include "scan.h" -# include "scanline.h" -# include "tokentable.h" -# include "syntable.h" -# include "lslinit.h" - -/* needed to parse init files */ -# include "shift.h" -#if TRACING == 1 -/*@notfunction@*/ -# define LTRACE(rule) printf ("Reducing: %s\n", rule) -#else -/*@notfunction@*/ -# define LTRACE(rule) -#endif - -static void LocalUserError (ltoken p_t, /*@temp@*/ char *p_msg) - /*@modifies *g_warningstream@*/; - -static /*@only@*/ ltoken nextToken; - -static void InitFile (void) /*@modifies nextToken@*/ ; -static void InitLines (void) /*@modifies nextToken@*/ ; -static void InitLine (void) /*@modifies nextToken@*/ ; -static void Classification (void) /*@modifies nextToken@*/ ; -static void CharClass (void) /*@modifies nextToken@*/ ; - -static void EndCommentChars (void) /*@modifies nextToken@*/ ; -static void IdChars (void) /*@modifies nextToken@*/ ; -static void OpChars (void) /*@modifies nextToken@*/ ; -static void ExtensionChar (void) /*@modifies nextToken@*/ ; -static void SingChars (void) /*@modifies nextToken@*/ ; -static void WhiteChars (void) /*@modifies nextToken@*/ ; -static void EndCommentChar (void) /*@modifies nextToken@*/ ; -static void IdChar (void) /*@modifies nextToken@*/ ; -static void OpChar (void) /*@modifies nextToken@*/ ; -static void SingChar (void) /*@modifies nextToken@*/ ; -static void WhiteChar (void) /*@modifies nextToken@*/ ; - -static void TokenClass (void) /*@modifies nextToken@*/ ; -static void QuantifierSymToks (void) /*@modifies nextToken@*/ ; -static void LogicalOpToks (void) /*@modifies nextToken@*/ ; -static void EqOpToks (void) /*@modifies nextToken@*/ ; -static void EquationSymToks (void) /*@modifies nextToken@*/ ; -static void EqSepSymToks (void) /*@modifies nextToken@*/ ; -static void SelectSymToks (void) /*@modifies nextToken@*/ ; -static void OpenSymToks (void) /*@modifies nextToken@*/ ; -static void SepSymToks (void) /*@modifies nextToken@*/ ; -static void CloseSymToks (void) /*@modifies nextToken@*/ ; -static void SimpleIdToks (void) /*@modifies nextToken@*/ ; -static void MapSymToks (void) /*@modifies nextToken@*/ ; -static void MarkerSymToks (void) /*@modifies nextToken@*/ ; -static void CommentSymToks (void) /*@modifies nextToken@*/ ; -static void QuantifierSymTok (void) /*@modifies nextToken@*/ ; -static void LogicalOpTok (void) /*@modifies nextToken@*/ ; -static void EqOpTok (void) /*@modifies nextToken@*/ ; -static void EquationSymTok (void) /*@modifies nextToken@*/ ; -static void EqSepSymTok (void) /*@modifies nextToken@*/ ; -static void SelectSymTok (void) /*@modifies nextToken@*/ ; -static void OpenSymTok (void) /*@modifies nextToken@*/ ; -static void SepSymTok (void) /*@modifies nextToken@*/ ; -static void CloseSymTok (void) /*@modifies nextToken@*/ ; -static void SimpleIdTok (void) /*@modifies nextToken@*/ ; -static void MapSymTok (void) /*@modifies nextToken@*/ ; -static void MarkerSymTok (void) /*@modifies nextToken@*/ ; -static void CommentSymTok (void) /*@modifies nextToken@*/ ; -static void SynClass (void) /*@modifies nextToken@*/ ; -static void OldToken (void) /*@modifies nextToken@*/ ; -static void NewToken (void) /*@modifies nextToken@*/ ; -static void Token (void) /*@modifies nextToken@*/ ; - -static void InitReduce (LSLInitRuleCode p_rule) /*@modifies nextToken@*/ ; -static void UpdateXCharKeywords (charCode) /*@modifies nextToken@*/ ; -static void ProcessExtensionChar (void) /*@modifies nextToken@*/ ; -static void ProcessEndCommentChar (void) /*@modifies nextToken@*/ ; -static void ProcessSingleChar (charCode p_code) /*@modifies nextToken@*/ ; -static void ProcessToken (ltokenCode p_code) /*@modifies nextToken@*/ ; -static void ProcessSynonym (void) /*@modifies nextToken@*/ ; - -/* If TRUE character has been redefined as a singleChar. */ -static bool defineSingleChar[LASTCHAR + 1]; - -static charCode currentExtensionChar; - -/* LSL init file keyword tokens. */ - -static /*@dependent@*/ ltoken endCommentCharToken; -static /*@dependent@*/ ltoken idCharToken; -static /*@dependent@*/ ltoken opCharToken; -static /*@dependent@*/ ltoken extensionCharToken; -static /*@dependent@*/ ltoken singleCharToken; -static /*@dependent@*/ ltoken whiteCharToken; -static /*@dependent@*/ ltoken quantifierSymToken; -static /*@dependent@*/ ltoken logicalOpToken; -static /*@dependent@*/ ltoken eqOpToken; -static /*@dependent@*/ ltoken equationSymToken; -static /*@dependent@*/ ltoken eqSepSymToken; -static /*@dependent@*/ ltoken selectSymToken; -static /*@dependent@*/ ltoken openSymToken; -static /*@dependent@*/ ltoken sepSymToken; -static /*@dependent@*/ ltoken closeSymToken; -static /*@dependent@*/ ltoken simpleIdToken; -static /*@dependent@*/ ltoken mapSymToken; -static /*@dependent@*/ ltoken markerSymToken; -static /*@dependent@*/ ltoken commentSymToken; -static /*@dependent@*/ ltoken synonymToken; - -static bool -hasFirstChar (ltoken tok) -{ - return (ltoken_isChar (tok) - && lscanCharClass (cstring_firstChar (ltoken_unparse (tok))) == SINGLECHAR); -} - -void -LSLProcessInitFile (void) -{ - InitFile (); -} - -/* -** -** Parsing functions for init file processing, in the same order as the -** grammar file lslinit.cfg. This is top-down order, as much as possible. -** -*/ - -static void -InitFile (void) -{ - InitLines (); - InitReduce (INITFILE1); - - if (ltoken_getCode (nextToken) != LEOFTOKEN) - { - LocalUserError (nextToken, "unexpected tokens after end-of-file"); - } -} - -static void -InitLines (void) -{ - InitReduce (INITLINES1); - - if (ltoken_getCode (nextToken) != LEOFTOKEN) - { - InitLine (); - InitReduce (INITLINES2); - } - - while (ltoken_getCode (nextToken) != LEOFTOKEN) - { - InitLine (); - InitReduce (INITLINES3); - } - -} - -static void -InitLine (void) -{ - if (ltoken_getCode (nextToken) == LST_EOL) - { - /* Nothing on line. */ - InitReduce (INITLINE1); - } - else - { - Classification (); - InitReduce (INITLINE2); - } - - if (ltoken_getCode (nextToken) != LST_EOL) - { - LocalUserError (nextToken, "Unexpected tokens on line"); - } - - ltoken_free (nextToken); - nextToken = LSLScanNextToken (); -} - -static void -Classification (void) -{ - if (ltoken_getRawText (nextToken) == ltoken_getText (endCommentCharToken) - || ltoken_getRawText (nextToken) == ltoken_getText (idCharToken) - || ltoken_getRawText (nextToken) == ltoken_getText (opCharToken) - || ltoken_getRawText (nextToken) == ltoken_getText (extensionCharToken) - || ltoken_getRawText (nextToken) == ltoken_getText (singleCharToken) - || ltoken_getRawText (nextToken) == ltoken_getText (whiteCharToken)) - { - CharClass (); - InitReduce (CLASSIFICATION1); - } - else if (ltoken_getRawText (nextToken) == ltoken_getText (quantifierSymToken) - || ltoken_getRawText (nextToken) == ltoken_getText (logicalOpToken) - || ltoken_getRawText (nextToken) == ltoken_getText (eqOpToken) - || ltoken_getRawText (nextToken) == ltoken_getText (equationSymToken) - || ltoken_getRawText (nextToken) == ltoken_getText (eqSepSymToken) - || ltoken_getRawText (nextToken) == ltoken_getText (selectSymToken) - || ltoken_getRawText (nextToken) == ltoken_getText (openSymToken) - || ltoken_getRawText (nextToken) == ltoken_getText (sepSymToken) - || ltoken_getRawText (nextToken) == ltoken_getText (closeSymToken) - || ltoken_getRawText (nextToken) == ltoken_getText (simpleIdToken) - || ltoken_getRawText (nextToken) == ltoken_getText (mapSymToken) - || ltoken_getRawText (nextToken) == ltoken_getText (markerSymToken) - || ltoken_getRawText (nextToken) == ltoken_getText (commentSymToken)) - { - TokenClass (); - InitReduce (CLASSIFICATION2); - } - else if (ltoken_getRawText (nextToken) == ltoken_getText (synonymToken)) - { - SynClass (); - InitReduce (CLASSIFICATION3); - } - else - { - LocalUserError (nextToken, - "expected character, token, or synonym classification"); - } -} - -static void -CharClass (void) -{ - ltoken charClassToken; - - charClassToken = nextToken; - - nextToken = LSLScanNextToken (); /* Discard char class keyword. */ - - if (ltoken_getRawText (charClassToken) == ltoken_getText (endCommentCharToken)) - { - EndCommentChars (); - InitReduce (CHARCLASS1); - } - else if (ltoken_getRawText (charClassToken) == ltoken_getText (idCharToken)) - { - IdChars (); - InitReduce (CHARCLASS2); - } - else if (ltoken_getRawText (charClassToken) == ltoken_getText (opCharToken)) - { - OpChars (); - InitReduce (CHARCLASS3); - } - else if (ltoken_getRawText (charClassToken) - == ltoken_getText (extensionCharToken)) - { - ExtensionChar (); - InitReduce (CHARCLASS4); - } - else if (ltoken_getRawText (charClassToken) == ltoken_getText (singleCharToken)) - { - SingChars (); - InitReduce (CHARCLASS5); - } - else if (ltoken_getRawText (charClassToken) == ltoken_getText (whiteCharToken)) - { - WhiteChars (); - InitReduce (CHARCLASS6); - } - else - { - LocalUserError (nextToken, "expected character classification"); - } - - ltoken_free (charClassToken); -} - -static void -EndCommentChars (void) -{ - EndCommentChar (); - InitReduce (LRC_ENDCOMMENT1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - EndCommentChar (); - InitReduce (LRC_ENDCOMMENT2); - } - -} - -static void -IdChars (void) -{ - IdChar (); - InitReduce (IDCHARS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - IdChar (); - InitReduce (IDCHARS2); - } -} - -static void -OpChars (void) -{ - OpChar (); - InitReduce (OPCHARS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - OpChar (); - InitReduce (OPCHARS2); - } -} - -static void -ExtensionChar (void) -{ - if (ltoken_isChar (nextToken) - && lscanCharClass (cstring_firstChar (ltoken_unparse (nextToken))) == SINGLECHAR) - { - LSLGenShiftOnly (nextToken); - nextToken = LSLScanNextToken (); - InitReduce (LRC_EXTENSIONCHAR1); - } - else - { - LocalUserError (nextToken, "expected only one character"); - } -} - -static void -SingChars (void) -{ - SingChar (); - InitReduce (SINGCHARS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - SingChar (); - InitReduce (SINGCHARS2); - } -} - -static void -WhiteChars (void) -{ - WhiteChar (); - InitReduce (WHITECHARS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - WhiteChar (); - InitReduce (WHITECHARS2); - } -} - -static void -EndCommentChar (void) -{ - if (ltoken_isChar (nextToken)) - { - LSLGenShiftOnly (nextToken); - nextToken = LSLScanNextToken (); - InitReduce (LRC_ENDCOMMENTCHAR1); - } - else - { - LocalUserError (nextToken, "expected only one character"); - } -} - -static void -IdChar (void) -{ - if (hasFirstChar (nextToken)) - { - LSLGenShiftOnly (nextToken); - nextToken = LSLScanNextToken (); - InitReduce (IDCHAR1); - } - else - { - LocalUserError (nextToken, "character is already defined, cannot redefine"); - } -} - -static void -OpChar (void) -{ - if (hasFirstChar (nextToken)) - { - LSLGenShiftOnly (nextToken); - nextToken = LSLScanNextToken (); - InitReduce (OPCHAR1); - } - else - { - LocalUserError (nextToken, "character is already defined, cannot redefine"); - } -} - -static void -SingChar (void) -{ - if (hasFirstChar (nextToken)) - { - LSLGenShiftOnly (nextToken); - nextToken = LSLScanNextToken (); - InitReduce (SINGCHAR1); - } - else - { - LocalUserError (nextToken, "character is already defined, cannot redefine"); - } -} - -static void -WhiteChar (void) -{ - if (hasFirstChar (nextToken)) - { - LSLGenShiftOnly (nextToken); - nextToken = LSLScanNextToken (); - InitReduce (WHITECHAR1); - } - else - { - LocalUserError (nextToken, "character is already defined, cannot redefine"); - } -} - -static void -TokenClass (void) -{ - ltoken tokenClassToken; - - tokenClassToken = nextToken; - - nextToken = LSLScanNextToken (); - - if (ltoken_getRawText (tokenClassToken) == ltoken_getText (quantifierSymToken)) - { - QuantifierSymToks (); - InitReduce (TOKENCLASS1); - } - else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (logicalOpToken)) - { - LogicalOpToks (); - InitReduce (TOKENCLASS2); - } - else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (eqOpToken)) - { - EqOpToks (); - InitReduce (TOKENCLASS3); - } - else if (ltoken_getRawText (tokenClassToken) - == ltoken_getText (equationSymToken)) - { - EquationSymToks (); - InitReduce (TOKENCLASS4); - } - else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (eqSepSymToken)) - { - EqSepSymToks (); - InitReduce (TOKENCLASS5); - } - else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (selectSymToken)) - { - SelectSymToks (); - InitReduce (TOKENCLASS6); - } - else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (openSymToken)) - { - OpenSymToks (); - InitReduce (TOKENCLASS7); - } - else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (sepSymToken)) - { - SepSymToks (); - InitReduce (TOKENCLASS8); - } - else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (closeSymToken)) - { - CloseSymToks (); - InitReduce (TOKENCLASS9); - } - else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (simpleIdToken)) - { - SimpleIdToks (); - InitReduce (TOKENCLASS10); - } - else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (mapSymToken)) - { - MapSymToks (); - InitReduce (TOKENCLASS11); - } - else if (ltoken_getRawText (tokenClassToken) == ltoken_getText (markerSymToken)) - { - MarkerSymToks (); - InitReduce (TOKENCLASS12); - } - else if (ltoken_getRawText (tokenClassToken) - == ltoken_getText (commentSymToken)) - { - CommentSymToks (); - InitReduce (TOKENCLASS13); - } - else - { - LocalUserError (nextToken, "expected token classification"); - } - - ltoken_free (tokenClassToken); -} - -static void -QuantifierSymToks (void) -{ - QuantifierSymTok (); - InitReduce (QUANTIFIERSYMTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - QuantifierSymTok (); - InitReduce (QUANTIFIERSYMTOKS2); - } -} - -static void -LogicalOpToks (void) -{ - LogicalOpTok (); - InitReduce (LOGICALOPTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - LogicalOpTok (); - InitReduce (LOGICALOPTOKS2); - } -} - -static void -EqOpToks (void) -{ - EqOpTok (); - InitReduce (LRC_EQOPTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - EqOpTok (); - InitReduce (LRC_EQOPTOKS2); - } -} - -static void -EquationSymToks (void) -{ - EquationSymTok (); - InitReduce (LRC_EQUATIONSYMTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - EquationSymTok (); - InitReduce (LRC_EQUATIONSYMTOKS2); - } -} - -static void -EqSepSymToks (void) -{ - EqSepSymTok (); - InitReduce (LRC_EQSEPSYMTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - EqSepSymTok (); - InitReduce (LRC_EQSEPSYMTOKS2); - } -} - -static void -SelectSymToks (void) -{ - SelectSymTok (); - InitReduce (SELECTSYMTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - SelectSymTok (); - InitReduce (SELECTSYMTOKS2); - } -} - -static void -OpenSymToks (void) -{ - OpenSymTok (); - InitReduce (OPENSYMTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - OpenSymTok (); - InitReduce (OPENSYMTOKS2); - } -} - -static void -SepSymToks (void) -{ - SepSymTok (); - InitReduce (SEPSYMTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - SepSymTok (); - InitReduce (SEPSYMTOKS2); - } -} - -static void -CloseSymToks (void) -{ - CloseSymTok (); - InitReduce (CLOSESYMTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - CloseSymTok (); - InitReduce (CLOSESYMTOKS2); - } -} - -static void -SimpleIdToks (void) -{ - SimpleIdTok (); - InitReduce (SIMPLEIDTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - SimpleIdTok (); - InitReduce (SIMPLEIDTOKS2); - } -} - -static void -MapSymToks (void) -{ - MapSymTok (); - InitReduce (MAPSYMTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - MapSymTok (); - InitReduce (MAPSYMTOKS2); - } -} - -static void -MarkerSymToks (void) -{ - MarkerSymTok (); - InitReduce (MARKERSYMTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - MarkerSymTok (); - InitReduce (MARKERSYMTOKS2); - } -} - -static void -CommentSymToks (void) -{ - CommentSymTok (); - InitReduce (COMMENTSYMTOKS1); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - CommentSymTok (); - InitReduce (COMMENTSYMTOKS2); - } -} - -static void -QuantifierSymTok (void) -{ - Token (); - InitReduce (QUANTIFIERSYMTOK1); -} - -static void -LogicalOpTok (void) -{ - Token (); - InitReduce (LOGICALOPTOK1); -} - -static void -EqOpTok (void) -{ - Token (); - InitReduce (LRC_EQOPTOK1); -} - -static void -EquationSymTok (void) -{ - /* ### EquationSymTok (); ### */ - Token (); - InitReduce (LRC_EQUATIONSYMTOK1); -} - -static void -EqSepSymTok (void) -{ - Token (); - InitReduce (LRC_EQSEPSYMTOK1); - -} - -static void -SelectSymTok (void) -{ - Token (); - InitReduce (SELECTSYMTOK1); -} - -static void -OpenSymTok (void) -{ - Token (); - InitReduce (OPENSYMTOK1); -} - -static void -SepSymTok (void) -{ - Token (); - InitReduce (SEPSYMTOK1); -} - -static void -CloseSymTok (void) -{ - Token (); - InitReduce (CLOSESYMTOK1); -} - -static void -SimpleIdTok (void) -{ - Token (); - InitReduce (SIMPLEIDTOK1); -} - -static void -MapSymTok (void) -{ - Token (); - InitReduce (MAPSYMTOK1); -} - -static void -MarkerSymTok (void) -{ - Token (); - InitReduce (MARKERSYMTOK1); - -} - -static void -CommentSymTok (void) -{ - Token (); - InitReduce (COMMENTSYMTOK1); -} - - -static void -SynClass (void) -{ - if (ltoken_getRawText (nextToken) == ltoken_getText (synonymToken)) - { - ltoken_free (nextToken); - nextToken = LSLScanNextToken (); - - OldToken (); - NewToken (); - - InitReduce (SYNCLASS1); - } - else - { - LocalUserError (nextToken, "expected synonym classification"); - } - -} - -static void -OldToken (void) -{ - Token (); - InitReduce (OLDTOKEN1); - -} - -static void -NewToken (void) -{ - Token (); - InitReduce (NEWTOKEN1); - -} - -static void -Token (void) -{ - if (ltoken_getCode (nextToken) == LST_EOL - || ltoken_getCode (nextToken) == LEOFTOKEN) - { - LocalUserError (nextToken, "unexpected end-of-line or end-of-file"); - } - else - { - LSLGenShiftOnly (nextToken); - nextToken = LSLScanNextToken (); - } -} - -/* -** Init File Processing Routines, these routines use the shift-reduce sequence -** produced by the init file parser and update the necessary tables for the -** scanner. -** -** The same shift stack is used that LSL parser uses. A different reduce -** procedure is used because the init file grammar is different from the LSL -** grammar. -** -*/ - -static void -InitReduce (LSLInitRuleCode rule) -{ - switch (rule) - { - case INITFILE1: - LTRACE ("INITFILE1"); - break; - - case INITLINES1: - LTRACE ("INITLINES1"); - break; - - case INITLINES2: - LTRACE ("INITLINES2"); - break; - - case INITLINES3: - LTRACE ("INITLINES3"); - break; - - case INITLINE1: - LTRACE ("INITLINE1"); - break; - - case INITLINE2: - LTRACE ("INITLINE2"); - break; - - case CLASSIFICATION1: - LTRACE ("CLASSIFICATION1"); - break; - - case CLASSIFICATION2: - LTRACE ("CLASSIFICATION2"); - break; - - case CLASSIFICATION3: - LTRACE ("CLASSIFICATION3"); - break; - - case CHARCLASS1: - LTRACE ("CHARCLASS1"); - break; - - case CHARCLASS2: - LTRACE ("CHARCLASS2"); - break; - - case CHARCLASS3: - LTRACE ("CHARCLASS3"); - break; - - case CHARCLASS4: - LTRACE ("CHARCLASS4"); - break; - - case CHARCLASS5: - LTRACE ("CHARCLASS5"); - break; - - case CHARCLASS6: - LTRACE ("CHARCLASS6"); - break; - - case LRC_ENDCOMMENT1: - LTRACE ("LRC_ENDCOMMENT1"); - break; - - case LRC_ENDCOMMENT2: - LTRACE ("LRC_ENDCOMMENT2"); - break; - - case IDCHARS1: - LTRACE ("IDCHARS1"); - break; - - case IDCHARS2: - LTRACE ("IDCHARS2"); - break; - - case OPCHARS1: - LTRACE ("OPCHARS1"); - break; - - case OPCHARS2: - LTRACE ("OPCHARS2"); - break; - - case LRC_EXTENSIONCHAR1: - LTRACE ("LRC_EXTENSIONCHAR1"); - ProcessExtensionChar (); - break; - - case SINGCHARS1: - LTRACE ("SINGCHARS1"); - break; - - case SINGCHARS2: - LTRACE ("SINGCHARS2"); - break; - - case WHITECHARS1: - LTRACE ("WHITECHARS1"); - break; - - case WHITECHARS2: - LTRACE ("WHITECHARS2"); - break; - - case LRC_ENDCOMMENTCHAR1: - LTRACE ("LRC_ENDCOMMENTCHAR1"); - ProcessEndCommentChar (); - break; - - case IDCHAR1: - LTRACE ("IDCHAR1"); - ProcessSingleChar (IDCHAR); - break; - - case OPCHAR1: - LTRACE ("OPCHAR1"); - ProcessSingleChar (OPCHAR); - break; - - case SINGCHAR1: - LTRACE ("SINGCHAR1"); - ProcessSingleChar (SINGLECHAR); - break; - - case WHITECHAR1: - LTRACE ("CHAR1"); - ProcessSingleChar (WHITECHAR); - break; - - case TOKENCLASS1: - LTRACE ("TOKENCLASS1"); - break; - - case TOKENCLASS2: - LTRACE ("TOKENCLASS2"); - break; - - case TOKENCLASS3: - LTRACE ("TOKENCLASS3"); - break; - - case TOKENCLASS4: - LTRACE ("TOKENCLASS4"); - break; - - case TOKENCLASS5: - LTRACE ("TOKENCLASS5"); - break; - - case TOKENCLASS6: - LTRACE ("TOKENCLASS6"); - break; - - case TOKENCLASS7: - LTRACE ("TOKENCLASS7"); - break; - - case TOKENCLASS8: - LTRACE ("TOKENCLASS8"); - break; - - case TOKENCLASS9: - LTRACE ("TOKENCLASS9"); - break; - - case TOKENCLASS10: - LTRACE ("TOKENCLASS10"); - break; - - case TOKENCLASS11: - LTRACE ("TOKENCLASS11"); - break; - - case TOKENCLASS12: - LTRACE ("TOKENCLASS12"); - break; - - case TOKENCLASS13: - LTRACE ("TOKENCLASS13"); - break; - - case QUANTIFIERSYMTOKS1: - LTRACE ("QUALIFERSYMTOKS1"); - break; - - case QUANTIFIERSYMTOKS2: - LTRACE ("QUANTIFIERSYMTOKS2"); - break; - - case LOGICALOPTOKS1: - LTRACE ("LOGICALOPTOKS1"); - break; - - case LOGICALOPTOKS2: - LTRACE ("LOGICALOPTOKS2"); - break; - - case LRC_EQOPTOKS1: - LTRACE ("LRC_EQOPTOKS1"); - break; - - case LRC_EQOPTOKS2: - LTRACE ("LRC_EQOPTOKS2"); - break; - - case LRC_EQUATIONSYMTOKS1: - LTRACE ("LRC_EQUATIONSYMTOKS1"); - break; - - case LRC_EQUATIONSYMTOKS2: - LTRACE ("LRC_EQUATIONSYMTOKS2"); - break; - - case LRC_EQSEPSYMTOKS1: - LTRACE ("LRC_EQSEPSYMTOKS1"); - break; - - case LRC_EQSEPSYMTOKS2: - LTRACE ("LRC_EQSEPSYMTOKS2"); - break; - - case SELECTSYMTOKS1: - LTRACE ("SELECTSYMTOKS1"); - break; - - case SELECTSYMTOKS2: - LTRACE ("SELECTSYMTOKS2"); - break; - - case OPENSYMTOKS1: - LTRACE ("OPENSYMTOKS1"); - break; - - case OPENSYMTOKS2: - LTRACE ("OPENSYMTOKS2"); - break; - - case SEPSYMTOKS1: - LTRACE ("SEPSYMTOKS1"); - break; - - case SEPSYMTOKS2: - LTRACE ("SEPSYMTOKS2"); - break; - - case CLOSESYMTOKS1: - LTRACE ("CLOSESYMTOKS1"); - break; - - case CLOSESYMTOKS2: - LTRACE ("CLOSESYMTOKS2"); - break; - - case SIMPLEIDTOKS1: - LTRACE ("SIMPLEIDTOKS1"); - break; - - case SIMPLEIDTOKS2: - LTRACE ("SIMPLEIDTOKS2"); - break; - - case MAPSYMTOKS1: - LTRACE ("MAPSYMTOKS1"); - break; - - case MAPSYMTOKS2: - LTRACE ("MAPSYMTOKS2"); - break; - - case MARKERSYMTOKS1: - LTRACE ("MARKERSYMTOKS1"); - break; - - case MARKERSYMTOKS2: - LTRACE ("MARKERSYMTOKS2"); - break; - - case COMMENTSYMTOKS1: - LTRACE ("COMMENTSYMTOKS1"); - break; - - case COMMENTSYMTOKS2: - LTRACE ("COMMENTSYMTOKS2"); - break; - - case QUANTIFIERSYMTOK1: - LTRACE ("QUANTIFERSYMTOK1"); - ProcessToken (LST_QUANTIFIERSYM); - break; - - case LOGICALOPTOK1: - LTRACE ("LOGICALOPTOK1"); - ProcessToken (LST_LOGICALOP); - break; - - case LRC_EQOPTOK1: - LTRACE ("LRC_EQOPTOK1"); - ProcessToken (LST_EQOP); - break; - - case LRC_EQUATIONSYMTOK1: - LTRACE ("LRC_EQUATIONSYMTOK1"); - ProcessToken (LST_EQUATIONSYM); - break; - - case LRC_EQSEPSYMTOK1: - LTRACE ("LRC_EQSEPSYMTOK1"); - ProcessToken (LST_EQSEPSYM); - break; - - case SELECTSYMTOK1: - LTRACE ("SELECTSYMTOK1"); - ProcessToken (LST_SELECTSYM); - break; - - case OPENSYMTOK1: - LTRACE ("OPENSYMTOK1"); - ProcessToken (LST_OPENSYM); - break; - - case SEPSYMTOK1: - LTRACE ("SEPSYMTOK1"); - ProcessToken (LST_SEPSYM); - break; - - case CLOSESYMTOK1: - LTRACE ("CLOSESYMTOK1"); - ProcessToken (LST_CLOSESYM); - break; - - case SIMPLEIDTOK1: - LTRACE ("SIMPLEIDTOK1"); - ProcessToken (LST_SIMPLEID); - break; - - case MAPSYMTOK1: - LTRACE ("MAPSYMTOK1"); - ProcessToken (LST_MAPSYM); - break; - - case MARKERSYMTOK1: - LTRACE ("MARKERSYMTOK1"); - ProcessToken (LST_MARKERSYM); - break; - - case COMMENTSYMTOK1: - LTRACE ("COMMENTSYMTOK1"); - ProcessToken (LST_COMMENTSYM); - break; - - case SYNCLASS1: - LTRACE ("SYNCLASS1"); - ProcessSynonym (); - break; - - case OLDTOKEN1: - LTRACE ("OLDTOKEN1"); - break; - - case NEWTOKEN1: - LTRACE ("NEWTOKEN1"); - break; - - default: - llcontbuglit ("InitReduce: bad switch"); - break; - - } /* end switch */ -} /* end InitReduce () */ - - - -/* Reset the first character of the predefined extensionChar keywords when */ -/* the extensionChar changes. e.g. "extensionChar @" changes "forall" to */ -/* "@forall". */ - -static void -UpdateXCharKeywords (charCode xCharCode) -{ - char xChar = (char) xCharCode; - char *str; - - str = ltoken_getTextChars (ltoken_forall); - *str = xChar; - - str = ltoken_getTextChars (ltoken_and); - *str = xChar; - - str = ltoken_getTextChars (ltoken_or); - *str = xChar; - - str = ltoken_getTextChars (ltoken_implies); - *str = xChar; - - str = ltoken_getTextChars (ltoken_eq); - *str = xChar; - - str = ltoken_getTextChars (ltoken_neq); - *str = xChar; - - str = ltoken_getTextChars (ltoken_equals); - *str = xChar; - - str = ltoken_getTextChars (ltoken_eqsep); - *str = xChar; - - str = ltoken_getTextChars (ltoken_select); - *str = xChar; - - str = ltoken_getTextChars (ltoken_open); - *str = xChar; - - str = ltoken_getTextChars (ltoken_sep); - *str = xChar; - - str = ltoken_getTextChars (ltoken_close); - *str = xChar; - - str = ltoken_getTextChars (ltoken_id); - *str = xChar; - - str = ltoken_getTextChars (ltoken_arrow); - *str = xChar; - - str = ltoken_getTextChars (ltoken_marker); - *str = xChar; - - str = ltoken_getTextChars (ltoken_comment); - *str = xChar; - -} - -/* Different from ProcessCharClass because only allow one extension */ -/* character. Therefore, the present extension character must be set to a */ -/* singleChar. */ - -static void -ProcessExtensionChar (void) -{ - ltoken stackToken = LSLGenTopPopShiftStack (); - char firstChar = cstring_firstChar (ltoken_unparse (stackToken)); - - if (!defineSingleChar[(int)firstChar] - && lscanCharClass (firstChar) == SINGLECHAR) - { - /* Is a single character that has not been defined before. */ - /* Can only have one extension char. Release old one. */ - lsetCharClass (firstChar, CHC_EXTENSION); - - /* this is a (bogus) type bug! caught by splint */ - /* lsetCharClass (currentExtensionChar, SINGLECHAR); */ - - lsetCharClass ((char) currentExtensionChar, SINGLECHAR); - - currentExtensionChar = (charCode) firstChar; - UpdateXCharKeywords (currentExtensionChar); - } - else - { - /* Already redefined. Don't allow to be redefined. */ - LocalUserError (stackToken, "character is already defined, cannot redefine"); - } - ltoken_free (stackToken); -} - -/* Different from ProcessSingleChar because allow any characters to be */ -/* endCommentChar and also set a different part of the scanner structure. */ - -static void -ProcessEndCommentChar (void) -{ - ltoken stackToken = LSLGenTopPopShiftStack (); - char firstChar = cstring_firstChar (ltoken_unparse (stackToken)); - - if (LSLIsEndComment (firstChar)) - { - LocalUserError (stackToken, - "already defined as a endCommentChar, cannot redefine"); - } - else - { - lsetEndCommentChar (firstChar, TRUE); - } - ltoken_free (stackToken); -} - -static void -ProcessSingleChar (charCode code) -{ - ltoken stackToken = LSLGenTopPopShiftStack (); - char firstChar = cstring_firstChar (ltoken_unparse (stackToken)); - - if (!defineSingleChar[(int)firstChar] - && lscanCharClass (firstChar) == SINGLECHAR) - { - /* Is a single character that has not been defined before. */ - /* It's OK to redefine once. */ - lsetCharClass (firstChar, code); - /* OK to mark as a defined singleChar even if not. Only check */ - /* defineSingleChar[] if defining a singleChar. */ - defineSingleChar[(int)firstChar] = TRUE; - } - else - { - LocalUserError (stackToken, "character is already defined, cannot redefine"); - } - ltoken_free (stackToken); -} - -static void -ProcessToken (ltokenCode code) -{ - ltoken stackToken, temp; - lsymbol sym; - - stackToken = LSLGenTopPopShiftStack (); - sym = ltoken_getText (stackToken); - - if (LSLIsSyn (sym)) - { - LocalUserError (stackToken, - "already defined as a synonym, cannot redefine"); - } - - /* Get the token from the token table, so can check if the token */ - /* was updated by a previous token. */ - temp = LSLGetToken (sym); - - if (ltoken_isStateDefined (temp)) - { - if ((code == LST_OPENSYM && sym == lsymbol_fromChars ("[")) || - (code == LST_CLOSESYM && sym == lsymbol_fromChars ("]"))) - { - /* ignore "openSym [" and "closeSym ]" TokenClass */ - ltoken_free (stackToken); - return; - } - else - { - LocalUserError (stackToken, "already defined, cannot redefine"); - PrintToken (temp); - } - } - - LSLUpdateToken (code, ltoken_getText (stackToken), TRUE); - ltoken_free (stackToken); -} - - -static void -ProcessSynonym (void) -{ - ltoken newtok; - ltoken oldtok; - - newtok = LSLGenTopPopShiftStack (); - oldtok = LSLGenTopPopShiftStack (); - - if (ltoken_wasSyn (newtok)) - { - /* The token has a synonym. This means that the synonym was in the */ - /* init file, so complain about redefining as a synonym again */ - LocalUserError (newtok, "newtok already is a synonym, cannot redefine"); - } - - if (ltoken_hasSyn (newtok)) - { - /* - ** newtok already has a synonym defined for it. Do not allow - ** synonyms to be chained. - */ - - LocalUserError (newtok, - "newtok already has a synonym, cannot chain synonyms"); - } - - if (ltoken_isStateDefined (newtok)) - { - LocalUserError (newtok, "newtok already defined, cannot redefine"); - } - - LSLAddSyn (ltoken_getText (newtok), ltoken_getText (oldtok)); - ltoken_free (oldtok); - ltoken_free (newtok); -} - - -/* - * Utilities, in alphabetical order - */ - -static void -LocalUserError (ltoken t, /*@temp@*/ char *msg) -{ - lldiagmsg (message ("%s %s in the LSL init file:", - ltoken_unparse (t), cstring_fromChars (msg))); - - ltoken_free (nextToken); - nextToken = LSLScanNextToken (); - - while (ltoken_getCode (nextToken) != LST_EOL) - { - ltoken_free (nextToken); - nextToken = LSLScanNextToken (); - } -} - -/* -** Required initialization and cleanup routines -*/ - -static /*@exposed@*/ ltoken insertSimpleToken (char *text) - /*@modifies internalState@*/ -{ - return (LSLInsertToken (LST_SIMPLEID, lsymbol_fromChars (text), 0, FALSE)); -} - -void -LSLProcessInitFileInit (void) -{ - int i; - - LSLGenInit (TRUE); /* parsing LSLinit not LCLinit */ - - /* - ** Insert the init file keywords into the token table as undefined - ** SIMPLEIDs. They are defined as simpleIds since they must be treated - ** that way if they do not appear as the first token on a line, and - ** they must be treated that way for the actual LSL parsing. Save the - ** tokens so can recognize as init file keywords when necessary. - */ - - endCommentCharToken = insertSimpleToken ("endCommentChar"); - idCharToken = insertSimpleToken ("idChar"); - opCharToken = insertSimpleToken ("opChar"); - extensionCharToken = insertSimpleToken ("extensionChar"); - singleCharToken = insertSimpleToken ("singleChar"); - whiteCharToken = insertSimpleToken ("whiteChar"); - - quantifierSymToken = insertSimpleToken ("quantifierSym"); - logicalOpToken = insertSimpleToken ("logicalOp"); - eqOpToken = insertSimpleToken ("eqOp"); - equationSymToken = insertSimpleToken ("equationSym"); - eqSepSymToken = insertSimpleToken ("eqSepSym"); - selectSymToken = insertSimpleToken ("selectSym"); - openSymToken = insertSimpleToken ("openSym"); - sepSymToken = insertSimpleToken ("sepSym"); - closeSymToken = insertSimpleToken ("closeSym"); - simpleIdToken = insertSimpleToken ("simpleId"); - mapSymToken = insertSimpleToken ("mapSym"); - markerSymToken = insertSimpleToken ("markerSym"); - commentSymToken = insertSimpleToken ("commentSym"); - synonymToken = insertSimpleToken ("synonym"); - - for (i = 0; i <= LASTCHAR; i++) - { - defineSingleChar[i] = FALSE; - } - - /* - ** Record the current extension character so can redefine back to - ** singleChar if a new extension character is redefined. - */ - - currentExtensionChar = (charCode) CHAREXTENDER; - - LSLReportEolTokens (TRUE); - ltoken_free (nextToken); - nextToken = LSLScanNextToken (); -} - - - - - - - - diff --git a/src/osd.c b/src/osd.c index 8ba1c60..a78861f 100644 --- a/src/osd.c +++ b/src/osd.c @@ -1033,6 +1033,7 @@ cstring osd_absolutePath (cstring cwd, cstring filename) cstring osd_outputPath (cstring filename) { + /*@i2534 fix this junky code once and for all! */ # if defined (UNIX) || defined (OS2) char *rel_buffer; char *rel_buf_p; @@ -1064,7 +1065,7 @@ cstring osd_outputPath (cstring filename) else { /*@i324 ! splint didn't report an errors for: return ++path_p; */ - return cstring_fromCharsNew (++path_p); + return cstring_fromCharsNew (path_p + 1); } } else @@ -1090,7 +1091,7 @@ cstring osd_outputPath (cstring filename) /* Find out how many directory levels in cwd were *not* matched. */ while (*cwd_p != '\0') - { + {s if (osd_isConnectChar (*cwd_p++)) unmatched_slash_count++; } @@ -1130,6 +1131,7 @@ cstring osd_outputPath (cstring filename) } /*@-usereleased@*/ while ((*rel_buf_p++ = *path_p++) != '\0') ; + /*@=usereleased@*/ /*@i523! shouldn't need these */ --rel_buf_p; diff --git a/src/rcfiles.c b/src/rcfiles.c new file mode 100644 index 0000000..b234c44 --- /dev/null +++ b/src/rcfiles.c @@ -0,0 +1,204 @@ +/* +** Splint - annotation-assisted static program checker +** Copyright (C) 1994-2002 University of Virginia, +** Massachusetts Institute of Technology +** +** This program is free software; you can redistribute it and/or modify it +** under the terms of the GNU General Public License as published by the +** Free Software Foundation; either version 2 of the License, or (at your +** option) any later version. +** +** This program is distributed in the hope that it will be useful, but +** WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** +** The GNU General Public License is available from http://www.gnu.org/ or +** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +** MA 02111-1307, USA. +** +** For information on splint: info@splint.org +** To report a bug: splint-bug@splint.org +** For more information: http://www.splint.org +*/ +/* +** rcfiles.c +*/ + +# include "splintMacros.nf" +# include "basic.h" +# include "rcfiles.h" + + +static void rcfiles_loadFile (FILE *p_rcfile, cstringSList *p_passThroughArgs) + /*@modifies *p_passThroughArgs, p_rcfile@*/ + /*@ensures closed p_rcfile@*/ ; + +bool rcfiles_read (cstring fname, cstringSList *passThroughArgs, bool report) +{ + bool res = FALSE; + + if (fileTable_exists (context_fileTable (), fname)) + { + if (report) + { + voptgenerror + (FLG_WARNRC, + message ("Multiple attempts to read options file: %s", fname), + g_currentloc); + } + } + else + { + FILE *innerf = fileTable_openReadFile (context_fileTable (), fname); + + if (innerf != NULL) + { + fileloc fc = g_currentloc; + g_currentloc = fileloc_createRc (fname); + + displayScan (message ("< reading options from %q >", + fileloc_outputFilename (g_currentloc))); + + rcfiles_loadFile (innerf, passThroughArgs); + fileloc_reallyFree (g_currentloc); + g_currentloc = fc; + res = TRUE; + } + else + { + if (report) + { + voptgenerror + (FLG_WARNRC, + message ("Cannot open options file: %s", fname), + g_currentloc); + } + } + } + + return res; +} + +static void rcfiles_loadFile (/*:open:*/ FILE *rcfile, cstringSList *passThroughArgs) + /*@modifies rcfile@*/ + /*@ensures closed rcfile@*/ +{ + char *s = mstring_create (MAX_LINE_LENGTH); + char *os = s; + cstringList args = cstringList_new (); + + DPRINTF (("Loading rc file...")); + + s = os; + + while (reader_readLine (rcfile, s, MAX_LINE_LENGTH) != NULL) + { + char c; + + DPRINTF (("Line: %s", s)); + DPRINTF (("args: %s", cstringList_unparse (args))); + + while (*s == ' ' || *s == '\t') + { + s++; + incColumn (); + } + + while (*s != '\0') + { + char *thisflag; + bool escaped = FALSE; + bool quoted = FALSE; + c = *s; + + /* comment characters */ + if (c == '#' || c == ';' || c == '\n') + { + /*@innerbreak@*/ + break; + } + + thisflag = s; + + while ((c = *s) != '\0') + { /* remember to handle spaces and quotes in -D and -U ... */ + if (escaped) + { + escaped = FALSE; + } + else if (quoted) + { + if (c == '\\') + { + escaped = TRUE; + } + else if (c == '\"') + { + quoted = FALSE; + } + else + { + ; + } + } + else if (c == '\"') + { + quoted = TRUE; + } + else + { + if (c == ' ' || c == '\t' || c == '\n') + { + /*@innerbreak@*/ break; + } + } + + s++; + incColumn (); + } + + DPRINTF (("Nulling: %c", *s)); + *s = '\0'; + + if (mstring_isEmpty (thisflag)) + { + llfatalerror (message ("Missing flag: %s", + cstring_fromChars (os))); + } + else + { + args = cstringList_add (args, cstring_fromCharsNew (thisflag)); + DPRINTF (("args: %s", cstringList_unparse (args))); + } + + *s = c; + DPRINTF (("Pass through: %s", cstringSList_unparse (*passThroughArgs))); + + while ((c == ' ') || (c == '\t')) + { + c = *(++s); + incColumn (); + } + } + + s = os; + } + + sfree (os); + + DPRINTF (("args: %s", cstringList_unparse (args))); + flags_processFlags (FALSE, + fileIdList_undefined, + fileIdList_undefined, + fileIdList_undefined, + fileIdList_undefined, + passThroughArgs, + cstringList_size (args), + cstringList_getElements (args)); + cstringList_free (args); + check (fileTable_closeFile (context_fileTable (), rcfile)); +} + + + diff --git a/src/uentry.c b/src/uentry.c index 5386fbf..d64ad4b 100644 --- a/src/uentry.c +++ b/src/uentry.c @@ -7311,9 +7311,10 @@ checkEnumConformance (/*@notnull@*/ uentry old, /*@notnull@*/ uentry unew) if (optgenerror (FLG_MATCHFIELDS, message ("Enum %q declared with members { %q } but " - "specified with members { %q }", + "%s with members { %q }", uentry_getName (old), enumNameList_unparse (enew), + uentry_specOrDefName (old), enumNameList_unparse (eold)), uentry_whereDeclared (unew))) { diff --git a/src/usymtab.c b/src/usymtab.c index 099737a..cc26ba8 100644 --- a/src/usymtab.c +++ b/src/usymtab.c @@ -891,7 +891,8 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st, if (!(st->lexlevel > fileScope || !sRef_modInFunction ())) { if (uentry_isDatatype (e) || uentry_isAnyTag (e) - || uentry_isEnumConstant (e)) + || uentry_isEnumConstant (e) + || uentry_isStatic (e)) /* bug fix from Brian St. Pierre */ { ; /* ** Not a bug. Code like, diff --git a/test/Makefile.am b/test/Makefile.am index e33bceb..7fc4721 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -42,7 +42,7 @@ UNITTESTS = \ abstptr abstract alias alttypes ansireserved argorder \ args arraydims arrayinit arraylit blocks break cases cast charlit clauses commentchar compdestroy \ compoundliterals compoundstmt constannot controldepth csyntax czechnames czechoslovaknames deadparam \ - decl divzero enum exports external fields flags forbody format freearray \ + decl divzero enum enumtag exports external fields flags forbody format freearray \ funcpointer functionmacro glob globals impabstract info init inparam internal iter keep libs \ linked lintcomments list loopexec looptesteffect \ macros macrosef merge mergenull modifies modtest moduncon \ @@ -76,25 +76,25 @@ all check: fulltest .PHONY: version version: - -$(SPLINTP) -help version + -$(SPLINT) -help version .PHONY: help help: -@$(SPLINT) -@LARCH_PATH=/dev/null; $(SPLINT) -nof empty.lcl - -@$(SPLINTP) -help + -@$(SPLINT) -help -@$(SPLINTP) -asdf -@$(SPLINTP) +boolint +boolint - -@$(SPLINTP) -help flags alpha + -@$(SPLINT) -help flags alpha #commenting these out for the release because they will almost always fail #since the default will only fit one system #Don't want to panic the user... -# -@$(SPLINTP) -help flags all | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " -# -@$(SPLINTP) -help flags full | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " -# -@$(SPLINTP) -help flags manual | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " +# -@$(SPLINT) -help flags all | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " +# -@$(SPLINT) -help flags full | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " +# -@$(SPLINT) -help flags manual | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " #larch and lclimportdir have different hardcoded default paths so don't include the path in the output.. @@ -159,8 +159,8 @@ fulltest: @echo "Testing $(PACKAGE) $(VERSION)..." @echo @echo "Version Info:" - @$(SPLINTP) -help version - @$(SPLINTP) -help vars + @$(SPLINT) -help version + @$(SPLINT) -help vars @echo "" @echo "Tests:" @echo "" @@ -370,6 +370,10 @@ enum: -$(SPLINTR) enum -expect 16 -$(SPLINTR) enum -misscase -expect 14 +.PHONY: enumtag +enumtag: + -$(SPLINTR) enumtag.c -expect 2 + .PHONY: exports exports: -$(SPLINTR) exports.c +exporttype +exportvar +exportfcn +topuse +typeuse -expect 6 @@ -1084,6 +1088,7 @@ EXTRA_DIST = ./abst_t.lcl ./abst_t.lcs \ ./dkf5kSprintf.c \ ./ensures.c \ ./enum.c \ + ./enumtag.c \ ./exports.c \ ./external.c \ ./fields.c \ @@ -1379,6 +1384,7 @@ EXTRA_DIST = ./abst_t.lcl ./abst_t.lcs \ deadparam.expect \ decl.expect \ enum.expect \ + enumtag.expect \ exports.expect \ external.expect \ fields.expect \ diff --git a/test/Makefile.in b/test/Makefile.in index 263863d..64d934d 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -120,7 +120,7 @@ UNITTESTS = \ abstptr abstract alias alttypes ansireserved argorder \ args arraydims arrayinit arraylit blocks break cases cast charlit clauses commentchar compdestroy \ compoundliterals compoundstmt constannot controldepth csyntax czechnames czechoslovaknames deadparam \ - decl divzero enum exports external fields flags forbody format freearray \ + decl divzero enum enumtag exports external fields flags forbody format freearray \ funcpointer functionmacro glob globals impabstract info init inparam internal iter keep libs \ linked lintcomments list loopexec looptesteffect \ macros macrosef merge mergenull modifies modtest moduncon \ @@ -337,6 +337,7 @@ EXTRA_DIST = ./abst_t.lcl ./abst_t.lcs \ ./dkf5kSprintf.c \ ./ensures.c \ ./enum.c \ + ./enumtag.c \ ./exports.c \ ./external.c \ ./fields.c \ @@ -632,6 +633,7 @@ EXTRA_DIST = ./abst_t.lcl ./abst_t.lcs \ deadparam.expect \ decl.expect \ enum.expect \ + enumtag.expect \ exports.expect \ external.expect \ fields.expect \ @@ -926,24 +928,24 @@ all check: fulltest .PHONY: version version: - -$(SPLINTP) -help version + -$(SPLINT) -help version .PHONY: help help: -@$(SPLINT) -@LARCH_PATH=/dev/null; $(SPLINT) -nof empty.lcl - -@$(SPLINTP) -help + -@$(SPLINT) -help -@$(SPLINTP) -asdf -@$(SPLINTP) +boolint +boolint - -@$(SPLINTP) -help flags alpha + -@$(SPLINT) -help flags alpha #commenting these out for the release because they will almost always fail #since the default will only fit one system #Don't want to panic the user... -# -@$(SPLINTP) -help flags all | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " -# -@$(SPLINTP) -help flags full | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " -# -@$(SPLINTP) -help flags manual | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " +# -@$(SPLINT) -help flags all | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " +# -@$(SPLINT) -help flags full | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " +# -@$(SPLINT) -help flags manual | $(GREP) -v "^larchpath " | $(GREP) -v "^lclimportdir " | $(GREP) -v " Path argument. Default: " | $(GREP) -v " Directory argument. Default: " | $(GREP) -v " lclimportdir " #larch and lclimportdir have different hardcoded default paths so don't include the path in the output.. @@ -980,8 +982,8 @@ fulltest: @echo "Testing $(PACKAGE) $(VERSION)..." @echo @echo "Version Info:" - @$(SPLINTP) -help version - @$(SPLINTP) -help vars + @$(SPLINT) -help version + @$(SPLINT) -help vars @echo "" @echo "Tests:" @echo "" @@ -1191,6 +1193,10 @@ enum: -$(SPLINTR) enum -expect 16 -$(SPLINTR) enum -misscase -expect 14 +.PHONY: enumtag +enumtag: + -$(SPLINTR) enumtag.c -expect 2 + .PHONY: exports exports: -$(SPLINTR) exports.c +exporttype +exportvar +exportfcn +topuse +typeuse -expect 6 diff --git a/test/clauses.expect b/test/clauses.expect index 36ca6ff..3ef4575 100644 --- a/test/clauses.expect +++ b/test/clauses.expect @@ -25,9 +25,9 @@ clauses3.c:61:5: Storage x->x is released in one path, but live in another. Finished checking --- 2 code warnings, as expected -Warning: selecting unix library. Unix library is ad hoc addition to POSIX -library. Recommend use +posixlib to select POSIX library instead. Use --warnunixlib to suppress this message. +Command Line: Selecting unix library. Unix library is ad hoc addition to POSIX + library. Recommend use +posixlib to select POSIX library instead. Use + -warnunixlib to suppress this message. clauses3.c: (in function h) clauses3.c:48:5: Storage x->x is released in one path, but live in another. clauses3.c:46:10: Storage x->x is released diff --git a/test/enumtag.c b/test/enumtag.c new file mode 100644 index 0000000..6e89120 --- /dev/null +++ b/test/enumtag.c @@ -0,0 +1,37 @@ +typedef struct s_st st; + +struct s_st { + int x; +} ; + + +typedef enum e_tag tag; + +enum e_tag r; + +enum e_tag { + E_X, E_Y, E_Z +} ; + +int f (tag e) +{ + if (e == E_X) + { + return 3; + } + else + { + enum e_tag h = E_Z; + + if (h == e) + { + return 7; + } + } + + return 12; +} + +enum e_tag { + E_M +} ; diff --git a/test/enumtag.expect b/test/enumtag.expect new file mode 100644 index 0000000..19860fb --- /dev/null +++ b/test/enumtag.expect @@ -0,0 +1,8 @@ + +enumtag.c:35:6: Enum tag enum e_tag defined more than once + enumtag.c:12:6: Previous definition of enum e_tag +enumtag.c:35:6: Enum enum e_tag declared with members { E_M } but previously + declared with members { E_X, E_Y, E_Z } + enumtag.c:12:6: Declaration of enum e_tag + +Finished checking --- 2 code warnings, as expected diff --git a/test/exports.expect b/test/exports.expect index 6d3dd7f..c3403bf 100644 --- a/test/exports.expect +++ b/test/exports.expect @@ -1,5 +1,5 @@ -Warning: setting +typeuse redundant with current value +Command Line: Setting +typeuse redundant with current value exports.h:1:13: Type exported, but not specified: myint exports.h:3:12: Variable exported, but not specified: glob exports.h:5:12: Function exported, but not specified: f diff --git a/test/flags.expect b/test/flags.expect index 7fe89bb..b93e9c0 100644 --- a/test/flags.expect +++ b/test/flags.expect @@ -4,10 +4,9 @@ flags.c:5:9: Variable y initialized to type char, expects int: 'c' -flags.c:7:18: Warning: - Value for linelen - must be at least 20 - (given 13) +flags.c:7:18: Value for + linelen must be at + least 20 (given 13) flags.c:11:5: Internal identifier xx2 is not diff --git a/test/rc.expect b/test/rc.expect index 3bd57c8..07a8fd9 100644 --- a/test/rc.expect +++ b/test/rc.expect @@ -11,24 +11,24 @@ rc.c:3:10: Return value type int does not match declared type char *: 12 Finished checking --- 1 code warning, as expected -rc2.splintrc:1:18: Warning: setting +boolint redundant with current value +rc2.splintrc:1:18: Setting +boolint redundant with current value rc.c: (in function f) rc.c:3:10: Observer storage returned without qualification: "a silly\"flag\"\\" rc.c:3:10: Storage becomes observer Finished checking --- 1 code warning, as expected -rc2.splintrc:1:18: Warning: setting +boolint redundant with current value +rc2.splintrc:1:18: Setting +boolint redundant with current value rc.c: (in function f) rc.c:3:10: Unrecognized identifier: MYSTERY Finished checking --- 1 code warning, as expected -rc3.splintrc:2:1: Bad flag syntax (+ or - expected, + is assumed): - internalnamelen 73 +rc3.splintrc:6:3: Flag dump must be followed by a string A flag is not recognized or used in an incorrect way (Use -badflag to inhibit warning) -rc3.splintrc:5:24: Flag dump must be followed by an argument +rc3.splintrc:6:3: Cannot list files in .splintrc files: + internalnamelen, 73 (probable missing + or -) rc.c: (in function f) rc.c:3:10: Unrecognized identifier: MYSTERY