VirtualBox

Changeset 769 in kBuild


Ignore:
Timestamp:
Jan 19, 2007 4:41:59 AM (18 years ago)
Author:
bird
Message:

Added variable lookup printing to delay expansion and such.

File:
1 edited

Legend:

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

    r767 r769  
    2929#include "err.h"
    3030#include "kmkbuiltin.h"
     31#ifndef kmk_builtin_append
     32# include "make.h"
     33# include "variable.h"
     34#endif
    3135
    3236
     
    3640static int usage(void)
    3741{
    38     fprintf(stderr, "usage: append [-n] file [string ...]\n");
     42    fprintf(stderr, "usage: append [-nv] file [string ...]\n");
    3943    return 1;
    4044}
     
    5054    FILE *pFile;
    5155    int fNewLine = 0;
     56#ifndef kmk_builtin_append
     57    int fVariables = 0;
     58#endif
    5259
    5360    g_progname = argv[0];
     
    6067       &&  argv[i][0] == '-'
    6168       &&  argv[i][1] != '\0' /* '-' is a file */
    62        &&  strchr("n", argv[i][1]) /* valid option char */
     69       &&  strchr("nv", argv[i][1]) /* valid option char */
    6370       )
    6471    {
     
    7178                    fNewLine = 1;
    7279                    break;
     80                case 'v':
     81#ifndef kmk_builtin_append
     82                    fVariables = 1;
     83                    break;
     84#else
     85                    errx(1, "Option '-v' isn't supported in external mode.");
     86                    return usage();
     87#endif
    7388                default:
    7489                    errx(1, "Invalid option '%c'! (%s)", *psz, argv[i]);
     
    101116        if (!fFirst)
    102117            fputc(fNewLine ? '\n' : ' ', pFile);
     118#ifndef kmk_builtin_append
     119        if (fVariables)
     120        {
     121            struct variable *pVar = lookup_variable(psz, cch);
     122            if (!pVar)
     123                continue;
     124            if (    pVar->recursive
     125                &&  memchr(pVar->value, '$', pVar->value_length))
     126            {
     127                char *pszExpanded = allocated_variable_expand(pVar->value);
     128                fwrite(pszExpanded, 1, strlen(pszExpanded), pFile);
     129                free(pszExpanded);
     130            }
     131            else
     132                fwrite(pVar->value, 1, pVar->value_length, pFile);
     133        }
    103134        else
    104             fFirst = 0;
    105         fwrite(psz, 1, cch, pFile);
     135#endif
     136            fwrite(psz, 1, cch, pFile);
     137        fFirst = 0;
    106138    }
    107139
Note: See TracChangeset for help on using the changeset viewer.

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