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

cstringSList.c File Reference

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

Go to the source code of this file.

Functions

cstringSList cstringSList_new ()
cstringSList cstringSList_single ( cstring el)
cstringSList cstringSList_add (cstringSList s, cstring el)
cstring cstringSList_unparse (cstringSList s)
cstring cstringSList_unparseSep (cstringSList s, cstring sep)
void cstringSList_printSpaced (cstringSList s, int indent, int gap, int linelen)
cstring cstringSList_unparseAbbrev (cstringSList s)
void cstringSList_free (cstringSList s)
void cstringSList_alphabetize (cstringSList s)


Function Documentation

cstringSList cstringSList_add ( cstringSList s,
cstring el )
 

Definition at line 86 of file cstringSList.c.

Referenced by cstringSList_single(), and main().

00087 {
00088   if (!cstringSList_isDefined (s))
00089     {
00090       s = cstringSList_newEmpty ();
00091     }
00092 
00093   if (s->nspace <= 0)
00094     {
00095       cstringSList_grow (s);
00096     }
00097   
00098   s->nspace--;
00099   s->elements[s->nelements] = el;
00100   s->nelements++;
00101 
00102   return s;
00103 }

void cstringSList_alphabetize ( cstringSList s )
 

Definition at line 242 of file cstringSList.c.

00243 {
00244   if (cstringSList_isDefined (s))
00245     {
00246       /*@-modobserver@*/
00247       qsort (s->elements, (size_t) s->nelements, 
00248              sizeof (*s->elements), (int (*)(const void *, const void *)) cstring_xcompare);
00249       /*@=modobserver@*/
00250     }
00251 }

void cstringSList_free ( cstringSList s )
 

Definition at line 223 of file cstringSList.c.

Referenced by describeModes(), main(), printAllFlags(), and printAlphaFlags().

00224 {
00225   if (cstringSList_isDefined (s))
00226     {
00227       /*
00228       ** A modification of observer message is reported here, since
00229       ** *s->elements is an observer.  But sfree doesn't REALLY modify
00230       ** the value of this object.
00231       */
00232 
00233       /*@-modobserver@*/ 
00234       sfree (s->elements);
00235       /*@=modobserver@*/
00236 
00237       sfree (s);
00238     }
00239 }

cstringSList cstringSList_new ( )
 

Definition at line 36 of file cstringSList.c.

Referenced by cstringSList_single().

00037 {
00038   return cstringSList_undefined;
00039 }

void cstringSList_printSpaced ( cstringSList s,
int indent,
int gap,
int linelen )
 

Definition at line 135 of file cstringSList.c.

Referenced by printAlphaFlags().

00136 {
00137   if (cstringSList_isDefined (s))
00138     {
00139       cstring line = cstring_undefined;
00140       cstring istring = cstring_fill (cstring_undefined, indent);
00141       cstring gstring = cstring_fill (cstring_undefined, gap);
00142       int numcol;
00143       int longest = 0;
00144       int i;
00145  
00146       /*
00147       ** find the longest string
00148       */
00149 
00150       for (i = 0; i < s->nelements; i++)
00151         {
00152           int len = cstring_length (s->elements[i]);
00153 
00154           if (len > longest)
00155             {
00156               longest = len;
00157             }
00158         }
00159 
00160       numcol = (linelen - indent) / (longest + gap);
00161       
00162       if (numcol <= 1) 
00163         {
00164           numcol = 1;
00165         }
00166 
00167       for (i = 0; i < s->nelements; i++)
00168         {
00169           if (i % numcol == 0)
00170             {
00171               if (i != 0)
00172                 {
00173                   llmsg (line);
00174                 }
00175               
00176               line = message ("%s%q", istring,
00177                               cstring_fill (s->elements[i], longest));
00178             }
00179           else
00180             {
00181               line = message ("%q%s%q", line, gstring, 
00182                               cstring_fill (s->elements[i], longest));
00183             }
00184         }
00185 
00186       cstring_free (line);
00187       cstring_free (istring);
00188       cstring_free (gstring);
00189     }
00190 }

cstringSList cstringSList_single ( cstring el )
 

Definition at line 79 of file cstringSList.c.

00080 {
00081   cstringSList s = cstringSList_new ();
00082   s = cstringSList_add (s, el);
00083   return s;
00084 }

cstring cstringSList_unparse ( cstringSList s )
 

Definition at line 106 of file cstringSList.c.

00107 {
00108   return cstringSList_unparseSep (s, cstring_makeLiteralTemp (", "));
00109 }

cstring cstringSList_unparseAbbrev ( cstringSList s )
 

Definition at line 193 of file cstringSList.c.

00194 {
00195    cstring st = cstring_undefined;
00196 
00197    if (cstringSList_isDefined (s))
00198      {
00199        int i;
00200        
00201        for (i = 0; i < s->nelements; i++)
00202          {
00203            if (i == 0)
00204              {
00205                st = cstring_copy (s->elements[i]);
00206              }
00207            else if (i > 3 && s->nelements > 5)
00208              {
00209                st = message ("%q, ...", st);
00210                break;
00211              }
00212            else
00213              {
00214                st = message ("%q, %s", st, s->elements[i]);
00215              }
00216          }
00217      }
00218 
00219    return st;
00220 }

cstring cstringSList_unparseSep ( cstringSList s,
cstring sep )
 

Definition at line 112 of file cstringSList.c.

Referenced by cstringSList_unparse().

00113 {
00114    cstring st = cstring_undefined;
00115 
00116    if (cstringSList_isDefined (s))
00117      {
00118        int i;
00119 
00120        for (i = 0; i < s->nelements; i++)
00121          {
00122            if (i == 0)
00123              {
00124                st = cstring_copy (s->elements[i]);
00125              }
00126            else
00127              st = message ("%q%s%s", st, sep, s->elements[i]);
00128          }
00129      }
00130 
00131    return st;
00132 }


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