slashdot fix

This commit is contained in:
albert 2002-10-09 06:23:58 +00:00
parent d64a12f799
commit c785a0e34a
2 changed files with 29 additions and 33 deletions

2
NEWS
View File

@ -1,5 +1,7 @@
procps-3.0.0 --> procps-3.0.1 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" is now about 2x faster than in procps-2.x.x
"ps -F" now documented "ps -F" now documented
w works in KOI8-R locale w works in KOI8-R locale

View File

@ -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"; const char *WARN_BAD_LINE = "warning: %s(%d): invalid syntax, continuing...\n";
#define DOTSLASH(x) do{ \ static void slashdot(char *p, char old, char new){
char *p_ = (x); \ p = strpbrk(p,"/.");
for(;;){ \ if(!p) return; /* nothing -- can't be, but oh well */
p_ = strchr(p_, '.'); \ if(*p==new) return; /* already in desired format */
if(!p_) break; \ while(p){
*p_ = '/'; \ char c = *p;
} \ if(c==old) *p=new;
}while(0) if(c==new) *p=old;
p = strpbrk(p+1,"/.");
#define SLASHDOT(x) do{ \ }
char *p_ = (x); \ }
for(;;){ \
p_ = strchr(p_, '.'); \
if(!p_) break; \
*p_ = '/'; \
} \
}while(0)
/* /*
* Main... * Main...
@ -265,7 +258,7 @@ char *tmpname;
FILE *fp; FILE *fp;
char *outname; char *outname;
if (!name) { /* probably dont' want to display this err */ if (!name) { /* probably don't want to display this err */
return 0; return 0;
} /* end if */ } /* end if */
@ -276,24 +269,25 @@ char *outname;
return -1; return -1;
} /* end if */ } /* 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) { if (!*name || !*value || name == equals) {
fprintf(stderr, ERR_MALFORMED_SETTING, setting); fprintf(stderr, ERR_MALFORMED_SETTING, setting);
return -2; return -2;
} /* end if */ } /* end if */
tmpname = (char *)malloc((equals-name+1+strlen(PROC_PATH))*sizeof(char)); /* used to open the file */
outname = (char *)malloc((equals-name+1)*sizeof(char)); tmpname = malloc(equals-name+1+strlen(PROC_PATH));
strcpy(tmpname, PROC_PATH); strcpy(tmpname, PROC_PATH);
strncat(tmpname, name, (int)(equals-name)); strncat(tmpname, name, (int)(equals-name));
tmpname[equals-name+strlen(PROC_PATH)] = 0; 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)); strncpy(outname, name, (int)(equals-name));
outname[equals-name] = 0; outname[equals-name] = 0;
slashdot(outname,'/','.'); /* change / to . */
DOTSLASH(tmpname); /* change . to / */
SLASHDOT(outname); /* change / to . */
fp = fopen(tmpname, "w"); fp = fopen(tmpname, "w");
@ -313,6 +307,7 @@ char *outname;
} else { } else {
fprintf(fp, "%s\n", value); fprintf(fp, "%s\n", value);
fclose(fp); fclose(fp);
if (PrintName) { if (PrintName) {
fprintf(stdout, "%s = %s\n", outname, value); fprintf(stdout, "%s = %s\n", outname, value);
} else { } else {
@ -345,16 +340,15 @@ FILE *fp;
fprintf(stderr, ERR_INVALID_KEY, setting); fprintf(stderr, ERR_INVALID_KEY, setting);
} /* endif */ } /* endif */
tmpname = (char *)malloc((strlen(name)+strlen(PROC_PATH)+1)*sizeof(char)); /* used to open the file */
outname = (char *)malloc((strlen(name)+1)*sizeof(char)); tmpname = malloc(strlen(name)+strlen(PROC_PATH)+1);
strcpy(tmpname, PROC_PATH); strcpy(tmpname, PROC_PATH);
strcat(tmpname, name); strcat(tmpname, name);
strcpy(outname, name); slashdot(tmpname+strlen(PROC_PATH),'.','/'); /* change . to / */
/* used to display the output */
DOTSLASH(tmpname); /* change . to / */ outname = strdup(name);
SLASHDOT(outname); /* change / to . */ slashdot(outname,'/','.'); /* change / to . */
fp = fopen(tmpname, "r"); fp = fopen(tmpname, "r");