Skip to content

Commit

Permalink
reformat core code
Browse files Browse the repository at this point in the history
  • Loading branch information
scholarsmate committed Nov 21, 2023
1 parent 5a58de9 commit c0d8c5c
Show file tree
Hide file tree
Showing 22 changed files with 599 additions and 515 deletions.
14 changes: 8 additions & 6 deletions core/src/include/omega_edit/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#ifndef OMEGA_EDIT_CONFIG_H
#define OMEGA_EDIT_CONFIG_H

#include <omega_edit/features.h> // this header is generated at build time
#include <fcntl.h>
#include <omega_edit/features.h>// this header is generated at build time

#ifdef __cplusplus

Expand Down Expand Up @@ -57,7 +57,7 @@
#define OMEGA_BYTE_T unsigned char
#endif//OMEGA_BYTE_T

#if !defined(__CYGWIN__) && \
#if !defined(__CYGWIN__) && \
(defined(WIN32) || defined(_WIN32) || defined(__WIN32) || defined(_WIN64) || defined(_MSC_BUILD))
/** Define if building for Windows */
#define OMEGA_BUILD_WINDOWS
Expand All @@ -79,17 +79,19 @@
#ifdef _MSC_VER
#include <io.h>
// For MSVC, use _sopen_s
static inline int safe_open_(const char* filename, int oflag, int pmode) {
static inline int safe_open_(const char *filename, int oflag, int pmode) {
int fd;
_sopen_s(&fd, filename, oflag | _O_BINARY, _SH_DENYWR, pmode);
return fd;
}
#else

// For other compilers/platforms, fall back to open
static inline int safe_open_(const char* filename, int oflag, int pmode) {
static inline int safe_open_(const char *filename, int oflag, int pmode) {
// Note: The mode only applies if O_CREAT is part of oflag
return open(filename, oflag, pmode);
}

#endif

/**
Expand All @@ -105,8 +107,8 @@ static inline int safe_open_(const char* filename, int oflag, int pmode) {
* @param mode mode to open the file in
* @return opened file pointer
*/
static inline FILE* safe_fopen_(const char* filename, const char* mode) {
FILE* file;
static inline FILE *safe_fopen_(const char *filename, const char *mode) {
FILE *file;
#ifdef HAVE_FOPEN_S
// Use fopen_s where supported
fopen_s(&file, filename, mode);
Expand Down
1 change: 1 addition & 0 deletions core/src/include/omega_edit/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @file features.h
* @brief Features that are available on the current platform.
* @warning Dummy file to satisfy IDEs. A real version is generated at build time.
* @info To ignore changes to this file, use: git update-index --assume-unchanged core/src/include/omega_edit/features.h
*/

#ifndef OMEGA_EDIT_FEATURES_H
Expand Down
4 changes: 2 additions & 2 deletions core/src/include/omega_edit/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int omega_util_paths_equivalent(char const *path1, char const *path2);
* @param path2 second path
* @return 0 if the contents are equal, 1 if the contents are not equal, or -1 if an error occurred opening the file at path1 or -2 if an error occurred opening the file at path2
*/
int omega_util_compare_files(const char* path1, const char* path2);
int omega_util_compare_files(const char *path1, const char *path2);

/**
* Compare the modification times of two files
Expand Down Expand Up @@ -149,7 +149,7 @@ char *omega_util_available_filename(char const *path, char *buffer);
* Given a path, which must exist, returns an absolute path that has no symbolic link, dot, or dot-dot elements
* @param path path to get the absolute path of
* @param buffer pointer to memory to hold the file extension (allocated to at least FILENAME_MAX) or could be NULL, in which case an internal static buffer will be used
* @return absolute path that has no symbolic link, dot, or dot-dot elements
* @return absolute path that has no symbolic link, dot, or dot-dot path elements
*/
char *omega_util_normalize_path(char const *path, char *buffer);

Expand Down
8 changes: 6 additions & 2 deletions core/src/include/omega_edit/fwd_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ typedef enum {
#define ORIGINAL_MODIFIED (-100)

/** Mask types */
typedef enum { MASK_AND, MASK_OR, MASK_XOR } omega_mask_kind_t;
typedef enum {
MASK_AND, MASK_OR, MASK_XOR
} omega_mask_kind_t;

/** Byte order mark (BOM) types */
typedef enum { BOM_UNKNOWN = 0, BOM_NONE, BOM_UTF8, BOM_UTF16LE, BOM_UTF16BE, BOM_UTF32LE, BOM_UTF32BE } omega_bom_t;
typedef enum {
BOM_UNKNOWN = 0, BOM_NONE, BOM_UTF8, BOM_UTF16LE, BOM_UTF16BE, BOM_UTF32LE, BOM_UTF32BE
} omega_bom_t;

/** Opaque character counts */
typedef struct omega_character_counts_struct omega_character_counts_t;
Expand Down
1 change: 1 addition & 0 deletions core/src/include/omega_edit/stl_string_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ int64_t omega_edit_overwrite_string(omega_session_t *session_ptr, int64_t offset
*/
std::string omega_session_get_segment_string(const omega_session_t *session_ptr, int64_t offset,
int64_t length) noexcept;

/**
* Create a search context
* @param session_ptr session to find patterns in
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib/change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ int64_t omega_change_get_serial(const omega_change_t *change_ptr) {
static inline const omega_byte_t *change_bytes_(const omega_change_t *change_ptr) {
assert(change_ptr);
return (omega_change_get_kind(change_ptr) != change_kind_t::CHANGE_DELETE)
? omega_data_get_data_const(&change_ptr->data, change_ptr->length)
: nullptr;
? omega_data_get_data_const(&change_ptr->data, change_ptr->length)
: nullptr;
}

const omega_byte_t *omega_change_get_bytes(const omega_change_t *change_ptr) {
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib/check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ int omega_check_model(const omega_session_t *session_ptr) {
assert(session_ptr);
int64_t expected_offset = 0;
if (!session_ptr->models_.empty()) {
for (auto &&model_ptr : session_ptr->models_) {
for (auto &&model_ptr: session_ptr->models_) {
assert(model_ptr);
for (const auto &segment : model_ptr->model_segments) {
for (const auto &segment: model_ptr->model_segments) {
assert(segment->change_ptr);
if (expected_offset != segment->computed_offset ||
(segment->change_offset + segment->computed_length) > segment->change_ptr->length) {
Expand Down
Loading

0 comments on commit c0d8c5c

Please sign in to comment.