Skip to content

Commit de34b51

Browse files
author
Ashkan Ghassemi
committed
fixes an issue which caused an extra space to be printed after day number indicator when highlighted current day was friday. closes ashkang#1
1 parent 2154c99 commit de34b51

File tree

7 files changed

+61
-76
lines changed

7 files changed

+61
-76
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ test_kit/jyinfo
4848
test_kit/leap
4949
test_kit/sec_converter
5050
docs/genpages.sh
51+
sources/compile

sources/libjalali/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ libjalali_la_SOURCES = jalali.c jtime.c
1414
# compatible (have not removed a function from the API, for
1515
# example...)
1616

17-
libjalali_la_LDFLAGS = -version-info 0:2:0
17+
libjalali_la_LDFLAGS = -version-info 0:5:0
1818
includedir= $(prefix)/include/jalali
1919
include_HEADERS = jalali.h jtime.h jconfig.h
2020
INCLUDES = -I. -I@includedir@

sources/libjalali/jalali.c

+12-20
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ extern char* tzname[2];
4646
* The current 2820 year period started in the year AP 475 (AD 1096).
4747
*/
4848

49-
int
50-
jalali_is_jleap(int year)
49+
int jalali_is_jleap(int year)
5150
{
5251
int pr = year;
5352

@@ -110,8 +109,7 @@ jalali_is_jleap(int year)
110109
* Creates absolute values for day, hour, minute and seconds from time_t.
111110
* Values are signed integers.
112111
*/
113-
void
114-
jalali_create_time_from_secs(time_t t, struct ab_jtm* d)
112+
void jalali_create_time_from_secs(time_t t, struct ab_jtm* d)
115113
{
116114
d->ab_days = (t >= 0) ? (t / (time_t) J_DAY_LENGTH_IN_SECONDS) :
117115
((t - (time_t) J_DAY_LENGTH_IN_SECONDS + (time_t) 1) /
@@ -137,8 +135,7 @@ jalali_create_time_from_secs(time_t t, struct ab_jtm* d)
137135
* Creates a timestamp from day, hour, minute and seconds.
138136
* Values are signed integers.
139137
*/
140-
time_t
141-
jalali_create_secs_from_time(const struct ab_jtm* d)
138+
time_t jalali_create_secs_from_time(const struct ab_jtm* d)
142139
{
143140
return (time_t)
144141
((time_t) d->ab_days * (time_t) J_DAY_LENGTH_IN_SECONDS +
@@ -152,8 +149,7 @@ jalali_create_secs_from_time(const struct ab_jtm* d)
152149
* Alters only tm_mday and tm_mon.
153150
* Zero on success, -1 on failure.
154151
*/
155-
int
156-
jalali_create_date_from_days(struct jtm* j)
152+
int jalali_create_date_from_days(struct jtm* j)
157153
{
158154
int p = j->tm_yday;
159155
if (p > 365 || p < 0)
@@ -179,8 +175,7 @@ jalali_create_date_from_days(struct jtm* j)
179175
/*
180176
* Calculate day of year (0-365) based on month and day.
181177
*/
182-
int
183-
jalali_create_days_from_date(struct jtm* j)
178+
int jalali_create_days_from_date(struct jtm* j)
184179
{
185180
int p = 0;
186181
int i;
@@ -207,8 +202,7 @@ jalali_create_days_from_date(struct jtm* j)
207202
* 3. Passed and remaining leap years in grand leap cycle. -pl, -rl
208203
* 4. Absolute passed leap years since grand leap cycle epoch (AP 475). -apl
209204
*/
210-
void
211-
jalali_get_jyear_info(struct jyinfo* year)
205+
void jalali_get_jyear_info(struct jyinfo* year)
212206
{
213207
int y = year->y;
214208
year->lf = jalali_is_jleap(year->y);
@@ -245,8 +239,7 @@ jalali_get_jyear_info(struct jyinfo* year)
245239
* Calculates date (Jalali) based on difference factor from UTC Epoch by days.
246240
* 0 means 1 January 1970 (11 Dey 1348).
247241
*/
248-
void
249-
jalali_get_date(int p, struct jtm* j)
242+
void jalali_get_date(int p, struct jtm* j)
250243
{
251244
time_t t;
252245
struct tm lt;
@@ -304,8 +297,7 @@ jalali_get_date(int p, struct jtm* j)
304297
/*
305298
* Calculates UTC epoch difference of a desired date by measure of days.
306299
*/
307-
int
308-
jalali_get_diff(const struct jtm* j)
300+
int jalali_get_diff(const struct jtm* j)
309301
{
310302
int p = 0;
311303
int i;
@@ -349,8 +341,8 @@ jalali_get_diff(const struct jtm* j)
349341
/*
350342
* Updates a jalali date struct fields based on tm_year, tm_mon and tm_mday
351343
*/
352-
void
353-
jalali_update(struct jtm* jtm) {
344+
void jalali_update(struct jtm* jtm)
345+
{
354346
int d;
355347

356348
jalali_create_days_from_date(jtm);
@@ -362,8 +354,8 @@ jalali_update(struct jtm* jtm) {
362354
* Displays a jalali date struct fields.
363355
* should be used for debugging purposes only.
364356
*/
365-
void
366-
jalali_show_time(const struct jtm* j) {
357+
void jalali_show_time(const struct jtm* j)
358+
{
367359
printf("%d/%02d/%02d (%02d:%02d:%02d) [%d]",
368360
j->tm_year, j->tm_mon + 1, j->tm_mday, j->tm_hour, j->tm_min,
369361
j->tm_sec, j->tm_wday);

sources/libjalali/jtime.c

+36-32
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ static struct jtm in_jtm;
6767

6868
extern char* tzname[2];
6969

70-
void
71-
in_jasctime(const struct jtm* jtm, char* buf) {
70+
void in_jasctime(const struct jtm* jtm, char* buf)
71+
{
7272
if (!jtm)
7373
return;
7474

@@ -96,8 +96,8 @@ in_jasctime(const struct jtm* jtm, char* buf) {
9696
}
9797
}
9898

99-
void
100-
in_jlocaltime(const time_t* timep, struct jtm* result) {
99+
void in_jlocaltime(const time_t* timep, struct jtm* result)
100+
{
101101
if (!timep)
102102
return;
103103

@@ -143,8 +143,8 @@ in_jlocaltime(const time_t* timep, struct jtm* result) {
143143
memcpy(&in_jtm, &c_jtm, sizeof(struct jtm));
144144
}
145145

146-
void
147-
in_jctime(const time_t* timep, char* buf) {
146+
void in_jctime(const time_t* timep, char* buf)
147+
{
148148
if (!timep)
149149
return;
150150

@@ -159,8 +159,8 @@ in_jctime(const time_t* timep, char* buf) {
159159
}
160160
}
161161

162-
void
163-
in_jgmtime(const time_t* timep, struct jtm* result) {
162+
void in_jgmtime(const time_t* timep, struct jtm* result)
163+
{
164164
if (!timep)
165165
return;
166166

@@ -191,43 +191,43 @@ in_jgmtime(const time_t* timep, struct jtm* result) {
191191
memcpy(&in_jtm, &c_jtm, sizeof(struct jtm));
192192
}
193193

194-
char*
195-
jasctime(const struct jtm* jtm) {
194+
char* jasctime(const struct jtm* jtm)
195+
{
196196
if (!jtm)
197197
return 0;
198198

199199
in_jasctime(jtm, 0);
200200
return in_buf;
201201
}
202202

203-
char*
204-
jctime(const time_t* timep) {
203+
char* jctime(const time_t* timep)
204+
{
205205
if (!timep)
206206
return 0;
207207

208208
in_jctime(timep, 0);
209209
return in_buf;
210210
}
211211

212-
struct jtm*
213-
jgmtime(const time_t* timep) {
212+
struct jtm* jgmtime(const time_t* timep)
213+
{
214214
if (!timep)
215215
return 0;
216216
in_jgmtime(timep, 0);
217217
return &in_jtm;
218218
}
219219

220-
struct jtm*
221-
jlocaltime(const time_t* timep) {
220+
struct jtm* jlocaltime(const time_t* timep)
221+
{
222222
if (!timep)
223223
return 0;
224224

225225
in_jlocaltime(timep, 0);
226226
return &in_jtm;
227227
}
228228

229-
time_t
230-
jmktime(const struct jtm* jtm) {
229+
time_t jmktime(const struct jtm* jtm)
230+
{
231231
if (!jtm)
232232
return (time_t) (-1);
233233
tzset();
@@ -242,8 +242,8 @@ jmktime(const struct jtm* jtm) {
242242
return t;
243243
}
244244

245-
size_t
246-
jstrftime(char* s, size_t max, const char* format, const struct jtm* jtm) {
245+
size_t jstrftime(char* s, size_t max, const char* format, const struct jtm* jtm)
246+
{
247247
if (!s || max <= 0 || !format || !jtm)
248248
return -1;
249249

@@ -641,8 +641,8 @@ jstrftime(char* s, size_t max, const char* format, const struct jtm* jtm) {
641641
return rb;
642642
}
643643

644-
char*
645-
jstrptime(const char* s, const char* format, struct jtm* jtm) {
644+
char* jstrptime(const char* s, const char* format, struct jtm* jtm)
645+
{
646646
char buf[MAX_BUF_SIZE];
647647
char delim[MAX_BUF_SIZE];
648648

@@ -844,8 +844,8 @@ jstrptime(const char* s, const char* format, struct jtm* jtm) {
844844
return (char*) &s[s_s];
845845
}
846846

847-
char*
848-
jasctime_r(const struct jtm* jtm, char* buf) {
847+
char* jasctime_r(const struct jtm* jtm, char* buf)
848+
{
849849
if (!jtm || !buf)
850850
return 0;
851851

@@ -854,8 +854,8 @@ jasctime_r(const struct jtm* jtm, char* buf) {
854854
return in_buf;
855855
}
856856

857-
struct jtm*
858-
jlocaltime_r(const time_t* timep, struct jtm* result) {
857+
struct jtm* jlocaltime_r(const time_t* timep, struct jtm* result)
858+
{
859859
if (!timep || !result)
860860
return 0;
861861

@@ -864,8 +864,8 @@ jlocaltime_r(const time_t* timep, struct jtm* result) {
864864
return &in_jtm;
865865
}
866866

867-
struct jtm*
868-
jgmtime_r(const time_t* timep, struct jtm* result) {
867+
struct jtm* jgmtime_r(const time_t* timep, struct jtm* result)
868+
{
869869
if (!timep || !result)
870870
return 0;
871871

@@ -874,8 +874,8 @@ jgmtime_r(const time_t* timep, struct jtm* result) {
874874
return &in_jtm;
875875
}
876876

877-
char*
878-
jctime_r(const time_t* timep, char* buf) {
877+
char* jctime_r(const time_t* timep, char* buf)
878+
{
879879
if (!timep || !buf)
880880
return 0;
881881

@@ -890,8 +890,12 @@ jctime_r(const time_t* timep, char* buf) {
890890
* jalali_to_farsi() converts an integer's digits to Arabic-Indic
891891
* padding works just like printf() field width.
892892
*/
893-
int jalali_to_farsi(char* buf, size_t n, int padding, char* pad,
894-
int d) {
893+
int jalali_to_farsi(char* buf,
894+
size_t n,
895+
int padding,
896+
char* pad,
897+
int d)
898+
{
895899
char _buf[100] = {0};
896900
int i=0, j=0;
897901
int p = 0;

sources/src/jcal.c

+5-10
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ int is_in_margin(struct cal_layout* l,
148148
* @Should not be used directly. (See display_cal())
149149
*/
150150

151-
void show_cal_matrix(struct cal_layout* l,
152-
struct cal_matrix* mat)
151+
void show_cal_matrix(struct cal_layout* l, struct cal_matrix* mat)
153152
{
154153
int i, j, m;
155154
char buf[100];
@@ -264,8 +263,7 @@ void show_cal_matrix(struct cal_layout* l,
264263
* and height according to number of calendars.
265264
*/
266265

267-
void create_cal_matrix(struct cal_layout* l,
268-
struct cal_matrix* mat)
266+
void create_cal_matrix(struct cal_layout* l, struct cal_matrix* mat)
269267
{
270268
mat->width = (mat->n * 7) + ((mat->n - 1) * l->margin) ;
271269
mat->height = 6;
@@ -407,8 +405,7 @@ void show_cal(struct cal_layout* l,
407405
* screen according to a given jalali date.
408406
*/
409407

410-
void show_3(struct cal_layout* l,
411-
struct jtm* j)
408+
void show_3(struct cal_layout* l, struct jtm* j)
412409
{
413410
struct jtm** _j;
414411
struct cal_matrix m;
@@ -451,8 +448,7 @@ void show_3(struct cal_layout* l,
451448
* Displays a calendar on standard screen according to a given jalali date.
452449
*/
453450

454-
void show_1(struct cal_layout* l,
455-
struct jtm* j)
451+
void show_1(struct cal_layout* l, struct jtm* j)
456452
{
457453
struct jtm** _j;
458454
struct cal_matrix m;
@@ -476,8 +472,7 @@ void show_1(struct cal_layout* l,
476472
* to a given jalali date.
477473
*/
478474

479-
void show_year(struct cal_layout* l,
480-
struct jtm* j)
475+
void show_year(struct cal_layout* l, struct jtm* j)
481476
{
482477
struct jtm _j[4];
483478

sources/src/jcal.h

+5-10
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,20 @@ int is_in_margin(struct cal_layout* l,
5555
struct cal_matrix* mat,
5656
int c);
5757

58-
void show_cal_matrix(struct cal_layout* l,
59-
struct cal_matrix* mat);
58+
void show_cal_matrix(struct cal_layout* l, struct cal_matrix* mat);
6059

61-
void create_cal_matrix(struct cal_layout* l,
62-
struct cal_matrix* mat);
60+
void create_cal_matrix(struct cal_layout* l, struct cal_matrix* mat);
6361

6462
void destroy_cal_matrix(struct cal_matrix* mat);
6563

6664
void show_cal(struct cal_layout* l,
6765
struct cal_matrix* m,
6866
struct jtm** _j);
6967

70-
void show_3(struct cal_layout* l,
71-
struct jtm* j);
68+
void show_3(struct cal_layout* l, struct jtm* j);
7269

73-
void show_1(struct cal_layout* l,
74-
struct jtm* j);
70+
void show_1(struct cal_layout* l, struct jtm* j);
7571

76-
void show_year(struct cal_layout* l,
77-
struct jtm* j);
72+
void show_year(struct cal_layout* l, struct jtm* j);
7873

7974
#endif /* JCAL_H */

sources/src/jdate.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ extern char* optarg;
4444
* otherwise: st_atime (last access time)
4545
*/
4646

47-
int mod_time(const char* path,
48-
time_t* t,
49-
int a)
47+
int mod_time(const char* path, time_t* t, int a)
5048
{
5149
struct stat st;
5250
int err;

0 commit comments

Comments
 (0)