Reduce variable scopes

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2014-10-23 21:00:20 +03:00
parent 5e3615b246
commit c03834a1c6
5 changed files with 12 additions and 17 deletions

View File

@ -166,8 +166,6 @@ get_home_xcompose_file_path(void)
char *
get_locale_compose_file_path(const char *locale)
{
int ret;
const char *xlocaledir;
char *resolved;
char *path;
@ -193,8 +191,8 @@ get_locale_compose_file_path(const char *locale)
path = resolved;
}
else {
xlocaledir = get_xlocaledir_path();
ret = asprintf(&path, "%s/%s", xlocaledir, resolved);
const char *xlocaledir = get_xlocaledir_path();
int ret = asprintf(&path, "%s/%s", xlocaledir, resolved);
free(resolved);
if (ret < 0)
return NULL;

View File

@ -1163,14 +1163,13 @@ xkb_state_mod_indices_are_active(struct xkb_state *state,
...)
{
va_list ap;
xkb_mod_index_t idx = 0;
xkb_mod_mask_t wanted = 0;
int ret = 0;
xkb_mod_index_t num_mods = xkb_keymap_num_mods(state->keymap);
va_start(ap, match);
while (1) {
idx = va_arg(ap, xkb_mod_index_t);
xkb_mod_index_t idx = va_arg(ap, xkb_mod_index_t);
if (idx == XKB_MOD_INVALID)
break;
if (idx >= num_mods) {
@ -1214,12 +1213,12 @@ xkb_state_mod_names_are_active(struct xkb_state *state,
...)
{
va_list ap;
xkb_mod_index_t idx = 0;
xkb_mod_mask_t wanted = 0;
int ret = 0;
va_start(ap, match);
while (1) {
xkb_mod_index_t idx;
const char *str = va_arg(ap, const char *);
if (str == NULL)
break;

View File

@ -377,8 +377,6 @@ static void
MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
enum merge_mode merge)
{
SymInterpInfo *si;
if (from->errorCount > 0) {
into->errorCount += from->errorCount;
return;
@ -396,6 +394,7 @@ MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
darray_init(from->interps);
}
else {
SymInterpInfo *si;
darray_foreach(si, from->interps) {
si->merge = (merge == MERGE_DEFAULT ? si->merge : merge);
if (!AddInterp(into, si, false))

View File

@ -499,8 +499,6 @@ static void
MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
enum merge_mode merge)
{
KeyInfo *keyi;
ModMapEntry *mm;
xkb_atom_t *group_name;
xkb_layout_index_t group_names_in_both;
@ -536,6 +534,7 @@ MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
darray_init(from->keys);
}
else {
KeyInfo *keyi;
darray_foreach(keyi, from->keys) {
keyi->merge = (merge == MERGE_DEFAULT ? keyi->merge : merge);
if (!AddKeySymbols(into, keyi, false))
@ -548,6 +547,7 @@ MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
darray_init(from->modmaps);
}
else {
ModMapEntry *mm;
darray_foreach(mm, from->modmaps) {
mm->merge = (merge == MERGE_DEFAULT ? mm->merge : merge);
if (!AddModMapEntry(into, mm))
@ -1258,13 +1258,12 @@ FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym)
{
struct xkb_key *key;
xkb_layout_index_t group;
xkb_level_index_t level;
bool got_one_group, got_one_level;
group = 0;
do {
xkb_level_index_t level = 0;
got_one_group = false;
level = 0;
do {
got_one_level = false;
xkb_keys_foreach(key, keymap) {
@ -1299,8 +1298,8 @@ FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym)
static xkb_atom_t
FindAutomaticType(struct xkb_context *ctx, GroupInfo *groupi)
{
xkb_keysym_t sym0, sym1, sym2, sym3;
xkb_level_index_t width = darray_size(groupi->levels);
xkb_keysym_t sym0, sym1;
const xkb_level_index_t width = darray_size(groupi->levels);
#define GET_SYM(level) \
(darray_item(groupi->levels, level).num_syms == 0 ? \
@ -1328,6 +1327,7 @@ FindAutomaticType(struct xkb_context *ctx, GroupInfo *groupi)
if (width <= 4) {
if (xkb_keysym_is_lower(sym0) && xkb_keysym_is_upper(sym1)) {
xkb_keysym_t sym2, sym3;
sym2 = GET_SYM(2);
sym3 = (width == 4 ? GET_SYM(3) : XKB_KEY_NoSymbol);

View File

@ -174,8 +174,6 @@ static void
MergeIncludedKeyTypes(KeyTypesInfo *into, KeyTypesInfo *from,
enum merge_mode merge)
{
KeyTypeInfo *type;
if (from->errorCount > 0) {
into->errorCount += from->errorCount;
return;
@ -193,6 +191,7 @@ MergeIncludedKeyTypes(KeyTypesInfo *into, KeyTypesInfo *from,
darray_init(from->types);
}
else {
KeyTypeInfo *type;
darray_foreach(type, from->types) {
type->merge = (merge == MERGE_DEFAULT ? type->merge : merge);
if (!AddKeyType(into, type, false))