*BSD News Article 84589


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.Hawaii.Edu!news.uoregon.edu!ddsw1!news.mcs.net!www.nntp.primenet.com!nntp.primenet.com!nntp.uio.no!news.apfel.de!nntp.zit.th-darmstadt.de!fu-berlin.de!cs.tu-berlin.de!js
From: js@cs.tu-berlin.de (Joerg Schilling)
Newsgroups: comp.unix.solaris,comp.unix.bsd.misc,comp.unix.internals
Subject: Re: Solaris 2.6
Date: 9 Dec 1996 16:16:51 GMT
Organization: Technical University of Berlin, Germany
Lines: 58
Distribution: inet
Message-ID: <58he1j$145$1@news.cs.tu-berlin.de>
References: <32986299.AC7@mail.esrin.esa.it> <slrn5af88v.199.dave@pc-damir.srce.hr> <588tfe$pf2@arktur.rz.uni-ulm.de> <58ag7g$i0d@tooting.netapp.com>
NNTP-Posting-Host: 130.149.25.72
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Xref: euryale.cc.adfa.oz.au comp.unix.solaris:91895 comp.unix.bsd.misc:1740 comp.unix.internals:11531

In article <58ag7g$i0d@tooting.netapp.com>, Guy Harris <guy@netapp.com> wrote:
>Andreas Borchert <borchert@turing.mathematik.uni-ulm.de> wrote:
>>long does not do the job because of the
>>existence of sometimes larger types named long long. Then you may cast
>>(or assign) it accordingly. You need, of course, an associated %-tag
>>for it.
>
>...and I'm not sure there's a *de facto* standard % tag for "long long
>int", to the same extent that there's somewhat of a *de facto* standard
>"long long int" for getting 64-bit "int"s.  Solaris 2.x offers
>"%ll[dux]"; 4.4BSD offers "%q[dux]"; I seem to remember reading that
>Linux, at least at some point, offered some *third* tag.
>
>So much for portability, even to systems that all support "long long
>int"....


Linux supports %lld , but that's not a real solution.

	printf("filesize: %ld\n", stat.st_size);
	...
	printf("filesize: %lld\n", stat.st_size);

	Cannot be made portable!

Printf needs a new, more portable interface for printing numbers.

I propose the general form:

	%*.*:*.*	 = %fldwith.signif:size.base	Most complex form
or
	%*.*:*d						Width & size form
or
	%:*d						Siplest extension


This would allow to make the printf statement above portable
by using:

	printf("filesize: %:*d\n", sizeof(stat.st_size), stat.st_size);


This also would allow to print a number to any base e.g.:

	printf("%:.9\n", i);

would print 'i' to the base of 9.


Joerg



-- 
EMail:	joerg@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
	js@cs.tu-berlin.de		  (uni)  If you don't have iso-8859-1
	jes@fokus.gmd.de		  (work) chars my name is
URL:	http://www.fokus.gmd.de/usr/schilling    J"org Schilling