[BACK]Return to magic-load.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / file

Diff for /src/usr.bin/file/magic-load.c between version 1.8 and 1.9

version 1.8, 2015/08/11 21:52:14 version 1.9, 2015/08/11 22:02:40
Line 784 
Line 784 
         ml->test_unsigned = 0;          ml->test_unsigned = 0;
         ml->test_signed = 0;          ml->test_signed = 0;
   
           if (**line == '\0')
                   return (0);
   
         s = *line;          s = *line;
         if (s[0] == 'x' && (s[1] == '\0' || isspace((u_char)s[1]))) {          if (s[0] == 'x' && (s[1] == '\0' || isspace((u_char)s[1]))) {
                 (*line)++;                  (*line)++;
Line 818 
Line 821 
                 break;                  break;
         }          }
   
         copy = s = cp = xmalloc(strlen(*line) + 1);          while (isspace((u_char)**line))
         if ((*line)[0] == '=' && (*line)[1] == ' ') {                  (*line)++;
                 /*          if ((*line)[0] == '<' && (*line)[1] == '=') {
                  * Extra spaces such as "byte&7 = 0" are accepted, which is                  ml->test_operator = '[';
                  * annoying. But it seems to be only for =, so special case it.  
                  */  
                 *cp++ = '=';  
                 (*line) += 2;                  (*line) += 2;
           } else if ((*line)[0] == '>' && (*line)[1] == '=') {
                   ml->test_operator = ']';
                   (*line) += 2;
           } else if (strchr("=<>&^", **line) != NULL) {
                   ml->test_operator = **line;
                   (*line)++;
         }          }
   
           while (isspace((u_char)**line))
                   (*line)++;
           copy = cp = xmalloc(strlen(*line) + 1);
         while (**line != '\0' && !isspace((u_char)**line))          while (**line != '\0' && !isspace((u_char)**line))
                 *cp++ = *(*line)++;                  *cp++ = *(*line)++;
         *cp = '\0';          *cp = '\0';
   
         if (*s == '\0')  
                 goto done;  
   
         if (s[0] == '<' && s[1] == '=') {  
                 ml->test_operator = '[';  
                 s += 2;  
         } else if (s[0] == '>' && s[1] == '=') {  
                 ml->test_operator = ']';  
                 s += 2;  
         } else if (strchr("=<>&^", *s) != NULL) {  
                 ml->test_operator = *s;  
                 s++;  
         }  
   
         if (*ml->type_string == 'u')          if (*ml->type_string == 'u')
                 endptr = magic_strtoull(s, &ml->test_unsigned);                  endptr = magic_strtoull(copy, &ml->test_unsigned);
         else          else
                 endptr = magic_strtoll(s, &ml->test_signed);                  endptr = magic_strtoll(copy, &ml->test_signed);
         if (endptr == NULL || *endptr != '\0') {          if (endptr == NULL || *endptr != '\0') {
                 magic_warn(ml, "can't parse number: %s", s);                  magic_warn(ml, "can't parse number: %s", copy);
                 goto fail;                  goto fail;
         }          }
   
 done:  
         free(copy);          free(copy);
         return (0);          return (0);
   

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9