mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-20 05:17:54 +00:00
df94f6803f
This commit introduces the following upstream changes: fd65465b7016 kconfig: do not require pkg-config on make {menu,n}config bc8d2e20a3eb kconfig: remove a spurious self-assignment 9a9ddcf47831 kconfig: suppress "configuration written to .config" for syncconfig 98a4afbfafd2 kconfig: fix "Can't open ..." in parallel build f498926c47aa kconfig: improve the recursive dependency report 5e8c5299d315 kconfig: report recursive dependency involving 'imply' f1575595d156 kconfig: error out when seeing recursive dependency 4bf6a9af0e91 kconfig: add build-only configurator targets 1880861226c1 kconfig: remove P_ENV property type c151272d1687 kconfig: remove unused sym_get_env_prop() function 56869d45e364 kconfig: fix the rule of mainmenu_stmt symbol 00c864f8903d kconfig: allow all config targets to write auto.conf if missing 16952b77d8b5 kconfig: make syncconfig update .config regardless of sym_change_count 79123b1389cc kconfig: create directories needed for syncconfig by itself adc18acf42a1 kconfig: remove unneeded directory generation from local*config 0608182ad542 kconfig: split out useful helpers in confdata.c a2ff4040151a kconfig: rename file_write_dep and move it to confdata.c 5accd7f3360e kconfig: handle format string before calling conf_message_callback() 693359f7ac90 kconfig: rename SYMBOL_AUTO to SYMBOL_NO_WRITE 4ab3b80159d4 kconfig: check for pkg-config on make {menu,n,g,x}config 8377bd2b9ee1 kbuild: Rename HOST_LOADLIBES to KBUILD_HOSTLDLIBS Signed-off-by: Chris Packham <judge.packham@gmail.com>
131 lines
2.2 KiB
C
131 lines
2.2 KiB
C
/*
|
|
* Copyright (C) 2002-2005 Roman Zippel <zippel@linux-m68k.org>
|
|
* Copyright (C) 2002-2005 Sam Ravnborg <sam@ravnborg.org>
|
|
*
|
|
* Released under the terms of the GNU GPL v2.0.
|
|
*/
|
|
|
|
#include <stdarg.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "lkc.h"
|
|
|
|
/* file already present in list? If not add it */
|
|
struct file *file_lookup(const char *name)
|
|
{
|
|
struct file *file;
|
|
|
|
for (file = file_list; file; file = file->next) {
|
|
if (!strcmp(name, file->name)) {
|
|
return file;
|
|
}
|
|
}
|
|
|
|
file = xmalloc(sizeof(*file));
|
|
memset(file, 0, sizeof(*file));
|
|
file->name = xstrdup(name);
|
|
file->next = file_list;
|
|
file_list = file;
|
|
return file;
|
|
}
|
|
|
|
/* Allocate initial growable string */
|
|
struct gstr str_new(void)
|
|
{
|
|
struct gstr gs;
|
|
gs.s = xmalloc(sizeof(char) * 64);
|
|
gs.len = 64;
|
|
gs.max_width = 0;
|
|
strcpy(gs.s, "\0");
|
|
return gs;
|
|
}
|
|
|
|
/* Free storage for growable string */
|
|
void str_free(struct gstr *gs)
|
|
{
|
|
if (gs->s)
|
|
free(gs->s);
|
|
gs->s = NULL;
|
|
gs->len = 0;
|
|
}
|
|
|
|
/* Append to growable string */
|
|
void str_append(struct gstr *gs, const char *s)
|
|
{
|
|
size_t l;
|
|
if (s) {
|
|
l = strlen(gs->s) + strlen(s) + 1;
|
|
if (l > gs->len) {
|
|
gs->s = xrealloc(gs->s, l);
|
|
gs->len = l;
|
|
}
|
|
strcat(gs->s, s);
|
|
}
|
|
}
|
|
|
|
/* Append printf formatted string to growable string */
|
|
void str_printf(struct gstr *gs, const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
char s[10000]; /* big enough... */
|
|
va_start(ap, fmt);
|
|
vsnprintf(s, sizeof(s), fmt, ap);
|
|
str_append(gs, s);
|
|
va_end(ap);
|
|
}
|
|
|
|
/* Retrieve value of growable string */
|
|
const char *str_get(struct gstr *gs)
|
|
{
|
|
return gs->s;
|
|
}
|
|
|
|
void *xmalloc(size_t size)
|
|
{
|
|
void *p = malloc(size);
|
|
if (p)
|
|
return p;
|
|
fprintf(stderr, "Out of memory.\n");
|
|
exit(1);
|
|
}
|
|
|
|
void *xcalloc(size_t nmemb, size_t size)
|
|
{
|
|
void *p = calloc(nmemb, size);
|
|
if (p)
|
|
return p;
|
|
fprintf(stderr, "Out of memory.\n");
|
|
exit(1);
|
|
}
|
|
|
|
void *xrealloc(void *p, size_t size)
|
|
{
|
|
p = realloc(p, size);
|
|
if (p)
|
|
return p;
|
|
fprintf(stderr, "Out of memory.\n");
|
|
exit(1);
|
|
}
|
|
|
|
char *xstrdup(const char *s)
|
|
{
|
|
char *p;
|
|
|
|
p = strdup(s);
|
|
if (p)
|
|
return p;
|
|
fprintf(stderr, "Out of memory.\n");
|
|
exit(1);
|
|
}
|
|
|
|
char *xstrndup(const char *s, size_t n)
|
|
{
|
|
char *p;
|
|
|
|
p = strndup(s, n);
|
|
if (p)
|
|
return p;
|
|
fprintf(stderr, "Out of memory.\n");
|
|
exit(1);
|
|
}
|