All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jeff V. Merkey" <jmerkey@wolfmountaingroup.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Inserting Commas into Those Big Numbers
Date: Wed, 18 Jan 2006 21:59:59 -0700	[thread overview]
Message-ID: <43CF1CCF.20007@wolfmountaingroup.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 270 bytes --]


If anyone cares to make the kernel output more readable, heres a code 
snippet that formats any text string with numbers (decimal) to
insert commas.  I am too old and going blind looking at computer screen 
with these long numbers.  If useful to anyone, enjoy.

Jeff



[-- Attachment #2: sprintf_comma.c --]
[-- Type: text/x-csrc, Size: 432 bytes --]


void sprintf_comma(char *buf, char *fmt, ...)
{

     register long i, r, flag, len;
     va_list args;

     va_start(args, fmt);
     vsprintf(buf, fmt, args);
     va_end(args);

     for (len = i = strlen(buf), flag = 0; i >= 0; i--)
     {
	if (buf[i] >= '0' && buf[i] <= '9')
	{
	   if (++flag > 3)
	   {
	      flag = 1;
	      for (r = ++len; r > i; r--)
		 buf[r] = buf[r - 1];
	      buf[i + 1] = ',';
	   }
	}
     }
}


             reply	other threads:[~2006-01-19  6:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-19  4:59 Jeff V. Merkey [this message]
2006-01-20  2:03 ` Inserting Commas into Those Big Numbers dean gaudet

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=43CF1CCF.20007@wolfmountaingroup.com \
    --to=jmerkey@wolfmountaingroup.com \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.