From 0ea73247a8ba4036567a9dc28b6133d4b58507b3 Mon Sep 17 00:00:00 2001 From: foswret Date: Wed, 26 Nov 2025 09:54:00 -0600 Subject: added CFLAGS to Makefile, therefore cleaned up some errors --- 0.pdf | Bin 5492 -> 5500 bytes Makefile | 2 +- draw.c | 6 ++---- main.c | 18 ++++++++++-------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/0.pdf b/0.pdf index ac92d4d..a4a8dcc 100644 Binary files a/0.pdf and b/0.pdf differ diff --git a/Makefile b/Makefile index 8c6785c..a53e318 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ OBJS = draw.o main.o CAIROI = `pkg-config --cflags -libs cairo cairo-pdf` .PHONY: clean all -#CFLAGS = -O2 -g -Wall -Werror -Wextra -Winit-self -Wuninitialized -pedantic +CFLAGS = -O2 -g -Wall -Werror -Wextra -Winit-self -Wuninitialized -pedantic all: output diff --git a/draw.c b/draw.c index dc84bfe..51f9367 100644 --- a/draw.c +++ b/draw.c @@ -41,7 +41,7 @@ int draw_calendar(cairo_t *c, double x, double y, struct dimensions d) { int draw_numbers(cairo_t *c, double x, double y, struct dimensions d, int wd, int nd) { - char str[3]; + char str[20]; cairo_text_extents_t te; cairo_font_extents_t fe; @@ -51,7 +51,6 @@ int draw_numbers(cairo_t *c, double x, double y, struct dimensions d, int wd, in int iterative = 0; cairo_font_extents (c, &fe); - double yi = y; double xi = x; int current_weekday = wd; x = d.m + (wd * d.bw); @@ -59,7 +58,7 @@ int draw_numbers(cairo_t *c, double x, double y, struct dimensions d, int wd, in y = y + d.bh - ((d.bh - fe.ascent) / 2); for (int k = current_weekday; k < d.c; k++) { if (iterative < nd) { - sprintf(str, "%d", iterative + 1); + snprintf(str, sizeof(str), "%d", iterative + 1); cairo_text_extents (c, str, &te); double box_margins = (d.bw - te.width) / 2; @@ -85,7 +84,6 @@ int draw_month_name(cairo_t *c, char *name, struct dimensions d) { double x, y = d.m; cairo_set_font_size(c, 1.0); cairo_text_extents_t te; - cairo_font_extents_t fe; cairo_text_extents(c, name, &te); x = (d.pw / 2) - (te.width / 2); y = 1.5; diff --git a/main.c b/main.c index 282fcb9..51fb86d 100644 --- a/main.c +++ b/main.c @@ -17,7 +17,8 @@ #include "draw.h" -int main (int argc, char *argv[]) { +// int main (int argc, char *argv[]) { +int main (void) { /* Dimension initialization */ int rows = 5; /* Number of weeks in a month */ int columns = 7; /* Number of days in a week */ @@ -52,14 +53,15 @@ int main (int argc, char *argv[]) { "November", "December" }; - int days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - const char *weekday_names[] = { - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" - }; + //int days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + // const char *weekday_names[] = { + // "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" + // }; - const char *weekdays_abbr[] = { - "Su", "Mo", "Tue", "Wed", "Thurs", "Fri", "Sat" - }; + // const char *weekdays_abbr[] = { + // "Su", "Mo", "Tue", "Wed", "Thurs", "Fri", "Sat" + // }; int year = 2025; int month = 2; -- cgit v1.2.3