[BACK]Return to str.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Diff for /src/usr.bin/make/str.c between version 1.6 and 1.7

version 1.6, 1998/03/07 18:34:50 version 1.7, 1998/12/05 00:06:29
Line 49 
Line 49 
   
 #include "make.h"  #include "make.h"
   
 static char **argv, *buffer;  
 static int argmax, curlen;  
   
 /*  
  * str_init --  
  *      Initialize the strings package  
  *  
  */  
 void  
 str_init()  
 {  
     char *p1;  
     argv = (char **)emalloc(((argmax = 50) + 1) * sizeof(char *));  
     argv[0] = Var_Value(".MAKE", VAR_GLOBAL, &p1);  
 }  
   
   
 /*  
  * str_end --  
  *      Cleanup the strings package  
  *  
  */  
 void  
 str_end()  
 {  
     if (argv) {  
         if (argv[0])  
             free(argv[0]);  
         free((Address) argv);  
     }  
     if (buffer)  
         free(buffer);  
 }  
   
 /*-  /*-
  * str_concat --   * str_concat --
  *      concatenate the two strings, inserting a space or slash between them,   *      concatenate the two strings, inserting a space or slash between them,
Line 140 
Line 106 
  *      the first word is always the value of the .MAKE variable.   *      the first word is always the value of the .MAKE variable.
  */   */
 char **  char **
 brk_string(str, store_argc, expand)  brk_string(str, store_argc, expand, buffer)
         register char *str;          register char *str;
         int *store_argc;          int *store_argc;
         Boolean expand;          Boolean expand;
           char **buffer;
 {  {
         register int argc, ch;          register int argc, ch;
         register char inquote, *p, *start, *t;          register char inquote, *p, *start, *t;
         int len;          int len;
           int argmax = 50, curlen = 0;
           char **argv = (char **)emalloc((argmax + 1) * sizeof(char *));
   
         /* skip leading space chars. */          /* skip leading space chars. */
         for (; *str == ' ' || *str == '\t'; ++str)          for (; *str == ' ' || *str == '\t'; ++str)
                 continue;                  continue;
   
         /* allocate room for a copy of the string */          /* allocate room for a copy of the string */
         if ((len = strlen(str) + 1) > curlen) {          if ((len = strlen(str) + 1) > curlen)
                 if (buffer)                  *buffer = emalloc(curlen = len);
                     free(buffer);  
                 buffer = emalloc(curlen = len);  
         }  
   
         /*          /*
          * copy the string; at the same time, parse backslashes,           * copy the string; at the same time, parse backslashes,
          * quotes and build the argument list.           * quotes and build the argument list.
          */           */
         argc = 1;          argc = 0;
         inquote = '\0';          inquote = '\0';
         for (p = str, start = t = buffer;; ++p) {          for (p = str, start = t = *buffer;; ++p) {
                 switch(ch = *p) {                  switch(ch = *p) {
                 case '"':                  case '"':
                 case '\'':                  case '\'':

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