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

Diff for /src/usr.bin/tput/tput.c between version 1.8 and 1.9

version 1.8, 1999/06/29 19:39:40 version 1.9, 1999/07/02 16:00:13
Line 89 
Line 89 
 static void   init __P((void));  static void   init __P((void));
 static char **process __P((char *, char *, char **));  static char **process __P((char *, char *, char **));
 static void   reset __P((void));  static void   reset __P((void));
   static void   set_margins __P((void));
 static void   usage __P((void));  static void   usage __P((void));
   
 extern char  *__progname;  extern char  *__progname;
Line 294 
Line 295 
         FILE *ifile;          FILE *ifile;
         size_t len;          size_t len;
         char *buf;          char *buf;
         int waitinfo;          int wstatus;
   
         /* XXX - should we check for existence before exec()'ing? */  
         if (init_prog && !issetugid()) {          if (init_prog && !issetugid()) {
                 switch (vfork()) {                  switch (vfork()) {
                 case -1:                  case -1:
Line 308 
Line 308 
                         _exit(127);                          _exit(127);
                         break;                          break;
                 default:                  default:
                         wait(&waitinfo);                          wait(&wstatus);
                         /* XXX - interpret waitinfo? */                          /* parent */
                         break;                          break;
                 }                  }
         }          }
Line 317 
Line 317 
                 putp(init_1string);                  putp(init_1string);
         if (init_2string)          if (init_2string)
                 putp(init_2string);                  putp(init_2string);
           set_margins();
           /* always use 8 space tabs */
           if (init_tabs != 8 && clear_all_tabs && set_tab) {
                   int i;
   
                   putp(clear_all_tabs);
                   for (i = 0; i < (columns - 1) / 8; i++) {
                           if (parm_right_cursor)
                                   putp(tparm(parm_right_cursor, 8));
                           else
                                   fputs("        ", stdout);
                           putp(set_tab);
                   }
           }
         if (init_file && !issetugid() && (ifile = fopen(init_file, "r"))) {          if (init_file && !issetugid() && (ifile = fopen(init_file, "r"))) {
                 while ((buf = fgetln(ifile, &len)) != NULL) {                  while ((buf = fgetln(ifile, &len)) != NULL) {
                         if (buf[len-1] != '\n')                          if (buf[len-1] != '\n')
Line 328 
Line 342 
         }          }
         if (init_3string)          if (init_3string)
                 putp(init_3string);                  putp(init_3string);
         /* XXX - do tabs and margins */  
         fflush(stdout);          fflush(stdout);
 }  }
   
Line 343 
Line 356 
                 putp(reset_1string);                  putp(reset_1string);
         if (reset_2string)          if (reset_2string)
                 putp(reset_2string);                  putp(reset_2string);
         /* XXX - cat reset_file */          set_margins();
         if (reset_file && !issetugid() && (rfile = fopen(reset_file, "r"))) {          if (reset_file && !issetugid() && (rfile = fopen(reset_file, "r"))) {
                 while ((buf = fgetln(rfile, &len)) != NULL) {                  while ((buf = fgetln(rfile, &len)) != NULL) {
                         if (buf[len-1] != '\n')                          if (buf[len-1] != '\n')
Line 355 
Line 368 
         }          }
         if (reset_3string)          if (reset_3string)
                 putp(reset_3string);                  putp(reset_3string);
         /* XXX - do tabs and margins */          fflush(stdout);
   }
   
   static void
   set_margins()
   {
   
           /*
            * Four possibilities:
            *      1) we have set_lr_margin and can set things with one call
            *      2) we have set_{left,right}_margin_parm, use two calls
            *      3) we have set_{left,right}_margin, set based on position
            *      4) none of the above, leave things the way they are
            */
           if (set_lr_margin) {
                   putp(tparm(set_lr_margin, 0, columns - 1));
           } else if (set_left_margin_parm && set_right_margin_parm) {
                   putp(tparm(set_left_margin_parm, 0));
                   putp(tparm(set_right_margin_parm, columns - 1));
           } else if (set_left_margin && set_right_margin && clear_margins) {
                   putp(clear_margins);
   
                   /* go to column 0 and set the left margin */
                   putp(carriage_return ? carriage_return : "\r");
                   putp(set_left_margin);
   
                   /* go to last column and set the right margin */
                   if (parm_right_cursor)
                           putp(tparm(parm_right_cursor, columns - 1));
                   else
                           printf("%*s", columns - 1, " ");
                   putp(set_right_margin);
                   putp(carriage_return ? carriage_return : "\r");
           }
         fflush(stdout);          fflush(stdout);
 }  }
   

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