Skip to content

Commit

Permalink
1.0.2 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Baurens and abaurens committed Dec 17, 2024
1 parent 98a416d commit 713ae98
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
38 changes: 23 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: abaurens <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/12/03 03:51:56 by abaurens #+# #+# #
# Updated: 2024/12/04 13:57:47 by abaurens ### ########.fr #
# Updated: 2024/12/05 22:00:12 by abaurens ### ########.fr #
# #
# **************************************************************************** #

Expand All @@ -15,10 +15,11 @@ RM := rm -rf
CP := cp -rf
LINKER := gcc -o

CVERSION := c99

NAME := select

CVERSION := ansi
OPTI_LVL := 3

SRCD := src
OBJD := obj

Expand All @@ -33,36 +34,43 @@ OBJS := $(addprefix $(OBJD)/,$(SRCS:.c=.o))
SRCS := $(addprefix $(SRCD)/,$(SRCS))
INCDEPS := $(INCDEPS) $(OBJS:.o=.d)

INCLUDES := ./include
INCLUDES := $(addprefix -I,$(INCLUDES))


DEFINES := _GNU_SOURCE \
VERSION="\"$(shell git describe --tag)\n\""
DEFINES := $(addprefix -D,$(DEFINES))

OPTI_LVL := 3

CFLAGS := -std=$(CVERSION) -MMD -MP -I./include -W -Wall -Wextra -pedantic $(DEFINES)
CFLAGS := -MMD -MP -W -Wall -Wextra -pedantic $(INCLUDES) $(DEFINES)
LDFLAGS := -lncurses -ltinfo


ifeq ($(strip $(CVERSION)), ansi)
CFLAGS := -ansi $(CFLAGS)
else
CFLAGS := -std=$(CVERSION) $(CFLAGS)
endif

AIO := false
ifeq ($(strip $(AIO)), true)
# Optimize for binary size and force static linkage
OPTI_LVL := s
LDFLAGS := -static $(LDFLAGS)
OPTI_LVL := s
LDFLAGS := -static $(LDFLAGS)
endif

DEBUG := false
ifeq ($(strip $(DEBUG)), true)
# Optimize for debugging and enable debug symbols
OPTI_LVL := g
CFLAGS := $(CFLAGS) -g
OPTI_LVL := g
CFLAGS := $(CFLAGS) -g
else
# Optimize for speed and enable no tollerance mode on warnings
CFLAGS := $(CFLAGS) -Werror
CFLAGS := $(CFLAGS) -Werror
endif

CFLAGS := -O$(OPTI_LVL) $(CFLAGS)

all: $(NAME)

$(NAME): $(OBJS)
$(LINKER) $(NAME) $(OBJS) $(LDFLAGS)

Expand All @@ -79,6 +87,6 @@ fclean:
$(RM) $(OBJD)
$(RM) $(NAME)

re: fclean all
re: fclean $(NAME)

.PHONY: all clean fclean re debug
.PHONY: clean fclean re debug
4 changes: 2 additions & 2 deletions include/select.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
enum e_exit_codes
{
EX_SUCCESS,
EX_CANCLED,
EX_CANCELLED,
EX_ERROR,
EX_PARSING_ERROR,
EX_ALLOCATION_ERROR
Expand All @@ -22,7 +22,7 @@ typedef enum
{
WAITING,
VALIDATED,
CANCLED
CANCELLED
} t_app_status;


Expand Down
2 changes: 1 addition & 1 deletion src/UI.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ t_app_status present(t_entry *entries, int entry_count)
clear();
column_count = calc_max_column_count(entries, entry_count);
if (g_settings.column_count > 0 && g_settings.column_count < column_count)
column_count = column_count;
column_count = g_settings.column_count;

column_width = COLS / column_count;

Expand Down
2 changes: 1 addition & 1 deletion src/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ t_app_status process_event(t_entry *entries, int entry_count, int column_count,
{
case 'q':
case 33:
return CANCLED;
return CANCELLED;

case '\n':
case KEY_ENTER:
Expand Down
6 changes: 4 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "settings.h"

#include <string.h>
#include <stdlib.h>

t_settings g_settings;

Expand Down Expand Up @@ -42,8 +43,9 @@ int main(int ac, char **av)
if (!entries)
fatal_error(EX_ALLOCATION_ERROR, NULL);

if (present(entries, entry_count) == CANCLED)
return EX_CANCLED;
if (present(entries, entry_count) == CANCELLED)
return EX_CANCELLED;
print_selection(entries, entry_count);
free(entries);
return EX_SUCCESS;
}

0 comments on commit 713ae98

Please sign in to comment.