VirtualBox

Changeset 1301 in kBuild for trunk/src


Ignore:
Timestamp:
Dec 1, 2007 10:35:55 PM (17 years ago)
Author:
bird
Message:

Added options for sending the output to a file without having to make use of redirection (-o, --output, --output-text, --output-binary).

Location:
trunk/src/sed/sed
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sed/sed/compile.c

    r599 r1301  
    405405      /* std* sometimes are not constants, so they
    406406         cannot be used in the initializer for special_files */
     407#ifndef CONFIG_WITHOUT_O_OPT
     408      my_stdin = stdin; my_stdout = sed_stdout; my_stderr = stderr;
     409#else
    407410      my_stdin = stdin; my_stdout = stdout; my_stderr = stderr;
     411#endif
    408412      for (special = special_files; special->outf.name; special++)
    409413        if (strcmp(special->outf.name, file_name) == 0)
  • trunk/src/sed/sed/execute.c

    r599 r1301  
    504504  FILE *fp;
    505505{
     506#ifndef CONFIG_WITHOUT_O_OPT
     507  if (fp != sed_stdout || unbuffered_output)
     508#else
    506509  if (fp != stdout || unbuffered_output)
     510#endif
    507511    ck_fflush(fp);
    508512}
     
    699703    }
    700704  else
     705#ifndef CONFIG_WITHOUT_O_OPT
     706    output_file.fp = sed_stdout;
     707#else
    701708    output_file.fp = stdout;
     709#endif
    702710}
    703711
  • trunk/src/sed/sed/sed.c

    r1188 r1301  
    6161
    6262int extended_regexp_flags = 0;
     63
     64#ifndef CONFIG_WITHOUT_O_OPT
     65/* The output file, defaults to stdout but can be overridden
     66   by the -o or --output option. main sets this to avoid problems. */
     67FILE *sed_stdout = NULL;
     68#endif
    6369
    6470/* If set, fflush(stdout) on every line output. */
     
    112118  fprintf(out, _("  --posix\n\
    113119                 disable all GNU extensions.\n"));
     120#ifndef CONFIG_WITHOUT_O_OPT
     121  fprintf(out, _("  -o, --output=file, --output-text=file, --output-binary=file\n\
     122                 use the specified file instead of stdout; the first two uses\n\
     123                 uses the default text/binary mode.\n"));
     124#endif
    114125  fprintf(out, _("  -r, --regexp-extended\n\
    115126                 use extended regular expressions in the script.\n"));
     
    143154{
    144155#ifdef REG_PERL
     156# ifndef CONFIG_WITHOUT_O_OPT
     157#define SHORTOPTS "snrRue:f:l:i::o:V:"
     158# else
    145159#define SHORTOPTS "snrRue:f:l:i::V:"
    146 #else
     160# endif
     161#else
     162# ifndef CONFIG_WITHOUT_O_OPT
     163#define SHORTOPTS "snrue:f:l:i::o:V:"
     164# else
    147165#define SHORTOPTS "snrue:f:l:i::V:"
     166# endif
    148167#endif
    149168
     
    162181    {"separate", 0, NULL, 's'},
    163182    {"unbuffered", 0, NULL, 'u'},
     183#ifndef CONFIG_WITHOUT_O_OPT
     184    {"output", 1, NULL, 'o'},
     185    {"output-binary", 1, NULL, 300},
     186    {"output-text", 1, NULL, 301},
     187#endif
    164188    {"version", 0, NULL, 'v'},
    165189    {"help", 0, NULL, 'h'},
     
    172196
    173197  initialize_main (&argc, &argv);
     198#ifndef CONFIG_WITHOUT_O_OPT
     199  sed_stdout = stdout;
     200#endif
    174201#if HAVE_SETLOCALE
    175202  /* Set locale according to user's wishes.  */
     
    259286          break;
    260287
     288#ifndef CONFIG_WITHOUT_O_OPT
     289        case 'o':
     290          sed_stdout = ck_fopen (optarg, "w", true /* fail on error */);
     291          break;
     292
     293        case 300:
     294          sed_stdout = ck_fopen (optarg, "wb", true /* fail on error */);
     295          break;
     296
     297        case 301:
     298          sed_stdout = ck_fopen (optarg, "wt", true /* fail on error */);
     299          break;
     300#endif
     301
    261302        case 'p':
    262303          posixicity = POSIXLY_BASIC;
  • trunk/src/sed/sed/sed.h

    r599 r1301  
    212212extern int extended_regexp_flags;
    213213
     214#ifndef CONFIG_WITHOUT_O_OPT
     215/* The output file, defaults to stdout but can be overridden
     216   by the -o or --output option. main sets this to avoid problems. */
     217extern FILE *sed_stdout;
     218#endif
     219
    214220/* If set, fflush(stdout) on every line output. */
    215221extern bool unbuffered_output;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette