Compare commits
No commits in common. "4ef7c9edf7e37c41712520a1b4acf3b490094629" and "e17c5e20830b36b03a0adf8c6c7d1fee31e594d0" have entirely different histories.
4ef7c9edf7
...
e17c5e2083
@ -3,8 +3,7 @@ cmake_minimum_required (VERSION 3.1)
|
|||||||
project (sdn VERSION 0.1 LANGUAGES CXX)
|
project (sdn VERSION 0.1 LANGUAGES CXX)
|
||||||
|
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||||
set (CMAKE_CXX_FLAGS
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
|
||||||
"${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-misleading-indentation -pedantic")
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Since we use a language with slow compilers, let's at least use a fast linker
|
# Since we use a language with slow compilers, let's at least use a fast linker
|
||||||
|
12
Makefile
12
Makefile
@ -1,19 +1,19 @@
|
|||||||
.POSIX:
|
.POSIX:
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
CXXFLAGS = -g -std=c++14 -Wall -Wextra -Wno-misleading-indentation -pedantic
|
CXXFLAGS = -g -std=c++14 -Wall -Wextra -pedantic
|
||||||
CPPFLAGS = `sed -ne '/^project (\([^ )]*\) VERSION \([^ )]*\).*/ \
|
CPPFLAGS = `sed -ne '/^project (\([^ )]*\) VERSION \([^ )]*\).*/ \
|
||||||
s//-DPROJECT_NAME="\1" -DPROJECT_VERSION="\2"/p' CMakeLists.txt`
|
s//-DPROJECT_NAME="\1" -DPROJECT_VERSION="\2"/p' CMakeLists.txt`
|
||||||
|
|
||||||
sdn: sdn.cpp CMakeLists.txt
|
sdn: sdn.cpp CMakeLists.txt
|
||||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o $@ \
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o sdn \
|
||||||
-lacl `pkg-config --libs --cflags ncursesw`
|
-lacl `pkg-config --libs --cflags ncursesw`
|
||||||
sdn-static: sdn.cpp CMakeLists.txt
|
static: sdn.cpp CMakeLists.txt
|
||||||
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o $@ \
|
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $< -o sdn \
|
||||||
-static-libstdc++ \
|
-static-libstdc++ \
|
||||||
-Wl,--start-group,-Bstatic \
|
-Wl,--start-group,-Bstatic \
|
||||||
-lacl `pkg-config --static --libs --cflags ncursesw` \
|
-lacl `pkg-config --static --libs --cflags ncursesw` \
|
||||||
-Wl,--end-group,-Bdynamic
|
-Wl,--end-group,-Bdynamic
|
||||||
clean:
|
clean:
|
||||||
rm -f sdn sdn-static
|
rm -f sdn
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: static clean
|
||||||
|
10
sdn.cpp
10
sdn.cpp
@ -93,8 +93,8 @@ fun to_mb (const wstring &wide) -> string {
|
|||||||
return mb;
|
return mb;
|
||||||
}
|
}
|
||||||
|
|
||||||
fun prefix_length (const wstring &in, const wstring &of) -> size_t {
|
fun prefix_length (const wstring &in, const wstring &of) -> int {
|
||||||
size_t score = 0;
|
int score = 0;
|
||||||
for (size_t i = 0; i < of.size () && in.size () >= i && in[i] == of[i]; i++)
|
for (size_t i = 0; i < of.size () && in.size () >= i && in[i] == of[i]; i++)
|
||||||
score++;
|
score++;
|
||||||
return score;
|
return score;
|
||||||
@ -1008,10 +1008,10 @@ fun show_help () {
|
|||||||
fun search (const wstring &needle, int push) -> int {
|
fun search (const wstring &needle, int push) -> int {
|
||||||
int best = g.cursor, best_n = 0, matches = 0, step = push != 0 ? push : 1;
|
int best = g.cursor, best_n = 0, matches = 0, step = push != 0 ? push : 1;
|
||||||
for (int i = 0, count = g.entries.size (); i < count; i++) {
|
for (int i = 0, count = g.entries.size (); i < count; i++) {
|
||||||
int o = (g.cursor + (count + i * step) + (count + push)) % count;
|
auto o = (g.cursor + (count + i * step) + (count + push)) % count;
|
||||||
size_t n = prefix_length (to_wide (g.entries[o].filename), needle);
|
int n = prefix_length (to_wide (g.entries[o].filename), needle);
|
||||||
matches += n == needle.size ();
|
matches += n == needle.size ();
|
||||||
if (n > (size_t) best_n) {
|
if (n > best_n) {
|
||||||
best = o;
|
best = o;
|
||||||
best_n = n;
|
best_n = n;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user