Revision: 75942
http://sourceforge.net/p/brlcad/code/75942
Author: starseeker
Date: 2020-05-26 20:56:38 +0000 (Tue, 26 May 2020)
Log Message:
-----------
HACKING says headers should be .h but the footer.sh tool recognizes hpp. Go
with .h for now - wonder if HACKING should go with .hpp so we can distinguish C
and C++ header files?
Modified Paths:
--------------
brlcad/trunk/src/libged/which.cpp
Added Paths:
-----------
brlcad/trunk/src/libged/alphanum.h
Removed Paths:
-------------
brlcad/trunk/src/libged/alphanum.hpp
Copied: brlcad/trunk/src/libged/alphanum.h (from rev 75941,
brlcad/trunk/src/libged/alphanum.hpp)
===================================================================
--- brlcad/trunk/src/libged/alphanum.h (rev 0)
+++ brlcad/trunk/src/libged/alphanum.h 2020-05-26 20:56:38 UTC (rev 75942)
@@ -0,0 +1,134 @@
+#ifndef ALPHANUM__HPP
+#define ALPHANUM__HPP
+
+/*
+ The Alphanum Algorithm is an improved sorting algorithm for strings
+ containing numbers. Instead of sorting numbers in ASCII order like a
+ standard sort, this algorithm sorts numbers in numeric order.
+
+ The Alphanum Algorithm is discussed at http://www.DaveKoelle.com
+
+ This implementation is Copyright (c) 2008 Dirk Jagdmann <[email protected]>.
+ It is a cleanroom implementation of the algorithm and not derived by
+ other's works. In contrast to the versions written by Dave Koelle this
+ source code is distributed with the libpng/zlib license.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you
+ must not claim that you wrote the original software. If you use
+ this software in a product, an acknowledgment in the product
+ documentation would be appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and
+ must not be misrepresented as being the original software.
+
+ 3. This notice may not be removed or altered from any source
+ distribution.
+
+Source:
+https://github.com/facontidavide/PlotJuggler/blob/master/include/PlotJuggler/alphanum.hpp
+
+Simplified down to the essential sorting comparison of C strings
+
+*/
+
+#include "common.h"
+
+#include <cassert>
+#include <functional>
+#include <string>
+#include <sstream>
+#include <cctype>
+
+/**
+ compare l and r with strcmp() semantics, but using
+ the "Alphanum Algorithm". This function is designed to read
+ through the l and r strings only one time, for
+ maximum performance. It does not allocate memory for
+ substrings. It can either use the C-library functions isdigit()
+ and atoi() to honour your locale settings, when recognizing
+ digit characters when you "#define ALPHANUM_LOCALE=1" or use
+ it's own digit character handling which only works with ASCII
+ digit characters, but provides better performance.
+
+ @param l NULL-terminated C-style string
+ @param r NULL-terminated C-style string
+ @return negative if l<r, 0 if l equals r, positive if l>r
+ */
+int alphanum_impl(const char *l, const char *r, void *UNUSED(arg))
+{
+ enum alphanum_mode_t { STRING, NUMBER } mode=STRING;
+
+ while(*l && *r)
+ {
+ if(mode == STRING)
+ {
+ char l_char, r_char;
+ while((l_char=*l) && (r_char=*r))
+ {
+ // check if this are digit characters
+ const bool l_digit=isdigit(l_char), r_digit=isdigit(r_char);
+ // if both characters are digits, we continue in NUMBER mode
+ if(l_digit && r_digit)
+ {
+ mode=NUMBER;
+ break;
+ }
+ // if only the left character is a digit, we have a result
+ if(l_digit) return -1;
+ // if only the right character is a digit, we have a result
+ if(r_digit) return +1;
+ // compute the difference of both characters
+ const int diff=l_char - r_char;
+ // if they differ we have a result
+ if(diff != 0) return diff;
+ // otherwise process the next characters
+ ++l;
+ ++r;
+ }
+ }
+ else // mode==NUMBER
+ {
+ // get the left number
+ char *end;
+ unsigned long l_int=strtoul(l, &end, 0);
+ l=end;
+
+ // get the right number
+ unsigned long r_int=strtoul(r, &end, 0);
+ r=end;
+
+ // if the difference is not equal to zero, we have a comparison
result
+ const long diff=l_int-r_int;
+ if(diff != 0)
+ return diff;
+
+ // otherwise we process the next substring in STRING mode
+ mode=STRING;
+ }
+ }
+
+ if(*r) return -1;
+ if(*l) return +1;
+ return 0;
+}
+
+
+#endif
+
+
+// Local Variables:
+// tab-width: 8
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: t
+// c-file-style: "stroustrup"
+// End:
+// ex: shiftwidth=4 tabstop=8
Deleted: brlcad/trunk/src/libged/alphanum.hpp
===================================================================
--- brlcad/trunk/src/libged/alphanum.hpp 2020-05-26 20:53:53 UTC (rev
75941)
+++ brlcad/trunk/src/libged/alphanum.hpp 2020-05-26 20:56:38 UTC (rev
75942)
@@ -1,134 +0,0 @@
-#ifndef ALPHANUM__HPP
-#define ALPHANUM__HPP
-
-/*
- The Alphanum Algorithm is an improved sorting algorithm for strings
- containing numbers. Instead of sorting numbers in ASCII order like a
- standard sort, this algorithm sorts numbers in numeric order.
-
- The Alphanum Algorithm is discussed at http://www.DaveKoelle.com
-
- This implementation is Copyright (c) 2008 Dirk Jagdmann <[email protected]>.
- It is a cleanroom implementation of the algorithm and not derived by
- other's works. In contrast to the versions written by Dave Koelle this
- source code is distributed with the libpng/zlib license.
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you
- must not claim that you wrote the original software. If you use
- this software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
- 2. Altered source versions must be plainly marked as such, and
- must not be misrepresented as being the original software.
-
- 3. This notice may not be removed or altered from any source
- distribution.
-
-Source:
-https://github.com/facontidavide/PlotJuggler/blob/master/include/PlotJuggler/alphanum.hpp
-
-Simplified down to the essential sorting comparison of C strings
-
-*/
-
-#include "common.h"
-
-#include <cassert>
-#include <functional>
-#include <string>
-#include <sstream>
-#include <cctype>
-
-/**
- compare l and r with strcmp() semantics, but using
- the "Alphanum Algorithm". This function is designed to read
- through the l and r strings only one time, for
- maximum performance. It does not allocate memory for
- substrings. It can either use the C-library functions isdigit()
- and atoi() to honour your locale settings, when recognizing
- digit characters when you "#define ALPHANUM_LOCALE=1" or use
- it's own digit character handling which only works with ASCII
- digit characters, but provides better performance.
-
- @param l NULL-terminated C-style string
- @param r NULL-terminated C-style string
- @return negative if l<r, 0 if l equals r, positive if l>r
- */
-int alphanum_impl(const char *l, const char *r, void *UNUSED(arg))
-{
- enum alphanum_mode_t { STRING, NUMBER } mode=STRING;
-
- while(*l && *r)
- {
- if(mode == STRING)
- {
- char l_char, r_char;
- while((l_char=*l) && (r_char=*r))
- {
- // check if this are digit characters
- const bool l_digit=isdigit(l_char), r_digit=isdigit(r_char);
- // if both characters are digits, we continue in NUMBER mode
- if(l_digit && r_digit)
- {
- mode=NUMBER;
- break;
- }
- // if only the left character is a digit, we have a result
- if(l_digit) return -1;
- // if only the right character is a digit, we have a result
- if(r_digit) return +1;
- // compute the difference of both characters
- const int diff=l_char - r_char;
- // if they differ we have a result
- if(diff != 0) return diff;
- // otherwise process the next characters
- ++l;
- ++r;
- }
- }
- else // mode==NUMBER
- {
- // get the left number
- char *end;
- unsigned long l_int=strtoul(l, &end, 0);
- l=end;
-
- // get the right number
- unsigned long r_int=strtoul(r, &end, 0);
- r=end;
-
- // if the difference is not equal to zero, we have a comparison
result
- const long diff=l_int-r_int;
- if(diff != 0)
- return diff;
-
- // otherwise we process the next substring in STRING mode
- mode=STRING;
- }
- }
-
- if(*r) return -1;
- if(*l) return +1;
- return 0;
-}
-
-
-#endif
-
-
-// Local Variables:
-// tab-width: 8
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: t
-// c-file-style: "stroustrup"
-// End:
-// ex: shiftwidth=4 tabstop=8
Modified: brlcad/trunk/src/libged/which.cpp
===================================================================
--- brlcad/trunk/src/libged/which.cpp 2020-05-26 20:53:53 UTC (rev 75941)
+++ brlcad/trunk/src/libged/which.cpp 2020-05-26 20:56:38 UTC (rev 75942)
@@ -34,7 +34,7 @@
#include "bu/opt.h"
#include "bu/vls.h"
-#include "./alphanum.hpp"
+#include "./alphanum.h"
#include "./ged_private.h"
bool alphanum_cmp(const std::string& a, const std::string& b) {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits