Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

message.c File Reference

#include "lclintMacros.nf"
#include "basic.h"

Go to the source code of this file.

Defines

#define GETPRINTF(s,v)    (sprintf (strbuf, s, v), mstring_copy (strbuf))

Enumerations

enum  ccode {
  XINVALID, XCHAR, XSTRING, XSTRINGFREE,
  XTSTRINGFREE, XINT, XFLOAT, XBOOL,
  XUENTRY, XPERCENT, XCTYPE, XPLURAL,
  XREPREFIX, XFILELOC
}

Functions

cstring message ( char *fmt, ...)


Define Documentation

#define GETPRINTF( s, v )   (sprintf (strbuf, s, v), mstring_copy (strbuf))
 

Definition at line 45 of file message.c.


Enumeration Type Documentation

enum ccode
 

Enumeration values:
XINVALID  
XCHAR  
XSTRING  
XSTRINGFREE  
XTSTRINGFREE  
XINT  
XFLOAT  
XBOOL  
XUENTRY  
XPERCENT  
XCTYPE  
XPLURAL  
XREPREFIX  
XFILELOC  

Definition at line 36 of file message.c.

00037 {
00038   XINVALID, 
00039   XCHAR, XSTRING, XSTRINGFREE, XTSTRINGFREE, XINT, XFLOAT, XBOOL, XUENTRY,
00040   XPERCENT, XCTYPE, XPLURAL, XREPREFIX, XFILELOC
00041 }


Function Documentation

cstring message ( char * fmt,
... )
 

Definition at line 141 of file message.c.

Referenced by YY_RULE_SETUP(), abstBodyNode_unparseExposed(), abstractNode_unparse(), aliasTable_checkGlobs(), aliasTable_unparse(), checkAnsiName(), checkCppName(), checkModifiesId(), checkParamNames(), checkPassTransfer(), checkPrefix(), checkReturnTransfer(), checkSpecClausesId(), checkValueConstant(), claimNode_unparse(), clauseStack_unparse(), coerceId(), computePossibleSorts(), constDeclarationNode_unparse(), context_getAliasAnnote(), context_setFilename(), context_setMode(), context_setString(), context_unparse(), context_unparseAccess(), context_userSetFlag(), cppGetToken(), cppReader_define(), cppReader_parseExpression(), cstringList_printSpaced(), cstringList_unparseAbbrev(), cstringList_unparseSep(), cstringSList_printSpaced(), cstringSList_unparseAbbrev(), cstringSList_unparseSep(), ctypeList_unparse(), ctype_dump(), ctype_unparseSafe(), declaratorInvNodeList_unparse(), declaratorInvNode_unparse(), declaratorNodeList_unparse(), declareStruct(), declareUnion(), declareUnnamedStruct(), declareUnnamedUnion(), describeFlag(), describeModes(), dicalloc(), dimalloc(), direalloc(), enumNameList_dump(), enumNameList_unparse(), enumNameList_unparseBrief(), enumSpecNode_unparse(), exportNode_unparse(), exposedNode_unparse(), exprChecks_checkEmptyMacroBody(), exprChecks_checkExport(), exprNodeList_unparse(), exprNodeSList_unparse(), exprNode_arrayFetch(), exprNode_arrowAccess(), exprNode_assign(), exprNode_break(), exprNode_cast(), exprNode_checkAllMods(), exprNode_checkFunctionBody(), exprNode_checkMacroBody(), exprNode_checkPred(), exprNode_checkStatement(), exprNode_comma(), exprNode_cond(), exprNode_fieldAccess(), exprNode_fromUIO(), exprNode_if(), exprNode_ifelse(), exprNode_iterExpr(), exprNode_iterId(), exprNode_postOp(), exprNode_preOp(), exprNode_sizeofExpr(), exprNode_vaArg(), exprNode_while(), fakeTag(), fcnNodeList_unparse(), fcnNode_unparse(), fileTable_getName(), fileTable_unparse(), filelocList_unparse(), filelocList_unparseUses(), filelocStack_unparse(), fileloc_unparse(), fileloc_unparseDirect(), fileloc_unparseFilename(), fileloc_unparseRaw(), fileloc_unparseRawCol(), fixModifiesId(), fixSpecClausesId(), fixTagName(), flagMarkerList_unparse(), flagMarker_unparse(), globListUnrecognized(), guardSet_unparse(), hashTable_stats(), idDeclList_unparse(), idDecl_unparse(), importCTrait(), importNodeList_unparse(), initDeclNodeList_unparse(), intSet_unparse(), intSet_unparseText(), interfaceNode_unparse(), iterNode_unparse(), lclTypeSpecNode_unparseComments(), lcllib_isSkipHeader(), letDeclNodeList_unparse(), lhFunction(), lhType(), lhVarDecl(), llparseerror(), lslOpList_unparse(), lslOpSet_unparse(), lsymbolSet_unparse(), ltokenList_unparse(), ltoken_unparseLoc(), macrocache_unparse(), main(), makeConstDeclarationNode(), makeSimpleTermNode(), messageLog_unparse(), modListArrowAccess(), modListFieldAccess(), modListPointer(), modifyNode_unparse(), multiVal_dump(), multiVal_unparse(), o_fctInfo(), opFormNode_unparse(), pairNodeList_unparse(), paramNodeList_unparse(), paramNodeList_unparseComments(), paramNode_unparse(), paramNode_unparseComments(), parseSignatures(), printRawLeaves2(), processImport(), processNamedDecl(), programNodeList_unparse(), programNode_unparse(), qtype_unparse(), qualList_toCComments(), qualList_unparse(), quantifierNodeList_unparse(), renamingNode_unparse(), replaceNodeList_unparse(), replaceNode_unparse(), sRefSet_unparse(), sRefSet_unparseDebug(), sRefSet_unparsePlain(), sRefSet_unparseUnconstrained(), sRefSet_unparseUnconstrainedPlain(), sRefTable_unparse(), sRef_dump(), sRef_dumpGlobal(), sRef_showAliasInfo(), sRef_showNotReallyDefined(), sRef_showNullInfo(), sRef_showStateInconsistent(), sRef_showStateInfo(), sRef_unparseDebug(), sRef_unparseDeep(), sRef_unparseFull(), sRef_unparseState(), sigNodeSet_unparse(), sigNodeSet_unparseSomeSigs(), sigNode_unparse(), sigNode_unparseText(), signNode_unparse(), sortList_unparse(), sortSetList_unparse(), sortSet_unparse(), sortSet_unparseClean(), sortSet_unparseOr(), sort_import(), sort_unparse(), specialClause_unparse(), specialClause_unparseKind(), specialClauses_add(), specialClauses_checkAll(), specialClauses_checkEqual(), specialClauses_dump(), specialClauses_unparse(), stDeclNodeList_unparse(), stmtNode_unparse(), storeRefNodeList_unparse(), strOrUnionNode_unparse(), symtable_import(), taggedUnionNode_unparse(), termNodeList_unparse(), termNodeList_unparseSecondToCurrent(), termNodeList_unparseTail(), termNodeList_unparseToCurrent(), termNode_unparse(), traitRefNodeList_unparse(), typeExpr_unparse(), typeExpr_unparseNoBase(), typeIdSet_dump(), typeNameNodeList_unparse(), typeNameNode_unparse(), uentryList_dumpFields(), uentryList_dumpParams(), uentryList_mergeFields(), uentryList_showFieldDifference(), uentryList_unparse(), uentryList_unparseAbbrev(), uentryList_unparseFull(), uentryList_unparseParams(), uentry_checkMatchParam(), uentry_checkParams(), uentry_makeIdFunction(), uentry_mergeConstantValue(), uentry_mergeDefinition(), uentry_mergeEntries(), uentry_mergeState(), uentry_reflectQualifiers(), uentry_setModifies(), uentry_setStatic(), uentry_setUsed(), uentry_unparseAbbrev(), uentry_unparseFull(), argdata::use_count(), usymIdSet_dump(), usymIdSet_unparse(), usymtab_allDefined(), usymtab_allUsed(), usymtab_checkFinalScope(), usymtab_exportHeader(), usymtab_exportLocal(), usymtab_getTypeEntryName(), varDeclarationNodeList_unparse(), varDeclarationNode_unparse(), and varNodeList_unparse().

00143 {
00144   char c;
00145   int lastint = 0;
00146   char *ret = mstring_createEmpty ();
00147   char *ofmt = fmt;
00148   va_list pvar;
00149 
00150 # if USEVARARGS
00151   va_start (pvar);
00152 # else
00153   va_start (pvar, fmt);
00154 # endif  
00155 
00156   while ((c = *fmt++) != '\0')
00157     {
00158       if (c == '%')
00159         {
00160           /*@-loopswitchbreak@*/
00161 
00162           switch (identify_control (&fmt))
00163             {
00164             case XPERCENT:
00165               {
00166                 ret = mstring_concatFree1 (ret, "%");
00167                 break;
00168               }
00169             case XCHAR:
00170               {
00171                 /*
00172                 ** some systems don't handle char va_arg correctly, so it must be
00173                 ** passed as an int here
00174                 */
00175 
00176                 char lc = (char) va_arg (pvar, int);
00177 
00178                 ret = mstring_append (ret, lc);
00179                 break;
00180               }
00181             case XSTRING:
00182               {
00183                 cstring s = va_arg (pvar, cstring);
00184                 
00185                 if (modcode != 0)
00186                   {
00187                     ret = mstring_concatFree (ret, cstring_toCharsSafe 
00188                                           (cstring_fill (s, modcode)));
00189                   }
00190                 else
00191                   {
00192                     if (cstring_isDefined (s))
00193                       {
00194                         ret = mstring_concatFree1 (ret, cstring_toCharsSafe (s));
00195                       }
00196                   }
00197               }
00198               break;
00199             case XSTRINGFREE:
00200             case XTSTRINGFREE:
00201               {
00202                 cstring s = va_arg (pvar, cstring);
00203                 
00204                 if (modcode != 0)
00205                   {
00206                     ret = mstring_concatFree (ret, cstring_toCharsSafe 
00207                                               (cstring_fill (s, modcode)));
00208                   }
00209                 else
00210                   {
00211                     if (cstring_isDefined (s))
00212                       {
00213                         ret = mstring_concatFree 
00214                           (ret, cstring_toCharsSafe (s));
00215                       }
00216                   }
00217               }
00218               break;
00219             case XREPREFIX:
00220               lastint = va_arg (pvar, int);
00221 
00222               if (lastint != 0)
00223                 {
00224                   ret = mstring_concatFree1 (ret, "re");
00225                 }
00226               break;
00227             case XPLURAL:
00228               if (lastint != 1)
00229                 {
00230                   ret = mstring_concatFree1 (ret, "s");
00231                 }
00232               break;
00233             case XINT:
00234               lastint = va_arg (pvar, int);
00235               ret = mstring_concatFree (ret, GETPRINTF ("%d", lastint));
00236               break;
00237             case XFLOAT:
00238               ret = mstring_concatFree (ret, GETPRINTF ("%e", va_arg (pvar, double)));
00239               break;
00240             case XBOOL:
00241               ret = mstring_concatFree1 (ret, cstring_toCharsSafe 
00242                                     (bool_unparse (va_arg (pvar, bool))));
00243               break;
00244             case XUENTRY:
00245               ret = mstring_concatFree (ret, cstring_toCharsSafe 
00246                                    (uentry_unparse (va_arg (pvar, uentry))));
00247               break;
00248             case XCTYPE:
00249               /* cannot free ctype_unparse */
00250               ret = mstring_concatFree1 (ret, cstring_toCharsSafe 
00251                                    (ctype_unparse (va_arg (pvar, ctype)))); 
00252               break;
00253             case XFILELOC:
00254               ret = mstring_concatFree (ret, cstring_toCharsSafe 
00255                                    (fileloc_unparse (va_arg (pvar, fileloc))));
00256               break;
00257             case XINVALID:
00258             default:
00259               llcontbug (cstring_makeLiteral ("message: bad control flag"));
00260               fprintf (stdout, "\tFormat string: %s", ofmt);
00261             }
00262           /*@=loopswitchbreak@*/
00263         }
00264       else
00265         {
00266           ret = mstring_append (ret, c);
00267         }
00268     }
00269 
00270   va_end (pvar);
00271 
00272   /*
00273   ** cstring_fromChars returns the same storage (exposed)
00274   */
00275 
00276   /*@-mustfree@*/ return (cstring_fromChars (ret)); /*@=mustfree@*/
00277 }


Generated at Fri Nov 3 18:58:03 2000 for LCLint by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000