Ticket #13828: 0003-Reduce-levels-of-nesting-in-setlocale.patch

File 0003-Reduce-levels-of-nesting-in-setlocale.patch, 1.4 KB (added by KeyboardFire, 6 years ago)
  • src/bin/setlocale.cpp

    From 9f9dc8ea40e5ab4eae42b76d24448c4f620f2d90 Mon Sep 17 00:00:00 2001
    From: KeyboardFire <andy@keyboardfire.com>
    Date: Sun, 3 Dec 2017 10:16:35 -0600
    Subject: [PATCH 3/4] Reduce levels of nesting in setlocale
    
    ---
     src/bin/setlocale.cpp | 25 ++++++++++++-------------
     1 file changed, 12 insertions(+), 13 deletions(-)
    
    diff --git a/src/bin/setlocale.cpp b/src/bin/setlocale.cpp
    index d143337324..59d20dd660 100644
    a b int main(int argc, char **argv)  
    5656                }
    5757            } else
    5858                err = false; // unknown flag
    59         } else {
     59        } else if (queryCode == NULL)
    6060            // bare argument; fill up code and then country, erroring on
    6161            // anything more than two arguments
    62             if (queryCode == NULL)
    63                 queryCode = argv[i];
    64             else if (queryCountry == NULL)
    65                 queryCountry = argv[i];
    66             else {
    67                 err = true;
    68                 break;
    69             }
    70 
     62            queryCode = argv[i];
     63        else if (queryCountry == NULL)
     64            queryCountry = argv[i];
     65        else {
     66            err = true;
     67            break;
    7168        }
    7269    }
    7370
    int main(int argc, char **argv)  
    123120            fprintf(stderr, "Failed to get BLanguage for %s\n", id);
    124121    }
    125122
    126     if (list)
    127         return 0;
    128     else {
     123    // if we've gotten this far and the -l flag wasn't passed, the requested
     124    // locale wasn't found
     125    if (!list) {
    129126        fprintf(stderr, "Locale not found\n");
    130127        return 1;
    131128    }
     129
     130    return 0;
    132131}