diff --git a/.clang-format b/.clang-format index ee4f548e1..23dc43d55 100644 --- a/.clang-format +++ b/.clang-format @@ -1,3 +1,4 @@ +Standard: Cpp03 SpaceBeforeAssignmentOperators: false SpaceBeforeParens: Always AlwaysBreakAfterReturnType: TopLevelDefinitions @@ -10,4 +11,4 @@ BreakBeforeBraces: Custom BraceWrapping: BeforeElse: true PointerAlignment: Left -CommentPragmas: '^\\.+' \ No newline at end of file +CommentPragmas: '^\\.+' diff --git a/Data/String/fast_search.cpp b/Data/String/fast_search.cpp index 9109d6f88..d441180b4 100644 --- a/Data/String/fast_search.cpp +++ b/Data/String/fast_search.cpp @@ -53,7 +53,7 @@ string_searcher_rep::string_searcher_rep (string s2) : s (s2), a () { codes[i]= (int) (unsigned int) (unsigned char) s[i]; int l= 1; while (l <= n) { - hashmap> h; + hashmap > h; for (i= 0; i + l <= n; i++) { int c= codes[i]; if (!h->contains (c)) h (c)= array (); @@ -129,9 +129,9 @@ get_longest_common (string s1, string s2, int& b1, int& e1, int& b2, int& e2) { string_searcher ss1 (s1); string_searcher ss2 (s2); for (int i= min (N (ss1->a), N (ss2->a)) - 1; i >= 0; i--) { - hashmap> a1= ss1->a[i]; - hashmap> a2= ss2->a[i]; - iterator it= iterate (a1); + hashmap > a1= ss1->a[i]; + hashmap > a2= ss2->a[i]; + iterator it= iterate (a1); while (it->busy ()) { int h = it->next (); array ps1= a1[h]; diff --git a/Data/String/fast_search.hpp b/Data/String/fast_search.hpp index 67375d520..4bfd5c06f 100644 --- a/Data/String/fast_search.hpp +++ b/Data/String/fast_search.hpp @@ -18,9 +18,9 @@ class string_searcher; class string_searcher_rep : concrete_struct { - string s; - array>> a; - array search_sub (string what); + string s; + array > > a; + array search_sub (string what); public: string_searcher_rep (string s); diff --git a/Kernel/Abstractions/blackbox.hpp b/Kernel/Abstractions/blackbox.hpp index 8d11a892c..9a6ef3eb8 100644 --- a/Kernel/Abstractions/blackbox.hpp +++ b/Kernel/Abstractions/blackbox.hpp @@ -67,7 +67,7 @@ type_box (blackbox bb) { template blackbox close_box (const T& data) { - return tm_new> (data); + return tm_new > (data); } template diff --git a/Kernel/Algorithms/merge_sort.hpp b/Kernel/Algorithms/merge_sort.hpp index 80f1cfb6b..c5b867eb1 100644 --- a/Kernel/Algorithms/merge_sort.hpp +++ b/Kernel/Algorithms/merge_sort.hpp @@ -58,7 +58,7 @@ merge_sort_leq (array& a) { template inline void merge_sort (array& a) { - merge_sort_leq> (a); + merge_sort_leq > (a); } /****************************************************************************** @@ -127,7 +127,7 @@ merge_sort_leq_permutation (array& a) { template array merge_sort_leq_permutation (array& a) { - return merge_sort_leq_permutation> (a); + return merge_sort_leq_permutation > (a); } template diff --git a/Kernel/Containers/array.hpp b/Kernel/Containers/array.hpp index 9d3ac45f4..a1b6f0d77 100644 --- a/Kernel/Containers/array.hpp +++ b/Kernel/Containers/array.hpp @@ -98,7 +98,7 @@ template class array { /** * @brief Construct a new array object with length 0. */ - inline array (int n= 0) : rep (tm_new> (n)) {} + inline array (int n= 0) : rep (tm_new > (n)) {} /** * @brief Construct a new array object from a C array with specified length. diff --git a/Kernel/Containers/array.ipp b/Kernel/Containers/array.ipp index cd63394f1..3b990448e 100644 --- a/Kernel/Containers/array.ipp +++ b/Kernel/Containers/array.ipp @@ -56,26 +56,26 @@ array_rep::resize (int m) { template array::array (T* a, int n) { int i; - rep= tm_new> (n); + rep= tm_new > (n); for (i= 0; i < n; i++) rep->a[i]= a[i]; } template array::array (T x1, T x2) { - rep = tm_new> (2); + rep = tm_new > (2); rep->a[0]= x1; rep->a[1]= x2; } template array::array (T x1, T x2, T x3) { - rep = tm_new> (3); + rep = tm_new > (3); rep->a[0]= x1; rep->a[1]= x2; rep->a[2]= x3; } template array::array (T x1, T x2, T x3, T x4) { - rep = tm_new> (4); + rep = tm_new > (4); rep->a[0]= x1; rep->a[1]= x2; rep->a[2]= x3; @@ -83,7 +83,7 @@ template array::array (T x1, T x2, T x3, T x4) { } template array::array (T x1, T x2, T x3, T x4, T x5) { - rep = tm_new> (5); + rep = tm_new > (5); rep->a[0]= x1; rep->a[1]= x2; rep->a[2]= x3; diff --git a/Kernel/Containers/hashfunc.hpp b/Kernel/Containers/hashfunc.hpp index 5bf142f39..09394a4b5 100644 --- a/Kernel/Containers/hashfunc.hpp +++ b/Kernel/Containers/hashfunc.hpp @@ -50,7 +50,7 @@ template class hashfunc { * @param init The initial value for the hash map. */ inline hashfunc (U (*func) (T), U init) - : rep (tm_new> (func, init)) {} + : rep (tm_new > (func, init)) {} /** * @brief Applies the hash function to the given input. diff --git a/Kernel/Containers/hashmap.hpp b/Kernel/Containers/hashmap.hpp index 23b3793d7..74d753296 100644 --- a/Kernel/Containers/hashmap.hpp +++ b/Kernel/Containers/hashmap.hpp @@ -41,16 +41,16 @@ template struct hashentry { }; template class hashmap_rep : concrete_struct { - int size; // size of hashmap (nr of entries) - int n; // nr of keys (a power of two) - int max; // mean number of entries per key - U init; // default entry - list>* a; // the array of entries + int size; // size of hashmap (nr of entries) + int n; // nr of keys (a power of two) + int max; // mean number of entries per key + U init; // default entry + list >* a; // the array of entries public: inline hashmap_rep (U init2, int n2= 1, int max2= 1) : size (0), n (n2), max (max2), init (init2), - a (tm_new_array>> (n)) {} + a (tm_new_array > > (n)) {} inline ~hashmap_rep () { tm_delete_array (a); } void resize (int n); void reset (T x); @@ -88,9 +88,9 @@ template class hashmap { CONCRETE_TEMPLATE_2 (hashmap, T, U); static hashmap init; inline hashmap () - : rep (tm_new> (type_helper::init_val (), 1, 1)) {} + : rep (tm_new > (type_helper::init_val (), 1, 1)) {} inline hashmap (U init, int n= 1, int max= 1) - : rep (tm_new> (init, n, max)) {} + : rep (tm_new > (init, n, max)) {} inline U operator[] (T x) { return rep->bracket_ro (x); } inline U& operator() (T x) { return rep->bracket_rw (x); } }; diff --git a/Kernel/Containers/hashmap.ipp b/Kernel/Containers/hashmap.ipp index 6c0d6365f..ff58f055d 100644 --- a/Kernel/Containers/hashmap.ipp +++ b/Kernel/Containers/hashmap.ipp @@ -46,17 +46,17 @@ operator!= (H h1, H h2) { TMPL void hashmap_rep::resize (int n2) { - int i; - int oldn= n; - list>* olda= a; - n = n2; - a = tm_new_array>> (n); + int i; + int oldn= n; + list >* olda= a; + n = n2; + a = tm_new_array > > (n); for (i= 0; i < oldn; i++) { - list> l (olda[i]); + list > l (olda[i]); while (!is_nil (l)) { - list>& newl= a[hash (l->item.key) & (n - 1)]; - newl = list> (l->item, newl); - l = l->next; + list >& newl= a[hash (l->item.key) & (n - 1)]; + newl = list > (l->item, newl); + l = l->next; } } tm_delete_array (olda); @@ -64,8 +64,8 @@ hashmap_rep::resize (int n2) { TMPL bool hashmap_rep::contains (T x) { - int hv= hash (x); - list> l (a[hv & (n - 1)]); + int hv= hash (x); + list > l (a[hv & (n - 1)]); while (!is_nil (l)) { if (l->item.code == hv && l->item.key == x) return true; l= l->next; @@ -80,23 +80,23 @@ hashmap_rep::empty () { TMPL U& hashmap_rep::bracket_rw (T x) { - int hv= hash (x); - list> l (a[hv & (n - 1)]); + int hv= hash (x); + list > l (a[hv & (n - 1)]); while (!is_nil (l)) { if (l->item.code == hv && l->item.key == x) return l->item.im; l= l->next; } if (size >= n * max) resize (n << 1); - list>& rl= a[hv & (n - 1)]; - rl = list> (H (hv, x, init), rl); + list >& rl= a[hv & (n - 1)]; + rl = list > (H (hv, x, init), rl); size++; return rl->item.im; } TMPL U hashmap_rep::bracket_ro (T x) { - int hv= hash (x); - list> l (a[hv & (n - 1)]); + int hv= hash (x); + list > l (a[hv & (n - 1)]); while (!is_nil (l)) { if (l->item.code == hv && l->item.key == x) return l->item.im; l= l->next; @@ -106,8 +106,8 @@ hashmap_rep::bracket_ro (T x) { TMPL void hashmap_rep::reset (T x) { - int hv= hash (x); - list>* l = &(a[hv & (n - 1)]); + int hv= hash (x); + list >* l = &(a[hv & (n - 1)]); while (!is_nil (*l)) { if ((*l)->item.code == hv && (*l)->item.key == x) { *l= (*l)->next; @@ -123,7 +123,7 @@ TMPL void hashmap_rep::generate (void (*routine) (T)) { int i; for (i= 0; i < n; i++) { - list> l (a[i]); + list > l (a[i]); while (!is_nil (l)) { routine (l->item.key); l= l->next; @@ -136,7 +136,7 @@ operator<< (tm_ostream& out, hashmap h) { int i= 0, j= 0, n= h->n, size= h->size; out << "{ "; for (; i < n; i++) { - list> l= h->a[i]; + list > l= h->a[i]; for (; !is_nil (l); l= l->next, j++) { out << l->item; if (j != size - 1) out << ", "; @@ -150,7 +150,7 @@ TMPL void hashmap_rep::join (hashmap h) { int i= 0, n= h->n; for (; i < n; i++) { - list> l= h->a[i]; + list > l= h->a[i]; for (; !is_nil (l); l= l->next) bracket_rw (l->item.key)= copy (l->item.im); } @@ -161,7 +161,7 @@ operator== (hashmap h1, hashmap h2) { if (h1->size != h2->size) return false; int i= 0, n= h1->n; for (; i < n; i++) { - list> l= h1->a[i]; + list > l= h1->a[i]; for (; !is_nil (l); l= l->next) if (h2[l->item.key] != l->item.im) return false; } diff --git a/Kernel/Containers/hashmap_extra.ipp b/Kernel/Containers/hashmap_extra.ipp index 57e6270aa..d71c35e48 100644 --- a/Kernel/Containers/hashmap_extra.ipp +++ b/Kernel/Containers/hashmap_extra.ipp @@ -18,18 +18,18 @@ TMPL void hashmap_rep::write_back (T x, hashmap base) { - int hv= hash (x); - list> l (a[hv & (n - 1)]); + int hv= hash (x); + list > l (a[hv & (n - 1)]); while (!is_nil (l)) { if (l->item.code == hv && l->item.key == x) return; l= l->next; } if (size >= n * max) resize (n << 1); - list>& rl= a[hv & (n - 1)]; - rl = list> (H (hv, x, init), rl); + list >& rl= a[hv & (n - 1)]; + rl = list > (H (hv, x, init), rl); size++; - list> bl (base->a[hv & (base->n - 1)]); + list > bl (base->a[hv & (base->n - 1)]); while (!is_nil (bl)) { if (bl->item.code == hv && bl->item.key == x) { rl->item.im= bl->item.im; @@ -44,7 +44,7 @@ TMPL void hashmap_rep::pre_patch (hashmap patch, hashmap base) { int i= 0, n= patch->n; for (; i < n; i++) { - list> l= patch->a[i]; + list > l= patch->a[i]; for (; !is_nil (l); l= l->next) { T x= l->item.key; U y= contains (x) ? bracket_ro (x) : l->item.im; @@ -58,7 +58,7 @@ TMPL void hashmap_rep::post_patch (hashmap patch, hashmap base) { int i= 0, n= patch->n; for (; i < n; i++) { - list> l= patch->a[i]; + list > l= patch->a[i]; for (; !is_nil (l); l= l->next) { T x= l->item.key; U y= l->item.im; @@ -68,11 +68,11 @@ hashmap_rep::post_patch (hashmap patch, hashmap base) { } } -TMPL list> - copy_list (list> l) { +TMPL list > + copy_list (list > l) { if (is_nil (l)) return l; else - return list> ( + return list > ( hashentry (l->item.code, l->item.key, l->item.im), copy_list (l->next)); } @@ -92,7 +92,7 @@ TMPL hashmap int i; hashmap h (base->init); for (i= 0; i < patch->n; i++) { - list> l (patch->a[i]); + list > l (patch->a[i]); while (!is_nil (l)) { if (l->item.im != base[l->item.key]) h (l->item.key)= l->item.im; l= l->next; @@ -106,7 +106,7 @@ TMPL hashmap int i; hashmap h (base->init); for (i= 0; i < patch->n; i++) { - list> l (patch->a[i]); + list > l (patch->a[i]); while (!is_nil (l)) { if (l->item.im != base[l->item.key]) h (l->item.key)= base[l->item.key]; l= l->next; diff --git a/Kernel/Containers/hashset.hpp b/Kernel/Containers/hashset.hpp index 5bb36ea92..985cabf2b 100644 --- a/Kernel/Containers/hashset.hpp +++ b/Kernel/Containers/hashset.hpp @@ -35,7 +35,7 @@ template class hashset_rep : concrete_struct { * */ inline hashset_rep () - : size (0), n (1), max (1), a (tm_new_array> (1)) {} + : size (0), n (1), max (1), a (tm_new_array > (1)) {} /** * @brief Construct a new hashset_rep object with specified values. @@ -44,7 +44,7 @@ template class hashset_rep : concrete_struct { * @param max2 The mean number of entries per key. */ inline hashset_rep (int n2, int max2= 1) - : size (0), n (n2), max (max2), a (tm_new_array> (n)) {} + : size (0), n (n2), max (max2), a (tm_new_array > (n)) {} /** * @brief Destroy the hashset_rep object. @@ -79,7 +79,7 @@ template class hashset { * @param max The mean number of entries per key. */ inline hashset (int n= 1, int max= 1) - : rep (tm_new> (n, max)) {} + : rep (tm_new > (n, max)) {} }; CONCRETE_TEMPLATE_CODE (hashset, class, T); diff --git a/Kernel/Containers/hashset.ipp b/Kernel/Containers/hashset.ipp index c4ba37b16..00c8bc958 100644 --- a/Kernel/Containers/hashset.ipp +++ b/Kernel/Containers/hashset.ipp @@ -20,7 +20,7 @@ hashset_rep::resize (int n2) { int oldn= n; list* olda= a; n = n2; - a = tm_new_array> (n); + a = tm_new_array > (n); for (i= 0; i < oldn; i++) { list l (olda[i]); while (!is_nil (l)) { diff --git a/Kernel/Containers/hashtree.hpp b/Kernel/Containers/hashtree.hpp index 89d949488..36290f6a5 100644 --- a/Kernel/Containers/hashtree.hpp +++ b/Kernel/Containers/hashtree.hpp @@ -21,7 +21,7 @@ template int N (hashtree tree); template bool is_nil (hashtree tree); template class hashtree_rep : concrete_struct { - hashmap> children; + hashmap > children; public: V label; @@ -100,10 +100,10 @@ template class hashtree { inline hashtree& operator= (hashtree x); // default constructor returns a non-NULL node, which does not have a value - inline hashtree () : rep (tm_new> ()) {} + inline hashtree () : rep (tm_new > ()) {} // returns a non-NULL node, that has value - inline hashtree (V val) : rep (tm_new> (val)) {} + inline hashtree (V val) : rep (tm_new > (val)) {} // returns this node's value inline hashtree_rep* operator->(void); diff --git a/Kernel/Containers/hashtree.ipp b/Kernel/Containers/hashtree.ipp index 20ed77a30..8939f1b53 100644 --- a/Kernel/Containers/hashtree.ipp +++ b/Kernel/Containers/hashtree.ipp @@ -82,7 +82,7 @@ template inline void hashtree::realize () { if (rep == NULL) { - rep= tm_new> (); + rep= tm_new > (); INC_COUNT (rep); } } diff --git a/Kernel/Containers/iterator.ipp b/Kernel/Containers/iterator.ipp index 95af1a6f8..12a2f4590 100644 --- a/Kernel/Containers/iterator.ipp +++ b/Kernel/Containers/iterator.ipp @@ -11,9 +11,9 @@ #ifndef ITERATOR_CC #define ITERATOR_CC -#include "iterator.hpp" #include "hashmap.hpp" #include "hashset.hpp" +#include "iterator.hpp" template int @@ -81,17 +81,17 @@ hashset_iterator_rep::next () { template iterator iterate (hashset h) { - return tm_new> (h); + return tm_new > (h); } // end hashset_iterator // hashmap_iterator template class hashmap_iterator_rep : public iterator_rep { - hashmap h; - int i; - list> l; - void spool (); + hashmap h; + int i; + list > l; + void spool (); public: hashmap_iterator_rep (hashmap h); @@ -132,7 +132,7 @@ hashmap_iterator_rep::next () { template iterator iterate (hashmap h) { - return tm_new> (h); + return tm_new > (h); } // hashmap_iterator diff --git a/Kernel/Containers/list.hpp b/Kernel/Containers/list.hpp index 50338abb3..9d3804284 100644 --- a/Kernel/Containers/list.hpp +++ b/Kernel/Containers/list.hpp @@ -135,13 +135,13 @@ template class list_rep : concrete_struct { CONCRETE_NULL_TEMPLATE_CODE (list, class, T); #define TMPL template TMPL inline list::list (T item) - : rep (tm_new> (item, list ())) {} + : rep (tm_new > (item, list ())) {} TMPL inline list::list (T item, list next) - : rep (tm_new> (item, next)) {} + : rep (tm_new > (item, next)) {} TMPL inline list::list (T item1, T item2, list next) - : rep (tm_new> (item1, list (item2, next))) {} + : rep (tm_new > (item1, list (item2, next))) {} TMPL inline list::list (T item1, T item2, T item3, list next) - : rep (tm_new> (item1, list (item2, item3, next))) {} + : rep (tm_new > (item1, list (item2, item3, next))) {} TMPL inline bool is_atom (list l) { return (!is_nil (l)) && is_nil (l->next); diff --git a/Kernel/Containers/list.ipp b/Kernel/Containers/list.ipp index 0e2597651..d9e34afec 100644 --- a/Kernel/Containers/list.ipp +++ b/Kernel/Containers/list.ipp @@ -40,7 +40,6 @@ list::operator[] (int i) { return rep->next[i - 1]; } - /****************************************************************************** * insertion and suppression ******************************************************************************/ diff --git a/Kernel/Containers/rel_hashmap.hpp b/Kernel/Containers/rel_hashmap.hpp index 411145661..9fd1eaa53 100644 --- a/Kernel/Containers/rel_hashmap.hpp +++ b/Kernel/Containers/rel_hashmap.hpp @@ -47,13 +47,13 @@ template class rel_hashmap_rep : concrete_struct { CONCRETE_NULL_TEMPLATE_2_CODE (rel_hashmap, class, T, class, U); #define TMPL template TMPL inline rel_hashmap::rel_hashmap (U init) - : rep (tm_new> (hashmap (init), - rel_hashmap ())) {} + : rep (tm_new > (hashmap (init), + rel_hashmap ())) {} TMPL inline rel_hashmap::rel_hashmap (hashmap item) - : rep (tm_new> (item, rel_hashmap ())) {} + : rep (tm_new > (item, rel_hashmap ())) {} TMPL inline rel_hashmap::rel_hashmap (hashmap item, rel_hashmap next) - : rep (tm_new> (item, next)) {} + : rep (tm_new > (item, next)) {} TMPL tm_ostream& operator<< (tm_ostream& out, rel_hashmap H); #undef TMPL diff --git a/Kernel/Containers/rel_hashmap.ipp b/Kernel/Containers/rel_hashmap.ipp index adefa91ff..75146d719 100644 --- a/Kernel/Containers/rel_hashmap.ipp +++ b/Kernel/Containers/rel_hashmap.ipp @@ -70,14 +70,14 @@ rel_hashmap_rep::merge () { template void rel_hashmap_rep::find_changes (hashmap& CH) { - int i; - rel_hashmap h (item, next); - list> remove; + int i; + rel_hashmap h (item, next); + list > remove; for (i= 0; i < CH->n; i++) { - list> l (CH->a[i]); + list > l (CH->a[i]); while (!is_nil (l)) { if (h[l->item.key] == l->item.im) - remove= list> (l->item, remove); + remove= list > (l->item, remove); l= l->next; } } @@ -90,13 +90,13 @@ rel_hashmap_rep::find_changes (hashmap& CH) { template void rel_hashmap_rep::find_differences (hashmap& CH) { - int i; - list> add; + int i; + list > add; for (i= 0; i < item->n; i++) { - list> l (item->a[i]); + list > l (item->a[i]); while (!is_nil (l)) { if (!CH->contains (l->item.key)) - add= list> (l->item, add); + add= list > (l->item, add); l= l->next; } } @@ -112,7 +112,7 @@ void rel_hashmap_rep::change (hashmap CH) { int i; for (i= 0; i < CH->n; i++) { - list> l (CH->a[i]); + list > l (CH->a[i]); while (!is_nil (l)) { item (l->item.key)= l->item.im; l = l->next; diff --git a/bin/format b/bin/format index 0fb9211f7..bf83c12f3 100755 --- a/bin/format +++ b/bin/format @@ -16,3 +16,4 @@ if (eq $platform:os windows) { clang-format --version clang-format -i **/*cpp clang-format -i **/*hpp +clang-format -i **/*ipp diff --git a/bin/test b/bin/test old mode 100644 new mode 100755 index 14f554861..04bb8007a --- a/bin/test +++ b/bin/test @@ -1,9 +1,14 @@ -set paths = [ - C:/Windows/System32 - $E:USERPROFILE/scoop/apps/mingw/current/bin - $E:USERPROFILE/scoop/shims - C:/hostedtoolcache/windows/xmake/2.8.1/x64 -] -echo $paths +#!/usr/bin/env elvish + +use platform + +if (eq $platform:os windows) { + set paths = [ + C:/Windows/System32 + $E:USERPROFILE/scoop/apps/mingw/current/bin + $E:USERPROFILE/scoop/shims + C:/hostedtoolcache/windows/xmake/2.8.1/x64 + ] +} xmake run --yes -vD --group=tests diff --git a/xmake.lua b/xmake.lua index fc48f9e85..8280dc566 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,9 +1,8 @@ set_project("lolly") +set_languages("c++17") set_allowedplats("linux", "macosx", "mingw", "wasm", "windows") -set_languages("c++17") - includes("check_cxxtypes.lua") configvar_check_cxxtypes("HAVE_INTPTR_T", "intptr_t", {includes = {"memory"}}) configvar_check_cxxtypes("HAVE_TIME_T", "time_t", {includes = {"memory"}}) @@ -55,7 +54,11 @@ local l1_includedirs = { target("liblolly") do set_kind("static") - set_languages("c++17") + if is_plat("mingw") then + set_languages("c++11") + else + set_languages("c++98") + end set_policy("check.auto_ignore_flags", false) set_basename("lolly")