⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 print_cmd.c

📁 android-w.song.android.widget
💻 C
📖 第 1 页 / 共 3 页
字号:
      else if (sh_contains_shell_metas (t))	{	  x = sh_single_quote (t);	  fprintf (xtrace_fp, "%s%s", x, w->next ? " " : "");	  free (x);	}      else if (ansic_shouldquote (t))	{	  x = ansic_quote (t, 0, (int *)0);	  fprintf (xtrace_fp, "%s%s", x, w->next ? " " : "");	  free (x);	}      else	fprintf (xtrace_fp, "%s%s", t, w->next ? " " : "");    }  fprintf (xtrace_fp, "\n");  fflush (xtrace_fp);}static voidcommand_print_word_list (list, separator)     WORD_LIST *list;     char *separator;{  _print_word_list (list, separator, cprintf);}voidprint_for_command_head (for_command)     FOR_COM *for_command;{  cprintf ("for %s in ", for_command->name->word);  command_print_word_list (for_command->map_list, " ");}voidxtrace_print_for_command_head (for_command)     FOR_COM *for_command;{  CHECK_XTRACE_FP;  fprintf (xtrace_fp, "%s", indirection_level_string ());  fprintf (xtrace_fp, "for %s in ", for_command->name->word);  xtrace_print_word_list (for_command->map_list, 0);}static voidprint_for_command (for_command)     FOR_COM *for_command;{  print_for_command_head (for_command);  cprintf (";");  newline ("do\n");  indentation += indentation_amount;  make_command_string_internal (for_command->action);  PRINT_DEFERRED_HEREDOCS ("");  semicolon ();  indentation -= indentation_amount;  newline ("done");}#if defined (ARITH_FOR_COMMAND)static voidprint_arith_for_command (arith_for_command)     ARITH_FOR_COM *arith_for_command;{  cprintf ("for ((");  command_print_word_list (arith_for_command->init, " ");  cprintf ("; ");  command_print_word_list (arith_for_command->test, " ");  cprintf ("; ");  command_print_word_list (arith_for_command->step, " ");  cprintf ("))");  newline ("do\n");  indentation += indentation_amount;  make_command_string_internal (arith_for_command->action);  semicolon ();  indentation -= indentation_amount;  newline ("done");}#endif /* ARITH_FOR_COMMAND */#if defined (SELECT_COMMAND)voidprint_select_command_head (select_command)     SELECT_COM *select_command;{  cprintf ("select %s in ", select_command->name->word);  command_print_word_list (select_command->map_list, " ");}voidxtrace_print_select_command_head (select_command)     SELECT_COM *select_command;{  CHECK_XTRACE_FP;  fprintf (xtrace_fp, "%s", indirection_level_string ());  fprintf (xtrace_fp, "select %s in ", select_command->name->word);  xtrace_print_word_list (select_command->map_list, 0);}static voidprint_select_command (select_command)     SELECT_COM *select_command;{  print_select_command_head (select_command);  cprintf (";");  newline ("do\n");  indentation += indentation_amount;  make_command_string_internal (select_command->action);  PRINT_DEFERRED_HEREDOCS ("");  semicolon ();  indentation -= indentation_amount;  newline ("done");}#endif /* SELECT_COMMAND */static voidprint_group_command (group_command)     GROUP_COM *group_command;{  group_command_nesting++;  cprintf ("{ ");  if (inside_function_def == 0)    skip_this_indent++;  else    {      /* This is a group command { ... } inside of a function	 definition, and should be printed as a multiline group	 command, using the current indentation. */      cprintf ("\n");      indentation += indentation_amount;    }  make_command_string_internal (group_command->command);  if (inside_function_def)    {      cprintf ("\n");      indentation -= indentation_amount;      indent (indentation);    }  else    {      semicolon ();      cprintf (" ");    }  cprintf ("}");  group_command_nesting--;}voidprint_case_command_head (case_command)     CASE_COM *case_command;{  cprintf ("case %s in ", case_command->word->word);}voidxtrace_print_case_command_head (case_command)     CASE_COM *case_command;{  CHECK_XTRACE_FP;  fprintf (xtrace_fp, "%s", indirection_level_string ());  fprintf (xtrace_fp, "case %s in\n", case_command->word->word);}static voidprint_case_command (case_command)     CASE_COM *case_command;{  print_case_command_head (case_command);  if (case_command->clauses)    print_case_clauses (case_command->clauses);  newline ("esac");}static voidprint_case_clauses (clauses)     PATTERN_LIST *clauses;{  indentation += indentation_amount;  while (clauses)    {      newline ("");      command_print_word_list (clauses->patterns, " | ");      cprintf (")\n");      indentation += indentation_amount;      make_command_string_internal (clauses->action);      indentation -= indentation_amount;      PRINT_DEFERRED_HEREDOCS ("");      if (clauses->flags & CASEPAT_FALLTHROUGH)	newline (";&");      else if (clauses->flags & CASEPAT_TESTNEXT)	newline (";;&");      else	newline (";;");      clauses = clauses->next;    }  indentation -= indentation_amount;}static voidprint_while_command (while_command)     WHILE_COM *while_command;{  print_until_or_while (while_command, "while");}static voidprint_until_command (while_command)     WHILE_COM *while_command;{  print_until_or_while (while_command, "until");}static voidprint_until_or_while (while_command, which)     WHILE_COM *while_command;     char *which;{  cprintf ("%s ", which);  skip_this_indent++;  make_command_string_internal (while_command->test);  PRINT_DEFERRED_HEREDOCS ("");  semicolon ();  cprintf (" do\n");	/* was newline ("do\n"); */  indentation += indentation_amount;  make_command_string_internal (while_command->action);  PRINT_DEFERRED_HEREDOCS ("");  indentation -= indentation_amount;  semicolon ();  newline ("done");}static voidprint_if_command (if_command)     IF_COM *if_command;{  cprintf ("if ");  skip_this_indent++;  make_command_string_internal (if_command->test);  semicolon ();  cprintf (" then\n");  indentation += indentation_amount;  make_command_string_internal (if_command->true_case);  PRINT_DEFERRED_HEREDOCS ("");  indentation -= indentation_amount;  if (if_command->false_case)    {      semicolon ();      newline ("else\n");      indentation += indentation_amount;      make_command_string_internal (if_command->false_case);      PRINT_DEFERRED_HEREDOCS ("");      indentation -= indentation_amount;    }  semicolon ();  newline ("fi");}#if defined (DPAREN_ARITHMETIC)voidprint_arith_command (arith_cmd_list)     WORD_LIST *arith_cmd_list;{  cprintf ("((");  command_print_word_list (arith_cmd_list, " ");  cprintf ("))");}#endif#if defined (COND_COMMAND)static voidprint_cond_node (cond)     COND_COM *cond;{  if (cond->flags & CMD_INVERT_RETURN)    cprintf ("! ");  if (cond->type == COND_EXPR)    {      cprintf ("( ");      print_cond_node (cond->left);      cprintf (" )");    }  else if (cond->type == COND_AND)    {      print_cond_node (cond->left);      cprintf (" && ");      print_cond_node (cond->right);    }  else if (cond->type == COND_OR)    {      print_cond_node (cond->left);      cprintf (" || ");      print_cond_node (cond->right);    }  else if (cond->type == COND_UNARY)    {      cprintf ("%s", cond->op->word);      cprintf (" ");      print_cond_node (cond->left);    }  else if (cond->type == COND_BINARY)    {      print_cond_node (cond->left);      cprintf (" ");      cprintf ("%s", cond->op->word);      cprintf (" ");      print_cond_node (cond->right);    }  else if (cond->type == COND_TERM)    {      cprintf ("%s", cond->op->word);		/* need to add quoting here */    }}voidprint_cond_command (cond)     COND_COM *cond;{  cprintf ("[[ ");  print_cond_node (cond);  cprintf (" ]]");}#ifdef DEBUGvoiddebug_print_cond_command (cond)     COND_COM *cond;{  fprintf (stderr, "DEBUG: ");  command_string_index = 0;  print_cond_command (cond);  fprintf (stderr, "%s\n", the_printed_command);}#endifvoidxtrace_print_cond_term (type, invert, op, arg1, arg2)     int type, invert;     WORD_DESC *op;     char *arg1, *arg2;{  CHECK_XTRACE_FP;  command_string_index = 0;  fprintf (xtrace_fp, "%s", indirection_level_string ());  fprintf (xtrace_fp, "[[ ");  if (invert)    fprintf (xtrace_fp, "! ");  if (type == COND_UNARY)    {      fprintf (xtrace_fp, "%s ", op->word);      fprintf (xtrace_fp, "%s", (arg1 && *arg1) ? arg1 : "''");    }  else if (type == COND_BINARY)    {      fprintf (xtrace_fp, "%s", (arg1 && *arg1) ? arg1 : "''");      fprintf (xtrace_fp, " %s ", op->word);      fprintf (xtrace_fp, "%s", (arg2 && *arg2) ? arg2 : "''");    }  fprintf (xtrace_fp, " ]]\n");  fflush (xtrace_fp);}	  #endif /* COND_COMMAND */#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)/* A function to print the words of an arithmetic command when set -x is on. */voidxtrace_print_arith_cmd (list)     WORD_LIST *list;{  WORD_LIST *w;  CHECK_XTRACE_FP;  fprintf (xtrace_fp, "%s", indirection_level_string ());  fprintf (xtrace_fp, "(( ");  for (w = list; w; w = w->next)    fprintf (xtrace_fp, "%s%s", w->word->word, w->next ? " " : "");  fprintf (xtrace_fp, " ))\n");  fflush (xtrace_fp);}#endifvoidprint_simple_command (simple_command)     SIMPLE_COM *simple_command;{  command_print_word_list (simple_command->words, " ");  if (simple_command->redirects)    {      cprintf (" ");      print_redirection_list (simple_command->redirects);    }}static voidprint_heredocs (heredocs)     REDIRECT *heredocs;{  REDIRECT *hdtail;  cprintf (" ");   for (hdtail = heredocs; hdtail; hdtail = hdtail->next)    {      print_redirection (hdtail);      cprintf ("\n");    }  was_heredoc = 1;}/* Print heredocs that are attached to the command before the connector   represented by CSTRING.  The parsing semantics require us to print the   here-doc delimiters, then the connector (CSTRING), then the here-doc   bodies.  We don't print the connector if it's a `;', but we use it to   note not to print an extra space after the last heredoc body and   newline. */static voidprint_deferred_heredocs (cstring)     const char *cstring;{  REDIRECT *hdtail;	  for (hdtail = deferred_heredocs; hdtail; hdtail = hdtail->next)    {      cprintf (" ");      print_heredoc_header (hdtail);    }  if (cstring[0] && (cstring[0] != ';' || cstring[1]))    cprintf ("%s", cstring);   if (deferred_heredocs)    cprintf ("\n");  for (hdtail = deferred_heredocs; hdtail; hdtail = hdtail->next)    {      print_heredoc_body (hdtail);      cprintf ("\n");    }  if (deferred_heredocs)    {      if (cstring && cstring[0] && (cstring[0] != ';' || cstring[1]))	cprintf (" ");	/* make sure there's at least one space */      dispose_redirects (deferred_heredocs);      was_heredoc = 1;    }  deferred_heredocs = (REDIRECT *)NULL;}      static voidprint_redirection_list (redirects)     REDIRECT *redirects;{  REDIRECT *heredocs, *hdtail, *newredir;  heredocs = (REDIRECT *)NULL;  hdtail = heredocs;  was_heredoc = 0;  while (redirects)    {      /* Defer printing the here documents until we've printed the	 rest of the redirections. */      if (redirects->instruction == r_reading_until || redirects->instruction == r_deblank_reading_until)	{	  newredir = copy_redirect (redirects);	  newredir->next = (REDIRECT *)NULL;	  if (heredocs)	    {	      hdtail->next = newredir;	      hdtail = newredir;	    }	  else	    hdtail = heredocs = newredir;	}      else if (redirects->instruction == r_duplicating_output_word && redirects->redirector.dest == 1)	{	  /* Temporarily translate it as the execution code does. */	  redirects->instruction = r_err_and_out;	  print_redirection (redirects);	  redirects->instruction = r_duplicating_output_word;	}      else	print_redirection (redirects);      redirects = redirects->next;      if (redirects)	cprintf (" ");    }  /* Now that we've printed all the other redirections (on one line),     print the here documents. */  if (heredocs && printing_connection)    deferred_heredocs = heredocs;  else if (heredocs)    {      print_heredocs (heredocs);      dispose_redirects (heredocs);    }}static voidprint_heredoc_header (redirect)     REDIRECT *redirect;{  int kill_leading;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -