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)
|
56 | 56 | } |
57 | 57 | } else |
58 | 58 | err = false; // unknown flag |
59 | | } else { |
| 59 | } else if (queryCode == NULL) |
60 | 60 | // bare argument; fill up code and then country, erroring on |
61 | 61 | // 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; |
71 | 68 | } |
72 | 69 | } |
73 | 70 | |
… |
… |
int main(int argc, char **argv)
|
123 | 120 | fprintf(stderr, "Failed to get BLanguage for %s\n", id); |
124 | 121 | } |
125 | 122 | |
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) { |
129 | 126 | fprintf(stderr, "Locale not found\n"); |
130 | 127 | return 1; |
131 | 128 | } |
| 129 | |
| 130 | return 0; |
132 | 131 | } |