[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r8945 - in /fsf/trunk/libc: ChangeLog posix/getconf.c



Author: eglibc
Date: Thu Sep 10 00:02:40 2009
New Revision: 8945

Log:
Import glibc-mainline for 2009-09-10

Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/posix/getconf.c

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Thu Sep 10 00:02:40 2009
@@ -1,3 +1,7 @@
+2009-09-09  Ulrich Drepper  <drepper@xxxxxxxxxx>
+
+	* posix/getconf.c (main): Handle -- on command line.
+
 2009-09-05  H.J. Lu  <hongjiu.lu@xxxxxxxxx>
 
 	* configure.in: Support binutils 2.100 and 3.0.

Modified: fsf/trunk/libc/posix/getconf.c
==============================================================================
--- fsf/trunk/libc/posix/getconf.c (original)
+++ fsf/trunk/libc/posix/getconf.c Thu Sep 10 00:02:40 2009
@@ -1052,34 +1052,34 @@
     printf("%-35s", c->name);
     switch (c->call) {
       case PATHCONF:
-        value = pathconf (path, c->call_name);
-        if (value != -1) {
-          printf("%ld", value);
-        }
-        printf("\n");
-        break;
+	value = pathconf (path, c->call_name);
+	if (value != -1) {
+	  printf("%ld", value);
+	}
+	printf("\n");
+	break;
       case SYSCONF:
-        value = sysconf (c->call_name);
-        if (value == -1l) {
-          if (c->call_name == _SC_UINT_MAX
-            || c->call_name == _SC_ULONG_MAX)
-            printf ("%lu", value);
-        }
-        else {
-          printf ("%ld", value);
-        }
-        printf ("\n");
-        break;
+	value = sysconf (c->call_name);
+	if (value == -1l) {
+	  if (c->call_name == _SC_UINT_MAX
+	    || c->call_name == _SC_ULONG_MAX)
+	    printf ("%lu", value);
+	}
+	else {
+	  printf ("%ld", value);
+	}
+	printf ("\n");
+	break;
       case CONFSTR:
-        clen = confstr (c->call_name, (char *) NULL, 0);
-        cvalue = (char *) malloc (clen);
-        if (cvalue == NULL)
-          error (3, 0, _("memory exhausted"));
-        if (confstr (c->call_name, cvalue, clen) != clen)
-          error (3, errno, "confstr");
-        printf ("%.*s\n", (int) clen, cvalue);
+	clen = confstr (c->call_name, (char *) NULL, 0);
+	cvalue = (char *) malloc (clen);
+	if (cvalue == NULL)
+	  error (3, 0, _("memory exhausted"));
+	if (confstr (c->call_name, cvalue, clen) != clen)
+	  error (3, errno, "confstr");
+	printf ("%.*s\n", (int) clen, cvalue);
 	free (cvalue);
-        break;
+	break;
     }
   }
   exit (0);
@@ -1239,13 +1239,17 @@
 	usage ();
     }
 
-  if (argc < 2 || argc > 3)
+  int ai = 1;
+  if (argc > ai && strcmp (argv[ai], "--") == 0)
+    ++ai;
+
+  if (argc - ai < 1 || argc - ai > 2)
     usage ();
 
   for (c = vars; c->name != NULL; ++c)
-    if (strcmp (c->name, argv[1]) == 0
+    if (strcmp (c->name, argv[ai]) == 0
 	|| (strncmp (c->name, "_POSIX_", 7) == 0
-	    && strcmp (c->name + 7, argv[1]) == 0))
+	    && strcmp (c->name + 7, argv[ai]) == 0))
       {
 	long int value;
 	size_t clen;
@@ -1253,14 +1257,14 @@
 	switch (c->call)
 	  {
 	  case PATHCONF:
-	    if (argc < 3)
+	    if (argc - ai < 2)
 	      usage ();
 	    errno = 0;
-	    value = pathconf (argv[2], c->call_name);
+	    value = pathconf (argv[ai + 1], c->call_name);
 	    if (value == -1)
 	      {
 		if (errno)
-		  error (3, errno, "pathconf: %s", argv[2]);
+		  error (3, errno, "pathconf: %s", argv[ai + 1]);
 		else
 		  puts (_("undefined"));
 	      }
@@ -1269,7 +1273,7 @@
 	    exit (0);
 
 	  case SYSCONF:
-	    if (argc > 2)
+	    if (argc - ai > 1)
 	      usage ();
 	    value = sysconf (c->call_name);
 	    if (value == -1l)
@@ -1285,7 +1289,7 @@
 	    exit (0);
 
 	  case CONFSTR:
-	    if (argc > 2)
+	    if (argc - ai > 1)
 	      usage ();
 	    clen = confstr (c->call_name, (char *) NULL, 0);
 	    cvalue = (char *) malloc (clen);
@@ -1300,7 +1304,7 @@
 	  }
       }
 
-  error (2, 0, _("Unrecognized variable `%s'"), argv[1]);
+  error (2, 0, _("Unrecognized variable `%s'"), argv[ai]);
   /* NOTREACHED */
   return 2;
 }