public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Verych <olecom@flower.upol.cz>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Ingo Molnar <mingo@elte.hu>, Sergio Luis <sergio@uece.br>,
	Parag Warudkar <parag.warudkar@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	"akpm@osdl.org" <akpm@osdl.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Arjan van de Ven <arjan@infradead.org>,
	Dave Jones <davej@redhat.com>,
	linux-kbuild <linux-kbuild@vger.kernel.org>
Subject: Re: [PATCH] kconfig: add support for stdin (make K=- ...)
Date: Tue, 6 May 2008 05:51:08 +0200	[thread overview]
Message-ID: <20080506035108.GD24008@flower.upol.cz> (raw)
In-Reply-To: <20080505194929.GA8868@uranus.ravnborg.org>

Sam Ravnborg @ Mon, May 05, 2008 at 09:49:29PM +0200:
[]
> > i think the 'natural' script behavior would be for this to do the right 
> > thing:
> > 
> >    zcat /proc/config.gz | make K=- alldefconfig
> > 
> > or something like that - so that it can be scripted in a pipe.
> 
> I like this ;-)
> So I implemented support for stdin - see attached.
> It is also in kbuild.git.

Isn't /dev/stdin (or link to /proc) supported everywhere already?

> +	if (strcmp(config_file, "-")) {

full strcmp() for just one symbol?

> +		if (config_file && stat(config_file, &tmpstat)) {
> +			fprintf(stderr, _("%s: failed to open %s\n"),
> +			        av[0], config_file);
> +			exit(1);
> +		}
> +		config_filename = config_file;
> +	} else {
> +		config_filename = "stdin";
>  	}
> +
>  	if (config_file && conf_read_simple(config_file, S_DEF_USER)) {
>  		fprintf(stderr, _("%s: failed to read %s\n"),
> -		        av[0], config_file);
> +		        av[0], config_filename);
>  		exit(1);
>  	}
>  	if (config_file) {
>  		printf("#\n");
> -		printf(_("# configuration is based on '%s'\n"), config_file);
> +		printf(_("# configuration is based on '%s'\n"),
> +		       config_filename);
>  	}
>  	/* generate the config */
>  	do {
> diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped
> index 6a61cee..7bd00d3 100644
> --- a/scripts/kconfig/lex.zconf.c_shipped
> +++ b/scripts/kconfig/lex.zconf.c_shipped
> @@ -2268,13 +2268,17 @@ FILE *zconf_fopen(const char *name)
>  	char *env, fullname[PATH_MAX+1];
>  	FILE *f;
>  
> -	f = fopen(name, "r");
> -	if (!f && name != NULL && name[0] != '/') {
> -		env = getenv(SRCTREE);
> -		if (env) {
> -			sprintf(fullname, "%s/%s", env, name);
> -			f = fopen(fullname, "r");
> +	if (strcmp(name, "-")) {
> +		f = fopen(name, "r");
> +		if (!f && name != NULL && name[0] != '/') {
> +			env = getenv(SRCTREE);
> +			if (env) {
> +				sprintf(fullname, "%s/%s", env, name);
> +				f = fopen(fullname, "r");
> +			}
>  		}
> +	} else {
> +		f = stdin;
>  	}
>  	return f;
>  }
> diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
> index 4cea5c8..a268d88 100644
> --- a/scripts/kconfig/zconf.l
> +++ b/scripts/kconfig/zconf.l
> @@ -269,13 +269,17 @@ FILE *zconf_fopen(const char *name)
>  	char *env, fullname[PATH_MAX+1];
>  	FILE *f;
>  
> -	f = fopen(name, "r");
> -	if (!f && name != NULL && name[0] != '/') {
> -		env = getenv(SRCTREE);
> -		if (env) {
> -			sprintf(fullname, "%s/%s", env, name);
> -			f = fopen(fullname, "r");
> +	if (strcmp(name, "-")) {
> +		f = fopen(name, "r");
> +		if (!f && name != NULL && name[0] != '/') {
> +			env = getenv(SRCTREE);
> +			if (env) {
> +				sprintf(fullname, "%s/%s", env, name);
> +				f = fopen(fullname, "r");
> +			}
>  		}
> +	} else {
> +		f = stdin;
>  	}
>  	return f;

rather big diffstat for almost nothing. Userspacy?
____

  reply	other threads:[~2008-05-06  3:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-04  0:42 [PATCH] default to n for GROUP_SCHED and FAIR_GROUP_SCHED Parag Warudkar
2008-05-04  9:24 ` Ingo Molnar
2008-05-05 15:14   ` Parag Warudkar
2008-05-05 17:15     ` Ingo Molnar
2008-05-05 18:24       ` Sam Ravnborg
2008-05-05 18:36         ` Sergio Luis
2008-05-05 18:45           ` Ingo Molnar
2008-05-05 19:49             ` [PATCH] kconfig: add support for stdin (make K=- ...) Sam Ravnborg
2008-05-06  3:51               ` Oleg Verych [this message]
2008-05-05 19:05           ` [PATCH] default to n for GROUP_SCHED and FAIR_GROUP_SCHED Sam Ravnborg
2008-05-05 18:42         ` Ingo Molnar
2008-05-05 19:01           ` Sam Ravnborg
2008-05-05 19:56           ` Arjan van de Ven
2008-05-05 20:27             ` Ingo Molnar
2008-05-05 20:48               ` Linus Torvalds
2008-05-05 21:05                 ` Ingo Molnar
2008-05-05 21:40                   ` Parag Warudkar
2008-05-25 19:30       ` Roman Zippel
2008-05-05 17:21     ` Ingo Molnar
2008-05-05 17:33       ` Jesse Barnes
2008-05-05 18:36         ` Ingo Molnar
2008-05-05 21:36       ` Parag Warudkar
2008-05-05 21:49         ` Ingo Molnar
2008-05-06  0:38           ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080506035108.GD24008@flower.upol.cz \
    --to=olecom@flower.upol.cz \
    --cc=akpm@osdl.org \
    --cc=arjan@infradead.org \
    --cc=davej@redhat.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=parag.warudkar@gmail.com \
    --cc=peterz@infradead.org \
    --cc=sam@ravnborg.org \
    --cc=sergio@uece.br \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox