Example #1
0
extern void do_undef (int sharp)
{
   char *mac;

   if (! in_false_if())
   {
      mac = read_ident();
      if (! mac)
      {
         err_head();
         fprintf(stderr, "missing/illegal macro name\n");
      }
      else
      {
         undef (mac);
      }
   }
   if (sharp)
   {
      flush_sharp_line();
   }
}
Example #2
0
extern void do_else (int sharp)
{
#ifdef DEBUG_IF
   if (debugging)
   {
      outputc('<');
      outputc(sharp ? '#' : '@');
      outputs("else: ");
      // fflush(outfile);
   }
#endif
   if (n_skipped_ifs == 0)
   {
      if (ifstack)
      {
#ifdef DEBUG_IF
         if (debugging)
         {
            outputs("top ");
            output_ifstate(ifstack->condstate);
            // fflush(outfile);
         }
#endif
         switch (ifstack->condstate)
         {
            case IFSTATE_TRUE:
               ifstack->condstate = IFSTATE_STAYFALSE;
               break;
            case IFSTATE_FALSE:
               ifstack->condstate = IFSTATE_TRUE;
               break;
         }
#ifdef DEBUG_IF
         if (debugging)
         {
            outputs(" now ");
            output_ifstate(ifstack->condstate);
            outputc('>');
            // fflush(outfile);
         }
#endif

      }
      else
      {
#ifdef DEBUG_IF
         if (debugging)
         {
            outputs(" no if>");
            // fflush(outfile);
         }
#endif
         err_head();
         fprintf(stderr, "if-less else\n");
      }
   }
   else
   {
#ifdef DEBUG_IF
      if (debugging)
      {
         outputs("in-false, forgetting>");
         // fflush(outfile);
      }
#endif

   }
   if (sharp)
   {
      flush_sharp_line();
   }
}
Example #3
0
void do_ifndef (int sharp)
{
   char *w;

#ifdef DEBUG_IF

   if (debugging)
   {
      outputc('<');
      outputc(sharp ? '#' : '@');
      outputs("ifndef: ");
      // fflush(outfile);
   }
#endif
   if (in_false_if())
   {
      n_skipped_ifs ++;
#ifdef DEBUG_IF

      if (debugging)
      {
         outputs("in-false, skipped>");
         // fflush(outfile);
      }
#endif

   }
   else
   {
      w = read_ident();
      if (! w)
      {
#ifdef DEBUG_IF
         if (debugging)
         {
            outputs("no ident ");
            // fflush(outfile);
         }
#endif
         iftrue();
      }
      else
      {
#ifdef DEBUG_IF
         if (debugging)
         {
            outputs(w);
            outputc(' ');
            // fflush(outfile);
         }
#endif
         if (find_def(w))
         {
            iffalse();
         }
         else
         {
            iftrue();
         }
         os_free(w);
      }
#ifdef DEBUG_IF
      if (debugging)
      {
         outputc('>');
         // fflush(outfile);
      }
#endif

   }
   if (sharp)
   {
      flush_sharp_line();
   }
}
Example #4
0
extern void do_sharp (void)
{
   char *w;
   char c;

   w = read_ctrl();
   if (strcmp(w, "ifdef") == 0)
   {
      do_ifdef(1);
   }
   else if (strcmp(w, "ifndef") == 0)
   {
      do_ifndef(1);
   }
   else if (strcmp(w, "if") == 0)
   {
      do_if(1);
   }
   else if (strcmp(w, "else") == 0)
   {
      do_else(1);
   }
   else if (strcmp(w, "elif") == 0)
   {
      do_elif(1);
   }
   else if (strcmp(w, "endif") == 0)
   {
      do_endif(1);
   }
   else if (strcmp(w, "include") == 0)
   {
      do_include(1);
   }
   else if (strcmp(w, "define") == 0)
   {
      do_define(1, 0);
   }
   else if (strcmp(w, "undef") == 0)
   {
      do_undef(1);
   }
   else if (strcmp(w, "line") == 0)
   {
      do_line();
   }
   else if (strcmp(w, "pragma") == 0)
   {
      do_pragma();
   }
   else if (strcmp(w, "") == 0)
   {}
   else
   {
      int isnull;
      isnull = 0;
      if (strcmp(w, "") == 0)
      {
         c = Get();
         if (c != '\n')
         {
            Push(c);
         }
         else
         {
            isnull = 1;
         }
      }
      if (!isnull && !in_false_if())
      {
         err_head();
         fprintf(stderr, "unknown control `%s'\n", w);
         flush_sharp_line();
      }
   }
   maybe_print('\n');
   os_free(w);
}