]> granicus.if.org Git - procps-ng/commitdiff
slashdot fix
authoralbert <>
Wed, 9 Oct 2002 06:23:58 +0000 (06:23 +0000)
committeralbert <>
Wed, 9 Oct 2002 06:23:58 +0000 (06:23 +0000)
NEWS
sysctl.c

diff --git a/NEWS b/NEWS
index b7fc5c5e0950b15057edbbc8227985180aebe47c..c4b9607e4659afc4e171abc102583ac0d357212e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
 procps-3.0.0 --> procps-3.0.1
 
+sysctl handles net/ipv4/conf/eth1.0123/tag (VLAN interface)
+sysctl handles net.ipv4.conf.eth1/0123.tag (VLAN interface)
 "ps" is now about 2x faster than in procps-2.x.x
 "ps -F" now documented
 w works in KOI8-R locale
index e1af4bd79bd5affc6e040fa048e8bf0a9a9558a1..6220efbb378e3b1a67457f3d45769b5e8b49f1c2 100644 (file)
--- a/sysctl.c
+++ b/sysctl.c
@@ -68,24 +68,17 @@ const char *ERR_PRELOAD_FILE = "error: unable to open preload file '%s'\n";
 const char *WARN_BAD_LINE = "warning: %s(%d): invalid syntax, continuing...\n";
 
 
-#define DOTSLASH(x) do{ \
-  char *p_ = (x);           \
-  for(;;){                  \
-    p_ = strchr(p_, '.');   \
-    if(!p_) break;          \
-    *p_ = '/';              \
-  }                         \
-}while(0)
-
-#define SLASHDOT(x) do{ \
-  char *p_ = (x);           \
-  for(;;){                  \
-    p_ = strchr(p_, '.');   \
-    if(!p_) break;          \
-    *p_ = '/';              \
-  }                         \
-}while(0)
-
+static void slashdot(char *p, char old, char new){
+  p = strpbrk(p,"/.");
+  if(!p) return;            /* nothing -- can't be, but oh well */
+  if(*p==new) return;       /* already in desired format */
+  while(p){
+    char c = *p;
+    if(c==old) *p=new;
+    if(c==new) *p=old;
+    p = strpbrk(p+1,"/.");
+  }
+}
 
 /*
  *    Main... 
@@ -265,7 +258,7 @@ char *tmpname;
 FILE *fp;
 char *outname;
 
-   if (!name) {                /* probably dont' want to display this  err */
+   if (!name) {        /* probably don't want to display this err */
       return 0;
    } /* end if */
 
@@ -276,25 +269,26 @@ char *outname;
       return -1;
    } /* end if */
 
-   value = equals + sizeof(char);      /* point to the value in name=value */   
+   value = equals + 1;      /* point to the value in name=value */   
 
    if (!*name || !*value || name == equals) { 
       fprintf(stderr, ERR_MALFORMED_SETTING, setting);
       return -2;
    } /* end if */
 
-   tmpname = (char *)malloc((equals-name+1+strlen(PROC_PATH))*sizeof(char));
-   outname = (char *)malloc((equals-name+1)*sizeof(char));
-
+   /* used to open the file */
+   tmpname = malloc(equals-name+1+strlen(PROC_PATH));
    strcpy(tmpname, PROC_PATH);
    strncat(tmpname, name, (int)(equals-name)); 
    tmpname[equals-name+strlen(PROC_PATH)] = 0;
+   slashdot(tmpname+strlen(PROC_PATH),'.','/'); /* change . to / */
+
+   /* used to display the output */
+   outname = malloc(equals-name+1);                       
    strncpy(outname, name, (int)(equals-name)); 
    outname[equals-name] = 0;
+   slashdot(outname,'/','.'); /* change / to . */
  
-   DOTSLASH(tmpname); /* change . to / */
-   SLASHDOT(outname); /* change / to . */
-
    fp = fopen(tmpname, "w");
 
    if (!fp) {
@@ -313,6 +307,7 @@ char *outname;
    } else {
       fprintf(fp, "%s\n", value);
       fclose(fp);
+
       if (PrintName) {
          fprintf(stdout, "%s = %s\n", outname, value);
       } else {
@@ -345,16 +340,15 @@ FILE *fp;
       fprintf(stderr, ERR_INVALID_KEY, setting);
    } /* endif */
 
-   tmpname = (char *)malloc((strlen(name)+strlen(PROC_PATH)+1)*sizeof(char));
-   outname = (char *)malloc((strlen(name)+1)*sizeof(char));
-
+   /* used to open the file */
+   tmpname = malloc(strlen(name)+strlen(PROC_PATH)+1);
    strcpy(tmpname, PROC_PATH);
    strcat(tmpname, name); 
-   strcpy(outname, name); 
+   slashdot(tmpname+strlen(PROC_PATH),'.','/'); /* change . to / */
 
-   DOTSLASH(tmpname); /* change . to / */
-   SLASHDOT(outname); /* change / to . */
+   /* used to display the output */
+   outname = strdup(name);
+   slashdot(outname,'/','.'); /* change / to . */
 
    fp = fopen(tmpname, "r");