1 /* print_command -- A way to make readable commands from a command tree. */
3 /* Copyright (C) 1989-2005 Free Software Foundation, Inc.
5 This file is part of GNU Bash, the Bourne Again SHell.
7 Bash is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Bash is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License along
18 with Bash; see the file COPYING. If not, write to the Free Software
19 Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
25 #if defined (HAVE_UNISTD_H)
27 # include <sys/types.h>
32 #if defined (PREFER_STDARG)
43 #include <y.tab.h> /* use <...> so we pick it up from the build directory */
47 #include "builtins/common.h"
50 extern int printf __P((const char *, ...)); /* Yuck. Double yuck. */
53 extern int indirection_level;
55 static int indentation;
56 static int indentation_amount = 4;
58 #if defined (PREFER_STDARG)
59 typedef void PFUNC __P((const char *, ...));
61 static void cprintf __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
62 static void xprintf __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2)));
64 #define PFUNC VFunction
65 static void cprintf ();
66 static void xprintf ();
69 static void reset_locals __P((void));
70 static void newline __P((char *));
71 static void indent __P((int));
72 static void semicolon __P((void));
73 static void the_printed_command_resize __P((int));
75 static void make_command_string_internal __P((COMMAND *));
76 static void _print_word_list __P((WORD_LIST *, char *, PFUNC *));
77 static void command_print_word_list __P((WORD_LIST *, char *));
78 static void print_case_clauses __P((PATTERN_LIST *));
79 static void print_redirection_list __P((REDIRECT *));
80 static void print_redirection __P((REDIRECT *));
82 static void print_for_command __P((FOR_COM *));
83 #if defined (ARITH_FOR_COMMAND)
84 static void print_arith_for_command __P((ARITH_FOR_COM *));
86 #if defined (SELECT_COMMAND)
87 static void print_select_command __P((SELECT_COM *));
89 static void print_group_command __P((GROUP_COM *));
90 static void print_case_command __P((CASE_COM *));
91 static void print_while_command __P((WHILE_COM *));
92 static void print_until_command __P((WHILE_COM *));
93 static void print_until_or_while __P((WHILE_COM *, char *));
94 static void print_if_command __P((IF_COM *));
95 #if defined (COND_COMMAND)
96 static void print_cond_node __P((COND_COM *));
98 static void print_function_def __P((FUNCTION_DEF *));
100 #define PRINTED_COMMAND_INITIAL_SIZE 64
101 #define PRINTED_COMMAND_GROW_SIZE 128
103 char *the_printed_command = (char *)NULL;
104 int the_printed_command_size = 0;
105 int command_string_index = 0;
107 /* Non-zero means the stuff being printed is inside of a function def. */
108 static int inside_function_def;
109 static int skip_this_indent;
110 static int was_heredoc;
112 /* The depth of the group commands that we are currently printing. This
113 includes the group command that is a function body. */
114 static int group_command_nesting;
116 /* A buffer to indicate the indirection level (PS4) when set -x is enabled. */
117 static char indirection_string[100];
119 /* Print COMMAND (a command tree) on standard output. */
121 print_command (command)
124 command_string_index = 0;
125 printf ("%s", make_command_string (command));
128 /* Make a string which is the printed representation of the command
129 tree in COMMAND. We return this string. However, the string is
130 not consed, so you have to do that yourself if you want it to
133 make_command_string (command)
136 command_string_index = was_heredoc = 0;
137 make_command_string_internal (command);
138 return (the_printed_command);
141 /* The internal function. This is the real workhorse. */
143 make_command_string_internal (command)
150 if (skip_this_indent)
153 indent (indentation);
155 if (command->flags & CMD_TIME_PIPELINE)
158 if (command->flags & CMD_TIME_POSIX)
162 if (command->flags & CMD_INVERT_RETURN)
165 switch (command->type)
168 print_for_command (command->value.For);
171 #if defined (ARITH_FOR_COMMAND)
173 print_arith_for_command (command->value.ArithFor);
177 #if defined (SELECT_COMMAND)
179 print_select_command (command->value.Select);
184 print_case_command (command->value.Case);
188 print_while_command (command->value.While);
192 print_until_command (command->value.While);
196 print_if_command (command->value.If);
199 #if defined (DPAREN_ARITHMETIC)
201 print_arith_command (command->value.Arith->exp);
205 #if defined (COND_COMMAND)
207 print_cond_command (command->value.Cond);
212 print_simple_command (command->value.Simple);
218 make_command_string_internal (command->value.Connection->first);
220 switch (command->value.Connection->connector)
225 char c = command->value.Connection->connector;
227 if (c != '&' || command->value.Connection->second)
237 if (command->value.Connection->second)
243 if (command->value.Connection->second)
248 if (was_heredoc == 0)
253 if (inside_function_def)
258 if (command->value.Connection->second)
264 cprintf (_("print_command: bad connector `%d'"),
265 command->value.Connection->connector);
269 make_command_string_internal (command->value.Connection->second);
272 case cm_function_def:
273 print_function_def (command->value.Function_def);
277 print_group_command (command->value.Group);
283 make_command_string_internal (command->value.Subshell->command);
288 command_error ("print_command", CMDERR_BADTYPE, command->type, 0);
293 if (command->redirects)
296 print_redirection_list (command->redirects);
302 _print_word_list (list, separator, pfunc)
309 for (w = list; w; w = w->next)
310 (*pfunc) ("%s%s", w->word->word, w->next ? separator : "");
314 print_word_list (list, separator)
318 _print_word_list (list, separator, xprintf);
321 /* Return a string denoting what our indirection level is. */
324 indirection_level_string ()
328 char ps4_firstc[MB_LEN_MAX+1];
329 int ps4_firstc_len, ps4_len;
331 indirection_string[0] = '\0';
332 ps4 = get_string_value ("PS4");
334 if (ps4 == 0 || *ps4 == '\0')
335 return (indirection_string);
337 change_flag ('x', FLAG_OFF);
338 ps4 = decode_prompt_string (ps4);
339 change_flag ('x', FLAG_ON);
341 if (ps4 == 0 || *ps4 == '\0')
342 return (indirection_string);
344 #if defined (HANDLE_MULTIBYTE)
345 ps4_len = strnlen (ps4, MB_CUR_MAX);
346 ps4_firstc_len = MBLEN (ps4, ps4_len);
347 if (ps4_firstc_len == 1 || ps4_firstc_len == 0 || MB_INVALIDCH (ps4_firstc_len))
349 ps4_firstc[0] = ps4[0];
350 ps4_firstc[ps4_firstc_len = 1] = '\0';
353 memcpy (ps4_firstc, ps4, ps4_firstc_len);
355 ps4_firstc[0] = ps4[0];
356 ps4_firstc[ps4_firstc_len = 1] = '\0';
359 for (i = j = 0; ps4_firstc[0] && j < indirection_level && i < 99; i += ps4_firstc_len, j++)
361 if (ps4_firstc_len == 1)
362 indirection_string[i] = ps4_firstc[0];
364 memcpy (indirection_string+i, ps4_firstc, ps4_firstc_len);
367 for (j = ps4_firstc_len; *ps4 && ps4[j] && i < 99; i++, j++)
368 indirection_string[i] = ps4[j];
370 indirection_string[i] = '\0';
372 return (indirection_string);
376 xtrace_print_assignment (name, value, assign_list, xflags)
378 int assign_list, xflags;
383 fprintf (stderr, "%s", indirection_level_string ());
385 /* VALUE should not be NULL when this is called. */
386 if (*value == '\0' || assign_list)
388 else if (sh_contains_shell_metas (value))
389 nval = sh_single_quote (value);
390 else if (ansic_shouldquote (value))
391 nval = ansic_quote (value, 0, (int *)0);
396 fprintf (stderr, "%s=(%s)\n", name, nval);
398 fprintf (stderr, "%s=%s\n", name, nval);
406 /* A function to print the words of a simple command when set -x is on. */
408 xtrace_print_word_list (list, xtflags)
416 fprintf (stderr, "%s", indirection_level_string ());
418 for (w = list; w; w = w->next)
421 if (t == 0 || *t == '\0')
422 fprintf (stderr, "''%s", w->next ? " " : "");
423 else if (sh_contains_shell_metas (t))
425 x = sh_single_quote (t);
426 fprintf (stderr, "%s%s", x, w->next ? " " : "");
429 else if (ansic_shouldquote (t))
431 x = ansic_quote (t, 0, (int *)0);
432 fprintf (stderr, "%s%s", x, w->next ? " " : "");
436 fprintf (stderr, "%s%s", t, w->next ? " " : "");
438 fprintf (stderr, "\n");
442 command_print_word_list (list, separator)
446 _print_word_list (list, separator, cprintf);
450 print_for_command_head (for_command)
451 FOR_COM *for_command;
453 cprintf ("for %s in ", for_command->name->word);
454 command_print_word_list (for_command->map_list, " ");
458 xtrace_print_for_command_head (for_command)
459 FOR_COM *for_command;
461 fprintf (stderr, "%s", indirection_level_string ());
462 fprintf (stderr, "for %s in ", for_command->name->word);
463 xtrace_print_word_list (for_command->map_list, 0);
467 print_for_command (for_command)
468 FOR_COM *for_command;
470 print_for_command_head (for_command);
474 indentation += indentation_amount;
475 make_command_string_internal (for_command->action);
477 indentation -= indentation_amount;
481 #if defined (ARITH_FOR_COMMAND)
483 print_arith_for_command (arith_for_command)
484 ARITH_FOR_COM *arith_for_command;
487 command_print_word_list (arith_for_command->init, " ");
489 command_print_word_list (arith_for_command->test, " ");
491 command_print_word_list (arith_for_command->step, " ");
494 indentation += indentation_amount;
495 make_command_string_internal (arith_for_command->action);
497 indentation -= indentation_amount;
500 #endif /* ARITH_FOR_COMMAND */
502 #if defined (SELECT_COMMAND)
504 print_select_command_head (select_command)
505 SELECT_COM *select_command;
507 cprintf ("select %s in ", select_command->name->word);
508 command_print_word_list (select_command->map_list, " ");
512 xtrace_print_select_command_head (select_command)
513 SELECT_COM *select_command;
515 fprintf (stderr, "%s", indirection_level_string ());
516 fprintf (stderr, "select %s in ", select_command->name->word);
517 xtrace_print_word_list (select_command->map_list, 0);
521 print_select_command (select_command)
522 SELECT_COM *select_command;
524 print_select_command_head (select_command);
528 indentation += indentation_amount;
529 make_command_string_internal (select_command->action);
531 indentation -= indentation_amount;
534 #endif /* SELECT_COMMAND */
537 print_group_command (group_command)
538 GROUP_COM *group_command;
540 group_command_nesting++;
543 if (inside_function_def == 0)
547 /* This is a group command { ... } inside of a function
548 definition, and should be printed as a multiline group
549 command, using the current indentation. */
551 indentation += indentation_amount;
554 make_command_string_internal (group_command->command);
556 if (inside_function_def)
559 indentation -= indentation_amount;
560 indent (indentation);
570 group_command_nesting--;
574 print_case_command_head (case_command)
575 CASE_COM *case_command;
577 cprintf ("case %s in ", case_command->word->word);
581 xtrace_print_case_command_head (case_command)
582 CASE_COM *case_command;
584 fprintf (stderr, "%s", indirection_level_string ());
585 fprintf (stderr, "case %s in\n", case_command->word->word);
589 print_case_command (case_command)
590 CASE_COM *case_command;
592 print_case_command_head (case_command);
594 if (case_command->clauses)
595 print_case_clauses (case_command->clauses);
600 print_case_clauses (clauses)
601 PATTERN_LIST *clauses;
603 indentation += indentation_amount;
607 command_print_word_list (clauses->patterns, " | ");
609 indentation += indentation_amount;
610 make_command_string_internal (clauses->action);
611 indentation -= indentation_amount;
613 clauses = clauses->next;
615 indentation -= indentation_amount;
619 print_while_command (while_command)
620 WHILE_COM *while_command;
622 print_until_or_while (while_command, "while");
626 print_until_command (while_command)
627 WHILE_COM *while_command;
629 print_until_or_while (while_command, "until");
633 print_until_or_while (while_command, which)
634 WHILE_COM *while_command;
637 cprintf ("%s ", which);
639 make_command_string_internal (while_command->test);
641 cprintf (" do\n"); /* was newline ("do\n"); */
642 indentation += indentation_amount;
643 make_command_string_internal (while_command->action);
644 indentation -= indentation_amount;
650 print_if_command (if_command)
655 make_command_string_internal (if_command->test);
658 indentation += indentation_amount;
659 make_command_string_internal (if_command->true_case);
660 indentation -= indentation_amount;
662 if (if_command->false_case)
666 indentation += indentation_amount;
667 make_command_string_internal (if_command->false_case);
668 indentation -= indentation_amount;
674 #if defined (DPAREN_ARITHMETIC)
676 print_arith_command (arith_cmd_list)
677 WORD_LIST *arith_cmd_list;
680 command_print_word_list (arith_cmd_list, " ");
685 #if defined (COND_COMMAND)
687 print_cond_node (cond)
690 if (cond->flags & CMD_INVERT_RETURN)
693 if (cond->type == COND_EXPR)
696 print_cond_node (cond->left);
699 else if (cond->type == COND_AND)
701 print_cond_node (cond->left);
703 print_cond_node (cond->right);
705 else if (cond->type == COND_OR)
707 print_cond_node (cond->left);
709 print_cond_node (cond->right);
711 else if (cond->type == COND_UNARY)
713 cprintf ("%s", cond->op->word);
715 print_cond_node (cond->left);
717 else if (cond->type == COND_BINARY)
719 print_cond_node (cond->left);
721 cprintf ("%s", cond->op->word);
723 print_cond_node (cond->right);
725 else if (cond->type == COND_TERM)
727 cprintf ("%s", cond->op->word); /* need to add quoting here */
732 print_cond_command (cond)
736 print_cond_node (cond);
742 debug_print_cond_command (cond)
745 fprintf (stderr, "DEBUG: ");
746 command_string_index = 0;
747 print_cond_command (cond);
748 fprintf (stderr, "%s\n", the_printed_command);
753 xtrace_print_cond_term (type, invert, op, arg1, arg2)
758 command_string_index = 0;
759 fprintf (stderr, "%s", indirection_level_string ());
760 fprintf (stderr, "[[ ");
762 fprintf (stderr, "! ");
764 if (type == COND_UNARY)
766 fprintf (stderr, "%s ", op->word);
767 fprintf (stderr, "%s", (arg1 && *arg1) ? arg1 : "''");
769 else if (type == COND_BINARY)
771 fprintf (stderr, "%s", (arg1 && *arg1) ? arg1 : "''");
772 fprintf (stderr, " %s ", op->word);
773 fprintf (stderr, "%s", (arg2 && *arg2) ? arg2 : "''");
776 fprintf (stderr, " ]]\n");
778 #endif /* COND_COMMAND */
780 #if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
781 /* A function to print the words of an arithmetic command when set -x is on. */
783 xtrace_print_arith_cmd (list)
788 fprintf (stderr, "%s", indirection_level_string ());
789 fprintf (stderr, "(( ");
790 for (w = list; w; w = w->next)
791 fprintf (stderr, "%s%s", w->word->word, w->next ? " " : "");
792 fprintf (stderr, " ))\n");
797 print_simple_command (simple_command)
798 SIMPLE_COM *simple_command;
800 command_print_word_list (simple_command->words, " ");
802 if (simple_command->redirects)
805 print_redirection_list (simple_command->redirects);
810 print_redirection_list (redirects)
813 REDIRECT *heredocs, *hdtail, *newredir;
815 heredocs = (REDIRECT *)NULL;
821 /* Defer printing the here documents until we've printed the
822 rest of the redirections. */
823 if (redirects->instruction == r_reading_until || redirects->instruction == r_deblank_reading_until)
825 newredir = copy_redirect (redirects);
826 newredir->next = (REDIRECT *)NULL;
829 hdtail->next = newredir;
833 hdtail = heredocs = newredir;
835 else if (redirects->instruction == r_duplicating_output_word && redirects->redirector == 1)
837 /* Temporarily translate it as the execution code does. */
838 redirects->instruction = r_err_and_out;
839 print_redirection (redirects);
840 redirects->instruction = r_duplicating_output_word;
843 print_redirection (redirects);
845 redirects = redirects->next;
850 /* Now that we've printed all the other redirections (on one line),
851 print the here documents. */
855 for (hdtail = heredocs; hdtail; hdtail = hdtail->next)
857 print_redirection (hdtail);
860 dispose_redirects (heredocs);
866 print_redirection (redirect)
869 int kill_leading, redirector, redir_fd;
870 WORD_DESC *redirectee;
873 redirectee = redirect->redirectee.filename;
874 redirector = redirect->redirector;
875 redir_fd = redirect->redirectee.dest;
877 switch (redirect->instruction)
879 case r_output_direction:
881 cprintf ("%d", redirector);
882 cprintf (">%s", redirectee->word);
885 case r_input_direction:
887 cprintf ("%d", redirector);
888 cprintf ("<%s", redirectee->word);
891 case r_inputa_direction: /* Redirection created by the shell. */
897 cprintf ("%d", redirector);
898 cprintf (">>%s", redirectee->word);
901 case r_deblank_reading_until:
904 case r_reading_until:
906 cprintf ("%d", redirector);
907 /* If the here document delimiter is quoted, single-quote it. */
908 if (redirect->redirectee.filename->flags & W_QUOTED)
911 x = sh_single_quote (redirect->here_doc_eof);
912 cprintf ("<<%s%s\n", kill_leading? "-" : "", x);
916 cprintf ("<<%s%s\n", kill_leading? "-" : "", redirect->here_doc_eof);
918 redirect->redirectee.filename->word, redirect->here_doc_eof);
921 case r_reading_string:
923 cprintf ("%d", redirector);
924 if (ansic_shouldquote (redirect->redirectee.filename->word))
927 x = ansic_quote (redirect->redirectee.filename->word, 0, (int *)0);
928 cprintf ("<<< %s", x);
932 cprintf ("<<< %s", redirect->redirectee.filename->word);
935 case r_duplicating_input:
936 cprintf ("%d<&%d", redirector, redir_fd);
939 case r_duplicating_output:
940 cprintf ("%d>&%d", redirector, redir_fd);
943 case r_duplicating_input_word:
944 cprintf ("%d<&%s", redirector, redirectee->word);
947 case r_duplicating_output_word:
948 cprintf ("%d>&%s", redirector, redirectee->word);
952 cprintf ("%d<&%d-", redirector, redir_fd);
956 cprintf ("%d>&%d-", redirector, redir_fd);
959 case r_move_input_word:
960 cprintf ("%d<&%s-", redirector, redirectee->word);
963 case r_move_output_word:
964 cprintf ("%d>&%s-", redirector, redirectee->word);
968 cprintf ("%d>&-", redirector);
972 cprintf (">&%s", redirectee->word);
977 cprintf ("%d", redirector);
978 cprintf ("<>%s", redirectee->word);
983 cprintf ("%d", redirector);
984 cprintf (">|%s", redirectee->word);
992 inside_function_def = 0;
997 print_function_def (func)
1001 REDIRECT *func_redirects;
1003 func_redirects = NULL;
1004 cprintf ("function %s () \n", func->name->word);
1005 add_unwind_protect (reset_locals, 0);
1007 indent (indentation);
1010 inside_function_def++;
1011 indentation += indentation_amount;
1013 cmdcopy = copy_command (func->command);
1014 if (cmdcopy->type == cm_group)
1016 func_redirects = cmdcopy->redirects;
1017 cmdcopy->redirects = (REDIRECT *)NULL;
1019 make_command_string_internal (cmdcopy->type == cm_group
1020 ? cmdcopy->value.Group->command
1023 remove_unwind_protect ();
1024 indentation -= indentation_amount;
1025 inside_function_def--;
1030 print_redirection_list (func_redirects);
1031 cmdcopy->redirects = func_redirects;
1036 dispose_command (cmdcopy);
1039 /* Return the string representation of the named function.
1040 NAME is the name of the function.
1041 COMMAND is the function body. It should be a GROUP_COM.
1042 MULTI_LINE is non-zero to pretty-print, or zero for all on one line.
1045 named_function_string (name, command, multi_line)
1051 int old_indent, old_amount;
1053 REDIRECT *func_redirects;
1055 old_indent = indentation;
1056 old_amount = indentation_amount;
1057 command_string_index = was_heredoc = 0;
1060 cprintf ("%s ", name);
1064 if (multi_line == 0)
1067 indentation_amount = 0;
1072 indentation += indentation_amount;
1075 inside_function_def++;
1077 cprintf (multi_line ? "{ \n" : "{ ");
1079 cmdcopy = copy_command (command);
1080 /* Take any redirections specified in the function definition (which should
1081 apply to the function as a whole) and save them for printing later. */
1082 func_redirects = (REDIRECT *)NULL;
1083 if (cmdcopy->type == cm_group)
1085 func_redirects = cmdcopy->redirects;
1086 cmdcopy->redirects = (REDIRECT *)NULL;
1088 make_command_string_internal (cmdcopy->type == cm_group
1089 ? cmdcopy->value.Group->command
1092 indentation = old_indent;
1093 indentation_amount = old_amount;
1094 inside_function_def--;
1099 print_redirection_list (func_redirects);
1100 cmdcopy->redirects = func_redirects;
1105 result = the_printed_command;
1111 for (i = 0; result[i]; i++)
1112 if (result[i] == '\n')
1114 strcpy (result + i, result + i + 1);
1118 if (result[2] == '\n') /* XXX -- experimental */
1119 strcpy (result + 2, result + 3);
1123 dispose_command (cmdcopy);
1133 indent (indentation);
1134 if (string && *string)
1135 cprintf ("%s", string);
1138 static char *indentation_string;
1139 static int indentation_size;
1147 RESIZE_MALLOCED_BUFFER (indentation_string, 0, amount, indentation_size, 16);
1149 for (i = 0; amount > 0; amount--)
1150 indentation_string[i++] = ' ';
1151 indentation_string[i] = '\0';
1152 cprintf (indentation_string);
1158 if (command_string_index > 0 &&
1159 (the_printed_command[command_string_index - 1] == '&' ||
1160 the_printed_command[command_string_index - 1] == '\n'))
1165 /* How to make the string. */
1167 #if defined (PREFER_STDARG)
1168 cprintf (const char *control, ...)
1170 cprintf (control, va_alist)
1171 const char *control;
1175 register const char *s;
1176 char char_arg[2], *argp, intbuf[INT_STRLEN_BOUND (int) + 1];
1177 int digit_arg, arg_len, c;
1180 SH_VA_START (args, control);
1182 arg_len = strlen (control);
1183 the_printed_command_resize (arg_len + 1);
1190 argp = (char *)NULL;
1191 if (c != '%' || !*s)
1209 argp = va_arg (args, char *);
1210 arg_len = strlen (argp);
1214 /* Represent an out-of-range file descriptor with an out-of-range
1215 integer value. We can do this because the only use of `%d' in
1216 the calls to cprintf is to output a file descriptor number for
1218 digit_arg = va_arg (args, int);
1221 sprintf (intbuf, "%u", (unsigned)-1);
1225 argp = inttostr (digit_arg, intbuf, sizeof (intbuf));
1226 arg_len = strlen (argp);
1230 char_arg[0] = va_arg (args, int);
1236 programming_error (_("cprintf: `%c': invalid format character"), c);
1241 if (argp && arg_len)
1243 the_printed_command_resize (arg_len + 1);
1244 FASTCOPY (argp, the_printed_command + command_string_index, arg_len);
1245 command_string_index += arg_len;
1249 the_printed_command[command_string_index] = '\0';
1252 /* Ensure that there is enough space to stuff LENGTH characters into
1253 THE_PRINTED_COMMAND. */
1255 the_printed_command_resize (length)
1258 if (the_printed_command == 0)
1260 the_printed_command_size = (length + PRINTED_COMMAND_INITIAL_SIZE - 1) & ~(PRINTED_COMMAND_INITIAL_SIZE - 1);
1261 the_printed_command = (char *)xmalloc (the_printed_command_size);
1262 command_string_index = 0;
1264 else if ((command_string_index + length) >= the_printed_command_size)
1267 new = command_string_index + length + 1;
1269 /* Round up to the next multiple of PRINTED_COMMAND_GROW_SIZE. */
1270 new = (new + PRINTED_COMMAND_GROW_SIZE - 1) & ~(PRINTED_COMMAND_GROW_SIZE - 1);
1271 the_printed_command_size = new;
1273 the_printed_command = (char *)xrealloc (the_printed_command, the_printed_command_size);
1277 #if defined (HAVE_VPRINTF)
1278 /* ``If vprintf is available, you may assume that vfprintf and vsprintf are
1279 also available.'' */
1282 #if defined (PREFER_STDARG)
1283 xprintf (const char *format, ...)
1285 xprintf (format, va_alist)
1292 SH_VA_START (args, format);
1294 vfprintf (stdout, format, args);
1301 xprintf (format, arg1, arg2, arg3, arg4, arg5)
1304 printf (format, arg1, arg2, arg3, arg4, arg5);
1307 #endif /* !HAVE_VPRINTF */