VirtualBox

source: kBuild/trunk/src/kmk/loadapi.c@ 3387

Last change on this file since 3387 was 3143, checked in by bird, 6 years ago

kmk: bootstrap fixes for linux.

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1/* API for GNU Make dynamic objects.
2Copyright (C) 2013-2016 Free Software Foundation, Inc.
3This file is part of GNU Make.
4
5GNU Make is free software; you can redistribute it and/or modify it under the
6terms of the GNU General Public License as published by the Free Software
7Foundation; either version 3 of the License, or (at your option) any later
8version.
9
10GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
11WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#include "makeint.h"
18
19#include "filedef.h"
20#include "variable.h"
21#include "dep.h"
22
23/* Allocate a buffer in our context, so we can free it. */
24char *
25gmk_alloc (unsigned int len)
26{
27 return xmalloc (len);
28}
29
30/* Free a buffer returned by gmk_expand(). */
31void
32gmk_free (char *s)
33{
34 free (s);
35}
36
37/* Evaluate a buffer as make syntax.
38 Ideally eval_buffer() will take const char *, but not yet. */
39void
40gmk_eval (const char *buffer, const gmk_floc *gfloc)
41{
42 /* Preserve existing variable buffer context. */
43 char *pbuf;
44 unsigned int plen;
45 char *s;
46 floc fl;
47 floc *flp;
48
49 if (gfloc)
50 {
51 fl.filenm = gfloc->filenm;
52 fl.lineno = gfloc->lineno;
53 fl.offset = 0;
54 flp = &fl;
55 }
56 else
57 flp = NULL;
58
59 install_variable_buffer (&pbuf, &plen);
60
61 s = xstrdup (buffer);
62 eval_buffer (s, flp IF_WITH_VALUE_LENGTH_PARAM (strlen (s) /** @todo suboptimal */));
63 free (s);
64
65 restore_variable_buffer (pbuf, plen);
66}
67
68/* Expand a string and return an allocated buffer.
69 Caller must call gmk_free() with this buffer. */
70char *
71gmk_expand (const char *ref)
72{
73 return allocated_variable_expand (ref);
74}
75
76/* Register a function to be called from makefiles. */
77void
78gmk_add_function (const char *name, gmk_func_ptr func,
79 unsigned int min, unsigned int max, unsigned int flags)
80{
81 define_new_function (reading_file, name, min, max, flags, func);
82}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use