summary refs log tree commit diff stats
path: root/c/acronym
diff options
context:
space:
mode:
Diffstat (limited to 'c/acronym')
-rw-r--r--c/acronym/src/acronym.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/c/acronym/src/acronym.c b/c/acronym/src/acronym.c
index 35cbfe9..9d86a6d 100644
--- a/c/acronym/src/acronym.c
+++ b/c/acronym/src/acronym.c
@@ -13,11 +13,11 @@ char *abbreviate(const char *phrase) {
         acronym[pos++] = toupper((unsigned char) phrase[0]);
 
     for (size_t idx = 0; phrase[idx] != '\0'; idx++)
-        if (phrase[idx] == ' ' || phrase[idx] == '-' || phrase[idx] == '_')
-            if (phrase[idx + 1] != '\0' && isalpha(phrase[idx + 1])) {
-                acronym = realloc(acronym, (pos + 1) * sizeof(char));
-                acronym[pos++] = toupper((unsigned char) phrase[idx + 1]);
-            }
+        if ((phrase[idx] == ' ' || phrase[idx] == '-' || phrase[idx] == '_')
+            && isalpha(phrase[idx + 1])) {
+            acronym = realloc(acronym, (pos + 1) * sizeof(char));
+            acronym[pos++] = toupper((unsigned char) phrase[idx + 1]);
+        }
 
     acronym = realloc(acronym, (pos + 1) * sizeof(char));
     acronym[pos] = '\0';