lib/subText.c File Reference

#include "common.h"
#include "subText.h"

Include dependency graph for subText.c:

Go to the source code of this file.

Functions

subTextsubTextNew (char *in, char *out)
void subTextFree (struct subText **pSub)
void subTextFreeList (struct subText **pList)
static struct subTextfirstInList (struct subText *l, char *name)
int subTextSizeAfter (struct subText *subList, char *in)
static void doSub (char *in, char *buf, struct subText *subList)
void subTextStatic (struct subText *subList, char *in, char *out, int outMaxSize)
char * subTextString (struct subText *subList, char *in)

Variables

static char const rcsid [] = "$Id: subText.c,v 1.11 2005/04/10 14:41:26 markd Exp $"


Function Documentation

static void doSub ( char *  in,
char *  buf,
struct subText subList 
) [static]

Definition at line 110 of file subText.c.

References firstInList(), subText::inSize, subText::out, and subText::outSize.

Referenced by subTextStatic(), and subTextString().

00113 {
00114 struct subText *sub;
00115 char *s, *d;
00116 
00117 s = in;
00118 d = buf;
00119 while (*s)
00120     {
00121     if ((sub = firstInList(subList, s)) != NULL)
00122         {
00123         s += sub->inSize;
00124         memcpy(d, sub->out, sub->outSize);
00125         d += strlen(sub->out);
00126         }
00127     else
00128         {
00129         *d++ = *s++;
00130         }
00131     }
00132 *d++ = 0;
00133 }

Here is the call graph for this function:

Here is the caller graph for this function:

static struct subText* firstInList ( struct subText l,
char *  name 
) [static, read]

Definition at line 62 of file subText.c.

References subText::in, subText::inSize, and subText::next.

Referenced by doSub(), and subTextSizeAfter().

00065 {
00066 struct subText *text = l;
00067 char *start;
00068 char *end;
00069 char *cmp;
00070 
00071 for(; text; text = text->next)
00072     {
00073     start = text->in;
00074     end = &start[text->inSize];
00075     cmp = name;
00076     for(;(start < end) && (*start == *cmp); start++, cmp++)
00077         ;
00078     if (start == end)
00079         return text;
00080     }
00081 return NULL;
00082 }

Here is the caller graph for this function:

void subTextFree ( struct subText **  pSub  ) 

Definition at line 23 of file subText.c.

References freeMem(), freez(), subText::in, and subText::out.

Referenced by subTextFreeList().

00025 {
00026 struct subText *sub = *pSub;
00027 if (sub != NULL)
00028     {
00029     freeMem(sub->in);
00030     freeMem(sub->out);
00031     freez(pSub);
00032     }
00033 }

Here is the call graph for this function:

Here is the caller graph for this function:

void subTextFreeList ( struct subText **  pList  ) 

Definition at line 35 of file subText.c.

References subText::next, and subTextFree().

00037 {
00038 struct subText *el, *next;
00039 
00040 for (el = *pList; el != NULL; el = next)
00041     {
00042     next = el->next;
00043     subTextFree(&el);
00044     }
00045 *pList = NULL;
00046 }

Here is the call graph for this function:

struct subText* subTextNew ( char *  in,
char *  out 
) [read]

Definition at line 11 of file subText.c.

References AllocVar, cloneString(), subText::in, subText::inSize, subText::out, and subText::outSize.

00013 {
00014 struct subText *sub;
00015 AllocVar(sub);
00016 sub->in = cloneString(in);
00017 sub->out = cloneString(out);
00018 sub->inSize = strlen(in);
00019 sub->outSize = strlen(out);
00020 return sub;
00021 }

Here is the call graph for this function:

int subTextSizeAfter ( struct subText subList,
char *  in 
)

Definition at line 85 of file subText.c.

References firstInList(), subText::inSize, and subText::outSize.

Referenced by subTextStatic(), and subTextString().

00087 {
00088 struct subText *sub;
00089 char *s;
00090 int size = 0;
00091 
00092 s = in;
00093 while (*s)
00094     {
00095     if ((sub = firstInList(subList, s)) != NULL)
00096         {
00097         s += sub->inSize;
00098         size += sub->outSize;
00099         }
00100     else
00101         {
00102         size += 1;
00103         s += 1;
00104         }
00105     }
00106 return size;
00107 }

Here is the call graph for this function:

Here is the caller graph for this function:

void subTextStatic ( struct subText subList,
char *  in,
char *  out,
int  outMaxSize 
)

Definition at line 135 of file subText.c.

References doSub(), errAbort(), and subTextSizeAfter().

00138 {
00139 int newSize = subTextSizeAfter(subList, in);
00140 if (newSize >= outMaxSize)
00141     errAbort("%s would expand to more than %d bytes", in, outMaxSize);
00142 doSub(in, out, subList);
00143 }

Here is the call graph for this function:

char* subTextString ( struct subText subList,
char *  in 
)

Definition at line 145 of file subText.c.

References doSub(), needMem(), subText::out, and subTextSizeAfter().

00148 {
00149 int size = subTextSizeAfter(subList, in);
00150 char *out = needMem(size+1);
00151 doSub(in, out, subList);
00152 return out;
00153 }

Here is the call graph for this function:


Variable Documentation

char const rcsid[] = "$Id: subText.c,v 1.11 2005/04/10 14:41:26 markd Exp $" [static]

Definition at line 9 of file subText.c.


Generated on Tue Dec 25 20:18:38 2007 for blat by  doxygen 1.5.2