Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 May 1995 19:09:13 -0700 (PDT)
From:      "Rodney W. Grimes" <rgrimes@gndrsh.aac.dev.com>
To:        jkh@time.cdrom.com
Cc:        freebsd-bugs@freefall.cdrom.com
Subject:   Re: bin/386: *s field width specification doesn't seem to work for printf
Message-ID:  <199505070209.TAA11643@gndrsh.aac.dev.com>
In-Reply-To: <199505070150.SAA27670@freefall.cdrom.com> from "Jordan K. Hubbard" at May 6, 95 06:50:01 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> 
> >Number:         386
> >Category:       bin
> >Synopsis:       *s field width specification for printf seems to loop
> >Confidential:   no
> >Severity:       non-critical
> >Priority:       low
> >Responsible:    freebsd-bugs (FreeBSD bugs mailing list)
> >State:          open
> >Class:          sw-bug
> >Submitter-Id:   current-users
> >Arrival-Date:   Sat May  6 18:50:00 1995
> >Originator:     Jordan K. Hubbard
> >Organization:
> Walnut Creek CDROM
> >Release:        FreeBSD BUILT-19950425 i386
> >Environment:
> 
> 	See Release
> 
> >Description:
> 
> 	Try this:  printf "%8*s" foobarblatt
> 
> 	It will loop forever.  The man page would tend to indicate that it,
> 	or perhaps rather %*8s, should print the arg truncated to 8 characters.
> 	Either way, it shouldn't loop.

I am not sure how you read that from the man page, from print(1):

  A field width or precision may be `*' instead of a digit string.  In this
  case an argument supplies the field width or precision.

and from print(3):

  A field width or precision, or both, may be indicated by an asterisk `*'
  instead of a digit string.  In this case, an int argument supplies the
  field width or precision.  A negative field width is treated as a left
  adjustment flag followed by a positive field width; a negative precision
  is treated as though it were missing.


You are missing the required int arg for the * and foobarblatt is being
used for this int.  foobarblatt is probably some rather very large int
value and appears to loop forever, when infact it is outputing tons and
tons of spaces to bad the width of the field.

Please close this bug report as programmer error.... 

-- 
Rod Grimes                                      rgrimes@gndrsh.aac.dev.com
Accurate Automation Company                   Custom computers for FreeBSD



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199505070209.TAA11643>