view toys/posix/uname.c @ 694:786841fdb1e0

Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style. The actual code should be the same afterward, this is just cosmetic refactoring.
author Rob Landley <>
date Tue, 13 Nov 2012 17:14:08 -0600
parents fa858a67e231
children b89ab13436fa
line wrap: on
line source

/* uname.c - return system name
 * Copyright 2008 Rob Landley <>
 * See


config UNAME
  bool "uname"
  default y
    usage: uname [-asnrvmpio]

    Print system information.

    -s	System name
    -n	Network (domain) name
    -r	Release number
    -v	Version (build date)
    -m	Machine (hardware) name
    -a	All of the above

#define FOR_uname
#include "toys.h"

// If a 32 bit x86 build environment working in a chroot under an x86-64
// kernel returns x86_64 for -m it confuses ./configure.  Special case it.

#if defined(__i686__)
#define GROSS "i686"
#elif defined(__i586__)
#define GROSS "i586"
#elif defined(__i486__)
#define GROSS "i486"
#elif defined(__i386__)
#define GROSS "i386"

void uname_main(void)
  int i, flags = toys.optflags, needspace=0;

  uname((void *)toybuf);

  if (!flags) flags = FLAG_s;
  for (i=0; i<5; i++) {
    char *c = toybuf+(65*i);

    if (flags & ((1<<i)|FLAG_a)) {
      int len = strlen(c);

      // This problem originates in autoconf, so of course the solution
      // is horribly ugly.
#ifdef GROSS
      if (i==4 && !strcmp(c,"x86_64")) {

      if (needspace++) {
        // We can't decrement on the first entry, because
        // needspace would be 0
        *(--c)=' ';
      xwrite(1, c, len);