示例#1
0
extern void do_line (void)
{
   char c;

   outputc('#');
   while ((c = Get()) != '\n')
   {
      outputc(c);
   }
}
示例#2
0
extern void do_pragma (void)
{
   char c;

   if (in_false_if())
   {
      while ((c = Get()) != '\n')
         ;
   }
   else
   {
      outputc('#');
      outputc('p');
      outputc('r');
      outputc('a');
      outputc('g');
      outputc('m');
      outputc('a');
      outputc(' ');
      c = Get();
      while ((c != '\n') && (c != -1))
      {
         outputc(c);
         c = Get();
      }
   }
}
示例#3
0
文件: expr.c 项目: S73417H/opensplice
static EORB_CPP_node *read_expr_5(void)
{
   EORB_CPP_node *l;
   EORB_CPP_node *r;
   char c;
   char d;

#ifdef DEBUG_EXPR

   if (debugging)
   {
      outputs("~E5:");
   }
#endif
   l = read_expr_6();
   while (1)
   {
      c = getnhsexpand();
      switch (c)
      {
         case '=':
         case '!':
            d = Get();
            if (d == '=')
            {
#ifdef DEBUG_EXPR
               if (debugging)
               {
                  outputc(c);
                  outputc(d);
               }
#endif
               r = read_expr_6();
               l = newnode(l, (c == '=') ? EQL : NEQ, r);
               break;
            }
            Push(d);
            /* fall through ... */
         default:
#ifdef DEBUG_EXPR

            if (debugging)
            {
               outputs("~");
            }
#endif
            Push(c);
            return (l);
            break;
      }
   }
}
示例#4
0
文件: expr.c 项目: S73417H/opensplice
int eval_expr (int Sharp, int Complain)
{
   char c;
   char d;
   int rv;

   sharp = Sharp;
   complain = Complain;
   expr = read_expr_();
   if (sharp)
   {
      c = getnonhspace();
      d = '\n';
   }
   else
   {
      c = getnonspace();
      d = ')';
   }
   if (c != d)
   {
      if (complain)
      {
         err_head();
         fprintf(stderr, "expression syntax error -- junk after expression\n");
      }
      while (Get() != d)
         ;
   }
#ifdef DEBUG_EXPR
   if (debugging)
   {
      outputc('<');
      dump_expr(expr);
      outputc('=');
      rv = exec_free(expr);
      outputd(rv);
      outputc('>');
   }
   else
   {
      rv = exec_free(expr);
   }
   return (rv);
#else

   return (exec_free(expr));
#endif
}
示例#5
0
文件: expr.c 项目: S73417H/opensplice
static void putx (int i)
{
   char c1 = i&0xff;
   
   if (i > 0xff)
   {
      char c2 = i >> 8;
      outputc(c2);
   }
示例#6
0
文件: json.c 项目: bkoropoff/moonunit
static void
key_begin(JsonLogger* self, char const* key)
{
    output(self, "\"");
    escape(self, key);
    output(self, "\":");
    if (self->pretty)
    {
        outputc(self, ' ');
    }
}
示例#7
0
文件: expr.c 项目: S73417H/opensplice
static EORB_CPP_node *read_expr_2(void)
{
   EORB_CPP_node *l;
   EORB_CPP_node *r;
   char c;
   char d;

#ifdef DEBUG_EXPR

   if (debugging)
   {
      outputs("~E2:");
   }
#endif
   l = read_expr_3();
   while (1)
   {
      c = getnhsexpand();
      switch (c)
      {
         case '|':
            d = Get();
            if (d != '|')
            {
               Push(d);
#ifdef DEBUG_EXPR

               if (debugging)
               {
                  outputc(c);
               }
#endif
               r = read_expr_3();
               l = newnode(l, c, r);
               break;
            }
            Push(d);
            /* fall through ... */
         default:
#ifdef DEBUG_EXPR

            if (debugging)
            {
               outputs("~");
            }
#endif
            Push(c);
            return (l);
            break;
      }
   }
}
示例#8
0
文件: expr.c 项目: S73417H/opensplice
static EORB_CPP_node * read_expr_9 (void)
{
   EORB_CPP_node *l;
   EORB_CPP_node *r;
   char c;

#ifdef DEBUG_EXPR

   if (debugging)
   {
      outputs("~E9:");
   }
#endif
   l = read_expr_10();
   while (1)
   {
      c = getnhsexpand();
      switch (c)
      {
         case '*':
         case '%':
#ifdef DEBUG_EXPR

            if (debugging)
            {
               outputc(c);
            }
#endif
            r = read_expr_10();
            l = newnode(l, c, r);
            break;
         case '/':
            r = read_expr_10();
            if (!r->op) {
               Push(c);
               return (l);
            }
            break;
         default:
#ifdef DEBUG_EXPR

            if (debugging)
            {
               outputs("~");
            }
#endif
            Push(c);
            return (l);
            break;
      }
   }
}
示例#9
0
static void		clean_char(char *line, int i)
{
	tputs(tgetstr("dm", NULL), 0, outputc);
	tputs(tgetstr("le", NULL), 0, outputc);
	tputs(tgetstr("dc", NULL), 0, outputc);
	tputs(tgetstr("ed", NULL), 0, outputc);
	tputs(tgetstr("sc", NULL), 0, outputc);
	if (line)
	{
		while (i <= (int)ft_strlen(line))
		{
			outputc(line[i - 1]);
			i++;
		}
	}
	tputs(tgetstr("rc", NULL), 0, outputc);
}
示例#10
0
文件: expr.c 项目: S73417H/opensplice
static EORB_CPP_node *read_expr_3(void)
{
   EORB_CPP_node *l;
   EORB_CPP_node *r;
   char c;

#ifdef DEBUG_EXPR

   if (debugging)
   {
      outputs("~E3:");
   }
#endif
   l = read_expr_4();
   while (1)
   {
      c = getnhsexpand();
      switch (c)
      {
         case '^':
#ifdef DEBUG_EXPR

            if (debugging)
            {
               outputc(c);
            }
#endif
            r = read_expr_4();
            l = newnode(l, c, r);
            break;
         default:
#ifdef DEBUG_EXPR

            if (debugging)
            {
               outputs("~");
            }
#endif
            Push(c);
            return (l);
            break;
      }
   }
}
示例#11
0
文件: json.c 项目: bkoropoff/moonunit
static void
escape(JsonLogger* self, char const* str)
{
    for (; *str; str++)
    {
        if (*str <= 0x1f)
        {
            print(self, "\\u%.4x", (unsigned int) *str);
        }
        else switch (*str)
        {
        case '"':
            output(self, "\"");
            break;
        case '\\':
            output(self, "\\");
            break;
        default:
            outputc(self, *str);
        }
    }
}
示例#12
0
文件: if.c 项目: AmitShah/opensplice
void do_if (int sharp)
{
   char c;
   char d;

#ifdef DEBUG_IF

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

      if (debugging)
      {
         outputs("in-false, skipped>");
         // fflush(outfile);
      }
#endif
      if (sharp)
      {
         d = '\0';
         do
         {
            c = d;
            d = Get();
         }
         while ((c == '\\') || (d != '\n'));
      }
      return ;
   }
   if (! sharp)
   {
      c = getnonspace();
      if (c != '(')
      {
         err_head();
         fprintf(stderr, "@if must have ()s\n");
         Push(c);
         iffalse();
#ifdef DEBUG_IF

         if (debugging)
         {
            outputc('>');
            // fflush(outfile);
         }
#endif
         return ;
      }
   }
   if (eval_expr(sharp, 0))
   {
      iftrue();
   }
   else
   {
      iffalse();
   }
#ifdef DEBUG_IF
   if (debugging)
   {
      outputc('>');
      // fflush(outfile);
   }
#endif
}
示例#13
0
文件: if.c 项目: AmitShah/opensplice
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();
   }
}
示例#14
0
文件: if.c 项目: AmitShah/opensplice
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();
   }
}
示例#15
0
extern void expand_def (DEF * d)
{
   unsigned char *cp;
   char *dp;
   char *ep;
   char *result;
   int ok;
   int incomm;
   char last;

   if (d->nargs >= 0)
   {
      read_actuals(d);
   }
#ifdef DEBUG_EXPAND
   if (debugging)
   {
      char *cp;
      outputs("~EXPAND:");
      outputs(d->name);
      if (d->nargs == 0)
      {
         outputs("()");
      }
      else if (d->nargs > 0)
      {
         int i;
         for (i = 0;i < d->nargs;i++)
         {
            char c = i ? ',' : '(';
            outputc(c);
            outputs(actuals[i]);
         }
         outputc(')');
      }
      outputs("-->");
      for (cp = (char *)d->repl;*cp;cp++)
      {
         outputs(unctrl(*cp));
      }
      outputc('~');
   }
#endif
   result = init_accum();
   for (cp = d->repl;*cp;cp++)
   {
      if (*cp & 0x80)
      {
         char *dp;
         int i;
         i = *cp & ~0x80;
         for (dp = actuals[i];*dp;dp++)
         {
            accum_char(result, *dp);
         }
      }
      else
      {
         accum_char(result, *cp);
      }
   }
   dp = accum_result(result);
#ifdef DEBUG_EXPAND

   if (debugging)
   {
      outputs("first:");
      for (ep = dp;*ep;ep++)
      {
         outputs(unctrl(*ep));
      }
      outputc('~');
   }
#endif
   result = init_accum();
   last = '\0';
   ok = 1;
   incomm = 0;
   for (ep = dp;*ep;ep++)
   {
      if (!incomm && (last == '/') && (*ep == '*'))
      {
         incomm = 1;
         if (!keep_comments || (strncmp(ep, "**/", 3) == 0))
         {
            accum_regret(result);
            ok = 0;
         }
      }
      if (ok)
      {
         accum_char(result, *ep);
      }
      if ((last == '*') && (*ep == '/'))
      {
         incomm = 0;
         ok = 1;
      }
      last = *ep;
   }
   os_free(dp);
   result = accum_result(result);
#ifdef DEBUG_EXPAND

   if (debugging)
   {
      outputs("/**/strip:");
      outputs(result);
      outputc('~');
   }
#endif
   for (dp = result + strlen(result) - 1;dp >= result;dp--)
   {
      Push(*dp);
   }
   os_free(result);
   if (d->nargs >= 0)
   {
      int i;
      for (i = 0;i < d->nargs;i++)
      {
         os_free(actuals[i]);
      }
      os_free((char *)actuals);
   }
}
示例#16
0
文件: expr.c 项目: S73417H/opensplice
static EORB_CPP_node *read_expr_11 (void)
{
   char c;

#ifdef DEBUG_EXPR

   if (debugging)
   {
      outputs("~E11:");
   }
#endif
   while (1)
   {
      c = getnhsexpand();
      if (c == '(')
      {
         EORB_CPP_node *n;
#ifdef DEBUG_EXPR

         if (debugging)
         {
            outputs("()");
         }
#endif
         n = read_expr_();
         c = getnhsexpand();
         if (c != ')')
         {
            err_head();
            fprintf(stderr, "expression syntax error -- missing ) supplied\n");
            Push(c);
         }
#ifdef DEBUG_EXPR
         if (debugging)
         {
            outputs("~");
         }
#endif
         return (n);
      }
      else if (isdigit((int) c))
      {
         int base;
         static char digits[] = "0123456789abcdefABCDEF";
         static char values[] =
            "\0\1\2\3\4\5\6\7\10\11\12\13\14\15\16\17\12\13\14\15\16\17";
         char *d;
         int v;
#ifdef DEBUG_EXPR

         if (debugging)
         {
            outputs("N");
         }
#endif
         base = 10;
         if (c == '0')
         {
            base = 8;
            c = Get();
            if ((c == 'x') || (c == 'X'))
            {
               base = 16;
               c = Get();
            }
         }
         v = 0;
         while (1)
         {
            d = strchr(digits, c);
            if (d == 0)
            {
               Push(c);
#ifdef DEBUG_EXPR

               if (debugging)
               {
                  outputd(v);
                  outputs("~");
               }
#endif
               return (newleaf(v));
            }
            else if (values[d -digits] >= base)
            {
               err_head();
               fprintf(stderr, "warning: illegal %sdigit `%c'\n",
                       (base == 16) ? "hex " : (base == 8) ? "octal " : "", c);
            }
            v = (v * base) + values[d - digits];
            c = Get();
         }
      }
      else if (c == '\'')
      {
         int i;
         int j;
         int n;
         i = 0;
         n = 0;
         while (1)
         {
            j = get_quote_char();
            if (j < 0)
            {
               break;
            }
            i = (i << 8) | j;
            n ++;
         }
         if (n > 4)
         {
            err_head();
            fprintf(stderr, "warning: too many characters in character constant\n");
         }
         return (newleaf(i));
      }
      else if ((c == '\n') && !sharp)
      {}
      else
      {
         char *id;
         if (complain)
         {
            err_head();
            fprintf(stderr, "expression syntax error -- number expected\n");
         }
         if (isbsymchar(c))
         {
            Push(c);
            id = read_ident();
         }
         else
         {
            id = 0;
         }
#ifdef DEBUG_EXPR
         if (debugging)
         {
            outputs("0(");
            outputc(c);
            outputs(":");
            outputs(id ? id : "(none)");
            outputs(")~");
         }
#endif
         if (id)
         {
            os_free(id);
         }
         return (newleaf(0));
      }
   }
}
示例#17
0
文件: expr.c 项目: S73417H/opensplice
static EORB_CPP_node *read_expr_10 (void)
{
   char c;
   char *w;
   EORB_CPP_node *n;

#ifdef DEBUG_EXPR

   if (debugging)
   {
      outputs("~E10:");
   }
#endif
   while (1)
   {
      c = getnhsexpand();
      switch (c)
      {
         case '-':
         case '~':
         case '!':
#ifdef DEBUG_EXPR

            if (debugging)
            {
               outputc(c);
            }
#endif
            n = read_expr_10();
#ifdef DEBUG_EXPR

            if (debugging)
            {
               outputs("~");
            }
#endif
            return (newnode(0, c, n));
            break;
         case 'd':
            Push(c);
            input_mark();
            w = read_ident();
            if (strcmp(w, "defined") == 0)
            {
               c = getnonspace();
               if (c == '(')
               {
                  char *id;
                  id = read_ident();
                  if (id)
                  {
                     c = getnonspace();
                     if (c == ')')
                     {
                        input_unmark();
#ifdef DEBUG_EXPR

                        if (debugging)
                        {
                           outputs("ifdef");
                        }
#endif
                        return (newname(id));
                     }
                  }
               }
               else if (isbsymchar(c))
               {
                  char *id;
                  Push(c);
                  id = read_ident();
                  if (id)
                  {
                     input_unmark();
#ifdef DEBUG_EXPR

                     if (debugging)
                     {
                        outputs("ifdef");
                     }
#endif
                     return (newname(id));
                  }
               }
            }
            input_recover();
            n = read_expr_11();
#ifdef DEBUG_EXPR

            if (debugging)
            {
               outputs("~");
            }
#endif
            return (n);
            break;
         default:
            Push(c);
            n = read_expr_11();
#ifdef DEBUG_EXPR

            if (debugging)
            {
               outputs("~");
            }
#endif
            return (n);
            break;
      }
   }
}
示例#18
0
文件: expr.c 项目: S73417H/opensplice
static EORB_CPP_node *read_expr_6(void)
{
   EORB_CPP_node *l;
   EORB_CPP_node *r;
   char c;
   char d;

#ifdef DEBUG_EXPR

   if (debugging)
   {
      outputs("~E6:");
   }
#endif
   l = read_expr_7();
   while (1)
   {
      c = getnhsexpand();
      switch (c)
      {
         case '<':
         case '>':
            d = Get();
            if (d == '=')
            {
#ifdef DEBUG_EXPR
               if (debugging)
               {
                  outputc(c);
                  outputc(d);
               }
#endif
               r = read_expr_7();
               l = newnode(l, (c == '<') ? LEQ : GEQ, r);
            }
            else
            {
#ifdef DEBUG_EXPR
               if (debugging)
               {
                  outputc(c);
               }
#endif
               Push(d);
               r = read_expr_7();
               l = newnode(l, c, r);
            }
            break;
         default:
#ifdef DEBUG_EXPR

            if (debugging)
            {
               outputs("~");
            }
#endif
            Push(c);
            return (l);
            break;
      }
   }
}