/* CHGFILE - changes an old macro file into a new one
   This macro changes a version 1.1 ME macro file into a version
   1.2 macro file. The two changes are
     1) %define => #define
     2) old style comments (# <text>) into C-style comments (/*...)
   After you load this file in, go to the first line and press ALT C.
   Written by Marc Adler  12/29/86
*/

#define ALT_C   174

init()
{
  assign_key("chgfile", ALT_C);
}

chgfile()
{
  int i;

  save_position();              /* save the current cursor position */

  while (!is_eof())
  {
    gobol();                    /* make sure we start at the front */
    if (currchar() == '%')      /* change "%define" to "#define"   */
    {
      delchar();
      insert("#");
    }
    else if ((i = index(currline(), "#")) > 0)
    {
      setcol(i);                /* change all old comments ('#' followed */
      delchar();                /* by text) to the C-style comments (/*..) */
      insert("/*");
      goeol();
      insert(" */");
    }
    if (!down())
      break;
  }
  
  restore_position();           /* return from whence we came */
}
