From a0f16b945a151b6b9f23804127d211f4df4b1351 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Tue, 19 May 2015 22:30:50 -0500 Subject: [PATCH] wmgeneral: Reduce scope of several variables. Also took the opportunity to fix some whitespace formatting. --- wmSMPmon/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- wmckgmail/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- wmcpufreq/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- wmfsm/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- wmifs/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- wmitime/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- wmkeys/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- wmmon/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- wmppp.app/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- wmsm.app/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- wmtime/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- wmtz/wmgeneral/wmgeneral.c | 59 +++++++++++++++++++-------------- 12 files changed, 408 insertions(+), 300 deletions(-) diff --git a/wmSMPmon/wmgeneral/wmgeneral.c b/wmSMPmon/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100644 --- a/wmSMPmon/wmgeneral/wmgeneral.c +++ b/wmSMPmon/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++; diff --git a/wmckgmail/wmgeneral/wmgeneral.c b/wmckgmail/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100644 --- a/wmckgmail/wmgeneral/wmgeneral.c +++ b/wmckgmail/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++; diff --git a/wmcpufreq/wmgeneral/wmgeneral.c b/wmcpufreq/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100755 --- a/wmcpufreq/wmgeneral/wmgeneral.c +++ b/wmcpufreq/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++; diff --git a/wmfsm/wmgeneral/wmgeneral.c b/wmfsm/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100644 --- a/wmfsm/wmgeneral/wmgeneral.c +++ b/wmfsm/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++; diff --git a/wmifs/wmgeneral/wmgeneral.c b/wmifs/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100644 --- a/wmifs/wmgeneral/wmgeneral.c +++ b/wmifs/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++; diff --git a/wmitime/wmgeneral/wmgeneral.c b/wmitime/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100644 --- a/wmitime/wmgeneral/wmgeneral.c +++ b/wmitime/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++; diff --git a/wmkeys/wmgeneral/wmgeneral.c b/wmkeys/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100644 --- a/wmkeys/wmgeneral/wmgeneral.c +++ b/wmkeys/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++; diff --git a/wmmon/wmgeneral/wmgeneral.c b/wmmon/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100644 --- a/wmmon/wmgeneral/wmgeneral.c +++ b/wmmon/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++; diff --git a/wmppp.app/wmgeneral/wmgeneral.c b/wmppp.app/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100644 --- a/wmppp.app/wmgeneral/wmgeneral.c +++ b/wmppp.app/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++; diff --git a/wmsm.app/wmgeneral/wmgeneral.c b/wmsm.app/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100644 --- a/wmsm.app/wmgeneral/wmgeneral.c +++ b/wmsm.app/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++; diff --git a/wmtime/wmgeneral/wmgeneral.c b/wmtime/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100644 --- a/wmtime/wmgeneral/wmgeneral.c +++ b/wmtime/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++; diff --git a/wmtz/wmgeneral/wmgeneral.c b/wmtz/wmgeneral/wmgeneral.c index 739003d..9b7e5d0 100644 --- a/wmtz/wmgeneral/wmgeneral.c +++ b/wmtz/wmgeneral/wmgeneral.c @@ -100,20 +100,25 @@ int CheckMouseRegion(int, int); void parse_rcfile(const char *filename, rckeys *keys) { - char *p,*q; - char temp[128]; - char *tokens = " :\t\n"; + char *p; FILE *fp; - int i,key; fp = fopen(filename, "r"); if (fp) { + char temp[128]; + while (fgets(temp, 128, fp)) { + char *q; + char *tokens = " :\t\n"; + int key; + key = 0; q = strdup(temp); q = strtok(q, tokens); while (key >= 0 && keys[key].label) { if ((!strcmp(q, keys[key].label))) { + int i; + p = strstr(temp, keys[key].label); p += strlen(keys[key].label); p += strspn(p, tokens); @@ -138,17 +143,20 @@ void parse_rcfile2(const char *filename, rckeys2 *keys) { char *p; char *line = NULL; size_t line_size = 0; - char *tokens = " :\t\n"; FILE *fp; - int i,key; char *family = NULL; fp = fopen(filename, "r"); if (fp) { while (getline(&line, &line_size, fp) >= 0) { + int key; + key = 0; while (key >= 0 && keys[key].label) { if ((p = strstr(line, keys[key].label))) { + char *tokens = " :\t\n"; + int i; + p += strlen(keys[key].label); p += strspn(p, tokens); if ((i = strcspn(p, "#\n"))) p[i] = 0; @@ -293,36 +301,37 @@ int CheckMouseRegion(int x, int y) { \*******************************************************************************/ void createXBMfromXPM(char *xbm, char **xpm, int sx, int sy) { - int i,j,k; - int width, height, numcol, depth; - int zero=0; - unsigned char bwrite; - int bcount; - int curpixel; + int i,j,k; + int width, height, numcol, depth; + int zero=0; + int curpixel; sscanf(*xpm, "%d %d %d %d", &width, &height, &numcol, &depth); - for (k=0; k!=depth; k++) - { - zero <<=8; - zero |= xpm[1][k]; - } + for (k=0; k!=depth; k++) + { + zero <<=8; + zero |= xpm[1][k]; + } for (i=numcol+1; i < numcol+sy+1; i++) { + unsigned char bwrite; + int bcount; + bcount = 0; bwrite = 0; for (j=0; j>= 1; + bwrite >>= 1; - curpixel=0; - for (k=0; k!=depth; k++) - { - curpixel <<=8; - curpixel |= xpm[i][j+k]; - } + curpixel=0; + for (k=0; k!=depth; k++) + { + curpixel <<=8; + curpixel |= xpm[i][j+k]; + } - if ( curpixel != zero ) { + if ( curpixel != zero ) { bwrite += 128; } bcount++;