Skip to content

Commit

Permalink
Apply and enforce astyle (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
zcsahok authored Sep 13, 2023
1 parent d3ab00d commit 5fa4733
Show file tree
Hide file tree
Showing 26 changed files with 201 additions and 156 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci-build-ubuntu-20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get -qq update
sudo apt-get install -y libhamlib-dev libxmlrpc-core-c3-dev libcmocka-dev python3-pexpect
sudo apt-get install -y libhamlib-dev libxmlrpc-core-c3-dev libcmocka-dev python3-pexpect astyle
- name: Set up datadir
run: mkdir datadir && ln -s $PWD/share datadir/tlf
- name: Check source formatting
run: |
F=$(astyle --dry-run --formatted --options=tools/astylerc src/*.[ch])
if [ ! -z "$F" ] ; then sed -e 's/^F/To be f/' <<< $F; exit 1; fi
- name: Autoreconf and basic make
run: |
autoreconf -i && ./configure --datadir=$PWD/datadir && make -j2
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get -qq update
sudo apt-get install -y libhamlib-dev libxmlrpc-core-c3-dev libcmocka-dev python3-pexpect python3-dev
sudo apt-get install -y libhamlib-dev libxmlrpc-core-c3-dev libcmocka-dev python3-pexpect python3-dev astyle
- name: Set up datadir
run: mkdir datadir && ln -s $PWD/share datadir/tlf
- name: Check source formatting
run: |
F=$(astyle --dry-run --formatted --options=tools/astylerc src/*.[ch])
if [ ! -z "$F" ] ; then sed -e 's/^F/To be f/' <<< $F; exit 1; fi
- name: Autoreconf and basic make
run: |
autoreconf -i && ./configure --datadir=$PWD/datadir && make -j2
Expand Down
8 changes: 4 additions & 4 deletions src/addspot.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void add_local_spot(void) {
static struct qso_t *find_last_qso() {
int i = NR_QSOS;
while (i > 0) {
struct qso_t *last_qso = g_ptr_array_index(qso_array, i-1);
struct qso_t *last_qso = g_ptr_array_index(qso_array, i - 1);
if (!last_qso->is_comment) {
return last_qso;
}
Expand Down Expand Up @@ -154,7 +154,7 @@ static gchar *prepare_spot(void) {
freq_t spot_freq;
if (get_spot_data(&spot_call, &spot_freq)) {
spot_line = g_strdup_printf("DX %.1f %s ", spot_freq / 1000.,
spot_call);
spot_call);
g_free(spot_call);
} else {
beep();
Expand Down Expand Up @@ -206,7 +206,7 @@ static bool complete_spot(gchar **line) {
wmove(stdscr, LINES - 1, strlen(buffer) + 2);
}

g_free (*line);
g_free(*line);
*line = g_strdup(buffer);

return c != ESCAPE;
Expand All @@ -225,5 +225,5 @@ void add_cluster_spot(void) {
g_free(line);
}
}
g_free (spot_line);
g_free(spot_line);
}
54 changes: 27 additions & 27 deletions src/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ static void sr_start(void);
void sr_stop();

void sound_setup_default(void) {
if (vk_record_cmd) g_free (vk_record_cmd);
if (vk_record_cmd) g_free(vk_record_cmd);
vk_record_cmd = g_strdup("rec -r 8000 $1 -q");

if (vk_play_cmd) g_free (vk_play_cmd);
if (vk_play_cmd) g_free(vk_play_cmd);
vk_play_cmd = g_strdup("play_vk $1");

if (soundlog_record_cmd) g_free (soundlog_record_cmd);
if (soundlog_record_cmd) g_free(soundlog_record_cmd);
soundlog_record_cmd = g_strdup("soundlog");

if (soundlog_play_cmd) g_free (soundlog_play_cmd);
if (soundlog_play_cmd) g_free(soundlog_play_cmd);
soundlog_play_cmd = g_strdup("play -q $1 2> /dev/null");

if (soundlog_dir) g_free (soundlog_dir);
if (soundlog_dir) g_free(soundlog_dir);
soundlog_dir = g_strdup("./soundlogs");
}

Expand All @@ -91,7 +91,7 @@ void sound_setup_default(void) {
*/
bool is_sr_running() {
char *lockfile = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S,
".VRlock", NULL);
".VRlock", NULL);
bool exists = (access(lockfile, F_OK) == 0);
g_free(lockfile);
return exists;
Expand All @@ -110,7 +110,7 @@ static void recordmenue(void) {
mvaddstr(6, 20, "F1 ... F12, S, C: Record Messages");

mvprintw(9, 20, "1; %s contest recorder",
is_sr_running() ? "Stop" : "Start");
is_sr_running() ? "Stop" : "Start");

mvaddstr(10, 20, "2: List and Play contest file");
mvaddstr(12, 20, "ESC: Exit sound recorder function");
Expand Down Expand Up @@ -273,10 +273,10 @@ static char *expand_directory(const char *dir) {
}

/* strip audio file suffix */
static char* strip_suffix(char * filename) {
static char *strip_suffix(char *filename) {
GRegex *regex = g_regex_new("\\.au$", 0, 0, NULL);
char *stripped_name = g_regex_replace(regex, filename, -1 , 0,
"", 0, NULL);
char *stripped_name = g_regex_replace(regex, filename, -1, 0,
"", 0, NULL);
g_regex_unref(regex);
return stripped_name;
}
Expand Down Expand Up @@ -312,7 +312,7 @@ static int sr_listfiles() {
g_free(printname);

i += 10;
if (i > 60) {
if (i > 60) {
i = 10;
j++;
}
Expand Down Expand Up @@ -340,8 +340,8 @@ static void sr_start(void) {
IGNORE(system("echo " " > ~/.VRlock"));

char *command = g_strconcat("mkdir -p ", soundlog_dir, "; ",
"cd ", soundlog_dir, "; ",
soundlog_record_cmd, " >/dev/null 2>/dev/null &", NULL);
"cd ", soundlog_dir, "; ",
soundlog_record_cmd, " >/dev/null 2>/dev/null &", NULL);

IGNORE(system(command));
g_free(command);
Expand All @@ -360,15 +360,15 @@ void sr_stop() {
static char *prepare_playback_command(char *filename) {
char *file = g_strconcat(filename, ".au", NULL);

GRegex *regex = g_regex_new("\\$1", 0, 0 , NULL);
GRegex *regex = g_regex_new("\\$1", 0, 0, NULL);
char *play_command = g_regex_replace(regex, soundlog_play_cmd, -1, 0,
file, 0, NULL);
g_regex_unref(regex);
file, 0, NULL);
g_regex_unref(regex);
g_free(file);

char *full_command = g_strconcat("cd ", soundlog_dir, "; ",
play_command, NULL);
g_free (play_command);
play_command, NULL);
g_free(play_command);

return full_command;
}
Expand All @@ -384,14 +384,14 @@ static void vk_do_record(int message_nr) {
move(17, 20);
refreshp();

GRegex *regex = g_regex_new("\\$1", 0, 0 , NULL);
GRegex *regex = g_regex_new("\\$1", 0, 0, NULL);
char *command = g_regex_replace(regex, vk_record_cmd, -1, 0,
ph_message[message_nr], 0, NULL);
ph_message[message_nr], 0, NULL);
g_regex_unref(regex);

/* let the command run in background so we can stop recording by
* <esc> key later */
char *reccommand = g_strconcat( command, " &", NULL);
char *reccommand = g_strconcat(command, " &", NULL);

IGNORE(system(reccommand));
g_free(command);
Expand All @@ -413,11 +413,11 @@ void *play_thread(void *ptr) {

pthread_detach(pthread_self());

vk_running=true;
vk_running = true;

GRegex *regex = g_regex_new("\\$1", 0, 0, NULL);
char *playcommand = g_regex_replace(regex, vk_play_cmd, -1, 0,
audiofile, 0, NULL);
audiofile, 0, NULL);
g_regex_unref(regex);
g_free(ptr);

Expand All @@ -441,7 +441,7 @@ void *play_thread(void *ptr) {
netkeyer(K_PTT, "0"); // ptt off
}

vk_running= false;
vk_running = false;

return NULL;
}
Expand All @@ -467,8 +467,8 @@ void vk_play_file(char *audiofile) {

/* play sound in separate thread so it can be killed from the main one */
if (pthread_create(&vk_thread, NULL, play_thread, (void *)file) != 0) {
g_free(file);
TLF_LOG_INFO("could not start sound thread!");
g_free(file);
TLF_LOG_INFO("could not start sound thread!");
}
}

Expand All @@ -480,7 +480,7 @@ void vk_stop() {

/* check if playing VK message is finished */
bool is_vk_finished() {
return (vk_running == false);
return (vk_running == false);
}


10 changes: 5 additions & 5 deletions src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

#include <stdbool.h>

extern char* vk_record_cmd;
extern char* vk_play_cmd;
extern char* soundlog_record_cmd;
extern char* soundlog_play_cmd;
extern char* soundlog_dir;
extern char *vk_record_cmd;
extern char *vk_play_cmd;
extern char *soundlog_record_cmd;
extern char *soundlog_play_cmd;
extern char *soundlog_dir;

void sound_setup_default(void);
void record(void);
Expand Down
4 changes: 2 additions & 2 deletions src/checklogfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ void checklogfile(void) {
fputs(inputbuffer, outfile);
}
}
if (inputbuffer != NULL)
free(inputbuffer);
if (inputbuffer != NULL)
free(inputbuffer);
fclose(infile);
fclose(outfile);
}
Expand Down
3 changes: 3 additions & 0 deletions src/cw_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@

#include <glib.h>

// *INDENT-OFF*

#define CW_SPEEDS "06121416182022242628303234363840424446485060"
/*< speed string with 2 chars each (in WPM) */

// *INDENT-ON*

char speedstr[50] = CW_SPEEDS;
int speed = 10;
Expand Down
Loading

0 comments on commit 5fa4733

Please sign in to comment.