From: herbert Date: Thu, 11 Sep 2003 11:54:11 +0000 (+0000) Subject: Removed obsolete OS/2 test makefiles. X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/commitdiff_plain/6ee276d286314ab6807ce1af746bbd88c186fddc Removed obsolete OS/2 test makefiles. Added snprintf.c for pre-C99 compilers, updated OS/2 specific test Makefiles for where necessary (which is not in all test subdirs). Changed a number of `#ifdef WIN32' directives to `#if defined (WIN32) || defined (OS)', changed the default system dir for OS/2 from `/usr/' to `/os2/'. --- diff --git a/lib/Makefile.os2 b/lib/Makefile.os2 index 985b66f..af6c77f 100644 --- a/lib/Makefile.os2 +++ b/lib/Makefile.os2 @@ -6,13 +6,38 @@ include ../os2/make.vars -DATAFILES = standard.h standard.lcd standardstrict.lcd posix.h posix.lcd \ - posixstrict.lcd unix.h unix.lcd unixstrict.lcd -SPLINT = ../bin/splint$(EXEEXT) +top_builddir = .. -all: $(DATAFILES) +UnixHeaders = stdio.h stdlib.h -clean: $(RM) -f $(DATAFILES) +splintlib_DATA = \ + standard.h standard.lcd standardstrict.lcd posix.h posix.lcd posixstrict.lcd\ + unix.h unix.lcd unixstrict.lcd CTrait.syms CTraitGen.lcl bool.h \ + file.mts file.xh filerw.mts filerw.xh \ + lclinit.lci linux.h lslinit.lsi tainted.mts tainted.xh \ + stdio.h stdlib.h $(UnixHeaders) + +EXTRA_DIST = $(splintlib_DATA) + +CLEANFILES = posix.lcd standard.lcd unix.lcd \ + posixstrict.lcd standardstrict.lcd unixstrict.lcd + + +SPLINT = $(top_builddir)/src/splint$(EXEEXT) + +subdir = lib +CONFIG_HEADER = $(top_builddir)/config.h +DATA = $(splintlib_DATA) + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +all: $(DATA) + +$(SPLINT): + cd $(top_builddir)/src; $(MAKE) -f Makefile.os2 + +clean: + $(RM) -f $(CLEANFILES) standard.lcd: standard.h $(SPLINT) -$(SPLINT) -nof -nolib +impconj standard.h -dump standard diff --git a/os2/Makefile.os2 b/os2/Makefile.os2 index bad7920..3c1252a 100644 --- a/os2/Makefile.os2 +++ b/os2/Makefile.os2 @@ -79,23 +79,11 @@ FLEX = flex YFLAGS = -v -t -d LFLAGS = -### -### file-related commands (I use emx GNUish utilities) -### -CP = cp -MV = mv -CAT = cat -RM = rm -INSTALL = cp -INSTALLFLAGS = -ECHO = echo -SED = sed - ### ### Set automatically: splint version and date etc. ### -LCL_VERSION := $(shell grep "^VERSION" ../configure | $(SED) "s/VERSION *= *//") +LCL_VERSION := $(shell grep "^VERSION" ../configure | sed "s/VERSION *= *//") LCL_DATE := $(shell date +"%d %b %Y") BUILD_DATE := $(shell date +"%c") ME := $(shell whoami) @@ -106,6 +94,22 @@ LCL_PARSE_VERSION = Splint $(LCL_VERSION) SPLINT_VERSION = $(LCL_PARSE_VERSION) -- $(LCL_DATE) +### +### Then, run: +### +### make +### +### + +### file-related commands (I use emx GNUish utilities) +CP = cp +MV = mv +CAT = cat +RM = rm +INSTALL = cp +INSTALLFLAGS = +ECHO = echo + ### ### compiler --- gcc is recommended, but splint has been compiled ### without changes using cc on several platforms. @@ -178,10 +182,9 @@ make.vars: echo "INSTALL = $(INSTALL)" >>make.vars echo "INSTALLFLAGS = $(INSTALLFLAGS)" >>make.vars echo "ECHO = $(ECHO)" >>make.vars - echo "SED = $(SED)" >>make.vars ../config.h: os2config.h.in - $(SED) -e 's|@DEFAULT_LARCHPATH@|$(DEFAULT_LARCHPATH)|' \ + sed -e 's|@DEFAULT_LARCHPATH@|$(DEFAULT_LARCHPATH)|' \ -e 's|@DEFAULT_LCLIMPORTDIR@|$(DEFAULT_LCLIMPORTDIR)|' \ -e 's|@GCC_INCLUDE_DIR@|$(GCC_INCLUDE_DIR)|' \ -e 's|@GCC_INCLUDE_DIR2@|$(GCC_INCLUDE_DIR2)|' \ @@ -194,9 +197,9 @@ make.vars: os2config.h.in >../config.h setenv.cmd: setenv.cmd.in - $(SED) -e 's|@LCL_VERSION@|$(LCL_VERSION)|' \ + sed -e 's|@LCL_VERSION@|$(LCL_VERSION)|' \ -e 's|@BASEDIR@|$(BASEDIR)|' \ - setenv.cmd.in | tr '/' '\\\\' >setenv.cmd + setenv.cmd.in | tr '/' '\\\\\\' >setenv.cmd config: make.vars ../config.h setenv.cmd diff --git a/os2/README.OS2 b/os2/README.OS2 index 019bfaf..e6279d4 100644 --- a/os2/README.OS2 +++ b/os2/README.OS2 @@ -1,5 +1,5 @@ -splint 3.0.0.16 for OS/2 -======================== +splint 3.1.1 for OS/2 +===================== This file is originally part of the binary distribution of splint for OS/2. @@ -94,6 +94,10 @@ History: The following things specific to the OS/2 version of splint have changed / fixed since the first official release: +version 3.1.1 +- Set the default system directory to `/os2/'. +- Bugfixes. + version 3.0.0.16: - Finally fully united the OS/2 port with the main source tree. - Bugfixes. diff --git a/src/Headers/basic.h b/src/Headers/basic.h index 5fd921a..1d14404 100644 --- a/src/Headers/basic.h +++ b/src/Headers/basic.h @@ -22,11 +22,15 @@ # include # include -# ifndef WIN32 +# if !defined (WIN32) && !(defined (OS2) && defined (__IBMC__)) /* Microsoft VC++ still doesn't support ISO C99... */ # include # endif +#if defined (OS2) && defined (__IBMC__) +extern int snprintf (char *str, size_t count, const char *fmt, ...); +#endif + # include # include # include diff --git a/src/Headers/bool.h b/src/Headers/bool.h index d0e0be5..0989f14 100644 --- a/src/Headers/bool.h +++ b/src/Headers/bool.h @@ -7,7 +7,7 @@ # define BOOL_H -# ifdef WIN32 +# if defined (WIN32) || defined (OS2) && defined (__IBMC__) # ifndef FALSE /*@constant bool FALSE=false@*/ # define FALSE 0 diff --git a/src/Headers/constants.h b/src/Headers/constants.h index 9c0ef2a..83867fb 100644 --- a/src/Headers/constants.h +++ b/src/Headers/constants.h @@ -97,7 +97,11 @@ # define PPMRCODE "@@MR@@" /*@constant observer char *DEFAULT_SYSTEMDIR; @*/ +# ifdef OS2 +# define DEFAULT_SYSTEMDIR "/os2/" +# else # define DEFAULT_SYSTEMDIR "/usr/" +# endif /*@constant char DEFAULT_COMMENTCHAR; @*/ # define DEFAULT_COMMENTCHAR '@' diff --git a/src/Headers/forwardTypes.h b/src/Headers/forwardTypes.h index 36a417b..091bea7 100644 --- a/src/Headers/forwardTypes.h +++ b/src/Headers/forwardTypes.h @@ -3,7 +3,7 @@ # include "lclForwardTypes.h" -# ifdef WIN32 +# if defined (WIN32) || defined (OS2) && defined (__IBMC__) /* Microsoft doesn't support ISO C99 yet */ /*@-namechecks@*/ typedef int bool; diff --git a/src/Makefile.os2 b/src/Makefile.os2 index 8fe9af8..206b37b 100644 --- a/src/Makefile.os2 +++ b/src/Makefile.os2 @@ -42,24 +42,24 @@ LISTSRC = clauseStack.c filelocStack.c \ CPPSRC = cppmain.c cpplib.c cppexp.c cpphash.c cpperror.c -CSRC = uentry.c cprim.c macrocache.c qual.c qtype.c stateClause.c \ +CSRC = context.c uentry.c cprim.c macrocache.c qual.c qtype.c stateClause.c \ stateClauseList.c ctype.c cvar.c clabstract.c idDecl.c clause.c \ globalsClause.c modifiesClause.c warnClause.c functionClause.c \ functionClauseList.c metaStateConstraint.c metaStateConstraintList.c \ metaStateExpression.c metaStateSpecifier.c functionConstraint.c \ - pointers.c + pointers.c cscannerHelp.c SPLINTSRC = exprNode.c exprChecks.c llmain.c help.c rcfiles.c CHECKSRC = structNames.c transferChecks.c varKinds.c nameChecks.c -GLOBSRC = context.c globals.c flags.c general.c osd.c reader.c mtreader.c +GLOBSRC = globals.c flags.c general.c osd.c reader.c mtreader.c GRAMSRC = cgrammar.c cscanner.c mtscanner.c mtgrammar.c llgrammar.c signature.c -OVERFLOWCHSRC = constraintGeneration.c constraintTerm.c \ +OVERFLOWCHSRC = constraintList.c constraintResolve.c \ + constraintGeneration.c constraintTerm.c \ constraintExprData.c constraintExpr.c constraint.c \ - constraintList.c constraintResolve.c \ - constraintOutput.c loopHeuristics.c + loopHeuristics.c GENERALSRC = exprData.c cstring.c fileloc.c message.c inputStream.c \ fileTable.c cstringTable.c valueTable.c stateValue.c \ @@ -99,113 +99,33 @@ LCLLISTSRC = initDeclNodeList.c sortList.c declaratorInvNodeList.c \ IFILES = ctbase.i cttable.i exprDataQuite.i - #Files that are used on systems that do not have bison or yacc DER_BISON_FILES = signature.c.der cgrammar.c.der mtgrammar.c.der \ llgrammar.c.der DER_FILES = $(DER_BISON_FILES) -COMMONSRC = $(OVERFLOWCHSRC) $(CPPSRC) $(CSRC) $(CHECKSRC) $(GENERALSRC) \ - $(GLOBSRC) $(IFACESRC) $(LISTSRC) $(SETSRC) $(METASTATESRC) +COMMONSRC = $(CPPSRC) $(CSRC) $(CHECKSRC) $(GENERALSRC) \ + $(GLOBSRC) $(LISTSRC) $(SETSRC) $(METASTATESRC) + +LCLSRC = $(LCLSETSRC) $(LCLLISTSRC) $(LSLSRC) $(COMMONSRC) $(LCLONLYSRC) -ALLSRC = $(GRAMSRC) $(COMMONSRC) $(SPLINTSRC) $(DER_FILES) +ALLSRC = $(GRAMSRC) $(SPLINTSRC) $(OVERFLOWCHSRC) $(LCLSRC) snprintf.c #files to run Splint on -LINTSRC = $(COMMONSRC) $(SPLINTSRC) cscanner.c cgrammar.c +LINTSRC = $(COMMONSRC) $(SPLINTSRC) -LCLSRC = $(LCLSETSRC) $(LCLLISTSRC) $(LSLSRC) $(CMNSRC) $(LCLONLYSRC) lcl_SOURCES = $(LCLSRC) CONFIG_HEADER = $(top_builddir)/config.h splint_SOURCES = $(ALLSRC) - -lcl_OBJECTS = lsymbolSet$O sigNodeSet$O \ - lslOpSet$O sortSet$O initDeclNodeList$O \ - sortList$O declaratorInvNodeList$O \ - interfaceNodeList$O sortSetList$O \ - declaratorNodeList$O letDeclNodeList$O \ - stDeclNodeList$O storeRefNodeList$O \ - lslOpList$O lsymbolList$O \ - termNodeList$O ltokenList$O \ - traitRefNodeList$O pairNodeList$O \ - typeNameNodeList$O fcnNodeList$O \ - paramNodeList$O programNodeList$O \ - varDeclarationNodeList$O varNodeList$O \ - quantifierNodeList$O replaceNodeList$O \ - importNodeList$O tokentable$O scan$O \ - scanline$O lslparse$O lh$O \ - checking$O lclctypes$O imports$O \ - lslinit$O syntable$O \ - usymtab_interface$O abstract$O ltoken$O \ - lclscanline$O lclsyntable$O \ - lcltokentable$O sort$O symtable$O \ - lclinit$O shift$O lclscan$O \ - lsymbol$O mapping$O - -splint_OBJECTS = cgrammar$O cscanner$O \ - mtscanner$O mtgrammar$O llgrammar$O \ - signature$O cppmain$O cpplib$O \ - cppexp$O cpphash$O cpperror$O \ - context$O uentry$O cprim$O \ - macrocache$O qual$O qtype$O \ - stateClause$O stateClauseList$O ctype$O \ - cvar$O clabstract$O idDecl$O \ - clause$O globalsClause$O \ - modifiesClause$O warnClause$O \ - functionClause$O functionClauseList$O \ - metaStateConstraint$O metaStateConstraintList$O \ - metaStateExpression$O metaStateSpecifier$O \ - functionConstraint$O pointers$O \ - structNames$O transferChecks$O \ - varKinds$O nameChecks$O exprData$O \ - cstring$O fileloc$O message$O \ - inputStream$O fileTable$O \ - cstringTable$O valueTable$O \ - stateValue$O llerror$O messageLog$O \ - flagMarker$O aliasTable$O ynm$O \ - sRefTable$O genericTable$O ekind$O \ - usymtab$O multiVal$O lltok$O \ - sRef$O lcllib$O randomNumbers$O \ - fileLib$O globals$O \ - flags$O general$O osd$O \ - reader$O mtreader$O clauseStack$O \ - filelocStack$O cstringList$O \ - cstringSList$O sRefSetList$O \ - ctypeList$O enumNameList$O \ - enumNameSList$O exprNodeList$O \ - exprNodeSList$O uentryList$O \ - fileIdList$O filelocList$O qualList$O \ - sRefList$O flagMarkerList$O \ - idDeclList$O flagSpec$O globSet$O \ - intSet$O typeIdSet$O guardSet$O \ - usymIdSet$O sRefSet$O stateInfo$O \ - stateCombinationTable$O metaStateTable$O \ - metaStateInfo$O annotationTable$O \ - annotationInfo$O mttok$O \ - mtDeclarationNode$O mtDeclarationPieces$O \ - mtDeclarationPiece$O mtContextNode$O \ - mtValuesNode$O mtDefaultsNode$O \ - mtAnnotationsNode$O mtMergeNode$O \ - mtAnnotationList$O mtAnnotationDecl$O \ - mtTransferClauseList$O mtTransferClause$O \ - mtTransferAction$O mtLoseReferenceList$O \ - mtLoseReference$O mtDefaultsDeclList$O \ - mtDefaultsDecl$O mtMergeItem$O \ - mtMergeClause$O mtMergeClauseList$O \ - exprNode$O exprChecks$O llmain$O \ - help$O rcfiles$O constraintGeneration$O \ - constraintTerm$O constraintExprData$O \ - constraintExpr$O constraint$O \ - constraintList$O constraintResolve$O \ - constraintOutput$O loopHeuristics$O snprintf$O +splint_OBJECTS = $(splint_SOURCES:.c=$O) # Keep it fake .PHONY: lcl$(EXEEXT) DEFS = -DHAVE_CONFIG_H DEFAULT_INCLUDES = -I. -I.. -LDADD = $(lcl_OBJECTS) ## Sources that need to be built BUILT_SOURCES = Headers/signature_gen.h Headers/cgrammar_tokens.h \ @@ -239,14 +159,10 @@ else @echo "Expect 141 shift/reduce conflicts and 111 reduce/reduce conflicts." @echo "(see cgrammar.y for explanation)" $(BISON) $(YFLAGS) cgrammar.y - $(CAT) bison.head cgrammar.tab.c bison.reset | $(SED) \ - -e 's/YYSTYPE/cgrammar_YYSTYPE/g' -e 's/lsllex/cgrammar_lsllex/' \ - >cgrammar.c + $(CAT) bison.head cgrammar.tab.c bison.reset >cgrammar.c $(CP) cgrammar.c cgrammar.c.der -$(MV) Headers/cgrammar_tokens.h Headers/cgrammar_tokens.bak - $(CAT) bison.head cgrammar.tab.h bison.reset | $(SED) \ - -e 's/YYSTYPE/cgrammar_YYSTYPE/g' -e 's/lsllex/cgrammar_lsllex/g' \ - >Headers/cgrammar_tokens.h + $(CAT) bison.head cgrammar.tab.h bison.reset >Headers/cgrammar_tokens.h $(RM) cgrammar.tab.c cgrammar.tab.h endif @@ -285,31 +201,31 @@ endif cscanner.c: cscanner.l $(FLEX) $(LFLAGS) cscanner.l - $(CAT) flex.head lexyy.c flex.reset | $(SED) \ - -e 's/YYSTYPE/cgrammar_YYSTYPE/g' -e 's/lsllex/cgrammar_lsllex/g' \ - >cscanner.c + $(CAT) flex.head lexyy.c flex.reset > cscanner.c Headers/flag_codes.gen: flags.def grep "FLG_" flags.def > Headers/flag_codes.gen + $(MAKE) + cd ../lib; $(MAKE) $(binDir)/splint$(EXEEXT): splint$(EXEEXT) -$(RM) -f $(binDir)/splint$(EXEEXT) $(CP) splint$(EXEEXT) $(binDir)/splint$(EXEEXT) -up: clean - rm -f cgrammar.c llgrammar.c mtgrammar.c signature.c cscanner.c - - clean: -rm -f $(splint_OBJECTS) core *.core *~ - + -rm -f cgrammar.c llgrammar.c mtgrammar.c signature.c cscanner.c CLEANFILES = splint$(EXEEXT) $(binDir)/splint$(EXEEXT) +snprintf$O: snprintf.c + $(CC) $(CFLAGS) $(DEFS) $(DEFAULT_INCLUDES) \ + -DHAVE_STRING_H -DHAVE_STDLIB_H -DHAVE_CTYPE_H $(CPPFLAGS) -c $< + %$O: %.c $(CC) $(CFLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(CPPFLAGS) -c $< -splint$(EXEEXT) : $(splint_OBJECTS) $(lcl_OBJECTS) +splint$(EXEEXT) : $(splint_OBJECTS) $(CC) $(OFLAG)$@ $^ $(LDFLAGS) list: diff --git a/src/context.c b/src/context.c index 6493cc1..0f1906b 100644 --- a/src/context.c +++ b/src/context.c @@ -935,7 +935,7 @@ context_resetAllFlags (void) ** On by default for Win32, but not Unix */ -# ifdef WIN32 +# if defined (WIN32) || defined (OS2) gc.flags[FLG_PARENFILEFORMAT] = TRUE; gc.flags[FLG_CASEINSENSITIVEFILENAMES] = TRUE; # endif diff --git a/src/llmain.c b/src/llmain.c index 7b8ad6f..343441f 100644 --- a/src/llmain.c +++ b/src/llmain.c @@ -823,7 +823,7 @@ int main (int argc, char *argv[]) */ { -# ifdef WIN32 +# if defined (WIN32) || defined (OS2) && defined (__IBMC__) int nfiles = /*@-unrecog@*/ _fcloseall (); /*@=unrecog@*/ if (nfiles != 0) @@ -1258,7 +1258,7 @@ cleanupFiles (void) } else { -# ifdef WIN32 +# if defined (WIN32) || defined (OS2) && defined (__IBMC__) int nfiles = /*@-unrecog@*/ _fcloseall (); /*@=unrecog@*/ if (nfiles != 0) @@ -1281,7 +1281,7 @@ llexit (int status) { DPRINTF (("llexit: %d", status)); -# ifdef WIN32 +# if defined (WIN32) || defined (OS2) && defined (__IBMC__) if (status == LLFAILURE) { _fcloseall (); diff --git a/src/osd.c b/src/osd.c index 653a0ee..0014942 100644 --- a/src/osd.c +++ b/src/osd.c @@ -452,7 +452,7 @@ nextdir (d_char *current_dir, d_char *dir, size_t *len) # endif } -# ifdef WIN32 +# if defined (WIN32) || defined (OS2) && defined (__IBMC__) extern /*@external@*/ int _flushall (void) /*@modifies fileSystem@*/ ; # endif @@ -463,7 +463,7 @@ int osd_system (cstring cmd) { int res; /* system ("printenv"); */ -# ifdef WIN32 +# if defined (WIN32) || defined (OS2) && defined (__IBMC__) (void) _flushall (); # endif diff --git a/src/snprintf.c b/src/snprintf.c new file mode 100644 index 0000000..032e7e3 --- /dev/null +++ b/src/snprintf.c @@ -0,0 +1,940 @@ +#if defined (OS2) && defined (__IBMC__) +/* + * Copyright Patrick Powell 1995 + * This code is based on code written by Patrick Powell (papowell@astart.com) + * It may be used for any purpose as long as this notice remains intact + * on all source code distributions + */ + +/************************************************************** + * Original: + * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 + * A bombproof version of doprnt (dopr) included. + * Sigh. This sort of thing is always nasty do deal with. Note that + * the version here does not include floating point... + * + * snprintf() is used instead of sprintf() as it does limit checks + * for string length. This covers a nasty loophole. + * + * The other functions are there to prevent NULL pointers from + * causing nast effects. + * + * More Recently: + * Brandon Long 9/15/96 for mutt 0.43 + * This was ugly. It is still ugly. I opted out of floating point + * numbers, but the formatter understands just about everything + * from the normal C string format, at least as far as I can tell from + * the Solaris 2.5 printf(3S) man page. + * + * Brandon Long 10/22/97 for mutt 0.87.1 + * Ok, added some minimal floating point support, which means this + * probably requires libm on most operating systems. Don't yet + * support the exponent (e,E) and sigfig (g,G). Also, fmtint() + * was pretty badly broken, it just wasn't being exercised in ways + * which showed it, so that's been fixed. Also, formated the code + * to mutt conventions, and removed dead code left over from the + * original. Also, there is now a builtin-test, just compile with: + * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm + * and run snprintf for results. + * + * Thomas Roessler 01/27/98 for mutt 0.89i + * The PGP code was using unsigned hexadecimal formats. + * Unfortunately, unsigned formats simply didn't work. + * + * Michael Elkins 03/05/98 for mutt 0.90.8 + * The original code assumed that both snprintf() and vsnprintf() were + * missing. Some systems only have snprintf() but not vsnprintf(), so + * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. + * + * Andrew Tridgell (tridge@samba.org) Oct 1998 + * fixed handling of %.0f + * added test for HAVE_LONG_DOUBLE + * + * tridge@samba.org, idra@samba.org, April 2001 + * got rid of fcvt code (twas buggy and made testing harder) + * added C99 semantics + * + **************************************************************/ + +#ifndef NO_CONFIG_H /* for some tests */ +#include "config.h" +#endif + +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_STRINGS_H +#include +#endif +#ifdef HAVE_CTYPE_H +#include +#endif +#include +#include +#ifdef HAVE_STDLIB_H +#include +#endif + +#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF) +/* only include stdio.h if we are not re-defining snprintf or vsnprintf */ +#include +/* make the compiler happy with an empty file */ +void dummy_snprintf(void) {} +#else + +#ifdef HAVE_LONG_DOUBLE +#define LDOUBLE long double +#else +#define LDOUBLE double +#endif + +#ifdef HAVE_LONG_LONG +#define LLONG long long +#else +#define LLONG long +#endif + +static size_t dopr(char *buffer, size_t maxlen, const char *format, + va_list args); +static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max); +static void fmtint(char *buffer, size_t *currlen, size_t maxlen, + long value, int base, int min, int max, int flags); +static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags); +static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); + +/* + * dopr(): poor man's version of doprintf + */ + +/* format read states */ +#define DP_S_DEFAULT 0 +#define DP_S_FLAGS 1 +#define DP_S_MIN 2 +#define DP_S_DOT 3 +#define DP_S_MAX 4 +#define DP_S_MOD 5 +#define DP_S_CONV 6 +#define DP_S_DONE 7 + +/* format flags - Bits */ +#define DP_F_MINUS (1 << 0) +#define DP_F_PLUS (1 << 1) +#define DP_F_SPACE (1 << 2) +#define DP_F_NUM (1 << 3) +#define DP_F_ZERO (1 << 4) +#define DP_F_UP (1 << 5) +#define DP_F_UNSIGNED (1 << 6) + +/* Conversion Flags */ +#define DP_C_SHORT 1 +#define DP_C_LONG 2 +#define DP_C_LDOUBLE 3 +#define DP_C_LLONG 4 + +#define char_to_int(p) ((p)- '0') +#ifndef MAX +#define MAX(p,q) (((p) >= (q)) ? (p) : (q)) +#endif + +static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args) +{ + char ch; + LLONG value; + LDOUBLE fvalue; + char *strvalue; + int min; + int max; + int state; + int flags; + int cflags; + size_t currlen; + + state = DP_S_DEFAULT; + currlen = flags = cflags = min = 0; + max = -1; + ch = *format++; + + while (state != DP_S_DONE) { + if (ch == '\0') + state = DP_S_DONE; + + switch(state) { + case DP_S_DEFAULT: + if (ch == '%') + state = DP_S_FLAGS; + else + dopr_outch (buffer, &currlen, maxlen, ch); + ch = *format++; + break; + case DP_S_FLAGS: + switch (ch) { + case '-': + flags |= DP_F_MINUS; + ch = *format++; + break; + case '+': + flags |= DP_F_PLUS; + ch = *format++; + break; + case ' ': + flags |= DP_F_SPACE; + ch = *format++; + break; + case '#': + flags |= DP_F_NUM; + ch = *format++; + break; + case '0': + flags |= DP_F_ZERO; + ch = *format++; + break; + default: + state = DP_S_MIN; + break; + } + break; + case DP_S_MIN: + if (isdigit((unsigned char)ch)) { + min = 10*min + char_to_int (ch); + ch = *format++; + } else if (ch == '*') { + min = va_arg (args, int); + ch = *format++; + state = DP_S_DOT; + } else { + state = DP_S_DOT; + } + break; + case DP_S_DOT: + if (ch == '.') { + state = DP_S_MAX; + ch = *format++; + } else { + state = DP_S_MOD; + } + break; + case DP_S_MAX: + if (isdigit((unsigned char)ch)) { + if (max < 0) + max = 0; + max = 10*max + char_to_int (ch); + ch = *format++; + } else if (ch == '*') { + max = va_arg (args, int); + ch = *format++; + state = DP_S_MOD; + } else { + state = DP_S_MOD; + } + break; + case DP_S_MOD: + switch (ch) { + case 'h': + cflags = DP_C_SHORT; + ch = *format++; + break; + case 'l': + cflags = DP_C_LONG; + ch = *format++; + if (ch == 'l') { /* It's a long long */ + cflags = DP_C_LLONG; + ch = *format++; + } + break; + case 'L': + cflags = DP_C_LDOUBLE; + ch = *format++; + break; + default: + break; + } + state = DP_S_CONV; + break; + case DP_S_CONV: + switch (ch) { + case 'd': + case 'i': + if (cflags == DP_C_SHORT) + value = va_arg (args, int); + else if (cflags == DP_C_LONG) + value = va_arg (args, long int); + else if (cflags == DP_C_LLONG) + value = va_arg (args, LLONG); + else + value = va_arg (args, int); + fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'o': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned int); + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (long)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); + break; + case 'u': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned int); + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (LLONG)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'X': + flags |= DP_F_UP; + case 'x': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg (args, unsigned int); + else if (cflags == DP_C_LONG) + value = (long)va_arg (args, unsigned long int); + else if (cflags == DP_C_LLONG) + value = (LLONG)va_arg (args, unsigned LLONG); + else + value = (long)va_arg (args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); + break; + case 'f': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + /* um, floating point? */ + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); + break; + case 'E': + flags |= DP_F_UP; + case 'e': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + break; + case 'G': + flags |= DP_F_UP; + case 'g': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg (args, LDOUBLE); + else + fvalue = va_arg (args, double); + break; + case 'c': + dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); + break; + case 's': + strvalue = va_arg (args, char *); + if (max == -1) { + max = strlen(strvalue); + } + if (min > 0 && max >= 0 && min > max) max = min; + fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); + break; + case 'p': + strvalue = va_arg (args, void *); + fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); + break; + case 'n': + if (cflags == DP_C_SHORT) { + short int *num; + num = va_arg (args, short int *); + *num = currlen; + } else if (cflags == DP_C_LONG) { + long int *num; + num = va_arg (args, long int *); + *num = (long int)currlen; + } else if (cflags == DP_C_LLONG) { + LLONG *num; + num = va_arg (args, LLONG *); + *num = (LLONG)currlen; + } else { + int *num; + num = va_arg (args, int *); + *num = currlen; + } + break; + case '%': + dopr_outch (buffer, &currlen, maxlen, ch); + break; + case 'w': + /* not supported yet, treat as next char */ + ch = *format++; + break; + default: + /* Unknown, skip */ + break; + } + ch = *format++; + state = DP_S_DEFAULT; + flags = cflags = min = 0; + max = -1; + break; + case DP_S_DONE: + break; + default: + /* hmm? */ + break; /* some picky compilers need this */ + } + } + if (maxlen != 0) { + if (currlen < maxlen - 1) + buffer[currlen] = '\0'; + else if (maxlen > 0) + buffer[maxlen - 1] = '\0'; + } + + return currlen; +} + +static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, + char *value, int flags, int min, int max) +{ + int padlen, strln; /* amount to pad */ + int cnt = 0; + +#ifdef DEBUG_SNPRINTF + printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value); +#endif + if (value == 0) { + value = ""; + } + + for (strln = 0; value[strln]; ++strln); /* strlen */ + padlen = min - strln; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justify */ + + while ((padlen > 0) && (cnt < max)) { + dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + ++cnt; + } + while (*value && (cnt < max)) { + dopr_outch (buffer, currlen, maxlen, *value++); + ++cnt; + } + while ((padlen < 0) && (cnt < max)) { + dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + ++cnt; + } +} + +/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ + +static void fmtint(char *buffer, size_t *currlen, size_t maxlen, + long value, int base, int min, int max, int flags) +{ + int signvalue = 0; + unsigned long uvalue; + char convert[20]; + int place = 0; + int spadlen = 0; /* amount to space pad */ + int zpadlen = 0; /* amount to zero pad */ + int caps = 0; + + if (max < 0) + max = 0; + + uvalue = value; + + if(!(flags & DP_F_UNSIGNED)) { + if( value < 0 ) { + signvalue = '-'; + uvalue = -value; + } else { + if (flags & DP_F_PLUS) /* Do a sign (+/i) */ + signvalue = '+'; + else if (flags & DP_F_SPACE) + signvalue = ' '; + } + } + + if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ + + do { + convert[place++] = + (caps? "0123456789ABCDEF":"0123456789abcdef") + [uvalue % (unsigned)base ]; + uvalue = (uvalue / (unsigned)base ); + } while(uvalue && (place < 20)); + if (place == 20) place--; + convert[place] = 0; + + zpadlen = max - place; + spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); + if (zpadlen < 0) zpadlen = 0; + if (spadlen < 0) spadlen = 0; + if (flags & DP_F_ZERO) { + zpadlen = MAX(zpadlen, spadlen); + spadlen = 0; + } + if (flags & DP_F_MINUS) + spadlen = -spadlen; /* Left Justifty */ + +#ifdef DEBUG_SNPRINTF + printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", + zpadlen, spadlen, min, max, place); +#endif + + /* Spaces */ + while (spadlen > 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + --spadlen; + } + + /* Sign */ + if (signvalue) + dopr_outch (buffer, currlen, maxlen, signvalue); + + /* Zeros */ + if (zpadlen > 0) { + while (zpadlen > 0) { + dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + } + + /* Digits */ + while (place > 0) + dopr_outch (buffer, currlen, maxlen, convert[--place]); + + /* Left Justified spaces */ + while (spadlen < 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + ++spadlen; + } +} + +static LDOUBLE abs_val(LDOUBLE value) +{ + LDOUBLE result = value; + + if (value < 0) + result = -value; + + return result; +} + +static LDOUBLE POW10(int exp) +{ + LDOUBLE result = 1; + + while (exp) { + result *= 10; + exp--; + } + + return result; +} + +static LLONG ROUND(LDOUBLE value) +{ + LLONG intpart; + + intpart = (LLONG)value; + value = value - intpart; + if (value >= 0.5) intpart++; + + return intpart; +} + +/* a replacement for modf that doesn't need the math library. Should + be portable, but slow */ +static double my_modf(double x0, double *iptr) +{ + int i; + long l; + double x = x0; + double f = 1.0; + + for (i=0;i<100;i++) { + l = (long)x; + if (l <= (x+1) && l >= (x-1)) break; + x *= 0.1; + f *= 10.0; + } + + if (i == 100) { + /* yikes! the number is beyond what we can handle. What do we do? */ + (*iptr) = 0; + return 0; + } + + if (i != 0) { + double i2; + double ret; + + ret = my_modf(x0-l*f, &i2); + (*iptr) = l*f + i2; + return ret; + } + + (*iptr) = l; + return x - (*iptr); +} + + +static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, + LDOUBLE fvalue, int min, int max, int flags) +{ + int signvalue = 0; + double ufvalue; + char iconvert[311]; + char fconvert[311]; + int iplace = 0; + int fplace = 0; + int padlen = 0; /* amount to pad */ + int zpadlen = 0; + int caps = 0; + int index; + double intpart; + double fracpart; + double temp; + + /* + * AIX manpage says the default is 0, but Solaris says the default + * is 6, and sprintf on AIX defaults to 6 + */ + if (max < 0) + max = 6; + + ufvalue = abs_val (fvalue); + + if (fvalue < 0) { + signvalue = '-'; + } else { + if (flags & DP_F_PLUS) { /* Do a sign (+/i) */ + signvalue = '+'; + } else { + if (flags & DP_F_SPACE) + signvalue = ' '; + } + } + +#if 0 + if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ +#endif + +#if 0 + if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */ +#endif + + /* + * Sorry, we only support 16 digits past the decimal because of our + * conversion method + */ + if (max > 16) + max = 16; + + /* We "cheat" by converting the fractional part to integer by + * multiplying by a factor of 10 + */ + + temp = ufvalue; + my_modf(temp, &intpart); + + fracpart = ROUND((POW10(max)) * (ufvalue - intpart)); + + if (fracpart >= POW10(max)) { + intpart++; + fracpart -= POW10(max); + } + + + /* Convert integer part */ + do { + temp = intpart; + my_modf(intpart*0.1, &intpart); + temp = temp*0.1; + index = (int) ((temp -intpart +0.05)* 10.0); + /* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */ + /* printf ("%llf, %f, %x\n", temp, intpart, index); */ + iconvert[iplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; + } while (intpart && (iplace < 311)); + if (iplace == 311) iplace--; + iconvert[iplace] = 0; + + /* Convert fractional part */ + if (fracpart) + { + do { + temp = fracpart; + my_modf(fracpart*0.1, &fracpart); + temp = temp*0.1; + index = (int) ((temp -fracpart +0.05)* 10.0); + /* index = (int) ((((temp/10) -fracpart) +0.05) *10); */ + /* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */ + fconvert[fplace++] = + (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; + } while(fracpart && (fplace < 311)); + if (fplace == 311) fplace--; + } + fconvert[fplace] = 0; + + /* -1 for decimal point, another -1 if we are printing a sign */ + padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); + zpadlen = max - fplace; + if (zpadlen < 0) zpadlen = 0; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; /* Left Justifty */ + + if ((flags & DP_F_ZERO) && (padlen > 0)) { + if (signvalue) { + dopr_outch (buffer, currlen, maxlen, signvalue); + --padlen; + signvalue = 0; + } + while (padlen > 0) { + dopr_outch (buffer, currlen, maxlen, '0'); + --padlen; + } + } + while (padlen > 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + --padlen; + } + if (signvalue) + dopr_outch (buffer, currlen, maxlen, signvalue); + + while (iplace > 0) + dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); + +#ifdef DEBUG_SNPRINTF + printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen); +#endif + + /* + * Decimal point. This should probably use locale to find the correct + * char to print out. + */ + if (max > 0) { + dopr_outch (buffer, currlen, maxlen, '.'); + + while (fplace > 0) + dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); + } + + while (zpadlen > 0) { + dopr_outch (buffer, currlen, maxlen, '0'); + --zpadlen; + } + + while (padlen < 0) { + dopr_outch (buffer, currlen, maxlen, ' '); + ++padlen; + } +} + +static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) +{ + if (*currlen < maxlen) { + buffer[(*currlen)] = c; + } + (*currlen)++; +} + +#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) +int vsnprintf (char *str, size_t count, const char *fmt, va_list args) +{ + return dopr(str, count, fmt, args); +} +#endif + +#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF) +int snprintf(char *str,size_t count,const char *fmt,...) +{ + size_t ret; + va_list ap; + + va_start(ap, fmt); + ret = vsnprintf(str, count, fmt, ap); + va_end(ap); + return ret; +} +#endif + +#endif + +#ifndef HAVE_VASPRINTF +int vasprintf(char **ptr, const char *format, va_list ap) +{ + int ret; + + ret = vsnprintf(NULL, 0, format, ap); + if (ret <= 0) return ret; + + (*ptr) = (char *)malloc(ret+1); + if (!*ptr) return -1; + ret = vsnprintf(*ptr, ret+1, format, ap); + + return ret; +} +#endif + + +#ifndef HAVE_ASPRINTF +int asprintf(char **ptr, const char *format, ...) +{ + va_list ap; + int ret; + + va_start(ap, format); + ret = vasprintf(ptr, format, ap); + va_end(ap); + + return ret; +} +#endif + +#ifdef TEST_SNPRINTF + +int sprintf(char *str,const char *fmt,...); + +int main (void) +{ + char buf1[1024]; + char buf2[1024]; + char *fp_fmt[] = { + "%1.1f", + "%-1.5f", + "%1.5f", + "%123.9f", + "%10.5f", + "% 10.5f", + "%+22.9f", + "%+4.9f", + "%01.3f", + "%4f", + "%3.1f", + "%3.2f", + "%.0f", + "%f", + "-16.16f", + NULL + }; + double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, + 0.9996, 1.996, 4.136, 0}; + char *int_fmt[] = { + "%-1.5d", + "%1.5d", + "%123.9d", + "%5.5d", + "%10.5d", + "% 10.5d", + "%+22.33d", + "%01.3d", + "%4d", + "%d", + NULL + }; + long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; + char *str_fmt[] = { + "10.5s", + "5.10s", + "10.1s", + "0.10s", + "10.0s", + "1.10s", + "%s", + "%.1s", + "%.10s", + "%10s", + NULL + }; + char *str_vals[] = {"hello", "a", "", "a longer string", NULL}; + int x, y; + int fail = 0; + int num = 0; + + printf ("Testing snprintf format codes against system sprintf...\n"); + + for (x = 0; fp_fmt[x] ; x++) { + for (y = 0; fp_nums[y] != 0 ; y++) { + int l1 = snprintf(NULL, 0, fp_fmt[x], fp_nums[y]); + int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); + sprintf (buf2, fp_fmt[x], fp_nums[y]); + if (strcmp (buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", + fp_fmt[x], buf1, buf2); + fail++; + } + if (l1 != l2) { + printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, fp_fmt[x]); + fail++; + } + num++; + } + } + + for (x = 0; int_fmt[x] ; x++) { + for (y = 0; int_nums[y] != 0 ; y++) { + int l1 = snprintf(NULL, 0, int_fmt[x], int_nums[y]); + int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); + sprintf (buf2, int_fmt[x], int_nums[y]); + if (strcmp (buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", + int_fmt[x], buf1, buf2); + fail++; + } + if (l1 != l2) { + printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, int_fmt[x]); + fail++; + } + num++; + } + } + + for (x = 0; str_fmt[x] ; x++) { + for (y = 0; str_vals[y] != 0 ; y++) { + int l1 = snprintf(NULL, 0, str_fmt[x], str_vals[y]); + int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); + sprintf (buf2, str_fmt[x], str_vals[y]); + if (strcmp (buf1, buf2)) { + printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", + str_fmt[x], buf1, buf2); + fail++; + } + if (l1 != l2) { + printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, str_fmt[x]); + fail++; + } + num++; + } + } + + printf ("%d tests failed out of %d.\n", fail, num); + + printf("seeing how many digits we support\n"); + { + double v0 = 0.12345678901234567890123456789012345678901; + for (x=0; x<100; x++) { + snprintf(buf1, sizeof(buf1), "%1.1f", v0*pow(10, x)); + sprintf(buf2, "%1.1f", v0*pow(10, x)); + if (strcmp(buf1, buf2)) { + printf("we seem to support %d digits\n", x-1); + break; + } + } + } + + return 0; +} +#endif /* SNPRINTF_TEST */ + +#endif /* OS2 && __IBMC__ */ diff --git a/test/Makefile.os2 b/test/Makefile.os2 index d7c9b5a..430a8fe 100644 --- a/test/Makefile.os2 +++ b/test/Makefile.os2 @@ -36,11 +36,11 @@ UNITTESTS = \ abstptr abstract alias alttypes ansireserved argorder \ args arraydims arrayinit arraylit blocks break cases cast chararraylit 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 \ + linked lintcomments list longint loopexec looptesteffect \ macros macrosef merge mergenull modifies modtest moduncon \ - mongoincludes mystrncat noeffect null observer oldstyle outglob outparam \ + mongoincludes mystrncat noeffect null nullret nullassign numabstract observer oldstyle outglob outparam \ parentype postnotnull preds prefixes printflike rc refcounts release repexpose \ returned sharing shifts sizesigns slovaknames \ specclauses \ @@ -53,10 +53,12 @@ UNITTESTS = \ UNITEXPECTS = $(addsuffix .expect, $(UNITTESTS)) ### warnuse doesn't work yet! -SUBDIRTESTS = metastate mergestate tainted fileio \ +SUBDIRTESTS1 = metastate mergestate fileio \ simplebufferConstraintTests moreBufferTests moreBufferTests2 globalbufferannotation \ - maxset strchr for manual\ -tests2.2 tests2.4 tests2.5 db1 db2 db3 + maxset strchr sizeoftest for manual +SUBDIRTESTS1 = tests2.5 db1 db2 db3 +SUBDIRTESTS2 = tainted tests2.2 tests2.4 +SUBDIRTESTS = $(SUBDIRTESTS1) $(SUBDIRTESTS2) SPLINTTESTS = $(UNITTESTS) $(SUBDIRTESTS) @@ -75,11 +77,12 @@ quicktest: $(SPLINTTESTS) help: -@$(SPLINT) - #@LARCH_PATH=/dev/null; $(SPLINT) -nof empty.lcl - @$(SPLINT) -help - @$(SPLINTP) -asdf - @$(SPLINTP) +boolint +boolint - @$(SPLINT) -help flags alpha + -@$(SPLINT) -help + -@$(SPLINTP) -asdf + -@$(SPLINTP) +boolint +boolint + -@$(SPLINT) -help flags alpha + +### Rules for tests start here .PHONY: abstptr abstptr: @@ -175,15 +178,16 @@ cast: .PHONY: chararraylit chararraylit: - -$(SPLINTR) chararraylit.c -expect 2 + $(SPLINTR) chararraylit.c -expect 2 ### Two addition errors detected with 2.5 with -numliteral. +### evans 2002-12-15: finds one more but in charlit .PHONY: charlit charlit: $(SPLINTR) +hints charlit.c -expect 4 $(SPLINTR) +hints -numliteral charlit.c -expect 6 - $(SPLINTR) +hints charlit.c +charintliteral +ignoresigns + $(SPLINTR) +hints charlit.c +charintliteral +ignoresigns -expect 1 .PHONY: clauses clauses: @@ -284,7 +288,7 @@ enum: .PHONY: enumtag enumtag: - -$(SPLINTR) enumtag.c -expect 2 + $(SPLINTR) enumtag.c -expect 2 .PHONY: exports exports: @@ -400,13 +404,14 @@ keep: ### libs ### 2001-05-22: 2 new errors found (fixed spec of signal) ### 2001-05-30: 3 new errors found (formatconst) +### 2002-07-08: 2 new errors found (getc modifies errno) .PHONY: libs libs: $(SPLINTR) libs.c +longunsignedunsignedintegral -expect 18 $(SPLINTR) libs.c -expect 22 $(SPLINTR) libs.c +globunspec +modunspec -expect 25 - $(SPLINTR) libs.c +strictlib +globunspec +modunspec -expect 42 + $(SPLINTR) libs.c +strictlib +globunspec +modunspec -expect 44 .PHONY: lintcomments lintcomments: @@ -418,6 +423,17 @@ lintcomments: list: $(SPLINTR) list.c -expect 3 +### +### 2002-12-12: Added test case for +longint and +shortint flags +### + +.PHONY: longint +longint: + $(SPLINTR) longint.c -expect 3 + $(SPLINTR) longint.c +longint -expect 2 + $(SPLINTR) longint.c +shortint -expect 2 + $(SPLINTR) longint.c +shortint +longint -expect 0 + ### ### 2002-01-01: Added test case for obvious loop execution. ### @@ -493,7 +509,7 @@ null: $(SPLINTR) null1.c -null -mustdefine -expect 4 $(SPLINTR) null2.c -expect 11 $(SPLINTR) null3.c -expect 15 - $(SPLINTR) null3.c -warnunixlib +unixlib -expect 16 + $(SPLINTR) null3.c +unixlib -expect 16 $(SPLINTR) null4.c -expect 1 $(SPLINTR) null5.c -expect 4 $(SPLINTR) null6 -expect 4 @@ -505,13 +521,21 @@ null: .PHONY: nullret nullret: $(SPLINTR) nullret.c -expect 2 - $(SPLINTR) -nullret nullret.c -expect 1 + $(SPLINTR) -nullret nullret.c -expect 0 .PHONY: nullassign nullassign: $(SPLINTR) nullassign.c -expect 2 $(SPLINTR) -nullassign nullassign.c -expect 1 +### Added for 3.1 - evans 2002-12-14 + +.PHONY: numabstract +numabstract: + $(SPLINTR) numabstract.c -expect 11 + $(SPLINTR) numabstract.c +numabstractlit -expect 9 + $(SPLINTR) numabstract.c -numabstractcast -expect 10 + # # Before 2.4, expected one more because error was reported both as # dependent and observer. @@ -554,7 +578,7 @@ parentype: preds: $(SPLINTR) +hints preds.c -expect 6 $(SPLINTRN) +hints preds.c -weak -expect 1 - $(SPLINTRN) +hints preds.c -strict -exportlocal -exportheader -expect 12 + $(SPLINTRN) +hints preds.c -strict -exportlocal -exportheader -expect 10 .PHONY: prefixes prefixes: @@ -573,7 +597,7 @@ prefixes: $(SPLINTR) prefixes.c -globalprefix "&G?_^" -expect 1 $(SPLINTR) prefixes.c -externalprefix "G" -expect 5 $(SPLINTR) prefixes.c -typeprefix "T" -externalprefix "G" -expect 4 -# herbert: unsolved problem with quoting the '*' here! +# Herbert: this does not work under OS/2 # $(SPLINTR) prefixes.c -localprefix "?*" +localprefixexclude -expect 13 .PHONY: printflike @@ -592,7 +616,7 @@ rc: .PHONY: rcfiles rcfiles: - cd rcfiles; ${MAKE} SPLINT="$(SPLINTPNEST)" + cd rcfiles; ${MAKE} SPLINT="-$(SPLINTPNEST)" .PHONY: refcounts refcounts: @@ -629,12 +653,12 @@ shifts: $(SPLINTR) shifts.c -shiftimplementation -expect 3 $(SPLINTR) shifts.c -shiftnegative -expect 1 +#drl comment this out until sizesigns is added to cvs + ### evans - added 2002-08-17: check warnings with arbitrary integral types sizesigns: - -$(SPLINTR) +strict sizesigns.c - -$(SPLINTR) +strict +ignoresigns sizesigns.c - -$(SPLINTR) +strict +matcharbitraryintegral sizesigns.c - -$(SPLINTR) +strict +matcharbitraryintegral +ignoresignz sizesigns.c + $(SPLINTR) +strict sizesigns.c -expect 5 + $(SPLINTR) +strict +matchanyintegral sizesigns.c -expect 4 .PHONY: slovaknames slovaknames: @@ -775,6 +799,8 @@ ullint: ### ### 2001-12-30: Poor warnings reported by Peter Deutsch ### +### 2002-07-03: removed warnings for datatype/macro definitions +### .PHONY: utypes utypes: @@ -819,7 +845,15 @@ sizeof: buffertest: $(SPLINTR) +bounds buffertest1.c -expect 5 -.PHONY: $(SUBDIRTESTS) -$(SUBDIRTESTS): - $(MAKE) -C $@ SPLINT="$(SPLINTRNNEST)" +.PHONY: $(SUBDIRTESTS1) +$(SUBDIRTESTS1): + cd $@; $(MAKE) SPLINT="$(SPLINTRNNEST)" + +.PHONY: $(SUBDIRTESTS2) +$(SUBDIRTESTS2): + cd $@; $(MAKE) SPLINT="$(SPLINTRNNEST)" -f Makefile.os2 +# sizesigns.c sizesigns.expect \ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/tainted/Makefile.os2 b/test/tainted/Makefile.os2 new file mode 100644 index 0000000..247d905 --- /dev/null +++ b/test/tainted/Makefile.os2 @@ -0,0 +1,19 @@ +.PHONY: tainted + +SPLINT = splint + +all: tainted + +tainted: + ${SPLINT} -mts tainted tainted.c -mustfree -exportlocal -expect 4 +# herbert: TODO + ${SPLINT} tainted-bad.mts tainted.xh tainted.c -mustfree -exportlocal -expect 9 + ${SPLINT} -mts tainted tainted2.c -mustfree -exportlocal -expect 1 + ${SPLINT} -mts tainted tainted3.c -mustfree -exportlocal -expect 1 + ${SPLINT} -mts tainted tainted4.c -mustfree -exportlocal -expect 1 + ${SPLINT} -mts tainted tainted5.c -mustfree -exportlocal + ${SPLINT} -mts tainted taintedmerge.c -mustfree -exportlocal -expect 3 + ${SPLINT} -mts tainted taintedimplicit.c -mustfree -exportlocal -expect 1 + ${SPLINT} -mts tainted sprintf.c -expect 5 + +# evans 2002-07-09: 3 more warnings for sprintf because of sprintf diff --git a/test/tests2.2/Makefile-tests2.2.os2 b/test/tests2.2/Makefile-tests2.2.os2 deleted file mode 100644 index 8f6f70a..0000000 --- a/test/tests2.2/Makefile-tests2.2.os2 +++ /dev/null @@ -1,50 +0,0 @@ -.PHONY: boolops bool boolenum break bstring decl enumbool extension modarray nestext offestof sizeofarray rex struct - -LCLINT = lclint - -all: boolops bool boolenum break bstring decl enumbool extension modarray nestext offestof sizeofarray rex struct - -boolops: - $(LCLINT) boolops.c -expect 1 - -bool: - $(LCLINT) bool.lcl booldef.c -expect 1 - -boolenum: - $(LCLINT) boolenum.c -booltype BOOLEAN -expect 1 - -break: - $(LCLINT) break.c -expect 1 - -bstring: - $(LCLINT) bstring.c -expect 2 - -decl: - $(LCLINT) decl.c -expect 1 - -enumbool: - $(LCLINT) enumbool.c -expect 3 - $(LCLINT) enumbool.c -booltype "bool" -booltrue "true" -boolfalse "false" - -extension: - -$(LCLINT) extension.c - -$(LCLINT) -gnuextensions extension.c - -modarray: - $(LCLINT) modarray.c - -nestext: - $(LCLINT) nestext.c -expect 1 - -offsetof: - $(LCLINT) offsetof.c - -sizeofarray: - $(LCLINT) sizeofarray.c -expect 3 - -rex: - $(LCLINT) rex.c -expect 4 -### 3 new errors reported - -struct: - $(LCLINT) struct.c -expect 1 diff --git a/test/tests2.2/Makefile.os2 b/test/tests2.2/Makefile.os2 new file mode 100644 index 0000000..0f25149 --- /dev/null +++ b/test/tests2.2/Makefile.os2 @@ -0,0 +1,52 @@ +.PHONY: boolops bool boolenum break bstring decl enumbool extension modarray nestext offestof sizeofarray rex struct + +SPLINT = splint + +all: boolops bool boolenum break bstring decl enumbool extension modarray nestext offestof sizeofarray rex struct + +boolops: + $(SPLINT) boolops.c -expect 1 + +bool: + -$(SPLINT) bool.lcl booldef.c -expect 1 + +boolenum: + $(SPLINT) boolenum.c -booltype BOOLEAN -booltrue TRUE -boolfalse FALSE -expect 1 + +break: + $(SPLINT) break.c -expect 1 + +bstring: + $(SPLINT) bstring.c -expect 2 + +decl: + $(SPLINT) decl.c -expect 1 + +enumbool: + $(SPLINT) enumbool.c -booltrue true -boolfalse false +# Herbert: TODO + -$(SPLINT) enumbool.c -booltrue TRUE -boolfalse FALSE -expect 2 + +extension: + $(SPLINT) extension.c +# Herbert: TODO + -$(SPLINT) -gnuextensions extension.c + +modarray: + $(SPLINT) modarray.c + +nestext: + $(SPLINT) nestext.c -expect 1 + +offsetof: + $(SPLINT) offsetof.c + +sizeofarray: + $(SPLINT) sizeofarray.c -expect 3 + +rex: + $(SPLINT) rex.c -expect 4 +### 3 new errors reported + +struct: + $(SPLINT) struct.c -expect 1 diff --git a/test/tests2.4/Makefile-tests2.4.os2 b/test/tests2.4/Makefile-tests2.4.os2 deleted file mode 100644 index ea99f56..0000000 --- a/test/tests2.4/Makefile-tests2.4.os2 +++ /dev/null @@ -1,78 +0,0 @@ -.PHONY: emptycase enumtest duffs bitfields bugs tests hexconstants innercomment nothing offsetof komazi print syslog error ulrich cpptest longlong subdir fink driverstub alignof source emptycase enumtest duffs bitfields bugs tests hexconstants innercomment nothing offsetof komazi print syslog error ulrich cpptest longlong subdir fink driverstub alignof source - -LCLINT = lclint - -all: emptycase enumtest duffs bitfields bugs tests hexconstants innercomment nothing offsetof komazi print syslog ulrich cpptest longlong subdir fink alignof source -#error driverstub - -emptycase: - $(LCLINT) emptycase.c - -enumtest: - $(LCLINT) enumtest.c -expect 2 - -duffs: - $(LCLINT) duffs.c -expect 7 - -bitfields: - $(LCLINT) bitfields.c - -bugs: - $(LCLINT) bug1.c - $(LCLINT) bug2.c -expect 5 - $(LCLINT) bug3.c -expect 3 - -tests: - $(LCLINT) test0.c - $(LCLINT) test1.c - $(LCLINT) test2.c - -hexconstants: - $(LCLINT) hexconstants.c -expect 1 - $(LCLINT) +checks hexconstants.c -expect 4 - -innercomment: - $(LCLINT) innercomment.c -expect 2 +forcehints - $(LCLINT) innercomment.c -nestcomment - -nothing: - $(LCLINT) nothing.c - -offsetof: - $(LCLINT) offsetof.c -expect 2 - -komazi: - $(LCLINT) komazi.c - -print: - $(LCLINT) print.c - -syslog: - $(LCLINT) syslog.c -warnunixlib +unixlib - -#error: -# $(LCLINT) error.c -expect 1 - -ulrich: - $(LCLINT) ulrich.c -expect 1 - -cpptest: - $(LCLINT) cpptest.c '-D__P(x)=x' -expect 1 - -longlong: - $(LCLINT) longlong.c -expect 4 - -subdir: - $(LCLINT) subdir/main.c subdir/main.lcl - -fink: - $(LCLINT) fink.c - -driverstub: - $(LCLINT) driverstub.c - -alignof: - $(LCLINT) alignof.c -expect 2 - -source: - $(LCLINT) -D DBL_MANT_DIG=25 source.c diff --git a/test/tests2.4/Makefile.os2 b/test/tests2.4/Makefile.os2 new file mode 100644 index 0000000..ac093cd --- /dev/null +++ b/test/tests2.4/Makefile.os2 @@ -0,0 +1,89 @@ +.PHONY: emptycase enumtest duffs bitfields bugs tests hexconstants innercomment nothing offsetof komazi print syslog error ulrich cpptest longlong subdir fink driverstub alignof source emptycase enumtest duffs bitfields bugs tests hexconstants innercomment nothing offsetof komazi print syslog error ulrich cpptest longlong subdir fink driverstub alignof source + +SPLINT = splint + +all: check + +check: emptycase enumtest duffs bitfields bugs tests hexconstants innercomment nothing offsetof komazi print syslog error ulrich cpptest longlong subdir fink alignof source + +emptycase: + $(SPLINT) emptycase.c + +enumtest: + $(SPLINT) enumtest.c -expect 2 + +duffs: + $(SPLINT) duffs.c -expect 7 + +bitfields: + $(SPLINT) bitfields.c + +bugs: + $(SPLINT) bug1.c + $(SPLINT) bug2.c -expect 5 + $(SPLINT) bug3.c -expect 3 + +tests: + $(SPLINT) test0.c + $(SPLINT) test1.c + $(SPLINT) test2.c + +hexconstants: + $(SPLINT) hexconstants.c -expect 1 + $(SPLINT) +checks hexconstants.c -expect 4 + +innercomment: + $(SPLINT) innercomment.c -expect 2 +forcehints + $(SPLINT) innercomment.c -nestcomment + +nothing: + $(SPLINT) nothing.c + +offsetof: + $(SPLINT) offsetof.c -expect 2 + +komazi: + $(SPLINT) komazi.c + +print: + $(SPLINT) print.c + +syslog: + $(SPLINT) syslog.c +unixlib + +error: + $(SPLINT) error.c -expect 1 + +ulrich: + $(SPLINT) ulrich.c -expect 1 + +cpptest: + $(SPLINT) cpptest.c '-D__P(x)=x' -expect 1 + +longlong: + $(SPLINT) longlong.c -expect 4 + +subdir: + $(SPLINT) subdir/main.c subdir/main.lcl + +fink: + $(SPLINT) fink.c + +# Herbert: don't test this, since splint is installed in /usr on my box +driverstub: + $(SPLINT) driverstub.c -sysdirs "/usr/" + +alignof: + $(SPLINT) alignof.c -expect 2 + +source: + $(SPLINT) -D DBL_MANT_DIG=25 source.c -expect 1 + + + + + + + + +