Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.system > #406 > unrolled thread

Coreutils C question

Started by"Benjamin S." <niacin89@yahoo.com>
First post2012-03-19 23:44 +0000
Last post2014-09-23 06:46 -0700
Articles 6 — 5 participants

Back to article view | Back to comp.os.linux.development.system


Contents

  Coreutils C question "Benjamin S." <niacin89@yahoo.com> - 2012-03-19 23:44 +0000
    Re: Coreutils C question Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-03-20 00:19 +0000
    Re: Coreutils C question Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-03-20 02:04 +0000
      Re: Coreutils C question "Benjamin S." <niacin89@yahoo.com> - 2012-03-20 16:43 +0000
        Re: Coreutils C question Nix <nix-razor-pit@esperi.org.uk> - 2012-03-21 11:30 +0000
    Re: Coreutils C question indrajith.k@gmail.com - 2014-09-23 06:46 -0700

#406 — Coreutils C question

From"Benjamin S." <niacin89@yahoo.com>
Date2012-03-19 23:44 +0000
SubjectCoreutils C question
Message-ID<jk8gcr$ddq$1@dont-email.me>
Hi, I'm reading the source code for coreutils. There are a few things I 
don't understand. The current one is the function:

initialize_main (&argc, &argv);

The definition seems to be:


/* Redirection and wildcarding when done by the utility itself.
   Generally a noop, but used in particular for native VMS. */
#ifndef initialize_main
# define initialize_main(ac, av)
#endif



The changelog says:


2003-06-17  Jim Meyering  <jim@meyering.net>

	* src/system.h (initialize_main): Define.
	Use it in every `main'.  Applied via this:
	p='initialize_main (&argc, &argv);'
	perl -ni -e '/program_name.=.argv.0/ and print "  '"$p"'\n"; 
print' \
	  $(grep -l program_name.=.argv.0 *.c)
	test.c uses margc/margv, so I made the change manually for that 
file.
	Based on a patch from Bernard Giroud.


I really don't understand what it's doing. My current understanding is 
that it's doing nothing. Any help?

[toc] | [next] | [standalone]


#407

FromJorgen Grahn <grahn+nntp@snipabacken.se>
Date2012-03-20 00:19 +0000
Message-ID<slrnjmfj8k.1ls.grahn+nntp@frailea.sa.invalid>
In reply to#406
On Mon, 2012-03-19, Benjamin S. wrote:
> Hi, I'm reading the source code for coreutils. There are a few things I 
> don't understand. The current one is the function:
>
> initialize_main (&argc, &argv);
>
> The definition seems to be:
>
>
> /* Redirection and wildcarding when done by the utility itself.
>    Generally a noop, but used in particular for native VMS. */
> #ifndef initialize_main
> # define initialize_main(ac, av)
> #endif
>
> The changelog says:
>
> 2003-06-17  Jim Meyering  <jim@meyering.net>
>
> 	* src/system.h (initialize_main): Define.
> 	Use it in every `main'.  Applied via this:
...
> 	Based on a patch from Bernard Giroud.
>
>
> I really don't understand what it's doing. My current understanding is 
> that it's doing nothing. Any help?

It would have helped if the ChangeLog said *why*, not just *what* :-(

The comment above seems to say it's more or less VMS-specific. (VMS
was a competitor to Unix way back.) What it does /there/ I don't know.
Are you sure there are no alternative definitions of initialize_main()
elsewhere in the code, say, in some VMS compatibiliy subsystem?

It's vaguely interesting, but I'm pretty sure you can ignore it since
you're not asking on a VMS newsgroup.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .     .
\X/     snipabacken.se>   O  o   .

[toc] | [prev] | [next] | [standalone]


#408

FromRainer Weikusat <rweikusat@mssgmbh.com>
Date2012-03-20 02:04 +0000
Message-ID<87zkbcrprz.fsf@sapphire.mobileactivedefense.com>
In reply to#406
"Benjamin S." <niacin89@yahoo.com> writes:
> initialize_main (&argc, &argv);
>
> The definition seems to be:
>
>
> /* Redirection and wildcarding when done by the utility itself.
>    Generally a noop, but used in particular for native VMS. */
> #ifndef initialize_main
> # define initialize_main(ac, av)
> #endif

[...]

> I really don't understand what it's doing. My current understanding is 
> that it's doing nothing. Any help?

Well, it is doing nothing. The comment seems to suggest that it was
supposed to interpret a command-line passed as literal string to the
program in order to set up UNIX(*)-style file descriptor redirection
and expand filename wildcards in the way a UNIX(*) shell would usually
do.

[toc] | [prev] | [next] | [standalone]


#409

From"Benjamin S." <niacin89@yahoo.com>
Date2012-03-20 16:43 +0000
Message-ID<jkac30$gls$1@dont-email.me>
In reply to#408
On Tue, 20 Mar 2012 02:04:48 +0000, Rainer Weikusat wrote:

> "Benjamin S." <niacin89@yahoo.com> writes:
>> initialize_main (&argc, &argv);
>>
>> The definition seems to be:
>>
>>
>> /* Redirection and wildcarding when done by the utility itself.
>>    Generally a noop, but used in particular for native VMS. */
>> #ifndef initialize_main
>> # define initialize_main(ac, av)
>> #endif
> 
> [...]
> 
>> I really don't understand what it's doing. My current understanding is
>> that it's doing nothing. Any help?
> 
> Well, it is doing nothing. The comment seems to suggest that it was
> supposed to interpret a command-line passed as literal string to the
> program in order to set up UNIX(*)-style file descriptor redirection and
> expand filename wildcards in the way a UNIX(*) shell would usually do.

Yes, I thought it was there so that an automated make system can run perl 
on it and substitute it with something else. And yes, I'm sure - that's 
the only definition. I checked with ctags and manually with grep.

I also think it might be for portability reasons (cross-OS stuff). I got 
the source from an official Linux repos (Ubuntu 10.10). I wonder whether 
they've removed all options with regards to other OS. From what I 
understand the coreutils package was rewritten/organized so maybe it is a 
leftover.

[toc] | [prev] | [next] | [standalone]


#410

FromNix <nix-razor-pit@esperi.org.uk>
Date2012-03-21 11:30 +0000
Message-ID<87obrqxkb9.fsf@spindle.srvr.nix>
In reply to#409
On 20 Mar 2012, Benjamin S. said:
> I also think it might be for portability reasons (cross-OS stuff). I got 
> the source from an official Linux repos (Ubuntu 10.10). I wonder whether 
> they've removed all options with regards to other OS. From what I 
> understand the coreutils package was rewritten/organized so maybe it is a 
> leftover.

It's clearly a leftover, if perhaps left around because it is plausible
that some future machine might also require constant per-utility
initialization.

-- 
NULL && (void)

[toc] | [prev] | [next] | [standalone]


#721

Fromindrajith.k@gmail.com
Date2014-09-23 06:46 -0700
Message-ID<4895477d-1ba6-4f4f-882b-c51ed1c362fc@googlegroups.com>
In reply to#406
Seems here is the explanation.
http://stackoverflow.com/questions/19276701/what-does-initialize-main-argc-argv-do


On Tuesday, March 20, 2012 5:14:27 AM UTC+5:30, Benjamin S. wrote:
> Hi, I'm reading the source code for coreutils. There are a few things I 
> 
> don't understand. The current one is the function:
> 
> 
> 
> initialize_main (&argc, &argv);
> 
> 
> 
> The definition seems to be:
> 
> 
> 
> 
> 
> /* Redirection and wildcarding when done by the utility itself.
> 
>    Generally a noop, but used in particular for native VMS. */
> 
> #ifndef initialize_main
> 
> # define initialize_main(ac, av)
> 
> #endif
> 
> 
> 
> 
> 
> 
> 
> The changelog says:
> 
> 
> 
> 
> 
> 2003-06-17  Jim Meyering  <jim@meyering.net>
> 
> 
> 
> 	* src/system.h (initialize_main): Define.
> 
> 	Use it in every `main'.  Applied via this:
> 
> 	p='initialize_main (&argc, &argv);'
> 
> 	perl -ni -e '/program_name.=.argv.0/ and print "  '"$p"'\n"; 
> 
> print' \
> 
> 	  $(grep -l program_name.=.argv.0 *.c)
> 
> 	test.c uses margc/margv, so I made the change manually for that 
> 
> file.
> 
> 	Based on a patch from Bernard Giroud.
> 
> 
> 
> 
> 
> I really don't understand what it's doing. My current understanding is 
> 
> that it's doing nothing. Any help?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.os.linux.development.system


csiph-web