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

Diff for /src/usr.bin/tip/Attic/value.c between version 1.20 and 1.21

version 1.20, 2010/06/29 20:57:33 version 1.21, 2010/06/29 21:34:50
Line 54 
Line 54 
         FILE *fp;          FILE *fp;
   
         for (p = vtable; p->v_name != NULL; p++) {          for (p = vtable; p->v_name != NULL; p++) {
                 if (p->v_type&ENVIRON)                  if (p->v_flags & V_ENVIRON)
                         if ((cp = getenv(p->v_name)))                          if ((cp = getenv(p->v_name)))
                                 p->v_value = cp;                                  p->v_value = cp;
                 if (p->v_type&IREMOTE)                  if (p->v_flags & V_IREMOTE)
                         setnumber(p->v_value, *address(p->v_value));                          setnumber(p->v_value, *address(p->v_value));
         }          }
         /*          /*
Line 88 
Line 88 
 static void  static void
 vassign(value_t *p, char *v)  vassign(value_t *p, char *v)
 {  {
         if (p->v_access & READONLY) {          if (p->v_flags & V_READONLY) {
                 printf("access denied\r\n");                  printf("access denied\r\n");
                 return;                  return;
         }          }
   
         switch (p->v_type&TMASK) {          switch (p->v_flags & V_TYPEMASK) {
         case STRING:          case V_STRING:
                 if (p->v_value && strcmp(p->v_value, v) == 0)                  if (p->v_value && strcmp(p->v_value, v) == 0)
                         return;                          return;
                 if (!(p->v_type&(ENVIRON|INIT)))                  if (!(p->v_flags & (V_ENVIRON|V_INIT)))
                         free(p->v_value);                          free(p->v_value);
                 if ((p->v_value = strdup(v)) == NULL) {                  if ((p->v_value = strdup(v)) == NULL) {
                         printf("out of core\r\n");                          printf("out of core\r\n");
                         return;                          return;
                 }                  }
                 p->v_type &= ~(ENVIRON|INIT);                  p->v_flags &= ~(V_ENVIRON|V_INIT);
                 break;                  break;
         case NUMBER:          case V_NUMBER:
                 if (number(p->v_value) == number(v))                  if (number(p->v_value) == number(v))
                         return;                          return;
                 setnumber(p->v_value, number(v));                  setnumber(p->v_value, number(v));
                 break;                  break;
         case BOOL:          case V_BOOL:
                 if (boolean(p->v_value) == (*v != '!'))                  if (boolean(p->v_value) == (*v != '!'))
                         return;                          return;
                 setboolean(p->v_value, (*v != '!'));                  setboolean(p->v_value, (*v != '!'));
                 break;                  break;
         case CHAR:          case V_CHAR:
                 if (character(p->v_value) == *v)                  if (character(p->v_value) == *v)
                         return;                          return;
                 setcharacter(p->v_value, *v);                  setcharacter(p->v_value, *v);
         }          }
         p->v_access |= CHANGED;          p->v_flags |= V_CHANGED;
 }  }
   
 void  void
Line 156 
Line 156 
                 *cp = '\0';                  *cp = '\0';
                 if ((p = vlookup(s))) {                  if ((p = vlookup(s))) {
                         cp++;                          cp++;
                         if (p->v_type&NUMBER)                          if ((p->v_flags & V_TYPEMASK) == V_NUMBER)
                                 vassign(p, (char *)atoi(cp));                                  vassign(p, (char *)atoi(cp));
                         else {                          else {
                                 if (strcmp(s, "record") == 0)                                  if (strcmp(s, "record") == 0)
Line 193 
Line 193 
                 while (col++ < MIDDLE)                  while (col++ < MIDDLE)
                         putchar(' ');                          putchar(' ');
         col += size(p->v_name);          col += size(p->v_name);
         switch (p->v_type&TMASK) {          switch (p->v_flags & V_TYPEMASK) {
   
         case BOOL:          case V_BOOL:
                 if (boolean(p->v_value) == FALSE) {                  if (!boolean(p->v_value)) {
                         col++;                          col++;
                         putchar('!');                          putchar('!');
                 }                  }
                 printf("%s", p->v_name);                  printf("%s", p->v_name);
                 break;                  break;
   
         case STRING:          case V_STRING:
                 printf("%s=", p->v_name);                  printf("%s=", p->v_name);
                 col++;                  col++;
                 if (p->v_value) {                  if (p->v_value) {
Line 213 
Line 213 
                 }                  }
                 break;                  break;
   
         case NUMBER:          case V_NUMBER:
                 col += 6;                  col += 6;
                 printf("%s=%-5ld", p->v_name, number(p->v_value));                  printf("%s=%-5ld", p->v_name, number(p->v_value));
                 break;                  break;
   
         case CHAR:          case V_CHAR:
                 printf("%s=", p->v_name);                  printf("%s=", p->v_name);
                 col++;                  col++;
                 if (p->v_value) {                  if (p->v_value) {
Line 240 
Line 240 
 {  {
         value_t *p;          value_t *p;
   
         for (p = vtable; p->v_name; p++)          for (p = vtable; p->v_name; p++) {
                 if (strcmp(p->v_name, s) == 0 ||                  if (strcmp(p->v_name, s) == 0 ||
                     (p->v_abrev && strcmp(p->v_abrev, s) == 0))                      (p->v_abbrev && strcmp(p->v_abbrev, s) == 0))
                         return (p);                          return (p);
           }
         return (NULL);          return (NULL);
 }  }
   
Line 310 
Line 311 
         p = vlookup(s);          p = vlookup(s);
         if (p == 0)          if (p == 0)
                 return (1);                  return (1);
         if (p->v_type&NUMBER)          if ((p->v_flags & V_TYPEMASK) == V_NUMBER)
                 vassign(p, (char *)atoi(v));                  vassign(p, (char *)atoi(v));
         else {          else {
                 if (strcmp(s, "record") == 0)                  if (strcmp(s, "record") == 0)

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21