/[anubis]/anubis/src/misc.c
ViewVC logotype

Diff of /anubis/src/misc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by gray, Fri Feb 28 15:28:20 2003 UTC revision 1.6 by polak, Fri May 2 20:36:01 2003 UTC
# Line 201  remcrlf(char *s) Line 201  remcrlf(char *s)
201   Substitutions (RE back-references)   Substitutions (RE back-references)
202  ************************************/  ************************************/
203    
204  char *  static char *
 substitute(char *inbuf, char **subbuf)  
 {  
         char **tmp = subbuf;  
         char *tmpout = 0;  
         char *tmpbuf = 0;  
         char sign[5];  
         int i = 0;  
   
         if (inbuf == 0 || subbuf == 0)  
                 return 0;  
   
         tmpbuf = allocbuf(inbuf, 0);  
         tmp++;  
         while (*tmp)  
         {  
                 snprintf(sign, 4, "\\%d", i + 1);  
                 tmpout = insert(tmpbuf, sign, *tmp);  
                 if (tmpout) {  
                         tmpbuf = (char *)xrealloc((char *)tmpbuf, strlen(tmpout) + 1);  
                         strcpy(tmpbuf, tmpout);  
                         free(tmpout);  
                 }  
                 tmp++;  
                 i++;  
         }  
         return tmpbuf;  
 }  
   
 char *  
205  insert(char *inbuf, char *sign, char *fill_in)  insert(char *inbuf, char *sign, char *fill_in)
206  {  {
207          int len1 = 0;          int len1 = 0;
# Line 271  insert(char *inbuf, char *sign, char *fi Line 242  insert(char *inbuf, char *sign, char *fi
242          return outbuf;          return outbuf;
243  }  }
244    
245    char *
246    substitute(char *inbuf, char **subbuf)
247    {
248            char **tmp = subbuf;
249            char *tmpout = 0;
250            char *tmpbuf = 0;
251            char sign[5];
252            int i = 0;
253    
254            if (inbuf == 0 || subbuf == 0)
255                    return 0;
256    
257            tmpbuf = allocbuf(inbuf, 0);
258            tmp++;
259            while (*tmp)
260            {
261                    snprintf(sign, 4, "\\%d", i + 1);
262                    tmpout = insert(tmpbuf, sign, *tmp);
263                    if (tmpout) {
264                            tmpbuf = (char *)xrealloc((char *)tmpbuf, strlen(tmpout) + 1);
265                            strcpy(tmpbuf, tmpout);
266                            free(tmpout);
267                    }
268                    tmp++;
269                    i++;
270            }
271            return tmpbuf;
272    }
273    
274  /***************************  /***************************
275   change to lower characters   Change to lower characters
276  ****************************/  ****************************/
277    
278  void  void

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26