Ignore:
Timestamp:
Mar 30, 2008, 6:13:55 AM (17 years ago)
Author:
bird
Message:

Added comp-cmds-ex, commands, commands-sc and commands-usr. Added a '%' command prefix that make the commands functions skip the line. Added a -c flag to append that'll make it call commands on each argument (similar to -v). Fixed a little bug in comp-cmds/vars.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/append.c

    r1183 r1440  
    4242{
    4343    fprintf(pf,
    44             "usage: %s [-nv] file [string ...]\n"
     44            "usage: %s [-cnv] file [string ...]\n"
    4545            "   or: %s --version\n"
    4646            "   or: %s --help\n",
     
    6161#ifndef kmk_builtin_append
    6262    int fVariables = 0;
     63    int fCommands = 0;
    6364#endif
    6465
     
    8283                switch (*psz)
    8384                {
     85                    case 'c':
     86#ifndef kmk_builtin_append
     87                        fCommands = 1;
     88                        break;
     89#else
     90                        errx(1, "Option '-c' isn't supported in external mode.");
     91                        return usage(stderr);
     92#endif
    8493                    case 'n':
    8594                        fNewLine = 1;
     
    134143            fputc(fNewLine ? '\n' : ' ', pFile);
    135144#ifndef kmk_builtin_append
    136         if (fVariables)
     145        if (fCommands)
     146        {
     147            char *pszOldBuf;
     148            unsigned cchOldBuf;
     149            char *pchEnd;
     150
     151            install_variable_buffer(&pszOldBuf, &cchOldBuf);
     152
     153            pchEnd = func_commands(variable_buffer, &argv[i], "commands");
     154            fwrite(variable_buffer, 1, pchEnd - variable_buffer, pFile);
     155
     156            restore_variable_buffer(pszOldBuf, cchOldBuf);
     157        }
     158        else if (fVariables)
    137159        {
    138160            struct variable *pVar = lookup_variable(psz, cch);
Note: See TracChangeset for help on using the changeset viewer.