Skip to content

Commit 4d0d71f

Browse files
authored
0.2.3
1 parent 9370902 commit 4d0d71f

File tree

3 files changed

+18
-34
lines changed

3 files changed

+18
-34
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333

3434
# If this run was triggered by a pull request event, then checkout
3535
# the head of the pull request instead of the merge commit.
36-
- run: git checkout HEAD^2
37-
if: ${{ github.event_name == 'pull_request' }}
36+
# - run: git checkout HEAD^2
37+
# if: ${{ github.event_name == 'pull_request' }}
3838

3939
# Initializes the CodeQL tools for scanning.
4040
- name: Initialize CodeQL

README

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
<a href="https://www.codacy.com/manual/mcpcpc/kirc/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=mcpcpc/kirc&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/5616c0ed4b2f4209826038dbc270dbf5" alt="Codacy status"></a>
1919
</p>
2020

21-
<p align="center">
22-
<img src="https://raw.githubusercontent.com/mcpcpc/kirc/gh-pages/tty.gif" width="550">
23-
</p>
24-
2521
## Features
2622

2723
* Excellent cross-platform compatibility.

kirc.c

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <termios.h>
1414
#include <sys/ioctl.h>
1515

16-
#define VERSION "0.2.2" /* version */
16+
#define VERSION "0.2.3" /* version */
1717
#define AUTHORS "Michael Czigler" /* authors */
1818
#define MSG_MAX 512 /* max message length */
1919
#define CHA_MAX 200 /* max channel length */
@@ -162,22 +162,9 @@ static void abFree(struct abuf * ab) {
162162
free(ab->b);
163163
}
164164

165-
static size_t pstrlen(const char * s) {
166-
size_t len = 0, i = 0;
167-
while (s[i] != '\0') {
168-
if (s[i] == '\033') {
169-
i = strpbrk(s + i, "m") - s + 1;
170-
continue;
171-
}
172-
len++;
173-
i++;
174-
}
175-
return len;
176-
}
177-
178165
static void refreshLine(struct State * l) {
179166
char seq[64];
180-
size_t plen = pstrlen(l->prompt) + 2;
167+
size_t plen = strlen(l->prompt) + 2;
181168
int fd = STDOUT_FILENO;
182169
char * buf = l->buf;
183170
size_t len = l->len;
@@ -378,23 +365,33 @@ static int edit(struct State * l) {
378365
}
379366

380367
static void stateReset(struct State * l) {
381-
l->plen = pstrlen(l->prompt);
368+
l->plen = strlen(l->prompt);
382369
l->oldpos = 0;
383370
l->pos = 0;
384371
l->len = 0;
385372
l->buf[0] = '\0';
386373
l->buflen--;
387374
}
388375

376+
static char * ctime_now(char buf[26]) {
377+
struct tm tm_;
378+
time_t now = time(NULL);
379+
if (!asctime_r(localtime_r (&now, &tm_), buf))
380+
return NULL;
381+
*strchr(buf, '\n') = '\0';
382+
return buf;
383+
}
384+
389385
static void logAppend(char * str, char * path) {
390386
FILE * out;
387+
char buf[26];
391388

392389
if ((out = fopen(path, "a")) == NULL) {
393390
perror("fopen");
394391
exit(1);
395392
}
396-
397-
fprintf(out, "%s\n", str);
393+
ctime_now(buf);
394+
fprintf(out, "%s:%s", buf, str);
398395
fclose(out);
399396
}
400397

@@ -502,15 +499,6 @@ static void paramPrintJoin(struct Param * p) {
502499
printf(" [\x1b[33m%s\x1b[0m] ", p->channel);
503500
}
504501

505-
static char * ctime_now (char buf[26]) {
506-
struct tm tm_;
507-
time_t now = time(NULL);
508-
if (!asctime_r(localtime_r (&now, &tm_), buf))
509-
return NULL;
510-
*strchr(buf, '\n') = '\0';
511-
return buf;
512-
}
513-
514502
static void handleCTCP(const char * nickname, char * message) {
515503
if (message[0] != '\001' && strncmp(message, "ACTION", 6))
516504
return;
@@ -555,7 +543,7 @@ static void paramPrintChan(struct Param * p) {
555543
s = p->nicklen - strnlen(p->nickname, MSG_MAX);
556544
printf("%*s\x1b[33;1m%-.*s\x1b[0m ", s, "", p->nicklen, p->nickname);
557545
if (p->params) {
558-
printf(p->params);
546+
printf("%s", p->params);
559547
p->offset += strnlen(p->params, CHA_MAX);
560548
}
561549
}

0 commit comments

Comments
 (0)