Skip to content

Commit

Permalink
space->tab indent
Browse files Browse the repository at this point in the history
  • Loading branch information
superg committed Dec 2, 2022
1 parent 517f6be commit 970546a
Show file tree
Hide file tree
Showing 23 changed files with 978 additions and 983 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ project(${REDUMPER_PROJECT_NAME} VERSION "${REDUMPER_VERSION_MAJOR}.${REDUMPER_V

# build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the build type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the build type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
endif()
set(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE INTERNAL "Active configuration" FORCE)

Expand Down Expand Up @@ -58,14 +58,14 @@ add_definitions(-DFMT_HEADER_ONLY)

# Visual Studio settings
if(MSVC)
# build MT configuration by default
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")

# multithreaded build
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
# build MT configuration by default
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")

# multithreaded build
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")

add_definitions(-D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -D_NTSCSI_USER_MODE_)

Expand Down
15 changes: 5 additions & 10 deletions cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@



//DEBUG
#include <iostream>



namespace gpsxre
{

static const uint32_t READ_CD_C2_SIZES[] =
{
0,
CD_C2_SIZE,
2 + CD_C2_SIZE,
0
0,
CD_C2_SIZE,
2 + CD_C2_SIZE,
0
};

static const uint32_t READ_CD_SUB_SIZES[] =
Expand Down Expand Up @@ -278,7 +273,7 @@ SPTD::Status cmd_get_configuration(SPTD &sptd)
(uint8_t *)fds + sizeof(GET_CONFIGURATION_FeatureDescriptor) <= fds_end &&
(uint8_t *)fds + sizeof(GET_CONFIGURATION_FeatureDescriptor) + fds->additional_length <= fds_end; fds = (GET_CONFIGURATION_FeatureDescriptor *)((uint8_t *)fds + sizeof(GET_CONFIGURATION_FeatureDescriptor) + fds->additional_length))
{
std::cout << endian_swap(fds->feature_code) << std::endl;
// std::cout << endian_swap(fds->feature_code) << std::endl;
}

return status;
Expand Down
160 changes: 80 additions & 80 deletions common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,126 +31,126 @@ std::string normalize_string(const std::string &s)

std::vector<std::string> tokenize(const std::string &str, const char *delimiters, const char *quotes)
{
std::vector<std::string> tokens;

std::set<char> delimiter;
for(auto d = delimiters; *d != '\0'; ++d)
delimiter.insert(*d);

bool in = false;
std::string::const_iterator s;
for(auto it = str.begin(); it < str.end(); ++it)
{
if(in)
{
// quoted
if(quotes != nullptr && *s == quotes[0])
{
if(*it == quotes[1])
{
++s;
tokens.emplace_back(s, it);
in = false;
}
}
// unquoted
else
{
if(delimiter.find(*it) != delimiter.end())
{
tokens.emplace_back(s, it);
in = false;
}
}
}
else
{
if(delimiter.find(*it) == delimiter.end())
{
s = it;
in = true;
}
}
}

// remaining entry
if(in)
tokens.emplace_back(s, str.end());

return tokens;
std::vector<std::string> tokens;

std::set<char> delimiter;
for(auto d = delimiters; *d != '\0'; ++d)
delimiter.insert(*d);

bool in = false;
std::string::const_iterator s;
for(auto it = str.begin(); it < str.end(); ++it)
{
if(in)
{
// quoted
if(quotes != nullptr && *s == quotes[0])
{
if(*it == quotes[1])
{
++s;
tokens.emplace_back(s, it);
in = false;
}
}
// unquoted
else
{
if(delimiter.find(*it) != delimiter.end())
{
tokens.emplace_back(s, it);
in = false;
}
}
}
else
{
if(delimiter.find(*it) == delimiter.end())
{
s = it;
in = true;
}
}
}

// remaining entry
if(in)
tokens.emplace_back(s, str.end());

return tokens;
}


std::string str_uppercase(const std::string &str)
{
std::string str_uc;
std::transform(str.begin(), str.end(), std::back_inserter(str_uc), [](unsigned char c) { return std::toupper(c); });
std::string str_uc;
std::transform(str.begin(), str.end(), std::back_inserter(str_uc), [](unsigned char c) { return std::toupper(c); });

return str_uc;
return str_uc;
}


void replace_all_occurences(std::string &str, const std::string &from, const std::string &to)
{
for(size_t pos = 0; (pos = str.find(from, pos)) != std::string::npos; pos += to.length())
str.replace(pos, from.length(), to);
for(size_t pos = 0; (pos = str.find(from, pos)) != std::string::npos; pos += to.length())
str.replace(pos, from.length(), to);
}


std::vector<std::pair<int32_t, int32_t>> string_to_ranges(const std::string &str)
{
std::vector<std::pair<int32_t, int32_t>> ranges;
std::vector<std::pair<int32_t, int32_t>> ranges;

std::istringstream iss(str);
for(std::string range; std::getline(iss, range, ':'); )
{
std::istringstream range_ss(range);
std::istringstream iss(str);
for(std::string range; std::getline(iss, range, ':'); )
{
std::istringstream range_ss(range);

std::pair<int32_t, int32_t> r;
std::pair<int32_t, int32_t> r;

std::string s;
std::getline(range_ss, s, '-');
r.first = stoi(s);
std::getline(range_ss, s, '-');
r.second = stoi(s) + 1;
std::string s;
std::getline(range_ss, s, '-');
r.first = stoi(s);
std::getline(range_ss, s, '-');
r.second = stoi(s) + 1;

ranges.push_back(r);
}
ranges.push_back(r);
}

return ranges;
return ranges;
}


std::string ranges_to_string(const std::vector<std::pair<int32_t, int32_t>> &ranges)
{
std::string str;
std::string str;

for(auto const &r : ranges)
str += fmt::format("{}-{}:", r.first, r.second - 1);
for(auto const &r : ranges)
str += fmt::format("{}-{}:", r.first, r.second - 1);

if(!str.empty())
str.pop_back();
if(!str.empty())
str.pop_back();

return str;
return str;
}


const std::pair<int32_t, int32_t> *inside_range(int32_t lba, const std::vector<std::pair<int32_t, int32_t>> &ranges)
{
for(auto const &r : ranges)
if(lba >= r.first && lba < r.second)
return &r;
for(auto const &r : ranges)
if(lba >= r.first && lba < r.second)
return &r;

return nullptr;
return nullptr;
}


std::string system_date_time(std::string fmt)
{
auto time_now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::stringstream ss;
ss << std::put_time(localtime(&time_now), fmt.c_str());
return ss.str();
auto time_now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::stringstream ss;
ss << std::put_time(localtime(&time_now), fmt.c_str());
return ss.str();
}

}
10 changes: 5 additions & 5 deletions common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace gpsxre
template <typename T, size_t N>
constexpr size_t countof(T(&)[N])
{
return N;
return N;
}

template <typename T, class = typename std::enable_if_t<std::is_unsigned_v<T>>>
Expand All @@ -49,21 +49,21 @@ constexpr T round_up_pow2(T value, T multiple)
template <typename T, typename U, class = typename std::enable_if_t<std::is_unsigned_v<U>>>
constexpr T scale(T value, U multiple)
{
assert(multiple);
assert(multiple);
T sign = value > 0 ? +1 : (value < 0 ? -1 : 0);
return (value - sign) / (T)multiple + sign;
return (value - sign) / (T)multiple + sign;
}

template <typename T, typename U, class = typename std::enable_if_t<std::is_unsigned_v<U>>>
constexpr T round_up(T value, U multiple)
{
return scale(value, multiple) * (T)multiple;
return scale(value, multiple) * (T)multiple;
}

template <typename T, typename U, class = typename std::enable_if_t<std::is_unsigned_v<U>>>
constexpr T round_down(T value, U multiple)
{
return value / (T)multiple * (T)multiple;
return value / (T)multiple * (T)multiple;
}

template<typename T, class = typename std::enable_if_t<std::is_unsigned_v<T>>>
Expand Down
Loading

0 comments on commit 970546a

Please sign in to comment.