New style

Mon, 12 Jun 2017 09:47:46 +0200

author
David Demelier <markand@malikania.fr>
date
Mon, 12 Jun 2017 09:47:46 +0200
changeset 3
d9d3406c1250
parent 2
84765c6f4872
child 4
34a7a99dbcfa

New style

generator/cat/cat.cpp file | annotate | diff | comparison | revisions
generator/make-unicode/src/mkunicode.c file | annotate | diff | comparison | revisions
generator/make-unicode/unicode-after.cpp file | annotate | diff | comparison | revisions
generator/make-unicode/unicode.hpp file | annotate | diff | comparison | revisions
unicode.cpp file | annotate | diff | comparison | revisions
unicode.hpp file | annotate | diff | comparison | revisions
--- a/generator/cat/cat.cpp	Thu Feb 02 18:07:27 2017 +0100
+++ b/generator/cat/cat.cpp	Mon Jun 12 09:47:46 2017 +0200
@@ -38,9 +38,8 @@
         std::ifstream input(argv[i]);
         std::string line;
 
-        while (std::getline(input, line)) {
+        while (std::getline(input, line))
             output << line << "\n";
-        }
     }
 
     return 0;
--- a/generator/make-unicode/src/mkunicode.c	Thu Feb 02 18:07:27 2017 +0100
+++ b/generator/make-unicode/src/mkunicode.c	Mon Jun 12 09:47:46 2017 +0200
@@ -391,27 +391,24 @@
     if(isr)
         fprintf(out,
             "    p = rbsearch(c, is%sr, nelem (is%sr) / 2, 2);\n\n"
-            "    if (p && c >= p[0] && c <= p[1]) {\n"
-            "        return true;\n"
-            "    }\n",
+            "    if (p && c >= p[0] && c <= p[1])\n"
+            "        return true;\n",
             label, label);
 
     if(isp)
         fprintf(out,
             "\n"
             "    p = rbsearch(c, is%sp, nelem (is%sp) / 2, 2);\n\n"
-            "    if (p && c >= p[0] && c <= p[1] && !((c - p[0]) & 1)) {\n"
-            "        return true;\n"
-            "    }\n",
+            "    if (p && c >= p[0] && c <= p[1] && !((c - p[0]) & 1))\n"
+            "        return true;\n",
             label, label);
 
     if(iss)
         fprintf(out,
             "\n"
             "    p = rbsearch(c, is%ss, nelem (is%ss), 1);\n\n"
-            "    if (p && c == p[0]) {\n"
-            "        return true;\n"
-            "    }\n",
+            "    if (p && c == p[0])\n"
+            "        return true;\n",
             label, label);
 
 
@@ -570,27 +567,24 @@
     if(tor)
         fprintf(out,
             "    p = rbsearch(c, to%sr, nelem (to%sr) / 3, 3);\n\n"
-            "    if (p && c >= p[0] && c <= p[1]) {\n"
-            "        return c + p[2] - %d;\n"
-            "    }\n",
+            "    if (p && c >= p[0] && c <= p[1])\n"
+            "        return c + p[2] - %d;\n",
             label, label, TO_OFFSET);
 
     if(top)
         fprintf(out,
             "\n"
             "    p = rbsearch(c, to%sp, nelem (to%sp) / 3, 3);\n\n"
-            "    if (p && c >= p[0] && c <= p[1] && !((c - p[0]) & 1)) {\n"
-            "        return c + p[2] - %d;\n"
-            "    }\n",
+            "    if (p && c >= p[0] && c <= p[1] && !((c - p[0]) & 1))\n"
+            "        return c + p[2] - %d;\n",
             label, label, TO_OFFSET);
 
     if(tos)
         fprintf(out,
             "\n"
             "    p = rbsearch(c, to%ss, nelem (to%ss) / 2, 2);\n\n"
-            "    if (p && c == p[0]) {\n"
-            "        return c + p[1] - %d;\n"
-            "    }\n\n",
+            "    if (p && c == p[0])\n"
+            "        return c + p[1] - %d;\n\n",
             label, label, TO_OFFSET);
 
     fprintf(out,
@@ -611,9 +605,8 @@
         "    const char32_t* p;\n"
         "\n"
         "    p = rbsearch(c, is%sr, nelem (is%sr) / 2, 2);\n\n"
-        "    if (p && c >= p[0] && c <= p[1]) {\n"
-        "        return true;\n"
-        "    }\n\n"
+        "    if (p && c >= p[0] && c <= p[1])\n"
+        "        return true;\n\n"
         "    return false;\n"
         "}\n"
         "\n",
@@ -645,13 +638,11 @@
         "        if (c >= p[0]) {\n"
         "            t = p;\n"
         "            n = n - m;\n"
-        "        } else {\n"
+        "        } else\n"
         "            n = m;\n"
-        "        }\n"
         "    }\n\n"
-        "    if (n && c >= t[0]) {\n"
-        "        return t;\n"
-        "    }\n\n"
+        "    if (n && c >= t[0])\n"
+        "        return t;\n\n"
         "    return nullptr;\n"
         "}\n\n"
         "} // !namespace\n\n"
--- a/generator/make-unicode/unicode-after.cpp	Thu Feb 02 18:07:27 2017 +0100
+++ b/generator/make-unicode/unicode-after.cpp	Mon Jun 12 09:47:46 2017 +0200
@@ -57,36 +57,28 @@
 
 int nbytes_utf8(char c) noexcept
 {
-    if (static_cast<unsigned char>(c) <= 127) {
+    if (static_cast<unsigned char>(c) <= 127)
         return 1;
-    }
-    if ((c & 0xE0) == 0xC0) {
+    if ((c & 0xE0) == 0xC0)
         return 2;
-    }
-    if ((c & 0xF0) == 0xE0) {
+    if ((c & 0xF0) == 0xE0)
         return 3;
-    }
-    if ((c & 0xF8) == 0xF0) {
+    if ((c & 0xF8) == 0xF0)
         return 4;
-    }
 
     return -1;
 }
 
 int nbytes_point(char32_t c) noexcept
 {
-    if (c <= 0x7F) {
+    if (c <= 0x7F)
         return 1;
-    }
-    if (c <= 0x7FF) {
+    if (c <= 0x7FF)
         return 2;
-    }
-    if (c <= 0xFFFF) {
+    if (c <= 0xFFFF)
         return 3;
-    }
-    if (c <= 0x1FFFFF) {
+    if (c <= 0x1FFFFF)
         return 4;
-    }
 
     return -1;
 }
@@ -110,9 +102,8 @@
         char tmp[5];
         int size = nbytes_point(array[i]);
 
-        if (size < 0) {
+        if (size < 0)
             throw std::invalid_argument("invalid sequence");
-        }
 
         encode(array[i], tmp);
         res.insert(res.length(), tmp);
--- a/generator/make-unicode/unicode.hpp	Thu Feb 02 18:07:27 2017 +0100
+++ b/generator/make-unicode/unicode.hpp	Mon Jun 12 09:47:46 2017 +0200
@@ -130,9 +130,8 @@
         char32_t point = 0;
         int size = nbytes_utf8(str[i]);
 
-        if (size < 0) {
+        if (size < 0)
             throw std::invalid_argument("invalid sequence");
-        }
 
         decode(point, str.data() + i);
         function(point);
@@ -239,9 +238,8 @@
  */
 inline std::u32string toupper(std::u32string str)
 {
-    for (size_t i = 0; i < str.size(); ++i) {
+    for (size_t i = 0; i < str.size(); ++i)
         str[i] = toupper(str[i]);
-    }
 
     return str;
 }
@@ -274,9 +272,8 @@
  */
 inline std::u32string tolower(std::u32string str)
 {
-    for (size_t i = 0; i < str.size(); ++i) {
+    for (size_t i = 0; i < str.size(); ++i)
         str[i] = tolower(str[i]);
-    }
 
     return str;
 }
--- a/unicode.cpp	Thu Feb 02 18:07:27 2017 +0100
+++ b/unicode.cpp	Mon Jun 12 09:47:46 2017 +0200
@@ -41,14 +41,12 @@
         if (c >= p[0]) {
             t = p;
             n = n - m;
-        } else {
+        } else
             n = m;
-        }
     }
 
-    if (n && c >= t[0]) {
+    if (n && c >= t[0])
         return t;
-    }
 
     return nullptr;
 }
@@ -79,9 +77,8 @@
 
     p = rbsearch(c, isspacer, nelem (isspacer) / 2, 2);
 
-    if (p && c >= p[0] && c <= p[1]) {
+    if (p && c >= p[0] && c <= p[1])
         return true;
-    }
 
     return false;
 }
@@ -149,9 +146,8 @@
 
     p = rbsearch(c, isdigitr, nelem (isdigitr) / 2, 2);
 
-    if (p && c >= p[0] && c <= p[1]) {
+    if (p && c >= p[0] && c <= p[1])
         return true;
-    }
 
     return false;
 }
@@ -713,15 +709,13 @@
 
     p = rbsearch(c, isalphar, nelem (isalphar) / 2, 2);
 
-    if (p && c >= p[0] && c <= p[1]) {
+    if (p && c >= p[0] && c <= p[1])
         return true;
-    }
 
     p = rbsearch(c, isalphas, nelem (isalphas), 1);
 
-    if (p && c == p[0]) {
+    if (p && c == p[0])
         return true;
-    }
 
     return false;
 }
@@ -1373,15 +1367,13 @@
 
     p = rbsearch(c, isupperr, nelem (isupperr) / 2, 2);
 
-    if (p && c >= p[0] && c <= p[1]) {
+    if (p && c >= p[0] && c <= p[1])
         return true;
-    }
 
     p = rbsearch(c, isuppers, nelem (isuppers), 1);
 
-    if (p && c == p[0]) {
+    if (p && c == p[0])
         return true;
-    }
 
     return false;
 }
@@ -2033,15 +2025,13 @@
 
     p = rbsearch(c, islowerr, nelem (islowerr) / 2, 2);
 
-    if (p && c >= p[0] && c <= p[1]) {
+    if (p && c >= p[0] && c <= p[1])
         return true;
-    }
 
     p = rbsearch(c, islowers, nelem (islowers), 1);
 
-    if (p && c == p[0]) {
+    if (p && c == p[0])
         return true;
-    }
 
     return false;
 }
@@ -2646,15 +2636,13 @@
 
     p = rbsearch(c, istitler, nelem (istitler) / 2, 2);
 
-    if (p && c >= p[0] && c <= p[1]) {
+    if (p && c >= p[0] && c <= p[1])
         return true;
-    }
 
     p = rbsearch(c, istitles, nelem (istitles), 1);
 
-    if (p && c == p[0]) {
+    if (p && c == p[0])
         return true;
-    }
 
     return false;
 }
@@ -3323,15 +3311,13 @@
 
     p = rbsearch(c, toupperr, nelem (toupperr) / 3, 3);
 
-    if (p && c >= p[0] && c <= p[1]) {
+    if (p && c >= p[0] && c <= p[1])
         return c + p[2] - 1048576;
-    }
 
     p = rbsearch(c, touppers, nelem (touppers) / 2, 2);
 
-    if (p && c == p[0]) {
+    if (p && c == p[0])
         return c + p[1] - 1048576;
-    }
 
     return c;
 }
@@ -3992,15 +3978,13 @@
 
     p = rbsearch(c, tolowerr, nelem (tolowerr) / 3, 3);
 
-    if (p && c >= p[0] && c <= p[1]) {
+    if (p && c >= p[0] && c <= p[1])
         return c + p[2] - 1048576;
-    }
 
     p = rbsearch(c, tolowers, nelem (tolowers) / 2, 2);
 
-    if (p && c == p[0]) {
+    if (p && c == p[0])
         return c + p[1] - 1048576;
-    }
 
     return c;
 }
@@ -4669,15 +4653,13 @@
 
     p = rbsearch(c, totitler, nelem (totitler) / 3, 3);
 
-    if (p && c >= p[0] && c <= p[1]) {
+    if (p && c >= p[0] && c <= p[1])
         return c + p[2] - 1048576;
-    }
 
     p = rbsearch(c, totitles, nelem (totitles) / 2, 2);
 
-    if (p && c == p[0]) {
+    if (p && c == p[0])
         return c + p[1] - 1048576;
-    }
 
     return c;
 }
@@ -4741,36 +4723,28 @@
 
 int nbytes_utf8(char c) noexcept
 {
-    if (static_cast<unsigned char>(c) <= 127) {
+    if (static_cast<unsigned char>(c) <= 127)
         return 1;
-    }
-    if ((c & 0xE0) == 0xC0) {
+    if ((c & 0xE0) == 0xC0)
         return 2;
-    }
-    if ((c & 0xF0) == 0xE0) {
+    if ((c & 0xF0) == 0xE0)
         return 3;
-    }
-    if ((c & 0xF8) == 0xF0) {
+    if ((c & 0xF8) == 0xF0)
         return 4;
-    }
 
     return -1;
 }
 
 int nbytes_point(char32_t c) noexcept
 {
-    if (c <= 0x7F) {
+    if (c <= 0x7F)
         return 1;
-    }
-    if (c <= 0x7FF) {
+    if (c <= 0x7FF)
         return 2;
-    }
-    if (c <= 0xFFFF) {
+    if (c <= 0xFFFF)
         return 3;
-    }
-    if (c <= 0x1FFFFF) {
+    if (c <= 0x1FFFFF)
         return 4;
-    }
 
     return -1;
 }
@@ -4794,9 +4768,8 @@
         char tmp[5];
         int size = nbytes_point(array[i]);
 
-        if (size < 0) {
+        if (size < 0)
             throw std::invalid_argument("invalid sequence");
-        }
 
         encode(array[i], tmp);
         res.insert(res.length(), tmp);
--- a/unicode.hpp	Thu Feb 02 18:07:27 2017 +0100
+++ b/unicode.hpp	Mon Jun 12 09:47:46 2017 +0200
@@ -130,9 +130,8 @@
         char32_t point = 0;
         int size = nbytes_utf8(str[i]);
 
-        if (size < 0) {
+        if (size < 0)
             throw std::invalid_argument("invalid sequence");
-        }
 
         decode(point, str.data() + i);
         function(point);
@@ -239,9 +238,8 @@
  */
 inline std::u32string toupper(std::u32string str)
 {
-    for (size_t i = 0; i < str.size(); ++i) {
+    for (size_t i = 0; i < str.size(); ++i)
         str[i] = toupper(str[i]);
-    }
 
     return str;
 }
@@ -274,9 +272,8 @@
  */
 inline std::u32string tolower(std::u32string str)
 {
-    for (size_t i = 0; i < str.size(); ++i) {
+    for (size_t i = 0; i < str.size(); ++i)
         str[i] = tolower(str[i]);
-    }
 
     return str;
 }

mercurial