Exemplo n.º 1
0
struct bwb_line *
bwb_edit( struct bwb_line *l )
   {
   char tbuf[ MAXSTRINGSIZE + 1 ];
   char edname[ MAXSTRINGSIZE + 1 ];
   struct bwb_variable *ed;
   FILE *loadfile;

   ed = var_find( DEFVNAME_EDITOR );
   str_btoc( edname, var_getsval( ed ));

   sprintf( tbuf, "%s %s", edname, CURTASK progfile );

#if INTENSIVE_DEBUG
   sprintf( bwb_ebuf, "in bwb_edit(): command line <%s>", tbuf );
   bwb_debug( bwb_ebuf );
#else
   nl();
   endwin(); /* Added by JBV 10/11/97 */
   system( tbuf );

   /*-----------------------*/
   /* Added by JBV 10/11/97 */
   /*-----------------------*/
   fprintf( stderr, "Press RETURN when ready..." );
   fgets( tbuf, MAXREADLINESIZE, stdin );
   refresh();

   nonl();
#endif

   /* open edited file for read */

   if ( ( loadfile = fopen( CURTASK progfile, "r" )) == NULL )
      {
      sprintf( bwb_ebuf, err_openfile, CURTASK progfile );
      bwb_error( bwb_ebuf );

      ncu_setpos();
      return bwb_zline( l );
      }

   /* clear current contents */

   bwb_new( l ); /* Relocated by JBV (bug found by DD) */

   /* and (re)load the file into memory */

   bwb_fload( loadfile );


   ncu_setpos();
   return bwb_zline( l );
   }
Exemplo n.º 2
0
struct bwb_line *
bwb_edit( struct bwb_line *l )
   {
   char tbuf[ MAXSTRINGSIZE + 1 ];
   char edname[ MAXSTRINGSIZE + 1 ];
   struct bwb_variable *ed;
   FILE *loadfile;

   ed = var_find( DEFVNAME_EDITOR );
   str_btoc( edname, var_getsval( ed ));

   sprintf( tbuf, "%s %s", edname, CURTASK progfile );

#if INTENSIVE_DEBUG
   sprintf( bwb_ebuf, "in bwb_edit(): command line <%s>", tbuf );
   bwb_debug( bwb_ebuf );
#else
   system( tbuf );
#endif

   /* open edited file for read */

   if ( ( loadfile = fopen( CURTASK progfile, "r" )) == NULL )
      {
      sprintf( bwb_ebuf, err_openfile, CURTASK progfile );
      bwb_error( bwb_ebuf );

      iqc_setpos();
      return bwb_zline( l );
      }

   /* clear current contents */

   bwb_new( l ); /* Relocated by JBV (bug found by DD) */

   /* and (re)load the file into memory */

   bwb_fload( loadfile );


   iqc_setpos();
   return bwb_zline( l );
   }
Exemplo n.º 3
0
struct bwb_line *
bwb_NAME(struct bwb_line * l)
{
   int             r;
   int             position;
   struct exp_ese *e;
   char            atbuf[BasicStringLengthMax + 1];
   char            btbuf[BasicStringLengthMax + 1];

   bwx_DEBUG(__FUNCTION__);

   /* get the first argument in atbuf */

   adv_element(l->buffer, &(l->position), atbuf);

   /* interpret the first argument */

   position = 0;
   e = bwb_exp(atbuf, FALSE, &position);
   if (ERROR_PENDING)
   {
      return bwb_zline(l);
   }
   if (e->type != STRING)
   {
      bwb_error(err_argstr);
      return bwb_zline(l);
   }
   /* this argument must be copied back to atbuf, else the next call to
    * bwb_exp() will overwrite the structure to which e refers */

   str_btoc(atbuf, &(e->sval));


   /* get the second argument in btbuf */

   adv_element(l->buffer, &(l->position), btbuf);


   if (strcasecmp(btbuf, "AS") != 0)
   {
      bwb_error(err_syntax);
      return bwb_zline(l);
   }
   /* get the third argument in btbuf */

   adv_element(l->buffer, &(l->position), btbuf);

   /* interpret the third argument */

   position = 0;
   e = bwb_exp(btbuf, FALSE, &position);
   if (ERROR_PENDING)
   {
      return bwb_zline(l);
   }
   if (e->type != STRING)
   {
      bwb_error(err_argstr);
      return bwb_zline(l);
   }
   str_btoc(btbuf, &(e->sval));


   /* try to rename the file */

   r = rename(atbuf, btbuf);

   /* detect error */

   if (r != 0)
   {
      bwb_error(err_opsys);
   }
   return bwb_zline(l);

}