summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard R. Link <brlink@debian.org>2009-07-15 17:30:31 +0200
committerBernhard R. Link <brlink@debian.org>2009-07-15 17:30:31 +0200
commitad06f3519881bd3b2d5b8a3f1880a6768a530e2a (patch)
tree5c0aa16782cc0e2463ab3fafccd9e460afbc57da
parent7bdee1c7f38befd9b6b0b5805dd0824fe2233936 (diff)
downloadratpoison-ad06f3519881bd3b2d5b8a3f1880a6768a530e2a.zip
do not shadow identifiers (silencing gcc's -Wshadow warnings)
-rw-r--r--src/actions.c131
-rw-r--r--src/frame.c30
-rw-r--r--src/input.c16
-rw-r--r--src/main.c22
-rw-r--r--src/screen.c20
5 files changed, 108 insertions, 111 deletions
diff --git a/src/actions.c b/src/actions.c
index f582ab5..77cdeb8 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -549,19 +549,19 @@ find_command_by_keydesc (char *desc, rp_keymap *map)
static char *
resolve_command_from_keydesc (char *desc, int depth, rp_keymap *map)
{
- char *cmd, *command;
+ char *cmd, *c;
- command = find_command_by_keydesc (desc, map);
- if (!command)
+ c = find_command_by_keydesc (desc, map);
+ if (!c)
return NULL;
/* is it a link? */
- if (strncmp (command, "link", 4) || depth > MAX_LINK_DEPTH)
+ if (strncmp (c, "link", 4) || depth > MAX_LINK_DEPTH)
/* it is not */
- return command;
+ return c;
- cmd = resolve_command_from_keydesc (&command[5], depth + 1, map);
- return (cmd != NULL) ? cmd : command;
+ cmd = resolve_command_from_keydesc (&c[5], depth + 1, map);
+ return (cmd != NULL) ? cmd : c;
}
@@ -673,14 +673,14 @@ find_alias_index (char *name)
static void
add_alias (char *name, char *alias)
{
- int index;
+ int i;
/* Are we updating an existing alias, or creating a new one? */
- index = find_alias_index (name);
- if (index >= 0)
+ i = find_alias_index (name);
+ if (i >= 0)
{
- free (alias_list[index].alias);
- alias_list[index].alias = xstrdup (alias);
+ free (alias_list[i].alias);
+ alias_list[i].alias = xstrdup (alias);
}
else
{
@@ -1707,10 +1707,10 @@ read_shellcmd (struct argspec *spec, struct sbuf *s, struct cmdarg **arg, const
ret = read_string (spec, s, hist_SHELLCMD, exec_completions, arg);
if (command_name && !s && !ret) {
/* store for command history */
- char *s = xmalloc (strlen(command_name) + strlen((*arg)->string) + 2);
- sprintf (s, "%s %s", command_name, (*arg)->string);
- history_add (hist_COMMAND, s);
- free(s);
+ char *str = xmalloc (strlen(command_name) + strlen((*arg)->string) + 2);
+ sprintf (str, "%s %s", command_name, (*arg)->string);
+ history_add (hist_COMMAND, str);
+ free(str);
}
return ret;
}
@@ -1744,14 +1744,14 @@ read_frame (struct argspec *spec, struct sbuf *s, struct cmdarg **arg)
for (j=0; j<num_screens; j++)
{
XSetWindowAttributes attr;
- rp_screen *s = &screens[j];
+ rp_screen *screen = &screens[j];
/* Set up the window attributes to be used in the loop. */
- attr.border_pixel = s->fg_color;
- attr.background_pixel = s->bg_color;
+ attr.border_pixel = screen->fg_color;
+ attr.background_pixel = screen->bg_color;
attr.override_redirect = True;
- list_for_each_entry (cur, &s->frames, node)
+ list_for_each_entry (cur, &screen->frames, node)
{
int width, height;
char *num;
@@ -1760,11 +1760,11 @@ read_frame (struct argspec *spec, struct sbuf *s, struct cmdarg **arg)
determine the height and width of the window. */
/* num = xsprintf (" %d ", cur->number); */
num = frame_selector (cur->number);
- width = defaults.bar_x_padding * 2 + rp_text_width (s, defaults.font, num, -1);
- height = (FONT_HEIGHT (s) + defaults.bar_y_padding * 2);
+ width = defaults.bar_x_padding * 2 + rp_text_width (screen, defaults.font, num, -1);
+ height = (FONT_HEIGHT (screen) + defaults.bar_y_padding * 2);
/* Create and map the window. */
- wins[i] = XCreateWindow (dpy, s->root, s->left + cur->x, s->top + cur->y, width, height, 1,
+ wins[i] = XCreateWindow (dpy, screen->root, screen->left + cur->x, screen->top + cur->y, width, height, 1,
CopyFromParent, CopyFromParent, CopyFromParent,
CWOverrideRedirect | CWBorderPixel | CWBackPixel,
&attr);
@@ -1772,9 +1772,9 @@ read_frame (struct argspec *spec, struct sbuf *s, struct cmdarg **arg)
XClearWindow (dpy, wins[i]);
/* Display the frame's number inside the window. */
- rp_draw_string (s, wins[i], STYLE_NORMAL,
+ rp_draw_string (screen, wins[i], STYLE_NORMAL,
defaults.bar_x_padding,
- defaults.bar_y_padding + FONT_ASCENT(s),
+ defaults.bar_y_padding + FONT_ASCENT(screen),
num, -1);
free (num);
@@ -2478,7 +2478,7 @@ command (int interactive, char *data)
struct cmdarg *acur;
struct list_head *iter, *tmp;
struct list_head head, args;
- int i, nargs = 0, raw = 0;
+ int nargs = 0, raw = 0;
INIT_LIST_HEAD (&args);
INIT_LIST_HEAD (&head);
@@ -3631,25 +3631,25 @@ set_bargravity (struct cmdarg **args)
static void
update_gc (rp_screen *s)
{
- XGCValues gv;
+ XGCValues gcv;
- gv.foreground = s->fg_color;
- gv.background = s->bg_color;
- gv.function = GXcopy;
- gv.line_width = 1;
- gv.subwindow_mode = IncludeInferiors;
+ gcv.foreground = s->fg_color;
+ gcv.background = s->bg_color;
+ gcv.function = GXcopy;
+ gcv.line_width = 1;
+ gcv.subwindow_mode = IncludeInferiors;
XFreeGC (dpy, s->normal_gc);
s->normal_gc = XCreateGC(dpy, s->root,
GCForeground | GCBackground
| GCFunction | GCLineWidth
- | GCSubwindowMode, &gv);
- gv.foreground = s->bg_color;
- gv.background = s->fg_color;
+ | GCSubwindowMode, &gcv);
+ gcv.foreground = s->bg_color;
+ gcv.background = s->fg_color;
XFreeGC (dpy, s->inverse_gc);
s->inverse_gc = XCreateGC(dpy, s->root,
GCForeground | GCBackground
| GCFunction | GCLineWidth
- | GCSubwindowMode, &gv);
+ | GCSubwindowMode, &gcv);
}
#ifndef USE_XFT_FONT
@@ -4441,11 +4441,11 @@ cmd_alias (int interactive, struct cmdarg **args)
cmdret *
cmd_unalias (int interactive, struct cmdarg **args)
{
- int index;
+ int i;
/* Are we updating an existing alias, or creating a new one? */
- index = find_alias_index (ARG_STRING(0));
- if (index >= 0)
+ i = find_alias_index (ARG_STRING(0));
+ if (i >= 0)
{
char *tmp;
@@ -4454,15 +4454,15 @@ cmd_unalias (int interactive, struct cmdarg **args)
/* Free the alias and put the last alias in the the space to
keep alias_list from becoming sparse. This code must jump
through some hoops to correctly handle the case when
- alias_list_last == index. */
- tmp = alias_list[index].alias;
- alias_list[index].alias = xstrdup (alias_list[alias_list_last].alias);
+ alias_list_last == i. */
+ tmp = alias_list[i].alias;
+ alias_list[i].alias = xstrdup (alias_list[alias_list_last].alias);
free (tmp);
free (alias_list[alias_list_last].alias);
/* Do the same for the name element. */
- tmp = alias_list[index].name;
- alias_list[index].name = xstrdup (alias_list[alias_list_last].name);
+ tmp = alias_list[i].name;
+ alias_list[i].name = xstrdup (alias_list[alias_list_last].name);
free (tmp);
free (alias_list[alias_list_last].name);
}
@@ -4823,12 +4823,12 @@ fdump (rp_screen *screen)
/* FIXME: Oooh, gross! there's a trailing comma, yuk! */
list_for_each_entry (cur, &(screen->frames), node)
{
- char *tmp;
+ char *t;
- tmp = frame_dump (cur, screen);
- sbuf_concat (s, tmp);
+ t = frame_dump (cur, screen);
+ sbuf_concat (s, t);
sbuf_concat (s, ",");
- free (tmp);
+ free (t);
}
tmp = sbuf_get (s);
@@ -4867,7 +4867,7 @@ static cmdret *
frestore (char *data, rp_screen *s)
{
char *token;
- char *dup;
+ char *d;
rp_frame *new, *cur;
rp_window *win;
struct list_head fset;
@@ -4876,11 +4876,11 @@ frestore (char *data, rp_screen *s)
INIT_LIST_HEAD (&fset);
- dup = xstrdup (data);
- token = strtok_r (dup, ",", &nexttok);
+ d = xstrdup (data);
+ token = strtok_r (d, ",", &nexttok);
if (token == NULL)
{
- free (dup);
+ free (d);
return cmdret_new (RET_FAILURE, "frestore: invalid frame format");
}
@@ -4890,14 +4890,14 @@ frestore (char *data, rp_screen *s)
new = frame_read (token, s);
if (new == NULL)
{
- free (dup);
+ free (d);
return cmdret_new (RET_SUCCESS, "frestore: invalid frame format");;
}
list_add_tail (&new->node, &fset);
token = strtok_r (NULL, ",", &nexttok);
}
- free (dup);
+ free (d);
/* Clear all the frames. */
list_for_each_entry (cur, &s->frames, node)
@@ -4916,8 +4916,6 @@ frestore (char *data, rp_screen *s)
/* Process the frames a bit to make sure everything lines up. */
list_for_each_entry (cur, &s->frames, node)
{
- rp_window *win;
-
PRINT_DEBUG (("restore %d %d\n", cur->number, cur->win_number));
/* Grab the frame's number, but if it already exists request a
@@ -4936,8 +4934,7 @@ frestore (char *data, rp_screen *s)
/* Update the window the frame points to. */
if (cur->win_number != EMPTY)
{
- win = find_window_number (cur->win_number);
- set_frames_window (cur, win);
+ set_frames_window (cur, find_window_number (cur->win_number));
}
}
@@ -5322,13 +5319,13 @@ cmd_set (int interactive, struct cmdarg **args)
list_last (last, &set_vars, node);
list_for_each_entry (cur, &set_vars, node)
{
- cmdret *ret;
- ret = cur->set_fn (args);
- sbuf_printf_concat (s, "%s: %s", cur->var, ret->output);
+ cmdret *r;
+ r = cur->set_fn (args);
+ sbuf_printf_concat (s, "%s: %s", cur->var, r->output);
/* Skip a newline on the last line. */
if (cur != last)
sbuf_concat (s, "\n");
- cmdret_free (ret);
+ cmdret_free (r);
}
/* Return the accumulated string. */
@@ -5446,7 +5443,7 @@ cmd_sfrestore (int interactively, struct cmdarg **args)
int number_of_frames = 0;
int j;
long x;
- char *dup;
+ char *d;
char *token;
char *ptr;
struct sbuf *buffer[num_screens];
@@ -5457,11 +5454,11 @@ cmd_sfrestore (int interactively, struct cmdarg **args)
}
/* now split the whole input to the corresponding screens */
- dup = xstrdup (ARG_STRING(0));
+ d = xstrdup (ARG_STRING(0));
- token = strtok (dup, ",");
+ token = strtok (d, ",");
if (token == NULL) {
- free (dup);
+ free (d);
return cmdret_new (RET_FAILURE, "sfrestore: invalid frame format");
}
@@ -5492,7 +5489,7 @@ cmd_sfrestore (int interactively, struct cmdarg **args)
token = strtok (NULL, ",");
}
- free (dup);
+ free (d);
/* now restore the frames for each screen */
for (j=0; j<num_screens; j++) {
diff --git a/src/frame.c b/src/frame.c
index d7c0fb9..c42e2ab 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -198,9 +198,9 @@ frame_read (char *str, rp_screen *screen)
Window w = 0L;
rp_window *win;
rp_frame *f;
- char *tmp, *dup;
- int screen_width = -1;
- int screen_height = -1;
+ char *tmp, *d;
+ int s_width = -1;
+ int s_height = -1;
/* Create a blank frame. */
f = xmalloc (sizeof (rp_frame));
@@ -208,14 +208,14 @@ frame_read (char *str, rp_screen *screen)
PRINT_DEBUG(("parsing '%s'\n", str));
- dup = xstrdup(str);
- tmp = strtok_ws (dup);
+ d = xstrdup(str);
+ tmp = strtok_ws (d);
/* Verify it starts with '(frame ' */
if (strcmp(tmp, "(frame"))
{
PRINT_DEBUG(("Doesn't start with '(frame '\n"));
- free (dup);
+ free (d);
free (f);
return NULL;
}
@@ -234,9 +234,9 @@ frame_read (char *str, rp_screen *screen)
else if (!strcmp(tmp, ":height"))
read_slot(f->height);
else if (!strcmp(tmp, ":screenw"))
- read_slot(screen_width);
+ read_slot(s_width);
else if (!strcmp(tmp, ":screenh"))
- read_slot(screen_height);
+ read_slot(s_height);
else if (!strcmp(tmp, ":window"))
read_slot(w);
else if (!strcmp(tmp, ":last-access"))
@@ -260,18 +260,18 @@ frame_read (char *str, rp_screen *screen)
}
if (tmp)
PRINT_ERROR(("Frame has trailing garbage\n"));
- free (dup);
+ free (d);
/* adjust x, y, width and height to a possible screen size change */
- if (screen_width > 0)
+ if (s_width > 0)
{
- f->x = (f->x*screen->width)/screen_width;
- f->width = (f->width*screen->width)/screen_width;
+ f->x = (f->x*screen->width)/s_width;
+ f->width = (f->width*screen->width)/s_width;
}
- if (screen_height > 0)
+ if (s_height > 0)
{
- f->y = (f->y*screen->height)/screen_height;
- f->height = (f->height*screen->height)/screen_height;
+ f->y = (f->y*screen->height)/s_height;
+ f->height = (f->height*screen->height)/s_height;
}
/* Perform some integrity checks on what we got and fix any
diff --git a/src/input.c b/src/input.c
index e2c3054..8c8ab80 100644
--- a/src/input.c
+++ b/src/input.c
@@ -432,7 +432,7 @@ update_input_window (rp_screen *s, rp_input_line *line)
int input_width = rp_text_width (s, defaults.font, line->buffer, line->length);
int total_width;
GC lgc;
- XGCValues gv;
+ XGCValues gcv;
int height;
total_width = defaults.bar_x_padding * 2 + prompt_width + input_width + MAX_FONT_WIDTH (defaults.font);
@@ -462,9 +462,9 @@ update_input_window (rp_screen *s, rp_input_line *line)
line->buffer,
line->length);
- gv.function = GXxor;
- gv.foreground = s->fg_color ^ s->bg_color;
- lgc = XCreateGC (dpy, s->input_window, GCFunction | GCForeground, &gv);
+ gcv.function = GXxor;
+ gcv.foreground = s->fg_color ^ s->bg_color;
+ lgc = XCreateGC (dpy, s->input_window, GCFunction | GCForeground, &gcv);
/* Draw a cheap-o cursor - MkII */
XFillRectangle (dpy, s->input_window, lgc,
@@ -482,15 +482,15 @@ ring_bell (void)
{
#ifdef VISUAL_BELL
GC lgc;
- XGCValues gv;
+ XGCValues gcv;
XWindowAttributes attr;
rp_screen *s = current_screen ();
XGetWindowAttributes (dpy, s->input_window, &attr);
- gv.function = GXxor;
- gv.foreground = s->fg_color ^ s->bg_color;
- lgc = XCreateGC (dpy, s->input_window, GCFunction | GCForeground, &gv);
+ gcv.function = GXxor;
+ gcv.foreground = s->fg_color ^ s->bg_color;
+ lgc = XCreateGC (dpy, s->input_window, GCFunction | GCForeground, &gcv);
XFillRectangle (dpy, s->input_window, lgc, 0, 0, attr.width, attr.height);
XFlush (dpy);
diff --git a/src/main.c b/src/main.c
index c7ad72f..4255b8f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -574,7 +574,7 @@ main (int argc, char *argv[])
{
int i;
int c;
- char **command = NULL;
+ char **cmd = NULL;
int cmd_count = 0;
int screen_arg = 0;
int screen_num = 0;
@@ -602,17 +602,17 @@ main (int argc, char *argv[])
print_version ();
break;
case 'c':
- if (!command)
+ if (!cmd)
{
- command = xmalloc (sizeof(char *));
+ cmd = xmalloc (sizeof(char *));
cmd_count = 0;
}
else
{
- command = xrealloc (command, sizeof (char *) * (cmd_count + 1));
+ cmd = xrealloc (cmd, sizeof (char *) * (cmd_count + 1));
}
- command[cmd_count] = xstrdup (optarg);
+ cmd[cmd_count] = xstrdup (optarg);
cmd_count++;
break;
case 'd':
@@ -658,19 +658,19 @@ main (int argc, char *argv[])
if (cmd_count > 0)
{
- int i;
+ int j;
- for (i=0; i<cmd_count; i++)
+ for (j=0; j<cmd_count; j++)
{
if (screen_arg)
- send_command (interactive, (unsigned char *)command[i], screen_num);
+ send_command (interactive, (unsigned char *)cmd[j], screen_num);
else
- send_command (interactive, (unsigned char *)command[i], -1);
+ send_command (interactive, (unsigned char *)cmd[j], -1);
- free (command[i]);
+ free (cmd[j]);
}
- free (command);
+ free (cmd);
XCloseDisplay (dpy);
return EXIT_SUCCESS;
}
diff --git a/src/screen.c b/src/screen.c
index aaf7bd8..3848e29 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -237,7 +237,7 @@ init_rat_cursor (rp_screen *s)
static void
init_screen (rp_screen *s, int screen_num)
{
- XGCValues gv;
+ XGCValues gcv;
int xine_screen_num;
/* We use screen_num below to refer to the real X screen number, but
@@ -300,21 +300,21 @@ init_screen (rp_screen *s, int screen_num)
s->bw_color = BlackPixel (dpy, s->screen_num);
/* Setup the GC for drawing the font. */
- gv.foreground = s->fg_color;
- gv.background = s->bg_color;
- gv.function = GXcopy;
- gv.line_width = 1;
- gv.subwindow_mode = IncludeInferiors;
+ gcv.foreground = s->fg_color;
+ gcv.background = s->bg_color;
+ gcv.function = GXcopy;
+ gcv.line_width = 1;
+ gcv.subwindow_mode = IncludeInferiors;
s->normal_gc = XCreateGC(dpy, s->root,
GCForeground | GCBackground | GCFunction
| GCLineWidth | GCSubwindowMode,
- &gv);
- gv.foreground = s->bg_color;
- gv.background = s->fg_color;
+ &gcv);
+ gcv.foreground = s->bg_color;
+ gcv.background = s->fg_color;
s->inverse_gc = XCreateGC(dpy, s->root,
GCForeground | GCBackground | GCFunction
| GCLineWidth | GCSubwindowMode,
- &gv);
+ &gcv);
/* Create the program bar window. */
s->bar_is_raised = 0;